2021-08-21 08:46:43 +00:00
|
|
|
// TODO: Create a new datatable below to display the import summary json files saved on server (Need to do as well).
|
|
|
|
<template>
|
|
|
|
<v-container fluid>
|
|
|
|
<section>
|
2021-12-04 23:18:46 +00:00
|
|
|
<BaseCardSectionTitle title="Site Backups"> </BaseCardSectionTitle>
|
2021-08-21 08:46:43 +00:00
|
|
|
|
|
|
|
<!-- Delete Dialog -->
|
|
|
|
<BaseDialog
|
2021-11-25 23:17:02 +00:00
|
|
|
v-model="deleteDialog"
|
2021-08-21 08:46:43 +00:00
|
|
|
:title="$t('settings.backup.delete-backup')"
|
|
|
|
color="error"
|
|
|
|
:icon="$globals.icons.alertCircle"
|
|
|
|
@confirm="deleteBackup()"
|
|
|
|
>
|
|
|
|
<v-card-text>
|
|
|
|
{{ $t("general.confirm-delete-generic") }}
|
|
|
|
</v-card-text>
|
|
|
|
</BaseDialog>
|
|
|
|
|
|
|
|
<!-- Import Dialog -->
|
|
|
|
<BaseDialog
|
2021-11-25 23:17:02 +00:00
|
|
|
v-model="importDialog"
|
2021-08-21 08:46:43 +00:00
|
|
|
:title="selected.name"
|
|
|
|
:icon="$globals.icons.database"
|
|
|
|
:submit-text="$t('general.import')"
|
|
|
|
@submit="importBackup()"
|
|
|
|
>
|
|
|
|
<v-divider></v-divider>
|
|
|
|
<v-card-text>
|
|
|
|
<AdminBackupImportOptions v-model="selected.options" class="mt-5 mb-2" :import-backup="true" />
|
|
|
|
</v-card-text>
|
|
|
|
|
|
|
|
<v-divider></v-divider>
|
|
|
|
</BaseDialog>
|
|
|
|
|
2021-12-04 23:18:46 +00:00
|
|
|
<v-card outlined>
|
|
|
|
<v-card-title class="py-2"> {{ $t("settings.backup.create-heading") }} </v-card-title>
|
|
|
|
<v-divider class="mx-2"></v-divider>
|
|
|
|
<v-form @submit.prevent="createBackup()">
|
2021-08-21 08:46:43 +00:00
|
|
|
<v-card-text>
|
2021-12-04 23:18:46 +00:00
|
|
|
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Dolores molestiae alias incidunt fugiat!
|
|
|
|
Recusandae natus numquam iusto voluptates deserunt quia? Sed voluptate rem facilis tempora, perspiciatis
|
|
|
|
corrupti dolore obcaecati laudantium!
|
|
|
|
<div style="max-width: 300px">
|
|
|
|
<v-text-field
|
|
|
|
v-model="backupOptions.tag"
|
|
|
|
class="mt-4"
|
|
|
|
:label="$t('settings.backup.backup-tag') + ' (optional)'"
|
|
|
|
>
|
|
|
|
</v-text-field>
|
|
|
|
<AdminBackupImportOptions v-model="backupOptions.options" class="mt-5 mb-2" />
|
|
|
|
<v-divider class="my-3"></v-divider>
|
|
|
|
</div>
|
|
|
|
<v-card-actions>
|
|
|
|
<BaseButton type="submit"> </BaseButton>
|
|
|
|
</v-card-actions>
|
2021-08-21 08:46:43 +00:00
|
|
|
</v-card-text>
|
2021-12-04 23:18:46 +00:00
|
|
|
</v-form>
|
|
|
|
</v-card>
|
2021-08-21 08:46:43 +00:00
|
|
|
|
2021-12-04 23:18:46 +00:00
|
|
|
<section class="mt-5">
|
|
|
|
<BaseCardSectionTitle title="Backups"></BaseCardSectionTitle>
|
|
|
|
<v-data-table
|
|
|
|
:headers="headers"
|
|
|
|
:items="backups.imports || []"
|
|
|
|
class="elevation-0"
|
|
|
|
hide-default-footer
|
|
|
|
disable-pagination
|
|
|
|
:search="search"
|
|
|
|
@click:row="setSelected"
|
|
|
|
>
|
|
|
|
<template #item.date="{ item }">
|
|
|
|
{{ $d(Date.parse(item.date), "medium") }}
|
|
|
|
</template>
|
|
|
|
<template #item.actions="{ item }">
|
|
|
|
<v-btn
|
|
|
|
icon
|
|
|
|
class="mx-1"
|
|
|
|
color="error"
|
|
|
|
@click.stop="
|
|
|
|
deleteDialog = true;
|
|
|
|
deleteTarget = item.name;
|
|
|
|
"
|
|
|
|
>
|
|
|
|
<v-icon> {{ $globals.icons.delete }} </v-icon>
|
|
|
|
</v-btn>
|
|
|
|
<BaseButton small download :download-url="backupsFileNameDownload(item.name)" @click.stop />
|
|
|
|
</template>
|
|
|
|
</v-data-table>
|
|
|
|
<v-divider></v-divider>
|
|
|
|
<div class="d-flex justify-end mt-6">
|
|
|
|
<div>
|
|
|
|
<AppButtonUpload
|
|
|
|
:text-btn="false"
|
|
|
|
class="mr-4"
|
|
|
|
url="/api/backups/upload"
|
|
|
|
accept=".zip"
|
|
|
|
color="info"
|
|
|
|
@uploaded="refreshBackups()"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
2021-08-21 08:46:43 +00:00
|
|
|
</section>
|
|
|
|
</v-container>
|
|
|
|
</template>
|
2021-08-21 19:00:42 +00:00
|
|
|
|
2021-08-21 08:46:43 +00:00
|
|
|
<script lang="ts">
|
2021-11-25 23:17:02 +00:00
|
|
|
import { defineComponent, reactive, toRefs, useContext } from "@nuxtjs/composition-api";
|
2021-09-06 06:05:29 +00:00
|
|
|
import AdminBackupImportOptions from "@/components/Domain/Admin/AdminBackupImportOptions.vue";
|
2021-08-21 08:46:43 +00:00
|
|
|
import { useBackups } from "~/composables/use-backups";
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: { AdminBackupImportOptions },
|
|
|
|
layout: "admin",
|
|
|
|
setup() {
|
|
|
|
const { i18n } = useContext();
|
|
|
|
|
|
|
|
const { selected, backups, backupOptions, deleteTarget, refreshBackups, importBackup, createBackup, deleteBackup } =
|
|
|
|
useBackups();
|
|
|
|
|
|
|
|
const state = reactive({
|
2021-11-25 23:17:02 +00:00
|
|
|
deleteDialog: false,
|
|
|
|
createDialog: false,
|
|
|
|
importDialog: false,
|
2021-08-21 08:46:43 +00:00
|
|
|
search: "",
|
|
|
|
headers: [
|
|
|
|
{ text: i18n.t("general.name"), value: "name" },
|
|
|
|
{ text: i18n.t("general.created"), value: "date" },
|
2021-11-24 03:57:24 +00:00
|
|
|
{ text: "Size", value: "size" },
|
2021-08-21 08:46:43 +00:00
|
|
|
{ text: "", value: "actions", align: "right" },
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
function setSelected(data: { name: string; date: string }) {
|
|
|
|
if (selected.value === null || selected.value === undefined) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
selected.value.name = data.name;
|
2021-11-25 23:17:02 +00:00
|
|
|
state.importDialog = true;
|
2021-08-21 08:46:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const backupsFileNameDownload = (fileName: string) => `api/backups/${fileName}/download`;
|
|
|
|
|
|
|
|
return {
|
|
|
|
selected,
|
|
|
|
...toRefs(state),
|
|
|
|
backupOptions,
|
|
|
|
backups,
|
|
|
|
createBackup,
|
|
|
|
deleteBackup,
|
|
|
|
setSelected,
|
|
|
|
deleteTarget,
|
|
|
|
importBackup,
|
|
|
|
refreshBackups,
|
|
|
|
backupsFileNameDownload,
|
|
|
|
};
|
|
|
|
},
|
2021-10-07 17:39:47 +00:00
|
|
|
head() {
|
|
|
|
return {
|
|
|
|
title: this.$t("sidebar.backups") as string,
|
|
|
|
};
|
|
|
|
},
|
2021-08-21 08:46:43 +00:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
</style>
|