1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-23 07:19:41 +02:00
portainer/app/components/secret/secretController.js
Anthony Lapenna ff628bb438 refactor(app): upgrade to the latest version of ui-router (#1219)
* refactor(app): upgrade to the latest version of ui-router

* fix(app): define optional from parameter in action.create.container state

* refactor(app): replace $uiRouterGlobals with $transition$
2017-09-21 16:00:53 +02:00

35 lines
1 KiB
JavaScript

angular.module('secret', [])
.controller('SecretController', ['$scope', '$transition$', '$state', 'SecretService', 'Notifications',
function ($scope, $transition$, $state, SecretService, Notifications) {
$scope.removeSecret = function removeSecret(secretId) {
$('#loadingViewSpinner').show();
SecretService.remove(secretId)
.then(function success(data) {
Notifications.success('Secret successfully removed');
$state.go('secrets', {});
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to remove secret');
})
.finally(function final() {
$('#loadingViewSpinner').hide();
});
};
function initView() {
$('#loadingViewSpinner').show();
SecretService.secret($transition$.params().id)
.then(function success(data) {
$scope.secret = data;
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to retrieve secret details');
})
.finally(function final() {
$('#loadingViewSpinner').hide();
});
}
initView();
}]);