]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/Utils.js
ceph: add 'scope' parameter to metadata api call
[pve-manager.git] / www / manager6 / Utils.js
CommitLineData
b0a6d326
EK
1Ext.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
6Ext.enableAria = false;
7Ext.enableAriaButtons = false;
8Ext.enableAriaPanels = false;
9
b0a6d326 10// avoid errors when running without development tools
0be88ae1
DC
11if (!Ext.isDefined(Ext.global.console)) {
12 var console = {
0be88ae1 13 log: function() {}
b0a6d326
EK
14 };
15}
0be88ae1 16console.log("Starting PVE Manager");
b0a6d326
EK
17
18Ext.Ajax.defaultHeaders = {
19 'Accept': 'application/json'
20};
21
89ae1bb1 22/*jslint confusion: true */
9fa2e36d 23Ext.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
8ec8af9c 49 noSubKeyHtml: 'You do not have a valid subscription for this server. Please visit <a target="_blank" href="https://www.proxmox.com/products/proxmox-ve/subscription-service-plans">www.proxmox.com</a> to get a list of available options.',
b0a6d326
EK
50
51 kvm_ostypes: {
45d6c71a 52 'Linux': [
ca71cd5d 53 { desc: '5.x - 2.6 Kernel', val: 'l26' },
45d6c71a
TL
54 { desc: '2.4 Kernel', val: 'l24' }
55 ],
56 'Microsoft Windows': [
beb3c8a4 57 { desc: '10/2016/2019', val: 'win10' },
45d6c71a
TL
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;
23c83a3a
DC
86 case 'upgrade':
87 icon = 'warning fa-upload';
88 break;
aa240b29
DC
89 case 'old':
90 icon = 'warning fa-refresh';
91 break;
428bc4a2
DC
92 case 'warning':
93 icon = 'warning fa-exclamation';
94 break;
95 case 'critical':
96 icon = 'critical fa-times';
97 break;
98 default: break;
99 }
100
101 if (circle) {
102 icon += '-circle';
103 }
104
105 return icon;
106 },
107
95d0de89
DC
108 parse_ceph_version: function(service) {
109 if (service.ceph_version_short) {
110 return service.ceph_version_short;
111 }
112
113 if (service.ceph_version) {
35306f47 114 var match = service.ceph_version.match(/version (\d+(\.\d+)*)/);
95d0de89
DC
115 if (match) {
116 return match[1];
117 }
118 }
119
120 return undefined;
121 },
122
005e0a60
DC
123 compare_ceph_versions: function(a, b) {
124 if (a === b) {
125 return 0;
126 }
35306f47
TL
127 let avers = a.toString().split('.');
128 let bvers = b.toString().split('.');
129
130 while (true) {
131 let av = avers.shift();
132 let bv = bvers.shift();
133
134 if (av === undefined && bv === undefined) {
135 return 0;
136 } else if (av === undefined) {
137 return -1;
138 } else if (bv === undefined) {
139 return 1;
140 } else {
141 let diff = parseInt(av, 10) - parseInt(bv, 10);
142 if (diff != 0) return diff;
143 // else we need to look at the next parts
005e0a60
DC
144 }
145 }
146
005e0a60
DC
147 },
148
2f5b82ae
DC
149 get_ceph_icon_html: function(health, fw) {
150 var state = PVE.Utils.map_ceph_health[health];
151 var cls = PVE.Utils.get_health_icon(state);
152 if (fw) {
153 cls += ' fa-fw';
154 }
155 return "<i class='fa " + cls + "'></i> ";
156 },
157
046e640c
DC
158 map_ceph_health: {
159 'HEALTH_OK':'good',
23c83a3a 160 'HEALTH_UPGRADE':'upgrade',
aa240b29 161 'HEALTH_OLD':'old',
046e640c
DC
162 'HEALTH_WARN':'warning',
163 'HEALTH_ERR':'critical'
164 },
165
dfe6d184 166 render_ceph_health: function(healthObj) {
046e640c
DC
167 var state = {
168 iconCls: PVE.Utils.get_health_icon(),
169 text: ''
170 };
171
dfe6d184 172 if (!healthObj || !healthObj.status) {
046e640c
DC
173 return state;
174 }
175
dfe6d184 176 var health = PVE.Utils.map_ceph_health[healthObj.status];
046e640c
DC
177
178 state.iconCls = PVE.Utils.get_health_icon(health, true);
dfe6d184 179 state.text = healthObj.status;
046e640c
DC
180
181 return state;
182 },
183
fee716d3 184 render_zfs_health: function(value) {
8c8604ba
TM
185 if (typeof value == 'undefined'){
186 return "";
187 }
fee716d3
DC
188 var iconCls = 'question-circle';
189 switch (value) {
8c8604ba 190 case 'AVAIL':
fee716d3
DC
191 case 'ONLINE':
192 iconCls = 'check-circle good';
193 break;
194 case 'REMOVED':
195 case 'DEGRADED':
196 iconCls = 'exclamation-circle warning';
197 break;
198 case 'UNAVAIL':
199 case 'FAULTED':
200 case 'OFFLINE':
201 iconCls = 'times-circle critical';
202 break;
203 default: //unknown
204 }
205
206 return '<i class="fa fa-' + iconCls + '"></i> ' + value;
8c8604ba 207
fee716d3
DC
208 },
209
45d6c71a
TL
210 get_kvm_osinfo: function(value) {
211 var info = { base: 'Other' }; // default
212 if (value) {
213 Ext.each(Object.keys(PVE.Utils.kvm_ostypes), function(k) {
214 Ext.each(PVE.Utils.kvm_ostypes[k], function(e) {
215 if (e.val === value) {
216 info = { desc: e.desc, base: k };
217 }
218 });
219 });
b0a6d326 220 }
45d6c71a
TL
221 return info;
222 },
223
224 render_kvm_ostype: function (value) {
225 var osinfo = PVE.Utils.get_kvm_osinfo(value);
226 if (osinfo.desc && osinfo.desc !== '-') {
227 return osinfo.base + ' ' + osinfo.desc;
228 } else {
229 return osinfo.base;
b0a6d326 230 }
b0a6d326
EK
231 },
232
233 render_hotplug_features: function (value) {
23d3881a 234 var fa = [];
b0a6d326
EK
235
236 if (!value || (value === '0')) {
ec99b1c3 237 return gettext('Disabled');
b0a6d326
EK
238 }
239
4dcca8a4
DC
240 if (value === '1') {
241 value = 'disk,network,usb';
242 }
243
b0a6d326
EK
244 Ext.each(value.split(','), function(el) {
245 if (el === 'disk') {
246 fa.push(gettext('Disk'));
247 } else if (el === 'network') {
248 fa.push(gettext('Network'));
249 } else if (el === 'usb') {
b9628aa5 250 fa.push('USB');
b0a6d326
EK
251 } else if (el === 'memory') {
252 fa.push(gettext('Memory'));
253 } else if (el === 'cpu') {
254 fa.push(gettext('CPU'));
255 } else {
256 fa.push(el);
257 }
258 });
259
260 return fa.join(', ');
261 },
262
1662ccdb
SI
263 render_qga_features: function(value) {
264 if (!value) {
265 return Proxmox.Utils.defaultText + ' (' + Proxmox.Utils.disabledText + ')';
266 }
267 var props = PVE.Parser.parsePropertyString(value, 'enabled');
268 if (!PVE.Parser.parseBoolean(props.enabled)) {
269 return Proxmox.Utils.disabledText;
270 }
271
272 delete props.enabled;
273 var agentstring = Proxmox.Utils.enabledText;
274
275 Ext.Object.each(props, function(key, value) {
276 var keystring = '' ;
277 agentstring += ', ' + key + ': ';
278
5a6c563c
MD
279 if (key === 'type') {
280 let map = {
281 isa: "ISA",
176a62d3 282 virtio: "VirtIO",
5a6c563c
MD
283 };
284 agentstring += map[value] || Proxmox.Utils.unknownText;
1662ccdb 285 } else {
5a6c563c
MD
286 if (PVE.Parser.parseBoolean(value)) {
287 agentstring += Proxmox.Utils.enabledText;
288 } else {
289 agentstring += Proxmox.Utils.disabledText;
290 }
1662ccdb
SI
291 }
292 });
293
294 return agentstring;
295 },
296
a1ee14a2
DC
297 render_qemu_machine: function(value) {
298 return value || (Proxmox.Utils.defaultText + ' (i440fx)');
299 },
300
17c71f27
DC
301 render_qemu_bios: function(value) {
302 if (!value) {
e7ade592 303 return Proxmox.Utils.defaultText + ' (SeaBIOS)';
17c71f27
DC
304 } else if (value === 'seabios') {
305 return "SeaBIOS";
306 } else if (value === 'ovmf') {
307 return "OVMF (UEFI)";
308 } else {
309 return value;
310 }
311 },
312
8f17b496
TL
313 render_dc_ha_opts: function(value) {
314 if (!value) {
41ca3465 315 return Proxmox.Utils.defaultText;
8f17b496
TL
316 } else {
317 return PVE.Parser.printPropertyString(value);
318 }
319 },
bb469a11
TL
320 render_as_property_string: function(value) {
321 return (!value) ? Proxmox.Utils.defaultText
322 : PVE.Parser.printPropertyString(value);
323 },
8f17b496 324
b0a6d326
EK
325 render_scsihw: function(value) {
326 if (!value) {
e7ade592 327 return Proxmox.Utils.defaultText + ' (LSI 53C895A)';
b0a6d326
EK
328 } else if (value === 'lsi') {
329 return 'LSI 53C895A';
330 } else if (value === 'lsi53c810') {
331 return 'LSI 53C810';
332 } else if (value === 'megasas') {
333 return 'MegaRAID SAS 8708EM2';
334 } else if (value === 'virtio-scsi-pci') {
49f5d1ab
EK
335 return 'VirtIO SCSI';
336 } else if (value === 'virtio-scsi-single') {
337 return 'VirtIO SCSI single';
b0a6d326
EK
338 } else if (value === 'pvscsi') {
339 return 'VMware PVSCSI';
340 } else {
341 return value;
342 }
343 },
344
9c22da32 345 render_spice_enhancements: function(values) {
9c22da32
AL
346 let props = PVE.Parser.parsePropertyString(values);
347 if (Ext.Object.isEmpty(props)) {
3b0facc9 348 return Proxmox.Utils.noneText;
9c22da32
AL
349 }
350
351 let output = [];
352 if (PVE.Parser.parseBoolean(props.foldersharing)) {
353 output.push('Folder Sharing: ' + gettext('Enabled'));
354 }
355 if (props.videostreaming === 'all' || props.videostreaming === 'filter') {
356 output.push('Video Streaming: ' + props.videostreaming);
357 }
358 return output.join(', ');
359 },
360
b0a6d326
EK
361 // fixme: auto-generate this
362 // for now, please keep in sync with PVE::Tools::kvmkeymaps
363 kvm_keymaps: {
364 //ar: 'Arabic',
365 da: 'Danish',
0be88ae1
DC
366 de: 'German',
367 'de-ch': 'German (Swiss)',
368 'en-gb': 'English (UK)',
0a5b8747 369 'en-us': 'English (USA)',
b0a6d326
EK
370 es: 'Spanish',
371 //et: 'Estonia',
372 fi: 'Finnish',
0be88ae1
DC
373 //fo: 'Faroe Islands',
374 fr: 'French',
375 'fr-be': 'French (Belgium)',
b0a6d326
EK
376 'fr-ca': 'French (Canada)',
377 'fr-ch': 'French (Swiss)',
378 //hr: 'Croatia',
379 hu: 'Hungarian',
380 is: 'Icelandic',
0be88ae1 381 it: 'Italian',
b0a6d326
EK
382 ja: 'Japanese',
383 lt: 'Lithuanian',
384 //lv: 'Latvian',
0be88ae1 385 mk: 'Macedonian',
b0a6d326
EK
386 nl: 'Dutch',
387 //'nl-be': 'Dutch (Belgium)',
0be88ae1 388 no: 'Norwegian',
b0a6d326
EK
389 pl: 'Polish',
390 pt: 'Portuguese',
391 'pt-br': 'Portuguese (Brazil)',
392 //ru: 'Russian',
393 sl: 'Slovenian',
394 sv: 'Swedish',
395 //th: 'Thai',
396 tr: 'Turkish'
397 },
398
399 kvm_vga_drivers: {
400 std: gettext('Standard VGA'),
5ca366f2 401 vmware: gettext('VMware compatible'),
b0a6d326
EK
402 qxl: 'SPICE',
403 qxl2: 'SPICE dual monitor',
404 qxl3: 'SPICE three monitors',
405 qxl4: 'SPICE four monitors',
406 serial0: gettext('Serial terminal') + ' 0',
407 serial1: gettext('Serial terminal') + ' 1',
408 serial2: gettext('Serial terminal') + ' 2',
89ae1bb1
DC
409 serial3: gettext('Serial terminal') + ' 3',
410 virtio: 'VirtIO-GPU',
411 none: Proxmox.Utils.noneText
b0a6d326
EK
412 },
413
414 render_kvm_language: function (value) {
e7ade592
DC
415 if (!value || value === '__default__') {
416 return Proxmox.Utils.defaultText;
b0a6d326
EK
417 }
418 var text = PVE.Utils.kvm_keymaps[value];
419 if (text) {
420 return text + ' (' + value + ')';
421 }
422 return value;
423 },
424
425 kvm_keymap_array: function() {
f2782813 426 var data = [['__default__', PVE.Utils.render_kvm_language('')]];
b0a6d326
EK
427 Ext.Object.each(PVE.Utils.kvm_keymaps, function(key, value) {
428 data.push([key, PVE.Utils.render_kvm_language(value)]);
429 });
430
431 return data;
432 },
433
3438c27e 434 console_map: {
da9d14cd 435 '__default__': Proxmox.Utils.defaultText + ' (xterm.js)',
3438c27e
DC
436 'vv': 'SPICE (remote-viewer)',
437 'html5': 'HTML5 (noVNC)',
4ace5c6f 438 'xtermjs': 'xterm.js'
3438c27e
DC
439 },
440
b0a6d326 441 render_console_viewer: function(value) {
3438c27e
DC
442 value = value || '__default__';
443 if (PVE.Utils.console_map[value]) {
444 return PVE.Utils.console_map[value];
b0a6d326 445 }
3438c27e 446 return value;
b0a6d326
EK
447 },
448
755b9083 449 console_viewer_array: function() {
3438c27e 450 return Ext.Array.map(Object.keys(PVE.Utils.console_map), function(v) {
755b9083
TL
451 return [v, PVE.Utils.render_console_viewer(v)];
452 });
453 },
454
b0a6d326
EK
455 render_kvm_vga_driver: function (value) {
456 if (!value) {
e7ade592 457 return Proxmox.Utils.defaultText;
b0a6d326 458 }
4f3e66d8
DC
459 var vga = PVE.Parser.parsePropertyString(value, 'type');
460 var text = PVE.Utils.kvm_vga_drivers[vga.type];
461 if (!vga.type) {
462 text = Proxmox.Utils.defaultText;
463 }
0be88ae1 464 if (text) {
b0a6d326
EK
465 return text + ' (' + value + ')';
466 }
467 return value;
468 },
469
470 kvm_vga_driver_array: function() {
f2782813 471 var data = [['__default__', PVE.Utils.render_kvm_vga_driver('')]];
b0a6d326
EK
472 Ext.Object.each(PVE.Utils.kvm_vga_drivers, function(key, value) {
473 data.push([key, PVE.Utils.render_kvm_vga_driver(value)]);
474 });
475
476 return data;
477 },
478
479 render_kvm_startup: function(value) {
480 var startup = PVE.Parser.parseStartup(value);
481
482 var res = 'order=';
483 if (startup.order === undefined) {
484 res += 'any';
485 } else {
486 res += startup.order;
487 }
488 if (startup.up !== undefined) {
489 res += ',up=' + startup.up;
490 }
491 if (startup.down !== undefined) {
492 res += ',down=' + startup.down;
493 }
494
495 return res;
496 },
497
b0a6d326
EK
498 extractFormActionError: function(action) {
499 var msg;
500 switch (action.failureType) {
501 case Ext.form.action.Action.CLIENT_INVALID:
502 msg = gettext('Form fields may not be submitted with invalid values');
503 break;
504 case Ext.form.action.Action.CONNECT_FAILURE:
505 msg = gettext('Connection error');
506 var resp = action.response;
507 if (resp.status && resp.statusText) {
508 msg += " " + resp.status + ": " + resp.statusText;
509 }
510 break;
511 case Ext.form.action.Action.LOAD_FAILURE:
512 case Ext.form.action.Action.SERVER_INVALID:
e7ade592 513 msg = Proxmox.Utils.extractRequestError(action.result, true);
b0a6d326
EK
514 break;
515 }
516 return msg;
517 },
518
b0a6d326 519 format_duration_short: function(ut) {
0be88ae1 520
b0a6d326 521 if (ut < 60) {
530ee6b7 522 return ut.toFixed(1) + 's';
b0a6d326
EK
523 }
524
525 if (ut < 3600) {
526 var mins = ut / 60;
530ee6b7 527 return mins.toFixed(1) + 'm';
b0a6d326
EK
528 }
529
530 if (ut < 86400) {
531 var hours = ut / 3600;
530ee6b7 532 return hours.toFixed(1) + 'h';
b0a6d326
EK
533 }
534
535 var days = ut / 86400;
530ee6b7 536 return days.toFixed(1) + 'd';
b0a6d326
EK
537 },
538
0e244a29
DC
539 contentTypes: {
540 'images': gettext('Disk image'),
541 'backup': gettext('VZDump backup file'),
542 'vztmpl': gettext('Container template'),
543 'iso': gettext('ISO image'),
aef28e04
DC
544 'rootdir': gettext('Container'),
545 'snippets': gettext('Snippets')
0e244a29 546 },
b0a6d326 547
3b8f599b
DM
548 volume_is_qemu_backup: function(volid, format) {
549 return format === 'pbs-vm' || volid.match(':backup/vzdump-qemu-');
550 },
551
552 volume_is_lxc_backup: function(volid, format) {
553 return format === 'pbs-ct' || volid.match(':backup/vzdump-(lxc|openvz)-');
554 },
555
062a7f49
TL
556 storageSchema: {
557 dir: {
558 name: Proxmox.Utils.directoryText,
559 ipanel: 'DirInputPanel',
560 faIcon: 'folder'
561 },
562 lvm: {
563 name: 'LVM',
564 ipanel: 'LVMInputPanel',
565 faIcon: 'folder'
566 },
567 lvmthin: {
568 name: 'LVM-Thin',
569 ipanel: 'LvmThinInputPanel',
570 faIcon: 'folder'
571 },
572 nfs: {
573 name: 'NFS',
574 ipanel: 'NFSInputPanel',
575 faIcon: 'building'
576 },
577 cifs: {
578 name: 'CIFS',
579 ipanel: 'CIFSInputPanel',
580 faIcon: 'building'
581 },
582 glusterfs: {
583 name: 'GlusterFS',
584 ipanel: 'GlusterFsInputPanel',
585 faIcon: 'building'
586 },
587 iscsi: {
588 name: 'iSCSI',
589 ipanel: 'IScsiInputPanel',
590 faIcon: 'building'
591 },
4a4b2b6e
TL
592 cephfs: {
593 name: 'CephFS',
594 ipanel: 'CephFSInputPanel',
595 faIcon: 'building'
596 },
597 pvecephfs: {
598 name: 'CephFS (PVE)',
599 ipanel: 'CephFSInputPanel',
600 hideAdd: true,
601 faIcon: 'building'
602 },
062a7f49
TL
603 rbd: {
604 name: 'RBD',
605 ipanel: 'RBDInputPanel',
062a7f49
TL
606 faIcon: 'building'
607 },
608 pveceph: {
609 name: 'RBD (PVE)',
0d1ac958
TL
610 ipanel: 'RBDInputPanel',
611 hideAdd: true,
062a7f49
TL
612 faIcon: 'building'
613 },
614 zfs: {
615 name: 'ZFS over iSCSI',
616 ipanel: 'ZFSInputPanel',
617 faIcon: 'building'
618 },
619 zfspool: {
620 name: 'ZFS',
621 ipanel: 'ZFSPoolInputPanel',
622 faIcon: 'folder'
623 },
624 drbd: {
625 name: 'DRBD',
626 hideAdd: true
627 }
628 },
629
9233148b
AD
630 sdnvnetSchema: {
631 vnet: {
632 name: 'vnet',
633 faIcon: 'folder'
634 },
635 },
636
637 sdnzoneSchema: {
638 zone: {
639 name: 'zone',
640 hideAdd: true
641 },
642 vlan: {
643 name: 'vlan',
644 ipanel: 'VlanInputPanel',
645 faIcon: 'folder'
646 },
647 qinq: {
648 name: 'qinq',
649 ipanel: 'QinQInputPanel',
650 faIcon: 'folder'
651 },
652 vxlan: {
653 name: 'vxlan',
654 ipanel: 'VxlanInputPanel',
655 faIcon: 'folder'
656 },
657 evpn: {
658 name: 'evpn',
659 ipanel: 'EvpnInputPanel',
660 faIcon: 'folder'
661 },
662 },
663
664 sdncontrollerSchema: {
665 controller: {
666 name: 'controller',
667 hideAdd: true
668 },
669 evpn: {
670 name: 'evpn',
671 ipanel: 'EvpnInputPanel',
672 faIcon: 'folder'
673 },
674 },
675
676 format_sdnvnet_type: function(value, md, record) {
677 var schema = PVE.Utils.sdnvnetSchema[value];
678 if (schema) {
679 return schema.name;
680 }
681 return Proxmox.Utils.unknownText;
682 },
683
684 format_sdnzone_type: function(value, md, record) {
685 var schema = PVE.Utils.sdnzoneSchema[value];
686 if (schema) {
687 return schema.name;
688 }
689 return Proxmox.Utils.unknownText;
690 },
691
692 format_sdncontroller_type: function(value, md, record) {
693 var schema = PVE.Utils.sdncontrollerSchema[value];
694 if (schema) {
695 return schema.name;
696 }
697 return Proxmox.Utils.unknownText;
698 },
699
3c23c025 700 format_storage_type: function(value, md, record) {
4a4b2b6e
TL
701 if (value === 'rbd') {
702 value = (!record || record.get('monhost') ? 'rbd' : 'pveceph');
703 } else if (value === 'cephfs') {
704 value = (!record || record.get('monhost') ? 'cephfs' : 'pvecephfs');
3c23c025 705 }
062a7f49
TL
706
707 var schema = PVE.Utils.storageSchema[value];
708 if (schema) {
709 return schema.name;
b0a6d326 710 }
062a7f49 711 return Proxmox.Utils.unknownText;
a3b8efb4
EK
712 },
713
ced1677b 714 format_ha: function(value) {
e7ade592 715 var text = Proxmox.Utils.noneText;
ced1677b
TL
716
717 if (value.managed) {
e7ade592 718 text = value.state || Proxmox.Utils.noneText;
ced1677b 719
e7ade592
DC
720 text += ', ' + Proxmox.Utils.groupText + ': ';
721 text += value.group || Proxmox.Utils.noneText;
ced1677b
TL
722 }
723
724 return text;
725 },
726
b0a6d326 727 format_content_types: function(value) {
0e244a29
DC
728 return value.split(',').sort().map(function(ct) {
729 return PVE.Utils.contentTypes[ct] || ct;
730 }).join(', ');
b0a6d326
EK
731 },
732
733 render_storage_content: function(value, metaData, record) {
734 var data = record.data;
735 if (Ext.isNumber(data.channel) &&
736 Ext.isNumber(data.id) &&
737 Ext.isNumber(data.lun)) {
0be88ae1
DC
738 return "CH " +
739 Ext.String.leftPad(data.channel,2, '0') +
b0a6d326
EK
740 " ID " + data.id + " LUN " + data.lun;
741 }
3b8f599b 742 return data.volid.replace(/^.*?:(.*?\/)?/,'');
b0a6d326
EK
743 },
744
745 render_serverity: function (value) {
746 return PVE.Utils.log_severity_hash[value] || value;
747 },
748
749 render_cpu: function(value, metaData, record, rowIndex, colIndex, store) {
750
751 if (!(record.data.uptime && Ext.isNumeric(value))) {
752 return '';
753 }
754
755 var maxcpu = record.data.maxcpu || 1;
756
757 if (!Ext.isNumeric(maxcpu) && (maxcpu >= 1)) {
758 return '';
759 }
0be88ae1 760
b0a6d326
EK
761 var per = value * 100;
762
763 return per.toFixed(1) + '% of ' + maxcpu.toString() + (maxcpu > 1 ? 'CPUs' : 'CPU');
764 },
765
766 render_size: function(value, metaData, record, rowIndex, colIndex, store) {
767 /*jslint confusion: true */
768
769 if (!Ext.isNumeric(value)) {
770 return '';
771 }
772
e7ade592 773 return Proxmox.Utils.format_size(value);
b0a6d326
EK
774 },
775
946730cd
DC
776 render_bandwidth: function(value) {
777 if (!Ext.isNumeric(value)) {
778 return '';
779 }
780
e7ade592 781 return Proxmox.Utils.format_size(value) + '/s';
b0a6d326
EK
782 },
783
3f633655
EK
784 render_timestamp_human_readable: function(value) {
785 return Ext.Date.format(new Date(value * 1000), 'l d F Y H:i:s');
786 },
787
ddd26302
DC
788 render_duration: function(value) {
789 if (value === undefined) {
790 return '-';
791 }
792 return PVE.Utils.format_duration_short(value);
793 },
794
0bfc799f
DC
795 calculate_mem_usage: function(data) {
796 if (!Ext.isNumeric(data.mem) ||
797 data.maxmem === 0 ||
798 data.uptime < 1) {
799 return -1;
800 }
801
802 return (data.mem / data.maxmem);
803 },
804
805 render_mem_usage_percent: function(value, metaData, record, rowIndex, colIndex, store) {
806 if (!Ext.isNumeric(value) || value === -1) {
807 return '';
808 }
809 if (value > 1 ) {
810 // we got no percentage but bytes
811 var mem = value;
812 var maxmem = record.data.maxmem;
813 if (!record.data.uptime ||
814 maxmem === 0 ||
815 !Ext.isNumeric(mem)) {
816 return '';
817 }
818
819 return ((mem*100)/maxmem).toFixed(1) + " %";
820 }
821 return (value*100).toFixed(1) + " %";
822 },
823
b0a6d326
EK
824 render_mem_usage: function(value, metaData, record, rowIndex, colIndex, store) {
825
826 var mem = value;
827 var maxmem = record.data.maxmem;
0be88ae1 828
b0a6d326
EK
829 if (!record.data.uptime) {
830 return '';
831 }
832
833 if (!(Ext.isNumeric(mem) && maxmem)) {
834 return '';
835 }
836
728f1b97 837 return PVE.Utils.render_size(value);
b0a6d326
EK
838 },
839
0bfc799f
DC
840 calculate_disk_usage: function(data) {
841
842 if (!Ext.isNumeric(data.disk) ||
843 data.type === 'qemu' ||
844 (data.type === 'lxc' && data.uptime === 0) ||
845 data.maxdisk === 0) {
846 return -1;
847 }
848
849 return (data.disk / data.maxdisk);
850 },
851
852 render_disk_usage_percent: function(value, metaData, record, rowIndex, colIndex, store) {
853 if (!Ext.isNumeric(value) || value === -1) {
854 return '';
855 }
856
857 return (value * 100).toFixed(1) + " %";
858 },
859
b0a6d326
EK
860 render_disk_usage: function(value, metaData, record, rowIndex, colIndex, store) {
861
862 var disk = value;
863 var maxdisk = record.data.maxdisk;
728f1b97 864 var type = record.data.type;
b0a6d326 865
728f1b97
DC
866 if (!Ext.isNumeric(disk) ||
867 type === 'qemu' ||
868 maxdisk === 0 ||
869 (type === 'lxc' && record.data.uptime === 0)) {
b0a6d326
EK
870 return '';
871 }
872
728f1b97 873 return PVE.Utils.render_size(value);
b0a6d326
EK
874 },
875
4dbc64a7
DC
876 get_object_icon_class: function(type, record) {
877 var status = '';
878 var objType = type;
879
880 if (type === 'type') {
881 // for folder view
882 objType = record.groupbyid;
883 } else if (record.template) {
884 // templates
885 objType = 'template';
886 status = type;
887 } else {
888 // everything else
889 status = record.status + ' ha-' + record.hastate;
b1d8e73d
DC
890 }
891
6284a48a
DC
892 if (record.lock) {
893 status += ' locked lock-' + record.lock;
894 }
895
4dbc64a7
DC
896 var defaults = PVE.tree.ResourceTree.typeDefaults[objType];
897 if (defaults && defaults.iconCls) {
898 var retVal = defaults.iconCls + ' ' + status;
899 return retVal;
b0a6d326
EK
900 }
901
4dbc64a7
DC
902 return '';
903 },
904
905 render_resource_type: function(value, metaData, record, rowIndex, colIndex, store) {
906
907 var cls = PVE.Utils.get_object_icon_class(value,record.data);
2b2fe160 908
4dbc64a7 909 var fa = '<i class="fa-fw x-grid-icon-custom ' + cls + '"></i> ';
b1d8e73d 910 return fa + value;
b0a6d326
EK
911 },
912
b0a6d326
EK
913 render_support_level: function(value, metaData, record) {
914 return PVE.Utils.support_level_hash[value] || '-';
915 },
916
0be88ae1 917 render_upid: function(value, metaData, record) {
b0a6d326
EK
918 var type = record.data.type;
919 var id = record.data.id;
920
e7ade592 921 return Proxmox.Utils.format_task_description(type, id);
b0a6d326
EK
922 },
923
054ac1b8
DC
924 /* render functions for new status panel */
925
926 render_usage: function(val) {
927 return (val*100).toFixed(2) + '%';
928 },
929
930 render_cpu_usage: function(val, max) {
931 return Ext.String.format(gettext('{0}% of {1}') +
932 ' ' + gettext('CPU(s)'), (val*100).toFixed(2), max);
933 },
934
935 render_size_usage: function(val, max) {
bab64974
DC
936 if (max === 0) {
937 return gettext('N/A');
938 }
054ac1b8
DC
939 return (val*100/max).toFixed(2) + '% '+ '(' +
940 Ext.String.format(gettext('{0} of {1}'),
941 PVE.Utils.render_size(val), PVE.Utils.render_size(max)) + ')';
942 },
943
944 /* this is different for nodes */
945 render_node_cpu_usage: function(value, record) {
946 return PVE.Utils.render_cpu_usage(value, record.cpus);
947 },
948
949 /* this is different for nodes */
950 render_node_size_usage: function(record) {
951 return PVE.Utils.render_size_usage(record.used, record.total);
952 },
953
27809975
DC
954 render_optional_url: function(value) {
955 var match;
956 if (value && (match = value.match(/^https?:\/\//)) !== null) {
cdd9b6c0 957 return '<a target="_blank" href="' + value + '">' + value + '</a>';
27809975
DC
958 }
959 return value;
960 },
961
962 render_san: function(value) {
963 var names = [];
964 if (Ext.isArray(value)) {
965 value.forEach(function(val) {
966 if (!Ext.isNumber(val)) {
967 names.push(val);
968 }
969 });
970 return names.join('<br>');
971 }
972 return value;
973 },
974
6ad4be69
DC
975 render_full_name: function(firstname, metaData, record) {
976 var first = firstname || '';
977 var last = record.data.lastname || '';
978 return Ext.htmlEncode(first + " " + last);
979 },
980
2d41c7e6
TL
981 render_u2f_error: function(error) {
982 var ErrorNames = {
983 '1': gettext('Other Error'),
984 '2': gettext('Bad Request'),
985 '3': gettext('Configuration Unsupported'),
986 '4': gettext('Device Ineligible'),
987 '5': gettext('Timeout')
988 };
989 return "U2F Error: " + ErrorNames[error] || Proxmox.Utils.unknownText;
990 },
991
aa0819a8 992 windowHostname: function() {
e7ade592 993 return window.location.hostname.replace(Proxmox.Utils.IP6_bracket_match,
aa0819a8
WB
994 function(m, addr, offset, original) { return addr; });
995 },
0be88ae1 996
8eccc68f 997 openDefaultConsoleWindow: function(consoles, vmtype, vmid, nodename, vmname, cmd) {
3438c27e 998 var dv = PVE.Utils.defaultViewer(consoles);
8eccc68f 999 PVE.Utils.openConsoleWindow(dv, vmtype, vmid, nodename, vmname, cmd);
b0a6d326
EK
1000 },
1001
8eccc68f 1002 openConsoleWindow: function(viewer, vmtype, vmid, nodename, vmname, cmd) {
9e361643 1003 // kvm, lxc, shell, upgrade
b0a6d326 1004
9e361643 1005 if (vmid == undefined && (vmtype === 'kvm' || vmtype === 'lxc')) {
b0a6d326
EK
1006 throw "missing vmid";
1007 }
1008
1009 if (!nodename) {
1010 throw "no nodename specified";
1011 }
1012
c7218ab3 1013 if (viewer === 'html5') {
8eccc68f 1014 PVE.Utils.openVNCViewer(vmtype, vmid, nodename, vmname, cmd);
c6b2336c 1015 } else if (viewer === 'xtermjs') {
8eccc68f 1016 Proxmox.Utils.openXtermJsViewer(vmtype, vmid, nodename, vmname, cmd);
b0a6d326
EK
1017 } else if (viewer === 'vv') {
1018 var url;
aa0819a8 1019 var params = { proxy: PVE.Utils.windowHostname() };
b0a6d326
EK
1020 if (vmtype === 'kvm') {
1021 url = '/nodes/' + nodename + '/qemu/' + vmid.toString() + '/spiceproxy';
1022 PVE.Utils.openSpiceViewer(url, params);
9e361643
DM
1023 } else if (vmtype === 'lxc') {
1024 url = '/nodes/' + nodename + '/lxc/' + vmid.toString() + '/spiceproxy';
b0a6d326
EK
1025 PVE.Utils.openSpiceViewer(url, params);
1026 } else if (vmtype === 'shell') {
1027 url = '/nodes/' + nodename + '/spiceshell';
1028 PVE.Utils.openSpiceViewer(url, params);
1029 } else if (vmtype === 'upgrade') {
1030 url = '/nodes/' + nodename + '/spiceshell';
1031 params.upgrade = 1;
1032 PVE.Utils.openSpiceViewer(url, params);
8eccc68f
TM
1033 } else if (vmtype === 'cmd') {
1034 url = '/nodes/' + nodename + '/spiceshell';
1035 params.cmd = cmd;
1036 PVE.Utils.openSpiceViewer(url, params);
b0a6d326
EK
1037 }
1038 } else {
1039 throw "unknown viewer type";
1040 }
1041 },
1042
3438c27e
DC
1043 defaultViewer: function(consoles) {
1044
1045 var allowSpice, allowXtermjs;
1046
1047 if (consoles === true) {
1048 allowSpice = true;
1049 allowXtermjs = true;
1050 } else if (typeof consoles === 'object') {
1051 allowSpice = consoles.spice;
4ace5c6f 1052 allowXtermjs = !!consoles.xtermjs;
3438c27e 1053 }
da9d14cd 1054 var dv = PVE.VersionInfo.console || 'xtermjs';
f932cffa
DC
1055 if (dv === 'vv' && !allowSpice) {
1056 dv = (allowXtermjs) ? 'xtermjs' : 'html5';
1057 } else if (dv === 'xtermjs' && !allowXtermjs) {
1058 dv = (allowSpice) ? 'vv' : 'html5';
b0a6d326
EK
1059 }
1060
1061 return dv;
1062 },
1063
8eccc68f 1064 openVNCViewer: function(vmtype, vmid, nodename, vmname, cmd) {
af89f682
TL
1065 let scaling = 'off';
1066 if (Proxmox.Utils.toolkit !== 'touch') {
1067 var sp = Ext.state.Manager.getProvider();
1068 scaling = sp.get('novnc-scaling', 'off');
1069 }
8eccc68f 1070 var url = Ext.Object.toQueryString({
9e361643 1071 console: vmtype, // kvm, lxc, upgrade or shell
c7218ab3 1072 novnc: 1,
b0a6d326
EK
1073 vmid: vmid,
1074 vmname: vmname,
16e64c97 1075 node: nodename,
af89f682 1076 resize: scaling,
8eccc68f 1077 cmd: cmd
b0a6d326
EK
1078 });
1079 var nw = window.open("?" + url, '_blank', "innerWidth=745,innerheight=427");
7af1ab47
DC
1080 if (nw) {
1081 nw.focus();
1082 }
b0a6d326
EK
1083 },
1084
1085 openSpiceViewer: function(url, params){
1086
1087 var downloadWithName = function(uri, name) {
1088 var link = Ext.DomHelper.append(document.body, {
1089 tag: 'a',
1090 href: uri,
1091 css : 'display:none;visibility:hidden;height:0px;'
1092 });
1093
1094 // Note: we need to tell android the correct file name extension
1095 // but we do not set 'download' tag for other environments, because
1096 // It can have strange side effects (additional user prompt on firefox)
1097 var andriod = navigator.userAgent.match(/Android/i) ? true : false;
1098 if (andriod) {
1099 link.download = name;
1100 }
1101
1102 if (link.fireEvent) {
1103 link.fireEvent('onclick');
1104 } else {
1105 var evt = document.createEvent("MouseEvents");
1106 evt.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
1107 link.dispatchEvent(evt);
1108 }
1109 };
1110
e7ade592 1111 Proxmox.Utils.API2Request({
b0a6d326
EK
1112 url: url,
1113 params: params,
1114 method: 'POST',
1115 failure: function(response, opts){
1116 Ext.Msg.alert('Error', response.htmlStatus);
1117 },
1118 success: function(response, opts){
1119 var raw = "[virt-viewer]\n";
1120 Ext.Object.each(response.result.data, function(k, v) {
1121 raw += k + "=" + v + "\n";
1122 });
1123 var url = 'data:application/x-virt-viewer;charset=UTF-8,' +
1124 encodeURIComponent(raw);
0be88ae1 1125
b0a6d326
EK
1126 downloadWithName(url, "pve-spice.vv");
1127 }
1128 });
1129 },
1130
e3129443
DC
1131 openTreeConsole: function(tree, record, item, index, e) {
1132 e.stopEvent();
1133 var nodename = record.data.node;
1134 var vmid = record.data.vmid;
1135 var vmname = record.data.name;
1136 if (record.data.type === 'qemu' && !record.data.template) {
e7ade592 1137 Proxmox.Utils.API2Request({
e3129443
DC
1138 url: '/nodes/' + nodename + '/qemu/' + vmid + '/status/current',
1139 failure: function(response, opts) {
1140 Ext.Msg.alert('Error', response.htmlStatus);
1141 },
1142 success: function(response, opts) {
bd9537d7 1143 let conf = response.result.data;
54453c38 1144 var consoles = {
bd9537d7
TL
1145 spice: !!conf.spice,
1146 xtermjs: !!conf.serial,
54453c38
DC
1147 };
1148 PVE.Utils.openDefaultConsoleWindow(consoles, 'kvm', vmid, nodename, vmname);
e3129443
DC
1149 }
1150 });
1151 } else if (record.data.type === 'lxc' && !record.data.template) {
1152 PVE.Utils.openDefaultConsoleWindow(true, 'lxc', vmid, nodename, vmname);
1153 }
1154 },
1155
fbd60cfd
DM
1156 // test automation helper
1157 call_menu_handler: function(menu, text) {
1158
1159 var list = menu.query('menuitem');
1160
1161 Ext.Array.each(list, function(item) {
1162 if (item.text === text) {
1163 if (item.handler) {
1164 item.handler();
1165 return 1;
1166 } else {
1167 return undefined;
1168 }
1169 }
1170 });
1171 },
1172
685b7aa4
DC
1173 createCmdMenu: function(v, record, item, index, event) {
1174 event.stopEvent();
cc1a91be
DC
1175 if (!(v instanceof Ext.tree.View)) {
1176 v.select(record);
1177 }
685b7aa4 1178 var menu;
9bad05bd
DC
1179 var template = !!record.data.template;
1180 var type = record.data.type;
685b7aa4 1181
9bad05bd
DC
1182 if (template) {
1183 if (type === 'qemu' || type == 'lxc') {
1184 menu = Ext.create('PVE.menu.TemplateMenu', {
1185 pveSelNode: record
1186 });
1187 }
1188 } else if (type === 'qemu' ||
1189 type === 'lxc' ||
1190 type === 'node') {
1191 menu = Ext.create('PVE.' + type + '.CmdMenu', {
1192 pveSelNode: record,
c11ab8cb
DC
1193 nodename: record.data.node
1194 });
685b7aa4
DC
1195 } else {
1196 return;
1197 }
1198
1199 menu.showAt(event.getXY());
9f0b4e04 1200 return menu;
e7ade592 1201 },
9fa2e36d 1202
fe4f00ad
TL
1203 // helper for deleting field which are set to there default values
1204 delete_if_default: function(values, fieldname, default_val, create) {
1205 if (values[fieldname] === '' || values[fieldname] === default_val) {
1206 if (!create) {
1207 if (values['delete']) {
1208 values['delete'] += ',' + fieldname;
1209 } else {
1210 values['delete'] = fieldname;
1211 }
1212 }
1213
1214 delete values[fieldname];
1215 }
857b97a7
TL
1216 },
1217
1218 loadSSHKeyFromFile: function(file, callback) {
1219 // ssh-keygen produces 740 bytes for an average 4096 bit rsa key, with
1220 // a user@host comment, 1420 for 8192 bits; current max is 16kbit
1221 // assume: 740*8 for max. 32kbit (5920 byte file)
1222 // round upwards to nearest nice number => 8192 bytes, leaves lots of comment space
1223 if (file.size > 8192) {
1224 Ext.Msg.alert(gettext('Error'), gettext("Invalid file size: ") + file.size);
1225 return;
1226 }
1227 /*global
1228 FileReader
1229 */
1230 var reader = new FileReader();
1231 reader.onload = function(evt) {
1232 callback(evt.target.result);
1233 };
1234 reader.readAsText(file);
abe824aa
DC
1235 },
1236
8c4ec8c7
TL
1237 diskControllerMaxIDs: {
1238 ide: 4,
1239 sata: 6,
cf0d139e 1240 scsi: 31,
8c4ec8c7
TL
1241 virtio: 16,
1242 },
abe824aa
DC
1243
1244 // types is either undefined (all busses), an array of busses, or a single bus
1245 forEachBus: function(types, func) {
8c4ec8c7 1246 var busses = Object.keys(PVE.Utils.diskControllerMaxIDs);
abe824aa
DC
1247 var i, j, count, cont;
1248
1249 if (Ext.isArray(types)) {
1250 busses = types;
1251 } else if (Ext.isDefined(types)) {
1252 busses = [ types ];
1253 }
1254
1255 // check if we only have valid busses
1256 for (i = 0; i < busses.length; i++) {
8c4ec8c7 1257 if (!PVE.Utils.diskControllerMaxIDs[busses[i]]) {
abe824aa
DC
1258 throw "invalid bus: '" + busses[i] + "'";
1259 }
1260 }
1261
1262 for (i = 0; i < busses.length; i++) {
8c4ec8c7 1263 count = PVE.Utils.diskControllerMaxIDs[busses[i]];
abe824aa
DC
1264 for (j = 0; j < count; j++) {
1265 cont = func(busses[i], j);
1266 if (!cont && cont !== undefined) {
1267 return;
1268 }
1269 }
1270 }
14a845bc
DC
1271 },
1272
483bd394 1273 mp_counts: { mps: 256, unused: 256 },
14a845bc
DC
1274
1275 forEachMP: function(func, includeUnused) {
1276 var i, cont;
1277 for (i = 0; i < PVE.Utils.mp_counts.mps; i++) {
1278 cont = func('mp', i);
1279 if (!cont && cont !== undefined) {
1280 return;
1281 }
1282 }
1283
1284 if (!includeUnused) {
1285 return;
1286 }
1287
1288 for (i = 0; i < PVE.Utils.mp_counts.unused; i++) {
1289 cont = func('unused', i);
1290 if (!cont && cont !== undefined) {
1291 return;
1292 }
1293 }
b945c7c1
TM
1294 },
1295
6c1d8ead 1296 hardware_counts: { net: 32, usb: 5, hostpci: 16, audio: 1, efidisk: 1, serial: 4, rng: 1 },
9d855398 1297
b945c7c1
TM
1298 cleanEmptyObjectKeys: function (obj) {
1299 var propName;
1300 for (propName in obj) {
1301 if (obj.hasOwnProperty(propName)) {
1302 if (obj[propName] === null || obj[propName] === undefined) {
1303 delete obj[propName];
1304 }
1305 }
1306 }
4616a55b
TM
1307 },
1308
1309 handleStoreErrorOrMask: function(me, store, regex, callback) {
1310
1311 me.mon(store, 'load', function (proxy, response, success, operation) {
1312
1313 if (success) {
1314 Proxmox.Utils.setErrorMask(me, false);
1315 return;
1316 }
1317 var msg;
1318
1319 if (operation.error.statusText) {
1320 if (operation.error.statusText.match(regex)) {
1321 callback(me, operation.error);
1322 return;
1323 } else {
1324 msg = operation.error.statusText + ' (' + operation.error.status + ')';
1325 }
1326 } else {
1327 msg = gettext('Connection error');
1328 }
1329 Proxmox.Utils.setErrorMask(me, msg);
1330 });
1331 },
1332
1333 showCephInstallOrMask: function(container, msg, nodename, callback){
1334 var regex = new RegExp("not (installed|initialized)", "i");
1335 if (msg.match(regex)) {
1336 if (Proxmox.UserName === 'root@pam') {
1337 container.el.mask();
1338 if (!container.down('pveCephInstallWindow')){
f992ef80 1339 var isInstalled = msg.match(/not initialized/i) ? true : false;
4616a55b
TM
1340 var win = Ext.create('PVE.ceph.Install', {
1341 nodename: nodename
1342 });
f992ef80 1343 win.getViewModel().set('isInstalled', isInstalled);
4616a55b
TM
1344 container.add(win);
1345 win.show();
1346 callback(win);
1347 }
1348 } else {
a7e8b87b
TL
1349 container.mask(Ext.String.format(gettext('{0} not installed.') +
1350 ' ' + gettext('Log in as root to install.'), 'Ceph'), ['pve-static-mask']);
4616a55b
TM
1351 }
1352 return true;
1353 } else {
1354 return false;
1355 }
49dfba72
DC
1356 },
1357
1358 propertyStringSet: function(target, source, name, value) {
1359 if (source) {
1360 if (value === undefined) {
1361 target[name] = source;
1362 } else {
1363 target[name] = value;
1364 }
1365 } else {
1366 delete target[name];
1367 }
bbc83309
DC
1368 },
1369
1370 updateColumns: function(container) {
f973c5b2
DC
1371 let mode = Ext.state.Manager.get('summarycolumns') || 'auto';
1372 let factor;
1373 if (mode !== 'auto') {
1374 factor = parseInt(mode, 10);
1375 if (Number.isNaN(factor)) {
1376 factor = 1;
1377 }
1378 } else {
1379 factor = container.getSize().width < 1400 ? 1 : 2;
1380 }
bbc83309
DC
1381
1382 if (container.oldFactor === factor) {
1383 return;
1384 }
1385
1386 let items = container.query('>'); // direct childs
1387 factor = Math.min(factor, items.length);
1388 container.oldFactor = factor;
1389
1390 items.forEach((item) => {
1391 item.columnWidth = 1 / factor;
1392 });
1393
1394 // we have to update the layout twice, since the first layout change
1395 // can trigger the scrollbar which reduces the amount of space left
1396 container.updateLayout();
1397 container.updateLayout();
1398 },
e65817a1
SR
1399
1400 forEachCorosyncLink: function(nodeinfo, cb) {
1401 let re = /(?:ring|link)(\d+)_addr/;
1402 Ext.iterate(nodeinfo, (prop, val) => {
1403 let match = re.exec(prop);
1404 if (match) {
1405 cb(Number(match[1]), val);
1406 }
1407 });
1408 },
e7ade592 1409},
fe4f00ad 1410
9fa2e36d
EK
1411 singleton: true,
1412 constructor: function() {
1413 var me = this;
1414 Ext.apply(me, me.utilities);
685b7aa4 1415 }
e7ade592 1416
9fa2e36d 1417});