forked from DigiLive/mushroom-strategy
Add a showControls option to all domains
Adds the `showControls` option to the all-domains configuration to allow hiding the control buttons at a domain view or for the domains at an area view. Closes #126.
This commit is contained in:
@@ -19,7 +19,6 @@ class HeaderCard {
|
||||
static getDefaultConfig(): StrategyHeaderCardConfig {
|
||||
return {
|
||||
type: 'custom:mushroom-title-card',
|
||||
showControls: true,
|
||||
iconOn: 'mdi:power-on',
|
||||
iconOff: 'mdi:power-off',
|
||||
onService: 'none',
|
||||
|
@@ -38,6 +38,7 @@ export const ConfigurationDefaults: StrategyDefaults = {
|
||||
_: {
|
||||
hide_config_entities: undefined,
|
||||
hide_diagnostic_entities: undefined,
|
||||
showControls: true,
|
||||
},
|
||||
binary_sensor: {
|
||||
title: `${localize('sensor.binary')} ` + localize('sensor.sensors'),
|
||||
@@ -56,7 +57,6 @@ export const ConfigurationDefaults: StrategyDefaults = {
|
||||
},
|
||||
cover: {
|
||||
title: localize('cover.covers'),
|
||||
showControls: true,
|
||||
iconOn: 'mdi:arrow-up',
|
||||
iconOff: 'mdi:arrow-down',
|
||||
onService: 'cover.open_cover',
|
||||
@@ -70,7 +70,6 @@ export const ConfigurationDefaults: StrategyDefaults = {
|
||||
},
|
||||
fan: {
|
||||
title: localize('fan.fans'),
|
||||
showControls: true,
|
||||
iconOn: 'mdi:fan',
|
||||
iconOff: 'mdi:fan-off',
|
||||
onService: 'fan.turn_on',
|
||||
@@ -84,7 +83,6 @@ export const ConfigurationDefaults: StrategyDefaults = {
|
||||
},
|
||||
light: {
|
||||
title: localize('light.lights'),
|
||||
showControls: true,
|
||||
iconOn: 'mdi:lightbulb',
|
||||
iconOff: 'mdi:lightbulb-off',
|
||||
onService: 'light.turn_on',
|
||||
@@ -124,7 +122,6 @@ export const ConfigurationDefaults: StrategyDefaults = {
|
||||
},
|
||||
switch: {
|
||||
title: localize('switch.switches'),
|
||||
showControls: true,
|
||||
iconOn: 'mdi:power-plug',
|
||||
iconOff: 'mdi:power-plug-off',
|
||||
onService: 'switch.turn_on',
|
||||
|
@@ -123,7 +123,10 @@ class MushroomStrategy extends HTMLTemplateElement {
|
||||
|
||||
const titleCard = new HeaderCard(
|
||||
{ entity_id: entities.map((entity) => entity.entity_id) },
|
||||
Registry.strategyOptions.domains[domain],
|
||||
{
|
||||
...Registry.strategyOptions.domains['_'],
|
||||
...Registry.strategyOptions.domains[domain],
|
||||
},
|
||||
).createCard();
|
||||
|
||||
try {
|
||||
|
@@ -12,7 +12,7 @@ export type AbstractCardConfig = LovelaceCardConfig & EntitySharedConfig & Appea
|
||||
/**
|
||||
* Header Card Config.
|
||||
*
|
||||
* @property {boolean} [showControls=true] - False to hide controls.
|
||||
* @property {boolean} [showControls] - False to hide controls.
|
||||
* @property {string} [iconOn] - Icon to show for switching entities from the off state.
|
||||
* @property {string} [iconOff] - Icon to show for switching entities to the off state.
|
||||
* @property {string} [onService=none] - Service to call for switching entities from the off state.
|
||||
|
@@ -172,14 +172,14 @@ export interface ViewInfo {
|
||||
/**
|
||||
* All-Domains Configuration.
|
||||
*
|
||||
* @property {boolean | undefined} hide_config_entities - If True, all configuration entities are hidden from the
|
||||
* dashboard.
|
||||
* @property {boolean | undefined} hide_diagnostic_entities - If True, all diagnostic entities are hidden from the
|
||||
* dashboard.
|
||||
* @property {boolean} [hide_config_entities] - If True, all configuration entities are hidden from the dashboard.
|
||||
* @property {boolean} [hide_diagnostic_entities] - If True, all diagnostic entities are hidden from the dashboard.
|
||||
* @property {boolean} [showControls] - False to hide controls.
|
||||
*/
|
||||
export interface AllDomainsConfig {
|
||||
hide_config_entities: boolean | undefined;
|
||||
hide_diagnostic_entities: boolean | undefined;
|
||||
hide_config_entities?: boolean;
|
||||
hide_diagnostic_entities?: boolean;
|
||||
showControls?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -22,7 +22,7 @@ import RegistryFilter from '../utilities/RegistryFilter';
|
||||
*/
|
||||
abstract class AbstractView {
|
||||
/** The base configuration of a view. */
|
||||
protected baseConfiguration: LovelaceViewConfig = {
|
||||
protected baseConfiguration: ViewConfig = {
|
||||
icon: 'mdi:view-dashboard',
|
||||
subview: false,
|
||||
};
|
||||
@@ -143,10 +143,14 @@ abstract class AbstractView {
|
||||
): void {
|
||||
this.baseConfiguration = { ...this.baseConfiguration, ...viewConfiguration, ...customConfiguration };
|
||||
|
||||
this.baseConfiguration.headerCardConfiguration = {
|
||||
showControls:
|
||||
Registry.strategyOptions.domains[this.domain as Exclude<SupportedDomains, 'home'>]?.showControls ??
|
||||
Registry.strategyOptions.domains['_'].showControls,
|
||||
};
|
||||
|
||||
this.viewHeaderCardConfiguration = new HeaderCard(this.getDomainTargets(), {
|
||||
...(('headerCardConfiguration' in this.baseConfiguration
|
||||
? this.baseConfiguration.headerCardConfiguration
|
||||
: {}) as StrategyHeaderCardConfig),
|
||||
...(this.baseConfiguration.headerCardConfiguration as StrategyHeaderCardConfig),
|
||||
...headerCardConfig,
|
||||
}).createCard();
|
||||
}
|
||||
|
Reference in New Issue
Block a user