This commit is contained in:
2020-07-22 15:30:56 +00:00
parent da691f9798
commit 610f26acc6

View File

@@ -4,95 +4,42 @@
<v-form ref="form">
<v-row>
<gz-error :errorBoxMessage="formState.errorBoxMessage"></gz-error>
<v-col cols="12" sm="6" lg="4" xl="3">
<v-checkbox
v-model="obj.active"
:readonly="formState.readOnly"
:disabled="formState.readOnly"
:label="$ay.t('Active')"
ref="active"
:error-messages="form().serverErrors(this, 'active')"
@change="fieldValueChanged('active')"
></v-checkbox>
</v-col>
<v-col cols="12" sm="6" lg="4" xl="3">
<gz-time-picker
:label="$ay.t('BackupTime')"
:rules="[form().required(this, 'backupTime')]"
:error-messages="form().serverErrors(this, 'backupTime')"
v-model="obj.backupTime"
:readonly="formState.readOnly"
:disabled="formState.readOnly"
ref="backupTime"
@input="fieldValueChanged('backupTime')"
></gz-time-picker>
</v-col>
<v-col cols="12" sm="6" lg="4" xl="3">
<v-checkbox
v-model="obj.backupAttachments"
:readonly="formState.readOnly"
:disabled="formState.readOnly"
:label="$ay.t('BackupAttachments')"
ref="backupAttachments"
:error-messages="form().serverErrors(this, 'backupAttachments')"
@change="fieldValueChanged('backupAttachments')"
></v-checkbox>
</v-col>
<v-col cols="12" sm="6" lg="4" xl="3">
<v-text-field
v-model="obj.backupSetsToKeep"
:readonly="formState.readOnly"
:disabled="formState.readOnly"
:label="$ay.t('BackupSetsToKeep')"
ref="backupSetsToKeep"
:rules="[form().integerValid(this, 'backupSetsToKeep')]"
:error-messages="form().serverErrors(this, 'backupSetsToKeep')"
@input="fieldValueChanged('backupSetsToKeep')"
type="number"
></v-text-field>
</v-col>
</v-row>
<v-row>
<v-col cols="12" class="mt-6">
<v-col cols="12" lg="4">
<span class="title">{{ $ay.t("BackupFiles") }}</span>
<v-btn @click="getBackupStatus" class="ml-3">
<v-icon>fa-sync</v-icon>
</v-btn>
<v-simple-table>
<template v-slot:default>
<thead>
<tr>
<th class="text-left">{{ $ay.t("FileName") }}</th>
<th class="text-left">{{ $ay.t("FileDate") }}</th>
<th class="text-left">{{ $ay.t("FileSize") }}</th>
</tr>
</thead>
<tbody>
<tr v-for="item in backupFileList" :key="item.id">
<td>
<template v-if="!formState.readOnly">
<a :href="item.url">{{ item.name }}</a>
</template>
<template v-else>
{{ item.name }}
</template>
</td>
<td>{{ item.created }}</td>
<td>{{ item.length }}</td>
</tr>
</tbody>
</template>
</v-simple-table>
<div class="mt-6">
({{ $ay.t("AvailableSpace") }}&nbsp;{{ backupAvailableSpace }})
</div>
</v-col>
</v-col>
<v-row justify="center">
<v-dialog v-model="testDialog" persistent max-width="600px">
<v-card>
<v-card-title>
<span class="headline">{{ $ay.t("TestSMTPSettings") }}</span>
</v-card-title>
<v-card-text>
<v-container>
<v-row>
<v-col cols="12">
<v-text-field
v-model="testAddress"
:label="$ay.t('testToAddress')"
required
hint="test_send_to@example.com"
></v-text-field>
</v-col>
</v-row>
</v-container>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="blue darken-1" text @click="testDialog = false">{{
$ay.t("Cancel")
}}</v-btn>
<v-btn
color="blue darken-1"
text
@click="testConfiguration()"
:disabled="!testAddress"
>{{ $ay.t("OK") }}</v-btn
>
</v-card-actions>
</v-card>
</v-dialog>
</v-row>
</v-form>
</v-col>
@@ -117,7 +64,6 @@ export default {
vm.formState.ready = true;
window.$gz.eventBus.$on("menu-click", clickHandler);
await vm.getDataFromApi();
vm.getBackupStatus();
} catch (err) {
vm.formState.ready = true;
window.$gz.errorHandler.handleFormError(err, vm);
@@ -173,9 +119,9 @@ namespace AyaNova.Models
*/
return {
testAddress: null,
testDialog: false,
formCustomTemplateKey: null,
backupFileList: [],
backupAvailableSpace: null,
obj: {
id: 1,
concurrency: 0,
@@ -235,7 +181,7 @@ namespace AyaNova.Models
if (!this.formState.loading && !this.formState.readOnly) {
window.$gz.form.fieldValueChanged(this, ref);
}
},
},
async getDataFromApi() {
let vm = this;
vm.formState.loading = true;
@@ -300,7 +246,7 @@ namespace AyaNova.Models
async testConfiguration() {
let vm = this;
vm.formState.loading = true;
let url = "global-ops-notification-setting/test";
let url = `global-ops-notification-setting/test-smtp-settings/${vm.testAddress}`;
window.$gz.form.deleteAllErrorBoxErrors(vm);
try {
let res = await window.$gz.api.upsert(url, {});
@@ -330,15 +276,8 @@ async function clickHandler(menuItem) {
case "save":
m.vm.submit();
break;
case "backupnow":
if (
(await window.$gz.dialog.confirmGeneric(
"AreYouSureBackupNow",
"warning"
)) === true
) {
m.vm.backupNow();
}
case "test":
m.vm.testDialog = true;
break;
default:
window.$gz.eventBus.$emit(
@@ -375,10 +314,10 @@ function generateMenu(vm) {
});
menuOptions.menuItems.push({
title: "BackupNow",
icon: "fa-file-archive",
title: "TestSMTPSettings",
icon: "fa-vial",
surface: false,
key: FORM_KEY + ":backupnow",
key: FORM_KEY + ":test",
vm: vm
});
}