diff --git a/modal_app.py b/modal_app.py index f914f51..4afd96c 100644 --- a/modal_app.py +++ b/modal_app.py @@ -2,11 +2,7 @@ import os app = modal.App("rootstock-admin") -app.image = ( - modal.Image.debian_slim() - .pip_install("fastapi[standard]", "jinja2") - .add_local_dir("./templates/", remote_path="/templates") -) +app.image = modal.Image.debian_slim().pip_install("fastapi[standard]") env = os.environ.get("MODAL_ENVIRONMENT", "dev") vol = modal.Volume.from_name(f"rootstock-admin-{env}", create_if_missing=True) @@ -30,31 +26,15 @@ def manifest(manifest: dict): @modal.fastapi_endpoint() def dashboard(): import json - from datetime import datetime from pathlib import Path - from fastapi.responses import HTMLResponse - from jinja2 import Environment, FileSystemLoader, select_autoescape vol.reload() - env = Environment( - loader=FileSystemLoader("/templates"), - autoescape=select_autoescape(), - ) - t = env.get_template("index.html.jinja") - manifest_path = Path("/data") manifest_files = manifest_path.glob("*.json") manifests = [] for mf in manifest_files: with open(mf, "r") as f: - data = json.load(f) - if "last_updated" in data: - try: - dt = datetime.fromisoformat(data["last_updated"]) - data["last_updated"] = dt.strftime("%b %d, %Y") - except ValueError: - pass - manifests.append(data) - - return HTMLResponse(t.render(manifests=manifests)) + manifests.append(json.load(f)) + + return {"manifests": manifests} diff --git a/templates/index.html.jinja b/templates/index.html.jinja deleted file mode 100644 index 031b875..0000000 --- a/templates/index.html.jinja +++ /dev/null @@ -1,272 +0,0 @@ - - - - - - - - Rootstock - - - -
- -
- -

Rootstock

-
-
- - - - - - - - -
- {% if manifests %} - -
-
-

Select a cluster from the sidebar

-
-
- - {% for manifest in manifests %} -
- -
-
-
-

{{ manifest.cluster }}

-

Rootstock v{{ manifest.rootstock_version }}

-
- - {{ manifest.environments | length }} env{{ 's' if manifest.environments | length != 1 else '' }} - -
-
-
-
- Root - -
-
{{ manifest.root }}
-
-
-
Python
-
{{ manifest.python_version }}
-
-
-
Maintainer
-
{{ manifest.maintainer.name }}
- {{ manifest.maintainer.email }} -
-
-
Last Updated
-
{{ manifest.last_updated }}
-
-
-
- - -

Environments

-
- {% for env_name, env in manifest.environments.items() %} -
- -
- {{ env_name }} - {% if env.status == 'ready' %} - Ready - {% else %} - {{ env.status }} - {% endif %} -
- - - -
- -
-
-
- Built: - {{ env.built_at }} -
-
- Python: - {{ env.python_requires }} -
-
- - {% if env.source %} -
- -

Source Code

-
- - - - -
-
-
-
{{ env.source }}
-
-
- {% endif %} - - {% if env.dependencies %} -
-

Dependencies ({{ env.dependencies | length }})

-
- - - {% for pkg, version in env.dependencies.items() %} - - - - - {% endfor %} - - - - - - -
{{ pkg }}{{ version }}
- -
-
-
- {% endif %} - - {% if env.checkpoints %} -
-

Checkpoints

-
- {% for checkpoint in env.checkpoints %} - {{ checkpoint }} - {% endfor %} -
-
- {% endif %} -
-
- {% endfor %} -
-
- {% endfor %} - {% else %} -
-
- - - -

No cluster configurations found

-
-
- {% endif %} -
-
- - - - - -