diff --git a/plugins/core/package-lock.json b/plugins/core/package-lock.json index 5420b7c0e..7e8a6f33f 100644 --- a/plugins/core/package-lock.json +++ b/plugins/core/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/core", - "version": "0.0.218", + "version": "0.0.220", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@scrypted/core", - "version": "0.0.218", + "version": "0.0.220", "license": "Apache-2.0", "dependencies": { "@koush/wrtc": "^0.5.2", diff --git a/plugins/core/package.json b/plugins/core/package.json index 5250d4aa5..6698c387e 100644 --- a/plugins/core/package.json +++ b/plugins/core/package.json @@ -1,6 +1,6 @@ { "name": "@scrypted/core", - "version": "0.0.218", + "version": "0.0.220", "description": "Scrypted Core plugin. Provides the UI, websocket, and engine.io APIs.", "author": "Scrypted", "license": "Apache-2.0", diff --git a/plugins/core/ui/src/interfaces/CameraViewer.vue b/plugins/core/ui/src/interfaces/CameraViewer.vue index face3a401..bacec5704 100644 --- a/plugins/core/ui/src/interfaces/CameraViewer.vue +++ b/plugins/core/ui/src/interfaces/CameraViewer.vue @@ -1,5 +1,8 @@ @@ -76,7 +112,9 @@ export default { props: ["clipPathValue", "device"], data() { return { - isLive: true, + dateDialog: false, + adjustingTime: null, + startTime: null, lastDetection: {}, objectListener: this.device.listen( ScryptedInterface.ObjectDetector, @@ -89,6 +127,23 @@ export default { }; }, computed: { + isLive() { + return !this.startTime; + }, + time() { + const d = this.startTime ? new Date(this.startTime) : new Date(); + const h = d.getHours().toString().padStart(2, "0"); + const m = d.getMinutes().toString().padStart(2, "0"); + const s = d.getSeconds().toString().padStart(2, "0"); + return `${h}:${m}:${s}`; + }, + monthDay() { + const d = this.startTime ? new Date(this.startTime) : new Date(); + return d.toLocaleDateString(undefined, { + month: "short", + day: "numeric", + }); + }, showNvr() { return this.device.interfaces.includes(ScryptedInterface.VideoRecorder); }, @@ -132,6 +187,26 @@ export default { this.objectListener.removeListener(); }, methods: { + datePicked(value) { + this.dateDialog = false; + console.log(value); + const d = new Date(value); + const dt = d.getTime() + new Date().getTimezoneOffset() * 60 * 1000; + this.streamRecorder(dt); + }, + doTimeScroll(e) { + if (!this.startTime) { + this.startTime = Date.now() - 2 * 60 * 1000; + return; + } + const adjust = Math.round(e.deltaY / 7); + this.startTime -= adjust * 60000; + clearTimeout(this.adjustingTime); + this.adjustingTime = setTimeout(() => { + this.adjustingTime = null; + this.streamRecorder(this.startTime); + }, 2500); + }, cleanupConnection() { if (this.pc) { console.log("peer connection cleaned up"); @@ -141,7 +216,7 @@ export default { }, async streamCamera() { this.cleanupConnection(); - this.isLive = true; + this.startTime = null; this.pc = await streamCamera( this.$scrypted.mediaManager, this.device, @@ -150,7 +225,7 @@ export default { }, async streamRecorder(startTime) { this.cleanupConnection(); - this.isLive = false; + this.startTime = startTime; this.pc = await streamRecorder( this.$scrypted.mediaManager, this.device, diff --git a/plugins/core/ui/src/plugins/icons.ts b/plugins/core/ui/src/plugins/icons.ts index 15972c0ca..b0bbfd723 100644 --- a/plugins/core/ui/src/plugins/icons.ts +++ b/plugins/core/ui/src/plugins/icons.ts @@ -78,6 +78,7 @@ import { faHdd, faTimes, faHistory, + faCalendarAlt, } from '@fortawesome/free-solid-svg-icons' import { @@ -162,6 +163,7 @@ const icons =[ faCodeBranch, faHdd, faTimes, + faCalendarAlt, ]; for (var icon in icons) {