Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the "Existing backups" section #615

Merged
merged 7 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 41 additions & 4 deletions src/public/app/widgets/type_widgets/options/backup.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,21 @@ const TPL = `
<div class="options-section">
<h4>${t('backup.existing_backups')}</h4>

<ul class="existing-backup-list"></ul>
<table class="table table-stripped">
<colgroup>
<col width="33%" />
<col />
</colgroup>
<thead>
<tr>
<th>${t("backup.date-and-time")}</th>
<th>${t("backup.path")}</th>
</tr>
</thead>
<tbody class="existing-backup-list-items">
</tbody>
</table>

</div>
`;

Expand Down Expand Up @@ -73,7 +87,7 @@ export default class BackupOptions extends OptionsWidget {
this.$monthlyBackupEnabled.on('change', () =>
this.updateCheckboxOption('monthlyBackupEnabled', this.$monthlyBackupEnabled));

this.$existingBackupList = this.$widget.find(".existing-backup-list");
this.$existingBackupList = this.$widget.find(".existing-backup-list-items");
}

optionsLoaded(options) {
Expand All @@ -85,11 +99,34 @@ export default class BackupOptions extends OptionsWidget {
this.$existingBackupList.empty();

if (!backupFiles.length) {
backupFiles = [{filePath: t('backup.no_backup_yet'), mtime: ''}];
this.$existingBackupList.append($(`
<tr>
<td class="empty-table-placeholder" colspan="2">${t('backup.no_backup_yet')}</td>
</tr>
`));

return;
}

// Sort the backup files by modification date & time in a desceding order
backupFiles.sort((a, b) => {
if (a.mtime < b.mtime) return 1;
if (a.mtime > b.mtime) return -1;
return 0;
});

const dateTimeFormatter = new Intl.DateTimeFormat(navigator.language, {
dateStyle: "medium",
timeStyle: "medium"
});

for (const {filePath, mtime} of backupFiles) {
this.$existingBackupList.append($("<li>").text(`${filePath} ${mtime ? ` - ${mtime}` : ''}`));
this.$existingBackupList.append($(`
<tr>
<td>${(mtime) ? dateTimeFormatter.format(new Date(mtime)) : "-"}</td>
<td>${filePath}</td>
</tr>
`));
}
});
}
Expand Down
4 changes: 4 additions & 0 deletions src/public/stylesheets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1238,3 +1238,7 @@ textarea {
padding: 1rem;
}

.empty-table-placeholder {
text-align: center;
color: var(--muted-text-color);
}
2 changes: 2 additions & 0 deletions src/public/translations/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,8 @@
"backup_now": "Backup now",
"backup_database_now": "Backup database now",
"existing_backups": "Existing backups",
"date-and-time": "Date & time",
"path": "Path",
"database_backed_up_to": "Database has been backed up to",
"no_backup_yet": "no backup yet"
},
Expand Down
2 changes: 2 additions & 0 deletions src/public/translations/ro/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@
"enable_monthly_backup": "Activează copia de siguranță lunară",
"enable_weekly_backup": "Activează copia de siguranță săptămânală",
"existing_backups": "Copii de siguranță existente",
"date-and-time": "Data și ora",
"path": "Calea fișierului",
"no_backup_yet": "nu există încă nicio copie de siguranță"
},
"basic_properties": {
Expand Down