forked from trent_larson/crowd-funder-for-time-pwa
make the photo show in a pop-up dialog
This commit is contained in:
@@ -2,4 +2,5 @@
|
||||
|
||||
# this won't resolve as a URL on production; it's a URN only found in the test system
|
||||
VUE_APP_BVC_MEETUPS_PROJECT_CLAIM_ID=https://endorser.ch/entity/01HNTZYJJXTGT0EZS3VEJGX7AK
|
||||
VUE_APP_DEFAULT_ENDORSER_API_SERVER=http://localhost:3000
|
||||
VUE_APP_DEFAULT_IMAGE_API_SERVER=http://localhost:3001
|
||||
|
||||
@@ -14,12 +14,10 @@ tasks :
|
||||
- .2 list the "show more" contacts alphabetically
|
||||
|
||||
- 32 image on give :
|
||||
- send image type (eg. portrait, give, project)
|
||||
- upload to a public readable place at correct hosting location
|
||||
- remove previous image when editing
|
||||
- on gift details, if project then show, otherwise mark "gift for you"
|
||||
- ping endpoint
|
||||
- limits endpoint
|
||||
- upload a photo from elsewhere
|
||||
- go-live - create cert for new image domain, set up haproxy redirect
|
||||
|
||||
- 08 image on profile
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
</div>
|
||||
<input
|
||||
type="number"
|
||||
class="border border-r-0 border-slate-400 px-2 py-2 text-center"
|
||||
class="border border-r-0 border-slate-400 px-2 py-2 text-center w-20"
|
||||
v-model="amountInput"
|
||||
/>
|
||||
<div
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
<template>
|
||||
<!-- CONTENT -->
|
||||
<section id="Content" class="p-6 pb-24 max-w-3xl mx-auto">
|
||||
<div v-if="visible" class="dialog-overlay">
|
||||
<!-- Breadcrumb -->
|
||||
<div class="mb-8">
|
||||
<div class="dialog">
|
||||
<!-- Back -->
|
||||
<div class="text-lg text-center font-light relative px-7">
|
||||
<h1
|
||||
class="text-lg text-center px-2 py-1 absolute -left-2 -top-1"
|
||||
@click="$router.back()"
|
||||
class="text-lg text-center px-2 py-1 absolute -right-2 -top-1"
|
||||
@click="close()"
|
||||
>
|
||||
<fa icon="chevron-left" class="fa-fw"></fa>
|
||||
<fa icon="xmark" class="fa-fw"></fa>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
@@ -19,7 +18,6 @@
|
||||
<span v-else-if="blob"> Look Good? </span>
|
||||
<span v-else> Say "Cheese"! </span>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div v-if="uploading" class="flex justify-center">
|
||||
<fa icon="spinner" class="fa-spin fa-3x text-center block" />
|
||||
@@ -58,7 +56,8 @@
|
||||
</div>
|
||||
</camera>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
@@ -73,12 +72,14 @@ import { MASTER_SETTINGS_KEY, Settings } from "@/db/tables/settings";
|
||||
import { accessToken } from "@/libs/crypto";
|
||||
|
||||
@Component({ components: { Camera } })
|
||||
export default class GiftedPhoto extends Vue {
|
||||
export default class GiftedPhotoDialog extends Vue {
|
||||
$notify!: (notification: NotificationIface, timeout?: number) => void;
|
||||
|
||||
activeDid = "";
|
||||
blob: Blob | null = null;
|
||||
setImage: (arg: string) => void = () => {};
|
||||
uploading = false;
|
||||
visible = false;
|
||||
|
||||
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 */) {
|
||||
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
|
||||
@@ -145,7 +156,7 @@ export default class GiftedPhoto extends Vue {
|
||||
this.uploading = false;
|
||||
return;
|
||||
}
|
||||
formData.append("image", this.blob, "snapshot.png");
|
||||
formData.append("image", this.blob, "snapshot.png"); // png is set in snapshot()
|
||||
formData.append("claimType", "GiveAction");
|
||||
try {
|
||||
const response = await axios.post(
|
||||
@@ -155,10 +166,9 @@ export default class GiftedPhoto extends Vue {
|
||||
);
|
||||
this.uploading = false;
|
||||
|
||||
// we won't give a notification here because the user will be taken back to finish
|
||||
|
||||
localStorage.setItem("imageUrl", response.data.url as string);
|
||||
this.$router.back();
|
||||
this.visible = false;
|
||||
this.blob = null;
|
||||
this.setImage(response.data.url as string);
|
||||
} catch (error) {
|
||||
console.error("Error uploading the image", error);
|
||||
this.$notify(
|
||||
@@ -176,3 +186,26 @@ export default class GiftedPhoto extends Vue {
|
||||
}
|
||||
}
|
||||
</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>
|
||||
@@ -92,12 +92,6 @@ const routes: Array<RouteRecordRaw> = [
|
||||
/* webpackChunkName: "gifted-details" */ "../views/GiftedDetails.vue"
|
||||
),
|
||||
},
|
||||
{
|
||||
path: "/gifted-photo",
|
||||
name: "gifted-photo",
|
||||
component: () =>
|
||||
import(/* webpackChunkName: "gifted-photo" */ "../views/GiftedPhoto.vue"),
|
||||
},
|
||||
{
|
||||
path: "/help",
|
||||
name: "help",
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
</div>
|
||||
<input
|
||||
type="number"
|
||||
class="border border-r-0 border-slate-400 px-2 py-2 text-center"
|
||||
class="border border-r-0 border-slate-400 px-2 py-2 text-center w-20"
|
||||
v-model="amountInput"
|
||||
/>
|
||||
<div
|
||||
@@ -55,25 +55,26 @@
|
||||
<label class="text-sm">This is given to a project</label>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-center mb-4 mt-4">
|
||||
<span v-if="imageUrl">
|
||||
Includes Image:
|
||||
<a :href="imageUrl" target="_blank" class="text-blue-500 ml-4">View</a>
|
||||
<div class="flex justify-center mt-4">
|
||||
<span v-if="imageUrl" class="flex justify-between">
|
||||
<a :href="imageUrl" target="_blank" class="text-blue-500 ml-4">
|
||||
<img :src="imageUrl" class="h-24 rounded-xl" />
|
||||
</a>
|
||||
<fa
|
||||
icon="trash-can"
|
||||
@click="confirmDeleteImage"
|
||||
class="text-red-500 fa-fw ml-8"
|
||||
class="text-red-500 fa-fw ml-8 mt-10"
|
||||
/>
|
||||
</span>
|
||||
<span v-else>
|
||||
<router-link
|
||||
:to="{ name: 'gifted-photo' }"
|
||||
class="bg-blue-500 text-white px-1.5 py-1 rounded-md"
|
||||
>
|
||||
<fa icon="camera" class="fa-fw" />
|
||||
</router-link>
|
||||
<fa
|
||||
icon="camera"
|
||||
class="bg-blue-500 text-white px-2 py-2 rounded-md"
|
||||
@click="openPhotoDialog"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
<GiftedPhotoDialog ref="photoDialog" />
|
||||
|
||||
<div v-if="!projectId" class="mt-4">
|
||||
<input type="checkbox" class="h-6 w-6 mr-2" v-model="givenToUser" />
|
||||
@@ -114,9 +115,13 @@ import { MASTER_SETTINGS_KEY, Settings } from "@/db/tables/settings";
|
||||
import { createAndSubmitGive } from "@/libs/endorserServer";
|
||||
import * as libsUtil from "@/libs/util";
|
||||
import { accessToken } from "@/libs/crypto";
|
||||
import GiftedDialog from "@/components/GiftedDialog.vue";
|
||||
import GiftedPhotoDialog from "@/components/GiftedPhotoDialog.vue";
|
||||
|
||||
@Component({
|
||||
components: {
|
||||
GiftedDialog,
|
||||
GiftedPhotoDialog,
|
||||
QuickNav,
|
||||
TopMessage,
|
||||
},
|
||||
@@ -198,6 +203,12 @@ export default class GiftedDetails extends Vue {
|
||||
this.$router.back();
|
||||
}
|
||||
|
||||
openPhotoDialog() {
|
||||
(this.$refs.photoDialog as GiftedPhotoDialog).open((imgUrl) => {
|
||||
this.imageUrl = imgUrl;
|
||||
});
|
||||
}
|
||||
|
||||
confirmDeleteImage() {
|
||||
this.$notify(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user