This commit is contained in:
@@ -12,15 +12,9 @@ ____________
|
||||
## CURRENT STAGE:
|
||||
|
||||
|
||||
todo: test tag filtered notification with widget created etc
|
||||
todo: consider naming ability to subs, maybe people want to name it so it makes sense?
|
||||
or is it enough to just show all columns?
|
||||
|
||||
todo: subscription form still not completed, needs to be coded for when to show tags (for example) and other stuff
|
||||
|
||||
todo: Back end notification related settings
|
||||
GlobalBizSettings
|
||||
Add Notification system ACTIVE bool value
|
||||
GlobalOpsNotificationSettings (copy from backup settings)
|
||||
SMTP creds, return address
|
||||
|
||||
|
||||
@@ -9,6 +9,11 @@
|
||||
>
|
||||
<v-list-item-title>{{ $ay.t("PickListTemplates") }}</v-list-item-title>
|
||||
</v-list-item>
|
||||
|
||||
<!-- <v-subheader>{{ $ay.t("Server") }}</v-subheader>
|
||||
<v-list-item>
|
||||
<v-list-item-title>{{ $ay.t("Notifications") }}</v-list-item-title>
|
||||
</v-list-item> -->
|
||||
</v-list>
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
@@ -1,24 +1,416 @@
|
||||
<template>
|
||||
<UnderConstruction />
|
||||
<v-row v-if="formState.ready">
|
||||
<v-col>
|
||||
<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") }} {{ backupAvailableSpace }})
|
||||
</div>
|
||||
</v-col>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-form>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import UnderConstruction from "../components/underconstruction.vue";
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/* Xeslint-disable */
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const FORM_KEY = "ops-backup";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
UnderConstruction
|
||||
async created() {
|
||||
let vm = this;
|
||||
try {
|
||||
await initForm(vm);
|
||||
|
||||
vm.rights = window.$gz.role.getRights(window.$gz.type.GlobalOps);
|
||||
vm.formState.readOnly = !vm.rights.change;
|
||||
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);
|
||||
}
|
||||
},
|
||||
beforeCreate() {
|
||||
window.$gz.eventBus.$emit("menu-change", {
|
||||
isMain: true,
|
||||
icon: "fa-bullhorn",
|
||||
title: "NotificationSettings",
|
||||
helpUrl: "form-ops-notification-settings",
|
||||
formData: {
|
||||
ayaType: window.$gz.type.NotifySubscription
|
||||
async beforeRouteLeave(to, from, next) {
|
||||
if (!this.formState.dirty) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
if ((await window.$gz.dialog.confirmLeaveUnsaved()) === true) {
|
||||
next();
|
||||
} else {
|
||||
next(false);
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
window.$gz.eventBus.$off("menu-click", clickHandler);
|
||||
},
|
||||
components: {},
|
||||
data() {
|
||||
/*
|
||||
using System;
|
||||
using AyaNova.Biz;
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
|
||||
public class GlobalOpsNotificationSettings
|
||||
{
|
||||
public long Id { get; set; }//this is always 1 as there is only ever one single global Ops object
|
||||
public uint Concurrency { get; set; }
|
||||
public bool SmtpDeliveryActive { get; set; }
|
||||
public string SmtpServerAddress { get; set; }
|
||||
public string SmtpAccount { get; set; }
|
||||
public string SmtpPassword { get; set; }
|
||||
public NotifyMailSecurity ConnectionSecurity { get; set; }
|
||||
public int SmtpServerPort { get; set; }
|
||||
public string NotifyFromAddress { get; set; }
|
||||
|
||||
public GlobalOpsNotificationSettings()
|
||||
{
|
||||
SmtpDeliveryActive = true;
|
||||
Id = 1;
|
||||
SmtpServerAddress="mail.example.com";
|
||||
SmtpAccount="notifydeliverfromaccount@example.com";
|
||||
SmtpPassword="examplepassword";
|
||||
ConnectionSecurity= NotifyMailSecurity.SSLTLS;
|
||||
SmtpServerPort=587;
|
||||
NotifyFromAddress="noreply@example.com";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
return {
|
||||
formCustomTemplateKey: null,
|
||||
backupFileList: [],
|
||||
backupAvailableSpace: null,
|
||||
obj: {
|
||||
id: 1,
|
||||
concurrency: 0,
|
||||
SmtpDeliveryActive: null,
|
||||
SmtpServerAddress: null,
|
||||
SmtpAccount: null,
|
||||
SmtpPassword: null,
|
||||
ConnectionSecurity: null,
|
||||
SmtpServerPort: null,
|
||||
NotifyFromAddress: null
|
||||
},
|
||||
formState: {
|
||||
ready: false,
|
||||
dirty: false,
|
||||
valid: true,
|
||||
readOnly: false,
|
||||
loading: true,
|
||||
errorBoxMessage: null,
|
||||
appError: null,
|
||||
serverError: {}
|
||||
},
|
||||
rights: window.$gz.role.fullRightsObject()
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
formState: {
|
||||
handler: function(val) {
|
||||
if (this.formState.loading) {
|
||||
return;
|
||||
}
|
||||
let canSave = val.dirty && val.valid && !val.readOnly;
|
||||
if (canSave) {
|
||||
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":save");
|
||||
} else {
|
||||
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
canSave: function() {
|
||||
return this.formState.valid && this.formState.dirty;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
translation() {
|
||||
return window.$gz.translation;
|
||||
},
|
||||
locale() {
|
||||
return window.$gz.locale;
|
||||
},
|
||||
form() {
|
||||
return window.$gz.form;
|
||||
},
|
||||
fieldValueChanged(ref) {
|
||||
if (!this.formState.loading && !this.formState.readOnly) {
|
||||
window.$gz.form.fieldValueChanged(this, ref);
|
||||
}
|
||||
});
|
||||
},
|
||||
async getDataFromApi() {
|
||||
let vm = this;
|
||||
vm.formState.loading = true;
|
||||
let url = "global-ops-notification-setting";
|
||||
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||
try {
|
||||
let res = await window.$gz.api.get(url);
|
||||
|
||||
if (res.error) {
|
||||
if (res.error.code == "2010") {
|
||||
window.$gz.eventBus.$emit("notify-error", vm.$ay.t("ErrorAPI2010"));
|
||||
window.$gz._.delay(function() {
|
||||
vm.$router.go(-1);
|
||||
}, 2000);
|
||||
}
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
vm.obj = res.data;
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
dirty: false,
|
||||
valid: true,
|
||||
loading: false
|
||||
});
|
||||
generateMenu(vm);
|
||||
}
|
||||
} catch (error) {
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
loading: false
|
||||
});
|
||||
window.$gz.errorHandler.handleFormError(error, vm);
|
||||
}
|
||||
},
|
||||
async submit() {
|
||||
let vm = this;
|
||||
try {
|
||||
if (vm.canSave) {
|
||||
vm.formState.loading = true;
|
||||
let url = "global-ops-notification-setting";
|
||||
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||
let res = await window.$gz.api.upsert(url, vm.obj);
|
||||
|
||||
vm.formState.loading = false;
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
vm.obj.concurrency = res.data.concurrency;
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
dirty: false
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
vm.formState.loading = false;
|
||||
window.$gz.errorHandler.handleFormError(error, vm);
|
||||
}
|
||||
},
|
||||
async testConfiguration() {
|
||||
let vm = this;
|
||||
vm.formState.loading = true;
|
||||
let url = "global-ops-notification-setting/test";
|
||||
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||
try {
|
||||
let res = await window.$gz.api.upsert(url, {});
|
||||
vm.formState.loading = false;
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
}
|
||||
} catch (error) {
|
||||
vm.formState.loading = false;
|
||||
window.$gz.errorHandler.handleFormError(error, vm);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/////////////////////////////
|
||||
//
|
||||
//
|
||||
async function clickHandler(menuItem) {
|
||||
if (!menuItem) {
|
||||
return;
|
||||
}
|
||||
let m = window.$gz.menu.parseMenuItem(menuItem);
|
||||
if (m.owner == FORM_KEY && !m.disabled) {
|
||||
switch (m.key) {
|
||||
case "save":
|
||||
m.vm.submit();
|
||||
break;
|
||||
case "backupnow":
|
||||
if (
|
||||
(await window.$gz.dialog.confirmGeneric(
|
||||
"AreYouSureBackupNow",
|
||||
"warning"
|
||||
)) === true
|
||||
) {
|
||||
m.vm.backupNow();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
window.$gz.eventBus.$emit(
|
||||
"notify-warning",
|
||||
FORM_KEY + "::context click: [" + m.key + "]"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
//
|
||||
//
|
||||
function generateMenu(vm) {
|
||||
let menuOptions = {
|
||||
isMain: true,
|
||||
icon: "fa-bullhorn",
|
||||
title: "NotificationSettings",
|
||||
helpUrl: "form-ops-notification-settings",
|
||||
formData: {
|
||||
ayaType: window.$gz.type.OpsNotificationSettings
|
||||
},
|
||||
formData: {},
|
||||
menuItems: []
|
||||
};
|
||||
|
||||
if (vm.rights.change) {
|
||||
menuOptions.menuItems.push({
|
||||
title: "Save",
|
||||
icon: "fa-save",
|
||||
surface: true,
|
||||
key: FORM_KEY + ":save",
|
||||
vm: vm
|
||||
});
|
||||
|
||||
menuOptions.menuItems.push({
|
||||
title: "BackupNow",
|
||||
icon: "fa-file-archive",
|
||||
surface: false,
|
||||
key: FORM_KEY + ":backupnow",
|
||||
vm: vm
|
||||
});
|
||||
}
|
||||
|
||||
window.$gz.eventBus.$emit("menu-change", menuOptions);
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
//
|
||||
//
|
||||
async function initForm(vm) {
|
||||
await fetchTranslatedText(vm);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
async function fetchTranslatedText(vm) {
|
||||
await window.$gz.translation.cacheTranslations([
|
||||
"BackupSettings",
|
||||
"BackupTime",
|
||||
"BackupLast",
|
||||
"BackupSetsToKeep",
|
||||
"BackupAttachments",
|
||||
"BackupFiles",
|
||||
"BackupNow",
|
||||
"AreYouSureBackupNow",
|
||||
"FileName",
|
||||
"FileSize",
|
||||
"FileDate",
|
||||
"AvailableSpace"
|
||||
]);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user