mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-16 22:06:34 +00:00
Add overview settings link to backup settings sections
This commit is contained in:
parent
b35f9944ea
commit
fad435ea10
@ -53,6 +53,12 @@ export type BackupConfigData = {
|
|||||||
include_addons?: string[];
|
include_addons?: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HASSDomEvents {
|
||||||
|
"backup-addons-fetched": void;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@customElement("ha-backup-config-data")
|
@customElement("ha-backup-config-data")
|
||||||
class HaBackupConfigData extends LitElement {
|
class HaBackupConfigData extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
@ -89,6 +95,7 @@ class HaBackupConfigData extends LitElement {
|
|||||||
private async _fetchAddons() {
|
private async _fetchAddons() {
|
||||||
const { addons } = await fetchHassioAddonsInfo(this.hass);
|
const { addons } = await fetchHassioAddonsInfo(this.hass);
|
||||||
this._addons = addons;
|
this._addons = addons;
|
||||||
|
fireEvent(this, "backup-addons-fetched");
|
||||||
}
|
}
|
||||||
|
|
||||||
private _hasLocalAddons(addons: BackupAddonItem[]): boolean {
|
private _hasLocalAddons(addons: BackupAddonItem[]): boolean {
|
||||||
|
@ -5,6 +5,7 @@ import { customElement, property } from "lit/decorators";
|
|||||||
import { navigate } from "../../../../../common/navigate";
|
import { navigate } from "../../../../../common/navigate";
|
||||||
import "../../../../../components/ha-button";
|
import "../../../../../components/ha-button";
|
||||||
import "../../../../../components/ha-card";
|
import "../../../../../components/ha-card";
|
||||||
|
import "../../../../../components/ha-icon-next";
|
||||||
import "../../../../../components/ha-md-list";
|
import "../../../../../components/ha-md-list";
|
||||||
import "../../../../../components/ha-md-list-item";
|
import "../../../../../components/ha-md-list-item";
|
||||||
import "../../../../../components/ha-svg-icon";
|
import "../../../../../components/ha-svg-icon";
|
||||||
@ -103,7 +104,10 @@ class HaBackupBackupsSummary extends LitElement {
|
|||||||
<div class="card-header">Automatic backups</div>
|
<div class="card-header">Automatic backups</div>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<ha-md-list>
|
<ha-md-list>
|
||||||
<ha-md-list-item>
|
<ha-md-list-item
|
||||||
|
type="link"
|
||||||
|
href="/config/backup/settings#schedule"
|
||||||
|
>
|
||||||
<ha-svg-icon slot="start" .path=${mdiCalendar}></ha-svg-icon>
|
<ha-svg-icon slot="start" .path=${mdiCalendar}></ha-svg-icon>
|
||||||
<div slot="headline">
|
<div slot="headline">
|
||||||
${this._scheduleDescription(this.config)}
|
${this._scheduleDescription(this.config)}
|
||||||
@ -111,8 +115,9 @@ class HaBackupBackupsSummary extends LitElement {
|
|||||||
<div slot="supporting-text">
|
<div slot="supporting-text">
|
||||||
Schedule and number of backups to keep
|
Schedule and number of backups to keep
|
||||||
</div>
|
</div>
|
||||||
|
<ha-icon-next slot="end"></ha-icon-next>
|
||||||
</ha-md-list-item>
|
</ha-md-list-item>
|
||||||
<ha-md-list-item>
|
<ha-md-list-item type="link" href="/config/backup/settings#data">
|
||||||
<ha-svg-icon slot="start" .path=${mdiDatabase}></ha-svg-icon>
|
<ha-svg-icon slot="start" .path=${mdiDatabase}></ha-svg-icon>
|
||||||
<div slot="headline">
|
<div slot="headline">
|
||||||
${this.config.create_backup.include_database
|
${this.config.create_backup.include_database
|
||||||
@ -122,27 +127,34 @@ class HaBackupBackupsSummary extends LitElement {
|
|||||||
<div slot="supporting-text">
|
<div slot="supporting-text">
|
||||||
Home Assistant data that is included
|
Home Assistant data that is included
|
||||||
</div>
|
</div>
|
||||||
|
<ha-icon-next slot="end"></ha-icon-next>
|
||||||
</ha-md-list-item>
|
</ha-md-list-item>
|
||||||
${isHassio
|
${isHassio
|
||||||
? html`
|
? html`
|
||||||
<ha-md-list-item>
|
<ha-md-list-item
|
||||||
|
type="link"
|
||||||
|
href="/config/backup/settings#data"
|
||||||
|
>
|
||||||
<ha-svg-icon slot="start" .path=${mdiPuzzle}></ha-svg-icon>
|
<ha-svg-icon slot="start" .path=${mdiPuzzle}></ha-svg-icon>
|
||||||
<div slot="headline">
|
<div slot="headline">
|
||||||
${this._addonsDescription(this.config)}
|
${this._addonsDescription(this.config)}
|
||||||
</div>
|
</div>
|
||||||
<div slot="supporting-text">Add-ons that are included</div>
|
<div slot="supporting-text">Add-ons that are included</div>
|
||||||
</ha-md-list-item>
|
<ha-icon-next slot="end"></ha-icon-next>
|
||||||
<ha-md-list-item>
|
|
||||||
<ha-svg-icon slot="start" .path=${mdiUpload}></ha-svg-icon>
|
|
||||||
<div slot="headline">
|
|
||||||
${this._agentsDescription(this.config)}
|
|
||||||
</div>
|
|
||||||
<div slot="supporting-text">
|
|
||||||
Locations where backup is uploaded to
|
|
||||||
</div>
|
|
||||||
</ha-md-list-item>
|
</ha-md-list-item>
|
||||||
`
|
`
|
||||||
: nothing}
|
: nothing}
|
||||||
|
<ha-md-list-item
|
||||||
|
type="link"
|
||||||
|
href="/config/backup/settings#locations"
|
||||||
|
>
|
||||||
|
<ha-svg-icon slot="start" .path=${mdiUpload}></ha-svg-icon>
|
||||||
|
<div slot="headline">${this._agentsDescription(this.config)}</div>
|
||||||
|
<div slot="supporting-text">
|
||||||
|
Locations where backup is uploaded to
|
||||||
|
</div>
|
||||||
|
<ha-icon-next slot="end"></ha-icon-next>
|
||||||
|
</ha-md-list-item>
|
||||||
</ha-md-list>
|
</ha-md-list>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-actions">
|
<div class="card-actions">
|
||||||
|
@ -3,6 +3,7 @@ import { css, html, LitElement, nothing } from "lit";
|
|||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
import { debounce } from "../../../common/util/debounce";
|
import { debounce } from "../../../common/util/debounce";
|
||||||
|
import { nextRender } from "../../../common/util/render-status";
|
||||||
import "../../../components/ha-button";
|
import "../../../components/ha-button";
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
import "../../../components/ha-icon-next";
|
import "../../../components/ha-icon-next";
|
||||||
@ -38,6 +39,30 @@ class HaConfigBackupSettings extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected firstUpdated(_changedProperties: PropertyValues): void {
|
||||||
|
super.firstUpdated(_changedProperties);
|
||||||
|
this._scrollTo();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async _scrollTo() {
|
||||||
|
const hash = window.location.hash.substring(1);
|
||||||
|
if (hash === "locations") {
|
||||||
|
// Wait for the addons to be loaded before scrolling because the height can change
|
||||||
|
this.addEventListener("backup-addons-fetched", async () => {
|
||||||
|
await nextRender();
|
||||||
|
this._scrolltoHash(hash);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._scrolltoHash(hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
private _scrolltoHash(hash: string) {
|
||||||
|
const element = this.shadowRoot!.getElementById(hash);
|
||||||
|
element?.scrollIntoView();
|
||||||
|
history.replaceState(null, "", window.location.pathname);
|
||||||
|
}
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
if (!this._config) {
|
if (!this._config) {
|
||||||
return nothing;
|
return nothing;
|
||||||
@ -51,7 +76,7 @@ class HaConfigBackupSettings extends LitElement {
|
|||||||
.header=${"Automatic backups"}
|
.header=${"Automatic backups"}
|
||||||
>
|
>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<ha-card>
|
<ha-card id="schedule">
|
||||||
<div class="card-header">Automatic backups</div>
|
<div class="card-header">Automatic backups</div>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<p>
|
<p>
|
||||||
@ -65,7 +90,7 @@ class HaConfigBackupSettings extends LitElement {
|
|||||||
></ha-backup-config-schedule>
|
></ha-backup-config-schedule>
|
||||||
</div>
|
</div>
|
||||||
</ha-card>
|
</ha-card>
|
||||||
<ha-card>
|
<ha-card id="data">
|
||||||
<div class="card-header">Backup data</div>
|
<div class="card-header">Backup data</div>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<ha-backup-config-data
|
<ha-backup-config-data
|
||||||
@ -78,7 +103,7 @@ class HaConfigBackupSettings extends LitElement {
|
|||||||
</div>
|
</div>
|
||||||
</ha-card>
|
</ha-card>
|
||||||
|
|
||||||
<ha-card class="agents">
|
<ha-card class="agents" id="locations">
|
||||||
<div class="card-header">Locations</div>
|
<div class="card-header">Locations</div>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<p>
|
<p>
|
||||||
@ -199,6 +224,9 @@ class HaConfigBackupSettings extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static styles = css`
|
static styles = css`
|
||||||
|
ha-card {
|
||||||
|
scroll-margin-top: 16px;
|
||||||
|
}
|
||||||
.content {
|
.content {
|
||||||
padding: 28px 20px 0;
|
padding: 28px 20px 0;
|
||||||
max-width: 690px;
|
max-width: 690px;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user