]> git.proxmox.com Git - pve-manager.git/blame - www/manager6/dc/Health.js
add replication grid to lxc/qemu/node
[pve-manager.git] / www / manager6 / dc / Health.js
CommitLineData
0b659b8e
DC
1Ext.define('PVE.dc.Health', {
2 extend: 'Ext.panel.Panel',
3 alias: 'widget.pveDcHealth',
4
8f8ec25d 5 title: gettext('Health'),
0b659b8e
DC
6
7 bodyPadding: '0 20 0 20',
8 height: 200,
9 layout: 'column',
10
11 defaults: {
12 columnWidth: 0.5,
13 xtype: 'box',
14 style: {
15 'text-align':'center'
16 }
17 },
18
19 cepherrors: 0,
20
21 updateStatus: function(store, records, success) {
22 var me = this;
23 if (!success) {
24 return;
25 }
26
27 var cluster = {
428bc4a2 28 iconCls: PVE.Utils.get_health_icon('good', true),
0b659b8e
DC
29 text: gettext("Standalone node - no cluster defined")
30 };
31
32 var nodes = {
33 online: 0,
34 offline: 0
35 };
36
37 // by default we have one node
38 var numNodes = 1;
39 var i;
40
41 for (i = 0; i < records.length; i++) {
42 var item = records[i];
43 if (item.data.type === 'node') {
44 nodes[item.data.online === 1 ? 'online':'offline']++;
45 } else if(item.data.type === 'cluster') {
46 cluster.text = gettext("Cluster") + ": ";
47 cluster.text += item.data.name + ", ";
48 cluster.text += gettext("Quorate") + ": ";
49 cluster.text += PVE.Utils.format_boolean(item.data.quorate);
50 if (item.data.quorate != 1) {
428bc4a2 51 cluster.iconCls = PVE.Utils.get_health_icon('critical', true);
0b659b8e
DC
52 }
53
54 numNodes = item.data.nodes;
55 }
56 }
57
58 if (numNodes !== (nodes.online + nodes.offline)) {
59 nodes.offline = numNodes - nodes.online;
60 }
61
046e640c 62 me.getComponent('clusterstatus').updateHealth(cluster);
0b659b8e
DC
63 me.getComponent('nodestatus').update(nodes);
64 },
65
66 updateCeph: function(store, records, success) {
67 var me = this;
68 var cephstatus = me.getComponent('ceph');
69 if (!success || records.length < 1) {
d43f7042
DC
70
71 // if ceph status is already visible
72 // dont stop to update
73 if (cephstatus.isVisible()) {
74 return;
75 }
0b659b8e 76 me.cepherrors++;
0b659b8e
DC
77
78 // after 3 unsuccessful tries of
79 // /nodes/localhost/ceph/status
80 // we give up (there probably is no ceph installed)
81 if (me.cepherrors >= 3) {
82 me.cephstore.stopUpdate();
83 }
84 return;
85 }
86
87 me.cepherrors = 0;
88
046e640c
DC
89 var state = PVE.Utils.render_ceph_health(records[0]);
90 cephstatus.updateHealth(state);
0b659b8e
DC
91 cephstatus.setVisible(true);
92 },
93
94 listeners: {
95 destroy: function() {
96 var me = this;
97 me.cephstore.stopUpdate();
98 }
99 },
100
101 items: [
102 {
103 itemId: 'clusterstatus',
046e640c
DC
104 xtype: 'pveHealthWidget',
105 title: gettext('Status')
0b659b8e
DC
106 },
107 {
108 itemId: 'nodestatus',
109 data: {
110 online: 0,
111 offline: 0
112 },
113 tpl: [
114 '<h3>' + gettext('Nodes') + '</h3><br />',
115 '<div style="width: 150px;margin: auto;font-size: 12pt">',
116 '<div class="left-aligned">',
117 '<i class="good fa fa-fw fa-check">&nbsp;</i>',
118 gettext('Online'),
119 '</div>',
120 '<div class="right-aligned">{online}</div>',
121 '<br /><br />',
122 '<div class="left-aligned">',
123 '<i class="critical fa fa-fw fa-times">&nbsp;</i>',
124 gettext('Offline'),
125 '</div>',
126 '<div class="right-aligned">{offline}</div>',
127 '</div>'
128 ]
129 },
130 {
131 itemId: 'ceph',
132 width: 250,
133 columnWidth: undefined,
c359b437 134 userCls: 'pointer',
2ce6111f 135 title: 'Ceph',
046e640c 136 xtype: 'pveHealthWidget',
c359b437
DC
137 hidden: true,
138 listeners: {
139 element: 'el',
140 click: function() {
141 var me = this;
142 var sp = Ext.state.Manager.getProvider();
143
144 // preselect the ceph tab
145 sp.set('nodetab', {value:'ceph'});
146
147 // select the first node which is online
148 var nodeid = '';
149 var nodes = PVE.data.ResourceStore.getNodes();
150 Ext.Array.some(nodes, function(node) {
151 if (node.running) {
152 nodeid = node.id;
153 return true;
154 }
155
156 return false;
157 });
158 Ext.ComponentQuery.query('pveResourceTree')[0].selectById(nodeid);
159 }
160 }
0b659b8e
DC
161 }
162 ],
163
164 initComponent: function() {
165 var me = this;
166
167 me.cephstore = Ext.create('PVE.data.UpdateStore', {
168 interval: 3000,
169 storeid: 'pve-cluster-ceph',
170 proxy: {
171 type: 'pve',
172 url: '/api2/json/nodes/localhost/ceph/status'
173 }
174 });
175 me.callParent();
176 me.cephstore.startUpdate();
177 me.mon(me.cephstore, 'load', me.updateCeph, me);
178 }
179});