diff --git a/app/routes/apps.py b/app/routes/apps.py
index 50707e4..78c20b9 100644
--- a/app/routes/apps.py
+++ b/app/routes/apps.py
@@ -125,6 +125,11 @@ def index():
Vytváření záloh a kopírování příkazů pro obnovu. Obnova je záměrně ruční a chráněná.
diff --git a/app/routes/deployments.py b/app/routes/deployments.py
index ca7eb82..329adfb 100644
--- a/app/routes/deployments.py
+++ b/app/routes/deployments.py
@@ -1,30 +1,79 @@
-from fastapi import APIRouter, HTTPException, Request
+import html
+
+from fastapi import APIRouter, HTTPException
from fastapi.responses import HTMLResponse
-from fastapi.templating import Jinja2Templates
from app.db.apps import get_deployment, get_deployments
+from app.templates.layout import page
router = APIRouter()
-templates = Jinja2Templates(directory="app/templates")
-
@router.get("/deployments", response_class=HTMLResponse)
-async def deployments_page(request: Request):
+async def deployments_page():
deployments = get_deployments()
- return templates.TemplateResponse(
- request,
- "deployments.html",
- {
- "deployments": deployments,
- },
+ rows = ""
+ for deployment in deployments:
+ deployment_id = html.escape(str(deployment.get("id", "")))
+ app_id = html.escape(deployment.get("app_id", "") or "")
+ kind = html.escape(deployment.get("kind", "") or "")
+ status = html.escape(deployment.get("status", "") or "")
+ started_at = html.escape(deployment.get("started_at", "") or "")
+ finished_at = html.escape(deployment.get("finished_at", "") or "")
+ returncode = deployment.get("returncode")
+ returncode_label = "" if returncode is None else html.escape(str(returncode))
+
+ rows += f"""
+
+
+ #{deployment_id}
+ {started_at}
+ |
+ {app_id} |
+ {kind} |
+ {status} |
+ {returncode_label} |
+ {finished_at} |
+
+ Detail
+ |
+
+ """
+
+ if not rows:
+ rows = '
| Zatím nejsou evidovaná žádná nasazení. |
'
+
+ return page(
+ "Nasazení",
+ f"""
+
+
Historie nasazení
+
Přehled posledních běhů nasazení a jejich výsledků.
+
← Zpět na portál
+
+
+
+
Nasazení
+
+
+ | ID |
+ Aplikace |
+ Typ |
+ Status |
+ Kód |
+ Dokončeno |
+ Akce |
+
+ {rows}
+
+
+ """,
)
@router.get("/deployments/{deployment_id}", response_class=HTMLResponse)
async def deployment_detail_page(
- request: Request,
deployment_id: int,
):
deployment = get_deployment(deployment_id)
@@ -32,10 +81,46 @@ async def deployment_detail_page(
if not deployment:
raise HTTPException(status_code=404, detail="Deployment not found")
- return templates.TemplateResponse(
- request,
- "deployment-detail.html",
- {
- "deployment": deployment,
- },
+ title = f"Nasazení #{html.escape(str(deployment.get('id', deployment_id)))}"
+ app_id = html.escape(deployment.get("app_id", "") or "")
+ kind = html.escape(deployment.get("kind", "") or "")
+ status = html.escape(deployment.get("status", "") or "")
+ started_at = html.escape(deployment.get("started_at", "") or "")
+ finished_at = html.escape(deployment.get("finished_at", "") or "")
+ returncode = deployment.get("returncode")
+ returncode_label = "" if returncode is None else html.escape(str(returncode))
+ stdout = html.escape(deployment.get("stdout", "") or "")
+ stderr = html.escape(deployment.get("stderr", "") or "")
+
+ return page(
+ title,
+ f"""
+
+
+
+
Souhrn
+
+ | Aplikace | {app_id} |
+ | Typ | {kind} |
+ | Status | {status} |
+ | Návratový kód | {returncode_label} |
+ | Spuštěno | {started_at} |
+ | Dokončeno | {finished_at} |
+
+
+
+
+
Výstup
+
{stdout}
+
Chyba
+
{stderr}
+
+ """,
)
diff --git a/app/static/styles.css b/app/static/styles.css
index 0dcaad1..6a4497b 100644
--- a/app/static/styles.css
+++ b/app/static/styles.css
@@ -149,6 +149,18 @@ button:hover,
text-decoration: none;
}
+.btn + .btn {
+ margin-left: 8px;
+}
+
+.btn-secondary {
+ background: var(--secondary);
+}
+
+.btn-secondary:hover {
+ background: var(--secondary-dark);
+}
+
.danger {
background: var(--danger);
}
@@ -247,4 +259,4 @@ pre {
gap: 8px;
align-items: center;
flex-wrap: wrap;
-}
\ No newline at end of file
+}
diff --git a/app/templates/layout.py b/app/templates/layout.py
index 3c5f62c..1030483 100644
--- a/app/templates/layout.py
+++ b/app/templates/layout.py
@@ -20,6 +20,7 @@ def page(title: str, body: str) -> str: