From 6c11828ca6216bd177e974ba6843ec5332afddf4 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sat, 12 Oct 2013 20:47:06 +0000 Subject: [PATCH 1/1] luci2: add network hostname view --- luci2/htdocs/luci2/template/network.hosts.htm | 1 + luci2/htdocs/luci2/view/network.hosts.js | 31 +++++++++++++++++++++++++++ luci2/share/acl.d/luci2.json | 14 ++++++++++++ luci2/share/menu.d/network.json | 6 ++++++ 4 files changed, 52 insertions(+) create mode 100644 luci2/htdocs/luci2/template/network.hosts.htm create mode 100644 luci2/htdocs/luci2/view/network.hosts.js diff --git a/luci2/htdocs/luci2/template/network.hosts.htm b/luci2/htdocs/luci2/template/network.hosts.htm new file mode 100644 index 0000000..ad19e7d --- /dev/null +++ b/luci2/htdocs/luci2/template/network.hosts.htm @@ -0,0 +1 @@ +
diff --git a/luci2/htdocs/luci2/view/network.hosts.js b/luci2/htdocs/luci2/view/network.hosts.js new file mode 100644 index 0000000..2dab0d9 --- /dev/null +++ b/luci2/htdocs/luci2/view/network.hosts.js @@ -0,0 +1,31 @@ +L.ui.view.extend({ + title: L.tr('Hostnames'), + description: L.tr('Manage static host records to let the local DNS server resolve certain names to specific IP addresses.'), + + execute: function() { + var m = new L.cbi.Map('dhcp', { + readonly: !this.options.acls.hostnames + }); + + var s = m.section(L.cbi.TableSection, 'domain', { + caption: function(sid) { return sid ? (this.fields.name.textvalue(sid) || L.tr('Unnamed LED')) : '' }, + teasers: [ 'sysfs', 'default', 'trigger', '_net_dev', 'mode', '_usb_dev', 'delayon', 'delayoff' ], + collabsible: true, + addremove: true, + add_caption: L.tr('Add new hostname'), + remove_caption: L.tr('Remove hostname') + }); + + s.option(L.cbi.InputValue, 'name', { + caption: L.tr('Hostname'), + datatype: 'hostname' + }); + + s.option(L.cbi.InputValue, 'ip', { + caption: L.tr('IP address'), + datatype: 'ipaddr' + }); + + return m.insertInto('#map'); + } +}); diff --git a/luci2/share/acl.d/luci2.json b/luci2/share/acl.d/luci2.json index e8e6949..91f3313 100644 --- a/luci2/share/acl.d/luci2.json +++ b/luci2/share/acl.d/luci2.json @@ -309,5 +309,19 @@ ] } } + }, + + "hostnames": { + "description": "Host entry management", + "read": { + "uci": [ + "dhcp" + ] + }, + "write": { + "uci": [ + "dhcp" + ] + } } } diff --git a/luci2/share/menu.d/network.json b/luci2/share/menu.d/network.json index fc6f236..64921b3 100644 --- a/luci2/share/menu.d/network.json +++ b/luci2/share/menu.d/network.json @@ -9,6 +9,12 @@ "view": "network/switch", "index": 30 }, + "network/hosts": { + "title": "Hostnames", + "acls": [ "hostnames" ], + "view": "network/hosts", + "index": 50 + }, "network/diagnostics": { "title": "Diagnostics", "acls": [ "diagnostics" ], -- 2.11.0