mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 23:36:36 +00:00
Use last completed automatic backup time instead of last available ba… (#23522)
* Use last completed automatic backup time instead of last available backup * Update ha-backup-overview-summary.ts * Update src/panels/config/backup/components/overview/ha-backup-overview-summary.ts * Update ha-config-backup-overview.ts
This commit is contained in:
parent
cd69c4c361
commit
8daea5b565
@ -84,21 +84,21 @@ class HaBackupOverviewBackups extends LitElement {
|
|||||||
|
|
||||||
const lastSuccessfulBackup = this._lastSuccessfulBackup(this.backups);
|
const lastSuccessfulBackup = this._lastSuccessfulBackup(this.backups);
|
||||||
|
|
||||||
const lastSuccessfulBackupDate = lastSuccessfulBackup
|
|
||||||
? new Date(lastSuccessfulBackup.date)
|
|
||||||
: new Date(0);
|
|
||||||
|
|
||||||
const lastAttempt = this.config.last_attempted_automatic_backup
|
const lastAttempt = this.config.last_attempted_automatic_backup
|
||||||
? new Date(this.config.last_attempted_automatic_backup)
|
? new Date(this.config.last_attempted_automatic_backup)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
|
const lastCompletedBackupDate = this.config.last_completed_automatic_backup
|
||||||
|
? new Date(this.config.last_completed_automatic_backup)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
|
||||||
const lastBackupDescription = lastSuccessfulBackup
|
const lastBackupDescription = lastSuccessfulBackup
|
||||||
? `Last successful backup ${relativeTime(lastSuccessfulBackupDate, this.hass.locale, now, true)} and stored in ${lastSuccessfulBackup.agent_ids?.length} locations.`
|
? `Last successful backup ${relativeTime(new Date(lastSuccessfulBackup.date), this.hass.locale, now, true)} and stored in ${lastSuccessfulBackup.agent_ids?.length} locations.`
|
||||||
: "You have no successful backups.";
|
: "You have no successful backups.";
|
||||||
|
|
||||||
if (lastAttempt && lastAttempt > lastSuccessfulBackupDate) {
|
if (lastAttempt && lastAttempt > (lastCompletedBackupDate || 0)) {
|
||||||
const lastAttemptDescription = `The last automatic backup triggered ${relativeTime(lastAttempt, this.hass.locale, now, true)} wasn't successful.`;
|
const lastAttemptDescription = `The last automatic backup triggered ${relativeTime(lastAttempt, this.hass.locale, now, true)} wasn't successful.`;
|
||||||
return html`
|
return html`
|
||||||
<ha-backup-summary-card
|
<ha-backup-summary-card
|
||||||
@ -119,6 +119,10 @@ class HaBackupOverviewBackups extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const nextBackupDescription = this._nextBackupDescription(
|
||||||
|
this.config.schedule.state
|
||||||
|
);
|
||||||
|
|
||||||
if (!lastSuccessfulBackup) {
|
if (!lastSuccessfulBackup) {
|
||||||
return html`
|
return html`
|
||||||
<ha-backup-summary-card
|
<ha-backup-summary-card
|
||||||
@ -126,18 +130,20 @@ class HaBackupOverviewBackups extends LitElement {
|
|||||||
description="You have no automatic backups yet."
|
description="You have no automatic backups yet."
|
||||||
status="warning"
|
status="warning"
|
||||||
>
|
>
|
||||||
|
<ha-md-list>
|
||||||
|
<ha-md-list-item>
|
||||||
|
<ha-svg-icon slot="start" .path=${mdiCalendar}></ha-svg-icon>
|
||||||
|
<span slot="headline">${nextBackupDescription}</span>
|
||||||
|
</ha-md-list-item>
|
||||||
|
</ha-md-list>
|
||||||
</ha-backup-summary-card>
|
</ha-backup-summary-card>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const nextBackupDescription = this._nextBackupDescription(
|
|
||||||
this.config.schedule.state
|
|
||||||
);
|
|
||||||
|
|
||||||
const numberOfDays = differenceInDays(
|
const numberOfDays = differenceInDays(
|
||||||
// Subtract a few hours to avoid showing as overdue if it's just a few hours (e.g. daylight saving)
|
// Subtract a few hours to avoid showing as overdue if it's just a few hours (e.g. daylight saving)
|
||||||
addHours(now, -OVERDUE_MARGIN_HOURS),
|
addHours(now, -OVERDUE_MARGIN_HOURS),
|
||||||
lastSuccessfulBackupDate
|
new Date(lastSuccessfulBackup.date)
|
||||||
);
|
);
|
||||||
|
|
||||||
const isOverdue =
|
const isOverdue =
|
||||||
|
@ -127,7 +127,7 @@ class HaConfigBackupOverview extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private get _needsOnboarding() {
|
private get _needsOnboarding() {
|
||||||
return !this.config?.create_backup.password;
|
return this.config && !this.config.create_backup.password;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user