seeding expansion
also: replace energy output with energy output density
This commit is contained in:
@@ -109,11 +109,13 @@ def create_app() -> Flask:
|
||||
from physcom_web.routes.domains import bp as domains_bp
|
||||
from physcom_web.routes.pipeline import bp as pipeline_bp
|
||||
from physcom_web.routes.results import bp as results_bp
|
||||
from physcom_web.routes.admin import bp as admin_bp
|
||||
|
||||
app.register_blueprint(entities_bp)
|
||||
app.register_blueprint(domains_bp)
|
||||
app.register_blueprint(pipeline_bp)
|
||||
app.register_blueprint(results_bp)
|
||||
app.register_blueprint(admin_bp)
|
||||
|
||||
@app.route("/")
|
||||
def index():
|
||||
|
||||
51
src/physcom_web/routes/admin.py
Normal file
51
src/physcom_web/routes/admin.py
Normal file
@@ -0,0 +1,51 @@
|
||||
"""Admin panel routes."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from flask import Blueprint, flash, redirect, render_template, url_for
|
||||
|
||||
from physcom.seed.transport_example import load_transport_seed
|
||||
from physcom_web.app import get_repo
|
||||
|
||||
bp = Blueprint("admin", __name__, url_prefix="/admin")
|
||||
|
||||
|
||||
@bp.route("/")
|
||||
def admin_index():
|
||||
repo = get_repo()
|
||||
entities = repo.list_entities()
|
||||
domains = repo.list_domains()
|
||||
status_counts = repo.count_combinations_by_status()
|
||||
runs = repo.list_pipeline_runs()
|
||||
stats = {
|
||||
"entities": len(entities),
|
||||
"domains": len(domains),
|
||||
"combinations": sum(status_counts.values()),
|
||||
"pipeline_runs": len(runs),
|
||||
}
|
||||
return render_template("admin/index.html", stats=stats)
|
||||
|
||||
|
||||
@bp.route("/reseed", methods=["POST"])
|
||||
def reseed():
|
||||
repo = get_repo()
|
||||
counts = load_transport_seed(repo)
|
||||
total = counts["platforms"] + counts["power_sources"]
|
||||
flash(
|
||||
f"Reseed complete — added {total} entities, {counts['domains']} domains.",
|
||||
"success",
|
||||
)
|
||||
return redirect(url_for("admin.admin_index"))
|
||||
|
||||
|
||||
@bp.route("/wipe-and-reseed", methods=["POST"])
|
||||
def wipe_and_reseed():
|
||||
repo = get_repo()
|
||||
repo.clear_all()
|
||||
counts = load_transport_seed(repo)
|
||||
total = counts["platforms"] + counts["power_sources"]
|
||||
flash(
|
||||
f"Wiped all data and reseeded — {total} entities, {counts['domains']} domains.",
|
||||
"success",
|
||||
)
|
||||
return redirect(url_for("admin.admin_index"))
|
||||
@@ -647,5 +647,11 @@ select option {
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
|
||||
/* ── Admin warning box ──────────────────────────────────── */
|
||||
.warning-box {
|
||||
border-color: rgba(184,147,92,0.4);
|
||||
background: rgba(184,147,92,0.06);
|
||||
}
|
||||
|
||||
/* ── Google Fonts import ─────────────────────────────────── */
|
||||
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;500;600&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');
|
||||
|
||||
51
src/physcom_web/templates/admin/index.html
Normal file
51
src/physcom_web/templates/admin/index.html
Normal file
@@ -0,0 +1,51 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Admin — PhysCom{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Admin Panel</h1>
|
||||
|
||||
<div class="stats-row">
|
||||
<div class="stat-card">
|
||||
<div class="stat-value">{{ stats.entities }}</div>
|
||||
<div class="stat-label">Entities</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-value">{{ stats.domains }}</div>
|
||||
<div class="stat-label">Domains</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-value">{{ stats.combinations }}</div>
|
||||
<div class="stat-label">Combinations</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-value">{{ stats.pipeline_runs }}</div>
|
||||
<div class="stat-label">Pipeline Runs</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2>Seed Data</h2>
|
||||
<div class="card-grid">
|
||||
<div class="card">
|
||||
<h3>Reseed (Additive)</h3>
|
||||
<p class="subtitle">
|
||||
Add any missing seed entities and domains. Existing user-created data is
|
||||
preserved — only entries that don't already exist are inserted.
|
||||
</p>
|
||||
<form method="post" action="{{ url_for('admin.reseed') }}" style="margin-top: 0.75rem">
|
||||
<button type="submit" class="btn btn-primary">Reseed</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="card warning-box">
|
||||
<h3>Wipe & Reseed</h3>
|
||||
<p class="subtitle">
|
||||
Delete <strong>all</strong> data — entities, domains, combinations,
|
||||
pipeline runs — then reload seed data from scratch.
|
||||
</p>
|
||||
<form method="post" action="{{ url_for('admin.wipe_and_reseed') }}" style="margin-top: 0.75rem"
|
||||
onsubmit="return confirm('This will permanently delete ALL data and reseed from scratch. Continue?')">
|
||||
<button type="submit" class="btn btn-danger">Wipe & Reseed</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -19,6 +19,7 @@
|
||||
<li><a href="{{ url_for('domains.domain_list') }}">Domains</a></li>
|
||||
<li><a href="{{ url_for('pipeline.pipeline_form') }}">Pipeline</a></li>
|
||||
<li><a href="{{ url_for('results.results_index') }}">Results</a></li>
|
||||
<li><a href="{{ url_for('admin.admin_index') }}">Admin</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user