Add title to clips/snapshots.

This commit is contained in:
Dermot Duffy
2021-08-16 22:07:29 -07:00
parent 5ca5624dbd
commit 576ef91add
2 changed files with 42 additions and 6 deletions
+16
View File
@@ -1,3 +1,10 @@
.frigate-card-menu-container {
position: absolute;
top: 0px;
z-index: 1;
width: 100%;
}
.frigate-card-menu { .frigate-card-menu {
position: absolute; position: absolute;
top: 0px; top: 0px;
@@ -12,6 +19,15 @@
background-color: rgba(0, 0, 0, 0.6); background-color: rgba(0, 0, 0, 0.6);
} }
.frigate-card-menu-title {
@extend .frigate-card-menu-expanded;
top: 56px;
height: 1em;
padding-bottom: 0.5em;
color: rgba(255,255,255,0.7);
background-color: rgba(0, 0, 0, 0.5);
}
ha-icon-button.button { ha-icon-button.button {
position: relative; position: relative;
z-index: 10; z-index: 10;
+26 -6
View File
@@ -1,5 +1,5 @@
// TODO Feature: Add title to clips / snapshots playing/viewing
// TODO Bug: Sometimes webrtc component shows up as not found in browser (maybe after fresh build?) // TODO Bug: Sometimes webrtc component shows up as not found in browser (maybe after fresh build?)
// TODO Bug: Initializers in main class.
// TODO Last step: Add documentation & screenshots. // TODO Last step: Add documentation & screenshots.
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
@@ -102,6 +102,9 @@ export class FrigateCardMenu extends LitElement {
@property({ attribute: false }) @property({ attribute: false })
protected actionCallback: FrigateCardMenuCallback | null = null; protected actionCallback: FrigateCardMenuCallback | null = null;
@property({ attribute: false })
protected heading: string | null = null;
protected shouldUpdate(changedProps: PropertyValues): boolean { protected shouldUpdate(changedProps: PropertyValues): boolean {
return shouldUpdateBasedOnHass( return shouldUpdateBasedOnHass(
this.hass, this.hass,
@@ -146,6 +149,7 @@ export class FrigateCardMenu extends LitElement {
return transition( return transition(
html` html`
<div class="frigate-card-menu-container">
<div <div
class="frigate-card-menu-expanded" class="frigate-card-menu-expanded"
> >
@@ -198,6 +202,12 @@ export class FrigateCardMenu extends LitElement {
></ha-icon-button>` ></ha-icon-button>`
} }
</div> </div>
${this.heading ? html`
<div class="frigate-card-menu-title">
${this.heading}
</div>
` : ``}
</div>
` `
); );
} }
@@ -255,6 +265,9 @@ export class FrigateCard extends LitElement {
@property({ attribute: false }) @property({ attribute: false })
protected _showMenu: boolean; protected _showMenu: boolean;
@state()
protected _heading: string | null = null;
protected _interactionTimerID: number | null; protected _interactionTimerID: number | null;
protected _webrtcElement: any | null; protected _webrtcElement: any | null;
@@ -509,14 +522,17 @@ export class FrigateCard extends LitElement {
this._controlVideos({stop: true, control_clip: true}); this._controlVideos({stop: true, control_clip: true});
this._controlVideos({stop: false, control_live: true}); this._controlVideos({stop: false, control_live: true});
this._viewMode = name; this._viewMode = name;
this._heading = null;
break; break;
case "clips": case "clips":
this._controlVideos({stop: true, control_live: true}); this._controlVideos({stop: true, control_live: true});
this._viewMode = name; this._viewMode = name;
this._heading = null;
break; break;
case "snapshots": case "snapshots":
this._controlVideos({stop: true, control_clip: true, control_live: true}); this._controlVideos({stop: true, control_clip: true, control_live: true});
this._viewMode = name; this._viewMode = name;
this._heading = null;
break; break;
case "frigate-ui": case "frigate-ui":
window.open(this.config.frigate_url); window.open(this.config.frigate_url);
@@ -550,6 +566,7 @@ export class FrigateCard extends LitElement {
} }
event = events[0]; event = events[0];
} }
this._heading = this._getEventTitle(event);
const url = `${this.config.frigate_url}/clips/` + const url = `${this.config.frigate_url}/clips/` +
`${event.camera}-${event.id}.mp4`; `${event.camera}-${event.id}.mp4`;
return html` return html`
@@ -577,6 +594,7 @@ export class FrigateCard extends LitElement {
} }
event = events[0]; event = events[0];
} }
this._heading = this._getEventTitle(event);
const url = `${this.config.frigate_url}/clips/${event.camera}-${event.id}.jpg`; const url = `${this.config.frigate_url}/clips/${event.camera}-${event.id}.jpg`;
return html`<img class="frigate-card-viewer" src="${url}">` return html`<img class="frigate-card-viewer" src="${url}">`
} }
@@ -629,13 +647,9 @@ export class FrigateCard extends LitElement {
if (this.config.show_error) { if (this.config.show_error) {
return this._showError(localize('common.show_error')); return this._showError(localize('common.show_error'));
} }
// Note: Menu is rendered last to allow heading to be set by render methods.
return html` return html`
<ha-card @click=${this._interactionHandler}> <ha-card @click=${this._interactionHandler}>
<frigate-card-menu
.motionEntity=${this.config.motion_entity}
.hass=${this._hass}
.actionCallback=${this._menuActionHandler.bind(this)}
>
</frigate-card-menu> </frigate-card-menu>
${this._viewMode == "clips" ? ${this._viewMode == "clips" ?
html`<div class="frigate-card-gallery"> html`<div class="frigate-card-gallery">
@@ -658,6 +672,12 @@ export class FrigateCard extends LitElement {
</div>` : `` </div>` : ``
} }
${this._renderLiveViewer()} ${this._renderLiveViewer()}
<frigate-card-menu
.motionEntity=${this.config.motion_entity}
.hass=${this._hass}
.actionCallback=${this._menuActionHandler.bind(this)}
.heading=${this._heading}
></frigate-card-menu>
</ha-card>`; </ha-card>`;
} }