mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 19:56:42 +00:00
Fix banner when first backup was unsuccessful (#23430)
* Fix banner when first backup was unsuccesful * Update ha-backup-config-agents.ts * remove fix widths
This commit is contained in:
parent
361caafab9
commit
8c18d816b6
@ -51,7 +51,7 @@ class HaBackupConfigAgents extends LitElement {
|
|||||||
|
|
||||||
private _description(agentId: string) {
|
private _description(agentId: string) {
|
||||||
if (agentId === CLOUD_AGENT) {
|
if (agentId === CLOUD_AGENT) {
|
||||||
return "Note: It stores only one backup, regardless of your settings.";
|
return "Note: It stores only one backup with a maximum size of 5 GB, regardless of your settings.";
|
||||||
}
|
}
|
||||||
if (isNetworkMountAgent(agentId)) {
|
if (isNetworkMountAgent(agentId)) {
|
||||||
return "Network storage";
|
return "Network storage";
|
||||||
|
@ -331,16 +331,13 @@ class HaBackupConfigSchedule extends LitElement {
|
|||||||
@media all and (max-width: 450px) {
|
@media all and (max-width: 450px) {
|
||||||
ha-md-select {
|
ha-md-select {
|
||||||
min-width: 160px;
|
min-width: 160px;
|
||||||
width: 160px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ha-md-textfield#value {
|
ha-md-textfield#value {
|
||||||
min-width: 70px;
|
min-width: 70px;
|
||||||
width: 70px;
|
|
||||||
}
|
}
|
||||||
ha-md-select#type {
|
ha-md-select#type {
|
||||||
min-width: 100px;
|
min-width: 100px;
|
||||||
width: 100px;
|
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
@ -31,12 +31,9 @@ class HaBackupOverviewBackups extends LitElement {
|
|||||||
|
|
||||||
@property({ type: Boolean }) public fetching = false;
|
@property({ type: Boolean }) public fetching = false;
|
||||||
|
|
||||||
private _lastBackup = memoizeOne((backups: BackupContent[]) => {
|
private _lastSuccessfulBackup = memoizeOne((backups: BackupContent[]) => {
|
||||||
const sortedBackups = backups
|
const sortedBackups = backups
|
||||||
.filter(
|
.filter((backup) => backup.with_automatic_settings)
|
||||||
(backup) =>
|
|
||||||
backup.with_automatic_settings && !backup.failed_agent_ids?.length
|
|
||||||
)
|
|
||||||
.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
|
.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
|
||||||
|
|
||||||
return sortedBackups[0] as BackupContent | undefined;
|
return sortedBackups[0] as BackupContent | undefined;
|
||||||
@ -85,37 +82,27 @@ class HaBackupOverviewBackups extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const lastBackup = this._lastBackup(this.backups);
|
const lastSuccessfulBackup = this._lastSuccessfulBackup(this.backups);
|
||||||
|
|
||||||
if (!lastBackup) {
|
const lastSuccessfulBackupDate = lastSuccessfulBackup
|
||||||
return html`
|
? new Date(lastSuccessfulBackup.date)
|
||||||
<ha-backup-summary-card
|
: new Date(0);
|
||||||
heading="No automatic backup available"
|
|
||||||
description="You have no automatic backups yet."
|
|
||||||
status="warning"
|
|
||||||
>
|
|
||||||
</ha-backup-summary-card>
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
|
|
||||||
const lastBackupDate = new Date(lastBackup.date);
|
|
||||||
|
|
||||||
const now = new Date();
|
|
||||||
|
|
||||||
const lastBackupDescription = `Last successful backup ${relativeTime(lastBackupDate, this.hass.locale, now, true)} and stored to ${lastBackup.agent_ids?.length} locations.`;
|
|
||||||
const nextBackupDescription = this._nextBackupDescription(
|
|
||||||
this.config.schedule.state
|
|
||||||
);
|
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
if (lastAttempt && lastAttempt > lastBackupDate) {
|
const now = new Date();
|
||||||
|
|
||||||
|
const lastBackupDescription = lastSuccessfulBackup
|
||||||
|
? `Last successful backup ${relativeTime(lastSuccessfulBackupDate, this.hass.locale, now, true)} and stored to ${lastSuccessfulBackup.agent_ids?.length} locations.`
|
||||||
|
: "You have no successful backups.";
|
||||||
|
|
||||||
|
if (lastAttempt && lastAttempt > lastSuccessfulBackupDate) {
|
||||||
const lastAttemptDescription = `The last automatic backup trigged ${relativeTime(lastAttempt, this.hass.locale, now, true)} wasn't successful.`;
|
const lastAttemptDescription = `The last automatic backup trigged ${relativeTime(lastAttempt, this.hass.locale, now, true)} wasn't successful.`;
|
||||||
return html`
|
return html`
|
||||||
<ha-backup-summary-card
|
<ha-backup-summary-card
|
||||||
heading=${`Last automatic backup failed`}
|
heading="Last automatic backup failed"
|
||||||
status="error"
|
status="error"
|
||||||
>
|
>
|
||||||
<ha-md-list>
|
<ha-md-list>
|
||||||
@ -132,10 +119,25 @@ class HaBackupOverviewBackups extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!lastSuccessfulBackup) {
|
||||||
|
return html`
|
||||||
|
<ha-backup-summary-card
|
||||||
|
heading="No automatic backup available"
|
||||||
|
description="You have no automatic backups yet."
|
||||||
|
status="warning"
|
||||||
|
>
|
||||||
|
</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),
|
||||||
lastBackupDate
|
lastSuccessfulBackupDate
|
||||||
);
|
);
|
||||||
|
|
||||||
const isOverdue =
|
const isOverdue =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user