]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/dc/Summary.js
add pveceph install to shell api
[pve-manager.git] / www / manager6 / dc / Summary.js
CommitLineData
7c53ee24
DM
1Ext.define('PVE.dc.Summary', {
2 extend: 'Ext.panel.Panel',
cf8b372a 3 alias: 'widget.pveDcSummary',
7c53ee24 4
cf8b372a
DC
5 scrollable: true,
6
5da98a05 7 bodyPadding: 5,
cf8b372a
DC
8
9 layout: 'column',
10
11 defaults: {
5da98a05
DC
12 padding: 5,
13 plugins: 'responsive',
14 responsiveConfig: {
15 'width < 1900': {
16 columnWidth: 1
17 },
18 'width >= 1900': {
19 columnWidth: 0.5
20 }
21 }
cf8b372a
DC
22 },
23
24 items: [
50a1eb7d
DC
25 {
26 itemId: 'dcHealth',
27 xtype: 'pveDcHealth'
28 },
29 {
30 itemId: 'dcGuests',
31 xtype: 'pveDcGuests'
32 },
33 {
8f8ec25d 34 title: gettext('Resources'),
50a1eb7d 35 xtype: 'panel',
5da98a05
DC
36 minHeight: 250,
37 bodyPadding: 5,
701acf20 38 layout: 'hbox',
50a1eb7d 39 defaults: {
5683fb60 40 xtype: 'proxmoxGauge',
701acf20 41 flex: 1
50a1eb7d
DC
42 },
43 items:[
44 {
45 title: gettext('CPU'),
46 itemId: 'cpu'
47 },
48 {
49 title: gettext('Memory'),
50 itemId: 'memory'
51 },
52 {
53 title: gettext('Storage'),
54 itemId: 'storage'
55 }
56 ]
57 },
cf8b372a
DC
58 {
59 itemId: 'nodeview',
60 xtype: 'pveDcNodeView',
61 height: 250
62 }
63 ],
7c53ee24
DM
64
65 initComponent: function() {
66 var me = this;
67
0c7c0d6b 68 var rstore = Ext.create('Proxmox.data.UpdateStore', {
cf8b372a
DC
69 interval: 3000,
70 storeid: 'pve-cluster-status',
71 model: 'pve-dc-nodes',
72 proxy: {
56a353b9 73 type: 'proxmox',
cf8b372a
DC
74 url: "/api2/json/cluster/status"
75 }
7c53ee24
DM
76 });
77
eaa018d7 78 var gridstore = Ext.create('Proxmox.data.DiffStore', {
cf8b372a
DC
79 rstore: rstore,
80 filters: {
81 property: 'type',
82 value: 'node'
83 },
84 sorters: {
85 property: 'id',
86 direction: 'ASC'
7c53ee24
DM
87 }
88 });
89
90 me.callParent();
cf8b372a
DC
91
92 me.getComponent('nodeview').setStore(gridstore);
93
50a1eb7d
DC
94 var gueststatus = me.getComponent('dcGuests');
95
96 var cpustat = me.down('#cpu');
97 var memorystat = me.down('#memory');
98 var storagestat = me.down('#storage');
0d1c1267 99 var sp = Ext.state.Manager.getProvider();
50a1eb7d
DC
100
101 me.mon(PVE.data.ResourceStore, 'load', function(curstore, results) {
102 me.suspendLayout = true;
103
104 var cpu = 0;
105 var maxcpu = 0;
106
107 var nodes = 0;
108
109 var memory = 0;
110 var maxmem = 0;
111
112 var countedStorages = {};
113 var used = 0;
114 var total = 0;
0d1c1267
DC
115 var usableStorages = {};
116 var storages = sp.get('dash-storages') || '';
117 storages.split(',').forEach(function(storage){
118 if (storage !== '') {
119 usableStorages[storage] = true;
120 }
121 });
50a1eb7d
DC
122
123 var qemu = {
124 running: 0,
125 paused: 0,
126 stopped: 0,
127 template: 0
128 };
129 var lxc = {
130 running: 0,
131 paused: 0,
132 stopped: 0,
133 template: 0
134 };
135 var error = 0;
136
137 var i;
138
139 for (i = 0; i < results.length; i++) {
140 var item = results[i];
141 switch(item.data.type) {
142 case 'node':
143 cpu += (item.data.cpu * item.data.maxcpu);
144 maxcpu += item.data.maxcpu || 0;
145 memory += item.data.mem || 0;
146 maxmem += item.data.maxmem || 0;
147 nodes++;
148
149 // update grid also
150 var griditem = gridstore.getById(item.data.id);
151 if (griditem) {
152 griditem.set('cpuusage', item.data.cpu);
153 var max = item.data.maxmem || 1;
154 var val = item.data.mem || 0;
155 griditem.set('memoryusage', val/max);
156 griditem.set('uptime', item.data.uptime);
157 griditem.commit(); //else it marks the fields as dirty
158 }
159 break;
160 case 'storage':
0d1c1267
DC
161 if (!Ext.Object.isEmpty(usableStorages)) {
162 if (usableStorages[item.data.id] === true) {
163 used += item.data.disk;
164 total += item.data.maxdisk;
165 }
166 break;
167 }
50a1eb7d
DC
168 if (!countedStorages[item.data.storage] ||
169 (item.data.storage === 'local' &&
170 !countedStorages[item.data.id])) {
171 used += item.data.disk;
172 total += item.data.maxdisk;
173
174 countedStorages[item.data.storage === 'local'?item.data.id:item.data.storage] = true;
175 }
176 break;
177 case 'qemu':
178 qemu[item.data.template ? 'template' : item.data.status]++;
179 if (item.data.hastate === 'error') {
180 error++;
181 }
182 break;
183 case 'lxc':
184 lxc[item.data.template ? 'template' : item.data.status]++;
185 if (item.data.hastate === 'error') {
186 error++;
187 }
188 break;
189 default: break;
190 }
191 }
192
193 var text = Ext.String.format(gettext('of {0} CPU(s)'), maxcpu);
194 cpustat.updateValue((cpu/maxcpu), text);
195
196 text = Ext.String.format(gettext('{0} of {1}'), PVE.Utils.render_size(memory), PVE.Utils.render_size(maxmem));
197 memorystat.updateValue((memory/maxmem), text);
198
199 text = Ext.String.format(gettext('{0} of {1}'), PVE.Utils.render_size(used), PVE.Utils.render_size(total));
200 storagestat.updateValue((used/total), text);
201
202 gueststatus.updateValues(qemu,lxc,error);
203
204 me.suspendLayout = false;
205 me.updateLayout(true);
206 });
207
208 var dcHealth = me.getComponent('dcHealth');
209 me.mon(rstore, 'load', dcHealth.updateStatus, dcHealth);
210
cf8b372a
DC
211 me.on('destroy', function(){
212 rstore.stopUpdate();
213 });
214
215 rstore.startUpdate();
7c53ee24 216 }
50a1eb7d 217
7c53ee24 218});