Create timer variable to block video polling

This commit is contained in:
2025-05-13 13:03:25 +02:00
parent a6492ba0a0
commit c3740de47c
2 changed files with 22 additions and 43 deletions

View File

@@ -143,11 +143,11 @@
<p v-if="selectedFile" class="text-center">You can execute the indexing for the following file:</p>
<p v-if="selectedFile" class="text-center">{{ selectedFile.name }}</p>
<div class="flex justify-center mt-4">
<Button type="submit" label="Index" :fluid="false"></Button>
<Button type="submit" label="Upload" :fluid="false" :disabled="uploadPercentage > 0"></Button>
</div>
<div class="flex justify-center mt-8 w-1/2 mx-auto" v-if="uploadPercentage > 0">
<div class="flex flex-col items-center gap-4 w-full">
<p class="text-center">Wait until the indexing is completed. You will be automatically redirected.</p>
<p class="text-center">Wait until the upload is completed. You will be automatically redirected.</p>
<ProgressBar :value="uploadPercentage" class="w-full" />
</div>
</div>
@@ -292,14 +292,17 @@ const onFileSelect = (event) => {
});
};
onMounted(() => {
updateVideos();
onMounted(async () => {
await updateVideos();
});
async function updateVideos() {
await ksVideoStore.fetchKsVideoByGroupId(route.params.groupId);
ksVideos.value = (KsVideoStore.ksVideo || []);
console.log('ksVideos', ksVideos.value);
const updateVideos = async () => {
ksVideoStore.fetchKsVideoByGroupId(route.params.groupId).then(() => {
ksVideos.value = (ksVideoStore.ksVideo || []);
//groupDocType.value = ksVideoGroupStore.ksVideoGroup?.ksDocType || ''
console.log('ksVideos', ksVideos.value);
//console.log('groupDocType', groupDocType.value);
});
};
const onFileRemove = () => {
@@ -312,28 +315,6 @@ const onFileRemove = () => {
});
};
const startIndividualIndexing = async (id) => {
toast.add({ severity: 'info', summary: 'Info', detail: 'Starting Indexing', life: 3000 });
axios.get(`/test/index_video/${id}`)
.then(response => {
if (response.data.status == "OK") {
toast.add({ severity: 'success', summary: 'Success', detail: 'Video indexing started...', life: 3000 });
}
if (response.data.status == "ERROR") {
toast.add({ severity: 'error', summary: 'Success', detail: 'Error indexing video:' + response.data.message, life: 3000 });
}
})
.catch(error => {
//ingestionDialogVisible.value = true;
console.error('Error indexing record: ', error)
toast.add({ severity: 'error', summary: 'Success', detail: 'Error indexing video:' + error, life: 3000 });
});
};
const deleteRecord = (name) => {
const videoToDelete = ksVideos.value.find(video => video.name === name);
@@ -362,12 +343,6 @@ const deleteRecord = (name) => {
};
// onMounted(async () => {
// await ksVideoGroupStore.fetchKsVideoGroupById(route.params.groupId);
// groupDocType.value = ksVideoGroupStore.ksVideoGroup?.ksDocType || '';
// //per provare a mettere lo stesso type a tutti i video
// });
const submitForm = async () => {
formDataToSend.value = new FormData(); // Reset del formData ogni volta
@@ -423,9 +398,8 @@ const uploadFile = async (formDataToSend) => {
}
});
ksVideos.value.push(response.data);
toast.add({ severity: 'info', summary: 'Info', detail: 'Uploading done. Indexing will start in few seconds.', life: 3000 });
startIndividualIndexing(response.data.id);
router.push({ name: 'ks-video' });
} catch (error) {