diff --git a/luci-app-nikki/htdocs/luci-static/resources/tools/nikki.js b/luci-app-nikki/htdocs/luci-static/resources/tools/nikki.js index 0af6c5c14..f1bbaf7d4 100644 --- a/luci-app-nikki/htdocs/luci-static/resources/tools/nikki.js +++ b/luci-app-nikki/htdocs/luci-static/resources/tools/nikki.js @@ -28,6 +28,7 @@ const callNikkiVersion = rpc.declare({ const callNikkiProfile = rpc.declare({ object: 'luci.nikki', method: 'profile', + params: [ 'defaults' ], expect: { '': {} } }); @@ -98,8 +99,8 @@ return baseclass.extend({ return callNikkiVersion(); }, - profile: function () { - return callNikkiProfile(); + profile: function (defaults) { + return callNikkiProfile(defaults); }, updateSubscription: function (section_id) { @@ -107,7 +108,7 @@ return baseclass.extend({ }, api: async function (method, path, query, body) { - const profile = await callNikkiProfile(); + const profile = await callNikkiProfile({ 'external-controller': null, 'secret': null }); const apiListen = profile['external-controller']; const apiSecret = profile['secret'] ?? ''; const apiPort = apiListen.substring(apiListen.lastIndexOf(':') + 1); @@ -121,7 +122,7 @@ return baseclass.extend({ }, openDashboard: async function () { - const profile = await callNikkiProfile(); + const profile = await callNikkiProfile({ 'external-ui-name': null, 'external-controller': null, 'secret': null }); const uiName = profile['external-ui-name']; const apiListen = profile['external-controller']; const apiSecret = profile['secret'] ?? ''; diff --git a/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js b/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js index f767309b2..dbbff4e58 100644 --- a/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js +++ b/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js @@ -67,6 +67,8 @@ return view.extend({ o.rmempty = false; o = s.taboption('router', form.SectionValue, '_router_access_control', form.TableSection, 'router_access_control', _('Access Control')); + o.retain = true; + o.depends('router_proxy', '1'); o.subsection.addremove = true; o.subsection.anonymous = true; @@ -102,7 +104,9 @@ return view.extend({ o = s.taboption('lan', form.Flag, 'lan_proxy', _('Enable')); o = s.taboption('lan', form.DynamicList, 'lan_inbound_interface', _('Inbound Interface')); + o.retain = true; o.rmempty = false; + o.depends('lan_proxy', '1'); for (const network of networks) { if (network.getName() === 'loopback') { @@ -112,6 +116,8 @@ return view.extend({ } o = s.taboption('lan', form.SectionValue, '_lan_access_control', form.TableSection, 'lan_access_control', _('Access Control')); + o.retain = true; + o.depends('lan_proxy', '1'); o.subsection.addremove = true; o.subsection.anonymous = true; diff --git a/luci-app-nikki/root/usr/share/rpcd/ucode/luci.nikki b/luci-app-nikki/root/usr/share/rpcd/ucode/luci.nikki index 779989eaa..284502036 100644 --- a/luci-app-nikki/root/usr/share/rpcd/ucode/luci.nikki +++ b/luci-app-nikki/root/usr/share/rpcd/ucode/luci.nikki @@ -2,7 +2,7 @@ 'use strict'; -import { access, popen } from 'fs'; +import { access, popen, writefile } from 'fs'; import { get_users, get_groups, get_cgroups } from '/etc/nikki/ucode/include.uc'; const methods = { @@ -33,13 +33,18 @@ const methods = { } }, profile: { - call: function() { + args: { defaults: {} }, + call: function(req) { let profile = {}; + const defaults = req.args?.defaults ?? {}; const filepath = '/etc/nikki/run/config.yaml'; + const tmpFilepath = '/var/run/nikki/profile.json'; if (access(filepath, 'r')) { - const process = popen(`yq -p yaml -o json < ${filepath}`); + writefile(tmpFilepath, defaults); + const command = `yq -p yaml -o json eval-all 'select(fi == 0) *? select(fi == 1)' ${tmpFilepath} ${filepath}`; + const process = popen(command); if (process) { - profile = json(trim(process.read('all'))); + profile = json(process); process.close(); } } @@ -67,7 +72,7 @@ const methods = { }, debug: { call: function() { - const success = system('/etc/nikki/scripts/debug.sh > /var/log/nikki/debug.log 2>&1') == 0; + const success = system('/etc/nikki/scripts/debug.sh > /var/log/nikki/debug.log') == 0; return { success: success }; } }