feat: vendor edit with name/website/mont_page in admin panel
This commit is contained in:
+169
-23
@@ -15,11 +15,16 @@
|
||||
<div>
|
||||
<strong>Админ-панель матрицы</strong>
|
||||
<div class="scope-switch" style="margin-top:8px;">
|
||||
{% if 'infra' in allowed_scopes %}
|
||||
<a class="scope-chip {% if scope == 'infra' %}active{% endif %}" href="{{ request.path }}?scope=infra">Инфраструктура</a>
|
||||
{% endif %}
|
||||
{% if 'ib' in allowed_scopes %}
|
||||
<a class="scope-chip {% if scope == 'ib' %}active{% endif %}" href="{{ request.path }}?scope=ib">ИБ</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div style="display:flex; gap:8px;">
|
||||
<div class="top-actions">
|
||||
<button class="pri" type="submit" form="matrixForm">Сохранить</button>
|
||||
<a href="/" style="text-decoration:none;"><button class="warn" type="button">На сайт</button></a>
|
||||
<form method="post" style="margin:0;">
|
||||
<input type="hidden" name="scope" value="{{ scope }}" />
|
||||
@@ -29,6 +34,102 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||
{% if messages %}
|
||||
<section class="alerts">
|
||||
{% for category, message in messages %}
|
||||
<div class="alert {{ category }}">{{ message }}</div>
|
||||
{% endfor %}
|
||||
</section>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
{% if pending_changes %}
|
||||
<section class="box pending-box">
|
||||
<div class="pending-head">
|
||||
<h3>{% if is_super_admin %}Ожидают утверждения{% else %}Мои изменения на проверке{% endif %}</h3>
|
||||
{% if is_super_admin %}
|
||||
<form method="post">
|
||||
<input type="hidden" name="scope" value="{{ scope }}" />
|
||||
<input type="hidden" name="action" value="approve_all_changes" />
|
||||
<button class="pri" type="submit">Утвердить все</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="pending-list">
|
||||
{% for change in pending_changes %}
|
||||
<div class="pending-item">
|
||||
<div>
|
||||
<strong>#{{ change.id }} · {{ change.title }}</strong>
|
||||
<span>{{ change.created_at }} · {{ change.scope_label }} · {{ change.created_by }}</span>
|
||||
<div class="pending-desc">{{ change.description }}</div>
|
||||
</div>
|
||||
{% if is_super_admin %}
|
||||
<div class="pending-actions">
|
||||
<form method="post">
|
||||
<input type="hidden" name="scope" value="{{ scope }}" />
|
||||
<input type="hidden" name="action" value="approve_change" />
|
||||
<input type="hidden" name="change_id" value="{{ change.id }}" />
|
||||
<button class="pri" type="submit">Утвердить</button>
|
||||
</form>
|
||||
<form method="post">
|
||||
<input type="hidden" name="scope" value="{{ scope }}" />
|
||||
<input type="hidden" name="action" value="reject_change" />
|
||||
<input type="hidden" name="change_id" value="{{ change.id }}" />
|
||||
<button class="danger" type="submit">Отклонить</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
{% if is_super_admin %}
|
||||
<section class="box admin-users-box">
|
||||
<h3>Администраторы</h3>
|
||||
{% if created_admin_credentials %}
|
||||
<div class="created-admin-card">
|
||||
<strong>Новый админ создан</strong>
|
||||
<div>Логин: <code>{{ created_admin_credentials.username }}</code></div>
|
||||
<div>Пароль: <code>{{ created_admin_credentials.password }}</code></div>
|
||||
<div>Доступ: <code>{{ created_admin_credentials.access }}</code></div>
|
||||
<div class="created-admin-share">
|
||||
<textarea id="createdAdminShare" readonly>Админка: {{ request.url_root.rstrip('/') }}{{ request.path }}
|
||||
Логин: {{ created_admin_credentials.username }}
|
||||
Пароль: {{ created_admin_credentials.password }}</textarea>
|
||||
<button class="pri" type="button" data-copy-target="createdAdminShare">Скопировать</button>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<form method="post" class="admin-create">
|
||||
<input type="hidden" name="scope" value="{{ scope }}" />
|
||||
<input type="hidden" name="action" value="create_admin" />
|
||||
<input type="text" name="username" placeholder="Логин нового админа" required />
|
||||
<label><input type="checkbox" name="allow_infra" checked /> Инфраструктура</label>
|
||||
<label><input type="checkbox" name="allow_ib" checked /> ИБ</label>
|
||||
<button class="pri" type="submit">Создать</button>
|
||||
</form>
|
||||
<div class="admin-users-list">
|
||||
{% for user in admin_users %}
|
||||
<form class="admin-user-item" method="post">
|
||||
<input type="hidden" name="scope" value="{{ scope }}" />
|
||||
<input type="hidden" name="action" value="delete_admin" />
|
||||
<input type="hidden" name="admin_id" value="{{ user.id }}" />
|
||||
<span>
|
||||
<strong>{{ user.username }}</strong>
|
||||
<small>{{ user.role }} · {{ user.access_scopes }}</small>
|
||||
</span>
|
||||
{% if user.role != 'super' %}
|
||||
<button class="danger" type="submit">Удалить</button>
|
||||
{% endif %}
|
||||
</form>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
<section class="grid">
|
||||
<div class="box">
|
||||
<h3>Добавить вендора</h3>
|
||||
@@ -55,7 +156,7 @@
|
||||
<input type="hidden" name="action" value="add_product" />
|
||||
<select name="vendor_id" required style="padding:9px 10px; border:1px solid #c6d8fb; border-radius:9px;">
|
||||
{% for v in vendors %}
|
||||
<option value="{{ v.id }}">{{ v.name }}</option>
|
||||
<option value="{{ v.id }}" {% if v.pending %}disabled{% endif %}>{{ v.name }}{% if v.pending %} (на проверке){% endif %}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<input type="text" name="name" placeholder="Название продукта" required />
|
||||
@@ -67,16 +168,40 @@
|
||||
|
||||
<section class="lists">
|
||||
<div class="box">
|
||||
<h3>Удалить вендора</h3>
|
||||
<h3>Вендоры</h3>
|
||||
<div class="list-box">
|
||||
{% for v in vendors %}
|
||||
<form class="list-item" method="post">
|
||||
<input type="hidden" name="scope" value="{{ scope }}" />
|
||||
<span>{{ v.name }}</span>
|
||||
<input type="hidden" name="action" value="delete_vendor" />
|
||||
<input type="hidden" name="vendor_id" value="{{ v.id }}" />
|
||||
<button class="danger" type="submit">Удалить</button>
|
||||
</form>
|
||||
<div class="vendor-item">
|
||||
<div class="list-item">
|
||||
<span>
|
||||
{{ v.name }}{% if v.pending %} <small>(на проверке)</small>{% endif %}
|
||||
{% if v.website %}<a href="{{ v.website }}" target="_blank" rel="noopener" style="margin-left:6px;font-size:11px;">сайт</a>{% endif %}
|
||||
{% if v.mont_page %}<a href="{{ v.mont_page }}" target="_blank" rel="noopener" style="margin-left:4px;font-size:11px;">MONT</a>{% endif %}
|
||||
</span>
|
||||
{% if not v.pending %}
|
||||
<div class="product-actions">
|
||||
<button class="warn" type="button" data-edit-vendor="{{ v.id }}">Изменить</button>
|
||||
<form method="post" style="margin:0">
|
||||
<input type="hidden" name="scope" value="{{ scope }}" />
|
||||
<input type="hidden" name="action" value="delete_vendor" />
|
||||
<input type="hidden" name="vendor_id" value="{{ v.id }}" />
|
||||
<button class="danger" type="submit">Удалить</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if not v.pending %}
|
||||
<form class="product-edit" method="post" data-vendor-edit="{{ v.id }}" hidden>
|
||||
<input type="hidden" name="scope" value="{{ scope }}" />
|
||||
<input type="hidden" name="action" value="update_vendor" />
|
||||
<input type="hidden" name="vendor_id" value="{{ v.id }}" />
|
||||
<input type="text" name="name" value="{{ v.name }}" placeholder="Название вендора" required />
|
||||
<input type="url" name="website" value="{{ v.website or '' }}" placeholder="Сайт вендора (https://...)" />
|
||||
<input type="url" name="mont_page" value="{{ v.mont_page or '' }}" placeholder="Страница на MONT (https://...)" />
|
||||
<button class="pri" type="submit">Сохранить</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
@@ -86,28 +211,48 @@
|
||||
{% for c in categories %}
|
||||
<form class="list-item" method="post">
|
||||
<input type="hidden" name="scope" value="{{ scope }}" />
|
||||
<span>{{ c.name }}</span>
|
||||
<span>{{ c.name }}{% if c.pending %} <small>(на проверке)</small>{% endif %}</span>
|
||||
<input type="hidden" name="action" value="delete_category" />
|
||||
<input type="hidden" name="category_id" value="{{ c.id }}" />
|
||||
<button class="danger" type="submit">Удалить</button>
|
||||
{% if not c.pending %}<button class="danger" type="submit">Удалить</button>{% endif %}
|
||||
</form>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="box">
|
||||
<h3>Удалить продукт</h3>
|
||||
<h3>Продукты</h3>
|
||||
<div class="list-box">
|
||||
{% for p in products %}
|
||||
<form class="list-item" method="post">
|
||||
<input type="hidden" name="scope" value="{{ scope }}" />
|
||||
<span>
|
||||
{{ p.vendor_name }} :: {{ p.name }}
|
||||
{% if p.url %}<a href="{{ p.url }}" target="_blank" rel="noopener noreferrer" style="margin-left:6px; font-size:11px;">ссылка</a>{% endif %}
|
||||
</span>
|
||||
<input type="hidden" name="action" value="delete_product" />
|
||||
<input type="hidden" name="product_id" value="{{ p.id }}" />
|
||||
<button class="danger" type="submit">Удалить</button>
|
||||
</form>
|
||||
<div class="product-item">
|
||||
<div class="product-row">
|
||||
<span>
|
||||
{{ p.vendor_name }} :: {{ p.name }}
|
||||
{% if p.pending %}<small>(на проверке)</small>{% endif %}
|
||||
{% if p.url %}<a href="{{ p.url }}" target="_blank" rel="noopener noreferrer" style="margin-left:6px; font-size:11px;">ссылка</a>{% endif %}
|
||||
</span>
|
||||
{% if not p.pending %}
|
||||
<div class="product-actions">
|
||||
<button class="warn" type="button" data-edit-product="{{ p.id }}">Изменить</button>
|
||||
<form method="post">
|
||||
<input type="hidden" name="scope" value="{{ scope }}" />
|
||||
<input type="hidden" name="action" value="delete_product" />
|
||||
<input type="hidden" name="product_id" value="{{ p.id }}" />
|
||||
<button class="danger" type="submit">Удалить</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if not p.pending %}
|
||||
<form class="product-edit" method="post" data-product-edit="{{ p.id }}" hidden>
|
||||
<input type="hidden" name="scope" value="{{ scope }}" />
|
||||
<input type="hidden" name="action" value="update_product" />
|
||||
<input type="hidden" name="product_id" value="{{ p.id }}" />
|
||||
<input type="text" name="name" value="{{ p.name }}" placeholder="Название продукта" required />
|
||||
<input type="text" name="url" value="{{ p.url or '' }}" placeholder="URL продукта" />
|
||||
<button class="pri" type="submit">Сохранить</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
@@ -136,6 +281,7 @@
|
||||
type="checkbox"
|
||||
name="pc_{{ p.id }}_{{ c.id }}"
|
||||
{% if (p.id, c.id) in links %}checked{% endif %}
|
||||
{% if p.pending or c.pending %}disabled{% endif %}
|
||||
/>
|
||||
</td>
|
||||
{% endfor %}
|
||||
|
||||
Reference in New Issue
Block a user