Rename frigate_ui action to camera_ui .

This commit is contained in:
Dermot Duffy
2023-02-14 19:15:33 -08:00
parent bea7067771
commit 0128e2a818
9 changed files with 44 additions and 20 deletions
+6 -6
View File
@@ -300,7 +300,7 @@ menu:
| `recordings` | :white_check_mark: | The `recordings` view menu button: brings the user to the `recordings` view on tap and the most-recent `recording` view on hold. See [views](#views) below. This button will never be shown if the `frigate.camera_name` for the selected camera is not auto-detected/specified (e.g. non-Frigate cameras), or if the `frigate.camera_name` is `birdseye`.|
| `image` | :white_check_mark: | The `image` view menu button: brings the user to the static `image` view. See [views](#views) below.|
| `download` | :white_check_mark: | The `download` menu button: allow direct download of the media being displayed.|
| `frigate_ui` | :white_check_mark: | 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.|
| `camera_ui` | :white_check_mark: | The `camera_ui` menu button: brings the user to a context-appropriate page on the UI of their camera engine (e.g. the Frigate camera homepage). Will only appear if the camera engine supports a camera UI (e.g. if `frigate.url` option is set for `frigate` engine users).|
| `fullscreen` | :white_check_mark: | The `fullscreen` menu button: expand the card to consume the fullscreen. |
| `timeline` | :white_check_mark: | The `timeline` menu button: show the event timeline. |
| `media_player` | :white_check_mark: | The `media_player` menu button: sends the visible media to a remote media player. Supports Frigate clips, snapshots and live camera (only for cameras that specify a `camera_entity` and only using the default HA stream (equivalent to the `ha` live provider). `jsmpeg` or `webrtc-card` are not supported, although live can still be played as long as `camera_entity` is specified. In the player list, a `tap` will send the media to the player, a `hold` will stop the media on the player. |
@@ -1057,7 +1057,7 @@ Parameters for the `custom:frigate-card-ptz` element:
| Parameter | Description |
| - | - |
| `action` | Must be `custom:frigate-card-action`. |
| `frigate_card_action` | Call a Frigate Card action. Acceptable values are `default`, `clip`, `clips`, `image`, `live`, `recording`, `recordings`, `snapshot`, `snapshots`, `download`, `timeline`, `frigate_ui`, `fullscreen`, `camera_select`, `menu_toggle`, `media_player`.|
| `frigate_card_action` | Call a Frigate Card action. Acceptable values are `default`, `clip`, `clips`, `image`, `live`, `recording`, `recordings`, `snapshot`, `snapshots`, `download`, `timeline`, `camera_ui`, `fullscreen`, `camera_select`, `menu_toggle`, `media_player`.|
##### Command descriptions
@@ -1066,7 +1066,7 @@ Parameters for the `custom:frigate-card-ptz` element:
| `default` | Trigger the default view. |
| `clip`, `clips`, `image`, `live`, `recording`, `recordings`, `snapshot`, `snapshots` | Trigger the named [view](#views).|
|`download`|Download the displayed media.|
|`frigate_ui`|Open the Frigate UI at the configured URL.|
|`camera_ui`|Open the Frigate UI at the configured URL.|
|`fullscreen`|Toggle fullscreen.|
|`camera_select`|Select a given camera. Takes a single additional `camera` parameter with the [camera ID](#camera-ids) of the camera to select. Respects the value of `view.camera_select` to choose the appropriate view on the new camera.|
|`menu_toggle` | Show/hide the menu (for the `hidden` mode style). |
@@ -1455,7 +1455,7 @@ menu:
enabled: true
alignment: matching
icon: mdi:download
frigate_ui:
camera_ui:
priority: 50
enabled: true
alignment: matching
@@ -1976,7 +1976,7 @@ elements:
title: Open Frigate UI
tap_action:
action: custom:frigate-card-action
frigate_card_action: frigate_ui
frigate_card_action: camera_ui
- type: custom:frigate-card-menu-icon
icon: mdi:alpha-j-circle
title: Change to fullscreen
@@ -2175,7 +2175,7 @@ overrides:
enabled: true
alignment: matching
icon: mdi:download
frigate_ui:
camera_ui:
priority: 50
enabled: true
alignment: matching
+4 -4
View File
@@ -531,11 +531,11 @@ class FrigateCard extends LitElement {
if (this._getCameraURLFromContext()) {
buttons.push({
icon: 'mdi:web',
...this._getConfig().menu.buttons.frigate_ui,
...this._getConfig().menu.buttons.camera_ui,
type: 'custom:frigate-card-menu-icon',
title: localize('config.menu.buttons.frigate_ui'),
title: localize('config.menu.buttons.camera_ui'),
tap_action: createFrigateCardCustomAction(
'frigate_ui',
'camera_ui',
) as FrigateCardCustomAction,
});
}
@@ -1337,7 +1337,7 @@ class FrigateCard extends LitElement {
case 'download':
this._downloadViewerMedia();
break;
case 'frigate_ui':
case 'camera_ui':
const url = this._getCameraURLFromContext();
if (url) {
window.open(url);
+26 -2
View File
@@ -18,10 +18,10 @@ import {
CONF_MEDIA_VIEWER,
CONF_MENU,
CONF_MENU_BUTTONS_CAMERAS,
CONF_MENU_BUTTONS_CAMERA_UI,
CONF_MENU_BUTTONS_CLIPS,
CONF_MENU_BUTTONS_DOWNLOAD,
CONF_MENU_BUTTONS_FRIGATE,
CONF_MENU_BUTTONS_FRIGATE_UI,
CONF_MENU_BUTTONS_FULLSCREEN,
CONF_MENU_BUTTONS_IMAGE,
CONF_MENU_BUTTONS_LIVE,
@@ -599,6 +599,24 @@ const transformConditionMediaLoaded = (data: unknown): boolean => {
return false;
};
/**
* Transform action frigate_ui -> camera_ui
* @param data Input data.
* @returns `true` if the configuration was modified.
*/
const transformFrigateUIAction = (data: unknown): boolean => {
if (
typeof data === 'object' &&
data &&
data['action'] === 'custom:frigate-card-action' &&
data['frigate_card_action'] === 'frigate_ui'
) {
data['frigate_card_action'] = 'camera_ui';
return true;
}
return false;
};
const UPGRADES = [
// v1.2.1 -> v2.0.0
upgradeMoveTo('frigate_url', 'frigate.url'),
@@ -671,7 +689,7 @@ const UPGRADES = [
upgradeWithOverrides(CONF_MENU_BUTTONS_SNAPSHOTS, menuButtonBooleanToObject),
upgradeWithOverrides(CONF_MENU_BUTTONS_IMAGE, menuButtonBooleanToObject),
upgradeWithOverrides(CONF_MENU_BUTTONS_DOWNLOAD, menuButtonBooleanToObject),
upgradeWithOverrides(CONF_MENU_BUTTONS_FRIGATE_UI, menuButtonBooleanToObject),
upgradeWithOverrides('menu.buttons.frigate_ui', menuButtonBooleanToObject),
upgradeWithOverrides(CONF_MENU_BUTTONS_FULLSCREEN, menuButtonBooleanToObject),
upgrade(CONF_LIVE_LAZY_UNLOAD, (val) =>
typeof val === 'boolean' ? (val ? 'all' : 'never') : undefined,
@@ -711,4 +729,10 @@ const UPGRADES = [
)(typeof data === 'object' && data ? data[CONF_ELEMENTS] : {});
},
upgradeMoveToWithOverrides('event_gallery', CONF_MEDIA_GALLERY),
upgradeMoveToWithOverrides('menu.buttons.frigate_ui', CONF_MENU_BUTTONS_CAMERA_UI),
(data: unknown): boolean => {
return recursiveUpgradeObject(transformFrigateUIAction)(
typeof data === 'object' && data ? <RawFrigateCardConfig>data : {},
);
},
];
+1 -1
View File
@@ -194,7 +194,7 @@ export const CONF_MENU_BUTTONS_CAMERAS = `${CONF_MENU}.buttons.cameras` as const
export const CONF_MENU_BUTTONS_CLIPS = `${CONF_MENU}.buttons.clips` as const;
export const CONF_MENU_BUTTONS_DOWNLOAD = `${CONF_MENU}.buttons.download` as const;
export const CONF_MENU_BUTTONS_FRIGATE = `${CONF_MENU}.buttons.frigate` as const;
export const CONF_MENU_BUTTONS_FRIGATE_UI = `${CONF_MENU}.buttons.frigate_ui` as const;
export const CONF_MENU_BUTTONS_CAMERA_UI = `${CONF_MENU}.buttons.camera_ui` as const;
export const CONF_MENU_BUTTONS_FULLSCREEN = `${CONF_MENU}.buttons.fullscreen` as const;
export const CONF_MENU_BUTTONS_IMAGE = `${CONF_MENU}.buttons.image` as const;
export const CONF_MENU_BUTTONS_LIVE = `${CONF_MENU}.buttons.live` as const;
+1 -1
View File
@@ -1579,7 +1579,7 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor
${this._renderMenuButton('recordings')}
${this._renderMenuButton('image') /* */}
${this._renderMenuButton('download')}
${this._renderMenuButton('frigate_ui')}
${this._renderMenuButton('camera_ui')}
${this._renderMenuButton('fullscreen')}
${this._renderMenuButton('timeline')}
${this._renderMenuButton('media_player')}
+1 -1
View File
@@ -215,12 +215,12 @@
"matching": "Matching the menu alignment",
"opposing": "Opposing the menu alignment"
},
"camera_ui": "Camera user interface",
"cameras": "Cameras",
"clips": "Clips",
"download": "Download",
"enabled": "Button enabled",
"frigate": "Frigate menu / Default view",
"frigate_ui": "Frigate user interface",
"fullscreen": "Fullscreen",
"icon": "Icon",
"image": "Image",
+1 -1
View File
@@ -209,12 +209,12 @@
"matching": "Corrispondenza con l'allineamento del menu",
"opposing": "Contrastare l'allineamento del menu"
},
"camera_ui": "",
"cameras": "Telecamere",
"clips": "Clip",
"download": "Download",
"enabled": "Pulsante abilitato",
"frigate": "Frigate menu / Visualizzazione predefinita",
"frigate_ui": "Frigate interfaccia utente",
"fullscreen": "A schermo intero",
"icon": "Icona",
"image": "Immagine",
+1 -1
View File
@@ -209,12 +209,12 @@
"matching": "Mesmo alinhamento do menu",
"opposing": "Opor-se ao alinhamento do menu"
},
"camera_ui": "",
"cameras": "Selecionar câmera",
"clips": "Clipes",
"download": "Baixe a mídia do evento",
"enabled": "Botão ativado",
"frigate": "Frigate menu / Visualização padrão",
"frigate_ui": "Frigate Interface de usuário",
"fullscreen": "Tela cheia",
"icon": "Ícone",
"image": "Imagem",
+3 -3
View File
@@ -210,7 +210,7 @@ const FRIGATE_CARD_GENERAL_ACTIONS = [
'snapshots',
'timeline',
'download',
'frigate_ui',
'camera_ui',
'fullscreen',
'menu_toggle',
'diagnostics',
@@ -937,7 +937,7 @@ const menuConfigDefault = {
image: hiddenButtonDefault,
timeline: visibleButtonDefault,
download: visibleButtonDefault,
frigate_ui: visibleButtonDefault,
camera_ui: visibleButtonDefault,
fullscreen: visibleButtonDefault,
media_player: visibleButtonDefault,
recordings: hiddenButtonDefault,
@@ -969,7 +969,7 @@ const menuConfigSchema = z
image: hiddenButtonSchema.default(menuConfigDefault.buttons.image),
timeline: visibleButtonSchema.default(menuConfigDefault.buttons.timeline),
download: visibleButtonSchema.default(menuConfigDefault.buttons.download),
frigate_ui: visibleButtonSchema.default(menuConfigDefault.buttons.frigate_ui),
camera_ui: visibleButtonSchema.default(menuConfigDefault.buttons.camera_ui),
fullscreen: visibleButtonSchema.default(menuConfigDefault.buttons.fullscreen),
media_player: visibleButtonSchema.default(
menuConfigDefault.buttons.media_player,