]>
Commit | Line | Data |
---|---|---|
a5c093b1 | 1 | Ext.define('PVE.node.StatusView', { |
e3c4b75d | 2 | extend: 'Proxmox.panel.StatusView', |
cb892fb3 | 3 | alias: 'widget.pveNodeStatus', |
a5c093b1 | 4 | |
2bb75d1e FE |
5 | viewModel: { |
6 | data: { | |
7 | subscriptionActive: '', | |
8 | noSubscriptionRepo: '', | |
9 | enterpriseRepo: '', | |
10 | testRepo: '', | |
11 | }, | |
12 | formulas: { | |
13 | repoStatus: function(get) { | |
bcfcf87b | 14 | if (get('subscriptionActive') === '' || get('enterpriseRepo') === '') { |
2bb75d1e FE |
15 | return ''; |
16 | } | |
17 | ||
18 | if (!get('subscriptionActive') && get('enterpriseRepo')) { | |
19 | return 'no-sub'; | |
bcfcf87b | 20 | } else if (get('noSubscriptionRepo') || get('testRepo')) { |
2bb75d1e | 21 | return 'non-production'; |
bcfcf87b | 22 | } else if (!get('enterpriseRepo') || !get('noSubscriptionRepo') || !get('testRepo')) { |
2bb75d1e FE |
23 | return 'no-repo'; |
24 | } | |
2bb75d1e FE |
25 | return 'ok'; |
26 | }, | |
27 | repoStatusMessage: function(get) { | |
28 | const status = get('repoStatus'); | |
29 | ||
bcfcf87b | 30 | let fmt = (txt, cls) => `<i class="fa fa-fw fa-${cls}"></i> ${txt}`; |
2bb75d1e FE |
31 | |
32 | if (status === 'ok') { | |
bcfcf87b TL |
33 | return fmt(gettext('Enterprise repository enabled'), 'check good') + ', ' + |
34 | fmt(gettext('Active subscription'), 'check good'); | |
2bb75d1e | 35 | } else if (status === 'no-sub') { |
bcfcf87b TL |
36 | return fmt(gettext('Enterprise repository enabled'), 'check good') + ', ' + |
37 | fmt(gettext('No active subscription'), 'exclamation-circle warning'); | |
2bb75d1e | 38 | } else if (status === 'non-production') { |
bcfcf87b | 39 | return fmt(gettext('No production-ready repository used'), 'exclamation-circle warning'); |
2bb75d1e | 40 | } else if (status === 'no-repo') { |
bcfcf87b | 41 | return fmt(gettext('No Proxmox VE repository enabled!'), 'exclamation-circle critical'); |
2bb75d1e FE |
42 | } |
43 | ||
bcfcf87b | 44 | return Proxmox.Utils.unknownText; |
2bb75d1e FE |
45 | }, |
46 | }, | |
47 | }, | |
48 | ||
cb892fb3 | 49 | height: 300, |
7ec884ca | 50 | bodyPadding: '20 15 20 15', |
a5c093b1 | 51 | |
701acf20 DC |
52 | layout: { |
53 | type: 'table', | |
54 | columns: 2, | |
55 | tableAttrs: { | |
56 | style: { | |
f6710aac TL |
57 | width: '100%', |
58 | }, | |
59 | }, | |
701acf20 DC |
60 | }, |
61 | ||
cb892fb3 | 62 | defaults: { |
c95917c2 | 63 | xtype: 'pmxInfoWidget', |
f6710aac | 64 | padding: '0 15 5 15', |
cb892fb3 | 65 | }, |
a5c093b1 | 66 | |
cb892fb3 | 67 | items: [ |
cb892fb3 DC |
68 | { |
69 | itemId: 'cpu', | |
a8ea1b68 | 70 | iconCls: 'fa fa-fw pmx-itype-icon-processor pmx-icon', |
cb892fb3 DC |
71 | title: gettext('CPU usage'), |
72 | valueField: 'cpu', | |
73 | maxField: 'cpuinfo', | |
1bd7bcdb | 74 | renderer: Proxmox.Utils.render_node_cpu_usage, |
cb892fb3 DC |
75 | }, |
76 | { | |
77 | itemId: 'wait', | |
3ff9bf5a | 78 | iconCls: 'fa fa-fw fa-clock-o', |
cb892fb3 | 79 | title: gettext('IO delay'), |
701acf20 | 80 | valueField: 'wait', |
f6710aac | 81 | rowspan: 2, |
cb892fb3 DC |
82 | }, |
83 | { | |
84 | itemId: 'load', | |
3ff9bf5a | 85 | iconCls: 'fa fa-fw fa-tasks', |
cb892fb3 DC |
86 | title: gettext('Load average'), |
87 | printBar: false, | |
f6710aac | 88 | textField: 'loadavg', |
cb892fb3 DC |
89 | }, |
90 | { | |
91 | xtype: 'box', | |
701acf20 | 92 | colspan: 2, |
f6710aac | 93 | padding: '0 0 20 0', |
cb892fb3 DC |
94 | }, |
95 | { | |
a8ea1b68 | 96 | iconCls: 'fa fa-fw pmx-itype-icon-memory pmx-icon', |
cb892fb3 DC |
97 | itemId: 'memory', |
98 | title: gettext('RAM usage'), | |
99 | valueField: 'memory', | |
100 | maxField: 'memory', | |
1bd7bcdb | 101 | renderer: Proxmox.Utils.render_node_size_usage, |
cb892fb3 DC |
102 | }, |
103 | { | |
104 | itemId: 'ksm', | |
105 | printBar: false, | |
106 | title: gettext('KSM sharing'), | |
107 | textField: 'ksm', | |
108 | renderer: function(record) { | |
1bd7bcdb | 109 | return Proxmox.Utils.render_size(record.shared); |
cb892fb3 | 110 | }, |
f6710aac | 111 | padding: '0 15 10 15', |
cb892fb3 DC |
112 | }, |
113 | { | |
3ff9bf5a | 114 | iconCls: 'fa fa-fw fa-hdd-o', |
cb892fb3 DC |
115 | itemId: 'rootfs', |
116 | title: gettext('HD space') + '(root)', | |
117 | valueField: 'rootfs', | |
118 | maxField: 'rootfs', | |
1bd7bcdb | 119 | renderer: Proxmox.Utils.render_node_size_usage, |
cb892fb3 DC |
120 | }, |
121 | { | |
3ff9bf5a | 122 | iconCls: 'fa fa-fw fa-refresh', |
cb892fb3 DC |
123 | itemId: 'swap', |
124 | printSize: true, | |
125 | title: gettext('SWAP usage'), | |
126 | valueField: 'swap', | |
127 | maxField: 'swap', | |
1bd7bcdb | 128 | renderer: Proxmox.Utils.render_node_size_usage, |
cb892fb3 DC |
129 | }, |
130 | { | |
131 | xtype: 'box', | |
701acf20 | 132 | colspan: 2, |
f6710aac | 133 | padding: '0 0 20 0', |
cb892fb3 DC |
134 | }, |
135 | { | |
136 | itemId: 'cpus', | |
701acf20 | 137 | colspan: 2, |
cb892fb3 | 138 | printBar: false, |
4198e16f | 139 | title: gettext('CPU(s)'), |
cb892fb3 | 140 | textField: 'cpuinfo', |
1bd7bcdb | 141 | renderer: Proxmox.Utils.render_cpu_model, |
f6710aac | 142 | value: '', |
cb892fb3 DC |
143 | }, |
144 | { | |
145 | itemId: 'kversion', | |
701acf20 | 146 | colspan: 2, |
cb892fb3 DC |
147 | title: gettext('Kernel Version'), |
148 | printBar: false, | |
149 | textField: 'kversion', | |
f6710aac | 150 | value: '', |
cb892fb3 DC |
151 | }, |
152 | { | |
153 | itemId: 'version', | |
701acf20 | 154 | colspan: 2, |
cb892fb3 DC |
155 | printBar: false, |
156 | title: gettext('PVE Manager Version'), | |
157 | textField: 'pveversion', | |
f6710aac TL |
158 | value: '', |
159 | }, | |
2bb75d1e FE |
160 | { |
161 | itemId: 'repositoryStatus', | |
162 | colspan: 2, | |
163 | printBar: false, | |
bcfcf87b | 164 | title: gettext('Repository Status'), |
2bb75d1e FE |
165 | // for bind |
166 | setValue: function(value) { | |
167 | let me = this; | |
168 | me.updateValue(value); | |
169 | }, | |
170 | bind: { | |
2bb75d1e FE |
171 | value: '{repoStatusMessage}', |
172 | }, | |
173 | }, | |
cb892fb3 | 174 | ], |
a5c093b1 | 175 | |
cb892fb3 DC |
176 | updateTitle: function() { |
177 | var me = this; | |
e7ade592 | 178 | var uptime = Proxmox.Utils.render_uptime(me.getRecordValue('uptime')); |
cb892fb3 | 179 | me.setTitle(me.pveSelNode.data.node + ' (' + gettext('Uptime') + ': ' + uptime + ')'); |
f6710aac | 180 | }, |
cb892fb3 | 181 | |
2bb75d1e FE |
182 | setRepositoryInfo: function(standardRepos) { |
183 | let me = this; | |
184 | let vm = me.getViewModel(); | |
185 | ||
186 | for (const standardRepo of standardRepos) { | |
187 | const handle = standardRepo.handle; | |
188 | const status = standardRepo.status; | |
189 | ||
190 | if (handle === "enterprise") { | |
191 | vm.set('enterpriseRepo', status); | |
192 | } else if (handle === "no-subscription") { | |
193 | vm.set('noSubscriptionRepo', status); | |
194 | } else if (handle === "test") { | |
195 | vm.set('testRepo', status); | |
196 | } | |
197 | } | |
198 | }, | |
199 | ||
200 | setSubscriptionStatus: function(status) { | |
201 | let me = this; | |
202 | let vm = me.getViewModel(); | |
203 | ||
204 | vm.set('subscriptionActive', status); | |
205 | }, | |
a5c093b1 | 206 | }); |