mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 07:49:41 +02:00
feat(container-details): add the ability to update restart policy
This commit is contained in:
parent
de9f99d030
commit
8769fadd5c
7 changed files with 130 additions and 13 deletions
|
@ -15,6 +15,8 @@ function ($q, $scope, $state, $transition$, $filter, Commit, ContainerHelper, Co
|
|||
leaveNetworkInProgress: false
|
||||
};
|
||||
|
||||
$scope.updateRestartPolicy = updateRestartPolicy;
|
||||
|
||||
var update = function () {
|
||||
var nodeName = $transition$.params().nodeName;
|
||||
HttpRequestHelper.setPortainerAgentTargetHeader(nodeName);
|
||||
|
@ -308,6 +310,27 @@ function ($q, $scope, $state, $transition$, $filter, Commit, ContainerHelper, Co
|
|||
});
|
||||
};
|
||||
|
||||
function updateRestartPolicy(restartPolicy, maximumRetryCount) {
|
||||
maximumRetryCount = restartPolicy === 'on-failure' ? maximumRetryCount : undefined;
|
||||
|
||||
return ContainerService
|
||||
.updateRestartPolicy($scope.container.Id, restartPolicy, maximumRetryCount)
|
||||
.then(onUpdateSuccess)
|
||||
.catch(notifyOnError);
|
||||
|
||||
function onUpdateSuccess() {
|
||||
$scope.container.HostConfig.RestartPolicy = {
|
||||
Name: restartPolicy,
|
||||
MaximumRetryCount: maximumRetryCount
|
||||
};
|
||||
}
|
||||
|
||||
function notifyOnError(err) {
|
||||
Notifications.error('Failure', err, 'Unable to update restart policy');
|
||||
return $q.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
var provider = $scope.applicationState.endpoint.mode.provider;
|
||||
var apiVersion = $scope.applicationState.endpoint.apiVersion;
|
||||
NetworkService.networks(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue