Merged PR 118: Create timer variable to block video polling
Create timer variable to block video polling
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -121,7 +121,7 @@ import axios from 'axios';
|
||||
import moment from 'moment';
|
||||
import { useConfirm } from "primevue/useconfirm";
|
||||
import { useToast } from 'primevue/usetoast';
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { computed, onMounted, onUnmounted, ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
|
||||
import Button from 'primevue/button';
|
||||
@@ -153,6 +153,7 @@ const userPrefStore = UserPrefStore();
|
||||
const ksVideoStore = KsVideoStore();
|
||||
const loadingStore = LoadingStore();
|
||||
const fe_status = ref('');
|
||||
let updateTimer = null; // Variabile per memorizzare l'ID del timer
|
||||
|
||||
const initFilters = () => {
|
||||
filters.value = {
|
||||
@@ -176,14 +177,18 @@ onMounted(() => {
|
||||
groupName.value = response.data.name;
|
||||
});
|
||||
updateVideos();
|
||||
setInterval(() => {
|
||||
updateTimer = setInterval(() => {
|
||||
updateVideos();
|
||||
}, 5000);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
if (updateTimer) {
|
||||
clearInterval(updateTimer); // Cancella il timer quando il componente viene distrutto
|
||||
updateTimer = null;
|
||||
}
|
||||
});
|
||||
|
||||
const onRowExpand = (event) => {
|
||||
console.log("Row expanded:", event.data);
|
||||
@@ -298,7 +303,7 @@ const confirmDeleteFromVectorStore = (id) => {
|
||||
}
|
||||
|
||||
const requestPayload = {
|
||||
KsVideoId: id,
|
||||
ksDocumentId: id,
|
||||
ksIngestionInfoId: videoToDelete.ingestionInfo.id,
|
||||
ksDoctype: videoToDelete.ingestionInfo.metadata.KsDoctype,
|
||||
ksDocSource: videoToDelete.ingestionInfo.metadata.KsDocSource,
|
||||
|
||||
Reference in New Issue
Block a user