luci-app-ddns: convert to client side implementation
[project/luci.git] / applications / luci-app-ddns / htdocs / luci-static / resources / view / status / include / 70_ddns.js
1 'use strict';
2 'require rpc';
3 'require uci';
4
5 return L.Class.extend({
6 title: _('Dynamic DNS'),
7
8 callDDnsGetServicesStatus: rpc.declare({
9 object: 'luci.ddns',
10 method: 'get_services_status',
11 expect: { }
12 }),
13
14 load: function() {
15 return Promise.all([
16 this.callDDnsGetServicesStatus(),
17 uci.load('ddns')
18 ]);
19 },
20
21 render: function(data) {
22 var services = data[0];
23
24 var table = E('div', { 'class': 'table' }, [
25 E('div', { 'class': 'tr table-titles' }, [
26 E('div', { 'class': 'th' }, _('Configuration')),
27 E('div', { 'class': 'th' }, _('Next Update')),
28 E('div', { 'class': 'th' }, _('Lookup Hostname')),
29 E('div', { 'class': 'th' }, _('Registered IP')),
30 E('div', { 'class': 'th' }, _('Network'))
31 ])
32 ]);
33
34 cbi_update_table(table, Object.keys(services).map(function(key, index) {
35 return [
36 key,
37 services[key].next_update ? _(services[key].next_update) : _('Unknown'),
38 uci.get('ddns',key,'lookup_host'),
39 services[key].ip ? services[key].ip : _('No Data'),
40 (uci.get('ddns',key,'use_ipv6') == '1' ? 'IPv6' : 'IPv4') + ' / ' + uci.get('ddns',key,'interface')
41 ];
42 }), E('em', _('There is no service configured.')));
43
44 return E([table]);
45 }
46 });