42 lines
1.2 KiB
JavaScript
Raw Normal View History

2015-06-22 13:47:27 -07:00
'use strict';
angular.module('lemur')
2015-11-23 14:30:23 -08:00
.controller('CertificateUploadController', function ($scope, $modalInstance, CertificateService, LemurRestangular, DestinationService, NotificationService, PluginService, toaster) {
2015-06-22 13:47:27 -07:00
$scope.certificate = LemurRestangular.restangularizeElement(null, {}, 'certificates');
$scope.upload = CertificateService.upload;
$scope.destinationService = DestinationService;
$scope.notificationService = NotificationService;
2015-11-24 14:53:22 -08:00
$scope.certificateService = CertificateService;
2015-06-22 13:47:27 -07:00
PluginService.getByType('destination').then(function (plugins) {
$scope.plugins = plugins;
});
2015-06-22 13:47:27 -07:00
$scope.save = function (certificate) {
2015-11-23 14:30:23 -08:00
CertificateService.upload(certificate).then(
function () {
toaster.pop({
type: 'success',
title: certificate.name,
body: 'Successfully uploaded!'
});
$modalInstance.close();
},
function (response) {
toaster.pop({
type: 'error',
title: certificate.name,
body: 'Failed to upload ' + response.data.message,
timeout: 100000
});
});
2015-06-22 13:47:27 -07:00
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
2015-06-22 13:47:27 -07:00
});