2020-06-12 12:28:29 +00:00
|
|
|
import ngModule from '../module';
|
|
|
|
|
|
|
|
class Email {
|
|
|
|
constructor($http, $translate, vnApp) {
|
|
|
|
this.$http = $http;
|
|
|
|
this.vnApp = vnApp;
|
|
|
|
this.$t = $translate.instant;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sends an email displaying a notification when it's sent.
|
|
|
|
*
|
|
|
|
* @param {String} template The email report name
|
|
|
|
* @param {Object} params The email parameters
|
|
|
|
* @return {Promise} Promise resolved when it's sent
|
|
|
|
*/
|
|
|
|
send(template, params) {
|
|
|
|
return this.$http.get(`email/${template}`, {params})
|
|
|
|
.then(() => this.vnApp.showMessage(this.$t('Notification sent!')));
|
|
|
|
}
|
2021-10-01 10:41:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sends an email displaying a notification when it's sent.
|
|
|
|
*
|
|
|
|
* @param {String} template The email report name
|
|
|
|
* @param {Object} params The email parameters
|
|
|
|
* @return {Promise} Promise resolved when it's sent
|
|
|
|
*/
|
2021-10-07 08:04:50 +00:00
|
|
|
sendCsv(template, params) {
|
2021-10-01 10:41:31 +00:00
|
|
|
return this.$http.get(`csv/${template}/send`, {params})
|
|
|
|
.then(() => this.vnApp.showMessage(this.$t('Notification sent!')));
|
|
|
|
}
|
2020-06-12 12:28:29 +00:00
|
|
|
}
|
|
|
|
Email.$inject = ['$http', '$translate', 'vnApp'];
|
|
|
|
|
|
|
|
ngModule.service('vnEmail', Email);
|