2020-04-10 21:54:53 +00:00
|
|
|
angular.module('portainer.docker').controller('SecretsController', [
|
|
|
|
'$scope',
|
|
|
|
'$state',
|
|
|
|
'SecretService',
|
|
|
|
'Notifications',
|
|
|
|
function ($scope, $state, SecretService, Notifications) {
|
|
|
|
$scope.removeAction = function (selectedItems) {
|
|
|
|
var actionCount = selectedItems.length;
|
|
|
|
angular.forEach(selectedItems, function (secret) {
|
|
|
|
SecretService.remove(secret.Id)
|
|
|
|
.then(function success() {
|
|
|
|
Notifications.success('Secret successfully removed', secret.Name);
|
|
|
|
var index = $scope.secrets.indexOf(secret);
|
|
|
|
$scope.secrets.splice(index, 1);
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
Notifications.error('Failure', err, 'Unable to remove secret');
|
|
|
|
})
|
|
|
|
.finally(function final() {
|
|
|
|
--actionCount;
|
|
|
|
if (actionCount === 0) {
|
|
|
|
$state.reload();
|
|
|
|
}
|
|
|
|
});
|
2017-12-06 11:04:02 +00:00
|
|
|
});
|
2020-04-10 21:54:53 +00:00
|
|
|
};
|
2017-05-27 07:23:49 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
$scope.getSecrets = getSecrets;
|
2019-07-22 10:54:59 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
function getSecrets() {
|
|
|
|
SecretService.secrets()
|
|
|
|
.then(function success(data) {
|
|
|
|
$scope.secrets = data;
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
$scope.secrets = [];
|
|
|
|
Notifications.error('Failure', err, 'Unable to retrieve secrets');
|
|
|
|
});
|
|
|
|
}
|
2017-05-27 07:23:49 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
function initView() {
|
|
|
|
getSecrets();
|
|
|
|
}
|
2019-07-22 10:54:59 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
initView();
|
|
|
|
},
|
|
|
|
]);
|