|
@ -1,15 +1,14 @@ |
|
|
<template> |
|
|
<template> |
|
|
<!-- CONTENT --> |
|
|
<div v-if="visible" class="dialog-overlay"> |
|
|
<section id="Content" class="p-6 pb-24 max-w-3xl mx-auto"> |
|
|
|
|
|
<!-- Breadcrumb --> |
|
|
<!-- Breadcrumb --> |
|
|
<div class="mb-8"> |
|
|
<div class="dialog"> |
|
|
<!-- Back --> |
|
|
<!-- Back --> |
|
|
<div class="text-lg text-center font-light relative px-7"> |
|
|
<div class="text-lg text-center font-light relative px-7"> |
|
|
<h1 |
|
|
<h1 |
|
|
class="text-lg text-center px-2 py-1 absolute -left-2 -top-1" |
|
|
class="text-lg text-center px-2 py-1 absolute -right-2 -top-1" |
|
|
@click="$router.back()" |
|
|
@click="close()" |
|
|
> |
|
|
> |
|
|
<fa icon="chevron-left" class="fa-fw"></fa> |
|
|
<fa icon="xmark" class="fa-fw"></fa> |
|
|
</h1> |
|
|
</h1> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
@ -19,7 +18,6 @@ |
|
|
<span v-else-if="blob"> Look Good? </span> |
|
|
<span v-else-if="blob"> Look Good? </span> |
|
|
<span v-else> Say "Cheese"! </span> |
|
|
<span v-else> Say "Cheese"! </span> |
|
|
</h1> |
|
|
</h1> |
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<div v-if="uploading" class="flex justify-center"> |
|
|
<div v-if="uploading" class="flex justify-center"> |
|
|
<fa icon="spinner" class="fa-spin fa-3x text-center block" /> |
|
|
<fa icon="spinner" class="fa-spin fa-3x text-center block" /> |
|
@ -58,7 +56,8 @@ |
|
|
</div> |
|
|
</div> |
|
|
</camera> |
|
|
</camera> |
|
|
</div> |
|
|
</div> |
|
|
</section> |
|
|
</div> |
|
|
|
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script lang="ts"> |
|
|
<script lang="ts"> |
|
@ -73,12 +72,14 @@ import { MASTER_SETTINGS_KEY, Settings } from "@/db/tables/settings"; |
|
|
import { accessToken } from "@/libs/crypto"; |
|
|
import { accessToken } from "@/libs/crypto"; |
|
|
|
|
|
|
|
|
@Component({ components: { Camera } }) |
|
|
@Component({ components: { Camera } }) |
|
|
export default class GiftedPhoto extends Vue { |
|
|
export default class GiftedPhotoDialog extends Vue { |
|
|
$notify!: (notification: NotificationIface, timeout?: number) => void; |
|
|
$notify!: (notification: NotificationIface, timeout?: number) => void; |
|
|
|
|
|
|
|
|
activeDid = ""; |
|
|
activeDid = ""; |
|
|
blob: Blob | null = null; |
|
|
blob: Blob | null = null; |
|
|
|
|
|
setImage: (arg: string) => void = () => {}; |
|
|
uploading = false; |
|
|
uploading = false; |
|
|
|
|
|
visible = false; |
|
|
|
|
|
|
|
|
URL = window.URL || window.webkitURL; |
|
|
URL = window.URL || window.webkitURL; |
|
|
|
|
|
|
|
@ -102,6 +103,16 @@ export default class GiftedPhoto extends Vue { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
open(setImageFn: (arg: string) => void) { |
|
|
|
|
|
this.visible = true; |
|
|
|
|
|
this.setImage = setImageFn; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
close() { |
|
|
|
|
|
this.visible = false; |
|
|
|
|
|
this.blob = null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
async takeImage(/* payload: MouseEvent */) { |
|
|
async takeImage(/* payload: MouseEvent */) { |
|
|
const cameraComponent = this.$refs.camera as InstanceType<typeof Camera>; |
|
|
const cameraComponent = this.$refs.camera as InstanceType<typeof Camera>; |
|
|
this.blob = await cameraComponent?.snapshot(); // png is default; if that changes, change extension in formData.append |
|
|
this.blob = await cameraComponent?.snapshot(); // png is default; if that changes, change extension in formData.append |
|
@ -145,7 +156,7 @@ export default class GiftedPhoto extends Vue { |
|
|
this.uploading = false; |
|
|
this.uploading = false; |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
formData.append("image", this.blob, "snapshot.png"); |
|
|
formData.append("image", this.blob, "snapshot.png"); // png is set in snapshot() |
|
|
formData.append("claimType", "GiveAction"); |
|
|
formData.append("claimType", "GiveAction"); |
|
|
try { |
|
|
try { |
|
|
const response = await axios.post( |
|
|
const response = await axios.post( |
|
@ -155,10 +166,9 @@ export default class GiftedPhoto extends Vue { |
|
|
); |
|
|
); |
|
|
this.uploading = false; |
|
|
this.uploading = false; |
|
|
|
|
|
|
|
|
// we won't give a notification here because the user will be taken back to finish |
|
|
this.visible = false; |
|
|
|
|
|
this.blob = null; |
|
|
localStorage.setItem("imageUrl", response.data.url as string); |
|
|
this.setImage(response.data.url as string); |
|
|
this.$router.back(); |
|
|
|
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
console.error("Error uploading the image", error); |
|
|
console.error("Error uploading the image", error); |
|
|
this.$notify( |
|
|
this.$notify( |
|
@ -176,3 +186,26 @@ export default class GiftedPhoto extends Vue { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<style> |
|
|
|
|
|
.dialog-overlay { |
|
|
|
|
|
position: fixed; |
|
|
|
|
|
top: 0; |
|
|
|
|
|
left: 0; |
|
|
|
|
|
right: 0; |
|
|
|
|
|
bottom: 0; |
|
|
|
|
|
background-color: rgba(0, 0, 0, 0.5); |
|
|
|
|
|
display: flex; |
|
|
|
|
|
justify-content: center; |
|
|
|
|
|
align-items: center; |
|
|
|
|
|
padding: 1.5rem; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.dialog { |
|
|
|
|
|
background-color: white; |
|
|
|
|
|
padding: 1rem; |
|
|
|
|
|
border-radius: 0.5rem; |
|
|
|
|
|
width: 100%; |
|
|
|
|
|
max-width: 700px; |
|
|
|
|
|
} |
|
|
|
|
|
</style> |