]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/dc/Summary.js
1 Ext
.define('PVE.dc.Summary', {
2 extend
: 'Ext.panel.Panel',
3 alias
: 'widget.pveDcSummary',
26 title
: gettext('Resources'),
32 xtype
: 'proxmoxGauge',
37 title
: gettext('CPU'),
41 title
: gettext('Memory'),
45 title
: gettext('Storage'),
52 xtype
: 'pveDcNodeView',
56 title
: gettext('Subscriptions'),
60 itemId
: 'subscriptions',
61 xtype
: 'pveHealthWidget',
66 if (this.component
.userCls
=== 'pointer') {
67 window
.open('https://www.proxmox.com/en/proxmox-ve/pricing', '_blank');
77 resize: function(panel
) {
78 PVE
.Utils
.updateColumns(panel
);
82 initComponent: function() {
85 var rstore
= Ext
.create('Proxmox.data.UpdateStore', {
87 storeid
: 'pve-cluster-status',
88 model
: 'pve-dc-nodes',
91 url
: "/api2/json/cluster/status",
95 var gridstore
= Ext
.create('Proxmox.data.DiffStore', {
109 me
.getComponent('nodeview').setStore(gridstore
);
111 var gueststatus
= me
.getComponent('dcGuests');
113 var cpustat
= me
.down('#cpu');
114 var memorystat
= me
.down('#memory');
115 var storagestat
= me
.down('#storage');
116 var sp
= Ext
.state
.Manager
.getProvider();
118 me
.mon(PVE
.data
.ResourceStore
, 'load', function(curstore
, results
) {
119 me
.suspendLayout
= true;
129 var countedStorages
= {};
132 var usableStorages
= {};
133 var storages
= sp
.get('dash-storages') || '';
134 storages
.split(',').forEach(function(storage
) {
135 if (storage
!== '') {
136 usableStorages
[storage
] = true;
156 for (i
= 0; i
< results
.length
; i
++) {
157 var item
= results
[i
];
158 switch (item
.data
.type
) {
160 cpu
+= item
.data
.cpu
* item
.data
.maxcpu
;
161 maxcpu
+= item
.data
.maxcpu
|| 0;
162 memory
+= item
.data
.mem
|| 0;
163 maxmem
+= item
.data
.maxmem
|| 0;
167 var griditem
= gridstore
.getById(item
.data
.id
);
169 griditem
.set('cpuusage', item
.data
.cpu
);
170 var max
= item
.data
.maxmem
|| 1;
171 var val
= item
.data
.mem
|| 0;
172 griditem
.set('memoryusage', val
/max
);
173 griditem
.set('uptime', item
.data
.uptime
);
174 griditem
.commit(); //else it marks the fields as dirty
178 if (!Ext
.Object
.isEmpty(usableStorages
)) {
179 if (usableStorages
[item
.data
.id
] === true) {
180 used
+= item
.data
.disk
;
181 total
+= item
.data
.maxdisk
;
185 if (!countedStorages
[item
.data
.storage
] ||
186 !item
.data
.shared
&& !countedStorages
[item
.data
.id
]) {
187 used
+= item
.data
.disk
;
188 total
+= item
.data
.maxdisk
;
190 countedStorages
[item
.data
.storage
=== 'local'?item
.data
.id
:item
.data
.storage
] = true;
194 qemu
[item
.data
.template
? 'template' : item
.data
.status
]++;
195 if (item
.data
.hastate
=== 'error') {
200 lxc
[item
.data
.template
? 'template' : item
.data
.status
]++;
201 if (item
.data
.hastate
=== 'error') {
209 var text
= Ext
.String
.format(gettext('of {0} CPU(s)'), maxcpu
);
210 cpustat
.updateValue(cpu
/maxcpu
, text
);
212 text
= Ext
.String
.format(gettext('{0} of {1}'), Proxmox
.Utils
.render_size(memory
), Proxmox
.Utils
.render_size(maxmem
));
213 memorystat
.updateValue(memory
/maxmem
, text
);
215 text
= Ext
.String
.format(gettext('{0} of {1}'), Proxmox
.Utils
.render_size(used
), Proxmox
.Utils
.render_size(total
));
216 storagestat
.updateValue(used
/total
, text
);
218 gueststatus
.updateValues(qemu
, lxc
, error
);
220 me
.suspendLayout
= false;
221 me
.updateLayout(true);
224 var dcHealth
= me
.getComponent('dcHealth');
225 me
.mon(rstore
, 'load', dcHealth
.updateStatus
, dcHealth
);
227 var subs
= me
.down('#subscriptions');
228 me
.mon(rstore
, 'load', function(store
, records
, success
) {
232 for (i
= 0; i
< records
.length
; i
++) {
233 if (records
[i
].get('type') !== 'node') {
236 var node
= records
[i
];
237 if (node
.get('status') === 'offline') {
241 var curlevel
= node
.get('level');
243 if (curlevel
=== '') { // no subscription trumps all, set and break
248 if (level
=== undefined) { // save level
250 } else if (level
!== curlevel
) { // detect different levels
256 title
: Proxmox
.Utils
.unknownText
,
257 text
: Proxmox
.Utils
.unknownText
,
258 iconCls
: PVE
.Utils
.get_health_icon(undefined, true),
262 title
: gettext('No Subscription'),
263 iconCls
: PVE
.Utils
.get_health_icon('critical', true),
264 text
: gettext('You have at least one node without subscription.'),
266 subs
.setUserCls('pointer');
269 title
: gettext('Mixed Subscriptions'),
270 iconCls
: PVE
.Utils
.get_health_icon('warning', true),
271 text
: gettext('Warning: Your subscription levels are not the same.'),
273 subs
.setUserCls('pointer');
276 title
: PVE
.Utils
.render_support_level(level
),
277 iconCls
: PVE
.Utils
.get_health_icon('good', true),
278 text
: gettext('Your subscription status is valid.'),
286 me
.on('destroy', function() {
290 me
.mon(sp
, 'statechange', function(provider
, key
, value
) {
291 if (key
!== 'summarycolumns') {
294 PVE
.Utils
.updateColumns(me
);
297 rstore
.startUpdate();