Show message if no timeline cameras.
This commit is contained in:
@@ -37,9 +37,11 @@ import { View, ViewContext } from '../view';
|
|||||||
import {
|
import {
|
||||||
dispatchErrorMessageEvent,
|
dispatchErrorMessageEvent,
|
||||||
dispatchFrigateCardEvent,
|
dispatchFrigateCardEvent,
|
||||||
|
dispatchMessageEvent,
|
||||||
getCameraTitle,
|
getCameraTitle,
|
||||||
stopEventFromActivatingCardWideActions,
|
stopEventFromActivatingCardWideActions,
|
||||||
} from '../common.js';
|
} from '../common.js';
|
||||||
|
import { localize } from '../localize/localize';
|
||||||
|
|
||||||
import timelineCoreStyle from '../scss/timeline-core.scss';
|
import timelineCoreStyle from '../scss/timeline-core.scss';
|
||||||
import timelineStyle from '../scss/timeline.scss';
|
import timelineStyle from '../scss/timeline.scss';
|
||||||
@@ -593,7 +595,7 @@ export class FrigateCardTimelineCore extends LitElement {
|
|||||||
protected _getGroups(): DataGroupCollectionType {
|
protected _getGroups(): DataGroupCollectionType {
|
||||||
const groups: FrigateCardGroupData[] = [];
|
const groups: FrigateCardGroupData[] = [];
|
||||||
this.cameras?.forEach((cameraConfig, camera) => {
|
this.cameras?.forEach((cameraConfig, camera) => {
|
||||||
if (cameraConfig.camera_name !== CAMERA_BIRDSEYE) {
|
if (cameraConfig.camera_name && cameraConfig.camera_name !== CAMERA_BIRDSEYE) {
|
||||||
groups.push({
|
groups.push({
|
||||||
id: camera,
|
id: camera,
|
||||||
content: getCameraTitle(this.hass, cameraConfig),
|
content: getCameraTitle(this.hass, cameraConfig),
|
||||||
@@ -882,10 +884,21 @@ export class FrigateCardTimelineCore extends LitElement {
|
|||||||
if (this._timeline) {
|
if (this._timeline) {
|
||||||
this._timeline.setOptions(options);
|
this._timeline.setOptions(options);
|
||||||
} else {
|
} else {
|
||||||
|
// Don't show an empty timeline, show a message instead.
|
||||||
|
const groups = this._getGroups();
|
||||||
|
if (!groups.length) {
|
||||||
|
dispatchMessageEvent(
|
||||||
|
this,
|
||||||
|
localize('error.timeline_no_cameras'),
|
||||||
|
'mdi:chart-gantt',
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this._timeline = new Timeline(
|
this._timeline = new Timeline(
|
||||||
this._refTimeline.value,
|
this._refTimeline.value,
|
||||||
this._events.dataset,
|
this._events.dataset,
|
||||||
this._getGroups(),
|
groups,
|
||||||
options,
|
options,
|
||||||
);
|
);
|
||||||
this._timeline.on('select', this._timelineSelectHandler.bind(this));
|
this._timeline.on('select', this._timelineSelectHandler.bind(this));
|
||||||
|
|||||||
@@ -312,6 +312,7 @@
|
|||||||
"no_camera_name": "Could not determine a Frigate camera name for camera (or one of its dependents), please specify either 'camera_entity' or 'camera_name'",
|
"no_camera_name": "Could not determine a Frigate camera name for camera (or one of its dependents), please specify either 'camera_entity' or 'camera_name'",
|
||||||
"download_no_media": "No media to download",
|
"download_no_media": "No media to download",
|
||||||
"download_no_event_id": "Could not extract Frigate event id from media",
|
"download_no_event_id": "Could not extract Frigate event id from media",
|
||||||
"download_sign_failed": "Could not sign media URL for download"
|
"download_sign_failed": "Could not sign media URL for download",
|
||||||
|
"timeline_no_cameras": "No Frigate cameras to show in timeline"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user