diff --git a/README.md b/README.md index c7fd70a..ce4b436 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,133 @@ # deviceMap -LibreNMS plugin to locate indoor devices + +LibreNMS plugin to locate indoor devices using LeafletJS and multi-level floor mapping. + +--- + +## 🇮🇹 Descrizione + +**deviceMap** è un plugin per LibreNMS che consente di: + +- Visualizzare i dispositivi all'interno di edifici su una mappa indoor +- Supportare più piani (es. livello 0, 1, 2...) +- Mostrare lo stato dei dispositivi (es. Switch e Router ON/OFF) +- Mostrare lo stato delle **singole porte** (UP/DOWN) +- Gestire icone dinamiche in base allo zoom + +--- + +## 🇬🇧 Description + +**deviceMap** is a LibreNMS plugin to: + +- Display devices inside buildings on an indoor map +- Support multiple floors (e.g. level 0, 1, 2...) +- Show device status (Switch/Router ON/OFF) +- Show **individual port status** (UP/DOWN) +- Use dynamic icons depending on zoom level + +--- + +## 🛠️ Installazione / Installation + +1. Clona il repository: + +```bash +cd /opt/librenms/html/plugins/ +git clone https://github.com/viktec/deviceMap.git deviceMap +``` + +2. Rinomina il file `config.php.example` in `config.php`: + +```bash +cp deviceMap/config.php.example deviceMap/config.php +``` + +3. Inserisci il tuo API token di LibreNMS nel file `config.php`: + +```php + 'INSERISCI_IL_TUO_TOKEN' +]; +``` + +--- + +## 🗂️ File `data.json` + +### 🇮🇹 + +Il file `data.json` è un esempio di struttura GeoJSON per la planimetria di un edificio. +Ogni oggetto deve contenere una proprietà `level` all'interno di `reltags` per rappresentare il piano. + +Puoi usare più file `data.json` per gestire più edifici. + +### 🇬🇧 + +The `data.json` file is an example of a GeoJSON structure for a building floorplan. +Each object must contain a `level` property inside `reltags` to represent the floor. + +You can use multiple `data.json` files to represent multiple buildings. + +#### Esempio / Example: +```json +{ + "type": "FeatureCollection", + "features": [ + { + "properties": { + "tags": { + "buildingpart": "room" + }, + "relations": [ + { + "role": "buildingpart", + "rel": "....", + "reltags": { + "height": "4", + "level": "0", + "type": "level" + } + } + ], + "meta": {} + }, + "geometry": { + "type": "Polygon", + "coordinates": [...] + } + } + ] +} +``` + +--- + +## 🧭 Creazione della mappa (JOSM) + +Puoi generare il file `data.json` usando l’editor [**JOSM**](https://josm.openstreetmap.de/), importando livelli e planimetrie da disegno o da OpenStreetMap. + +--- + +## 📦 Contenuto del plugin + +- `deviceMap.php` – codice principale PHP +- `deviceMap.inc.html` – rendering HTML e JavaScript con Leaflet +- `leaflet-indoor.js`, `leaflet-src.js` – librerie di mappatura +- `icone/` – icone personalizzate per dispositivi e porte +- `config.php.example` – configurazione API +- `data.json` – esempio planimetria + +--- + +## ✍️ Autori + +Creato da **Vittorio Russo** +Supervisione: **Antonio Della Selva** – Università degli Studi di Urbino “Carlo Bo” + +--- + +## 🚀 Aggiornamenti + +Nuove funzionalità in arrivo... Stay tuned! 😉 diff --git a/config.php.example b/config.php.example new file mode 100644 index 0000000..bd86f14 --- /dev/null +++ b/config.php.example @@ -0,0 +1,5 @@ + 'YOUR_API_TOKEN_HERE' +]; + diff --git a/deviceMap.inc.html b/deviceMap.inc.html index 9ff6868..2140060 100644 --- a/deviceMap.inc.html +++ b/deviceMap.inc.html @@ -1,172 +1,233 @@ - - - - - - - - -
-
-
- + + + + -
-
-
- + \ No newline at end of file diff --git a/deviceMap.php b/deviceMap.php index ee81d15..ba8cef5 100644 --- a/deviceMap.php +++ b/deviceMap.php @@ -25,7 +25,7 @@ namespace LibreNMS\Plugins; -class deviceMap +class Map { public function menu() { @@ -39,7 +39,20 @@ public function device_overview_container($device) echo '
' . get_class() . ' Plugin
'; echo ' Plugin Mappatura
'; - include 'Map.inc.html'; + + $config = include __DIR__ . '/config.php'; + $token = $config['api_token']; + + echo ""; + + echo ""; + + include 'Map.inc.html'; + echo '
'; } diff --git a/icone/port-down.ico b/icone/port-down.ico new file mode 100644 index 0000000..ae5b0ed Binary files /dev/null and b/icone/port-down.ico differ diff --git a/icone/port-up.ico b/icone/port-up.ico new file mode 100644 index 0000000..25d7630 Binary files /dev/null and b/icone/port-up.ico differ diff --git a/icone/router-green.ico b/icone/router-green.ico new file mode 100644 index 0000000..0bf6602 Binary files /dev/null and b/icone/router-green.ico differ diff --git a/icone/router-red.ico b/icone/router-red.ico new file mode 100644 index 0000000..724a4d8 Binary files /dev/null and b/icone/router-red.ico differ diff --git a/icone/switch-off.ico b/icone/switch-off.ico new file mode 100644 index 0000000..e02a0e2 Binary files /dev/null and b/icone/switch-off.ico differ diff --git a/icone/switch-on.ico b/icone/switch-on.ico new file mode 100644 index 0000000..a96ad96 Binary files /dev/null and b/icone/switch-on.ico differ