]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager6/window/BulkAction.js
ui: avoid trivial decompression widget, only used once
[pve-manager.git] / www / manager6 / window / BulkAction.js
index 0429d96d614d840fcf2a95ffb31f27d8cddca8ba..949e167e257d5c91c91c67c7d36efe1b22bf41e2 100644 (file)
@@ -3,69 +3,56 @@ Ext.define('PVE.window.BulkAction', {
 
     resizable: true,
     width: 800,
+    height: 600,
     modal: true,
     layout: {
-       type: 'fit'
+       type: 'fit',
     },
     border: false,
 
-    // the action to be set
-    // currently there are
-    // startall
-    // migrateall
-    // stopall
+    // the action to set, currently there are: `startall`, `migrateall`, `stopall`
     action: undefined,
 
     submit: function(params) {
-       var me = this;
+       let me = this;
 
        Proxmox.Utils.API2Request({
            params: params,
-           url: '/nodes/' + me.nodename + '/' + me.action,
+           url: `/nodes/${me.nodename}/${me.action}`,
            waitMsgTarget: me,
            method: 'POST',
-           failure: function(response, opts) {
-               Ext.Msg.alert('Error', response.htmlStatus);
-           },
-           success: function(response, options) {
-               var upid = response.result.data;
-
-               var win = Ext.create('Proxmox.window.TaskViewer', {
-                   upid: upid
+           failure: response => Ext.Msg.alert('Error', response.htmlStatus),
+           success: function({ result }, options) {
+               Ext.create('Proxmox.window.TaskViewer', {
+                   autoShow: true,
+                   upid: result.data,
+                   listeners: {
+                       destroy: () => me.close(),
+                   },
                });
-               win.show();
                me.hide();
-               win.on('destroy', function() {
-                   me.close();
-               });
-           }
+           },
        });
     },
 
-    initComponent : function() {
-       var me = this;
+    initComponent: function() {
+       let me = this;
 
        if (!me.nodename) {
            throw "no node name specified";
        }
-
        if (!me.action) {
            throw "no action specified";
        }
-
        if (!me.btnText) {
            throw "no button text specified";
        }
-
        if (!me.title) {
            throw "no title specified";
        }
 
-       var items = [];
-
+       let items = [];
        if (me.action === 'migrateall') {
-           /*jslint confusion: true*/
-           /*value is string and number*/
            items.push(
                {
                    xtype: 'pveNodeSelector',
@@ -73,7 +60,7 @@ Ext.define('PVE.window.BulkAction', {
                    disallowedNodes: [me.nodename],
                    fieldLabel: gettext('Target node'),
                    allowBlank: false,
-                   onlineValidator: true
+                   onlineValidator: true,
                },
                {
                    xtype: 'proxmoxintegerfield',
@@ -82,43 +69,64 @@ Ext.define('PVE.window.BulkAction', {
                    maxValue: 100,
                    value: 1,
                    fieldLabel: gettext('Parallel jobs'),
-                   allowBlank: false
+                   allowBlank: false,
                },
                {
-                   xtype: 'proxmoxcheckbox',
-                   name: 'with-local-disks',
-                   checked: false,
-                   uncheckedValue: 0,
-                   fieldLabel: gettext('Migrate VMs with local disks'),
-                   listeners: {
-                       change: function(cb, val) {
-                           me.down('#localdiskwarning').setVisible(val);
-                       }
-                   }
-
-               },
-               {
-                   itemId: 'localdiskwarning',
-                   xtype: 'displayfield',
-                   userCls: 'pmx-hint',
-                   value: 'Warning: Migration with local disks might take long.',
-                   hidden: true
+                   xtype: 'fieldcontainer',
+                   fieldLabel: gettext('Allow local disk migration'),
+                   layout: 'hbox',
+                   items: [{
+                       xtype: 'proxmoxcheckbox',
+                       name: 'with-local-disks',
+                       checked: true,
+                       uncheckedValue: 0,
+                       listeners: {
+                           change: (cb, val) => me.down('#localdiskwarning').setVisible(val),
+                       },
+                   },
+                   {
+                       itemId: 'localdiskwarning',
+                       xtype: 'displayfield',
+                       flex: 1,
+                       padding: '0 0 0 10',
+                       userCls: 'pmx-hint',
+                       value: 'Note: Migration with local disks might take long.',
+                   }],
                },
                {
                    itemId: 'lxcwarning',
                    xtype: 'displayfield',
                    userCls: 'pmx-hint',
                    value: 'Warning: Running CTs will be migrated in Restart Mode.',
-                   hidden: true // only visible if running container chosen
-               }
+                   hidden: true, // only visible if running container chosen
+               },
            );
-           /*jslint confusion: false*/
        } else if (me.action === 'startall') {
            items.push({
                xtype: 'hiddenfield',
                name: 'force',
-               value: 1
+               value: 1,
            });
+       } else if (me.action === 'stopall') {
+           items.push(
+               {
+                   xtype: 'proxmoxcheckbox',
+                   name: 'force-stop',
+                   fieldLabel: gettext('Force Stop'),
+                   boxLabel: gettext('Force stop guest if shutdown times out.'),
+                   checked: true,
+                   uncheckedValue: 0,
+               },
+               {
+                   xtype: 'proxmoxintegerfield',
+                   name: 'timeout',
+                   fieldLabel: gettext('Timeout (s)'),
+                   emptyText: '180',
+                   minValue: 0,
+                   maxValue: 7200,
+                   allowBlank: true,
+               },
+           );
        }
 
        items.push({
@@ -133,15 +141,14 @@ Ext.define('PVE.window.BulkAction', {
            action: me.action,
            listeners: {
                selectionchange: function(vmselector, records) {
-                   if (me.action == 'migrateall') {
-                       var showWarning = records.some(function(item) {
-                           return (item.data.type == 'lxc' &&
-                               item.data.status == 'running');
-                       });
+                   if (me.action === 'migrateall') {
+                       let showWarning = records.some(
+                           item => item.data.type === 'lxc' && item.data.status === 'running',
+                       );
                        me.down('#lxcwarning').setVisible(showWarning);
                    }
-               }
-           }
+               },
+           },
        });
 
        me.formPanel = Ext.create('Ext.form.Panel', {
@@ -149,36 +156,36 @@ Ext.define('PVE.window.BulkAction', {
            border: false,
            layout: {
                type: 'vbox',
-               align: 'stretch'
+               align: 'stretch',
            },
            fieldDefaults: {
-               labelWidth: 300,
-               anchor: '100%'
+               labelWidth: me.action === 'migrateall' ? 300 : 120,
+               anchor: '100%',
            },
-           items: items
+           items: items,
        });
 
-       var form = me.formPanel.getForm();
+       let form = me.formPanel.getForm();
 
-       var submitBtn = Ext.create('Ext.Button', {
+       let submitBtn = Ext.create('Ext.Button', {
            text: me.btnText,
            handler: function() {
                form.isValid();
                me.submit(form.getValues());
-           }
+           },
        });
 
        Ext.apply(me, {
-           items: [ me.formPanel ],
-           buttons: [ submitBtn ]
+           items: [me.formPanel],
+           buttons: [submitBtn],
        });
 
        me.callParent();
 
        form.on('validitychange', function() {
-           var valid = form.isValid();
+           let valid = form.isValid();
            submitBtn.setDisabled(!valid);
        });
        form.isValid();
-    }
+    },
 });