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