43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
|
import ngModule from '../module';
|
||
|
import Component from 'core/lib/component';
|
||
|
import './style.scss';
|
||
|
|
||
|
class Controller extends Component {
|
||
|
constructor($element, $scope, $http, $translate, vnApp) {
|
||
|
super($element, $scope);
|
||
|
|
||
|
this.$scope = $scope;
|
||
|
this.$http = $http;
|
||
|
this.$translate = $translate;
|
||
|
this.vnApp = vnApp;
|
||
|
}
|
||
|
|
||
|
open() {
|
||
|
this.$scope.SMSDialog.show();
|
||
|
}
|
||
|
|
||
|
onResponse(response) {
|
||
|
if (response === 'ACCEPT') {
|
||
|
let params = {
|
||
|
recipient: this.sms.recipient,
|
||
|
message: this.sms.message
|
||
|
};
|
||
|
this.$http.post(`/client/api/Sms/send`, params).then(res => {
|
||
|
this.vnApp.showMessage(this.$translate.instant('SMS sent!'));
|
||
|
|
||
|
if (res.data) this.emit('send', {response: res.data});
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Controller.$inject = ['$element', '$scope', '$http', '$translate', 'vnApp'];
|
||
|
|
||
|
ngModule.component('vnClientSms', {
|
||
|
template: require('./index.html'),
|
||
|
controller: Controller,
|
||
|
bindings: {
|
||
|
sms: '<',
|
||
|
}
|
||
|
});
|