]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager6/window/BulkAction.js
ui: storage content: transform detected compression extension to lower-case
[pve-manager.git] / www / manager6 / window / BulkAction.js
index 135f570f33d0ba8d883d2a957b3f9acefe85298d..949e167e257d5c91c91c67c7d36efe1b22bf41e2 100644 (file)
@@ -3,47 +3,40 @@ Ext.define('PVE.window.BulkAction', {
 
     resizable: true,
     width: 800,
+    height: 600,
     modal: true,
     layout: {
        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;
+       let me = this;
 
        if (!me.nodename) {
            throw "no node name specified";
@@ -58,10 +51,8 @@ Ext.define('PVE.window.BulkAction', {
            throw "no title specified";
        }
 
-       var items = [];
-
+       let items = [];
        if (me.action === 'migrateall') {
-           /*value is string and number*/
            items.push(
                {
                    xtype: 'pveNodeSelector',
@@ -92,7 +83,6 @@ Ext.define('PVE.window.BulkAction', {
                        listeners: {
                            change: (cb, val) => me.down('#localdiskwarning').setVisible(val),
                        },
-
                    },
                    {
                        itemId: 'localdiskwarning',
@@ -117,6 +107,26 @@ Ext.define('PVE.window.BulkAction', {
                name: 'force',
                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({
@@ -131,11 +141,10 @@ 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);
                    }
                },
@@ -150,15 +159,15 @@ Ext.define('PVE.window.BulkAction', {
                align: 'stretch',
            },
            fieldDefaults: {
-               labelWidth: 300,
+               labelWidth: me.action === 'migrateall' ? 300 : 120,
                anchor: '100%',
            },
            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();
@@ -174,7 +183,7 @@ Ext.define('PVE.window.BulkAction', {
        me.callParent();
 
        form.on('validitychange', function() {
-           var valid = form.isValid();
+           let valid = form.isValid();
            submitBtn.setDisabled(!valid);
        });
        form.isValid();