Skip to content

Commit

Permalink
Offer download of video recording backups if they are available
Browse files Browse the repository at this point in the history
Remove them, independently if they were downloaded or not.
  • Loading branch information
rafaellehmkuhl committed Nov 21, 2023
1 parent 396daaf commit 5dec4d3
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/stores/video.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
import { useStorage } from '@vueuse/core'
import { saveAs } from 'file-saver'
import localforage from 'localforage'
import { defineStore } from 'pinia'
import { reactive } from 'vue'

export const useVideoStore = defineStore('video', () => {
const availableIceIps = reactive<string[]>([])
const allowedIceIps = useStorage<string[]>('cockpit-allowed-stream-ips', [])

// Offer download of backuped videos
const cockpitVideoDB = localforage.createInstance({
driver: localforage.INDEXEDDB,
name: 'CockpitVideoDB',
storeName: 'cockpit-video-db',
version: 1.0,
description: 'Local backups of Cockpit video recordings to be retrieved in case of failure.',
})

cockpitVideoDB.iterate((videoFile, videoName) => {
const blob = (videoFile as Blob[]).reduce((a, b) => new Blob([a, b], { type: 'video/webm' }))
saveAs(blob, videoName)
})
cockpitVideoDB.iterate((_, videoName) => {
cockpitVideoDB.removeItem(videoName)
})

return { availableIceIps, allowedIceIps }
})

0 comments on commit 5dec4d3

Please sign in to comment.