]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/panel/GuestSummary.js
ui: use byte unit and power-of-two base for memory rrd graphs
[pve-manager.git] / www / manager6 / panel / GuestSummary.js
CommitLineData
426d7f74
DM
1Ext.define('PVE.qemu.Summary', {
2 extend: 'Ext.panel.Panel',
df0875c2 3 xtype: 'pveGuestSummary',
426d7f74 4
6f68dcbe 5 scrollable: true,
33f459ca 6 bodyPadding: 5,
64ff6a19 7
426d7f74
DM
8 initComponent: function() {
9 var me = this;
10
11 var nodename = me.pveSelNode.data.node;
12 if (!nodename) {
13 throw "no node name specified";
14 }
15
16 var vmid = me.pveSelNode.data.vmid;
17 if (!vmid) {
18 throw "no VM ID specified";
19 }
20
21 if (!me.workspace) {
22 throw "no workspace specified";
23 }
24
25 if (!me.statusStore) {
26 throw "no status storage specified";
27 }
28
df0875c2 29 var type = me.pveSelNode.data.type;
a4d292d9 30 var template = !!me.pveSelNode.data.template;
426d7f74
DM
31 var rstore = me.statusStore;
32
33f459ca
DC
33 var items = [
34 {
35 xtype: template ? 'pveTemplateStatusView' : 'pveGuestStatusView',
bbc83309
DC
36 flex: 1,
37 padding: template ? '5' : '0 5 0 0',
33f459ca
DC
38 itemId: 'gueststatus',
39 pveSelNode: me.pveSelNode,
f6710aac 40 rstore: rstore,
33f459ca
DC
41 },
42 {
43 xtype: 'pveNotesView',
bbc83309
DC
44 flex: 1,
45 padding: template ? '5' : '0 0 0 5',
33f459ca
DC
46 itemId: 'notesview',
47 pveSelNode: me.pveSelNode,
bbc83309 48 },
33f459ca
DC
49 ];
50
51 var rrdstore;
52 if (!template) {
bbc83309
DC
53 // in non-template mode put the two panels always together
54 items = [
55 {
56 xtype: 'container',
57 layout: {
58 type: 'hbox',
59 align: 'stretch',
60 },
f6710aac
TL
61 items: items,
62 },
bbc83309
DC
63 ];
64
33f459ca 65 rrdstore = Ext.create('Proxmox.data.RRDStore', {
df0875c2 66 rrdurl: `/api2/json/nodes/${nodename}/${type}/${vmid}/rrddata`,
f6710aac 67 model: 'pve-rrd-guest',
a4d292d9
DC
68 });
69
33f459ca
DC
70 items.push(
71 {
72 xtype: 'proxmoxRRDChart',
73 title: gettext('CPU usage'),
74 pveSelNode: me.pveSelNode,
75 fields: ['cpu'],
76 fieldTitles: [gettext('CPU usage')],
f6710aac 77 store: rrdstore,
a4d292d9 78 },
33f459ca
DC
79 {
80 xtype: 'proxmoxRRDChart',
81 title: gettext('Memory usage'),
82 pveSelNode: me.pveSelNode,
83 fields: ['maxmem', 'mem'],
84 fieldTitles: [gettext('Total'), gettext('RAM usage')],
e67d454a
TL
85 unit: 'bytes',
86 powerOfTwo: true,
f6710aac 87 store: rrdstore,
33f459ca
DC
88 },
89 {
90 xtype: 'proxmoxRRDChart',
91 title: gettext('Network traffic'),
92 pveSelNode: me.pveSelNode,
f6710aac
TL
93 fields: ['netin', 'netout'],
94 store: rrdstore,
33f459ca
DC
95 },
96 {
97 xtype: 'proxmoxRRDChart',
98 title: gettext('Disk IO'),
99 pveSelNode: me.pveSelNode,
f6710aac
TL
100 fields: ['diskread', 'diskwrite'],
101 store: rrdstore,
102 },
33f459ca 103 );
a4d292d9 104 }
426d7f74 105
33f459ca 106 Ext.apply(me, {
8058410f 107 tbar: ['->', { xtype: 'proxmoxRRDTypeSelector' }],
33f459ca
DC
108 items: [
109 {
110 xtype: 'container',
bbc83309 111 itemId: 'itemcontainer',
33f459ca 112 layout: {
f6710aac 113 type: 'column',
33f459ca 114 },
ed3e711e 115 minWidth: 700,
33f459ca
DC
116 defaults: {
117 minHeight: 330,
118 padding: 5,
33f459ca 119 },
bbc83309
DC
120 items: items,
121 listeners: {
122 resize: function(container) {
123 PVE.Utils.updateColumns(container);
f6710aac
TL
124 },
125 },
126 },
127 ],
33f459ca
DC
128 });
129
426d7f74 130 me.callParent();
33f459ca
DC
131 if (!template) {
132 rrdstore.startUpdate();
133 me.on('destroy', rrdstore.stopUpdate);
134 }
f973c5b2
DC
135 let sp = Ext.state.Manager.getProvider();
136 me.mon(sp, 'statechange', function(provider, key, value) {
137 if (key !== 'summarycolumns') {
138 return;
139 }
140 PVE.Utils.updateColumns(me.getComponent('itemcontainer'));
141 });
f6710aac 142 },
426d7f74 143});