backups: display mail backup stats

This commit is contained in:
Girish Ramakrishnan
2025-10-16 13:00:08 +02:00
parent d6a4dd6965
commit 72030ee8fc
2 changed files with 23 additions and 23 deletions
+21 -21
View File
@@ -164,16 +164,7 @@ async function refreshBackups() {
result.forEach(function (backup) {
backup.site = sites.value.find(t => t.id === backup.siteId);
// filled when opening the info dialog - we only show apps for the moment
backup.contents = backup.dependsOn.filter(c => c.indexOf('app_') === 0).map(c => {
return {
id: c,
label: null,
fqdn: null,
stats: null
};
});
backup.appCount = backup.dependsOn.filter(c => c.indexOf('app_') === 0).length;
});
backups.value = result;
@@ -195,6 +186,7 @@ const infoDialog = useTemplateRef('infoDialog');
const infoBackup = ref({ contents: [] });
async function onInfo(backup) {
infoBackup.value = backup;
infoBackup.value.contents = [];
infoDialog.value.open();
// amend detailed app info
@@ -207,20 +199,27 @@ async function onInfo(backup) {
appsById[app.id] = app;
});
for (const content of infoBackup.value.contents) {
const match = content.id.match(/app_(.*?)_.*/); // *? means non-greedy
for (const contentId of infoBackup.value.dependsOn) {
const match = contentId.match(/(mail|app)_(.*?)_.*/); // *? means non-greedy
if (!match) continue;
const [error, backup] = await backupsModel.get(content.id);
const [error, backup] = await backupsModel.get(contentId);
if (error) console.error(error);
const content = { id: null, label: null, fqdn: null, stats: null };
content.stats = backup.stats;
const app = appsById[match[1]];
if (app) {
content.id = app.id;
content.label = app.label;
content.fqdn = app.fqdn;
if (match[1] === 'mail') {
content.id = 'mail';
content.label = 'Mail Server';
} else {
content.id = match[1];
const app = appsById[match[2]];
if (app) {
content.id = app.id;
content.label = app.label;
content.fqdn = app.fqdn;
} else { // uninstalled app
content.id = match[2];
}
}
infoBackup.value.contents.push(content);
}
}
@@ -313,7 +312,8 @@ defineExpose({ refresh });
<p class="text-muted">{{ $t('backups.backupDetails.list', { appCount: infoBackup.contents.length }) }}:</p>
<div v-for="content in infoBackup.contents" :key="content.id">
<a v-if="content.fqdn" :href="`/#/app/${content.id}/backups`">{{ content.label || content.fqdn }}</a>
<a v-if="content.id === 'mail'" href="/#/mailboxes">{{ content.label }}</a>
<a v-else-if="content.fqdn" :href="`/#/app/${content.id}/backups`">{{ content.label || content.fqdn }}</a>
<a v-else :href="`/#/system-eventlog?search=${content.id}`">{{ content.id }}</a>
<span v-if="content.stats">&nbsp;{{ prettyFileSize(content.stats.size) }} - {{ content.stats.fileCount }} file(s)</span>
</div>
@@ -355,7 +355,7 @@ defineExpose({ refresh });
<template #creationTime="backup">{{ prettyLongDate(backup.creationTime) }} <b v-show="backup.label">({{ backup.label }})</b></template>
<template #content="backup">
<span v-if="backup.contents.length">{{ $t('backups.listing.appCount', { appCount: backup.contents.length }) }}</span>
<span v-if="backup.appCount">{{ $t('backups.listing.appCount', { appCount: backup.appCount }) }}</span>
<span v-else>{{ $t('backups.listing.noApps') }}</span>
</template>