mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-26 11:17:21 +00:00
Compare commits
3 Commits
boolean_se
...
ingress-no
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5c42d24ed | ||
|
|
04a4d26b18 | ||
|
|
ed6b54e5c6 |
@@ -266,7 +266,6 @@ gulp.task(taskName, function () {
|
|||||||
TRANSLATION_FRAGMENTS.forEach((fragment) => {
|
TRANSLATION_FRAGMENTS.forEach((fragment) => {
|
||||||
delete data.ui.panel[fragment];
|
delete data.ui.panel[fragment];
|
||||||
});
|
});
|
||||||
delete data.supervisor;
|
|
||||||
return data;
|
return data;
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -61,10 +61,11 @@ class HassioRouter extends HassRouterPage {
|
|||||||
el.hass = this.hass;
|
el.hass = this.hass;
|
||||||
el.narrow = this.narrow;
|
el.narrow = this.narrow;
|
||||||
el.route = route;
|
el.route = route;
|
||||||
el.supervisor = this.supervisor;
|
|
||||||
|
|
||||||
if (el.localName === "hassio-ingress-view") {
|
if (el.localName === "hassio-ingress-view") {
|
||||||
el.ingressPanel = this.panel.config && this.panel.config.ingress;
|
el.ingressPanel = this.panel.config && this.panel.config.ingress;
|
||||||
|
} else {
|
||||||
|
el.supervisor = this.supervisor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import {
|
|||||||
createHassioSession,
|
createHassioSession,
|
||||||
validateHassioSession,
|
validateHassioSession,
|
||||||
} from "../../../src/data/hassio/ingress";
|
} from "../../../src/data/hassio/ingress";
|
||||||
import { Supervisor } from "../../../src/data/supervisor/supervisor";
|
|
||||||
import { showAlertDialog } from "../../../src/dialogs/generic/show-dialog-box";
|
import { showAlertDialog } from "../../../src/dialogs/generic/show-dialog-box";
|
||||||
import "../../../src/layouts/hass-loading-screen";
|
import "../../../src/layouts/hass-loading-screen";
|
||||||
import "../../../src/layouts/hass-subpage";
|
import "../../../src/layouts/hass-subpage";
|
||||||
@@ -31,11 +30,9 @@ import { HomeAssistant, Route } from "../../../src/types";
|
|||||||
class HassioIngressView extends LitElement {
|
class HassioIngressView extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
@property({ attribute: false }) public supervisor!: Supervisor;
|
@property({ attribute: false }) public route!: Route;
|
||||||
|
|
||||||
@property() public route!: Route;
|
@property({ type: Boolean }) public ingressPanel = false;
|
||||||
|
|
||||||
@property() public ingressPanel = false;
|
|
||||||
|
|
||||||
@state() private _addon?: HassioAddonDetails;
|
@state() private _addon?: HassioAddonDetails;
|
||||||
|
|
||||||
@@ -102,14 +99,14 @@ class HassioIngressView extends LitElement {
|
|||||||
}
|
}
|
||||||
if (!addonInfo.version) {
|
if (!addonInfo.version) {
|
||||||
await showAlertDialog(this, {
|
await showAlertDialog(this, {
|
||||||
text: this.supervisor.localize("my.error_addon_not_installed"),
|
text: this.hass.localize("supervisor.my.error_addon_not_installed"),
|
||||||
title: addonInfo.name,
|
title: addonInfo.name,
|
||||||
});
|
});
|
||||||
await nextRender();
|
await nextRender();
|
||||||
navigate(`/hassio/addon/${addonInfo.slug}/info`, { replace: true });
|
navigate(`/hassio/addon/${addonInfo.slug}/info`, { replace: true });
|
||||||
} else if (!addonInfo.ingress) {
|
} else if (!addonInfo.ingress) {
|
||||||
await showAlertDialog(this, {
|
await showAlertDialog(this, {
|
||||||
text: this.supervisor.localize("my.error_addon_no_ingress"),
|
text: this.hass.localize("supervisor.my.error_addon_no_ingress"),
|
||||||
title: addonInfo.name,
|
title: addonInfo.name,
|
||||||
});
|
});
|
||||||
await nextRender();
|
await nextRender();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Collection, UnsubscribeFunc } from "home-assistant-js-websocket";
|
import { Collection, UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||||
import { LitElement, PropertyValues } from "lit";
|
import { LitElement, PropertyValues } from "lit";
|
||||||
import { property, state } from "lit/decorators";
|
import { property, state } from "lit/decorators";
|
||||||
|
import memoizeOne from "memoize-one";
|
||||||
import { atLeastVersion } from "../../src/common/config/version";
|
import { atLeastVersion } from "../../src/common/config/version";
|
||||||
import { computeLocalize } from "../../src/common/translations/localize";
|
import { computeLocalize } from "../../src/common/translations/localize";
|
||||||
import { fetchHassioAddonsInfo } from "../../src/data/hassio/addon";
|
import { fetchHassioAddonsInfo } from "../../src/data/hassio/addon";
|
||||||
@@ -15,6 +16,7 @@ import {
|
|||||||
fetchHassioHomeAssistantInfo,
|
fetchHassioHomeAssistantInfo,
|
||||||
fetchHassioInfo,
|
fetchHassioInfo,
|
||||||
fetchHassioSupervisorInfo,
|
fetchHassioSupervisorInfo,
|
||||||
|
HassioPanelInfo,
|
||||||
} from "../../src/data/hassio/supervisor";
|
} from "../../src/data/hassio/supervisor";
|
||||||
import { fetchSupervisorStore } from "../../src/data/supervisor/store";
|
import { fetchSupervisorStore } from "../../src/data/supervisor/store";
|
||||||
import {
|
import {
|
||||||
@@ -25,7 +27,7 @@ import {
|
|||||||
} from "../../src/data/supervisor/supervisor";
|
} from "../../src/data/supervisor/supervisor";
|
||||||
import { ProvideHassLitMixin } from "../../src/mixins/provide-hass-lit-mixin";
|
import { ProvideHassLitMixin } from "../../src/mixins/provide-hass-lit-mixin";
|
||||||
import { urlSyncMixin } from "../../src/state/url-sync-mixin";
|
import { urlSyncMixin } from "../../src/state/url-sync-mixin";
|
||||||
import { HomeAssistant } from "../../src/types";
|
import { HomeAssistant, Route } from "../../src/types";
|
||||||
import { getTranslation } from "../../src/util/common-translation";
|
import { getTranslation } from "../../src/util/common-translation";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
@@ -35,6 +37,11 @@ declare global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isIngress = memoizeOne(
|
||||||
|
(panel?: HassioPanelInfo, route?: Route) =>
|
||||||
|
(panel?.config && "ingress" in panel.config) || route?.path === "/ingress"
|
||||||
|
);
|
||||||
|
|
||||||
export class SupervisorBaseElement extends urlSyncMixin(
|
export class SupervisorBaseElement extends urlSyncMixin(
|
||||||
ProvideHassLitMixin(LitElement)
|
ProvideHassLitMixin(LitElement)
|
||||||
) {
|
) {
|
||||||
@@ -42,19 +49,23 @@ export class SupervisorBaseElement extends urlSyncMixin(
|
|||||||
localize: () => "",
|
localize: () => "",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@property({ attribute: false }) public panel?: HassioPanelInfo;
|
||||||
|
|
||||||
|
@property({ attribute: false }) public route?: Route;
|
||||||
|
|
||||||
@state() private _unsubs: Record<string, UnsubscribeFunc> = {};
|
@state() private _unsubs: Record<string, UnsubscribeFunc> = {};
|
||||||
|
|
||||||
@state() private _collections: Record<string, Collection<unknown>> = {};
|
@state() private _collections: Record<string, Collection<unknown>> = {};
|
||||||
|
|
||||||
@state() private _language = "en";
|
@state() private _language = "en";
|
||||||
|
|
||||||
public connectedCallback(): void {
|
@state() private _ingress = true;
|
||||||
super.connectedCallback();
|
|
||||||
this._initializeLocalize();
|
|
||||||
}
|
|
||||||
|
|
||||||
public disconnectedCallback() {
|
public disconnectedCallback() {
|
||||||
super.disconnectedCallback();
|
super.disconnectedCallback();
|
||||||
|
if (this._ingress) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Object.keys(this._unsubs).forEach((unsub) => {
|
Object.keys(this._unsubs).forEach((unsub) => {
|
||||||
this._unsubs[unsub]();
|
this._unsubs[unsub]();
|
||||||
});
|
});
|
||||||
@@ -62,6 +73,11 @@ export class SupervisorBaseElement extends urlSyncMixin(
|
|||||||
|
|
||||||
protected updated(changedProperties: PropertyValues) {
|
protected updated(changedProperties: PropertyValues) {
|
||||||
super.updated(changedProperties);
|
super.updated(changedProperties);
|
||||||
|
this._ingress = isIngress(this.panel, this.route);
|
||||||
|
if (this._ingress) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (changedProperties.has("hass")) {
|
if (changedProperties.has("hass")) {
|
||||||
const oldHass = changedProperties.get("hass") as
|
const oldHass = changedProperties.get("hass") as
|
||||||
| HomeAssistant
|
| HomeAssistant
|
||||||
@@ -103,17 +119,27 @@ export class SupervisorBaseElement extends urlSyncMixin(
|
|||||||
|
|
||||||
protected firstUpdated(changedProps: PropertyValues): void {
|
protected firstUpdated(changedProps: PropertyValues): void {
|
||||||
super.firstUpdated(changedProps);
|
super.firstUpdated(changedProps);
|
||||||
|
this._ingress = isIngress(this.panel, this.route);
|
||||||
|
if (this._ingress) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this._language !== this.hass.language &&
|
this._language !== this.hass.language &&
|
||||||
this.hass.language !== undefined
|
this.hass.language !== undefined
|
||||||
) {
|
) {
|
||||||
this._language = this.hass.language;
|
this._language = this.hass.language;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._initializeLocalize();
|
this._initializeLocalize();
|
||||||
this._initSupervisor();
|
this._initSupervisor();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _initializeLocalize() {
|
private async _initializeLocalize() {
|
||||||
|
if (this._ingress) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const { language, data } = await getTranslation(
|
const { language, data } = await getTranslation(
|
||||||
null,
|
null,
|
||||||
this._language,
|
this._language,
|
||||||
|
|||||||
Reference in New Issue
Block a user