]> git.proxmox.com Git - pve-manager.git/blame - www/manager/form/NodeSelector.js
disable animation of charts on load
[pve-manager.git] / www / manager / form / NodeSelector.js
CommitLineData
aff192e6
DM
1Ext.define('PVE.form.NodeSelector', {
2 extend: 'PVE.form.ComboGrid',
aff192e6
DM
3 alias: ['widget.PVE.form.NodeSelector'],
4
5 // invalidate nodes which are offline
6 onlineValidator: false,
7
91b0d3c2
SP
8 selectCurNode: false,
9
9a32c2de
DM
10 // only allow those nodes (array)
11 allowedNodes: undefined,
12
aff192e6
DM
13 initComponent: function() {
14 var me = this;
15
16 var store = Ext.create('Ext.data.Store', {
b193e4ac 17 fields: [ 'node', 'cpu', 'maxcpu', 'mem', 'maxmem', 'uptime' ],
aff192e6
DM
18 autoLoad: true,
19 proxy: {
20 type: 'pve',
21 url: '/api2/json/nodes'
22 },
aff192e6 23 sorters: [
a1890e22
SP
24 {
25 property : 'node',
26 direction: 'ASC'
27 },
aff192e6
DM
28 {
29 property : 'mem',
30 direction: 'DESC'
9c5a54db 31 }
aff192e6
DM
32 ]
33 });
34
35 Ext.apply(me, {
36 store: store,
b193e4ac
DM
37 valueField: 'node',
38 displayField: 'node',
aff192e6
DM
39 listConfig: {
40 columns: [
41 {
0070ee37 42 header: gettext('Node'),
b193e4ac 43 dataIndex: 'node',
a1890e22 44 sortable: true,
aff192e6
DM
45 hideable: false,
46 flex: 1
47 },
48 {
0070ee37 49 header: gettext('Memory usage'),
aff192e6 50 renderer: PVE.Utils.render_mem_usage,
a1890e22 51 sortable: true,
aff192e6
DM
52 width: 100,
53 dataIndex: 'mem'
54 },
55 {
0070ee37 56 header: gettext('CPU usage'),
aff192e6
DM
57 renderer: PVE.Utils.render_cpu,
58 sortable: true,
59 width: 100,
60 dataIndex: 'cpu'
61 }
62 ]
63 },
64 validator: function(value) {
65 /*jslint confusion: true */
66 if (!me.onlineValidator || (me.allowBlank && !value)) {
67 return true;
68 }
69
70 var offline = [];
9a32c2de
DM
71 var notAllowed = [];
72
aff192e6
DM
73 Ext.Array.each(value.split(/\s*,\s*/), function(node) {
74 var rec = me.store.findRecord(me.valueField, node);
75 if (!(rec && rec.data) || !Ext.isNumeric(rec.data.mem)) {
76 offline.push(node);
9a32c2de
DM
77 } else if (me.allowedNodes && !Ext.Array.contains(me.allowedNodes, node)) {
78 notAllowed.push(node);
79 }
aff192e6
DM
80 });
81
9a32c2de 82 if (notAllowed.length !== 0) {
541ae882 83 return "Node " + notAllowed.join(', ') + " is not allowed for this action!";
9a32c2de 84 }
aff192e6 85
9a32c2de
DM
86 if (offline.length !== 0) {
87 return "Node " + offline.join(', ') + " seems to be offline!";
88 }
89 return true;
aff192e6
DM
90 }
91 });
92
91b0d3c2 93 if (me.selectCurNode && PVE.curSelectedNode.data.node) {
04a3ef7a 94 me.preferredValue = PVE.curSelectedNode.data.node;
91b0d3c2
SP
95 }
96
aff192e6
DM
97 me.callParent();
98 }
91b0d3c2 99});