|
|
@ -35,6 +35,7 @@ |
|
|
|
Cancel |
|
|
|
</button> |
|
|
|
</div> |
|
|
|
<PhotoDialog ref="photoDialog" /> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="flex justify-center"> |
|
|
@ -52,8 +53,10 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script lang="ts"> |
|
|
|
import axios from "axios"; |
|
|
|
import { Component, Vue } from "vue-facing-decorator"; |
|
|
|
|
|
|
|
import PhotoDialog from "@/components/PhotoDialog.vue"; |
|
|
|
import QuickNav from "@/components/QuickNav.vue"; |
|
|
|
import { |
|
|
|
DEFAULT_IMAGE_API_SERVER, |
|
|
@ -64,9 +67,8 @@ import { db } from "@/db/index"; |
|
|
|
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; |
|
|
|
import { getIdentity } from "@/libs/util"; |
|
|
|
import { accessToken } from "@/libs/crypto"; |
|
|
|
import axios from "axios"; |
|
|
|
|
|
|
|
@Component({ components: { QuickNav } }) |
|
|
|
@Component({ components: { PhotoDialog, QuickNav } }) |
|
|
|
export default class SharedPhotoView extends Vue { |
|
|
|
$notify!: (notification: NotificationIface, timeout?: number) => void; |
|
|
|
|
|
|
@ -123,15 +125,19 @@ export default class SharedPhotoView extends Vue { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
async recordProfile() { |
|
|
|
await this.sendToImageServer(IMAGE_TYPE_PROFILE).then((url) => { |
|
|
|
if (url) { |
|
|
|
recordProfile() { |
|
|
|
(this.$refs.photoDialog as PhotoDialog).open( |
|
|
|
async (imgUrl) => { |
|
|
|
db.settings.update(MASTER_SETTINGS_KEY, { |
|
|
|
profileImageUrl: url, |
|
|
|
profileImageUrl: imgUrl, |
|
|
|
}); |
|
|
|
this.$router.push({ name: "account" }); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
true, |
|
|
|
IMAGE_TYPE_PROFILE, |
|
|
|
this.imageBlob, |
|
|
|
this.imageFileName, |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
async cancel() { |
|
|
@ -159,16 +165,37 @@ export default class SharedPhotoView extends Vue { |
|
|
|
); |
|
|
|
formData.append("claimType", imageType); |
|
|
|
|
|
|
|
console.log( |
|
|
|
"Sending image to server", |
|
|
|
formData, |
|
|
|
headers, |
|
|
|
DEFAULT_IMAGE_API_SERVER + "/image", |
|
|
|
); |
|
|
|
const response = await axios.post( |
|
|
|
DEFAULT_IMAGE_API_SERVER + "/image", |
|
|
|
formData, |
|
|
|
{ headers }, |
|
|
|
); |
|
|
|
this.imageBlob = undefined; |
|
|
|
this.imageFileName = undefined; |
|
|
|
if (response?.data?.url) { |
|
|
|
this.imageBlob = undefined; |
|
|
|
this.imageFileName = undefined; |
|
|
|
result = response.data.url as string; |
|
|
|
} else { |
|
|
|
console.error("Problem uploading the image", response.data); |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|
group: "alert", |
|
|
|
type: "danger", |
|
|
|
title: "Error", |
|
|
|
text: |
|
|
|
"There was a problem saving the picture. " + |
|
|
|
(response?.data?.message || ""), |
|
|
|
}, |
|
|
|
5000, |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
this.uploading = false; |
|
|
|
result = response.data.url as string; |
|
|
|
} catch (error) { |
|
|
|
console.error("Error uploading the image", error); |
|
|
|
this.$notify( |
|
|
@ -176,7 +203,7 @@ export default class SharedPhotoView extends Vue { |
|
|
|
group: "alert", |
|
|
|
type: "danger", |
|
|
|
title: "Error", |
|
|
|
text: "There was an error saving the picture. Please try again.", |
|
|
|
text: "There was an error saving the picture.", |
|
|
|
}, |
|
|
|
5000, |
|
|
|
); |
|
|
|