mirror of
https://github.com/FoggedLens/deflock.git
synced 2026-10-12 18:07:07 +02:00
add loading for submissions
This commit is contained in:
1 parent
9b8c92a042
commit
f9da20a615
1 file changed
+8
-5
@@ -64,7 +64,7 @@
|
|||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
<span class="pl-4 text-grey-darken-1">Submitting as {{ user?.name }}</span>
|
<span class="pl-4 text-grey-darken-1">Submitting as {{ user?.name }}</span>
|
||||||
<v-spacer/>
|
<v-spacer/>
|
||||||
<v-btn color="primary" @click="upload" :disabled="!canSubmit">Submit</v-btn>
|
<v-btn :loading="isSubmitting" color="primary" @click="upload" :disabled="!canSubmit">Submit</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
|
|
||||||
@@ -97,6 +97,7 @@ const errorMessage = ref('');
|
|||||||
const areAllImagesGeotagged = ref(false);
|
const areAllImagesGeotagged = ref(false);
|
||||||
const showLoginDialog = ref(false); // TODO: changeme
|
const showLoginDialog = ref(false); // TODO: changeme
|
||||||
const presignedUrls = ref<string[]>([]);
|
const presignedUrls = ref<string[]>([]);
|
||||||
|
const isSubmitting = ref(false);
|
||||||
|
|
||||||
// watch(isAuthenticated, async (isAuthenticated) => {
|
// watch(isAuthenticated, async (isAuthenticated) => {
|
||||||
// if (isAuthenticated) {
|
// if (isAuthenticated) {
|
||||||
@@ -109,7 +110,7 @@ const presignedUrls = ref<string[]>([]);
|
|||||||
const MAX_FILE_SIZE = 8 * 1024 * 1024; // 8 MB
|
const MAX_FILE_SIZE = 8 * 1024 * 1024; // 8 MB
|
||||||
|
|
||||||
const canSubmit = computed(() => {
|
const canSubmit = computed(() => {
|
||||||
return agree.value && files.value.length > 0 && areAllImagesGeotagged.value;
|
return agree.value && files.value.length > 0 && areAllImagesGeotagged.value && !isSubmitting.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
const checkGeotagging = async () => {
|
const checkGeotagging = async () => {
|
||||||
@@ -138,7 +139,7 @@ const checkGeotagging = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fetch presigned urls ahead of time to save time
|
// fetch presigned urls ahead of time to save time
|
||||||
getPresignedUrls(files.value.length, files.value[0].type, 'CHANGE_ME_PLEASE!!').then((urls) => {
|
getPresignedUrls(files.value.length, files.value[0].type, 'willfreeman').then((urls) => {
|
||||||
presignedUrls.value = urls;
|
presignedUrls.value = urls;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -172,15 +173,17 @@ async function upload() {
|
|||||||
|
|
||||||
files.value.forEach(async (file, index) => {
|
files.value.forEach(async (file, index) => {
|
||||||
const presignedUrl = presignedUrls.value[index];
|
const presignedUrl = presignedUrls.value[index];
|
||||||
|
isSubmitting.value = true;
|
||||||
const response = await fetch(presignedUrl, {
|
const response = await fetch(presignedUrl, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
body: file,
|
body: file,
|
||||||
});
|
});
|
||||||
|
isSubmitting.value = false;
|
||||||
console.log(response);
|
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
console.log('File uploaded successfully');
|
console.log('File uploaded successfully');
|
||||||
|
files.value = [];
|
||||||
|
areAllImagesGeotagged.value = false;
|
||||||
} else {
|
} else {
|
||||||
console.error('Failed to upload file');
|
console.error('Failed to upload file');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user