]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/panel/GuestStatusView.js
make GuestStatusView declarative
[pve-manager.git] / www / manager6 / panel / GuestStatusView.js
1 Ext.define('PVE.panel.GuestStatusView', {
2 extend: 'PVE.panel.StatusView',
3 alias: 'widget.pveGuestStatusView',
4 mixins: ['Proxmox.Mixin.CBind'],
5
6 height: 300,
7
8 cbindData: function (initialConfig) {
9 var me = this;
10 return {
11 isQemu: me.pveSelNode.data.type === 'qemu',
12 isLxc: me.pveSelNode.data.type === 'lxc'
13 };
14 },
15
16 layout: {
17 type: 'vbox',
18 align: 'stretch'
19 },
20
21 defaults: {
22 xtype: 'pveInfoWidget',
23 padding: '2 25'
24 },
25 items: [
26 {
27 xtype: 'box',
28 height: 20
29 },
30 {
31 itemId: 'status',
32 title: gettext('Status'),
33 iconCls: 'fa fa-info fa-fw',
34 printBar: false,
35 textField: 'status'
36 },
37 {
38 itemId: 'hamanaged',
39 iconCls: 'fa fa-heartbeat fa-fw',
40 title: gettext('HA State'),
41 printBar: false,
42 textField: 'ha',
43 renderer: PVE.Utils.format_ha
44 },
45 {
46 xtype: 'pveInfoWidget',
47 itemId: 'node',
48 iconCls: 'fa fa-building fa-fw',
49 title: gettext('Node'),
50 cbind: {
51 text: '{pveSelNode.data.node}'
52 },
53 printBar: false
54 },
55 {
56 xtype: 'box',
57 height: 15
58 },
59 {
60 itemId: 'cpu',
61 iconCls: 'fa fa-fw pve-itype-icon-processor pve-icon',
62 title: gettext('CPU usage'),
63 valueField: 'cpu',
64 maxField: 'cpus',
65 renderer: PVE.Utils.render_cpu_usage,
66 // in this specific api call
67 // we already have the correct value for the usage
68 calculate: Ext.identityFn
69 },
70 {
71 itemId: 'memory',
72 iconCls: 'fa fa-fw pve-itype-icon-memory pve-icon',
73 title: gettext('Memory usage'),
74 valueField: 'mem',
75 maxField: 'maxmem'
76 },
77 {
78 itemId: 'swap',
79 xtype: 'pveInfoWidget',
80 iconCls: 'fa fa-refresh fa-fw',
81 title: gettext('SWAP usage'),
82 valueField: 'swap',
83 maxField: 'maxswap',
84 cbind: {
85 hidden: '{isQemu}',
86 disabled: '{isQemu}'
87 }
88 },
89 {
90 itemId: 'rootfs',
91 iconCls: 'fa fa-hdd-o fa-fw',
92 title: gettext('Bootdisk size'),
93 valueField: 'disk',
94 maxField: 'maxdisk',
95 printBar: false,
96 renderer: function(used, max) {
97 var me = this;
98 me.setPrintBar(used > 0);
99 if (used === 0) {
100 return PVE.Utils.render_size(max);
101 } else {
102 return PVE.Utils.render_size_usage(used,max);
103 }
104 }
105 },
106 {
107 xtype: 'box',
108 height: 15
109 },
110 {
111 itemId: 'ips',
112 xtype: 'pveAgentIPView',
113 cbind: {
114 rstore: '{rstore}',
115 pveSelNode: '{pveSelNode}',
116 hidden: '{isLxc}',
117 disabled: '{isLxc}'
118 }
119 }
120 ],
121
122 updateTitle: function() {
123 var me = this;
124 var uptime = me.getRecordValue('uptime');
125
126 var text = "";
127 if (Number(uptime) > 0) {
128 text = " (" + gettext('Uptime') + ': ' + Proxmox.Utils.format_duration_long(uptime)
129 + ')';
130 }
131
132 me.setTitle(me.getRecordValue('name') + text);
133 }
134 });