From c1734c8ea05dc2483287db391f3126cb431808a2 Mon Sep 17 00:00:00 2001 From: CyberMind-FR Date: Mon, 26 Jan 2026 12:49:32 +0100 Subject: [PATCH] fix(streamlit): Fix LuCI instance management bugs - Add ACL permissions for instance RPC methods - Fix settings page select styling (use st-form-input class) - Fix memory limit options to match actual config values (1024M) - Fix app selector dropdown in instances view (proper array handling) - Bump luci-app-streamlit to r5 Co-Authored-By: Claude Opus 4.5 --- package/secubox/luci-app-streamlit/Makefile | 2 +- .../resources/view/streamlit/instances.js | 19 +++++++---- .../resources/view/streamlit/settings.js | 32 +++++++++++-------- .../share/rpcd/acl.d/luci-app-streamlit.json | 13 ++++++-- 4 files changed, 43 insertions(+), 23 deletions(-) diff --git a/package/secubox/luci-app-streamlit/Makefile b/package/secubox/luci-app-streamlit/Makefile index b1762e3..4b15c8d 100644 --- a/package/secubox/luci-app-streamlit/Makefile +++ b/package/secubox/luci-app-streamlit/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-streamlit PKG_VERSION:=1.0.0 -PKG_RELEASE:=3 +PKG_RELEASE:=5 PKG_ARCH:=all PKG_LICENSE:=Apache-2.0 diff --git a/package/secubox/luci-app-streamlit/htdocs/luci-static/resources/view/streamlit/instances.js b/package/secubox/luci-app-streamlit/htdocs/luci-static/resources/view/streamlit/instances.js index 438259f..4b42b6b 100644 --- a/package/secubox/luci-app-streamlit/htdocs/luci-static/resources/view/streamlit/instances.js +++ b/package/secubox/luci-app-streamlit/htdocs/luci-static/resources/view/streamlit/instances.js @@ -158,9 +158,7 @@ return view.extend({ renderAddInstanceCard: function() { var self = this; - var apps = (this.appsData.apps || []).map(function(app) { - return E('option', { 'value': app.name + '.py' }, app.name); - }); + var appsList = this.appsData.apps || []; // Calculate next available port var usedPorts = this.instancesData.map(function(i) { return i.port; }); @@ -169,6 +167,16 @@ return view.extend({ nextPort++; } + // Build select options array + var selectOptions = [E('option', { 'value': '' }, _('-- Select App --'))]; + if (appsList.length > 0) { + appsList.forEach(function(app) { + selectOptions.push(E('option', { 'value': app.name + '.py' }, app.name)); + }); + } else { + selectOptions.push(E('option', { 'disabled': true }, _('No apps available'))); + } + return E('div', { 'class': 'st-card' }, [ E('div', { 'class': 'st-card-header' }, [ E('div', { 'class': 'st-card-title' }, [ @@ -202,10 +210,7 @@ return view.extend({ 'class': 'st-form-input', 'id': 'new-inst-app', 'style': 'height: 42px;' - }, [ - E('option', { 'value': '' }, _('-- Select App --')), - apps.length > 0 ? apps : E('option', { 'disabled': true }, _('No apps available')) - ]) + }, selectOptions) ]), E('div', { 'class': 'st-form-group' }, [ E('label', { 'class': 'st-form-label' }, _('Port')), diff --git a/package/secubox/luci-app-streamlit/htdocs/luci-static/resources/view/streamlit/settings.js b/package/secubox/luci-app-streamlit/htdocs/luci-static/resources/view/streamlit/settings.js index 23e7904..09a3685 100644 --- a/package/secubox/luci-app-streamlit/htdocs/luci-static/resources/view/streamlit/settings.js +++ b/package/secubox/luci-app-streamlit/htdocs/luci-static/resources/view/streamlit/settings.js @@ -70,8 +70,9 @@ return view.extend({ E('div', { 'class': 'st-form-group' }, [ E('label', { 'class': 'st-form-label' }, _('Enabled')), E('select', { - 'class': 'st-form-select', - 'id': 'cfg-enabled' + 'class': 'st-form-input', + 'id': 'cfg-enabled', + 'style': 'height: 42px;' }, [ E('option', { 'value': '1', 'selected': config.enabled }, _('Enabled')), E('option', { 'value': '0', 'selected': !config.enabled }, _('Disabled')) @@ -111,13 +112,15 @@ return view.extend({ E('div', { 'class': 'st-form-group' }, [ E('label', { 'class': 'st-form-label' }, _('Memory Limit')), E('select', { - 'class': 'st-form-select', - 'id': 'cfg-memory_limit' + 'class': 'st-form-input', + 'id': 'cfg-memory_limit', + 'style': 'height: 42px;' }, [ E('option', { 'value': '256M', 'selected': config.memory_limit === '256M' }, '256 MB'), - E('option', { 'value': '512M', 'selected': config.memory_limit === '512M' || !config.memory_limit }, '512 MB'), - E('option', { 'value': '1G', 'selected': config.memory_limit === '1G' }, '1 GB'), - E('option', { 'value': '2G', 'selected': config.memory_limit === '2G' }, '2 GB') + E('option', { 'value': '512M', 'selected': config.memory_limit === '512M' }, '512 MB'), + E('option', { 'value': '1024M', 'selected': config.memory_limit === '1024M' || !config.memory_limit }, '1 GB'), + E('option', { 'value': '2048M', 'selected': config.memory_limit === '2048M' }, '2 GB'), + E('option', { 'value': '4096M', 'selected': config.memory_limit === '4096M' }, '4 GB') ]) ]), E('div', { 'class': 'st-form-group' }, [ @@ -148,8 +151,9 @@ return view.extend({ E('div', { 'class': 'st-form-group' }, [ E('label', { 'class': 'st-form-label' }, _('Headless Mode')), E('select', { - 'class': 'st-form-select', - 'id': 'cfg-headless' + 'class': 'st-form-input', + 'id': 'cfg-headless', + 'style': 'height: 42px;' }, [ E('option', { 'value': 'true', 'selected': config.headless !== false }, _('Enabled (recommended)')), E('option', { 'value': 'false', 'selected': config.headless === false }, _('Disabled')) @@ -158,8 +162,9 @@ return view.extend({ E('div', { 'class': 'st-form-group' }, [ E('label', { 'class': 'st-form-label' }, _('Usage Statistics')), E('select', { - 'class': 'st-form-select', - 'id': 'cfg-gather_stats' + 'class': 'st-form-input', + 'id': 'cfg-gather_stats', + 'style': 'height: 42px;' }, [ E('option', { 'value': 'false', 'selected': !config.browser_gather_usage_stats }, _('Disabled (recommended)')), E('option', { 'value': 'true', 'selected': config.browser_gather_usage_stats }, _('Enabled')) @@ -168,8 +173,9 @@ return view.extend({ E('div', { 'class': 'st-form-group' }, [ E('label', { 'class': 'st-form-label' }, _('Theme Base')), E('select', { - 'class': 'st-form-select', - 'id': 'cfg-theme_base' + 'class': 'st-form-input', + 'id': 'cfg-theme_base', + 'style': 'height: 42px;' }, [ E('option', { 'value': 'dark', 'selected': config.theme_base === 'dark' || !config.theme_base }, _('Dark')), E('option', { 'value': 'light', 'selected': config.theme_base === 'light' }, _('Light')) diff --git a/package/secubox/luci-app-streamlit/root/usr/share/rpcd/acl.d/luci-app-streamlit.json b/package/secubox/luci-app-streamlit/root/usr/share/rpcd/acl.d/luci-app-streamlit.json index 74e52d1..bc19e5e 100644 --- a/package/secubox/luci-app-streamlit/root/usr/share/rpcd/acl.d/luci-app-streamlit.json +++ b/package/secubox/luci-app-streamlit/root/usr/share/rpcd/acl.d/luci-app-streamlit.json @@ -3,13 +3,22 @@ "description": "Grant access to Streamlit Platform management", "read": { "ubus": { - "luci.streamlit": ["get_status", "get_config", "get_logs", "list_apps", "get_app", "get_install_progress"] + "luci.streamlit": [ + "get_status", "get_config", "get_logs", + "list_apps", "get_app", "get_install_progress", + "list_instances" + ] }, "uci": ["streamlit"] }, "write": { "ubus": { - "luci.streamlit": ["save_config", "start", "stop", "restart", "install", "uninstall", "update", "add_app", "remove_app", "set_active_app", "upload_app"] + "luci.streamlit": [ + "save_config", "start", "stop", "restart", + "install", "uninstall", "update", + "add_app", "remove_app", "set_active_app", "upload_app", + "add_instance", "remove_instance", "enable_instance", "disable_instance" + ] }, "uci": ["streamlit"] }