mirror of
https://github.com/DigiLive/mushroom-strategy.git
synced 2025-08-04 20:14:28 +02:00
Merge pull request #47 from AalianKhan/hide-default-domain
Fix hiding default domain
This commit is contained in:
2
dist/mushroom-strategy.js
vendored
2
dist/mushroom-strategy.js
vendored
File diff suppressed because one or more lines are too long
@@ -188,52 +188,54 @@ class MushroomStrategy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Check if default is hidden
|
if (!Helper.strategyOptions.domains.default.hidden) {
|
||||||
// Create cards for any other domain.
|
// TODO: Check if default is hidden
|
||||||
// Collect device entities of the current area.
|
// Create cards for any other domain.
|
||||||
const areaDevices = Helper.devices.filter(device => device.area_id === area.area_id)
|
// Collect device entities of the current area.
|
||||||
.map(device => device.id);
|
const areaDevices = Helper.devices.filter(device => device.area_id === area.area_id)
|
||||||
|
.map(device => device.id);
|
||||||
// Collect the remaining entities of which all conditions below are met:
|
|
||||||
// 1. The entity is linked to a device which is linked to the current area,
|
// Collect the remaining entities of which all conditions below are met:
|
||||||
// or the entity itself is linked to the current area.
|
// 1. The entity is linked to a device which is linked to the current area,
|
||||||
// 2. The entity is not hidden and is not disabled.
|
// or the entity itself is linked to the current area.
|
||||||
const miscellaneousEntities = Helper.entities.filter(entity => {
|
// 2. The entity is not hidden and is not disabled.
|
||||||
return (areaDevices.includes(entity.device_id) || entity.area_id === area.area_id)
|
const miscellaneousEntities = Helper.entities.filter(entity => {
|
||||||
&& entity.hidden_by == null
|
return (areaDevices.includes(entity.device_id) || entity.area_id === area.area_id)
|
||||||
&& entity.disabled_by == null
|
&& entity.hidden_by == null
|
||||||
&& !exposedDomainIds.includes(entity.entity_id.split(".", 1)[0]);
|
&& entity.disabled_by == null
|
||||||
});
|
&& !exposedDomainIds.includes(entity.entity_id.split(".", 1)[0]);
|
||||||
|
|
||||||
// Create a column of miscellaneous entity cards.
|
|
||||||
if (miscellaneousEntities.length) {
|
|
||||||
let miscellaneousCards = [];
|
|
||||||
|
|
||||||
try {
|
|
||||||
miscellaneousCards = await import("./cards/MiscellaneousCard").then(cardModule => {
|
|
||||||
/** @type Object[] */
|
|
||||||
const miscellaneousCards = [
|
|
||||||
new TitleCard([area], Helper.strategyOptions.domains.default).createCard(),
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const entity of miscellaneousEntities) {
|
|
||||||
let cardOptions = Helper.strategyOptions.card_options?.[entity.entity_id] ?? {};
|
|
||||||
|
|
||||||
if (!cardOptions.hidden) {
|
|
||||||
miscellaneousCards.push(new cardModule.MiscellaneousCard(entity, cardOptions).getCard());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return miscellaneousCards;
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
console.error(Helper.debug ? e : "An error occurred while creating the domain cards!");
|
|
||||||
}
|
|
||||||
|
|
||||||
viewCards.push({
|
|
||||||
type: "vertical-stack",
|
|
||||||
cards: miscellaneousCards,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Create a column of miscellaneous entity cards.
|
||||||
|
if (miscellaneousEntities.length) {
|
||||||
|
let miscellaneousCards = [];
|
||||||
|
|
||||||
|
try {
|
||||||
|
miscellaneousCards = await import("./cards/MiscellaneousCard").then(cardModule => {
|
||||||
|
/** @type Object[] */
|
||||||
|
const miscellaneousCards = [
|
||||||
|
new TitleCard([area], Helper.strategyOptions.domains.default).createCard(),
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const entity of miscellaneousEntities) {
|
||||||
|
let cardOptions = Helper.strategyOptions.card_options?.[entity.entity_id] ?? {};
|
||||||
|
|
||||||
|
if (!cardOptions.hidden) {
|
||||||
|
miscellaneousCards.push(new cardModule.MiscellaneousCard(entity, cardOptions).getCard());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return miscellaneousCards;
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error(Helper.debug ? e : "An error occurred while creating the domain cards!");
|
||||||
|
}
|
||||||
|
|
||||||
|
viewCards.push({
|
||||||
|
type: "vertical-stack",
|
||||||
|
cards: miscellaneousCards,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return cards.
|
// Return cards.
|
||||||
|
Reference in New Issue
Block a user