mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 10:16:46 +00:00
Add UI for reload resources service (#5229)
* Add UI for reload resources service * Update hui-root.ts * Check for config of main panel
This commit is contained in:
parent
8bc8761af6
commit
127aaba47b
@ -154,14 +154,14 @@ export class HaConfigLovelaceRescources extends LitElement {
|
|||||||
this._resources = this._resources!.concat(created).sort((res1, res2) =>
|
this._resources = this._resources!.concat(created).sort((res1, res2) =>
|
||||||
compare(res1.url, res2.url)
|
compare(res1.url, res2.url)
|
||||||
);
|
);
|
||||||
loadLovelaceResources(this._resources, this.hass!.auth.data.hassUrl);
|
loadLovelaceResources([created], this.hass!.auth.data.hassUrl);
|
||||||
},
|
},
|
||||||
updateResource: async (values) => {
|
updateResource: async (values) => {
|
||||||
const updated = await updateResource(this.hass!, resource!.id, values);
|
const updated = await updateResource(this.hass!, resource!.id, values);
|
||||||
this._resources = this._resources!.map((res) =>
|
this._resources = this._resources!.map((res) =>
|
||||||
res === resource ? updated : res
|
res === resource ? updated : res
|
||||||
);
|
);
|
||||||
loadLovelaceResources(this._resources, this.hass!.auth.data.hassUrl);
|
loadLovelaceResources([updated], this.hass!.auth.data.hassUrl);
|
||||||
},
|
},
|
||||||
removeResource: async () => {
|
removeResource: async () => {
|
||||||
if (
|
if (
|
||||||
|
@ -29,7 +29,7 @@ import "../../components/ha-paper-icon-button-arrow-prev";
|
|||||||
import "../../components/ha-icon";
|
import "../../components/ha-icon";
|
||||||
import { debounce } from "../../common/util/debounce";
|
import { debounce } from "../../common/util/debounce";
|
||||||
import { HomeAssistant } from "../../types";
|
import { HomeAssistant } from "../../types";
|
||||||
import { LovelaceConfig } from "../../data/lovelace";
|
import { LovelaceConfig, LovelacePanelConfig } from "../../data/lovelace";
|
||||||
import { navigate } from "../../common/navigate";
|
import { navigate } from "../../common/navigate";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
import { swapView } from "./editor/config-util";
|
import { swapView } from "./editor/config-util";
|
||||||
@ -49,7 +49,10 @@ import { haStyle } from "../../resources/styles";
|
|||||||
import { computeRTLDirection } from "../../common/util/compute_rtl";
|
import { computeRTLDirection } from "../../common/util/compute_rtl";
|
||||||
import { showVoiceCommandDialog } from "../../dialogs/voice-command-dialog/show-ha-voice-command-dialog";
|
import { showVoiceCommandDialog } from "../../dialogs/voice-command-dialog/show-ha-voice-command-dialog";
|
||||||
import { isComponentLoaded } from "../../common/config/is_component_loaded";
|
import { isComponentLoaded } from "../../common/config/is_component_loaded";
|
||||||
import { showAlertDialog } from "../../dialogs/generic/show-dialog-box";
|
import {
|
||||||
|
showAlertDialog,
|
||||||
|
showConfirmationDialog,
|
||||||
|
} from "../../dialogs/generic/show-dialog-box";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
|
|
||||||
class HUIRoot extends LitElement {
|
class HUIRoot extends LitElement {
|
||||||
@ -225,6 +228,21 @@ class HUIRoot extends LitElement {
|
|||||||
</paper-item>
|
</paper-item>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
|
${(this.hass.panels.lovelace
|
||||||
|
?.config as LovelacePanelConfig)?.mode === "yaml"
|
||||||
|
? html`
|
||||||
|
<paper-item
|
||||||
|
aria-label=${this.hass!.localize(
|
||||||
|
"ui.panel.lovelace.menu.reload_resources"
|
||||||
|
)}
|
||||||
|
@tap="${this._handleReloadResources}"
|
||||||
|
>
|
||||||
|
${this.hass!.localize(
|
||||||
|
"ui.panel.lovelace.menu.reload_resources"
|
||||||
|
)}
|
||||||
|
</paper-item>
|
||||||
|
`
|
||||||
|
: ""}
|
||||||
${this.hass!.user!.is_admin &&
|
${this.hass!.user!.is_admin &&
|
||||||
!this.hass!.config.safe_mode
|
!this.hass!.config.safe_mode
|
||||||
? html`
|
? html`
|
||||||
@ -550,6 +568,19 @@ class HUIRoot extends LitElement {
|
|||||||
fireEvent(this, "config-refresh");
|
fireEvent(this, "config-refresh");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _handleReloadResources(): void {
|
||||||
|
this.hass.callService("lovelace", "reload_resources");
|
||||||
|
showConfirmationDialog(this, {
|
||||||
|
title: this.hass!.localize(
|
||||||
|
"ui.panel.lovelace.reload_resources.refresh_header"
|
||||||
|
),
|
||||||
|
text: this.hass!.localize(
|
||||||
|
"ui.panel.lovelace.reload_resources.refresh_body"
|
||||||
|
),
|
||||||
|
confirm: () => location.reload(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private _handleUnusedEntities(): void {
|
private _handleUnusedEntities(): void {
|
||||||
navigate(this, `${this.route?.prefix}/hass-unused-entities`);
|
navigate(this, `${this.route?.prefix}/hass-unused-entities`);
|
||||||
}
|
}
|
||||||
|
@ -1891,9 +1891,14 @@
|
|||||||
"configure_ui": "Configure UI",
|
"configure_ui": "Configure UI",
|
||||||
"help": "Help",
|
"help": "Help",
|
||||||
"refresh": "Refresh",
|
"refresh": "Refresh",
|
||||||
|
"reload_resources": "Reload resources",
|
||||||
"exit_edit_mode": "Exit UI edit mode",
|
"exit_edit_mode": "Exit UI edit mode",
|
||||||
"close": "Close"
|
"close": "Close"
|
||||||
},
|
},
|
||||||
|
"reload_resources": {
|
||||||
|
"refresh_header": "Do you want to refresh?",
|
||||||
|
"refresh_body": "You have to refresh the page to complete the reload, do you want to refresh now?"
|
||||||
|
},
|
||||||
"editor": {
|
"editor": {
|
||||||
"header": "Edit UI",
|
"header": "Edit UI",
|
||||||
"menu": {
|
"menu": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user