-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Offer download of video recording backups if they are available
Remove them, independently if they were downloaded or not.
- Loading branch information
1 parent
396daaf
commit 5dec4d3
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } | ||
}) |