lemur/lemur/static/app/angular/notifications/notification/notification.js

66 lines
2.1 KiB
JavaScript
Raw Normal View History

2015-08-02 00:29:34 +02:00
'use strict';
angular.module('lemur')
.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 () {
$uibModalInstance.close();
2015-08-02 00:29:34 +02:00
},
function () {
}
);
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
2015-08-02 00:29:34 +02:00
};
$scope.certificateService = CertificateService;
})
.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) {
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-02 00:29:34 +02:00
});
});
$scope.save = function (notification) {
NotificationService.update(notification).then(function () {
$uibModalInstance.close();
2015-08-02 00:29:34 +02:00
});
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
2015-08-02 00:29:34 +02:00
};
$scope.certificateService = CertificateService;
});