luci-mod-system: remplement dropbear settings as client side view
authorJo-Philipp Wich <jo@mein.io>
Tue, 17 Sep 2019 05:43:48 +0000 (07:43 +0200)
committerJo-Philipp Wich <jo@mein.io>
Tue, 17 Sep 2019 05:43:48 +0000 (07:43 +0200)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-mod-system/htdocs/luci-static/resources/view/system/dropbear.js [new file with mode: 0644]
modules/luci-mod-system/luasrc/controller/admin/system.lua
modules/luci-mod-system/luasrc/model/cbi/admin_system/dropbear.lua [deleted file]

diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/dropbear.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/dropbear.js
new file mode 100644 (file)
index 0000000..7a8b142
--- /dev/null
@@ -0,0 +1,42 @@
+'use strict';
+'require form';
+'require tools.widgets as widgets';
+
+return L.view.extend({
+       render: function() {
+               var m, s, o;
+
+               m = new form.Map('dropbear', _('SSH Access'), _('Dropbear offers <abbr title="Secure Shell">SSH</abbr> network shell access and an integrated <abbr title="Secure Copy">SCP</abbr> server'));
+
+               s = m.section(form.TypedSection, 'dropbear', _('Dropbear Instance'));
+               s.anonymous = true;
+               s.addremove = true;
+               s.addbtntitle = _('Add instance');
+
+               o = s.option(widgets.NetworkSelect, 'Interface', _('Interface'), _('Listen only on the given interface or, if unspecified, on all'));
+               o.nocreate    = true;
+               o.unspecified = true;
+
+               o = s.option(form.Value, 'Port', _('Port'));
+               o.datatype    = 'port';
+               o.placeholder = 22;
+
+               o = s.option(form.Flag, 'PasswordAuth', _('Password authentication'), _('Allow <abbr title="Secure Shell">SSH</abbr> password authentication'));
+               o.enabled  = 'on';
+               o.disabled = 'off';
+               o.default  = o.enabled;
+               o.rmempty  = false;
+
+               o = s.option(form.Flag, 'RootPasswordAuth', _('Allow root logins with password'), _('Allow the <em>root</em> user to login with password'));
+               o.enabled  = 'on';
+               o.disabled = 'off';
+               o.default  = o.enabled;
+
+               o = s.option(form.Flag, 'GatewayPorts', _('Gateway Ports'), _('Allow remote hosts to connect to local SSH forwarded ports'));
+               o.enabled  = 'on';
+               o.disabled = 'off';
+               o.default  = o.disabled;
+
+               return m.render();
+       }
+});
index d1fda1d7c7331b61c089e1d325188eaa2ee00a3e..0ce08d10bdf9d3bfc5a9c80477ecd41de5b93c1e 100644 (file)
@@ -15,7 +15,7 @@ function index()
        entry({"admin", "system", "admin", "password"}, view("system/password"), _("Router Password"), 1)
 
        if fs.access("/etc/config/dropbear") then
-               entry({"admin", "system", "admin", "dropbear"}, cbi("admin_system/dropbear"), _("SSH Access"), 2)
+               entry({"admin", "system", "admin", "dropbear"}, view("system/dropbear"), _("SSH Access"), 2)
                entry({"admin", "system", "admin", "sshkeys"}, view("system/sshkeys"), _("SSH-Keys"), 3)
        end
 
diff --git a/modules/luci-mod-system/luasrc/model/cbi/admin_system/dropbear.lua b/modules/luci-mod-system/luasrc/model/cbi/admin_system/dropbear.lua
deleted file mode 100644 (file)
index 1a1695d..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
--- Copyright 2008 Steven Barth <steven@midlink.org>
--- Copyright 2011-2018 Jo-Philipp Wich <jo@mein.io>
--- Licensed to the public under the Apache License 2.0.
-
-m = Map("dropbear", translate("SSH Access"),
-       translate("Dropbear offers <abbr title=\"Secure Shell\">SSH</abbr> network shell access and an integrated <abbr title=\"Secure Copy\">SCP</abbr> server"))
-m.apply_on_parse = true
-
-s = m:section(TypedSection, "dropbear", translate("Dropbear Instance"))
-s.anonymous = true
-s.addremove = true
-
-
-ni = s:option(Value, "Interface", translate("Interface"),
-       translate("Listen only on the given interface or, if unspecified, on all"))
-
-ni.template    = "cbi/network_netlist"
-ni.nocreate    = true
-ni.unspecified = true
-
-
-pt = s:option(Value, "Port", translate("Port"),
-       translate("Specifies the listening port of this <em>Dropbear</em> instance"))
-
-pt.datatype = "port"
-pt.default  = 22
-
-
-pa = s:option(Flag, "PasswordAuth", translate("Password authentication"),
-       translate("Allow <abbr title=\"Secure Shell\">SSH</abbr> password authentication"))
-
-pa.enabled  = "on"
-pa.disabled = "off"
-pa.default  = pa.enabled
-pa.rmempty  = false
-
-
-ra = s:option(Flag, "RootPasswordAuth", translate("Allow root logins with password"),
-       translate("Allow the <em>root</em> user to login with password"))
-
-ra.enabled  = "on"
-ra.disabled = "off"
-ra.default  = ra.enabled
-
-
-gp = s:option(Flag, "GatewayPorts", translate("Gateway ports"),
-       translate("Allow remote hosts to connect to local SSH forwarded ports"))
-
-gp.enabled  = "on"
-gp.disabled = "off"
-gp.default  = gp.disabled
-
-return m