mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Don't allow history to be picked for backup when db is not in default … (#24402)
This commit is contained in:
parent
1c8284609f
commit
cf288f7cd1
@ -5,6 +5,7 @@ import type { HomeAssistant } from "../types";
|
|||||||
|
|
||||||
export interface RecorderInfo {
|
export interface RecorderInfo {
|
||||||
backlog: number | null;
|
backlog: number | null;
|
||||||
|
db_in_default_location: boolean;
|
||||||
max_backlog: number;
|
max_backlog: number;
|
||||||
migration_in_progress: boolean;
|
migration_in_progress: boolean;
|
||||||
migration_is_live: boolean;
|
migration_is_live: boolean;
|
||||||
|
@ -24,6 +24,7 @@ import { fetchHassioAddonsInfo } from "../../../../../data/hassio/addon";
|
|||||||
import type { HomeAssistant } from "../../../../../types";
|
import type { HomeAssistant } from "../../../../../types";
|
||||||
import "../ha-backup-addons-picker";
|
import "../ha-backup-addons-picker";
|
||||||
import type { BackupAddonItem } from "../ha-backup-addons-picker";
|
import type { BackupAddonItem } from "../ha-backup-addons-picker";
|
||||||
|
import { getRecorderInfo } from "../../../../../data/recorder";
|
||||||
|
|
||||||
export interface FormData {
|
export interface FormData {
|
||||||
homeassistant: boolean;
|
homeassistant: boolean;
|
||||||
@ -75,8 +76,11 @@ class HaBackupConfigData extends LitElement {
|
|||||||
|
|
||||||
@state() private _showAddons = false;
|
@state() private _showAddons = false;
|
||||||
|
|
||||||
|
@state() private _showDbOption = true;
|
||||||
|
|
||||||
protected firstUpdated(changedProperties: PropertyValues): void {
|
protected firstUpdated(changedProperties: PropertyValues): void {
|
||||||
super.firstUpdated(changedProperties);
|
super.firstUpdated(changedProperties);
|
||||||
|
this._checkDbOption();
|
||||||
if (isComponentLoaded(this.hass, "hassio")) {
|
if (isComponentLoaded(this.hass, "hassio")) {
|
||||||
this._fetchAddons();
|
this._fetchAddons();
|
||||||
}
|
}
|
||||||
@ -98,6 +102,18 @@ class HaBackupConfigData extends LitElement {
|
|||||||
fireEvent(this, "backup-addons-fetched");
|
fireEvent(this, "backup-addons-fetched");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async _checkDbOption() {
|
||||||
|
if (isComponentLoaded(this.hass, "recorder")) {
|
||||||
|
const info = await getRecorderInfo(this.hass.connection);
|
||||||
|
this._showDbOption = info.db_in_default_location;
|
||||||
|
if (!this._showDbOption && this.value?.include_database) {
|
||||||
|
this.value.include_database = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this._showDbOption = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private _hasLocalAddons(addons: BackupAddonItem[]): boolean {
|
private _hasLocalAddons(addons: BackupAddonItem[]): boolean {
|
||||||
return addons.some((addon) => addon.slug === "local");
|
return addons.some((addon) => addon.slug === "local");
|
||||||
}
|
}
|
||||||
@ -179,24 +195,25 @@ class HaBackupConfigData extends LitElement {
|
|||||||
></ha-switch>
|
></ha-switch>
|
||||||
</ha-md-list-item>
|
</ha-md-list-item>
|
||||||
|
|
||||||
<ha-md-list-item>
|
${this._showDbOption
|
||||||
<ha-svg-icon slot="start" .path=${mdiChartBox}></ha-svg-icon>
|
? html`<ha-md-list-item>
|
||||||
<span slot="headline">
|
<ha-svg-icon slot="start" .path=${mdiChartBox}></ha-svg-icon>
|
||||||
${this.hass.localize("ui.panel.config.backup.data.history")}
|
<span slot="headline">
|
||||||
</span>
|
${this.hass.localize("ui.panel.config.backup.data.history")}
|
||||||
<span slot="supporting-text">
|
</span>
|
||||||
${this.hass.localize(
|
<span slot="supporting-text">
|
||||||
"ui.panel.config.backup.data.history_description"
|
${this.hass.localize(
|
||||||
)}
|
"ui.panel.config.backup.data.history_description"
|
||||||
</span>
|
)}
|
||||||
<ha-switch
|
</span>
|
||||||
id="database"
|
<ha-switch
|
||||||
slot="end"
|
id="database"
|
||||||
@change=${this._switchChanged}
|
slot="end"
|
||||||
.checked=${data.database}
|
@change=${this._switchChanged}
|
||||||
></ha-switch>
|
.checked=${data.database}
|
||||||
</ha-md-list-item>
|
></ha-switch>
|
||||||
|
</ha-md-list-item>`
|
||||||
|
: nothing}
|
||||||
${isHassio
|
${isHassio
|
||||||
? html`
|
? html`
|
||||||
<ha-md-list-item>
|
<ha-md-list-item>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { mdiCalendar, mdiDatabase, mdiPuzzle, mdiUpload } from "@mdi/js";
|
import { mdiCalendar, mdiDatabase, mdiPuzzle, mdiUpload } from "@mdi/js";
|
||||||
import type { CSSResultGroup } from "lit";
|
import type { CSSResultGroup, PropertyValues } from "lit";
|
||||||
import { css, html, LitElement, nothing } from "lit";
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property, state } 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";
|
||||||
@ -18,6 +18,8 @@ import {
|
|||||||
} from "../../../../../data/backup";
|
} from "../../../../../data/backup";
|
||||||
import { haStyle } from "../../../../../resources/styles";
|
import { haStyle } from "../../../../../resources/styles";
|
||||||
import type { HomeAssistant } from "../../../../../types";
|
import type { HomeAssistant } from "../../../../../types";
|
||||||
|
import { isComponentLoaded } from "../../../../../common/config/is_component_loaded";
|
||||||
|
import { getRecorderInfo } from "../../../../../data/recorder";
|
||||||
|
|
||||||
@customElement("ha-backup-overview-settings")
|
@customElement("ha-backup-overview-settings")
|
||||||
class HaBackupBackupsSummary extends LitElement {
|
class HaBackupBackupsSummary extends LitElement {
|
||||||
@ -27,10 +29,26 @@ class HaBackupBackupsSummary extends LitElement {
|
|||||||
|
|
||||||
@property({ attribute: false }) public agents!: BackupAgent[];
|
@property({ attribute: false }) public agents!: BackupAgent[];
|
||||||
|
|
||||||
|
@state() private _showDbOption = true;
|
||||||
|
|
||||||
|
protected firstUpdated(changedProperties: PropertyValues): void {
|
||||||
|
super.firstUpdated(changedProperties);
|
||||||
|
this._checkDbOption();
|
||||||
|
}
|
||||||
|
|
||||||
private _configure() {
|
private _configure() {
|
||||||
navigate("/config/backup/settings");
|
navigate("/config/backup/settings");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async _checkDbOption() {
|
||||||
|
if (isComponentLoaded(this.hass, "recorder")) {
|
||||||
|
const info = await getRecorderInfo(this.hass.connection);
|
||||||
|
this._showDbOption = info.db_in_default_location;
|
||||||
|
} else {
|
||||||
|
this._showDbOption = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private _scheduleDescription(config: BackupConfig): string {
|
private _scheduleDescription(config: BackupConfig): string {
|
||||||
const { copies, days } = config.retention;
|
const { copies, days } = config.retention;
|
||||||
const { recurrence } = config.schedule;
|
const { recurrence } = config.schedule;
|
||||||
@ -214,7 +232,8 @@ class HaBackupBackupsSummary extends LitElement {
|
|||||||
<ha-md-list-item type="link" href="/config/backup/settings#data">
|
<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._showDbOption &&
|
||||||
|
this.config.create_backup.include_database
|
||||||
? this.hass.localize(
|
? this.hass.localize(
|
||||||
"ui.panel.config.backup.overview.settings.data_settings_history"
|
"ui.panel.config.backup.overview.settings.data_settings_history"
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user