]>
Commit | Line | Data |
---|---|---|
b0a6d326 EK |
1 | Ext.ns('PVE'); |
2 | ||
63b9faae EK |
3 | // avoid errors related to Accessible Rich Internet Applications |
4 | // (access for people with disabilities) | |
0be88ae1 | 5 | // TODO reenable after all components are upgraded |
63b9faae EK |
6 | Ext.enableAria = false; |
7 | Ext.enableAriaButtons = false; | |
8 | Ext.enableAriaPanels = false; | |
9 | ||
b0a6d326 | 10 | // avoid errors when running without development tools |
0be88ae1 DC |
11 | if (!Ext.isDefined(Ext.global.console)) { |
12 | var console = { | |
0be88ae1 | 13 | log: function() {} |
b0a6d326 EK |
14 | }; |
15 | } | |
0be88ae1 | 16 | console.log("Starting PVE Manager"); |
b0a6d326 EK |
17 | |
18 | Ext.Ajax.defaultHeaders = { | |
19 | 'Accept': 'application/json' | |
20 | }; | |
21 | ||
89ae1bb1 | 22 | /*jslint confusion: true */ |
9fa2e36d | 23 | Ext.define('PVE.Utils', { utilities: { |
b0a6d326 | 24 | |
9fa2e36d | 25 | // this singleton contains miscellaneous utilities |
b0a6d326 | 26 | |
0be88ae1 | 27 | toolkit: undefined, // (extjs|touch), set inside Toolkit.js |
b0a6d326 | 28 | |
98a01af2 EK |
29 | bus_match: /^(ide|sata|virtio|scsi)\d+$/, |
30 | ||
b0a6d326 EK |
31 | log_severity_hash: { |
32 | 0: "panic", | |
33 | 1: "alert", | |
34 | 2: "critical", | |
35 | 3: "error", | |
36 | 4: "warning", | |
37 | 5: "notice", | |
38 | 6: "info", | |
39 | 7: "debug" | |
40 | }, | |
41 | ||
42 | support_level_hash: { | |
43 | 'c': gettext('Community'), | |
44 | 'b': gettext('Basic'), | |
45 | 's': gettext('Standard'), | |
46 | 'p': gettext('Premium') | |
47 | }, | |
48 | ||
49 | noSubKeyHtml: 'You do not have a valid subscription for this server. Please visit <a target="_blank" href="http://www.proxmox.com/products/proxmox-ve/subscription-service-plans">www.proxmox.com</a> to get a list of available options.', | |
50 | ||
51 | kvm_ostypes: { | |
45d6c71a TL |
52 | 'Linux': [ |
53 | { desc: '4.X/3.X/2.6 Kernel', val: 'l26' }, | |
54 | { desc: '2.4 Kernel', val: 'l24' } | |
55 | ], | |
56 | 'Microsoft Windows': [ | |
57 | { desc: '10/2016', val: 'win10' }, | |
58 | { desc: '8.x/2012/2012r2', val: 'win8' }, | |
59 | { desc: '7/2008r2', val: 'win7' }, | |
60 | { desc: 'Vista/2008', val: 'w2k8' }, | |
61 | { desc: 'XP/2003', val: 'wxp' }, | |
62 | { desc: '2000', val: 'w2k' } | |
63 | ], | |
64 | 'Solaris Kernel': [ | |
65 | { desc: '-', val: 'solaris'} | |
66 | ], | |
67 | 'Other': [ | |
68 | { desc: '-', val: 'other'} | |
69 | ] | |
b0a6d326 EK |
70 | }, |
71 | ||
428bc4a2 DC |
72 | get_health_icon: function(state, circle) { |
73 | if (circle === undefined) { | |
74 | circle = false; | |
75 | } | |
76 | ||
77 | if (state === undefined) { | |
78 | state = 'uknown'; | |
79 | } | |
80 | ||
81 | var icon = 'faded fa-question'; | |
82 | switch(state) { | |
83 | case 'good': | |
84 | icon = 'good fa-check'; | |
85 | break; | |
86 | case 'warning': | |
87 | icon = 'warning fa-exclamation'; | |
88 | break; | |
89 | case 'critical': | |
90 | icon = 'critical fa-times'; | |
91 | break; | |
92 | default: break; | |
93 | } | |
94 | ||
95 | if (circle) { | |
96 | icon += '-circle'; | |
97 | } | |
98 | ||
99 | return icon; | |
100 | }, | |
101 | ||
046e640c DC |
102 | map_ceph_health: { |
103 | 'HEALTH_OK':'good', | |
104 | 'HEALTH_WARN':'warning', | |
105 | 'HEALTH_ERR':'critical' | |
106 | }, | |
107 | ||
dfe6d184 | 108 | render_ceph_health: function(healthObj) { |
046e640c DC |
109 | var state = { |
110 | iconCls: PVE.Utils.get_health_icon(), | |
111 | text: '' | |
112 | }; | |
113 | ||
dfe6d184 | 114 | if (!healthObj || !healthObj.status) { |
046e640c DC |
115 | return state; |
116 | } | |
117 | ||
dfe6d184 | 118 | var health = PVE.Utils.map_ceph_health[healthObj.status]; |
046e640c DC |
119 | |
120 | state.iconCls = PVE.Utils.get_health_icon(health, true); | |
dfe6d184 | 121 | state.text = healthObj.status; |
046e640c DC |
122 | |
123 | return state; | |
124 | }, | |
125 | ||
fee716d3 | 126 | render_zfs_health: function(value) { |
8c8604ba TM |
127 | if (typeof value == 'undefined'){ |
128 | return ""; | |
129 | } | |
fee716d3 DC |
130 | var iconCls = 'question-circle'; |
131 | switch (value) { | |
8c8604ba | 132 | case 'AVAIL': |
fee716d3 DC |
133 | case 'ONLINE': |
134 | iconCls = 'check-circle good'; | |
135 | break; | |
136 | case 'REMOVED': | |
137 | case 'DEGRADED': | |
138 | iconCls = 'exclamation-circle warning'; | |
139 | break; | |
140 | case 'UNAVAIL': | |
141 | case 'FAULTED': | |
142 | case 'OFFLINE': | |
143 | iconCls = 'times-circle critical'; | |
144 | break; | |
145 | default: //unknown | |
146 | } | |
147 | ||
148 | return '<i class="fa fa-' + iconCls + '"></i> ' + value; | |
8c8604ba | 149 | |
fee716d3 DC |
150 | }, |
151 | ||
45d6c71a TL |
152 | get_kvm_osinfo: function(value) { |
153 | var info = { base: 'Other' }; // default | |
154 | if (value) { | |
155 | Ext.each(Object.keys(PVE.Utils.kvm_ostypes), function(k) { | |
156 | Ext.each(PVE.Utils.kvm_ostypes[k], function(e) { | |
157 | if (e.val === value) { | |
158 | info = { desc: e.desc, base: k }; | |
159 | } | |
160 | }); | |
161 | }); | |
b0a6d326 | 162 | } |
45d6c71a TL |
163 | return info; |
164 | }, | |
165 | ||
166 | render_kvm_ostype: function (value) { | |
167 | var osinfo = PVE.Utils.get_kvm_osinfo(value); | |
168 | if (osinfo.desc && osinfo.desc !== '-') { | |
169 | return osinfo.base + ' ' + osinfo.desc; | |
170 | } else { | |
171 | return osinfo.base; | |
b0a6d326 | 172 | } |
b0a6d326 EK |
173 | }, |
174 | ||
175 | render_hotplug_features: function (value) { | |
23d3881a | 176 | var fa = []; |
b0a6d326 EK |
177 | |
178 | if (!value || (value === '0')) { | |
ec99b1c3 | 179 | return gettext('Disabled'); |
b0a6d326 EK |
180 | } |
181 | ||
4dcca8a4 DC |
182 | if (value === '1') { |
183 | value = 'disk,network,usb'; | |
184 | } | |
185 | ||
b0a6d326 EK |
186 | Ext.each(value.split(','), function(el) { |
187 | if (el === 'disk') { | |
188 | fa.push(gettext('Disk')); | |
189 | } else if (el === 'network') { | |
190 | fa.push(gettext('Network')); | |
191 | } else if (el === 'usb') { | |
b9628aa5 | 192 | fa.push('USB'); |
b0a6d326 EK |
193 | } else if (el === 'memory') { |
194 | fa.push(gettext('Memory')); | |
195 | } else if (el === 'cpu') { | |
196 | fa.push(gettext('CPU')); | |
197 | } else { | |
198 | fa.push(el); | |
199 | } | |
200 | }); | |
201 | ||
202 | return fa.join(', '); | |
203 | }, | |
204 | ||
1662ccdb SI |
205 | render_qga_features: function(value) { |
206 | if (!value) { | |
207 | return Proxmox.Utils.defaultText + ' (' + Proxmox.Utils.disabledText + ')'; | |
208 | } | |
209 | var props = PVE.Parser.parsePropertyString(value, 'enabled'); | |
210 | if (!PVE.Parser.parseBoolean(props.enabled)) { | |
211 | return Proxmox.Utils.disabledText; | |
212 | } | |
213 | ||
214 | delete props.enabled; | |
215 | var agentstring = Proxmox.Utils.enabledText; | |
216 | ||
217 | Ext.Object.each(props, function(key, value) { | |
218 | var keystring = '' ; | |
219 | agentstring += ', ' + key + ': '; | |
220 | ||
221 | if (PVE.Parser.parseBoolean(value)) { | |
222 | agentstring += Proxmox.Utils.enabledText; | |
223 | } else { | |
224 | agentstring += Proxmox.Utils.disabledText; | |
225 | } | |
226 | }); | |
227 | ||
228 | return agentstring; | |
229 | }, | |
230 | ||
a1ee14a2 DC |
231 | render_qemu_machine: function(value) { |
232 | return value || (Proxmox.Utils.defaultText + ' (i440fx)'); | |
233 | }, | |
234 | ||
17c71f27 DC |
235 | render_qemu_bios: function(value) { |
236 | if (!value) { | |
e7ade592 | 237 | return Proxmox.Utils.defaultText + ' (SeaBIOS)'; |
17c71f27 DC |
238 | } else if (value === 'seabios') { |
239 | return "SeaBIOS"; | |
240 | } else if (value === 'ovmf') { | |
241 | return "OVMF (UEFI)"; | |
242 | } else { | |
243 | return value; | |
244 | } | |
245 | }, | |
246 | ||
b0a6d326 EK |
247 | render_scsihw: function(value) { |
248 | if (!value) { | |
e7ade592 | 249 | return Proxmox.Utils.defaultText + ' (LSI 53C895A)'; |
b0a6d326 EK |
250 | } else if (value === 'lsi') { |
251 | return 'LSI 53C895A'; | |
252 | } else if (value === 'lsi53c810') { | |
253 | return 'LSI 53C810'; | |
254 | } else if (value === 'megasas') { | |
255 | return 'MegaRAID SAS 8708EM2'; | |
256 | } else if (value === 'virtio-scsi-pci') { | |
49f5d1ab EK |
257 | return 'VirtIO SCSI'; |
258 | } else if (value === 'virtio-scsi-single') { | |
259 | return 'VirtIO SCSI single'; | |
b0a6d326 EK |
260 | } else if (value === 'pvscsi') { |
261 | return 'VMware PVSCSI'; | |
262 | } else { | |
263 | return value; | |
264 | } | |
265 | }, | |
266 | ||
267 | // fixme: auto-generate this | |
268 | // for now, please keep in sync with PVE::Tools::kvmkeymaps | |
269 | kvm_keymaps: { | |
270 | //ar: 'Arabic', | |
271 | da: 'Danish', | |
0be88ae1 DC |
272 | de: 'German', |
273 | 'de-ch': 'German (Swiss)', | |
274 | 'en-gb': 'English (UK)', | |
0a5b8747 | 275 | 'en-us': 'English (USA)', |
b0a6d326 EK |
276 | es: 'Spanish', |
277 | //et: 'Estonia', | |
278 | fi: 'Finnish', | |
0be88ae1 DC |
279 | //fo: 'Faroe Islands', |
280 | fr: 'French', | |
281 | 'fr-be': 'French (Belgium)', | |
b0a6d326 EK |
282 | 'fr-ca': 'French (Canada)', |
283 | 'fr-ch': 'French (Swiss)', | |
284 | //hr: 'Croatia', | |
285 | hu: 'Hungarian', | |
286 | is: 'Icelandic', | |
0be88ae1 | 287 | it: 'Italian', |
b0a6d326 EK |
288 | ja: 'Japanese', |
289 | lt: 'Lithuanian', | |
290 | //lv: 'Latvian', | |
0be88ae1 | 291 | mk: 'Macedonian', |
b0a6d326 EK |
292 | nl: 'Dutch', |
293 | //'nl-be': 'Dutch (Belgium)', | |
0be88ae1 | 294 | no: 'Norwegian', |
b0a6d326 EK |
295 | pl: 'Polish', |
296 | pt: 'Portuguese', | |
297 | 'pt-br': 'Portuguese (Brazil)', | |
298 | //ru: 'Russian', | |
299 | sl: 'Slovenian', | |
300 | sv: 'Swedish', | |
301 | //th: 'Thai', | |
302 | tr: 'Turkish' | |
303 | }, | |
304 | ||
305 | kvm_vga_drivers: { | |
306 | std: gettext('Standard VGA'), | |
5ca366f2 | 307 | vmware: gettext('VMware compatible'), |
b0a6d326 EK |
308 | qxl: 'SPICE', |
309 | qxl2: 'SPICE dual monitor', | |
310 | qxl3: 'SPICE three monitors', | |
311 | qxl4: 'SPICE four monitors', | |
312 | serial0: gettext('Serial terminal') + ' 0', | |
313 | serial1: gettext('Serial terminal') + ' 1', | |
314 | serial2: gettext('Serial terminal') + ' 2', | |
89ae1bb1 DC |
315 | serial3: gettext('Serial terminal') + ' 3', |
316 | virtio: 'VirtIO-GPU', | |
317 | none: Proxmox.Utils.noneText | |
b0a6d326 EK |
318 | }, |
319 | ||
320 | render_kvm_language: function (value) { | |
e7ade592 DC |
321 | if (!value || value === '__default__') { |
322 | return Proxmox.Utils.defaultText; | |
b0a6d326 EK |
323 | } |
324 | var text = PVE.Utils.kvm_keymaps[value]; | |
325 | if (text) { | |
326 | return text + ' (' + value + ')'; | |
327 | } | |
328 | return value; | |
329 | }, | |
330 | ||
331 | kvm_keymap_array: function() { | |
f2782813 | 332 | var data = [['__default__', PVE.Utils.render_kvm_language('')]]; |
b0a6d326 EK |
333 | Ext.Object.each(PVE.Utils.kvm_keymaps, function(key, value) { |
334 | data.push([key, PVE.Utils.render_kvm_language(value)]); | |
335 | }); | |
336 | ||
337 | return data; | |
338 | }, | |
339 | ||
3438c27e DC |
340 | console_map: { |
341 | '__default__': Proxmox.Utils.defaultText + ' (HTML5)', | |
342 | 'vv': 'SPICE (remote-viewer)', | |
343 | 'html5': 'HTML5 (noVNC)', | |
4ace5c6f | 344 | 'xtermjs': 'xterm.js' |
3438c27e DC |
345 | }, |
346 | ||
b0a6d326 | 347 | render_console_viewer: function(value) { |
3438c27e DC |
348 | value = value || '__default__'; |
349 | if (PVE.Utils.console_map[value]) { | |
350 | return PVE.Utils.console_map[value]; | |
b0a6d326 | 351 | } |
3438c27e | 352 | return value; |
b0a6d326 EK |
353 | }, |
354 | ||
755b9083 | 355 | console_viewer_array: function() { |
3438c27e | 356 | return Ext.Array.map(Object.keys(PVE.Utils.console_map), function(v) { |
755b9083 TL |
357 | return [v, PVE.Utils.render_console_viewer(v)]; |
358 | }); | |
359 | }, | |
360 | ||
b0a6d326 EK |
361 | render_kvm_vga_driver: function (value) { |
362 | if (!value) { | |
e7ade592 | 363 | return Proxmox.Utils.defaultText; |
b0a6d326 | 364 | } |
4f3e66d8 DC |
365 | var vga = PVE.Parser.parsePropertyString(value, 'type'); |
366 | var text = PVE.Utils.kvm_vga_drivers[vga.type]; | |
367 | if (!vga.type) { | |
368 | text = Proxmox.Utils.defaultText; | |
369 | } | |
0be88ae1 | 370 | if (text) { |
b0a6d326 EK |
371 | return text + ' (' + value + ')'; |
372 | } | |
373 | return value; | |
374 | }, | |
375 | ||
376 | kvm_vga_driver_array: function() { | |
f2782813 | 377 | var data = [['__default__', PVE.Utils.render_kvm_vga_driver('')]]; |
b0a6d326 EK |
378 | Ext.Object.each(PVE.Utils.kvm_vga_drivers, function(key, value) { |
379 | data.push([key, PVE.Utils.render_kvm_vga_driver(value)]); | |
380 | }); | |
381 | ||
382 | return data; | |
383 | }, | |
384 | ||
385 | render_kvm_startup: function(value) { | |
386 | var startup = PVE.Parser.parseStartup(value); | |
387 | ||
388 | var res = 'order='; | |
389 | if (startup.order === undefined) { | |
390 | res += 'any'; | |
391 | } else { | |
392 | res += startup.order; | |
393 | } | |
394 | if (startup.up !== undefined) { | |
395 | res += ',up=' + startup.up; | |
396 | } | |
397 | if (startup.down !== undefined) { | |
398 | res += ',down=' + startup.down; | |
399 | } | |
400 | ||
401 | return res; | |
402 | }, | |
403 | ||
b0a6d326 EK |
404 | extractFormActionError: function(action) { |
405 | var msg; | |
406 | switch (action.failureType) { | |
407 | case Ext.form.action.Action.CLIENT_INVALID: | |
408 | msg = gettext('Form fields may not be submitted with invalid values'); | |
409 | break; | |
410 | case Ext.form.action.Action.CONNECT_FAILURE: | |
411 | msg = gettext('Connection error'); | |
412 | var resp = action.response; | |
413 | if (resp.status && resp.statusText) { | |
414 | msg += " " + resp.status + ": " + resp.statusText; | |
415 | } | |
416 | break; | |
417 | case Ext.form.action.Action.LOAD_FAILURE: | |
418 | case Ext.form.action.Action.SERVER_INVALID: | |
e7ade592 | 419 | msg = Proxmox.Utils.extractRequestError(action.result, true); |
b0a6d326 EK |
420 | break; |
421 | } | |
422 | return msg; | |
423 | }, | |
424 | ||
b0a6d326 | 425 | format_duration_short: function(ut) { |
0be88ae1 | 426 | |
b0a6d326 | 427 | if (ut < 60) { |
530ee6b7 | 428 | return ut.toFixed(1) + 's'; |
b0a6d326 EK |
429 | } |
430 | ||
431 | if (ut < 3600) { | |
432 | var mins = ut / 60; | |
530ee6b7 | 433 | return mins.toFixed(1) + 'm'; |
b0a6d326 EK |
434 | } |
435 | ||
436 | if (ut < 86400) { | |
437 | var hours = ut / 3600; | |
530ee6b7 | 438 | return hours.toFixed(1) + 'h'; |
b0a6d326 EK |
439 | } |
440 | ||
441 | var days = ut / 86400; | |
530ee6b7 | 442 | return days.toFixed(1) + 'd'; |
b0a6d326 EK |
443 | }, |
444 | ||
0e244a29 DC |
445 | contentTypes: { |
446 | 'images': gettext('Disk image'), | |
447 | 'backup': gettext('VZDump backup file'), | |
448 | 'vztmpl': gettext('Container template'), | |
449 | 'iso': gettext('ISO image'), | |
aef28e04 DC |
450 | 'rootdir': gettext('Container'), |
451 | 'snippets': gettext('Snippets') | |
0e244a29 | 452 | }, |
b0a6d326 | 453 | |
062a7f49 TL |
454 | storageSchema: { |
455 | dir: { | |
456 | name: Proxmox.Utils.directoryText, | |
457 | ipanel: 'DirInputPanel', | |
458 | faIcon: 'folder' | |
459 | }, | |
460 | lvm: { | |
461 | name: 'LVM', | |
462 | ipanel: 'LVMInputPanel', | |
463 | faIcon: 'folder' | |
464 | }, | |
465 | lvmthin: { | |
466 | name: 'LVM-Thin', | |
467 | ipanel: 'LvmThinInputPanel', | |
468 | faIcon: 'folder' | |
469 | }, | |
470 | nfs: { | |
471 | name: 'NFS', | |
472 | ipanel: 'NFSInputPanel', | |
473 | faIcon: 'building' | |
474 | }, | |
475 | cifs: { | |
476 | name: 'CIFS', | |
477 | ipanel: 'CIFSInputPanel', | |
478 | faIcon: 'building' | |
479 | }, | |
480 | glusterfs: { | |
481 | name: 'GlusterFS', | |
482 | ipanel: 'GlusterFsInputPanel', | |
483 | faIcon: 'building' | |
484 | }, | |
485 | iscsi: { | |
486 | name: 'iSCSI', | |
487 | ipanel: 'IScsiInputPanel', | |
488 | faIcon: 'building' | |
489 | }, | |
490 | sheepdog: { | |
491 | name: 'Sheepdog', | |
492 | ipanel: 'SheepdogInputPanel', | |
493 | hideAdd: true, | |
494 | faIcon: 'building' | |
495 | }, | |
4a4b2b6e TL |
496 | cephfs: { |
497 | name: 'CephFS', | |
498 | ipanel: 'CephFSInputPanel', | |
499 | faIcon: 'building' | |
500 | }, | |
501 | pvecephfs: { | |
502 | name: 'CephFS (PVE)', | |
503 | ipanel: 'CephFSInputPanel', | |
504 | hideAdd: true, | |
505 | faIcon: 'building' | |
506 | }, | |
062a7f49 TL |
507 | rbd: { |
508 | name: 'RBD', | |
509 | ipanel: 'RBDInputPanel', | |
062a7f49 TL |
510 | faIcon: 'building' |
511 | }, | |
512 | pveceph: { | |
513 | name: 'RBD (PVE)', | |
0d1ac958 TL |
514 | ipanel: 'RBDInputPanel', |
515 | hideAdd: true, | |
062a7f49 TL |
516 | faIcon: 'building' |
517 | }, | |
518 | zfs: { | |
519 | name: 'ZFS over iSCSI', | |
520 | ipanel: 'ZFSInputPanel', | |
521 | faIcon: 'building' | |
522 | }, | |
523 | zfspool: { | |
524 | name: 'ZFS', | |
525 | ipanel: 'ZFSPoolInputPanel', | |
526 | faIcon: 'folder' | |
527 | }, | |
528 | drbd: { | |
529 | name: 'DRBD', | |
530 | hideAdd: true | |
531 | } | |
532 | }, | |
533 | ||
3c23c025 | 534 | format_storage_type: function(value, md, record) { |
4a4b2b6e TL |
535 | if (value === 'rbd') { |
536 | value = (!record || record.get('monhost') ? 'rbd' : 'pveceph'); | |
537 | } else if (value === 'cephfs') { | |
538 | value = (!record || record.get('monhost') ? 'cephfs' : 'pvecephfs'); | |
3c23c025 | 539 | } |
062a7f49 TL |
540 | |
541 | var schema = PVE.Utils.storageSchema[value]; | |
542 | if (schema) { | |
543 | return schema.name; | |
b0a6d326 | 544 | } |
062a7f49 | 545 | return Proxmox.Utils.unknownText; |
a3b8efb4 EK |
546 | }, |
547 | ||
ced1677b | 548 | format_ha: function(value) { |
e7ade592 | 549 | var text = Proxmox.Utils.noneText; |
ced1677b TL |
550 | |
551 | if (value.managed) { | |
e7ade592 | 552 | text = value.state || Proxmox.Utils.noneText; |
ced1677b | 553 | |
e7ade592 DC |
554 | text += ', ' + Proxmox.Utils.groupText + ': '; |
555 | text += value.group || Proxmox.Utils.noneText; | |
ced1677b TL |
556 | } |
557 | ||
558 | return text; | |
559 | }, | |
560 | ||
b0a6d326 | 561 | format_content_types: function(value) { |
0e244a29 DC |
562 | return value.split(',').sort().map(function(ct) { |
563 | return PVE.Utils.contentTypes[ct] || ct; | |
564 | }).join(', '); | |
b0a6d326 EK |
565 | }, |
566 | ||
567 | render_storage_content: function(value, metaData, record) { | |
568 | var data = record.data; | |
569 | if (Ext.isNumber(data.channel) && | |
570 | Ext.isNumber(data.id) && | |
571 | Ext.isNumber(data.lun)) { | |
0be88ae1 DC |
572 | return "CH " + |
573 | Ext.String.leftPad(data.channel,2, '0') + | |
b0a6d326 EK |
574 | " ID " + data.id + " LUN " + data.lun; |
575 | } | |
576 | return data.volid.replace(/^.*:(.*\/)?/,''); | |
577 | }, | |
578 | ||
579 | render_serverity: function (value) { | |
580 | return PVE.Utils.log_severity_hash[value] || value; | |
581 | }, | |
582 | ||
583 | render_cpu: function(value, metaData, record, rowIndex, colIndex, store) { | |
584 | ||
585 | if (!(record.data.uptime && Ext.isNumeric(value))) { | |
586 | return ''; | |
587 | } | |
588 | ||
589 | var maxcpu = record.data.maxcpu || 1; | |
590 | ||
591 | if (!Ext.isNumeric(maxcpu) && (maxcpu >= 1)) { | |
592 | return ''; | |
593 | } | |
0be88ae1 | 594 | |
b0a6d326 EK |
595 | var per = value * 100; |
596 | ||
597 | return per.toFixed(1) + '% of ' + maxcpu.toString() + (maxcpu > 1 ? 'CPUs' : 'CPU'); | |
598 | }, | |
599 | ||
600 | render_size: function(value, metaData, record, rowIndex, colIndex, store) { | |
601 | /*jslint confusion: true */ | |
602 | ||
603 | if (!Ext.isNumeric(value)) { | |
604 | return ''; | |
605 | } | |
606 | ||
e7ade592 | 607 | return Proxmox.Utils.format_size(value); |
b0a6d326 EK |
608 | }, |
609 | ||
946730cd DC |
610 | render_bandwidth: function(value) { |
611 | if (!Ext.isNumeric(value)) { | |
612 | return ''; | |
613 | } | |
614 | ||
e7ade592 | 615 | return Proxmox.Utils.format_size(value) + '/s'; |
b0a6d326 EK |
616 | }, |
617 | ||
3f633655 EK |
618 | render_timestamp_human_readable: function(value) { |
619 | return Ext.Date.format(new Date(value * 1000), 'l d F Y H:i:s'); | |
620 | }, | |
621 | ||
ddd26302 DC |
622 | render_duration: function(value) { |
623 | if (value === undefined) { | |
624 | return '-'; | |
625 | } | |
626 | return PVE.Utils.format_duration_short(value); | |
627 | }, | |
628 | ||
0bfc799f DC |
629 | calculate_mem_usage: function(data) { |
630 | if (!Ext.isNumeric(data.mem) || | |
631 | data.maxmem === 0 || | |
632 | data.uptime < 1) { | |
633 | return -1; | |
634 | } | |
635 | ||
636 | return (data.mem / data.maxmem); | |
637 | }, | |
638 | ||
639 | render_mem_usage_percent: function(value, metaData, record, rowIndex, colIndex, store) { | |
640 | if (!Ext.isNumeric(value) || value === -1) { | |
641 | return ''; | |
642 | } | |
643 | if (value > 1 ) { | |
644 | // we got no percentage but bytes | |
645 | var mem = value; | |
646 | var maxmem = record.data.maxmem; | |
647 | if (!record.data.uptime || | |
648 | maxmem === 0 || | |
649 | !Ext.isNumeric(mem)) { | |
650 | return ''; | |
651 | } | |
652 | ||
653 | return ((mem*100)/maxmem).toFixed(1) + " %"; | |
654 | } | |
655 | return (value*100).toFixed(1) + " %"; | |
656 | }, | |
657 | ||
b0a6d326 EK |
658 | render_mem_usage: function(value, metaData, record, rowIndex, colIndex, store) { |
659 | ||
660 | var mem = value; | |
661 | var maxmem = record.data.maxmem; | |
0be88ae1 | 662 | |
b0a6d326 EK |
663 | if (!record.data.uptime) { |
664 | return ''; | |
665 | } | |
666 | ||
667 | if (!(Ext.isNumeric(mem) && maxmem)) { | |
668 | return ''; | |
669 | } | |
670 | ||
728f1b97 | 671 | return PVE.Utils.render_size(value); |
b0a6d326 EK |
672 | }, |
673 | ||
0bfc799f DC |
674 | calculate_disk_usage: function(data) { |
675 | ||
676 | if (!Ext.isNumeric(data.disk) || | |
677 | data.type === 'qemu' || | |
678 | (data.type === 'lxc' && data.uptime === 0) || | |
679 | data.maxdisk === 0) { | |
680 | return -1; | |
681 | } | |
682 | ||
683 | return (data.disk / data.maxdisk); | |
684 | }, | |
685 | ||
686 | render_disk_usage_percent: function(value, metaData, record, rowIndex, colIndex, store) { | |
687 | if (!Ext.isNumeric(value) || value === -1) { | |
688 | return ''; | |
689 | } | |
690 | ||
691 | return (value * 100).toFixed(1) + " %"; | |
692 | }, | |
693 | ||
b0a6d326 EK |
694 | render_disk_usage: function(value, metaData, record, rowIndex, colIndex, store) { |
695 | ||
696 | var disk = value; | |
697 | var maxdisk = record.data.maxdisk; | |
728f1b97 | 698 | var type = record.data.type; |
b0a6d326 | 699 | |
728f1b97 DC |
700 | if (!Ext.isNumeric(disk) || |
701 | type === 'qemu' || | |
702 | maxdisk === 0 || | |
703 | (type === 'lxc' && record.data.uptime === 0)) { | |
b0a6d326 EK |
704 | return ''; |
705 | } | |
706 | ||
728f1b97 | 707 | return PVE.Utils.render_size(value); |
b0a6d326 EK |
708 | }, |
709 | ||
4dbc64a7 DC |
710 | get_object_icon_class: function(type, record) { |
711 | var status = ''; | |
712 | var objType = type; | |
713 | ||
714 | if (type === 'type') { | |
715 | // for folder view | |
716 | objType = record.groupbyid; | |
717 | } else if (record.template) { | |
718 | // templates | |
719 | objType = 'template'; | |
720 | status = type; | |
721 | } else { | |
722 | // everything else | |
723 | status = record.status + ' ha-' + record.hastate; | |
b1d8e73d DC |
724 | } |
725 | ||
4dbc64a7 DC |
726 | var defaults = PVE.tree.ResourceTree.typeDefaults[objType]; |
727 | if (defaults && defaults.iconCls) { | |
728 | var retVal = defaults.iconCls + ' ' + status; | |
729 | return retVal; | |
b0a6d326 EK |
730 | } |
731 | ||
4dbc64a7 DC |
732 | return ''; |
733 | }, | |
734 | ||
735 | render_resource_type: function(value, metaData, record, rowIndex, colIndex, store) { | |
736 | ||
737 | var cls = PVE.Utils.get_object_icon_class(value,record.data); | |
2b2fe160 | 738 | |
4dbc64a7 | 739 | var fa = '<i class="fa-fw x-grid-icon-custom ' + cls + '"></i> '; |
b1d8e73d | 740 | return fa + value; |
b0a6d326 EK |
741 | }, |
742 | ||
b0a6d326 EK |
743 | render_support_level: function(value, metaData, record) { |
744 | return PVE.Utils.support_level_hash[value] || '-'; | |
745 | }, | |
746 | ||
0be88ae1 | 747 | render_upid: function(value, metaData, record) { |
b0a6d326 EK |
748 | var type = record.data.type; |
749 | var id = record.data.id; | |
750 | ||
e7ade592 | 751 | return Proxmox.Utils.format_task_description(type, id); |
b0a6d326 EK |
752 | }, |
753 | ||
054ac1b8 DC |
754 | /* render functions for new status panel */ |
755 | ||
756 | render_usage: function(val) { | |
757 | return (val*100).toFixed(2) + '%'; | |
758 | }, | |
759 | ||
760 | render_cpu_usage: function(val, max) { | |
761 | return Ext.String.format(gettext('{0}% of {1}') + | |
762 | ' ' + gettext('CPU(s)'), (val*100).toFixed(2), max); | |
763 | }, | |
764 | ||
765 | render_size_usage: function(val, max) { | |
bab64974 DC |
766 | if (max === 0) { |
767 | return gettext('N/A'); | |
768 | } | |
054ac1b8 DC |
769 | return (val*100/max).toFixed(2) + '% '+ '(' + |
770 | Ext.String.format(gettext('{0} of {1}'), | |
771 | PVE.Utils.render_size(val), PVE.Utils.render_size(max)) + ')'; | |
772 | }, | |
773 | ||
774 | /* this is different for nodes */ | |
775 | render_node_cpu_usage: function(value, record) { | |
776 | return PVE.Utils.render_cpu_usage(value, record.cpus); | |
777 | }, | |
778 | ||
779 | /* this is different for nodes */ | |
780 | render_node_size_usage: function(record) { | |
781 | return PVE.Utils.render_size_usage(record.used, record.total); | |
782 | }, | |
783 | ||
27809975 DC |
784 | render_optional_url: function(value) { |
785 | var match; | |
786 | if (value && (match = value.match(/^https?:\/\//)) !== null) { | |
cdd9b6c0 | 787 | return '<a target="_blank" href="' + value + '">' + value + '</a>'; |
27809975 DC |
788 | } |
789 | return value; | |
790 | }, | |
791 | ||
792 | render_san: function(value) { | |
793 | var names = []; | |
794 | if (Ext.isArray(value)) { | |
795 | value.forEach(function(val) { | |
796 | if (!Ext.isNumber(val)) { | |
797 | names.push(val); | |
798 | } | |
799 | }); | |
800 | return names.join('<br>'); | |
801 | } | |
802 | return value; | |
803 | }, | |
804 | ||
6ad4be69 DC |
805 | render_full_name: function(firstname, metaData, record) { |
806 | var first = firstname || ''; | |
807 | var last = record.data.lastname || ''; | |
808 | return Ext.htmlEncode(first + " " + last); | |
809 | }, | |
810 | ||
aa0819a8 | 811 | windowHostname: function() { |
e7ade592 | 812 | return window.location.hostname.replace(Proxmox.Utils.IP6_bracket_match, |
aa0819a8 WB |
813 | function(m, addr, offset, original) { return addr; }); |
814 | }, | |
0be88ae1 | 815 | |
8eccc68f | 816 | openDefaultConsoleWindow: function(consoles, vmtype, vmid, nodename, vmname, cmd) { |
3438c27e | 817 | var dv = PVE.Utils.defaultViewer(consoles); |
8eccc68f | 818 | PVE.Utils.openConsoleWindow(dv, vmtype, vmid, nodename, vmname, cmd); |
b0a6d326 EK |
819 | }, |
820 | ||
8eccc68f | 821 | openConsoleWindow: function(viewer, vmtype, vmid, nodename, vmname, cmd) { |
9e361643 | 822 | // kvm, lxc, shell, upgrade |
b0a6d326 | 823 | |
9e361643 | 824 | if (vmid == undefined && (vmtype === 'kvm' || vmtype === 'lxc')) { |
b0a6d326 EK |
825 | throw "missing vmid"; |
826 | } | |
827 | ||
828 | if (!nodename) { | |
829 | throw "no nodename specified"; | |
830 | } | |
831 | ||
c7218ab3 | 832 | if (viewer === 'html5') { |
8eccc68f | 833 | PVE.Utils.openVNCViewer(vmtype, vmid, nodename, vmname, cmd); |
c6b2336c | 834 | } else if (viewer === 'xtermjs') { |
8eccc68f | 835 | Proxmox.Utils.openXtermJsViewer(vmtype, vmid, nodename, vmname, cmd); |
b0a6d326 EK |
836 | } else if (viewer === 'vv') { |
837 | var url; | |
aa0819a8 | 838 | var params = { proxy: PVE.Utils.windowHostname() }; |
b0a6d326 EK |
839 | if (vmtype === 'kvm') { |
840 | url = '/nodes/' + nodename + '/qemu/' + vmid.toString() + '/spiceproxy'; | |
841 | PVE.Utils.openSpiceViewer(url, params); | |
9e361643 DM |
842 | } else if (vmtype === 'lxc') { |
843 | url = '/nodes/' + nodename + '/lxc/' + vmid.toString() + '/spiceproxy'; | |
b0a6d326 EK |
844 | PVE.Utils.openSpiceViewer(url, params); |
845 | } else if (vmtype === 'shell') { | |
846 | url = '/nodes/' + nodename + '/spiceshell'; | |
847 | PVE.Utils.openSpiceViewer(url, params); | |
848 | } else if (vmtype === 'upgrade') { | |
849 | url = '/nodes/' + nodename + '/spiceshell'; | |
850 | params.upgrade = 1; | |
851 | PVE.Utils.openSpiceViewer(url, params); | |
8eccc68f TM |
852 | } else if (vmtype === 'cmd') { |
853 | url = '/nodes/' + nodename + '/spiceshell'; | |
854 | params.cmd = cmd; | |
855 | PVE.Utils.openSpiceViewer(url, params); | |
b0a6d326 EK |
856 | } |
857 | } else { | |
858 | throw "unknown viewer type"; | |
859 | } | |
860 | }, | |
861 | ||
3438c27e DC |
862 | defaultViewer: function(consoles) { |
863 | ||
864 | var allowSpice, allowXtermjs; | |
865 | ||
866 | if (consoles === true) { | |
867 | allowSpice = true; | |
868 | allowXtermjs = true; | |
869 | } else if (typeof consoles === 'object') { | |
870 | allowSpice = consoles.spice; | |
4ace5c6f | 871 | allowXtermjs = !!consoles.xtermjs; |
3438c27e | 872 | } |
b0a6d326 EK |
873 | var vncdefault = 'html5'; |
874 | var dv = PVE.VersionInfo.console || vncdefault; | |
3438c27e | 875 | if ((dv === 'vv' && !allowSpice) || (dv === 'xtermjs' && !allowXtermjs)) { |
b0a6d326 EK |
876 | dv = vncdefault; |
877 | } | |
878 | ||
879 | return dv; | |
880 | }, | |
881 | ||
8eccc68f TM |
882 | openVNCViewer: function(vmtype, vmid, nodename, vmname, cmd) { |
883 | var url = Ext.Object.toQueryString({ | |
9e361643 | 884 | console: vmtype, // kvm, lxc, upgrade or shell |
c7218ab3 | 885 | novnc: 1, |
b0a6d326 EK |
886 | vmid: vmid, |
887 | vmname: vmname, | |
16e64c97 | 888 | node: nodename, |
8eccc68f TM |
889 | resize: 'off', |
890 | cmd: cmd | |
b0a6d326 EK |
891 | }); |
892 | var nw = window.open("?" + url, '_blank', "innerWidth=745,innerheight=427"); | |
7af1ab47 DC |
893 | if (nw) { |
894 | nw.focus(); | |
895 | } | |
b0a6d326 EK |
896 | }, |
897 | ||
898 | openSpiceViewer: function(url, params){ | |
899 | ||
900 | var downloadWithName = function(uri, name) { | |
901 | var link = Ext.DomHelper.append(document.body, { | |
902 | tag: 'a', | |
903 | href: uri, | |
904 | css : 'display:none;visibility:hidden;height:0px;' | |
905 | }); | |
906 | ||
907 | // Note: we need to tell android the correct file name extension | |
908 | // but we do not set 'download' tag for other environments, because | |
909 | // It can have strange side effects (additional user prompt on firefox) | |
910 | var andriod = navigator.userAgent.match(/Android/i) ? true : false; | |
911 | if (andriod) { | |
912 | link.download = name; | |
913 | } | |
914 | ||
915 | if (link.fireEvent) { | |
916 | link.fireEvent('onclick'); | |
917 | } else { | |
918 | var evt = document.createEvent("MouseEvents"); | |
919 | evt.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null); | |
920 | link.dispatchEvent(evt); | |
921 | } | |
922 | }; | |
923 | ||
e7ade592 | 924 | Proxmox.Utils.API2Request({ |
b0a6d326 EK |
925 | url: url, |
926 | params: params, | |
927 | method: 'POST', | |
928 | failure: function(response, opts){ | |
929 | Ext.Msg.alert('Error', response.htmlStatus); | |
930 | }, | |
931 | success: function(response, opts){ | |
932 | var raw = "[virt-viewer]\n"; | |
933 | Ext.Object.each(response.result.data, function(k, v) { | |
934 | raw += k + "=" + v + "\n"; | |
935 | }); | |
936 | var url = 'data:application/x-virt-viewer;charset=UTF-8,' + | |
937 | encodeURIComponent(raw); | |
0be88ae1 | 938 | |
b0a6d326 EK |
939 | downloadWithName(url, "pve-spice.vv"); |
940 | } | |
941 | }); | |
942 | }, | |
943 | ||
e3129443 DC |
944 | openTreeConsole: function(tree, record, item, index, e) { |
945 | e.stopEvent(); | |
946 | var nodename = record.data.node; | |
947 | var vmid = record.data.vmid; | |
948 | var vmname = record.data.name; | |
949 | if (record.data.type === 'qemu' && !record.data.template) { | |
e7ade592 | 950 | Proxmox.Utils.API2Request({ |
e3129443 DC |
951 | url: '/nodes/' + nodename + '/qemu/' + vmid + '/status/current', |
952 | failure: function(response, opts) { | |
953 | Ext.Msg.alert('Error', response.htmlStatus); | |
954 | }, | |
955 | success: function(response, opts) { | |
ab9f0fe1 | 956 | var allowSpice = !!response.result.data.spice; |
e3129443 DC |
957 | PVE.Utils.openDefaultConsoleWindow(allowSpice, 'kvm', vmid, nodename, vmname); |
958 | } | |
959 | }); | |
960 | } else if (record.data.type === 'lxc' && !record.data.template) { | |
961 | PVE.Utils.openDefaultConsoleWindow(true, 'lxc', vmid, nodename, vmname); | |
962 | } | |
963 | }, | |
964 | ||
fbd60cfd DM |
965 | // test automation helper |
966 | call_menu_handler: function(menu, text) { | |
967 | ||
968 | var list = menu.query('menuitem'); | |
969 | ||
970 | Ext.Array.each(list, function(item) { | |
971 | if (item.text === text) { | |
972 | if (item.handler) { | |
973 | item.handler(); | |
974 | return 1; | |
975 | } else { | |
976 | return undefined; | |
977 | } | |
978 | } | |
979 | }); | |
980 | }, | |
981 | ||
685b7aa4 DC |
982 | createCmdMenu: function(v, record, item, index, event) { |
983 | event.stopEvent(); | |
cc1a91be DC |
984 | if (!(v instanceof Ext.tree.View)) { |
985 | v.select(record); | |
986 | } | |
685b7aa4 | 987 | var menu; |
9bad05bd DC |
988 | var template = !!record.data.template; |
989 | var type = record.data.type; | |
685b7aa4 | 990 | |
9bad05bd DC |
991 | if (template) { |
992 | if (type === 'qemu' || type == 'lxc') { | |
993 | menu = Ext.create('PVE.menu.TemplateMenu', { | |
994 | pveSelNode: record | |
995 | }); | |
996 | } | |
997 | } else if (type === 'qemu' || | |
998 | type === 'lxc' || | |
999 | type === 'node') { | |
1000 | menu = Ext.create('PVE.' + type + '.CmdMenu', { | |
1001 | pveSelNode: record, | |
c11ab8cb DC |
1002 | nodename: record.data.node |
1003 | }); | |
685b7aa4 DC |
1004 | } else { |
1005 | return; | |
1006 | } | |
1007 | ||
1008 | menu.showAt(event.getXY()); | |
9f0b4e04 | 1009 | return menu; |
e7ade592 | 1010 | }, |
9fa2e36d | 1011 | |
fe4f00ad TL |
1012 | // helper for deleting field which are set to there default values |
1013 | delete_if_default: function(values, fieldname, default_val, create) { | |
1014 | if (values[fieldname] === '' || values[fieldname] === default_val) { | |
1015 | if (!create) { | |
1016 | if (values['delete']) { | |
1017 | values['delete'] += ',' + fieldname; | |
1018 | } else { | |
1019 | values['delete'] = fieldname; | |
1020 | } | |
1021 | } | |
1022 | ||
1023 | delete values[fieldname]; | |
1024 | } | |
857b97a7 TL |
1025 | }, |
1026 | ||
1027 | loadSSHKeyFromFile: function(file, callback) { | |
1028 | // ssh-keygen produces 740 bytes for an average 4096 bit rsa key, with | |
1029 | // a user@host comment, 1420 for 8192 bits; current max is 16kbit | |
1030 | // assume: 740*8 for max. 32kbit (5920 byte file) | |
1031 | // round upwards to nearest nice number => 8192 bytes, leaves lots of comment space | |
1032 | if (file.size > 8192) { | |
1033 | Ext.Msg.alert(gettext('Error'), gettext("Invalid file size: ") + file.size); | |
1034 | return; | |
1035 | } | |
1036 | /*global | |
1037 | FileReader | |
1038 | */ | |
1039 | var reader = new FileReader(); | |
1040 | reader.onload = function(evt) { | |
1041 | callback(evt.target.result); | |
1042 | }; | |
1043 | reader.readAsText(file); | |
abe824aa DC |
1044 | }, |
1045 | ||
1046 | bus_counts: { ide: 4, sata: 6, scsi: 16, virtio: 16 }, | |
1047 | ||
1048 | // types is either undefined (all busses), an array of busses, or a single bus | |
1049 | forEachBus: function(types, func) { | |
1050 | var busses = Object.keys(PVE.Utils.bus_counts); | |
1051 | var i, j, count, cont; | |
1052 | ||
1053 | if (Ext.isArray(types)) { | |
1054 | busses = types; | |
1055 | } else if (Ext.isDefined(types)) { | |
1056 | busses = [ types ]; | |
1057 | } | |
1058 | ||
1059 | // check if we only have valid busses | |
1060 | for (i = 0; i < busses.length; i++) { | |
1061 | if (!PVE.Utils.bus_counts[busses[i]]) { | |
1062 | throw "invalid bus: '" + busses[i] + "'"; | |
1063 | } | |
1064 | } | |
1065 | ||
1066 | for (i = 0; i < busses.length; i++) { | |
1067 | count = PVE.Utils.bus_counts[busses[i]]; | |
1068 | for (j = 0; j < count; j++) { | |
1069 | cont = func(busses[i], j); | |
1070 | if (!cont && cont !== undefined) { | |
1071 | return; | |
1072 | } | |
1073 | } | |
1074 | } | |
14a845bc DC |
1075 | }, |
1076 | ||
483bd394 | 1077 | mp_counts: { mps: 256, unused: 256 }, |
14a845bc DC |
1078 | |
1079 | forEachMP: function(func, includeUnused) { | |
1080 | var i, cont; | |
1081 | for (i = 0; i < PVE.Utils.mp_counts.mps; i++) { | |
1082 | cont = func('mp', i); | |
1083 | if (!cont && cont !== undefined) { | |
1084 | return; | |
1085 | } | |
1086 | } | |
1087 | ||
1088 | if (!includeUnused) { | |
1089 | return; | |
1090 | } | |
1091 | ||
1092 | for (i = 0; i < PVE.Utils.mp_counts.unused; i++) { | |
1093 | cont = func('unused', i); | |
1094 | if (!cont && cont !== undefined) { | |
1095 | return; | |
1096 | } | |
1097 | } | |
b945c7c1 TM |
1098 | }, |
1099 | ||
1100 | cleanEmptyObjectKeys: function (obj) { | |
1101 | var propName; | |
1102 | for (propName in obj) { | |
1103 | if (obj.hasOwnProperty(propName)) { | |
1104 | if (obj[propName] === null || obj[propName] === undefined) { | |
1105 | delete obj[propName]; | |
1106 | } | |
1107 | } | |
1108 | } | |
4616a55b TM |
1109 | }, |
1110 | ||
1111 | handleStoreErrorOrMask: function(me, store, regex, callback) { | |
1112 | ||
1113 | me.mon(store, 'load', function (proxy, response, success, operation) { | |
1114 | ||
1115 | if (success) { | |
1116 | Proxmox.Utils.setErrorMask(me, false); | |
1117 | return; | |
1118 | } | |
1119 | var msg; | |
1120 | ||
1121 | if (operation.error.statusText) { | |
1122 | if (operation.error.statusText.match(regex)) { | |
1123 | callback(me, operation.error); | |
1124 | return; | |
1125 | } else { | |
1126 | msg = operation.error.statusText + ' (' + operation.error.status + ')'; | |
1127 | } | |
1128 | } else { | |
1129 | msg = gettext('Connection error'); | |
1130 | } | |
1131 | Proxmox.Utils.setErrorMask(me, msg); | |
1132 | }); | |
1133 | }, | |
1134 | ||
1135 | showCephInstallOrMask: function(container, msg, nodename, callback){ | |
1136 | var regex = new RegExp("not (installed|initialized)", "i"); | |
1137 | if (msg.match(regex)) { | |
1138 | if (Proxmox.UserName === 'root@pam') { | |
1139 | container.el.mask(); | |
1140 | if (!container.down('pveCephInstallWindow')){ | |
1141 | var win = Ext.create('PVE.ceph.Install', { | |
1142 | nodename: nodename | |
1143 | }); | |
1144 | container.add(win); | |
1145 | win.show(); | |
1146 | callback(win); | |
1147 | } | |
1148 | } else { | |
a7e8b87b TL |
1149 | container.mask(Ext.String.format(gettext('{0} not installed.') + |
1150 | ' ' + gettext('Log in as root to install.'), 'Ceph'), ['pve-static-mask']); | |
4616a55b TM |
1151 | } |
1152 | return true; | |
1153 | } else { | |
1154 | return false; | |
1155 | } | |
e7ade592 DC |
1156 | } |
1157 | }, | |
fe4f00ad | 1158 | |
9fa2e36d EK |
1159 | singleton: true, |
1160 | constructor: function() { | |
1161 | var me = this; | |
1162 | Ext.apply(me, me.utilities); | |
685b7aa4 | 1163 | } |
e7ade592 | 1164 | |
9fa2e36d | 1165 | }); |
b0a6d326 | 1166 |