]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/window/BulkAction.js
add lxc restart warning to bulk migration screen
[pve-manager.git] / www / manager6 / window / BulkAction.js
CommitLineData
6ae2ec81
DC
1Ext.define('PVE.window.BulkAction', {
2 extend: 'Ext.window.Window',
3
4 resizable: true,
5 width: 800,
6 modal: true,
7 layout: {
8 type: 'fit'
9 },
10 border: false,
11
12 // the action to be set
13 // currently there are
14 // startall
15 // migrateall
16 // stopall
17 action: undefined,
18
19 submit: function(params) {
20 var me = this;
e7ade592 21 Proxmox.Utils.API2Request({
6ae2ec81 22 params: params,
6e5711db 23 url: '/nodes/' + me.nodename + '/' + me.action,
6ae2ec81
DC
24 waitMsgTarget: me,
25 method: 'POST',
26 failure: function(response, opts) {
27 Ext.Msg.alert('Error', response.htmlStatus);
28 },
29 success: function(response, options) {
30 var upid = response.result.data;
31
8cbc11a7 32 var win = Ext.create('Proxmox.window.TaskViewer', {
6ae2ec81
DC
33 upid: upid
34 });
35 win.show();
36 me.hide();
37 win.on('destroy', function() {
38 me.close();
39 });
40 }
41 });
42 },
43
44 initComponent : function() {
45 var me = this;
46
47 if (!me.nodename) {
48 throw "no node name specified";
49 }
50
51 if (!me.action) {
52 throw "no action specified";
53 }
54
55 if (!me.btnText) {
56 throw "no button text specified";
57 }
58
59 if (!me.title) {
60 throw "no title specified";
61 }
62
63 var items = [];
64
65 if (me.action === 'migrateall') {
66 items.push(
67 {
68 xtype: 'pveNodeSelector',
69 name: 'target',
70 disallowedNodes: [me.nodename],
09f5f402 71 fieldLabel: gettext('Target node'),
6ae2ec81
DC
72 allowBlank: false,
73 onlineValidator: true
74 },
75 {
bf96f60d 76 xtype: 'proxmoxintegerfield',
6ae2ec81
DC
77 name: 'maxworkers',
78 minValue: 1,
79 maxValue: 100,
80 value: 1,
09f5f402 81 fieldLabel: gettext('Parallel jobs'),
6ae2ec81 82 allowBlank: false
200a9b5d
OB
83 },
84 {
85 itemId: 'lxcwarning',
86 xtype: 'displayfield',
87 userCls: 'pve-hint',
88 value: 'Warning: Running CTs will be migrated in Restart Mode.',
89 hidden: true // only visible if running container chosen
6ae2ec81
DC
90 }
91 );
92 } else if (me.action === 'startall') {
93 items.push({
94 xtype: 'hiddenfield',
95 name: 'force',
96 value: 1
97 });
98 }
99
100 items.push({
101 xtype: 'vmselector',
102 itemId: 'vms',
103 name: 'vms',
104 flex: 1,
105 height: 300,
106 selectAll: true,
107 allowBlank: false,
eb882c6f 108 nodename: me.nodename,
200a9b5d
OB
109 action: me.action,
110 listeners: {
111 selectionchange: function(vmselector, records) {
112 if (me.action == 'migrateall') {
113 let showWarning = records.some(function(item) {
114 return (item.data.type == 'lxc' &&
115 item.data.status == 'running');
116 });
117 me.down('#lxcwarning').setVisible(showWarning);
118 }
119 }
120 }
6ae2ec81
DC
121 });
122
123 me.formPanel = Ext.create('Ext.form.Panel', {
124 bodyPadding: 10,
125 border: false,
126 layout: {
127 type: 'vbox',
128 align: 'stretch'
129 },
130 fieldDefaults: {
131 labelWidth: 300,
132 anchor: '100%'
133 },
134 items: items
135 });
136
137 var form = me.formPanel.getForm();
138
139 var submitBtn = Ext.create('Ext.Button', {
140 text: me.btnText,
141 handler: function() {
142 form.isValid();
143 me.submit(form.getValues());
144 }
145 });
146
147 Ext.apply(me, {
148 items: [ me.formPanel ],
149 buttons: [ submitBtn ]
150 });
151
152 me.callParent();
153
154 form.on('validitychange', function() {
155 var valid = form.isValid();
156 submitBtn.setDisabled(!valid);
157 });
158 form.isValid();
159 }
160});