From b17907a2c79608b60fc4c30765afaa4508da9aa5 Mon Sep 17 00:00:00 2001 From: Dermot Duffy Date: Mon, 7 Mar 2022 21:09:12 -0800 Subject: [PATCH] Add timeline to menu. --- src/card.ts | 14 ++++++++++++-- src/localize/languages/en.json | 3 ++- src/types.ts | 3 +++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/card.ts b/src/card.ts index 2aee36c5..b0a17de8 100644 --- a/src/card.ts +++ b/src/card.ts @@ -371,6 +371,16 @@ export class FrigateCard extends LitElement { }); } + if (this._getConfig().menu.buttons.timeline) { + buttons.push({ + type: 'custom:frigate-card-menu-icon', + title: localize('config.view.views.timeline'), + icon: 'mdi:chart-gantt', + style: this._view?.is('timeline') ? this._getEmphasizedStyle() : {}, + tap_action: createFrigateCardCustomAction('timeline') as FrigateCardCustomAction, + }); + } + if (this._getConfig().menu.buttons.download && this._view?.isViewerView()) { buttons.push({ type: 'custom:frigate-card-menu-icon', @@ -649,8 +659,7 @@ export class FrigateCard extends LitElement { // Load the default view. let camera; if (this._cameras?.size) { - if (this._view?.camera && - this._getConfig().view.update_cycle_camera) { + if (this._view?.camera && this._getConfig().view.update_cycle_camera) { const keys = Array.from(this._cameras.keys()); const currentIndex = keys.indexOf(this._view.camera); const targetIndex = currentIndex + 1 >= keys.length ? 0 : currentIndex + 1; @@ -827,6 +836,7 @@ export class FrigateCard extends LitElement { case 'live': case 'snapshot': case 'snapshots': + case 'timeline': if (this._view) { this._changeView({ view: new View({ diff --git a/src/localize/languages/en.json b/src/localize/languages/en.json index fee462b2..58613e91 100644 --- a/src/localize/languages/en.json +++ b/src/localize/languages/en.json @@ -42,7 +42,8 @@ "snapshot": "Most recent snapshot", "snapshots": "Snapshots gallery", "image": "Static image", - "current": "Current view" + "current": "Current view", + "timeline": "Timeline view" }, "timeout_seconds": "Reset to default view X seconds after user action (0=never)", "update_cycle_camera": "Cycle through cameras when default view updates", diff --git a/src/types.ts b/src/types.ts index 179f7efe..30a33f25 100644 --- a/src/types.ts +++ b/src/types.ts @@ -127,6 +127,7 @@ const FRIGATE_CARD_GENERAL_ACTIONS = [ 'live', 'snapshot', 'snapshots', + 'timeline', 'download', 'frigate_ui', 'fullscreen', @@ -591,6 +592,7 @@ const menuConfigDefault = { clips: true, snapshots: true, image: false, + timeline: true, download: true, frigate_ui: true, fullscreen: true, @@ -609,6 +611,7 @@ const menuConfigSchema = z clips: z.boolean().default(menuConfigDefault.buttons.clips), snapshots: z.boolean().default(menuConfigDefault.buttons.snapshots), image: z.boolean().default(menuConfigDefault.buttons.image), + timeline: z.boolean().default(menuConfigDefault.buttons.timeline), download: z.boolean().default(menuConfigDefault.buttons.download), frigate_ui: z.boolean().default(menuConfigDefault.buttons.frigate_ui), fullscreen: z.boolean().default(menuConfigDefault.buttons.fullscreen),