]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/dc/Summary.js
091ece7698396b4a7c38b7f265437561c010a7d2
1 Ext
.define('PVE.dc.Summary', {
2 extend
: 'Ext.panel.Panel',
3 alias
: 'widget.pveDcSummary',
13 plugins
: 'responsive',
34 title
: gettext('Resources'),
40 xtype
: 'proxmoxGauge',
45 title
: gettext('CPU'),
49 title
: gettext('Memory'),
53 title
: gettext('Storage'),
60 xtype
: 'pveDcNodeView',
64 title
: gettext('Subscriptions'),
68 itemId
: 'subscriptions',
69 xtype
: 'pveHealthWidget',
74 if (this.component
.userCls
=== 'pointer') {
75 window
.open('https://www.proxmox.com/en/proxmox-ve/pricing', '_blank');
84 initComponent: function() {
87 var rstore
= Ext
.create('Proxmox.data.UpdateStore', {
89 storeid
: 'pve-cluster-status',
90 model
: 'pve-dc-nodes',
93 url
: "/api2/json/cluster/status"
97 var gridstore
= Ext
.create('Proxmox.data.DiffStore', {
111 me
.getComponent('nodeview').setStore(gridstore
);
113 var gueststatus
= me
.getComponent('dcGuests');
115 var cpustat
= me
.down('#cpu');
116 var memorystat
= me
.down('#memory');
117 var storagestat
= me
.down('#storage');
118 var sp
= Ext
.state
.Manager
.getProvider();
120 me
.mon(PVE
.data
.ResourceStore
, 'load', function(curstore
, results
) {
121 me
.suspendLayout
= true;
131 var countedStorages
= {};
134 var usableStorages
= {};
135 var storages
= sp
.get('dash-storages') || '';
136 storages
.split(',').forEach(function(storage
){
137 if (storage
!== '') {
138 usableStorages
[storage
] = true;
158 for (i
= 0; i
< results
.length
; i
++) {
159 var item
= results
[i
];
160 switch(item
.data
.type
) {
162 cpu
+= (item
.data
.cpu
* item
.data
.maxcpu
);
163 maxcpu
+= item
.data
.maxcpu
|| 0;
164 memory
+= item
.data
.mem
|| 0;
165 maxmem
+= item
.data
.maxmem
|| 0;
169 var griditem
= gridstore
.getById(item
.data
.id
);
171 griditem
.set('cpuusage', item
.data
.cpu
);
172 var max
= item
.data
.maxmem
|| 1;
173 var val
= item
.data
.mem
|| 0;
174 griditem
.set('memoryusage', val
/max
);
175 griditem
.set('uptime', item
.data
.uptime
);
176 griditem
.commit(); //else it marks the fields as dirty
180 if (!Ext
.Object
.isEmpty(usableStorages
)) {
181 if (usableStorages
[item
.data
.id
] === true) {
182 used
+= item
.data
.disk
;
183 total
+= item
.data
.maxdisk
;
187 if (!countedStorages
[item
.data
.storage
] ||
188 (item
.data
.storage
=== 'local' &&
189 !countedStorages
[item
.data
.id
])) {
190 used
+= item
.data
.disk
;
191 total
+= item
.data
.maxdisk
;
193 countedStorages
[item
.data
.storage
=== 'local'?item
.data
.id
:item
.data
.storage
] = true;
197 qemu
[item
.data
.template
? 'template' : item
.data
.status
]++;
198 if (item
.data
.hastate
=== 'error') {
203 lxc
[item
.data
.template
? 'template' : item
.data
.status
]++;
204 if (item
.data
.hastate
=== 'error') {
212 var text
= Ext
.String
.format(gettext('of {0} CPU(s)'), maxcpu
);
213 cpustat
.updateValue((cpu
/maxcpu
), text
);
215 text
= Ext
.String
.format(gettext('{0} of {1}'), PVE
.Utils
.render_size(memory
), PVE
.Utils
.render_size(maxmem
));
216 memorystat
.updateValue((memory
/maxmem
), text
);
218 text
= Ext
.String
.format(gettext('{0} of {1}'), PVE
.Utils
.render_size(used
), PVE
.Utils
.render_size(total
));
219 storagestat
.updateValue((used
/total
), text
);
221 gueststatus
.updateValues(qemu
,lxc
,error
);
223 me
.suspendLayout
= false;
224 me
.updateLayout(true);
227 var dcHealth
= me
.getComponent('dcHealth');
228 me
.mon(rstore
, 'load', dcHealth
.updateStatus
, dcHealth
);
230 var subs
= me
.down('#subscriptions');
231 me
.mon(rstore
, 'load', function(store
, records
, success
) {
235 for (i
= 0; i
< records
.length
; i
++) {
236 if (records
[i
].get('type') !== 'node') {
240 curlevel
= records
[i
].get('level');
241 if (level
=== undefined || !curlevel
) {
246 if (level
!== curlevel
) {
253 title
: gettext('No Subscription'),
254 iconCls
: PVE
.Utils
.get_health_icon('critical', true),
255 text
: gettext('You have at least one node without subscription.')
257 subs
.setUserCls('pointer');
258 } else if (level
!== curlevel
) {
260 title
: gettext('Mixed Subscriptions'),
261 iconCls
: PVE
.Utils
.get_health_icon('warning', true),
262 text
: gettext('Warning: Your subscription levels are not the same.')
264 subs
.setUserCls('pointer');
267 title
: PVE
.Utils
.render_support_level(level
),
268 iconCls
: PVE
.Utils
.get_health_icon('good', true),
269 text
: gettext('Your subscription status is valid.')
275 me
.on('destroy', function(){
279 rstore
.startUpdate();