luci2: add network hostname view
authorJo-Philipp Wich <jow@openwrt.org>
Sat, 12 Oct 2013 20:47:06 +0000 (20:47 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sat, 12 Oct 2013 20:47:06 +0000 (20:47 +0000)
luci2/htdocs/luci2/template/network.hosts.htm [new file with mode: 0644]
luci2/htdocs/luci2/view/network.hosts.js [new file with mode: 0644]
luci2/share/acl.d/luci2.json
luci2/share/menu.d/network.json

diff --git a/luci2/htdocs/luci2/template/network.hosts.htm b/luci2/htdocs/luci2/template/network.hosts.htm
new file mode 100644 (file)
index 0000000..ad19e7d
--- /dev/null
@@ -0,0 +1 @@
+<div id="map"></div>
diff --git a/luci2/htdocs/luci2/view/network.hosts.js b/luci2/htdocs/luci2/view/network.hosts.js
new file mode 100644 (file)
index 0000000..2dab0d9
--- /dev/null
@@ -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');
+    }
+});
index e8e6949..91f3313 100644 (file)
                                ]
                        }
                }
                                ]
                        }
                }
+       },
+
+       "hostnames": {
+               "description": "Host entry management",
+               "read": {
+                       "uci": [
+                               "dhcp"
+                       ]
+               },
+               "write": {
+                       "uci": [
+                               "dhcp"
+                       ]
+               }
        }
 }
        }
 }
index fc6f236..64921b3 100644 (file)
@@ -9,6 +9,12 @@
         "view": "network/switch",
         "index": 30
     },
         "view": "network/switch",
         "index": 30
     },
+    "network/hosts": {
+        "title": "Hostnames",
+        "acls": [ "hostnames" ],
+        "view": "network/hosts",
+        "index": 50
+    },
     "network/diagnostics": {
         "title": "Diagnostics",
         "acls": [ "diagnostics" ],
     "network/diagnostics": {
         "title": "Diagnostics",
         "acls": [ "diagnostics" ],