diff --git a/src/components/FullscreenCamera.vue b/src/components/FullscreenCamera.vue index 9a0a6f6..3fadae6 100644 --- a/src/components/FullscreenCamera.vue +++ b/src/components/FullscreenCamera.vue @@ -42,11 +42,11 @@ function switchCamera() {
-
+
-
+
@@ -80,7 +80,7 @@ function switchCamera() { background-color: #ffffff; opacity: 0; } -.ring { +.buttonring { position: absolute; top: 0; left: 0; @@ -91,13 +91,13 @@ function switchCamera() { border: 0.5em solid #ffffff; opacity: 0.8; } -.photo-button .circle, .photo-button .ring { +.photo-button .circle, .photo-button .buttonring { transition: all 0.25s; } .photo-button:hover .circle { opacity: 1; } -.photo-button:active .ring { +.photo-button:active .buttonring { opacity: 1; } .photo-button:active .circle { diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 8885ba6..c44ddd5 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -15,6 +15,7 @@ const siteControlStore = useSiteControlStore(); const checkpointStore = useCheckpointStore(); const { isCameraOn } = storeToRefs(siteControlStore); const { checkpointList, currentCheckpoint } = storeToRefs(checkpointStore); +const base64StringbyCheckpoint = ref>(new Map()); function switchCamera(checkpoint : CheckpointPhoto) { @@ -23,33 +24,52 @@ function switchCamera(checkpoint : CheckpointPhoto) { } function sendPhoto() { - // let reader = new FileReader(); - // let base64String; - // reader.readAsDataURL(photosList.value[0].photoBlob); - // reader.onloadend = function () { - // base64String = reader.result as string; - // console.log('Base64 String - ', base64String); - // - // // Simply Print the Base64 Encoded String, - // // without additional data: Attributes. - // console.log('Base64 String without Tags- ', - // base64String.substring(base64String.indexOf(',') + 1)); - // const json = { - // comment: 'test test', - // filename: 'test.png', - // base64: base64String - // } - // console.log(JSON.stringify(json)); - // // axiosInstance.post('/upload', JSON.stringify(json)).then( response => { - // // console.log(response); - // // }); - //} + for(const checkpoint of checkpointList.value) { + let reader = new FileReader(); + let base64String; + reader.onloadend = function () { + base64String = reader.result as string; + //console.log('Base64 String - ', base64String); + + //console.log('Base64 String without Tags- ', + // base64String.substring(base64String.indexOf(',') + 1)); + base64StringbyCheckpoint.value.set(checkpoint.checkpointName, base64String); + sendRequest(); + } + reader.readAsDataURL(checkpoint.photoBlob); + } +} + +function sendRequest() { + if(base64StringbyCheckpoint.value.size == checkpointList.value.length) { + const json = []; + for(const checkpoint of checkpointList.value) { + json.push({ + comment: checkpoint.comment, + filename: new Date(Date.now()).toISOString() + checkpoint.checkpointName + '.png', + base64: base64StringbyCheckpoint.value.get(checkpoint.checkpointName) + }); + } + //console.log(base64StringbyCheckpoint); + console.log(JSON.stringify(json)); + console.log(json); + // axiosInstance.post('/upload', JSON.stringify(json), { + // headers: { + // 'Content-Type': 'application/json' + // } + // }).then( response => { + // console.log(response); + // }); + } }