Fix Home and Phone settings states
This commit is contained in:
@@ -4,25 +4,38 @@ import qs.services
|
||||
|
||||
Item {
|
||||
id: root
|
||||
objectName: "home-phone-page"
|
||||
|
||||
property string lightQuery: searchInput.text.trim().toLowerCase()
|
||||
|
||||
readonly property var availableLights: HomeAssistant.catalog.filter(entity => {
|
||||
if (HomePreferences.isSelected(entity.id))
|
||||
if (HomeAssistant.selectedEntities.some(selected => selected.id === entity.id))
|
||||
return false;
|
||||
const haystack = (entity.sourceName + " " + entity.id).toLowerCase();
|
||||
return root.lightQuery === "" || haystack.includes(root.lightQuery);
|
||||
})
|
||||
readonly property string availableEmptyText: root.availableLights.length > 0
|
||||
? ""
|
||||
: (root.lightQuery !== ""
|
||||
? "No lights match that search"
|
||||
: (HomeAssistant.catalog.length === 0
|
||||
? "No lights discovered"
|
||||
: "All discovered lights are already selected"))
|
||||
readonly property var pageDiagnostics: ({
|
||||
availableLightIds: root.availableLights.map(entity => entity.id),
|
||||
availableEmptyText: root.availableEmptyText,
|
||||
homeStatus: root.homeStatus()
|
||||
})
|
||||
|
||||
function homeStatus(): string {
|
||||
if (HomeAssistant.phase === "ready")
|
||||
return `Connected · ${HomeAssistant.discoveredCount} lights discovered`;
|
||||
if (HomeAssistant.phase === "degraded")
|
||||
return "Last update unavailable · showing saved controls";
|
||||
if (HomeAssistant.lastError === "authentication-required")
|
||||
return "Authentication required";
|
||||
if (HomeAssistant.lastError === "not-configured")
|
||||
return "Home Assistant is not configured";
|
||||
if (HomeAssistant.phase === "ready")
|
||||
return `Connected · ${HomeAssistant.discoveredCount} lights discovered`;
|
||||
if (HomeAssistant.phase === "degraded")
|
||||
return "Last update unavailable · showing saved controls";
|
||||
if (HomeAssistant.phase === "loading")
|
||||
return "Connecting to Home Assistant";
|
||||
return "Home Assistant is unavailable";
|
||||
@@ -250,9 +263,7 @@ Item {
|
||||
Text {
|
||||
width: parent.width
|
||||
visible: root.availableLights.length === 0
|
||||
text: root.lightQuery === "" && HomeAssistant.catalog.length > 0
|
||||
? "All discovered lights are already selected"
|
||||
: "No lights match that search"
|
||||
text: root.availableEmptyText
|
||||
color: Theme.fgDim
|
||||
font.family: Theme.fontFamily
|
||||
font.pixelSize: Theme.fontSize
|
||||
|
||||
@@ -6,6 +6,11 @@ Rectangle {
|
||||
id: root
|
||||
|
||||
property var hostWindow: null
|
||||
readonly property var homePhoneDiagnostics: pageLoader.status === Loader.Ready
|
||||
&& pageLoader.item
|
||||
&& pageLoader.item.objectName === "home-phone-page"
|
||||
? pageLoader.item.pageDiagnostics
|
||||
: ({})
|
||||
|
||||
color: Theme.bg
|
||||
radius: 18
|
||||
|
||||
@@ -6,6 +6,8 @@ import qs.services
|
||||
FloatingWindow {
|
||||
id: root
|
||||
|
||||
readonly property var homePhoneDiagnostics: settingsShell.homePhoneDiagnostics
|
||||
|
||||
title: "Panama Settings"
|
||||
visible: ShellState.settingsOpen
|
||||
implicitWidth: 1120
|
||||
@@ -23,6 +25,7 @@ FloatingWindow {
|
||||
}
|
||||
|
||||
SettingsShell {
|
||||
id: settingsShell
|
||||
anchors.fill: parent
|
||||
hostWindow: root
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user