diff --git a/dashboard/src/components/app/Backups.vue b/dashboard/src/components/app/Backups.vue index cac7413c6..5c0bca28e 100644 --- a/dashboard/src/components/app/Backups.vue +++ b/dashboard/src/components/app/Backups.vue @@ -4,8 +4,8 @@ import { useI18n } from 'vue-i18n'; const i18n = useI18n(); const t = i18n.t; -import { ref, watch, onMounted } from 'vue'; -import { Icon, Button, Switch, TableView, ButtonGroup } from 'pankow'; +import { ref, watch, onMounted, useTemplateRef } from 'vue'; +import { Icon, Button, Switch, Checkbox, FormGroup, TextInput, TableView, ButtonGroup, Dialog } from 'pankow'; import { prettyLongDate } from 'pankow/utils'; import AppsModel from '../../models/AppsModel.js'; @@ -36,10 +36,16 @@ const columns = ref({ const busy = ref(true); const errorMessage = ref(''); +const editBusy = ref(false); +const editError = ref(''); +const editBackup = ref({}); +const editPersist = ref(false); +const editLabel = ref(''); const createBusy = ref(false); const importBusy = ref(false); const autoBackupsEnabled = ref(false); const backups = ref([]); +const editDialog = useTemplateRef('editDialog'); watch(autoBackupsEnabled, async (newValue) => { const [error] = await appsModel.configure(props.app.id, 'automatic_backup', { enable: newValue }); @@ -54,6 +60,27 @@ async function onCreate() { setTimeout(() => createBusy.value = false, 2000); } +function onEdit(backup) { + editBusy.value = false; + editBackup.value = backup; + editPersist.value = backup.preserveSecs === -1; + editLabel.value = backup.label || ''; + editError.value = ''; + editDialog.value.open(); +} + +async function onEditSubmit() { + const [error] = await appsModel.updateBackup(props.app.id, editBackup.value.id, editLabel.value, editPersist.value ? -1 : 0); + if (error) { + editError.value = error.body ? error.body.message : 'Internal error'; + editBusy.value = false; + return console.error(error); + } + + refresh(); + editDialog.value.close(); +} + function getDownloadLink(backup) { const accessToken = localStorage.token; const origin = import.meta.env.VITE_API_ORIGIN || window.location.origin; @@ -78,6 +105,54 @@ onMounted(async () => {