case 4173
This commit is contained in:
174
ayanova/src/components/extension-direct-smtp-control.vue
Normal file
174
ayanova/src/components/extension-direct-smtp-control.vue
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
<template>
|
||||||
|
<v-expansion-panel v-if="available == true">
|
||||||
|
<v-expansion-panel-header disable-icon-rotate expand-icon="$ayiAt">{{
|
||||||
|
$ay.t("SendEmail")
|
||||||
|
}}</v-expansion-panel-header>
|
||||||
|
<v-expansion-panel-content>
|
||||||
|
subj:{{ subject }}msg:{{ message }}
|
||||||
|
<v-row dense>
|
||||||
|
<v-col cols="12">
|
||||||
|
<v-text-field
|
||||||
|
ref="subject"
|
||||||
|
v-model="subject"
|
||||||
|
dense
|
||||||
|
:label="$ay.t('MemoSubject')"
|
||||||
|
required
|
||||||
|
></v-text-field>
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="12">
|
||||||
|
<v-textarea
|
||||||
|
ref="message"
|
||||||
|
v-model="message"
|
||||||
|
dense
|
||||||
|
:label="$ay.t('MemoMessage')"
|
||||||
|
required
|
||||||
|
auto-grow
|
||||||
|
></v-textarea>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
<v-btn icon @click="goHelp()"><v-icon>$ayiQuestionCircle</v-icon></v-btn>
|
||||||
|
<v-btn
|
||||||
|
:disabled="!canDoAction()"
|
||||||
|
color="blue darken-1"
|
||||||
|
text
|
||||||
|
:loading="jobActive"
|
||||||
|
@click="doAction()"
|
||||||
|
>{{ $ay.t("StartJob") }}</v-btn
|
||||||
|
>
|
||||||
|
|
||||||
|
<v-btn
|
||||||
|
v-if="jobActive"
|
||||||
|
color="red darken-1"
|
||||||
|
text
|
||||||
|
@click="requestCancel()"
|
||||||
|
>
|
||||||
|
{{ $ay.t("Cancel") }}</v-btn
|
||||||
|
><span v-if="jobActive">{{ progress }}</span>
|
||||||
|
</v-expansion-panel-content>
|
||||||
|
</v-expansion-panel>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
dataListSelection: { type: Object, default: null }
|
||||||
|
},
|
||||||
|
data: () => ({
|
||||||
|
jobActive: false,
|
||||||
|
currentJobId: null,
|
||||||
|
progress: "",
|
||||||
|
rights: window.$gz.role.defaultRightsObject(),
|
||||||
|
available: false,
|
||||||
|
subject: null,
|
||||||
|
message: null
|
||||||
|
}),
|
||||||
|
async created() {
|
||||||
|
const vm = this;
|
||||||
|
await fetchTranslatedText();
|
||||||
|
//bulk email must have full read rights to object
|
||||||
|
//only the following types are supported: Customer, HeadOffice, Vendor, User
|
||||||
|
|
||||||
|
if (
|
||||||
|
vm.dataListSelection.AType != 0 &&
|
||||||
|
(vm.dataListSelection.AType == window.$gz.type.Customer ||
|
||||||
|
vm.dataListSelection.AType == window.$gz.type.HeadOffice ||
|
||||||
|
vm.dataListSelection.AType == window.$gz.type.Vendor ||
|
||||||
|
vm.dataListSelection.AType == window.$gz.type.User)
|
||||||
|
) {
|
||||||
|
vm.rights = window.$gz.role.getRights(vm.dataListSelection.AType);
|
||||||
|
}
|
||||||
|
vm.available = vm.rights.change;
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
goHelp() {
|
||||||
|
window.open(window.$gz.api.helpUrl() + "ay-ex-direct-smtp", "_blank");
|
||||||
|
},
|
||||||
|
canDoAction() {
|
||||||
|
return this.subject != null && this.message != null;
|
||||||
|
},
|
||||||
|
async requestCancel() {
|
||||||
|
await window.$gz.api.upsert(
|
||||||
|
"job-operations/request-cancel",
|
||||||
|
this.currentJobId
|
||||||
|
);
|
||||||
|
},
|
||||||
|
async doAction() {
|
||||||
|
const vm = this;
|
||||||
|
const dialogResult = await window.$gz.dialog.confirmGeneric(
|
||||||
|
"EmailMultipleObjectsWarning",
|
||||||
|
"error"
|
||||||
|
);
|
||||||
|
if (dialogResult == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//Clear any possible prior errors
|
||||||
|
vm.$emit("ext-show-job-log", "clear");
|
||||||
|
|
||||||
|
//do the batch action
|
||||||
|
const url = "job-operations/batch-direct-smtp";
|
||||||
|
const body = {
|
||||||
|
selectedRequest: this.dataListSelection,
|
||||||
|
subject: this.subject,
|
||||||
|
textBody: this.message
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.progress = "";
|
||||||
|
//call api route
|
||||||
|
let jobId = await window.$gz.api.upsert(url, body);
|
||||||
|
if (jobId.error) {
|
||||||
|
throw new Error(window.$gz.errorHandler.errorToString(jobId, vm));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.currentJobId = jobId.jobId;
|
||||||
|
vm.jobActive = true;
|
||||||
|
|
||||||
|
let jobProgress = {};
|
||||||
|
|
||||||
|
while (vm.jobActive == true) {
|
||||||
|
await window.$gz.util.sleepAsync(2000);
|
||||||
|
jobProgress = await window.$gz.api.get(
|
||||||
|
`job-operations/progress/${this.currentJobId}`
|
||||||
|
);
|
||||||
|
if (jobProgress.error) {
|
||||||
|
throw new Error(
|
||||||
|
window.$gz.errorHandler.errorToString(jobProgress, vm)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
jobProgress = jobProgress.data;
|
||||||
|
this.progress = jobProgress.progress;
|
||||||
|
|
||||||
|
if (jobProgress.jobStatus == 4 || jobProgress.jobStatus == 0) {
|
||||||
|
if (jobProgress.jobStatus == 4) {
|
||||||
|
//emit job id and event to parent for log viewing
|
||||||
|
vm.$emit("ext-show-job-log", jobId);
|
||||||
|
}
|
||||||
|
throw new Error("Job failed");
|
||||||
|
}
|
||||||
|
if (jobProgress.jobStatus == 3) {
|
||||||
|
vm.jobActive = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Here if it's completed successfully
|
||||||
|
window.$gz.eventBus.$emit("notify-success", vm.$ay.t("JobCompleted"));
|
||||||
|
vm.$emit("ext-close-refresh");
|
||||||
|
} catch (error) {
|
||||||
|
vm.jobActive = false;
|
||||||
|
window.$gz.eventBus.$emit("notify-error", vm.$ay.t("JobFailed"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Ensures UI translated text is available
|
||||||
|
//
|
||||||
|
async function fetchTranslatedText() {
|
||||||
|
await window.$gz.translation.cacheTranslations([
|
||||||
|
"EmailMultipleObjectsWarning",
|
||||||
|
"SendEmail",
|
||||||
|
"MemoSubject",
|
||||||
|
"MemoMessage"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -29,6 +29,11 @@
|
|||||||
@ext-close-refresh="close({ refresh: true })"
|
@ext-close-refresh="close({ refresh: true })"
|
||||||
@ext-show-job-log="handleError($event)"
|
@ext-show-job-log="handleError($event)"
|
||||||
/>
|
/>
|
||||||
|
<ExtensionDirectSMTP
|
||||||
|
:data-list-selection="dataListSelection"
|
||||||
|
@ext-close-refresh="close({ refresh: true })"
|
||||||
|
@ext-show-job-log="handleError($event)"
|
||||||
|
/>
|
||||||
</v-expansion-panels>
|
</v-expansion-panels>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
@@ -43,12 +48,14 @@
|
|||||||
import ExtensionTags from "./extension-tags-control.vue";
|
import ExtensionTags from "./extension-tags-control.vue";
|
||||||
import ExtensionExport from "./extension-export-control.vue";
|
import ExtensionExport from "./extension-export-control.vue";
|
||||||
import ExtensionDelete from "./extension-delete-control.vue";
|
import ExtensionDelete from "./extension-delete-control.vue";
|
||||||
|
import ExtensionDirectSMTP from "./extension-direct-smtp-control.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
ExtensionTags,
|
ExtensionTags,
|
||||||
ExtensionExport,
|
ExtensionExport,
|
||||||
ExtensionDelete
|
ExtensionDelete,
|
||||||
|
ExtensionDirectSMTP
|
||||||
},
|
},
|
||||||
data: () => ({
|
data: () => ({
|
||||||
isVisible: false,
|
isVisible: false,
|
||||||
|
|||||||
@@ -643,7 +643,8 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Show license expiration period days left (if it's set to willexpire)
|
//Show license expiration period days left (if it's set to willexpire)
|
||||||
if (vm.$store.state.globalSettings.licenseExpirationDays > -1) {
|
if (vm.$store.state.globalSettings.licenseStatus == 1) {
|
||||||
|
//licensestatus 1 = active trial not expired
|
||||||
window.$gz.eventBus.$emit(
|
window.$gz.eventBus.$emit(
|
||||||
"notify-info",
|
"notify-info",
|
||||||
`${vm.$ay.t("LicenseExpirationDays")}: ${
|
`${vm.$ay.t("LicenseExpirationDays")}: ${
|
||||||
|
|||||||
Reference in New Issue
Block a user