Files
evo-sync/web-python/templates/catalog_stores.html
mguschin 854c912a88 Migrate web app from Python/FastAPI to Node.js/TypeScript
Replace the entire Python/FastAPI backend with a Node.js/TypeScript stack:
- Framework: Hono + @hono/node-server
- Templates: Nunjucks (.njk) replacing Jinja2 (.html)
- ORM: Drizzle ORM with mysql2 (same MariaDB schema, no migrations needed)
- Sessions: hono-sessions with CookieStore
- CSS: Pico CSS v2 replacing Bootstrap 5 (Bootstrap Icons CDN kept)
- Dev: tsx watch; Prod: tsc + node dist/index.js

Original Python app preserved in web-python/ as backup.
Updated Dockerfile.web and docker-compose.yml for Node.js deployment.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 19:33:32 +03:00

114 lines
5.8 KiB
HTML

{% extends "base.html" %}
{% block title %}Каталог — ЭВОСИНК{% endblock %}
{% block content %}
<div class="d-flex align-items-center justify-content-between mb-3">
<h1 class="h4 mb-0">Каталог</h1>
<div class="d-flex gap-2">
{% if evotor %}
<form method="post" action="/catalog/refresh">
<button type="submit" class="btn btn-outline-secondary btn-sm">
<i class="bi bi-arrow-clockwise me-1"></i>Обновить
</button>
</form>
<a href="/catalog/export?type=stores" class="btn btn-outline-secondary btn-sm">
<i class="bi bi-download me-1"></i>Экспорт CSV
</a>
{% endif %}
</div>
</div>
{% if not evotor %}
<div class="alert alert-warning d-flex align-items-center gap-2">
<i class="bi bi-exclamation-triangle-fill"></i>
<span>Эвотор не подключён. <a href="/evotor">Подключить Эвотор</a></span>
</div>
{% elif not stores %}
<div class="text-center py-5 text-muted">
<i class="bi bi-shop fs-1 mb-3 d-block"></i>
<p>Магазины не найдены в вашем аккаунте Эвотор.</p>
</div>
{% else %}
{% if fetched_at %}
<p class="text-muted small mb-3">Последнее обновление: {{ fetched_at.strftime("%d.%m.%Y %H:%M") }}</p>
{% endif %}
<div class="table-responsive">
<table class="table table-striped table-hover align-middle">
<thead class="table-light">
<tr>
<th>Название</th>
<th>Адрес</th>
<th>Фильтр</th>
<th></th>
</tr>
</thead>
<tbody>
{% for store in stores %}
{% set mode = filter_map.get(store.evotor_id) %}
<tr>
<td>{{ store.name }}</td>
<td class="text-muted small">{{ store.address or "—" }}</td>
<td>
{% if mode == "include" %}
<span class="badge bg-success">✓ Включено</span>
{% elif mode == "exclude" %}
<span class="badge bg-danger">✗ Исключено</span>
{% else %}
<span class="badge bg-light text-muted border">— Нет правила</span>
{% endif %}
</td>
<td class="text-end">
<div class="d-flex gap-1 justify-content-end">
<a href="/catalog/groups?store_id={{ store.evotor_id }}"
class="btn btn-outline-secondary btn-sm" title="Группы">
<i class="bi bi-arrow-right"></i>
</a>
<div class="dropdown">
<button class="btn btn-outline-secondary btn-sm dropdown-toggle" data-bs-toggle="dropdown">
<i class="bi bi-funnel"></i>
</button>
<ul class="dropdown-menu dropdown-menu-end">
<li>
<form method="post" action="/catalog/filter">
<input type="hidden" name="entity_type" value="store">
<input type="hidden" name="entity_id" value="{{ store.evotor_id }}">
<input type="hidden" name="entity_name" value="{{ store.name }}">
<input type="hidden" name="filter_mode" value="include">
<input type="hidden" name="redirect_to" value="/catalog">
<button type="submit" class="dropdown-item">✓ Включить в синхронизацию</button>
</form>
</li>
<li>
<form method="post" action="/catalog/filter">
<input type="hidden" name="entity_type" value="store">
<input type="hidden" name="entity_id" value="{{ store.evotor_id }}">
<input type="hidden" name="entity_name" value="{{ store.name }}">
<input type="hidden" name="filter_mode" value="exclude">
<input type="hidden" name="redirect_to" value="/catalog">
<button type="submit" class="dropdown-item">✗ Исключить из синхронизации</button>
</form>
</li>
<li><hr class="dropdown-divider"></li>
<li>
<form method="post" action="/catalog/filter">
<input type="hidden" name="entity_type" value="store">
<input type="hidden" name="entity_id" value="{{ store.evotor_id }}">
<input type="hidden" name="entity_name" value="{{ store.name }}">
<input type="hidden" name="filter_mode" value="none">
<input type="hidden" name="redirect_to" value="/catalog">
<button type="submit" class="dropdown-item text-muted">— Убрать правило</button>
</form>
</li>
</ul>
</div>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
{% endblock %}