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