Working app (post request commented)
This commit is contained in:
		| @@ -42,11 +42,11 @@ function switchCamera() { | |||||||
|     <div style="display: flex; justify-content: center; align-items: center; height: 100%"> |     <div style="display: flex; justify-content: center; align-items: center; height: 100%"> | ||||||
|       <div @click="snapshot" class="photo-button" style="align-content: center;"> |       <div @click="snapshot" class="photo-button" style="align-content: center;"> | ||||||
|         <div class="circle"></div> |         <div class="circle"></div> | ||||||
|         <div class="ring"></div> |         <div class="buttonring"></div> | ||||||
|       </div> |       </div> | ||||||
|       <div @click="switchCamera" class="swap-button" style="align-content: center;"> |       <div @click="switchCamera" class="swap-button" style="align-content: center;"> | ||||||
|         <img src="/home/patryk/WebstormProjects/camera-app/src/assets/sync_200dp_FFFFFF_FILL0_wght700_GRAD200_opsz48.svg" style="height:80px; margin-left: 10px"/> |         <img src="/home/patryk/WebstormProjects/camera-app/src/assets/sync_200dp_FFFFFF_FILL0_wght700_GRAD200_opsz48.svg" style="height:80px; margin-left: 10px"/> | ||||||
|         <div class="ring"></div> |         <div class="buttonring"></div> | ||||||
|       </div> |       </div> | ||||||
|  |  | ||||||
|     </div> |     </div> | ||||||
| @@ -80,7 +80,7 @@ function switchCamera() { | |||||||
|   background-color: #ffffff; |   background-color: #ffffff; | ||||||
|   opacity: 0; |   opacity: 0; | ||||||
| } | } | ||||||
| .ring { | .buttonring { | ||||||
|   position: absolute; |   position: absolute; | ||||||
|   top: 0; |   top: 0; | ||||||
|   left: 0; |   left: 0; | ||||||
| @@ -91,13 +91,13 @@ function switchCamera() { | |||||||
|   border: 0.5em solid #ffffff; |   border: 0.5em solid #ffffff; | ||||||
|   opacity: 0.8; |   opacity: 0.8; | ||||||
| } | } | ||||||
| .photo-button .circle, .photo-button .ring { | .photo-button .circle, .photo-button .buttonring { | ||||||
|   transition: all 0.25s; |   transition: all 0.25s; | ||||||
| } | } | ||||||
| .photo-button:hover .circle { | .photo-button:hover .circle { | ||||||
|   opacity: 1; |   opacity: 1; | ||||||
| } | } | ||||||
| .photo-button:active .ring { | .photo-button:active .buttonring { | ||||||
|   opacity: 1; |   opacity: 1; | ||||||
| } | } | ||||||
| .photo-button:active .circle { | .photo-button:active .circle { | ||||||
|   | |||||||
| @@ -15,6 +15,7 @@ const siteControlStore = useSiteControlStore(); | |||||||
| const checkpointStore = useCheckpointStore(); | const checkpointStore = useCheckpointStore(); | ||||||
| const { isCameraOn } = storeToRefs(siteControlStore); | const { isCameraOn } = storeToRefs(siteControlStore); | ||||||
| const { checkpointList, currentCheckpoint } = storeToRefs(checkpointStore); | const { checkpointList, currentCheckpoint } = storeToRefs(checkpointStore); | ||||||
|  | const base64StringbyCheckpoint = ref<Map<string, string>>(new Map<string, string>()); | ||||||
|  |  | ||||||
|  |  | ||||||
| function switchCamera(checkpoint : CheckpointPhoto) { | function switchCamera(checkpoint : CheckpointPhoto) { | ||||||
| @@ -23,33 +24,52 @@ function switchCamera(checkpoint : CheckpointPhoto) { | |||||||
| } | } | ||||||
|  |  | ||||||
| function sendPhoto() { | function sendPhoto() { | ||||||
|   // let reader = new FileReader(); |   for(const checkpoint of checkpointList.value) { | ||||||
|   // let base64String; |     let reader = new FileReader(); | ||||||
|   // reader.readAsDataURL(photosList.value[0].photoBlob); |     let base64String; | ||||||
|   // reader.onloadend = function () { |     reader.onloadend = function () { | ||||||
|   //   base64String = reader.result as string; |       base64String = reader.result as string; | ||||||
|   //   console.log('Base64 String - ', base64String); |       //console.log('Base64 String - ', base64String); | ||||||
|   // |  | ||||||
|   //   // Simply Print the Base64 Encoded String, |       //console.log('Base64 String without Tags- ', | ||||||
|   //   // without additional data: Attributes. |  | ||||||
|   //   console.log('Base64 String without Tags- ', |  | ||||||
|       //  base64String.substring(base64String.indexOf(',') + 1)); |       //  base64String.substring(base64String.indexOf(',') + 1)); | ||||||
|   //   const json = { |       base64StringbyCheckpoint.value.set(checkpoint.checkpointName, base64String); | ||||||
|   //     comment: 'test test', |       sendRequest(); | ||||||
|   //     filename: 'test.png', |     } | ||||||
|   //     base64: base64String |     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' | ||||||
|     //   } |     //   } | ||||||
|   //   console.log(JSON.stringify(json)); |     // }).then( response => { | ||||||
|   //   // axiosInstance.post('/upload', JSON.stringify(json)).then( response => { |     //   console.log(response); | ||||||
|   //   //   console.log(response); |     // }); | ||||||
|   //   // }); |   } | ||||||
|   //} |  | ||||||
| } | } | ||||||
| </script> | </script> | ||||||
|  |  | ||||||
| <template> | <template> | ||||||
|   <FullscreenCamera v-if="isCameraOn == true"/> |   <FullscreenCamera v-if="isCameraOn == true"/> | ||||||
|   <div v-else> |   <div v-else> | ||||||
|  |     <div class="mb-2 p-2 shadow h-20"> | ||||||
|  |       <p class="font-medium text-5xl">Inspekcja</p> | ||||||
|  |     </div> | ||||||
|     <DataView :value="checkpointList" layout="grid" data-key=""> |     <DataView :value="checkpointList" layout="grid" data-key=""> | ||||||
|       <template #grid="slotProps"> |       <template #grid="slotProps"> | ||||||
|         <div class="grid grid-cols-12 gap-4"> |         <div class="grid grid-cols-12 gap-4"> | ||||||
| @@ -82,10 +102,9 @@ function sendPhoto() { | |||||||
|         </div> |         </div> | ||||||
|       </template> |       </template> | ||||||
|     </DataView> |     </DataView> | ||||||
|     <Button label="Send photo" @click="sendPhoto"/> |     <div class="flex"> | ||||||
|     <h1 class="text-3xl font-bold underline"> |       <Button label="Send photo" @click="sendPhoto" class="m-2 grow"/> | ||||||
|       Hello world! |     </div> | ||||||
|     </h1> |  | ||||||
|   </div> |   </div> | ||||||
|  |  | ||||||
| </template> | </template> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user