mirror of
https://github.com/portainer/portainer.git
synced 2025-07-29 10:19:41 +02:00
refactor(docker/services): migrate scale form to react [EE-6057] (#10208)
This commit is contained in:
parent
f7366d9788
commit
e82b34b775
19 changed files with 543 additions and 180 deletions
|
@ -1,32 +1,17 @@
|
|||
import { confirmDelete } from '@@/modals/confirm';
|
||||
import { confirmServiceForceUpdate } from '@/react/docker/services/common/update-service-modal';
|
||||
import { convertServiceToConfig } from '@/react/docker/services/common/convertServiceToConfig';
|
||||
|
||||
angular.module('portainer.docker').controller('ServicesDatatableActionsController', [
|
||||
'$q',
|
||||
'$state',
|
||||
'ServiceService',
|
||||
'ServiceHelper',
|
||||
'Notifications',
|
||||
'ImageHelper',
|
||||
'WebhookService',
|
||||
function ($q, $state, ServiceService, ServiceHelper, Notifications, ImageHelper, WebhookService) {
|
||||
function ($q, $state, ServiceService, Notifications, ImageHelper, WebhookService) {
|
||||
const ctrl = this;
|
||||
|
||||
this.scaleAction = function scaleService(service) {
|
||||
var config = ServiceHelper.serviceToConfig(service.Model);
|
||||
config.Mode.Replicated.Replicas = service.Replicas;
|
||||
ServiceService.update(service, config)
|
||||
.then(function success() {
|
||||
Notifications.success('Service successfully scaled', 'New replica count: ' + service.Replicas);
|
||||
$state.reload();
|
||||
})
|
||||
.catch(function error(err) {
|
||||
Notifications.error('Failure', err, 'Unable to scale service');
|
||||
service.Scale = false;
|
||||
service.Replicas = service.ReplicaCount;
|
||||
});
|
||||
};
|
||||
|
||||
this.removeAction = function (selectedItems) {
|
||||
confirmDelete('Do you want to remove the selected service(s)? All the containers associated to the selected service(s) will be removed too.').then((confirmed) => {
|
||||
if (!confirmed) {
|
||||
|
@ -51,7 +36,7 @@ angular.module('portainer.docker').controller('ServicesDatatableActionsControlle
|
|||
function forceUpdateServices(services, pullImage) {
|
||||
var actionCount = services.length;
|
||||
angular.forEach(services, function (service) {
|
||||
var config = ServiceHelper.serviceToConfig(service.Model);
|
||||
var config = convertServiceToConfig(service.Model);
|
||||
if (pullImage) {
|
||||
config.TaskTemplate.ContainerSpec.Image = ImageHelper.removeDigestFromRepository(config.TaskTemplate.ContainerSpec.Image);
|
||||
}
|
||||
|
|
|
@ -178,32 +178,11 @@
|
|||
</td>
|
||||
<td ng-if="$ctrl.showStackColumn">{{ item.StackName ? item.StackName : '-' }}</td>
|
||||
<td ng-show="$ctrl.columnVisibility.columns.image.display">{{ item.Image | hideshasum }}</td>
|
||||
<td ng-controller="ServicesDatatableActionsController as actionCtrl">
|
||||
<td>
|
||||
{{ item.Mode }}
|
||||
<code>{{ item.Tasks | runningtaskscount }}</code> / <code>{{ item.Mode === 'replicated' ? item.Replicas : ($ctrl.nodes | availablenodecount: item) }}</code>
|
||||
<span ng-if="item.Mode === 'replicated' && !item.Scale" authorization="DockerServiceUpdate">
|
||||
<a class="interactive vertical-center" ng-click="item.Scale = true; item.ReplicaCount = item.Replicas; $event.stopPropagation();">
|
||||
<pr-icon icon="'minimize-2'"></pr-icon>
|
||||
Scale
|
||||
</a>
|
||||
</span>
|
||||
<span ng-if="item.Mode === 'replicated' && item.Scale">
|
||||
<input
|
||||
class="input-sm"
|
||||
type="number"
|
||||
min="0"
|
||||
step="1"
|
||||
ng-model="item.Replicas"
|
||||
on-enter-key="actionCtrl.scaleAction(item)"
|
||||
auto-focus
|
||||
ng-click="$event.stopPropagation();"
|
||||
/>
|
||||
<a class="interactive vertical-center" ng-click="item.Scale = false; $event.stopPropagation();">
|
||||
<pr-icon icon="'x'"></pr-icon>
|
||||
</a>
|
||||
<a class="interactive vertical-center" ng-click="actionCtrl.scaleAction(item); $event.stopPropagation();">
|
||||
<pr-icon icon="'check-square'"></pr-icon>
|
||||
</a>
|
||||
<span ng-if="item.Mode === 'replicated'">
|
||||
<docker-services-datatable-scale-service-button service="item"></docker-services-datatable-scale-service-button>
|
||||
</span>
|
||||
</td>
|
||||
<td ng-show="$ctrl.columnVisibility.columns.ports.display">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue