Add editor support.

This commit is contained in:
Dermot Duffy
2023-10-10 20:16:00 -07:00
parent 50a979b06b
commit ac0eab40a2
6 changed files with 93 additions and 2 deletions
+5
View File
@@ -6,6 +6,11 @@ export const CONF_CAMERAS_ARRAY_CAMERA_ENTITY =
`${CONF_CAMERAS}.#.camera_entity` as const;
export const CONF_CAMERAS_ARRAY_FRIGATE_CAMERA_NAME =
`${CONF_CAMERAS}.#.frigate.camera_name` as const;
export const CONF_CAMERAS_ARRAY_CAST_METHOD = `${CONF_CAMERAS}.#.cast.method` as const;
export const CONF_CAMERAS_ARRAY_CAST_DASHBOARD_DASHBOARD_PATH =
`${CONF_CAMERAS}.#.cast.dashboard.dashboard_path` as const;
export const CONF_CAMERAS_ARRAY_CAST_DASHBOARD_VIEW_PATH =
`${CONF_CAMERAS}.#.cast.dashboard.view_path` as const;
export const CONF_CAMERAS_ARRAY_FRIGATE_CLIENT_ID =
`${CONF_CAMERAS}.#.frigate.client_id` as const;
export const CONF_CAMERAS_ARRAY_FRIGATE_LABELS =
+39 -1
View File
@@ -1,4 +1,8 @@
import { fireEvent, HomeAssistant, LovelaceCardEditor } from '@dermotduffy/custom-card-helpers';
import {
fireEvent,
HomeAssistant,
LovelaceCardEditor,
} from '@dermotduffy/custom-card-helpers';
import { CSSResultGroup, html, LitElement, TemplateResult, unsafeCSS } from 'lit';
import { customElement, property, state } from 'lit/decorators.js';
import { classMap } from 'lit/directives/class-map.js';
@@ -29,6 +33,9 @@ import {
import {
CONF_CAMERAS,
CONF_CAMERAS_ARRAY_CAMERA_ENTITY,
CONF_CAMERAS_ARRAY_CAST_DASHBOARD_DASHBOARD_PATH,
CONF_CAMERAS_ARRAY_CAST_DASHBOARD_VIEW_PATH,
CONF_CAMERAS_ARRAY_CAST_METHOD,
CONF_CAMERAS_ARRAY_DEPENDENCIES_ALL_CAMERAS,
CONF_CAMERAS_ARRAY_DEPENDENCIES_CAMERAS,
CONF_CAMERAS_ARRAY_FRIGATE_CAMERA_NAME,
@@ -191,6 +198,7 @@ import {
const MENU_BUTTONS = 'buttons';
const MENU_CAMERAS = 'cameras';
const MENU_CAMERAS_CAST = 'cameras.cast';
const MENU_CAMERAS_DEPENDENCIES = 'cameras.dependencies';
const MENU_CAMERAS_ENGINE = 'cameras.engine';
const MENU_CAMERAS_FRIGATE = 'cameras.frigate';
@@ -561,6 +569,12 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor
{ value: 'grid', label: localize('display_modes.grid') },
];
protected _castMethods: EditorSelectOption[] = [
{ value: '', label: '' },
{ value: 'standard', label: localize('config.cameras.cast.methods.standard') },
{ value: 'dashboard', label: localize('config.cameras.cast.methods.dashboard') },
];
public setConfig(config: RawFrigateCardConfig): void {
// Note: This does not use Zod to parse the configuration, so it may be
// partially or completely invalid. It's more useful to have a partially
@@ -1662,6 +1676,30 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor
},
)}`,
)}
${this._putInSubmenu(
MENU_CAMERAS_CAST,
cameraIndex,
'config.cameras.cast.editor_label',
{ name: 'mdi:cast' },
html`
${this._renderOptionSelector(
getArrayConfigPath(CONF_CAMERAS_ARRAY_CAST_METHOD, cameraIndex),
this._castMethods,
)}
${this._renderStringInput(
getArrayConfigPath(
CONF_CAMERAS_ARRAY_CAST_DASHBOARD_DASHBOARD_PATH,
cameraIndex,
),
)}
${this._renderStringInput(
getArrayConfigPath(
CONF_CAMERAS_ARRAY_CAST_DASHBOARD_VIEW_PATH,
cameraIndex,
),
)}
`,
)}
</div>`
: ``}
</div>
+13 -1
View File
@@ -10,6 +10,18 @@
"config": {
"cameras": {
"camera_entity": "Camera Entity",
"cast": {
"dashboard": {
"dashboard_path": "Dashboard path",
"view_path": "View path"
},
"editor_label": "Cast Options",
"method": "Cast method",
"methods": {
"standard": "Standard",
"dashboard": "Dashboard"
}
},
"dependencies": {
"all_cameras": "Show events for all cameras with this camera",
"cameras": "Show events for specific cameras with this camera",
@@ -522,4 +534,4 @@
},
"select_date": "Choose date"
}
}
}
+12
View File
@@ -10,6 +10,18 @@
"config": {
"cameras": {
"camera_entity": "Entità della telecamera",
"cast": {
"dashboard": {
"dashboard_path": "",
"view_path": ""
},
"editor_label": "",
"method": "",
"methods": {
"standard": "",
"dashboard": ""
}
},
"dependencies": {
"all_cameras": "Mostra eventi per tutte le telecamere con questa telecamera",
"cameras": "Mostra eventi per telecamere specifiche con questa telecamera",
+12
View File
@@ -10,6 +10,18 @@
"config": {
"cameras": {
"camera_entity": "Entidade da Câmera",
"cast": {
"dashboard": {
"dashboard_path": "",
"view_path": ""
},
"editor_label": "",
"method": "",
"methods": {
"standard": "",
"dashboard": ""
}
},
"dependencies": {
"all_cameras": "Mostrar eventos para todas as câmeras nesta câmera",
"cameras": "Mostrar eventos para câmeras específicas nesta câmera",
+12
View File
@@ -10,6 +10,18 @@
"config": {
"cameras": {
"camera_entity": "Entidade da Câmera",
"cast": {
"dashboard": {
"dashboard_path": "",
"view_path": ""
},
"editor_label": "",
"method": "",
"methods": {
"standard": "",
"dashboard": ""
}
},
"dependencies": {
"all_cameras": "Mostrar eventos para todas as câmeras nesta câmera",
"cameras": "Mostrar eventos para câmeras específicas nesta câmera",