Don't show timeline bar if we cannot seek.

This commit is contained in:
Dermot Duffy
2023-04-01 11:44:00 -07:00
parent 81f8be16ed
commit bff73b4e2d
5 changed files with 49 additions and 30 deletions
@@ -1076,6 +1076,7 @@ export class FrigateCameraManagerEngine
return { return {
canFavoriteEvents: !isBirdseye, canFavoriteEvents: !isBirdseye,
canFavoriteRecordings: !isBirdseye, canFavoriteRecordings: !isBirdseye,
canSeek: true,
supportsClips: !isBirdseye, supportsClips: !isBirdseye,
supportsSnapshots: !isBirdseye, supportsSnapshots: !isBirdseye,
supportsRecordings: !isBirdseye, supportsRecordings: !isBirdseye,
@@ -177,6 +177,7 @@ export class GenericCameraManagerEngine implements CameraManagerEngine {
return { return {
canFavoriteEvents: false, canFavoriteEvents: false,
canFavoriteRecordings: false, canFavoriteRecordings: false,
canSeek: false,
supportsClips: false, supportsClips: false,
supportsRecordings: false, supportsRecordings: false,
supportsSnapshots: false, supportsSnapshots: false,
+3
View File
@@ -747,6 +747,9 @@ export class CameraManager {
canFavoriteRecordings: perCameraCapabilities.some( canFavoriteRecordings: perCameraCapabilities.some(
(cap) => cap?.canFavoriteRecordings, (cap) => cap?.canFavoriteRecordings,
), ),
canSeek: perCameraCapabilities.some(
(cap) => cap?.canSeek,
),
supportsClips: perCameraCapabilities.some((cap) => cap?.supportsClips), supportsClips: perCameraCapabilities.some((cap) => cap?.supportsClips),
supportsRecordings: perCameraCapabilities.some((cap) => cap?.supportsRecordings), supportsRecordings: perCameraCapabilities.some((cap) => cap?.supportsRecordings),
+1
View File
@@ -94,6 +94,7 @@ export interface MediaMetadata {
interface BaseCapabilities { interface BaseCapabilities {
canFavoriteEvents: boolean; canFavoriteEvents: boolean;
canFavoriteRecordings: boolean; canFavoriteRecordings: boolean;
canSeek: boolean;
supportsClips: boolean; supportsClips: boolean;
supportsRecordings: boolean; supportsRecordings: boolean;
+43 -30
View File
@@ -280,6 +280,26 @@ export class FrigateCardTimelineCore extends LitElement {
${ref(this._refTimeline)} ${ref(this._refTimeline)}
> >
<div class="timeline-tools"> <div class="timeline-tools">
${this._shouldSupportSeeking()
? html` <ha-icon
.icon=${`mdi:${this._locked ? 'lock' : 'lock-open-variant'}`}
@click=${() => {
this._locked = !this._locked;
}}
aria-label="${lockTitle}"
title="${lockTitle}"
>
</ha-icon>`
: ''}
<ha-icon
.icon=${`mdi:calendar-search`}
aria-label="${localize('timeline.select_date')}"
title="${localize('timeline.select_date')}"
@click=${() => {
this._refDatePicker.value?.open();
}}
>
</ha-icon>
<frigate-card-date-picker <frigate-card-date-picker
${ref(this._refDatePicker)} ${ref(this._refDatePicker)}
@frigate-card:date-picker:change=${(ev: CustomEvent<DatePickerEvent>) => { @frigate-card:date-picker:change=${(ev: CustomEvent<DatePickerEvent>) => {
@@ -290,24 +310,6 @@ export class FrigateCardTimelineCore extends LitElement {
}} }}
> >
</frigate-card-date-picker> </frigate-card-date-picker>
<ha-icon
.icon=${`mdi:calendar-search`}
aria-label="${localize('timeline.select_date')}"
title="${localize('timeline.select_date')}"
@click=${() => {
this._refDatePicker.value?.open();
}}
>
</ha-icon>
<ha-icon
.icon=${`mdi:${this._locked ? 'lock' : 'lock-open-variant'}`}
@click=${() => {
this._locked = !this._locked;
}}
aria-label="${lockTitle}"
title="${lockTitle}"
>
</ha-icon>
</div> </div>
</div>` </div>`
: ''}`; : ''}`;
@@ -357,6 +359,16 @@ export class FrigateCardTimelineCore extends LitElement {
} }
} }
protected _shouldSupportSeeking(): boolean {
const cameraIDs = this._getTimelineCameraIDs();
if (!this._timeline || !cameraIDs) {
return false;
}
const capabilities = this.cameraManager?.getAggregateCameraCapabilities(cameraIDs);
return (this.view?.isViewerView() && capabilities?.canSeek) ?? false;
}
/** /**
* Set the target bar at a given time. * Set the target bar at a given time.
* @param targetTime * @param targetTime
@@ -367,18 +379,19 @@ export class FrigateCardTimelineCore extends LitElement {
} }
const targetBarOn = const targetBarOn =
!this._locked || this._shouldSupportSeeking() &&
(this.mini && (!this._locked ||
this._timeline.getSelection().some((id) => { (this.mini &&
const item = this._timelineSource?.dataset?.get(id); this._timeline.getSelection().some((id) => {
return ( const item = this._timelineSource?.dataset?.get(id);
item && return (
item.start && item &&
item.end && item.start &&
targetTime.getTime() >= item.start && item.end &&
targetTime.getTime() <= item.end targetTime.getTime() >= item.start &&
); targetTime.getTime() <= item.end
})); );
})));
if (targetBarOn) { if (targetBarOn) {
if (!this._targetBarVisible) { if (!this._targetBarVisible) {