Show AI structure path errors in HTML5
This commit is contained in:
@@ -25,6 +25,7 @@ def render_html5_ai_structure_page(*, project_id: str, projects: Iterable[object
|
||||
<section class="panel setup-main">
|
||||
<div class="panel-title">Подготовка структуры</div>
|
||||
{render_html5_ai_structure_form(project_id)}
|
||||
<p class="object-summary">Пути должны быть доступны серверу SFERA/API. Для docker-test используйте папку, смонтированную или доступную внутри контейнера; локальные диски Windows и закрытые SMB-папки без учетных данных сервер не увидит.</p>
|
||||
<div data-html5-ai-structure-result>{render_html5_ai_structure_result(result)}</div>
|
||||
</section>
|
||||
</section>
|
||||
@@ -43,11 +44,11 @@ def render_html5_ai_structure_form(project_id: str) -> str:
|
||||
>
|
||||
<label>
|
||||
<span>Папка с cf/cfe или выгрузкой</span>
|
||||
<input name="input_path" placeholder="D:\\1c\\source" />
|
||||
<input name="input_path" value="\\\\192.168.220.200\\mst\\1c\\MARKA\\CODEX\\CF" />
|
||||
</label>
|
||||
<label>
|
||||
<span>Папка результата</span>
|
||||
<input name="output_path" placeholder="D:\\sfera-ai\\result" />
|
||||
<input name="output_path" value="\\\\192.168.220.200\\mst\\1c\\MARKA\\CODEX\\CODEX" />
|
||||
</label>
|
||||
<label>
|
||||
<span>Project id</span>
|
||||
@@ -85,6 +86,21 @@ def render_html5_ai_structure_result(result: dict | None) -> str:
|
||||
"""
|
||||
|
||||
|
||||
def render_html5_ai_structure_error(message: str) -> str:
|
||||
return f"""
|
||||
<section class="ai-structure-result" data-html5-ai-structure-status="error">
|
||||
<div class="access-plan-head">
|
||||
<span class="status-pill">ошибка</span>
|
||||
<strong>Подготовка не выполнена</strong>
|
||||
</div>
|
||||
<ul class="access-warnings">
|
||||
<li>{escape(message)}</li>
|
||||
</ul>
|
||||
<p class="muted padded">Проверьте, что входная и выходная папки доступны именно серверу SFERA/API. Если файлы лежат на рабочем ПК, сначала положите их в общую папку или выполните экспорт через агент.</p>
|
||||
</section>
|
||||
"""
|
||||
|
||||
|
||||
def _diagnostics(items: list[object]) -> str:
|
||||
if not items:
|
||||
return ""
|
||||
|
||||
@@ -6,7 +6,11 @@ from typing import Any
|
||||
|
||||
from fastapi import HTTPException
|
||||
|
||||
from api_server.html5_ai_structure import render_html5_ai_structure_page, render_html5_ai_structure_result
|
||||
from api_server.html5_ai_structure import (
|
||||
render_html5_ai_structure_error,
|
||||
render_html5_ai_structure_page,
|
||||
render_html5_ai_structure_result,
|
||||
)
|
||||
from api_server.html5_forms import form_value
|
||||
|
||||
|
||||
@@ -28,8 +32,15 @@ def html5_ai_structure_run(
|
||||
input_path = form_value(form, "input_path")
|
||||
output_path = form_value(form, "output_path")
|
||||
if not input_path:
|
||||
raise HTTPException(status_code=400, detail="input_path is required")
|
||||
return render_html5_ai_structure_error("Заполните входную папку с .cf/.cfe или выгрузкой 1С.")
|
||||
if not output_path:
|
||||
raise HTTPException(status_code=400, detail="output_path is required")
|
||||
result = prepare(project_id=effective_project_id, input_path=Path(input_path), output_path=Path(output_path))
|
||||
return render_html5_ai_structure_error("Заполните папку результата.")
|
||||
try:
|
||||
result = prepare(project_id=effective_project_id, input_path=Path(input_path), output_path=Path(output_path))
|
||||
except FileNotFoundError as error:
|
||||
return render_html5_ai_structure_error(str(error))
|
||||
except PermissionError as error:
|
||||
return render_html5_ai_structure_error(f"Нет доступа к папке: {error}")
|
||||
except OSError as error:
|
||||
return render_html5_ai_structure_error(f"Ошибка файловой системы: {error}")
|
||||
return render_html5_ai_structure_result(result)
|
||||
|
||||
Reference in New Issue
Block a user