From 0e88a15edb51990340322bca6146b05789350309 Mon Sep 17 00:00:00 2001
From: Jean-Yves <7360784+docjyJ@users.noreply.github.com>
Date: Sat, 1 Mar 2025 20:57:21 +0100
Subject: [PATCH] Add container state component for improved status display and
hide password by default
Signed-off-by: Jean-Yves <7360784+docjyJ@users.noreply.github.com>
---
php/templates/components/container-state.twig | 23 +++++++++++++
php/templates/containers.twig | 34 +------------------
2 files changed, 24 insertions(+), 33 deletions(-)
create mode 100644 php/templates/components/container-state.twig
diff --git a/php/templates/components/container-state.twig b/php/templates/components/container-state.twig
new file mode 100644
index 00000000..cdf70016
--- /dev/null
+++ b/php/templates/components/container-state.twig
@@ -0,0 +1,23 @@
+{# @var c \App\Containers\Container #}
+
+ {% if c.GetStartingState().value == 'starting' %}
+
+ {% elseif c.GetRunningState().value == 'running' %}
+
+ {% else %}
+
+ {% endif %}
+
+ {{ c.GetDisplayName() }}
+ (Stopped)
+ {% if c.GetDocumentation() != '' %}
+ (docs)
+ {% endif %}
+
+ {% if c.GetUiSecret() != '' %}
+
+ Show password
+ {{ c.GetUiSecret() }}
+
+ {% endif %}
+
\ No newline at end of file
diff --git a/php/templates/containers.twig b/php/templates/containers.twig
index 1124c51a..96687dac 100644
--- a/php/templates/containers.twig
+++ b/php/templates/containers.twig
@@ -275,39 +275,7 @@
{# @var containers \AIO\Container\Container[] #}
{% for container in containers %}
{% if container.GetDisplayName() != '' %}
-
- {% if container.GetStartingState().value == 'starting' %}
-
- {{ container.GetDisplayName() }} (Starting)
- {% if container.GetDocumentation() != '' %}
- (docs)
- {% endif %}
- {% if container.GetUiSecret() != '' %}
- (password: {{ container.GetUiSecret() }})
- {% endif %}
-
- {% elseif container.GetRunningState().value == 'running' %}
-
- {{ container.GetDisplayName() }} (Running)
- {% if container.GetDocumentation() != '' %}
- (docs)
- {% endif %}
- {% if container.GetUiSecret() != '' %}
- (password: {{ container.GetUiSecret() }})
- {% endif %}
-
- {% else %}
-
- {{ container.GetDisplayName() }} (Stopped)
- {% if container.GetDocumentation() != '' %}
- (docs)
- {% endif %}
- {% if container.GetUiSecret() != '' %}
- (password: {{ container.GetUiSecret() }})
- {% endif %}
-
- {% endif %}
-
+ {% include 'components/container-state.twig' with {'c': container} only %}
{% endif %}
{% endfor %}