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