mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Add shortcut to label filter from label config page (#20313)
This commit is contained in:
parent
d8b43597a0
commit
bc8012dcc9
@ -379,7 +379,9 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
|
|||||||
<hass-tabs-subpage-data-table
|
<hass-tabs-subpage-data-table
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.narrow=${this.narrow}
|
.narrow=${this.narrow}
|
||||||
back-path="/config"
|
.backPath=${
|
||||||
|
this._searchParms.has("historyBack") ? undefined : "/config"
|
||||||
|
}
|
||||||
id="entity_id"
|
id="entity_id"
|
||||||
.route=${this.route}
|
.route=${this.route}
|
||||||
.tabs=${configSections.automations}
|
.tabs=${configSections.automations}
|
||||||
@ -728,6 +730,9 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
|
|||||||
if (this._searchParms.has("blueprint")) {
|
if (this._searchParms.has("blueprint")) {
|
||||||
this._filterBlueprint();
|
this._filterBlueprint();
|
||||||
}
|
}
|
||||||
|
if (this._searchParms.has("label")) {
|
||||||
|
this._filterLabel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _filterExpanded(ev) {
|
private _filterExpanded(ev) {
|
||||||
@ -815,6 +820,21 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
|
|||||||
this._filteredAutomations = items ? [...items] : undefined;
|
this._filteredAutomations = items ? [...items] : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _filterLabel() {
|
||||||
|
const label = this._searchParms.get("label");
|
||||||
|
if (!label) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._filters = {
|
||||||
|
...this._filters,
|
||||||
|
"ha-filter-labels": {
|
||||||
|
value: [label],
|
||||||
|
items: undefined,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
this._applyFilters();
|
||||||
|
}
|
||||||
|
|
||||||
private async _filterBlueprint() {
|
private async _filterBlueprint() {
|
||||||
const blueprint = this._searchParms.get("blueprint");
|
const blueprint = this._searchParms.get("blueprint");
|
||||||
if (!blueprint) {
|
if (!blueprint) {
|
||||||
|
@ -185,6 +185,23 @@ export class HaConfigDeviceDashboard extends SubscribeMixin(LitElement) {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
if (this._searchParms.has("label")) {
|
||||||
|
this._filterLabel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private _filterLabel() {
|
||||||
|
const label = this._searchParms.get("label");
|
||||||
|
if (!label) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._filters = {
|
||||||
|
...this._filters,
|
||||||
|
"ha-filter-labels": {
|
||||||
|
value: [label],
|
||||||
|
items: undefined,
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private _clearFilter() {
|
private _clearFilter() {
|
||||||
|
@ -758,6 +758,23 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
if (this._searchParms.has("label")) {
|
||||||
|
this._filterLabel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private _filterLabel() {
|
||||||
|
const label = this._searchParms.get("label");
|
||||||
|
if (!label) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._filters = {
|
||||||
|
...this._filters,
|
||||||
|
"ha-filter-labels": {
|
||||||
|
value: [label],
|
||||||
|
items: undefined,
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private _clearFilter() {
|
private _clearFilter() {
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
import { mdiDelete, mdiHelpCircle, mdiPlus } from "@mdi/js";
|
import {
|
||||||
|
mdiDelete,
|
||||||
|
mdiDevices,
|
||||||
|
mdiHelpCircle,
|
||||||
|
mdiPlus,
|
||||||
|
mdiRobot,
|
||||||
|
mdiShape,
|
||||||
|
} from "@mdi/js";
|
||||||
import { LitElement, PropertyValues, html, nothing } from "lit";
|
import { LitElement, PropertyValues, html, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
@ -28,6 +35,7 @@ import "../../../layouts/hass-tabs-subpage-data-table";
|
|||||||
import { HomeAssistant, Route } from "../../../types";
|
import { HomeAssistant, Route } from "../../../types";
|
||||||
import { configSections } from "../ha-panel-config";
|
import { configSections } from "../ha-panel-config";
|
||||||
import { showLabelDetailDialog } from "./show-dialog-label-detail";
|
import { showLabelDetailDialog } from "./show-dialog-label-detail";
|
||||||
|
import { navigate } from "../../../common/navigate";
|
||||||
|
|
||||||
@customElement("ha-config-labels")
|
@customElement("ha-config-labels")
|
||||||
export class HaConfigLabels extends LitElement {
|
export class HaConfigLabels extends LitElement {
|
||||||
@ -81,6 +89,21 @@ export class HaConfigLabels extends LitElement {
|
|||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
narrow
|
narrow
|
||||||
.items=${[
|
.items=${[
|
||||||
|
{
|
||||||
|
label: this.hass.localize("ui.panel.config.entities.caption"),
|
||||||
|
path: mdiShape,
|
||||||
|
action: () => this._navigateEntities(label),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: this.hass.localize("ui.panel.config.devices.caption"),
|
||||||
|
path: mdiDevices,
|
||||||
|
action: () => this._navigateDevices(label),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: this.hass.localize("ui.panel.config.automation.caption"),
|
||||||
|
path: mdiRobot,
|
||||||
|
action: () => this._navigateAutomations(label),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: this.hass.localize("ui.common.delete"),
|
label: this.hass.localize("ui.common.delete"),
|
||||||
path: mdiDelete,
|
path: mdiDelete,
|
||||||
@ -225,6 +248,20 @@ export class HaConfigLabels extends LitElement {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _navigateEntities(label: LabelRegistryEntry) {
|
||||||
|
navigate(`/config/entities?historyBack=1&label=${label.label_id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
private _navigateDevices(label: LabelRegistryEntry) {
|
||||||
|
navigate(`/config/devices/dashboard?historyBack=1&label=${label.label_id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
private _navigateAutomations(label: LabelRegistryEntry) {
|
||||||
|
navigate(
|
||||||
|
`/config/automation/dashboard?historyBack=1&label=${label.label_id}`
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
@ -96,6 +96,8 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) {
|
|||||||
|
|
||||||
@property({ attribute: false }) public scenes!: SceneEntity[];
|
@property({ attribute: false }) public scenes!: SceneEntity[];
|
||||||
|
|
||||||
|
@state() private _searchParms = new URLSearchParams(window.location.search);
|
||||||
|
|
||||||
@state() private _activeFilters?: string[];
|
@state() private _activeFilters?: string[];
|
||||||
|
|
||||||
@state() private _filteredScenes?: string[] | null;
|
@state() private _filteredScenes?: string[] | null;
|
||||||
@ -530,6 +532,27 @@ class HaSceneDashboard extends SubscribeMixin(LitElement) {
|
|||||||
this._applyFilters();
|
this._applyFilters();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
firstUpdated() {
|
||||||
|
if (this._searchParms.has("label")) {
|
||||||
|
this._filterLabel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private _filterLabel() {
|
||||||
|
const label = this._searchParms.get("label");
|
||||||
|
if (!label) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._filters = {
|
||||||
|
...this._filters,
|
||||||
|
"ha-filter-labels": {
|
||||||
|
value: [label],
|
||||||
|
items: undefined,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
this._applyFilters();
|
||||||
|
}
|
||||||
|
|
||||||
private _handleRowClicked(ev: HASSDomEvent<RowClickedEvent>) {
|
private _handleRowClicked(ev: HASSDomEvent<RowClickedEvent>) {
|
||||||
const scene = this.scenes.find((a) => a.entity_id === ev.detail.id);
|
const scene = this.scenes.find((a) => a.entity_id === ev.detail.id);
|
||||||
|
|
||||||
|
@ -572,6 +572,24 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
|
|||||||
if (this._searchParms.has("blueprint")) {
|
if (this._searchParms.has("blueprint")) {
|
||||||
this._filterBlueprint();
|
this._filterBlueprint();
|
||||||
}
|
}
|
||||||
|
if (this._searchParms.has("label")) {
|
||||||
|
this._filterLabel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private _filterLabel() {
|
||||||
|
const label = this._searchParms.get("label");
|
||||||
|
if (!label) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._filters = {
|
||||||
|
...this._filters,
|
||||||
|
"ha-filter-labels": {
|
||||||
|
value: [label],
|
||||||
|
items: undefined,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
this._applyFilters();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _filterBlueprint() {
|
private async _filterBlueprint() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user