From 7666ad99f16de0efc5b03860d39828da319b90af Mon Sep 17 00:00:00 2001 From: Van Waholtz Date: Fri, 28 Jan 2022 19:32:20 +0800 Subject: [PATCH] luci-app-frpc: use anonymous sections 1. Use anonymous sections and add name options to specify the proxy name 2. Add server name field for visitor mode Signed-off-by: Van Waholtz (cherry picked from commit 973a4b5e679d22988671f7019103f0aa0833d4c6) --- .../htdocs/luci-static/resources/view/frpc.js | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/applications/luci-app-frpc/htdocs/luci-static/resources/view/frpc.js b/applications/luci-app-frpc/htdocs/luci-static/resources/view/frpc.js index ec75e0bf94..7ad2f8a202 100644 --- a/applications/luci-app-frpc/htdocs/luci-static/resources/view/frpc.js +++ b/applications/luci-app-frpc/htdocs/luci-static/resources/view/frpc.js @@ -39,6 +39,7 @@ var commonConf = [ ]; var baseProxyConf = [ + [form.Value, 'name', _('Proxy name'), undefined, {rmempty: false, optional: false}], [form.ListValue, 'type', _('Proxy type'), _('ProxyType specifies the type of this proxy. Valid values include "tcp", "udp", "http", "https", "stcp", and "xtcp".
By default, this value is "tcp".'), {values: ['tcp', 'udp', 'http', 'https', 'stcp', 'xtcp']}], [form.Flag, 'use_encryption', _('Encryption'), _('UseEncryption controls whether or not communication with the server will be encrypted. Encryption is done using the tokens supplied in the server and client configuration.
By default, this value is false.'), {datatype: 'bool'}], [form.Flag, 'use_compression', _('Compression'), _('UseCompression controls whether or not communication with the server will be compressed.
By default, this value is false.'), {datatype: 'bool'}], @@ -65,6 +66,7 @@ var httpProxyConf = [ var stcpProxyConf = [ [form.ListValue, 'role', _('Role'), undefined, {values: ['server', 'visitor']}], + [form.Value, 'server_name', _('Server name'), undefined, {depends: [{role: 'visitor'}]}], [form.Value, 'sk', _('Sk')], ]; @@ -82,12 +84,20 @@ function setParams(o, params) { } else if (key === 'depends') { if (!Array.isArray(val)) val = [val]; + + var deps = []; for (var j = 0; j < val.length; j++) { - var args = val[j]; - if (!Array.isArray(args)) - args = [args]; - o.depends.apply(o, args); + var d = {}; + for (var vkey in val[j]) + d[vkey] = val[j][vkey]; + for (var k = 0; k < o.deps.length; k++) { + for (var dkey in o.deps[k]) { + d[dkey] = o.deps[k][dkey]; + } + } + deps.push(d); } + o.deps = deps; } else { o[key] = params[key]; } @@ -186,21 +196,17 @@ return view.extend({ defOpts(s, startupConf); s = m.section(form.GridSection, 'conf', _('Proxy Settings')); + s.anonymous = true; s.addremove = true; + s.sortable = true; + s.addbtntitle = _('Add new proxy...'); + s.filter = function(s) { return s !== 'common'; }; - s.renderSectionAdd = function(extra_class) { - var el = form.GridSection.prototype.renderSectionAdd.apply(this, arguments), - nameEl = el.querySelector('.cbi-section-create-name'); - ui.addValidator(nameEl, 'uciname', true, function(v) { - if (v === 'common') return _('Name can not be "common"'); - return true; - }, 'blur', 'keyup'); - return el; - } s.tab('general', _('General Settings')); s.tab('http', _('HTTP Settings')); + s.option(form.Value, 'name', _('Proxy name')).modalonly = false; s.option(form.Value, 'type', _('Proxy type')).modalonly = false; s.option(form.Value, 'local_ip', _('Local IP')).modalonly = false; s.option(form.Value, 'local_port', _('Local port')).modalonly = false; -- 2.30.2