diff --git a/services/api-server/src/api_server/html5.py b/services/api-server/src/api_server/html5.py
index 3e9a136..a3948ca 100644
--- a/services/api-server/src/api_server/html5.py
+++ b/services/api-server/src/api_server/html5.py
@@ -140,6 +140,76 @@ def render_html5_editor(
return _page(f"SFERA HTML5 - {project_id}", content)
+def render_html5_project_setup(*, project_id: str, projects: Iterable[object], setup: object) -> str:
+ project_nav = "\n".join(_project_link(project, project_id) for project in projects)
+ name = _setup_name(setup)
+ sources = getattr(setup, "import_sources", []) or []
+ source_cards = "".join(_import_source_card(source) for source in sources)
+ content = f"""
+
+ {_topbar(project_id, project_nav)}
+
+
+
+ {render_html5_setup_summary(project_id, setup)}
+
+
+
+ """
+ return _page(f"SFERA HTML5 setup - {project_id}", content)
+
+
+def render_html5_setup_summary(project_id: str, setup: object) -> str:
+ status = _enum_text(getattr(setup, "status", "unknown"))
+ message = str(getattr(setup, "message", ""))
+ current_source = _enum_text(getattr(setup, "current_source", None) or "не выбран")
+ last_import = getattr(setup, "last_import", None)
+ history = getattr(setup, "import_history", []) or []
+ return f"""
+
+
+
+
Server-rendered status
+
{escape(status)}
+
+
{escape(current_source)}
+
+
{escape(message)}
+
+ {_metric("Объекты", _import_value(last_import, "object_count"))}
+ {_metric("Модули", _import_value(last_import, "module_count"))}
+ {_metric("Формы", _import_value(last_import, "form_count"))}
+ {_metric("Роли", _import_value(last_import, "role_count"))}
+
+
Последняя загрузка
+ {_last_import_block(last_import)}
+
История
+
+ {''.join(_history_item(item) for item in history[:6]) or '
История импорта пока пустая
'}
+
+
+ """
+
+
def render_html5_status(project_id: str, snapshot: SirSnapshot) -> str:
return (
f'project: {escape(project_id)}'
@@ -200,7 +270,10 @@ def _project_row(project: object) -> str:
{escape(name)}{escape(project_id)} |
{escape(status)} |
{'yes' if has_snapshot else 'no'} |
- Открыть HTML5 |
+
+ IDE
+ Setup
+ |
"""
@@ -217,10 +290,76 @@ def _topbar(project_id: str, project_nav: str) -> str:
SFERA
API
+ HTML5 Setup
Legacy Next
"""
+def _setup_name(setup: object) -> str:
+ settings = getattr(setup, "settings", None)
+ return str(getattr(settings, "name", None) or getattr(setup, "project_id", "SFERA Project"))
+
+
+def _enum_text(value: object) -> str:
+ if value is None:
+ return ""
+ return str(value.value if hasattr(value, "value") else value)
+
+
+def _import_value(import_summary: object | None, field: str) -> int | str:
+ if import_summary is None:
+ return "0"
+ return getattr(import_summary, field, 0)
+
+
+def _metric(label: str, value: object) -> str:
+ return f"{escape(label)}{escape(str(value))}"
+
+
+def _last_import_block(import_summary: object | None) -> str:
+ if import_summary is None:
+ return 'Загрузка еще не выполнялась
'
+ source = _enum_text(getattr(import_summary, "source", ""))
+ status = str(getattr(import_summary, "status", ""))
+ source_path = str(getattr(import_summary, "source_path", "") or "source path unavailable")
+ runtime = str(getattr(import_summary, "runtime_mode", "") or "runtime unavailable")
+ return f"""
+
+ {escape(status)}
+ {escape(source)} · {escape(runtime)}
+ {escape(source_path)}
+
+ """
+
+
+def _history_item(item: object) -> str:
+ source = _enum_text(getattr(item, "source", ""))
+ status = str(getattr(item, "status", ""))
+ objects = getattr(item, "object_count", 0)
+ modules = getattr(item, "module_count", 0)
+ return f"""
+
+ {escape(status)}
+ {escape(source)}
+ {escape(str(objects))} objects · {escape(str(modules))} modules
+
+ """
+
+
+def _import_source_card(source: object) -> str:
+ kind = _enum_text(getattr(source, "kind", ""))
+ title = str(getattr(source, "title", kind))
+ description = str(getattr(source, "description", ""))
+ readiness = str(getattr(source, "readiness", ""))
+ return f"""
+
+ {escape(title)}
+ {escape(kind)}
+ {escape(readiness or description)}
+
+ """
+
+
def _tree_item(project_id: str, node: object) -> str:
name = getattr(node, "qualified_name", None) or getattr(node, "name", "")
kind = getattr(node, "kind", "")
@@ -272,5 +411,7 @@ def _css() -> str:
.layout{display:grid;grid-template-columns:280px minmax(0,1fr)320px;height:calc(100vh - 88px)}.panel{overflow:auto}.panel-title{padding:12px;border-bottom:1px solid var(--line);font-size:12px;font-weight:900;text-transform:uppercase;color:var(--muted)}.tree-item{display:block;padding:10px 12px;border-bottom:1px solid var(--line);text-decoration:none}.tree-item span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tree-item small{color:var(--muted)}
.editor{min-width:0;overflow:hidden;border-top:0;border-bottom:0}.editor-head{height:72px;border-bottom:1px solid var(--line);padding:0 14px}.editor-head h1{margin:0;font-size:18px}.search{display:flex;gap:6px}.search input{height:32px;width:260px;border:1px solid var(--line);padding:0 10px}.code{height:calc(100% - 72px);margin:0;overflow:auto;padding:16px;background:#fbfaf7;font:13px/1.55 ui-monospace,SFMono-Regular,Consolas,monospace;white-space:pre-wrap}
.metrics{display:grid;grid-template-columns:1fr 1fr;margin:0}.metrics div{padding:12px;border-bottom:1px solid var(--line)}.metrics dt{color:var(--muted);font-size:12px}.metrics dd{margin:2px 0 0;font-size:22px;font-weight:800}.compact{list-style:none;margin:0;padding:0}.compact li{display:flex;justify-content:space-between;padding:8px 12px;border-bottom:1px solid var(--line)}.symbol{display:grid;gap:3px;padding:10px 12px;border-bottom:1px solid var(--line)}.symbol span,.symbol small{color:var(--muted)}.status{position:fixed;bottom:0;left:0;right:0;display:flex;gap:18px;overflow:auto;height:34px;align-items:center;border-top:1px solid var(--line);background:#fff;padding:0 12px;color:var(--muted);font-size:12px}.empty-state{max-width:720px;margin:80px auto;background:#fff;border:1px solid var(--line);padding:28px}
+.setup-layout{display:grid;grid-template-columns:340px minmax(0,1fr);gap:16px;max-width:1180px;margin:18px auto;padding:0 16px}.setup-workspace{background:#f3f6fb}.setup-card{padding:16px;border-bottom:1px solid var(--line)}.setup-card h1{margin:0;font-size:24px}.setup-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:14px}.setup-main{min-height:620px}.setup-summary{display:grid;gap:0}.compact-lead{margin:0;padding:0 16px 16px}.setup-metrics{display:grid;grid-template-columns:repeat(4,1fr);margin:0;border-top:1px solid var(--line)}.setup-metrics div{padding:16px;border-right:1px solid var(--line);border-bottom:1px solid var(--line)}.setup-metrics div:last-child{border-right:0}.setup-metrics dt{font-size:12px;color:var(--muted)}.setup-metrics dd{margin:4px 0 0;font-size:28px;font-weight:900}.status-pill{border:1px solid var(--line);padding:6px 10px;background:#eef6f1;color:var(--ok);font-weight:800}.flush{border-top:1px solid var(--line)}.padded{padding:12px 16px;margin:0}.setup-detail,.history-item,.source-card{display:grid;gap:3px;padding:12px 16px;border-bottom:1px solid var(--line)}.setup-detail span,.setup-detail small,.history-item span,.history-item small,.source-card span,.source-card small{color:var(--muted)}.source-list,.history-list{display:grid}
@media(max-width:980px){.layout{grid-template-columns:1fr;height:auto}.tree,.inspector{max-height:320px}.editor{min-height:520px}.hero{display:block}.shell{padding:16px}}
+@media(max-width:980px){.setup-layout{grid-template-columns:1fr}.setup-metrics{grid-template-columns:1fr 1fr}}
"""
diff --git a/services/api-server/src/api_server/main.py b/services/api-server/src/api_server/main.py
index e08c1a3..4130d60 100644
--- a/services/api-server/src/api_server/main.py
+++ b/services/api-server/src/api_server/main.py
@@ -35,7 +35,15 @@ from fastapi.responses import PlainTextResponse, Response, StreamingResponse
from neo4j import AsyncGraphDatabase
from pydantic import BaseModel, Field
-from api_server.html5 import render_html5_editor, render_html5_index, render_html5_source, render_html5_status, render_html5_symbols
+from api_server.html5 import (
+ render_html5_editor,
+ render_html5_index,
+ render_html5_project_setup,
+ render_html5_setup_summary,
+ render_html5_source,
+ render_html5_status,
+ render_html5_symbols,
+)
from impact_engine import object_impact, routine_impact
from incremental_indexer import rebuild_changed_file
from integration_topology import IntegrationKind, build_integration_topology
@@ -1639,6 +1647,24 @@ async def html5_project_source(project_id: str, lineage_id: str) -> Response:
)
+@app.get("/html5/projects/{project_id}/setup")
+async def html5_project_setup(project_id: str) -> Response:
+ setup = _project_setup_response(project_id)
+ return Response(
+ render_html5_project_setup(project_id=project_id, projects=_project_summaries(), setup=setup),
+ media_type="text/html; charset=utf-8",
+ )
+
+
+@app.get("/html5/projects/{project_id}/setup/summary")
+async def html5_project_setup_summary(project_id: str) -> Response:
+ setup = _project_setup_response(project_id)
+ return Response(
+ render_html5_setup_summary(project_id, setup),
+ media_type="text/html; charset=utf-8",
+ )
+
+
@app.get("/version")
async def version() -> dict[str, str]:
return {"name": "sfera", "version": "0.1.0"}
diff --git a/services/api-server/tests/test_api.py b/services/api-server/tests/test_api.py
index 5e60419..aaf9e1d 100644
--- a/services/api-server/tests/test_api.py
+++ b/services/api-server/tests/test_api.py
@@ -142,6 +142,48 @@ def test_html5_server_rendered_project_editor(tmp_path: Path):
assert "