Merge pull request #321 from dermotduffy/editor-overrides

Add warning in editor if overrides are present
This commit is contained in:
Dermot Duffy
2022-02-05 14:56:16 -08:00
committed by GitHub
3 changed files with 46 additions and 3 deletions
+33 -1
View File
@@ -155,6 +155,12 @@ const options: EditorOptions = {
secondary: localize('editor.dimensions_secondary'), secondary: localize('editor.dimensions_secondary'),
show: false, show: false,
}, },
overrides: {
icon: 'file-replace',
name: localize('editor.overrides'),
secondary: localize('editor.overrides_secondary'),
show: false,
},
}; };
@customElement('frigate-card-editor') @customElement('frigate-card-editor')
@@ -302,7 +308,7 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor
return html` return html`
<div <div
class="option" class="option option-${optionSetName}"
@click=${this._toggleOptionHandler} @click=${this._toggleOptionHandler}
.optionSetName=${optionSetName} .optionSetName=${optionSetName}
> >
@@ -364,6 +370,15 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor
`; `;
} }
/**
* Render a number slider.
* @param configPath Configuration path of the variable.
* @param valueDefault The default value.
* @param icon The icon to use on the slider.
* @param min The minimum value.
* @param max The maximum value.
* @returns A rendered template.
*/
protected _renderSlider( protected _renderSlider(
configPath: string, configPath: string,
valueDefault: number, valueDefault: number,
@@ -388,6 +403,15 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor
</ha-labeled-slider>`; </ha-labeled-slider>`;
} }
/**
* Render a simple text info box.
* @param info The string to display.
* @returns A rendered template.
*/
protected _renderInfo(info: string): TemplateResult {
return html` <span class="info">${info}</span>`;
}
/** /**
* Render a camera header. * Render a camera header.
* @param cameraIndex The index of the camera to edit/add. * @param cameraIndex The index of the camera to edit/add.
@@ -856,6 +880,14 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor
${this._renderStringInput(CONF_DIMENSIONS_ASPECT_RATIO)} ${this._renderStringInput(CONF_DIMENSIONS_ASPECT_RATIO)}
</div>` </div>`
: ''} : ''}
${this._config['overrides'] !== undefined
? html` ${this._renderOptionSetHeader('overrides')}
${options.overrides.show
? html` <div class="values">
${this._renderInfo(localize('config.overrides.info'))}
</div>`
: ''}`
: html``}
</div> </div>
`; `;
} }
+6 -1
View File
@@ -160,6 +160,9 @@
"dynamic": "Aspect ratio adjusts to media", "dynamic": "Aspect ratio adjusts to media",
"static": "Static aspect ratio" "static": "Static aspect ratio"
} }
},
"overrides": {
"info": "This card configuration has manually specified overrides configured which may override values shown in the visual editor, please consult the code editor to view/modify these overrides"
} }
}, },
"editor": { "editor": {
@@ -186,7 +189,9 @@
"move_up": "Move up", "move_up": "Move up",
"move_down": "Move down", "move_down": "Move down",
"add_new_camera": "Add new camera", "add_new_camera": "Add new camera",
"camera": "Camera" "camera": "Camera",
"overrides": "Overrides are active",
"overrides_secondary": "Dynamic configuration overrides detected"
}, },
"error": { "error": {
"empty_response": "Received empty response from Home Assistant for request", "empty_response": "Received empty response from Home Assistant for request",
+7 -1
View File
@@ -1,9 +1,12 @@
@use './button.scss'; @use './button.scss';
.option { .option {
padding: 4px 0px; padding: 4px 4px;
cursor: pointer; cursor: pointer;
} }
.option.option-overrides .title {
color: var(--warning-color);
}
.row { .row {
display: flex; display: flex;
margin-bottom: -14px; margin-bottom: -14px;
@@ -70,4 +73,7 @@ div.upgrade span {
.cameras .controls ha-icon-button.button { .cameras .controls ha-icon-button.button {
--mdc-icon-button-size: 32px; --mdc-icon-button-size: 32px;
--mdc-icon-size: calc(var(--mdc-icon-button-size) / 2); --mdc-icon-size: calc(var(--mdc-icon-button-size) / 2);
}
span.info {
padding: 4px;
} }