From 45b7ebbe46a71cdee4c6de74fdef334a67579630 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Mon, 18 Dec 2023 13:59:36 +0100 Subject: [PATCH] Add empty page to automation/script/scene config (#19075) --- src/layouts/hass-tabs-subpage-data-table.ts | 115 +++++++++++------- .../config/automation/ha-automation-picker.ts | 50 +++++++- src/panels/config/scene/ha-scene-dashboard.ts | 40 +++++- src/panels/config/script/ha-script-picker.ts | 41 ++++++- src/translations/en.json | 13 +- 5 files changed, 205 insertions(+), 54 deletions(-) diff --git a/src/layouts/hass-tabs-subpage-data-table.ts b/src/layouts/hass-tabs-subpage-data-table.ts index f891f6b1f9..7d3e90d623 100644 --- a/src/layouts/hass-tabs-subpage-data-table.ts +++ b/src/layouts/hass-tabs-subpage-data-table.ts @@ -124,6 +124,12 @@ export class HaTabsSubpageDataTable extends LitElement { */ @property({ type: String }) public noDataText?: string; + /** + * Hides the data table and show an empty message. + * @type {Boolean} + */ + @property({ type: Boolean }) public empty = false; + @property() public route!: Route; /** @@ -198,56 +204,61 @@ export class HaTabsSubpageDataTable extends LitElement { .mainPage=${this.mainPage} .supervisor=${this.supervisor} > - ${!this.hideFilterMenu - ? html` -
- ${this.narrow + ${this.empty + ? html`
+ ${this.noDataText} +
` + : html`${!this.hideFilterMenu + ? html` +
+ ${this.narrow + ? html` +
+ ${this.numHidden || this.activeFilters + ? html`${this.numHidden || "!"}` + : ""} + +
+ ` + : ""} +
+ ` + : ""} + ${this.narrow + ? html` +
+ +
${headerToolbar}
+
+
+ ` + : ""} + + ${!this.narrow ? html` -
- ${this.numHidden || this.activeFilters - ? html`${this.numHidden || "!"}` - : ""} - +
+ +
${headerToolbar}
+
` - : ""} -
- ` - : ""} - ${this.narrow - ? html` -
- -
${headerToolbar}
-
-
- ` - : ""} - - ${!this.narrow - ? html` -
- -
${headerToolbar}
-
-
- ` - : html`
`} -
+ : html`
`} +
`} +
`; @@ -374,6 +385,16 @@ export class HaTabsSubpageDataTable extends LitElement { .filter-menu { position: relative; } + .center { + display: flex; + align-items: center; + justify-content: center; + text-align: center; + box-sizing: border-box; + height: 100%; + width: 100%; + padding: 16px; + } `; } } diff --git a/src/panels/config/automation/ha-automation-picker.ts b/src/panels/config/automation/ha-automation-picker.ts index 2e0c917086..acde418b3f 100644 --- a/src/panels/config/automation/ha-automation-picker.ts +++ b/src/panels/config/automation/ha-automation-picker.ts @@ -7,11 +7,19 @@ import { mdiPlay, mdiPlayCircleOutline, mdiPlus, + mdiRobotHappy, mdiStopCircleOutline, mdiTransitConnection, } from "@mdi/js"; import "@lrnwebcomponents/simple-tooltip/simple-tooltip"; -import { CSSResultGroup, html, LitElement, TemplateResult } from "lit"; +import { + css, + CSSResultGroup, + html, + LitElement, + nothing, + TemplateResult, +} from "lit"; import { customElement, property, state } from "lit/decorators"; import memoizeOne from "memoize-one"; import { differenceInDays } from "date-fns/esm"; @@ -295,6 +303,7 @@ class HaAutomationPicker extends LitElement { .activeFilters=${this._activeFilters} .columns=${this._columns(this.narrow, this.hass.locale)} .data=${this._automations(this.automations, this._filteredAutomations)} + .empty=${!this.automations.length} @row-click=${this._handleRowClicked} .noDataText=${this.hass.localize( "ui.panel.config.automation.picker.no_automations" @@ -318,6 +327,35 @@ class HaAutomationPicker extends LitElement { @related-changed=${this._relatedFilterChanged} > + ${!this.automations.length + ? html`
+ +

+ ${this.hass.localize( + "ui.panel.config.automation.picker.empty_header" + )} +

+

+ ${this.hass.localize( + "ui.panel.config.automation.picker.empty_text_1" + )}
+ ${this.hass.localize( + "ui.panel.config.automation.picker.empty_text_2" + )} +

+ + + ${this.hass.localize( + "ui.panel.config.automation.picker.learn_more" + )} + + +
` + : nothing} + ${!this.scenes.length + ? html`
+ +

+ ${this.hass.localize( + "ui.panel.config.scene.picker.empty_header" + )} +

+

+ ${this.hass.localize("ui.panel.config.scene.picker.empty_text")} +

+ + + ${this.hass.localize( + "ui.panel.config.scene.picker.learn_more" + )} + + +
` + : nothing} + ${!this.scripts.length + ? html` ` + : nothing}