Merge pull request #369 from dermotduffy/hide-frigate-events-buttons-for-normal-camera

Hide clips/snapshots button for non-Frigate cameras
This commit is contained in:
Dermot Duffy
2022-02-12 08:59:57 -08:00
committed by GitHub
2 changed files with 15 additions and 13 deletions
+2 -2
View File
@@ -173,8 +173,8 @@ menu:
| `frigate` | `true` | :white_check_mark: | Whether to show the `Frigate` menu button: brings the user to the default configured view (`view.default`), or collapses/expands the menu if the `menu.mode` is `hidden-*` . | | `frigate` | `true` | :white_check_mark: | Whether to show the `Frigate` menu button: brings the user to the default configured view (`view.default`), or collapses/expands the menu if the `menu.mode` is `hidden-*` . |
| `cameras` | `true` | :white_check_mark: | Whether to show the camera selection submenu. Will only appear if multiple cameras are configured. | | `cameras` | `true` | :white_check_mark: | Whether to show the camera selection submenu. Will only appear if multiple cameras are configured. |
| `live` | `true` | :white_check_mark: | Whether to show the `live` view menu button: brings the user to the `live` view. See [views](#views) below.| | `live` | `true` | :white_check_mark: | Whether to show the `live` view menu button: brings the user to the `live` view. See [views](#views) below.|
| `clips` | `true` | :white_check_mark: | Whether to show the `clips` view menu button: brings the user to the `clips` view on tap and the most-recent `clip` view on hold. See [views](#views) below.| | `clips` | `true` | :white_check_mark: | Whether to show the `clips` view menu button: brings the user to the `clips` view on tap and the most-recent `clip` view on hold. See [views](#views) below. This button will never be shown if the `camera_name` for the selected camera is not auto-detected/specified (e.g. non-Frigate cameras).|
| `snapshots` | `true` | :white_check_mark: | Whether to show the `snapshots` view menu button: brings the user to the `clips` view on tap and the most-recent `snapshot` view on hold. See [views](#views) below.| | `snapshots` | `true` | :white_check_mark: | Whether to show the `snapshots` view menu button: brings the user to the `clips` view on tap and the most-recent `snapshot` view on hold. See [views](#views) below. This button will never be shown if the `camera_name` for the selected camera is not auto-detected/specified (e.g. non-Frigate cameras).|
| `image` | `false` | :white_check_mark: | Whether to show the `image` view menu button: brings the user to the static `image` view. See [views](#views) below.| | `image` | `false` | :white_check_mark: | Whether to show the `image` view menu button: brings the user to the static `image` view. See [views](#views) below.|
| `download` | `true` | :white_check_mark: | Whether to show the `download` menu button: allow direct download of the media being displayed.| | `download` | `true` | :white_check_mark: | Whether to show the `download` menu button: allow direct download of the media being displayed.|
| `frigate_ui` | `true` | :white_check_mark: | Whether to show the `frigate_ui` menu button: brings the user to a context-appropriate page on the Frigate UI (e.g. the camera homepage). Will only appear if the `frigate.url` option is set.| | `frigate_ui` | `true` | :white_check_mark: | Whether to show the `frigate_ui` menu button: brings the user to a context-appropriate page on the Frigate UI (e.g. the camera homepage). Will only appear if the `frigate.url` option is set.|
+12 -10
View File
@@ -313,7 +313,11 @@ export class FrigateCard extends LitElement {
}); });
} }
if (this._getConfig().menu.buttons.clips) { const cameraConfig = this._getSelectedCameraConfig();
// Don't show `clips` button if there's no `camera_name` (e.g. non-Frigate
// cameras).
if (this._getConfig().menu.buttons.clips && cameraConfig?.camera_name) {
buttons.push({ buttons.push({
type: 'custom:frigate-card-menu-icon', type: 'custom:frigate-card-menu-icon',
title: localize('config.view.views.clips'), title: localize('config.view.views.clips'),
@@ -324,7 +328,9 @@ export class FrigateCard extends LitElement {
}); });
} }
if (this._getConfig().menu.buttons.snapshots) { // Don't show `snapshots` button if there's no `camera_name` (e.g. non-Frigate
// cameras).
if (this._getConfig().menu.buttons.snapshots && cameraConfig?.camera_name) {
buttons.push({ buttons.push({
type: 'custom:frigate-card-menu-icon', type: 'custom:frigate-card-menu-icon',
title: localize('config.view.views.snapshots'), title: localize('config.view.views.snapshots'),
@@ -358,12 +364,7 @@ export class FrigateCard extends LitElement {
}); });
} }
const cameraConfig = this._getSelectedCameraConfig(); if (this._getConfig().menu.buttons.frigate_ui && cameraConfig?.frigate_url) {
if (
this._getConfig().menu.buttons.frigate_ui &&
cameraConfig &&
cameraConfig.frigate_url
) {
buttons.push({ buttons.push({
type: 'custom:frigate-card-menu-icon', type: 'custom:frigate-card-menu-icon',
title: localize('config.menu.buttons.frigate_ui'), title: localize('config.menu.buttons.frigate_ui'),
@@ -834,9 +835,10 @@ export class FrigateCard extends LitElement {
if (this._cameras?.has(camera) && this._view) { if (this._cameras?.has(camera) && this._view) {
this._changeView({ this._changeView({
view: new View({ view: new View({
view: this._getConfig().view.camera_select === 'current' view:
this._getConfig().view.camera_select === 'current'
? this._view.view ? this._view.view
: this._getConfig().view.camera_select as FrigateCardView, : (this._getConfig().view.camera_select as FrigateCardView),
camera: camera, camera: camera,
}), }),
}); });