2023-02-14 08:19:41 +00:00
|
|
|
import { confirmDelete } from '@@/modals/confirm';
|
2020-04-10 21:54:53 +00:00
|
|
|
angular.module('portainer.docker').controller('SecretsController', [
|
|
|
|
'$scope',
|
|
|
|
'$state',
|
|
|
|
'SecretService',
|
|
|
|
'Notifications',
|
|
|
|
function ($scope, $state, SecretService, Notifications) {
|
2022-10-21 08:03:41 +00:00
|
|
|
$scope.removeAction = async function (selectedItems) {
|
2023-02-14 08:19:41 +00:00
|
|
|
const confirmed = await confirmDelete('Do you want to remove the selected secret(s)?');
|
2022-10-21 08:03:41 +00:00
|
|
|
if (!confirmed) {
|
|
|
|
return null;
|
|
|
|
}
|
2020-04-10 21:54:53 +00:00
|
|
|
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();
|
|
|
|
},
|
|
|
|
]);
|