Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add progress banner to warn about videos being processed on background #809

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/stores/video.ts
Expand Up @@ -425,6 +425,17 @@ export const useVideoStore = defineStore('video', () => {
})
})

const areThereVideosProcessing = computed(() => {
const dateNow = new Date(timeNow.value)

return keysAllUnprocessedVideos.value.some((recordingHash) => {
const info = unprocessedVideos.value[recordingHash]
const dateLastProcessingUpdate = new Date(info.dateLastProcessignUpdate ?? 0)
const secondsSinceLastProcessingUpdate = differenceInSeconds(dateNow, dateLastProcessingUpdate)
return info.dateFinish !== undefined && secondsSinceLastProcessingUpdate < 10
})
})

// Process videos that were being recorded when the app was closed
const processUnprocessedVideos = async (): Promise<void> => {
if (keysFailedUnprocessedVideos.value.isEmpty()) return
Expand Down Expand Up @@ -595,6 +606,7 @@ export const useVideoStore = defineStore('video', () => {
downloadTempVideoDB,
keysAllUnprocessedVideos,
keysFailedUnprocessedVideos,
areThereVideosProcessing,
processUnprocessedVideos,
discardUnprocessedVideos,
temporaryVideoDBSize,
Expand Down
20 changes: 19 additions & 1 deletion src/views/ConfigurationVideoView.vue
Expand Up @@ -50,6 +50,16 @@
</div>
</div>

<div v-if="areThereVideosProcessing" class="max-w-[50%] bg-slate-100 rounded-md p-6 border mb-8">
<div class="flex justify-center w-full mb-4 text-2xl font-semibold text-center align-center text-slate-500">
<span>Processing videos</span>
<span class="ml-2 mdi mdi-loading animate-spin" />
</div>
<p class="text-center text-slate-400">
There are videos being processed in background. Please wait until they are finished to download or discard.
</p>
</div>

<div v-if="availableVideosAndLogs.isEmpty()" class="max-w-[50%] bg-slate-100 rounded-md p-6 border">
<p class="mb-4 text-2xl font-semibold text-center text-slate-500">No videos available.</p>
<p class="text-center text-slate-400">
Expand Down Expand Up @@ -122,7 +132,7 @@
<script setup lang="ts">
import { storeToRefs } from 'pinia'
import Swal from 'sweetalert2'
import { computed, onMounted, ref } from 'vue'
import { computed, onMounted, ref, watch } from 'vue'
import type { VDataTable } from 'vuetify/components'
import Button from '@/components/Button.vue'
Expand Down Expand Up @@ -243,6 +253,14 @@ const discardFailedUnprocessedVideos = async (): Promise<void> => {
})
}
// After the videos are processed, fetch the data again to update the video table
const { areThereVideosProcessing } = storeToRefs(videoStore)
watch(areThereVideosProcessing, async () => {
// Sleep for a second before fetching to allow for the sensors logging update
await new Promise((resolve) => setTimeout(resolve, 1000))
await fetchVideoAndLogsData()
})
const nUnprocVideos = computed(() => videoStore.keysFailedUnprocessedVideos.length)
type ReadonlyHeaders = VDataTable['$props']['headers']
Expand Down