Files
maggesandClaude Sonnet 5 23898ff62e
Lint / ShellCheck (push) Successful in 11s
Lint / Validate .plg XML (push) Successful in 10s
Lint / EditorConfig (push) Successful in 6s
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>
2026-07-13 21:32:34 +00:00

109 lines
3.6 KiB
PHP

<?php
/**
* Config.php
*
* Reads unraid-podman's own settings so the WebUI and the shell-based
* plugin scripts under plugin/sbin/ agree on where everything lives —
* this file is the PHP-side counterpart of plugin/sbin/podman-common.sh's
* podman_load_cfg() function, and intentionally mirrors its defaults and
* paths exactly (see that script for the shell equivalent).
*/
declare(strict_types=1);
final class PodmanConfig
{
public string $storagePath;
public int $storageImageSizeGb;
public bool $enabled;
public int $stopTimeoutSeconds;
public string $socketPath;
public string $bootDir;
public string $autostartFile;
public string $autostartDelayFile;
public string $foldersFile;
private function __construct()
{
// Defaults mirror podman-common.sh's podman_load_cfg() defaults.
$this->bootDir = '/boot/config/plugins/podman';
$this->storagePath = '/mnt/cache/system/podman';
$this->storageImageSizeGb = 20;
$this->enabled = true;
$this->stopTimeoutSeconds = 10;
$this->socketPath = '/var/run/podman/podman.sock';
$this->autostartFile = $this->bootDir . '/autostart';
$this->autostartDelayFile = $this->bootDir . '/autostart-delay';
$this->foldersFile = $this->bootDir . '/folders.json';
}
public static function load(): self
{
$cfg = new self();
$cfgFile = $cfg->bootDir . '/podman.cfg';
if (is_readable($cfgFile)) {
$values = self::parseShellStyleFile($cfgFile);
if (isset($values['STORAGE_PATH'])) {
$cfg->storagePath = $values['STORAGE_PATH'];
}
if (isset($values['STORAGE_IMAGE_SIZE_GB'])) {
$cfg->storageImageSizeGb = (int) $values['STORAGE_IMAGE_SIZE_GB'];
}
if (isset($values['PODMAN_ENABLED'])) {
$cfg->enabled = strtolower($values['PODMAN_ENABLED']) === 'yes';
}
if (isset($values['STOP_TIMEOUT'])) {
$cfg->stopTimeoutSeconds = (int) $values['STOP_TIMEOUT'];
}
}
return $cfg;
}
/**
* Parses the simple `KEY="value"` / `KEY=value` shell-sourceable format
* used by podman.cfg (see config/podman.cfg.example) WITHOUT executing
* it as shell — this file is read by an unprivileged PHP-FPM worker,
* so treating it as data rather than sourcing it is a deliberate
* safety boundary, not just a convenience.
*
* @return array<string,string>
*/
private static function parseShellStyleFile(string $path): array
{
$result = [];
$lines = file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if ($lines === false) {
return $result;
}
foreach ($lines as $line) {
$line = trim($line);
if ($line === '' || str_starts_with($line, '#')) {
continue;
}
if (!preg_match('/^([A-Z_][A-Z0-9_]*)=(.*)$/', $line, $m)) {
continue;
}
[$_, $key, $value] = $m;
$value = trim($value);
// Strip one layer of matching quotes, if present.
if (strlen($value) >= 2 && (
($value[0] === '"' && str_ends_with($value, '"')) ||
($value[0] === "'" && str_ends_with($value, "'"))
)) {
$value = substr($value, 1, -1);
}
$result[$key] = $value;
}
return $result;
}
public function newClient(): PodmanClient
{
return new PodmanClient($this->socketPath);
}
}