]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/panel/GuestStatusView.js
ui: fix align mode of two column container
[pve-manager.git] / www / manager6 / panel / GuestStatusView.js
CommitLineData
c0a14978 1Ext.define('PVE.panel.GuestStatusView', {
e3c4b75d 2 extend: 'Proxmox.panel.StatusView',
c0a14978 3 alias: 'widget.pveGuestStatusView',
e7f07a2e 4 mixins: ['Proxmox.Mixin.CBind'],
c0a14978 5
8058410f 6 cbindData: function(initialConfig) {
5ba37d7c
DC
7 var me = this;
8 return {
9 isQemu: me.pveSelNode.data.type === 'qemu',
f6710aac 10 isLxc: me.pveSelNode.data.type === 'lxc',
5ba37d7c
DC
11 };
12 },
13
b1785dbc
CH
14 controller: {
15 xclass: 'Ext.app.ViewController',
16
17 init: function(view) {
18 if (view.pveSelNode.data.type !== 'lxc') {
19 return;
20 }
21
22 const nodename = view.pveSelNode.data.node;
23 const vmid = view.pveSelNode.data.vmid;
24
25 Proxmox.Utils.API2Request({
26 url: `/api2/extjs/nodes/${nodename}/lxc/${vmid}/config`,
27 waitMsgTargetView: view,
28 method: 'GET',
29 success: ({ result }) => {
30 view.down('#unprivileged').updateValue(
31 Proxmox.Utils.format_boolean(result.data.unprivileged));
8dfdcff8 32 view.ostype = Ext.htmlEncode(result.data.ostype);
b1785dbc
CH
33 },
34 });
35 },
36 },
37
3ff9bf5a
DC
38 layout: {
39 type: 'vbox',
f6710aac 40 align: 'stretch',
3ff9bf5a
DC
41 },
42
c0a14978 43 defaults: {
c95917c2 44 xtype: 'pmxInfoWidget',
f6710aac 45 padding: '2 25',
c0a14978
DC
46 },
47 items: [
48 {
49 xtype: 'box',
f6710aac 50 height: 20,
c0a14978
DC
51 },
52 {
53 itemId: 'status',
54 title: gettext('Status'),
3ff9bf5a 55 iconCls: 'fa fa-info fa-fw',
c0a14978 56 printBar: false,
09153eaf
DC
57 multiField: true,
58 renderer: function(record) {
59 var me = this;
60 var text = record.data.status;
61 var qmpstatus = record.data.qmpstatus;
62 if (qmpstatus && qmpstatus !== record.data.status) {
63 text += ' (' + qmpstatus + ')';
64 }
65 return text;
f6710aac 66 },
c0a14978
DC
67 },
68 {
69 itemId: 'hamanaged',
3ff9bf5a 70 iconCls: 'fa fa-heartbeat fa-fw',
50713765 71 title: gettext('HA State'),
c0a14978
DC
72 printBar: false,
73 textField: 'ha',
f6710aac 74 renderer: PVE.Utils.format_ha,
c0a14978
DC
75 },
76 {
77 itemId: 'node',
3ff9bf5a 78 iconCls: 'fa fa-building fa-fw',
c0a14978 79 title: gettext('Node'),
5ba37d7c 80 cbind: {
f6710aac 81 text: '{pveSelNode.data.node}',
5ba37d7c 82 },
f6710aac 83 printBar: false,
c0a14978 84 },
b1785dbc
CH
85 {
86 itemId: 'unprivileged',
87 iconCls: 'fa fa-lock fa-fw',
88 title: gettext('Unprivileged'),
89 printBar: false,
90 cbind: {
91 hidden: '{isQemu}',
92 },
93 },
c0a14978
DC
94 {
95 xtype: 'box',
f6710aac 96 height: 15,
c0a14978
DC
97 },
98 {
99 itemId: 'cpu',
a8ea1b68 100 iconCls: 'fa fa-fw pmx-itype-icon-processor pmx-icon',
c0a14978
DC
101 title: gettext('CPU usage'),
102 valueField: 'cpu',
103 maxField: 'cpus',
1bd7bcdb 104 renderer: Proxmox.Utils.render_cpu_usage,
c0a14978
DC
105 // in this specific api call
106 // we already have the correct value for the usage
f6710aac 107 calculate: Ext.identityFn,
c0a14978
DC
108 },
109 {
110 itemId: 'memory',
a8ea1b68 111 iconCls: 'fa fa-fw pmx-itype-icon-memory pmx-icon',
c0a14978
DC
112 title: gettext('Memory usage'),
113 valueField: 'mem',
f6710aac 114 maxField: 'maxmem',
c0a14978
DC
115 },
116 {
117 itemId: 'swap',
3ff9bf5a 118 iconCls: 'fa fa-refresh fa-fw',
c0a14978
DC
119 title: gettext('SWAP usage'),
120 valueField: 'swap',
5ba37d7c
DC
121 maxField: 'maxswap',
122 cbind: {
123 hidden: '{isQemu}',
f6710aac
TL
124 disabled: '{isQemu}',
125 },
c0a14978
DC
126 },
127 {
128 itemId: 'rootfs',
3ff9bf5a 129 iconCls: 'fa fa-hdd-o fa-fw',
4198e16f 130 title: gettext('Bootdisk size'),
5ce972f6
DC
131 valueField: 'disk',
132 maxField: 'maxdisk',
c0a14978 133 printBar: false,
5ce972f6
DC
134 renderer: function(used, max) {
135 var me = this;
136 me.setPrintBar(used > 0);
137 if (used === 0) {
1bd7bcdb 138 return Proxmox.Utils.render_size(max);
5ce972f6 139 } else {
1bd7bcdb 140 return Proxmox.Utils.render_size_usage(used, max);
5ce972f6 141 }
f6710aac 142 },
e7f07a2e
DC
143 },
144 {
145 xtype: 'box',
f6710aac 146 height: 15,
e7f07a2e
DC
147 },
148 {
149 itemId: 'ips',
150 xtype: 'pveAgentIPView',
151 cbind: {
152 rstore: '{rstore}',
5ba37d7c
DC
153 pveSelNode: '{pveSelNode}',
154 hidden: '{isLxc}',
f6710aac
TL
155 disabled: '{isLxc}',
156 },
157 },
c0a14978
DC
158 ],
159
160 updateTitle: function() {
161 var me = this;
162 var uptime = me.getRecordValue('uptime');
163
164 var text = "";
165 if (Number(uptime) > 0) {
e7ade592 166 text = " (" + gettext('Uptime') + ': ' + Proxmox.Utils.format_duration_long(uptime)
c0a14978
DC
167 + ')';
168 }
169
8dfdcff8
CH
170 let title = `<div class="left-aligned">${me.getRecordValue('name') + text}</div>`;
171
172 if (me.pveSelNode.data.type === 'lxc' && me.ostype && me.ostype !== 'unmanaged') {
173 // Manual mappings for distros with special casing
174 const namemap = {
175 'archlinux': 'Arch Linux',
176 'nixos': 'NixOS',
177 'opensuse': 'openSUSE',
178 'centos': 'CentOS',
179 };
180
181 const distro = namemap[me.ostype] ?? Ext.String.capitalize(me.ostype);
182 title += `<div class="right-aligned">
183 <i class="fl-${me.ostype} fl-fw"></i>&nbsp;${distro}</div>`;
184 }
185
186 me.setTitle(title);
f6710aac 187 },
c0a14978 188});