From 3a206f09965817dd1003a2153b5b2adeb1dc9975 Mon Sep 17 00:00:00 2001 From: "Jokob @NetAlertX" <96159884+jokob-sk@users.noreply.github.com> Date: Wed, 17 Jun 2026 06:43:26 +0000 Subject: [PATCH 1/4] Add REST Import plugin and corresponding tests - Implemented the REST Import plugin (rest_import.py) to handle importing data from REST APIs. - Added functionality for configurable HTTP methods, authentication types, and custom headers. - Included error handling for various HTTP response statuses and connection issues. - Created unit tests for the plugin covering header building, path resolution, MAC validation, record mapping, and authentication methods. - Ensured that module-level side effects are patched during tests to prevent live interactions. --- .../skills/plugin-development/plugin-skill.md | 16 + front/css/app.css | 7 + front/js/modal.js | 7 +- front/js/settings_utils.js | 1 + front/php/templates/modals.php | 2 +- front/plugins/rest_import/README.md | 84 + front/plugins/rest_import/config.json | 1459 +++++++++++++++++ front/plugins/rest_import/rest_import.py | 294 ++++ test/plugins/test_rest_import.py | 237 +++ 9 files changed, 2105 insertions(+), 2 deletions(-) create mode 100644 .gemini/skills/plugin-development/plugin-skill.md create mode 100644 front/plugins/rest_import/README.md create mode 100644 front/plugins/rest_import/config.json create mode 100644 front/plugins/rest_import/rest_import.py create mode 100644 test/plugins/test_rest_import.py diff --git a/.gemini/skills/plugin-development/plugin-skill.md b/.gemini/skills/plugin-development/plugin-skill.md new file mode 100644 index 000000000..215d9bf22 --- /dev/null +++ b/.gemini/skills/plugin-development/plugin-skill.md @@ -0,0 +1,16 @@ +# Plugin development skill + +1. Assess requirements +2. Read `docs/PLUGINS_DEV.md` +3. Confirm field mapping +4. Ask clarifying questions +5. code placed in `front/plugins/` + + +Plugin prefix: + +- has to be uppercase letters only (no underscores) +- must be unique +- keep short but readable if possible + + diff --git a/front/css/app.css b/front/css/app.css index 4a5b39fab..333da974e 100755 --- a/front/css/app.css +++ b/front/css/app.css @@ -1846,6 +1846,13 @@ textarea[readonly], display: grid; } +@media (min-width: 768px) { + .modal-dialog { + width: 750px; + margin: 30px auto; + } +} + /* ----------------------------------------------------------------- */ /* NETWORK page */ /* ----------------------------------------------------------------- */ diff --git a/front/js/modal.js b/front/js/modal.js index 0c4ec1fb6..b5d6113c0 100755 --- a/front/js/modal.js +++ b/front/js/modal.js @@ -208,7 +208,12 @@ function showModalPopupForm( } } - const fieldOptionsOverride = field.type?.elements[0]?.elementOptions || []; + // For select elements use field.options (the selectable values); for all other + // element types fall back to elementOptions (used for input attributes like placeholder). + const elementType = field.type?.elements[0]?.elementType; + const fieldOptionsOverride = (elementType === 'select' && field.options?.length) + ? field.options + : (field.type?.elements[0]?.elementOptions || []); const setValue = initialValue; const setType = JSON.stringify(field.type); const setEvents = field.events || []; // default to empty array if missing diff --git a/front/js/settings_utils.js b/front/js/settings_utils.js index ec6d00bc1..6cb01e622 100755 --- a/front/js/settings_utils.js +++ b/front/js/settings_utils.js @@ -1175,6 +1175,7 @@ function generateFormHtml(settingsData, set, overrideValue, overrideOptions, ori // Parse the setType JSON string // console.log(processQuotes(setType)); + console.log(setType); const setTypeObject = JSON.parse(processQuotes(setType)) const dataType = setTypeObject.dataType; diff --git a/front/php/templates/modals.php b/front/php/templates/modals.php index f7432290f..f142d2de3 100755 --- a/front/php/templates/modals.php +++ b/front/php/templates/modals.php @@ -129,7 +129,7 @@ - +