mirror of
https://github.com/portainer/portainer.git
synced 2025-08-07 23:05:26 +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
|
@ -223,21 +223,13 @@
|
|||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr ng-if="container.HostConfig.RestartPolicy.Name !== 'no'">
|
||||
<tr>
|
||||
<td>Restart policies</td>
|
||||
<td>
|
||||
<table class="table table-bordered table-condensed">
|
||||
<tr>
|
||||
<td class="col-md-3">Name</td>
|
||||
<td>{{ container.HostConfig.RestartPolicy.Name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-3">MaximumRetryCount</td>
|
||||
<td>
|
||||
{{ container.HostConfig.RestartPolicy.MaximumRetryCount }}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<container-restart-policy
|
||||
name="container.HostConfig.RestartPolicy.Name"
|
||||
maximum-retry-count="container.HostConfig.RestartPolicy.MaximumRetryCount"
|
||||
update-restart-policy="updateRestartPolicy(name, maximumRetryCount)">
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
|
|
@ -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