luci-app-keepalived: add missing cbi class section and description
[project/luci.git] / applications / luci-app-keepalived / htdocs / luci-static / resources / view / keepalived / overview.js
1 'use strict';
2 'require view';
3 'require form';
4 'require uci';
5 'require rpc';
6 'require poll';
7
8 var callKeepalivedStatus = rpc.declare({
9 object: 'keepalived',
10 method: 'dump',
11 expect: { },
12 });
13
14 return view.extend({
15 load: function() {
16 return Promise.all([
17 uci.load('keepalived'),
18 ]);
19 },
20
21 render: function() {
22 var table =
23 E('table', { 'class': 'table lases' }, [
24 E('tr', { 'class': 'tr table-titles' }, [
25 E('th', { 'class': 'th' }, _('Name')),
26 E('th', { 'class': 'th' }, _('Interface')),
27 E('th', { 'class': 'th' }, _('Active State/State')),
28 E('th', { 'class': 'th' }, _('Probes Sent')),
29 E('th', { 'class': 'th' }, _('Probes Received')),
30 E('th', { 'class': 'th' }, _('Last Transition')),
31 E([])
32 ])
33 ]);
34
35 poll.add(function() {
36 return callKeepalivedStatus().then(function(instancesInfo) {
37 var targets = Array.isArray(instancesInfo.status) ? instancesInfo.status : [];
38 var instances = uci.sections('keepalived', 'vrrp_instance');
39
40 cbi_update_table(table,
41 targets.map(function(target) {
42 var state = (target.stats.become_master - target.stats.release_master) ? 'MASTER' : 'BACKUP';
43 if (instances != '') {
44 for (var i = 0; i < instances.length; i++) {
45 if (instances[i]['name'] == target.data.iname) {
46 state = state + '/' + instances[i]['state'];
47 break;
48 }
49 }
50 }
51 return [
52 target.data.iname,
53 target.data.ifp_ifname,
54 state,
55 target.stats.advert_sent,
56 target.stats.advert_rcvd,
57 new Date(target.data.last_transition * 1000)
58 ];
59 }),
60 E('em', _('There are no active instances'))
61 );
62 });
63 });
64
65 return E('div', {'class': 'cbi-map'}, [
66 E('h2', _('VRRP')),
67 E('div', {'class': 'cbi-map-descr'}, _('This overview shows the current status of the VRRP instances on this device.')),
68 E('div', { 'class': 'cbi-section' }, table)
69 ]);
70 },
71
72 handleSave: null,
73 handleSaveApply:null,
74 handleReset: null
75 });