diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 9e18bea3..78488237 100755 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -52,7 +52,7 @@ Backend loop phases (see `server/__main__.py` and `server/plugin.py`): `once`, ` ## Conventions & helpers to reuse - Settings: add/modify via `ccd()` in `server/initialise.py` or per‑plugin manifest. Never hardcode ports or secrets; use `get_setting_value()`. -- Logging: use `mylog(level, [message])`; levels: none/minimal/verbose/debug/trace. `none` is used for most important messages that should always appear, such as exceptions. +- Logging: use `mylog(level, [message])`; levels: none/minimal/verbose/debug/trace. `none` is used for most important messages that should always appear, such as exceptions. Do NOT use `error` as level. - Time/MAC/strings: `server/utils/datetime_utils.py` (`timeNowDB`), `front/plugins/plugin_helper.py` (`normalize_mac`), `server/helper.py` (sanitizers). Validate MACs before DB writes. - DB helpers: prefer `server/db/db_helper.py` functions (e.g., `get_table_json`, device condition helpers) over raw SQL in new paths. @@ -71,6 +71,9 @@ Backend loop phases (see `server/__main__.py` and `server/plugin.py`): `once`, ` - When adding a plugin, start from `front/plugins/__template`, implement with `plugin_helper`, define manifest settings, and wire phase via `_RUN`. Verify logs in `/tmp/log/plugins/` and data in `api/*.json`. - When introducing new config, define it once (core `ccd()` or plugin manifest) and read it via helpers everywhere. - When exposing new server functionality, add endpoints in `server/api_server/*` and keep authorization consistent; update UI by reading/writing JSON cache rather than bypassing the pipeline. +- Always try following the DRY principle, do not re-implement functionality, but re-use existing methods where possible, or refactor to use a common method that is called multiple times +- If new functionality needs to be added, look at impenting it into existing handlers (e.g. `DeviceInstance` in `server/models/device_instance.py`) or create a new one if it makes sense. Do not access the DB from otehr application layers. +- Code files shoudln't be longer than 500 lines of code ## Useful references - Docs: `docs/PLUGINS_DEV.md`, `docs/SETTINGS_SYSTEM.md`, `docs/API_*.md`, `docs/DEBUG_*.md` diff --git a/docs/API_SESSIONS.md b/docs/API_SESSIONS.md index e5a4e746..94224aa4 100755 --- a/docs/API_SESSIONS.md +++ b/docs/API_SESSIONS.md @@ -118,11 +118,14 @@ curl -X DELETE "http://:/sessions/delete" \ ``` #### `curl` Example +**get sessions for mac** + ```bash curl -X GET "http://:/sessions/list?mac=AA:BB:CC:DD:EE:FF&start_date=2025-08-01&end_date=2025-08-21" \ -H "Authorization: Bearer " \ -H "Accept: application/json" ``` + --- ### Calendar View of Sessions diff --git a/docs/DOCKER_COMPOSE.md b/docs/DOCKER_COMPOSE.md index 0d8d1a17..0d0277fe 100755 --- a/docs/DOCKER_COMPOSE.md +++ b/docs/DOCKER_COMPOSE.md @@ -173,10 +173,6 @@ Now, any files created by NetAlertX in `/data/config` will appear in your `/loca This same method works for mounting other things, like custom plugins or enterprise NGINX files, as shown in the commented-out examples in the baseline file. -## Example Configuration Summaries - -Here are the essential modifications for common alternative setups. - ### Example 2: External `.env` File for Paths This method is useful for keeping your paths and other settings separate from your main compose file, making it more portable. diff --git a/docs/DOCKER_INSTALLATION.md b/docs/DOCKER_INSTALLATION.md index 001753fc..4d9e5d61 100644 --- a/docs/DOCKER_INSTALLATION.md +++ b/docs/DOCKER_INSTALLATION.md @@ -48,7 +48,7 @@ See alternative [docked-compose examples](https://github.com/jokob-sk/NetAlertX/ | Variable | Description | Example/Default Value | | :------------- |:------------------------| -----:| -| `PUID` |Runtime UID override, Set to `0` to run as root. | `20211` | +| `PUID` |Runtime UID override, set to `0` to run as root. | `20211` | | `PGID` |Runtime GID override | `20211` | | `PORT` |Port of the web interface | `20211` | | `LISTEN_ADDR` |Set the specific IP Address for the listener address for the nginx webserver (web interface). This could be useful when using multiple subnets to hide the web interface from all untrusted networks. | `0.0.0.0` |