]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/dc/Health.js
1 Ext
.define('PVE.dc.Health', {
2 extend
: 'Ext.panel.Panel',
3 alias
: 'widget.pveDcHealth',
5 title
: gettext('Health'),
18 'text-align': 'center',
25 updateStatus: function(store
, records
, success
) {
32 iconCls
: PVE
.Utils
.get_health_icon('good', true),
33 text
: gettext("Standalone node - no cluster defined"),
39 let numNodes
= 1; // by default we have one node
40 for (const { data
} of records
) {
41 if (data
.type
=== 'node') {
42 nodes
[data
.online
=== 1 ? 'online':'offline']++;
43 } else if (data
.type
=== 'cluster') {
44 cluster
.text
= `${gettext("Cluster")}: ${data.name}, ${gettext("Quorate")}: `;
45 cluster
.text
+= Proxmox
.Utils
.format_boolean(data
.quorate
);
46 if (data
.quorate
!== 1) {
47 cluster
.iconCls
= PVE
.Utils
.get_health_icon('critical', true);
49 numNodes
= data
.nodes
;
53 if (numNodes
!== nodes
.online
+ nodes
.offline
) {
54 nodes
.offline
= numNodes
- nodes
.online
;
57 me
.getComponent('clusterstatus').updateHealth(cluster
);
58 me
.getComponent('nodestatus').update(nodes
);
61 updateCeph: function(store
, records
, success
) {
63 let cephstatus
= me
.getComponent('ceph');
64 if (!success
|| records
.length
< 1) {
65 if (cephstatus
.isVisible()) {
66 return; // if ceph status is already visible don't stop to update
68 // try all nodes until we either get a successful api call, or we tried all nodes
69 if (++me
.nodeIndex
>= me
.nodeList
.length
) {
70 me
.cephstore
.stopUpdate();
72 store
.getProxy().setUrl(`/api2/json/nodes/${me.nodeList[me.nodeIndex].node}/ceph/status`);
77 let state
= PVE
.Utils
.render_ceph_health(records
[0].data
.health
|| {});
78 cephstatus
.updateHealth(state
);
79 cephstatus
.setVisible(true);
85 me
.cephstore
.stopUpdate();
91 itemId
: 'clusterstatus',
92 xtype
: 'pveHealthWidget',
93 title
: gettext('Status'),
102 '<h3>' + gettext('Nodes') + '</h3><br />',
103 '<div style="width: 150px;margin: auto;font-size: 12pt">',
104 '<div class="left-aligned">',
105 '<i class="good fa fa-fw fa-check"> </i>',
108 '<div class="right-aligned">{online}</div>',
110 '<div class="left-aligned">',
111 '<i class="critical fa fa-fw fa-times"> </i>',
114 '<div class="right-aligned">{offline}</div>',
121 columnWidth
: undefined,
124 xtype
: 'pveHealthWidget',
129 Ext
.state
.Manager
.getProvider().set('dctab', { value
: 'ceph' }, true);
135 initComponent: function() {
138 me
.nodeList
= PVE
.data
.ResourceStore
.getNodes();
140 me
.cephstore
= Ext
.create('Proxmox.data.UpdateStore', {
142 storeid
: 'pve-cluster-ceph',
145 url
: `/api2/json/nodes/${me.nodeList[me.nodeIndex].node}/ceph/status`,
149 me
.mon(me
.cephstore
, 'load', me
.updateCeph
, me
);
150 me
.cephstore
.startUpdate();