Rework Dashboard, add toasts, container folders/icons/WebUI links, detail tabs
Dashboard: - Plain-count stat tiles (Running/Stopped/Pods/Images/Volumes/Networks) separated from a single "Resource Usage" card (CPU/Memory/Swap/Storage meter rows) instead of forcing both into one tile grid, which produced awkward spanning-tile/dead-cell layouts. - Fixed CPU usage never changing (libpod's own cpuUtilization is computed once and never resampled) by computing it from /proc/stat deltas instead. - Fixed memory usage reading far too high by using /proc/meminfo's MemAvailable instead of libpod's raw (non-reclaimable-aware) memFree. - Added an Autostart Queue table reusing podman-autostart.sh's own failure-counter files. - Dashboard and Containers now auto-refresh every ~2s (paused when the tab is hidden or a modal is open). Toasts: - Real success/warn/error/info toast notifications replacing every alert() used for one-way feedback, across every panel. Container detail modal: - 5 new tabs: Resources, Logs, Console, Events, Healthcheck. Containers panel: - Folders to group containers (name + icon), stored in the plugin's own folders.json — a folder's header always shows an icon+name+status chip per member, matching Unraid's own Docker page folders. "Move to Folder" becomes "Remove from Folder" once a container is already grouped. - Containers can carry an icon URL and a WebUI URL (small button next to the name), both stored as container labels and auto-filled from templates where applicable. - Settings: an "Add container" control for the Autostart order table. Fixes: - Context menus now measure their own rendered size and flip above the anchor when there isn't room below, instead of running off-screen. - Containers table now uses table-layout:fixed with explicit column widths — auto layout was shifting every column (and the header) on every folder expand/collapse, and briefly again when a flex wrapper was mistakenly placed directly on a <td>. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* ajax/folders.php
|
||||
*
|
||||
* Container folders — a purely cosmetic, plugin-owned organizational
|
||||
* feature for the Containers panel. podman/libpod itself has no concept
|
||||
* of "folders"; this is grouping metadata only (name + icon + which
|
||||
* container names belong to it), similar to Unraid's own Docker page's
|
||||
* folders. Stored as JSON at PodmanConfig::$foldersFile — not a
|
||||
* PodmanClient/libpod concern, see Config.php.
|
||||
*
|
||||
* Actions (?action=...):
|
||||
* list GET -> {"folders": [{"id": "...", "name": "...", "icon": "...", "containers": ["name", ...]}, ...]}
|
||||
* save POST {"folders": [...]} -> persists the whole list (same
|
||||
* whole-list-replace pattern settings.php's autostart_save uses
|
||||
* — the frontend already holds the full, current structure in
|
||||
* memory after any add/rename/reassign, so there's no need for
|
||||
* narrower per-folder mutation endpoints)
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require __DIR__ . '/../include/bootstrap.php';
|
||||
|
||||
$action = $_GET['action'] ?? '';
|
||||
|
||||
switch ($action) {
|
||||
case 'list':
|
||||
podman_json_response(['folders' => folders_read($podmanConfig)]);
|
||||
break;
|
||||
|
||||
case 'save':
|
||||
$body = podman_read_json_body();
|
||||
podman_json_response(['folders' => folders_save($podmanConfig, is_array($body['folders'] ?? null) ? $body['folders'] : [])]);
|
||||
break;
|
||||
|
||||
default:
|
||||
podman_json_error("Unknown action '{$action}'", 400);
|
||||
}
|
||||
|
||||
/** @return array<int,array<string,mixed>> */
|
||||
function folders_read(PodmanConfig $config): array
|
||||
{
|
||||
if (!is_readable($config->foldersFile)) {
|
||||
return [];
|
||||
}
|
||||
$decoded = json_decode((string) file_get_contents($config->foldersFile), true);
|
||||
return is_array($decoded) ? $decoded : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-validates and normalizes before writing — a folder with no name (or
|
||||
* whose name became empty through some client-side bug) is silently
|
||||
* dropped rather than persisted as junk that would then need cleaning up
|
||||
* by hand in the JSON file directly.
|
||||
*
|
||||
* @param array<int,mixed> $folders
|
||||
* @return array<int,array<string,mixed>> the normalized list actually written
|
||||
*/
|
||||
function folders_save(PodmanConfig $config, array $folders): array
|
||||
{
|
||||
$clean = [];
|
||||
foreach ($folders as $f) {
|
||||
if (!is_array($f)) {
|
||||
continue;
|
||||
}
|
||||
$name = trim((string) ($f['name'] ?? ''));
|
||||
if ($name === '') {
|
||||
continue;
|
||||
}
|
||||
$containers = [];
|
||||
foreach (($f['containers'] ?? []) as $n) {
|
||||
$n = trim((string) $n);
|
||||
if ($n !== '') {
|
||||
$containers[] = $n;
|
||||
}
|
||||
}
|
||||
$clean[] = [
|
||||
'id' => (string) ($f['id'] ?? '') !== '' ? (string) $f['id'] : bin2hex(random_bytes(6)),
|
||||
'name' => $name,
|
||||
'icon' => trim((string) ($f['icon'] ?? '')),
|
||||
'containers' => $containers,
|
||||
];
|
||||
}
|
||||
|
||||
if (file_put_contents($config->foldersFile, json_encode($clean, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), LOCK_EX) === false) {
|
||||
podman_json_error("Could not write {$config->foldersFile}", 500);
|
||||
}
|
||||
|
||||
return $clean;
|
||||
}
|
||||
Reference in New Issue
Block a user