diff --git a/MEMORY.md b/MEMORY.md index 43018fc..cf1c61c 100644 --- a/MEMORY.md +++ b/MEMORY.md @@ -267,3 +267,51 @@ Il test del pulsante "Test API" continua a restituire 403 Forbidden quando acces - `src/AssetTab.php`: Aggiunti metodi `startBackup()`, `saveInternetMode()`, `saveDefaultDirs()` - `src/UrbackupApiClient.php`: Aggiunti metodi `updateClientSettings()`, `saveInternetMode()` - `front/asset.form.php`: Gestione azioni per salvataggio impostazioni e backup + +### Refactoring server.form.php e nuove tab (v0.4.7) + +**Data**: 2026-05-21 + +**Descrizione**: Restrutturazione completa della pagina server con tab laterali e nuove funzionalità: + +**Refactoring Server::showForm()**: +- Estratto `showFormFields(?int $ID)` da `showForm()` per permettere layout custom +- `showForm()` ora chiama header + fields + buttons in sequenza + +**Tab laterali (server.form.php)**: +- Side tabs a sinistra (col-2) con `nav-pills flex-column` +- 4 tab: Server, Linked clients, Unlinked clients, Missing clients +- Tab persistence via URL hash (JS su `shown.bs.tab`) + +**Missing clients tab**: +- Mostra asset GLPI con root location matching, non ancora collegati a ServerAsset e non presenti su UrBackup +- Colonne: Name (link all'asset), Entity, Location (completename), Inventory number, IP, State, User, Group +- Ricerca testuale client-side +- Ordinamento colonne click-to-sort vanilla JS +- Navigazione server spostata in server.form.php (sopra i tab, indipendente dalle sezioni) + +**Bug fix namespace risolto**: +- `getCachedName()` usava `new $classname()` con stringa → PHP cercava `GlpiPlugin\Urbackup\Group` invece di `\Group` +- Fix: `$fqcn = '\\' . ltrim($classname, '\\')` per forzare global namespace + +**Gruppo asset corretto**: +- Gruppo non in `glpi_computers.groups_id` (colonna inesistente) +- Letto da `glpi_groups_items` WHERE `type = 1` (GROUP_TYPE_NORMAL) +- Usa `completename` per gerarchia (es. "Helpdesk > Livello 1") + +**Indirizzo IP asset**: +- Query JOIN: `glpi_ipaddresses → glpi_networknames → glpi_networkports` +- Primo IP valido per l'item + +**Breadcrumb**: +- Cambiato da `'Assets'` a `'admin'` in `Html::header()` di server.php e server.form.php +- Mostra: Pagina principale > Amministrazione > UrBackup servers + +**Fix port default per nuovi server**: +- `prepareInputForAdd()` ora setta default 55414 per `port`, 'http' per `protocol`, 1 per `is_active`, ecc. +- `prepareInputForUpdate()` normalizza anche valori vuoti + +**File modificati**: +- `src/Server.php`: `showFormFields()`, `showMissingClientsTab()`, `getCachedName()` fix, `getAssetGroupName()`, `getAssetIp()`, `getCachedLocationName()`, `prepareInputForAdd/Update` default fix +- `front/server.form.php`: Tab laterali, tab hash JS, breadcrumb admin +- `front/server.php`: Breadcrumb admin, rimosso pulsante "Add" manuale (GLPI lo genera) diff --git a/front/server.form.php b/front/server.form.php index b8cade9..22e2037 100644 --- a/front/server.form.php +++ b/front/server.form.php @@ -47,13 +47,62 @@ $ID = $_GET['id'] ?? null; Html::header( $ID ? __('Edit UrBackup server', 'urbackup') : __('Add UrBackup server', 'urbackup'), '', - 'Assets', + 'admin', 'GlpiPlugin\Urbackup\Server' ); if ($ID > 0) { + global $DB; + $server->getFromDB($ID); + + $serverIterator = $DB->request([ + 'FROM' => Server::getTable(), + 'ORDER' => 'name', + ]); + $serverIds = []; + foreach ($serverIterator as $row) { + $serverIds[(int) $row['id']] = (string) $row['name']; + } + $serverIdKeys = array_keys($serverIds); + $currentIndex = array_search((int) $ID, $serverIdKeys, true); + $totalServers = count($serverIds); + $prevId = ($currentIndex !== false && $currentIndex > 0) ? $serverIdKeys[$currentIndex - 1] : null; + $nextId = ($currentIndex !== false && $currentIndex < $totalServers - 1) ? $serverIdKeys[$currentIndex + 1] : null; + + $baseUrl = PLUGIN_URBACKUP_WEB_DIR . '/front/server.form.php'; ?> +
| ' . htmlspecialchars(__('Name')) . ' | '; - echo '' . htmlspecialchars(Entity::getTypeName(1)) . ' | '; - echo '' . htmlspecialchars(Location::getTypeName(1)) . ' | '; - echo '' . htmlspecialchars(__('Inventory number')) . ' | '; - echo '' . htmlspecialchars(__('IP address', 'urbackup')) . ' | '; - echo '' . htmlspecialchars(State::getTypeName(1)) . ' | '; - echo '' . htmlspecialchars(User::getTypeName(1)) . ' | '; - echo '' . htmlspecialchars(Group::getTypeName(1)) . ' | '; - echo '' . htmlspecialchars(__('Actions', 'urbackup')) . ' | '; + echo '' . htmlspecialchars(__('Name')) . ' | '; + echo '' . htmlspecialchars(Entity::getTypeName(1)) . ' | '; + echo '' . htmlspecialchars(Location::getTypeName(1)) . ' | '; + echo '' . htmlspecialchars(__('Inventory number')) . ' | '; + echo '' . htmlspecialchars(__('IP address', 'urbackup')) . ' | '; + echo '' . htmlspecialchars(State::getTypeName(1)) . ' | '; + echo '' . htmlspecialchars(User::getTypeName(1)) . ' | '; + echo '' . htmlspecialchars(Group::getTypeName(1)) . ' | '; + echo '' . htmlspecialchars(__('Actions', 'urbackup')) . ' | '; echo '
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ' . htmlspecialchars($asset['name']) . ' | '; + echo ''; + if ($itemLink !== '') { + echo '' . htmlspecialchars($asset['name']) . ''; + } else { + echo htmlspecialchars($asset['name']); + } + echo ' | '; echo '' . htmlspecialchars($asset['entity']) . ' | '; echo '' . htmlspecialchars($asset['location']) . ' | '; echo '' . htmlspecialchars($asset['otherserial']) . ' | '; @@ -1190,6 +1236,50 @@ class Server extends CommonDBTM echo '