2015-08-02 00:29:34 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular.module('lemur')
|
|
|
|
|
2016-05-10 02:17:00 +02:00
|
|
|
.controller('NotificationsCreateController', function ($scope, $uibModalInstance, PluginService, NotificationService, CertificateService, LemurRestangular){
|
2015-08-02 00:29:34 +02:00
|
|
|
$scope.notification = LemurRestangular.restangularizeElement(null, {}, 'notifications');
|
|
|
|
|
|
|
|
PluginService.getByType('notification').then(function (plugins) {
|
|
|
|
$scope.plugins = plugins;
|
|
|
|
});
|
|
|
|
$scope.save = function (notification) {
|
|
|
|
NotificationService.create(notification).then(
|
|
|
|
function () {
|
2016-05-10 02:17:00 +02:00
|
|
|
$uibModalInstance.close();
|
2015-08-02 00:29:34 +02:00
|
|
|
},
|
|
|
|
function () {
|
|
|
|
|
|
|
|
}
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.cancel = function () {
|
2016-05-10 02:17:00 +02:00
|
|
|
$uibModalInstance.dismiss('cancel');
|
2015-08-02 00:29:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.certificateService = CertificateService;
|
|
|
|
})
|
|
|
|
|
2016-05-10 02:17:00 +02:00
|
|
|
.controller('NotificationsEditController', function ($scope, $uibModalInstance, NotificationService, NotificationApi, PluginService, CertificateService, editId) {
|
2015-08-02 00:29:34 +02:00
|
|
|
NotificationApi.get(editId).then(function (notification) {
|
|
|
|
$scope.notification = notification;
|
2015-08-04 00:52:39 +02:00
|
|
|
PluginService.getByType('notification').then(function (plugins) {
|
|
|
|
$scope.plugins = plugins;
|
|
|
|
_.each($scope.plugins, function (plugin) {
|
|
|
|
if (plugin.slug === $scope.notification.pluginName) {
|
|
|
|
plugin.pluginOptions = $scope.notification.notificationOptions;
|
|
|
|
$scope.notification.plugin = plugin;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2015-08-02 00:29:34 +02:00
|
|
|
NotificationService.getCertificates(notification);
|
|
|
|
});
|
|
|
|
|
|
|
|
PluginService.getByType('notification').then(function (plugins) {
|
|
|
|
$scope.plugins = plugins;
|
|
|
|
_.each($scope.plugins, function (plugin) {
|
2015-08-02 00:47:14 +02:00
|
|
|
if (plugin.slug === $scope.notification.pluginName) {
|
2015-08-02 00:29:34 +02:00
|
|
|
plugin.pluginOptions = $scope.notification.notificationOptions;
|
|
|
|
$scope.notification.plugin = plugin;
|
2015-08-03 22:51:27 +02:00
|
|
|
}
|
2015-08-02 00:29:34 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$scope.save = function (notification) {
|
|
|
|
NotificationService.update(notification).then(function () {
|
2016-05-10 02:17:00 +02:00
|
|
|
$uibModalInstance.close();
|
2015-08-02 00:29:34 +02:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.cancel = function () {
|
2016-05-10 02:17:00 +02:00
|
|
|
$uibModalInstance.dismiss('cancel');
|
2015-08-02 00:29:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.certificateService = CertificateService;
|
|
|
|
});
|