]>
Commit | Line | Data |
---|---|---|
6ae2ec81 DC |
1 | Ext.define('PVE.window.BulkAction', { |
2 | extend: 'Ext.window.Window', | |
3 | ||
4 | resizable: true, | |
5 | width: 800, | |
6 | modal: true, | |
7 | layout: { | |
f6710aac | 8 | type: 'fit', |
6ae2ec81 DC |
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; | |
3d625330 | 21 | |
e7ade592 | 22 | Proxmox.Utils.API2Request({ |
6ae2ec81 | 23 | params: params, |
6e5711db | 24 | url: '/nodes/' + me.nodename + '/' + me.action, |
6ae2ec81 DC |
25 | waitMsgTarget: me, |
26 | method: 'POST', | |
27 | failure: function(response, opts) { | |
28 | Ext.Msg.alert('Error', response.htmlStatus); | |
29 | }, | |
30 | success: function(response, options) { | |
31 | var upid = response.result.data; | |
32 | ||
8cbc11a7 | 33 | var win = Ext.create('Proxmox.window.TaskViewer', { |
f6710aac | 34 | upid: upid, |
6ae2ec81 DC |
35 | }); |
36 | win.show(); | |
37 | me.hide(); | |
38 | win.on('destroy', function() { | |
39 | me.close(); | |
40 | }); | |
f6710aac | 41 | }, |
6ae2ec81 DC |
42 | }); |
43 | }, | |
44 | ||
8058410f | 45 | initComponent: function() { |
6ae2ec81 DC |
46 | var me = this; |
47 | ||
48 | if (!me.nodename) { | |
49 | throw "no node name specified"; | |
50 | } | |
6ae2ec81 DC |
51 | if (!me.action) { |
52 | throw "no action specified"; | |
53 | } | |
6ae2ec81 DC |
54 | if (!me.btnText) { |
55 | throw "no button text specified"; | |
56 | } | |
6ae2ec81 DC |
57 | if (!me.title) { |
58 | throw "no title specified"; | |
59 | } | |
60 | ||
61 | var items = []; | |
62 | ||
63 | if (me.action === 'migrateall') { | |
21ef191b | 64 | /*value is string and number*/ |
6ae2ec81 DC |
65 | items.push( |
66 | { | |
67 | xtype: 'pveNodeSelector', | |
68 | name: 'target', | |
69 | disallowedNodes: [me.nodename], | |
09f5f402 | 70 | fieldLabel: gettext('Target node'), |
6ae2ec81 | 71 | allowBlank: false, |
f6710aac | 72 | onlineValidator: true, |
6ae2ec81 DC |
73 | }, |
74 | { | |
bf96f60d | 75 | xtype: 'proxmoxintegerfield', |
6ae2ec81 DC |
76 | name: 'maxworkers', |
77 | minValue: 1, | |
78 | maxValue: 100, | |
79 | value: 1, | |
09f5f402 | 80 | fieldLabel: gettext('Parallel jobs'), |
f6710aac | 81 | allowBlank: false, |
200a9b5d | 82 | }, |
3d625330 | 83 | { |
736cffb1 TL |
84 | xtype: 'fieldcontainer', |
85 | fieldLabel: gettext('Allow local disk migration'), | |
86 | layout: 'hbox', | |
87 | items: [{ | |
88 | xtype: 'proxmoxcheckbox', | |
89 | name: 'with-local-disks', | |
90 | checked: true, | |
91 | uncheckedValue: 0, | |
92 | listeners: { | |
93 | change: (cb, val) => me.down('#localdiskwarning').setVisible(val), | |
f6710aac | 94 | }, |
3d625330 | 95 | |
736cffb1 TL |
96 | }, |
97 | { | |
98 | itemId: 'localdiskwarning', | |
99 | xtype: 'displayfield', | |
100 | flex: 1, | |
101 | padding: '0 0 0 10', | |
102 | userCls: 'pmx-hint', | |
103 | value: 'Note: Migration with local disks might take long.', | |
104 | }], | |
3d625330 | 105 | }, |
200a9b5d OB |
106 | { |
107 | itemId: 'lxcwarning', | |
108 | xtype: 'displayfield', | |
f71b7c28 | 109 | userCls: 'pmx-hint', |
200a9b5d | 110 | value: 'Warning: Running CTs will be migrated in Restart Mode.', |
f6710aac TL |
111 | hidden: true, // only visible if running container chosen |
112 | }, | |
6ae2ec81 DC |
113 | ); |
114 | } else if (me.action === 'startall') { | |
115 | items.push({ | |
116 | xtype: 'hiddenfield', | |
117 | name: 'force', | |
f6710aac | 118 | value: 1, |
6ae2ec81 DC |
119 | }); |
120 | } | |
121 | ||
122 | items.push({ | |
123 | xtype: 'vmselector', | |
124 | itemId: 'vms', | |
125 | name: 'vms', | |
126 | flex: 1, | |
127 | height: 300, | |
128 | selectAll: true, | |
129 | allowBlank: false, | |
eb882c6f | 130 | nodename: me.nodename, |
200a9b5d OB |
131 | action: me.action, |
132 | listeners: { | |
133 | selectionchange: function(vmselector, records) { | |
134 | if (me.action == 'migrateall') { | |
21ef191b | 135 | var showWarning = records.some(function(item) { |
53e3ea84 TL |
136 | return item.data.type == 'lxc' && |
137 | item.data.status == 'running'; | |
200a9b5d | 138 | }); |
e2c97a19 | 139 | me.down('#lxcwarning').setVisible(showWarning); |
200a9b5d | 140 | } |
f6710aac TL |
141 | }, |
142 | }, | |
6ae2ec81 DC |
143 | }); |
144 | ||
145 | me.formPanel = Ext.create('Ext.form.Panel', { | |
146 | bodyPadding: 10, | |
147 | border: false, | |
148 | layout: { | |
149 | type: 'vbox', | |
f6710aac | 150 | align: 'stretch', |
6ae2ec81 DC |
151 | }, |
152 | fieldDefaults: { | |
153 | labelWidth: 300, | |
f6710aac | 154 | anchor: '100%', |
6ae2ec81 | 155 | }, |
f6710aac | 156 | items: items, |
6ae2ec81 DC |
157 | }); |
158 | ||
159 | var form = me.formPanel.getForm(); | |
160 | ||
161 | var submitBtn = Ext.create('Ext.Button', { | |
162 | text: me.btnText, | |
163 | handler: function() { | |
164 | form.isValid(); | |
165 | me.submit(form.getValues()); | |
f6710aac | 166 | }, |
6ae2ec81 DC |
167 | }); |
168 | ||
169 | Ext.apply(me, { | |
8058410f TL |
170 | items: [me.formPanel], |
171 | buttons: [submitBtn], | |
6ae2ec81 DC |
172 | }); |
173 | ||
174 | me.callParent(); | |
175 | ||
176 | form.on('validitychange', function() { | |
177 | var valid = form.isValid(); | |
178 | submitBtn.setDisabled(!valid); | |
179 | }); | |
180 | form.isValid(); | |
f6710aac | 181 | }, |
6ae2ec81 | 182 | }); |