mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-26 02:36:37 +00:00
parent
abd02eda0f
commit
f539516252
@ -32,6 +32,7 @@ import "../../../components/ha-filter-devices";
|
|||||||
import "../../../components/ha-filter-floor-areas";
|
import "../../../components/ha-filter-floor-areas";
|
||||||
import "../../../components/ha-filter-integrations";
|
import "../../../components/ha-filter-integrations";
|
||||||
import "../../../components/ha-filter-states";
|
import "../../../components/ha-filter-states";
|
||||||
|
import "../../../components/ha-filter-labels";
|
||||||
import "../../../components/ha-icon-button";
|
import "../../../components/ha-icon-button";
|
||||||
import "../../../components/ha-alert";
|
import "../../../components/ha-alert";
|
||||||
import { ConfigEntry, sortConfigEntries } from "../../../data/config_entries";
|
import { ConfigEntry, sortConfigEntries } from "../../../data/config_entries";
|
||||||
@ -221,16 +222,16 @@ export class HaConfigDeviceDashboard extends LitElement {
|
|||||||
|
|
||||||
const filteredDomains = new Set<string>();
|
const filteredDomains = new Set<string>();
|
||||||
|
|
||||||
Object.entries(filters).forEach(([key, flter]) => {
|
Object.entries(filters).forEach(([key, filter]) => {
|
||||||
if (key === "config_entry" && flter.value?.length) {
|
if (key === "config_entry" && filter.value?.length) {
|
||||||
outputDevices = outputDevices.filter((device) =>
|
outputDevices = outputDevices.filter((device) =>
|
||||||
device.config_entries.some((entryId) =>
|
device.config_entries.some((entryId) =>
|
||||||
flter.value?.includes(entryId)
|
filter.value?.includes(entryId)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
const configEntries = entries.filter(
|
const configEntries = entries.filter(
|
||||||
(entry) => entry.entry_id && flter.value?.includes(entry.entry_id)
|
(entry) => entry.entry_id && filter.value?.includes(entry.entry_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
configEntries.forEach((configEntry) => {
|
configEntries.forEach((configEntry) => {
|
||||||
@ -239,17 +240,21 @@ export class HaConfigDeviceDashboard extends LitElement {
|
|||||||
if (configEntries.length === 1) {
|
if (configEntries.length === 1) {
|
||||||
filteredConfigEntry = configEntries[0];
|
filteredConfigEntry = configEntries[0];
|
||||||
}
|
}
|
||||||
} else if (key === "ha-filter-integrations" && flter.value?.length) {
|
} else if (key === "ha-filter-integrations" && filter.value?.length) {
|
||||||
const entryIds = entries
|
const entryIds = entries
|
||||||
.filter((entry) => flter.value!.includes(entry.domain))
|
.filter((entry) => filter.value!.includes(entry.domain))
|
||||||
.map((entry) => entry.entry_id);
|
.map((entry) => entry.entry_id);
|
||||||
outputDevices = outputDevices.filter((device) =>
|
outputDevices = outputDevices.filter((device) =>
|
||||||
device.config_entries.some((entryId) => entryIds.includes(entryId))
|
device.config_entries.some((entryId) => entryIds.includes(entryId))
|
||||||
);
|
);
|
||||||
flter.value!.forEach((domain) => filteredDomains.add(domain));
|
filter.value!.forEach((domain) => filteredDomains.add(domain));
|
||||||
} else if (flter.items) {
|
} else if (key === "ha-filter-labels" && filter.value?.length) {
|
||||||
outputDevices = outputDevices.filter((device) =>
|
outputDevices = outputDevices.filter((device) =>
|
||||||
flter.items!.has(device.id)
|
device.labels.some((lbl) => filter.value!.includes(lbl))
|
||||||
|
);
|
||||||
|
} else if (filter.items) {
|
||||||
|
outputDevices = outputDevices.filter((device) =>
|
||||||
|
filter.items!.has(device.id)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -531,6 +536,15 @@ export class HaConfigDeviceDashboard extends LitElement {
|
|||||||
.narrow=${this.narrow}
|
.narrow=${this.narrow}
|
||||||
@expanded-changed=${this._filterExpanded}
|
@expanded-changed=${this._filterExpanded}
|
||||||
></ha-filter-states>
|
></ha-filter-states>
|
||||||
|
<ha-filter-labels
|
||||||
|
.hass=${this.hass}
|
||||||
|
.value=${this._filters["ha-filter-labels"]?.value}
|
||||||
|
@data-table-filter-changed=${this._filterChanged}
|
||||||
|
slot="filter-pane"
|
||||||
|
.expanded=${this._expandedFilter === "ha-filter-labels"}
|
||||||
|
.narrow=${this.narrow}
|
||||||
|
@expanded-changed=${this._filterExpanded}
|
||||||
|
></ha-filter-labels>
|
||||||
</hass-tabs-subpage-data-table>
|
</hass-tabs-subpage-data-table>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ import "../../../components/ha-filter-devices";
|
|||||||
import "../../../components/ha-filter-floor-areas";
|
import "../../../components/ha-filter-floor-areas";
|
||||||
import "../../../components/ha-filter-integrations";
|
import "../../../components/ha-filter-integrations";
|
||||||
import "../../../components/ha-filter-states";
|
import "../../../components/ha-filter-states";
|
||||||
|
import "../../../components/ha-filter-labels";
|
||||||
import "../../../components/ha-icon";
|
import "../../../components/ha-icon";
|
||||||
import "../../../components/ha-icon-button";
|
import "../../../components/ha-icon-button";
|
||||||
import "../../../components/ha-svg-icon";
|
import "../../../components/ha-svg-icon";
|
||||||
@ -337,12 +338,12 @@ export class HaConfigEntities extends LitElement {
|
|||||||
let filteredConfigEntry: ConfigEntry | undefined;
|
let filteredConfigEntry: ConfigEntry | undefined;
|
||||||
const filteredDomains = new Set<string>();
|
const filteredDomains = new Set<string>();
|
||||||
|
|
||||||
Object.entries(filters).forEach(([key, flter]) => {
|
Object.entries(filters).forEach(([key, filter]) => {
|
||||||
if (key === "config_entry" && flter.value?.length) {
|
if (key === "config_entry" && filter.value?.length) {
|
||||||
filteredEntities = filteredEntities.filter(
|
filteredEntities = filteredEntities.filter(
|
||||||
(entity) =>
|
(entity) =>
|
||||||
entity.config_entry_id &&
|
entity.config_entry_id &&
|
||||||
flter.value?.includes(entity.config_entry_id)
|
filter.value?.includes(entity.config_entry_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!entries) {
|
if (!entries) {
|
||||||
@ -351,7 +352,7 @@ export class HaConfigEntities extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const configEntries = entries.filter(
|
const configEntries = entries.filter(
|
||||||
(entry) => entry.entry_id && flter.value?.includes(entry.entry_id)
|
(entry) => entry.entry_id && filter.value?.includes(entry.entry_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
configEntries.forEach((configEntry) => {
|
configEntries.forEach((configEntry) => {
|
||||||
@ -360,23 +361,27 @@ export class HaConfigEntities extends LitElement {
|
|||||||
if (configEntries.length === 1) {
|
if (configEntries.length === 1) {
|
||||||
filteredConfigEntry = configEntries[0];
|
filteredConfigEntry = configEntries[0];
|
||||||
}
|
}
|
||||||
} else if (key === "ha-filter-integrations" && flter.value?.length) {
|
} else if (key === "ha-filter-integrations" && filter.value?.length) {
|
||||||
if (!entries) {
|
if (!entries) {
|
||||||
this._loadConfigEntries();
|
this._loadConfigEntries();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const entryIds = entries
|
const entryIds = entries
|
||||||
.filter((entry) => flter.value!.includes(entry.domain))
|
.filter((entry) => filter.value!.includes(entry.domain))
|
||||||
.map((entry) => entry.entry_id);
|
.map((entry) => entry.entry_id);
|
||||||
filteredEntities = filteredEntities.filter(
|
filteredEntities = filteredEntities.filter(
|
||||||
(entity) =>
|
(entity) =>
|
||||||
entity.config_entry_id &&
|
entity.config_entry_id &&
|
||||||
entryIds.includes(entity.config_entry_id)
|
entryIds.includes(entity.config_entry_id)
|
||||||
);
|
);
|
||||||
flter.value!.forEach((domain) => filteredDomains.add(domain));
|
filter.value!.forEach((domain) => filteredDomains.add(domain));
|
||||||
} else if (flter.items) {
|
} else if (key === "ha-filter-labels" && filter.value?.length) {
|
||||||
filteredEntities = filteredEntities.filter((entity) =>
|
filteredEntities = filteredEntities.filter((entity) =>
|
||||||
flter.items!.has(entity.entity_id)
|
entity.labels.some((lbl) => filter.value!.includes(lbl))
|
||||||
|
);
|
||||||
|
} else if (filter.items) {
|
||||||
|
filteredEntities = filteredEntities.filter((entity) =>
|
||||||
|
filter.items!.has(entity.entity_id)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -633,6 +638,15 @@ export class HaConfigEntities extends LitElement {
|
|||||||
.narrow=${this.narrow}
|
.narrow=${this.narrow}
|
||||||
@expanded-changed=${this._filterExpanded}
|
@expanded-changed=${this._filterExpanded}
|
||||||
></ha-filter-states>
|
></ha-filter-states>
|
||||||
|
<ha-filter-labels
|
||||||
|
.hass=${this.hass}
|
||||||
|
.value=${this._filters["ha-filter-labels"]?.value}
|
||||||
|
@data-table-filter-changed=${this._filterChanged}
|
||||||
|
slot="filter-pane"
|
||||||
|
.expanded=${this._expandedFilter === "ha-filter-labels"}
|
||||||
|
.narrow=${this.narrow}
|
||||||
|
@expanded-changed=${this._filterExpanded}
|
||||||
|
></ha-filter-labels>
|
||||||
${includeAddDeviceFab
|
${includeAddDeviceFab
|
||||||
? html`<ha-fab
|
? html`<ha-fab
|
||||||
.label=${this.hass.localize("ui.panel.config.devices.add_device")}
|
.label=${this.hass.localize("ui.panel.config.devices.add_device")}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user