luci-app-udpxy: rewritten in JS
authorTianling Shen <cnsztl@immortalwrt.org>
Wed, 23 Nov 2022 11:03:59 +0000 (19:03 +0800)
committerJo-Philipp Wich <jo@mein.io>
Mon, 3 Apr 2023 11:45:03 +0000 (13:45 +0200)
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
(cherry picked from commit 3aca045ec6173da675184d24d57d971065ce2eaf)

applications/luci-app-udpxy/Makefile
applications/luci-app-udpxy/htdocs/luci-static/resources/view/udpxy.js [new file with mode: 0644]
applications/luci-app-udpxy/luasrc/model/cbi/udpxy.lua [deleted file]
applications/luci-app-udpxy/root/usr/share/luci/menu.d/luci-app-udpxy.json

index c4286baaffe73bd6f1da8b619078523f5d8d874c..cb8f1792322266842c969c4804ed47c367267690 100644 (file)
@@ -7,7 +7,7 @@
 include $(TOPDIR)/rules.mk
 
 LUCI_TITLE:=LuCI Support for udpxy
-LUCI_DEPENDS:=+luci-compat +udpxy
+LUCI_DEPENDS:=+udpxy
 
 include ../../luci.mk
 
diff --git a/applications/luci-app-udpxy/htdocs/luci-static/resources/view/udpxy.js b/applications/luci-app-udpxy/htdocs/luci-static/resources/view/udpxy.js
new file mode 100644 (file)
index 0000000..9944f9e
--- /dev/null
@@ -0,0 +1,61 @@
+'use strict';
+'require form';
+'require view';
+
+return view.extend({
+       render: function () {
+               var m, s, o;
+
+               m = new form.Map('udpxy', _('udpxy'),
+                       _('udpxy is a UDP-to-HTTP multicast traffic relay daemon, here you can configure the settings.'));
+
+               s = m.section(form.TypedSection, 'udpxy');
+               s.anonymous = true;
+               s.addremove = true;
+
+               o = s.option(form.Flag, 'disabled', _('Enabled'));
+               o.enabled = '0';
+               o.disabled = '1';
+               o.default = o.disabled;
+               o.rmempty = false;
+
+               o = s.option(form.Flag, 'respawn', _('Respawn'));
+               o.default = o.disabled;
+
+               o = s.option(form.Flag, 'verbose', _('Verbose'));
+               o.default = o.disabled;
+
+               o = s.option(form.Flag, 'status', _('Status'));
+
+               o = s.option(form.Value, 'bind', _('Bind IP/Interface'));
+               o.datatype = 'or(ipaddr, network)';
+
+               o = s.option(form.Value, 'port', _('Port'));
+               o.datatype = 'port';
+
+               o = s.option(form.Value, 'source', _('Source IP/Interface'));
+               o.datatype = 'or(ipaddr, network)';
+
+               o = s.option(form.Value, 'max_clients', _('Max clients'));
+               o.datatype = 'range(1, 5000)';
+
+               o = s.option(form.Value, 'log_file', _('Log file'));
+
+               o = s.option(form.Value, 'buffer_size', _('Buffer size'));
+               o.datatype = 'range(4096, 2097152)';
+
+               o = s.option(form.Value, 'buffer_messages', _('Buffer messages'));
+               o.datatype = 'or(-1, and(min(1),uinteger))';
+
+               o = s.option(form.Value, 'buffer_time', _('Buffer time'));
+               o.datatype = 'or(-1, and(min(1),uinteger))';
+
+               o = s.option(form.Value, 'nice_increment', _('Nice increment'));
+               o.datatype = 'or(and(max(-1),uinteger), and(min(1),uinteger))';
+
+               o = s.option(form.Value, 'mcsub_renew', _('Multicast subscription renew'));
+               o.datatype = 'or(0, range(30, 64000))';
+
+               return m.render();
+       }
+});
diff --git a/applications/luci-app-udpxy/luasrc/model/cbi/udpxy.lua b/applications/luci-app-udpxy/luasrc/model/cbi/udpxy.lua
deleted file mode 100644 (file)
index d823da0..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
--- Copyright 2014 Álvaro Fernández Rojas <noltari@gmail.com>
--- Licensed to the public under the Apache License 2.0.
-
-m = Map("udpxy", "udpxy", translate("udpxy is a UDP-to-HTTP multicast traffic relay daemon, here you can configure the settings."))
-
-s = m:section(TypedSection, "udpxy", "")
-s.addremove = true
-s.anonymous = false
-
-enable=s:option(Flag, "disabled", translate("Enabled"))
-enable.enabled="0"
-enable.disabled="1"
-enable.default = "1"
-enable.rmempty = false
-respawn=s:option(Flag, "respawn", translate("Respawn"))
-respawn.default = false
-
-verbose=s:option(Flag, "verbose", translate("Verbose"))
-verbose.default = false
-
-status=s:option(Flag, "status", translate("Status"))
-
-bind=s:option(Value, "bind", translate("Bind IP/Interface"))
-bind.rmempty = true
-bind.datatype = "or(ipaddr, network)"
-
-port=s:option(Value, "port", translate("Port"))
-port.rmempty = true
-port.datatype = "port"
-
-source=s:option(Value, "source", translate("Source IP/Interface"))
-source.rmempty = true
-source.datatype = "or(ipaddr, network)"
-
-max_clients=s:option(Value, "max_clients", translate("Max clients"))
-max_clients.rmempty = true
-max_clients.datatype = "range(1, 5000)"
-
-log_file=s:option(Value, "log_file", translate("Log file"))
-log_file.rmempty = true
---log_file.datatype = "file"
-
-buffer_size=s:option(Value, "buffer_size", translate("Buffer size"))
-buffer_size.rmempty = true
-buffer_size.datatype = "range(4096,2097152)"
-
-buffer_messages=s:option(Value, "buffer_messages", translate("Buffer messages"))
-buffer_messages.rmempty = true
-buffer_messages.datatype = "or(-1, and(min(1), uinteger))"
-
-buffer_time=s:option(Value, "buffer_time", translate("Buffer time"))
-buffer_time.rmempty = true
-buffer_time.datatype = "or(-1, and(min(1), uinteger))"
-
-nice_increment=s:option(Value, "nice_increment", translate("Nice increment"))
-nice_increment.rmempty = true
-nice_increment.datatype = "or(and(max(-1), integer),and(min(1), integer))"
-
-mcsub_renew=s:option(Value, "mcsub_renew", translate("Multicast subscription renew"))
-mcsub_renew.rmempty = true
-mcsub_renew.datatype = "or(0, range(30, 64000))"
-
-return m
index c0171a13fe09028547517750f017366699089c76..8f66250f195611146a9e0c6831d1620ce0606522 100644 (file)
@@ -2,9 +2,8 @@
        "admin/services/udpxy": {
                "title": "udpxy",
                "action": {
-                       "type": "cbi",
-                       "path": "udpxy",
-                       "post": { "cbi.submit": true }
+                       "type": "view",
+                       "path": "udpxy"
                },
                "depends": {
                        "acl": [ "luci-app-udpxy" ],