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