mirror of
https://github.com/portainer/portainer.git
synced 2025-07-21 06:19:41 +02:00
feat(container-details): update container-restart-policy component (#2273)
This commit is contained in:
parent
b24891a6bc
commit
77913543b1
4 changed files with 27 additions and 55 deletions
|
@ -1,36 +1,26 @@
|
||||||
angular
|
angular
|
||||||
.module('portainer.docker')
|
.module('portainer.docker')
|
||||||
.controller('ContainerRestartPolicyController', [
|
.controller('ContainerRestartPolicyController', [function ContainerRestartPolicyController() {
|
||||||
function ContainerRestartPolicyController() {
|
var ctrl = this;
|
||||||
var ctrl = this;
|
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
editMode :false,
|
editModel : {}
|
||||||
editModel :{}
|
};
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
ctrl.toggleEdit = toggleEdit;
|
ctrl.save = save;
|
||||||
ctrl.save = save;
|
|
||||||
|
|
||||||
function toggleEdit() {
|
function save() {
|
||||||
ctrl.state.editMode = true;
|
if (ctrl.state.editModel.name === ctrl.name && ctrl.state.editModel.maximumRetryCount === ctrl.maximumRetryCount) {
|
||||||
ctrl.state.editModel = {
|
return;
|
||||||
name: ctrl.name,
|
|
||||||
maximumRetryCount: ctrl.maximumRetryCount
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function save() {
|
|
||||||
if (ctrl.state.editModel.name === ctrl.name &&
|
|
||||||
ctrl.state.editModel.maximumRetryCount === ctrl.maximumRetryCount) {
|
|
||||||
ctrl.state.editMode = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ctrl.updateRestartPolicy(ctrl.state.editModel)
|
|
||||||
.then(function onUpdateSucceed() {
|
|
||||||
ctrl.state.editMode = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]);
|
ctrl.updateRestartPolicy(ctrl.state.editModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$onInit = function() {
|
||||||
|
ctrl.state.editModel = {
|
||||||
|
name: ctrl.name,
|
||||||
|
maximumRetryCount: ctrl.maximumRetryCount
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
|
@ -1,23 +1,5 @@
|
||||||
<div>
|
<div>
|
||||||
<table class="table table-bordered table-condensed" ng-if="!$ctrl.state.editMode">
|
<table class="table table-bordered table-condensed">
|
||||||
<tr>
|
|
||||||
<td class="col-md-3">
|
|
||||||
<a href="" data-toggle="tooltip" title="Edit restart policy" ng-click="$ctrl.toggleEdit()">
|
|
||||||
<i class="fa fa-edit"></i>
|
|
||||||
</a>
|
|
||||||
<span>Name</span>
|
|
||||||
</td>
|
|
||||||
<td>{{$ctrl.name }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr ng-if="$ctrl.name === 'on-failure'">
|
|
||||||
<td class="col-md-3">Maximum Retry Count</td>
|
|
||||||
<td>
|
|
||||||
{{ $ctrl.maximumRetryCount }}
|
|
||||||
</td>
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<table class="table table-bordered table-condensed" ng-if="$ctrl.state.editMode">
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="col-md-3">
|
<td class="col-md-3">
|
||||||
<span>Name</span>
|
<span>Name</span>
|
||||||
|
@ -31,15 +13,14 @@
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<td class="col-md-2">
|
<td class="col-md-2">
|
||||||
<button class="btn btn-success" ng-click="$ctrl.save()">Save</button>
|
<button class="btn btn-sm btn-primary" ng-click="$ctrl.save()">Update</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr ng-if="$ctrl.state.editModel.name === 'on-failure'">
|
<tr ng-if="$ctrl.state.editModel.name === 'on-failure'">
|
||||||
<td class="col-md-3">Maximum Retry Count</td>
|
<td class="col-md-3">Maximum Retry Count</td>
|
||||||
<td>
|
<td colspan="2">
|
||||||
<input type="number" class="form-control" ng-model="$ctrl.state.editModel.maximumRetryCount" />
|
<input type="number" class="form-control" ng-model="$ctrl.state.editModel.maximumRetryCount" />
|
||||||
</td>
|
</td>
|
||||||
<td class="col-md-2"></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -226,7 +226,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td>Restart policies</td>
|
<td>Restart policies</td>
|
||||||
<td>
|
<td>
|
||||||
<container-restart-policy
|
<container-restart-policy ng-if="container"
|
||||||
name="container.HostConfig.RestartPolicy.Name"
|
name="container.HostConfig.RestartPolicy.Name"
|
||||||
maximum-retry-count="container.HostConfig.RestartPolicy.MaximumRetryCount"
|
maximum-retry-count="container.HostConfig.RestartPolicy.MaximumRetryCount"
|
||||||
update-restart-policy="updateRestartPolicy(name, maximumRetryCount)">
|
update-restart-policy="updateRestartPolicy(name, maximumRetryCount)">
|
||||||
|
|
|
@ -323,6 +323,7 @@ function ($q, $scope, $state, $transition$, $filter, Commit, ContainerHelper, Co
|
||||||
Name: restartPolicy,
|
Name: restartPolicy,
|
||||||
MaximumRetryCount: maximumRetryCount
|
MaximumRetryCount: maximumRetryCount
|
||||||
};
|
};
|
||||||
|
Notifications.success('Restart policy updated');
|
||||||
}
|
}
|
||||||
|
|
||||||
function notifyOnError(err) {
|
function notifyOnError(err) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue