feat(web): sources, crawlers, metrics on tailwind
This commit is contained in:
+66
-67
@@ -1,64 +1,64 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Источники{% endblock %}
|
||||
{% block content %}
|
||||
<h4 class="mb-3">📡 Источники <a href="/crawlers" class="btn btn-sm btn-outline-secondary ms-2">Статус краулеров →</a></h4>
|
||||
<h4 class="text-xl font-semibold mb-4 flex items-center gap-2 flex-wrap">📡 Источники
|
||||
<a href="/crawlers" class="btn btn-sm btn-outline">Статус краулеров →</a>
|
||||
</h4>
|
||||
|
||||
{% if did %}
|
||||
<div class="alert alert-{{ 'success' if not did.startswith('error') else 'danger' }} py-2 small">
|
||||
<div class="alert alert-{{ 'success' if not did.startswith('error') else 'error' }} mb-4 text-sm">
|
||||
{{ did }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Форма добавления -->
|
||||
<div class="card mb-3">
|
||||
<div class="card-header py-2"><b>➕ Добавить источник</b></div>
|
||||
<div class="card-body py-2">
|
||||
<form method="post" action="/sources/add" class="row g-2 align-items-end">
|
||||
<div class="col-auto">
|
||||
<label class="form-label mb-0 small">slug</label>
|
||||
<input type="text" name="slug" class="form-control form-control-sm" placeholder="my_channel" required>
|
||||
<div class="card card-outline mb-4 bg-white">
|
||||
<div class="border-b border-neutral-200 px-4 py-2 font-bold">➕ Добавить источник</div>
|
||||
<div class="card-content p-4">
|
||||
<form method="post" action="/sources/add" class="flex flex-wrap items-end gap-2">
|
||||
<div class="flex flex-col gap-1">
|
||||
<label class="text-xs text-neutral-500 mb-0" for="add_slug">slug</label>
|
||||
<input id="add_slug" type="text" name="slug" class="input input-sm w-40" placeholder="my_channel" required>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<label class="form-label mb-0 small">Название</label>
|
||||
<input type="text" name="name" class="form-control form-control-sm" placeholder="My Channel">
|
||||
<div class="flex flex-col gap-1">
|
||||
<label class="text-xs text-neutral-500 mb-0" for="add_name">Название</label>
|
||||
<input id="add_name" type="text" name="name" class="input input-sm w-48" placeholder="My Channel">
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<label class="form-label mb-0 small">Address</label>
|
||||
<input type="text" name="address" class="form-control form-control-sm"
|
||||
placeholder="@handle, t.me/name, https://t.me/name или https://.../rss" id="add_address">
|
||||
<div class="flex flex-col gap-1">
|
||||
<label class="text-xs text-neutral-500 mb-0" for="add_address">Address</label>
|
||||
<input id="add_address" type="text" name="address" class="input input-sm w-72"
|
||||
placeholder="@handle, t.me/name, https://t.me/name или https://.../rss">
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary" id="btn_fetch"
|
||||
<div>
|
||||
<button type="button" class="btn btn-sm btn-outline" id="btn_fetch"
|
||||
onclick="fetchSourcePreview()">🔎 Найти</button>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<label class="form-label mb-0 small">crawler</label>
|
||||
<select name="crawler" class="form-select form-select-sm">
|
||||
<div class="flex flex-col gap-1">
|
||||
<label class="text-xs text-neutral-500 mb-0" for="add_crawler">crawler</label>
|
||||
<select id="add_crawler" name="crawler" class="select select-sm w-32">
|
||||
<option value="telegram">telegram</option>
|
||||
<option value="rss">rss</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<label class="form-label mb-0 small">direction</label>
|
||||
<input type="text" name="direction" class="form-control form-control-sm" placeholder="linux" list="dirs">
|
||||
<div class="flex flex-col gap-1">
|
||||
<label class="text-xs text-neutral-500 mb-0" for="add_direction">direction</label>
|
||||
<input id="add_direction" type="text" name="direction" class="input input-sm w-32" placeholder="linux" list="dirs">
|
||||
<datalist id="dirs">
|
||||
{% for d in directions %}<option value="{{ d }}">{% endfor %}
|
||||
</datalist>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<label class="form-label mb-0 small">priority</label>
|
||||
<select name="priority" class="form-select form-select-sm">
|
||||
<div class="flex flex-col gap-1">
|
||||
<label class="text-xs text-neutral-500 mb-0" for="add_priority">priority</label>
|
||||
<select id="add_priority" name="priority" class="select select-sm w-20">
|
||||
<option value="P0">P0</option><option value="P1" selected>P1</option>
|
||||
<option value="P2">P2</option><option value="P3">P3</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="form-check form-switch mt-3">
|
||||
<input class="form-check-input" type="checkbox" name="enabled" id="add_en" checked>
|
||||
<label class="form-check-label small" for="add_en">enabled</label>
|
||||
</div>
|
||||
<div class="flex items-center gap-2 pb-2">
|
||||
<input class="size-4" type="checkbox" name="enabled" id="add_en" checked>
|
||||
<label class="text-sm mb-0" for="add_en">enabled</label>
|
||||
</div>
|
||||
<div class="col-auto"><button class="btn btn-sm btn-primary">Добавить</button></div>
|
||||
<div><button class="btn btn-sm btn-primary">Добавить</button></div>
|
||||
</form>
|
||||
<script>
|
||||
const addCrawler = document.querySelector('form[action="/sources/add"] select[name="crawler"]');
|
||||
@@ -93,41 +93,40 @@
|
||||
</div>
|
||||
|
||||
<!-- Таблица источников -->
|
||||
<div class="card">
|
||||
<div class="card-header py-2"><b>🗂️ Таблица ({{ sources|length }})</b>
|
||||
<span class="text-muted small">источник истины: sources.yaml (правки пишутся в yaml + БД)</span>
|
||||
<div class="card card-outline bg-white">
|
||||
<div class="border-b border-neutral-200 px-4 py-2 flex items-center gap-2 flex-wrap">
|
||||
<b>🗂️ Таблица ({{ sources|length }})</b>
|
||||
<span class="text-neutral-500 text-sm">источник истины: sources.yaml (правки пишутся в yaml + БД)</span>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-sm table-hover align-middle mb-0">
|
||||
<thead class="table-light">
|
||||
<div class="overflow-x-auto">
|
||||
<table class="table table-sm table-hover">
|
||||
<thead class="bg-neutral-100">
|
||||
<tr>
|
||||
<th>slug</th><th>Название</th><th>crawler</th><th>direction</th><th>lang</th>
|
||||
<th>priority</th><th>enabled</th><th class="text-end">статус</th><th>послед. запуск</th><th class="text-end">действия</th>
|
||||
<th>priority</th><th>enabled</th><th class="text-right">статус</th><th>послед. запуск</th><th class="text-right">действия</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for s in sources %}
|
||||
<tr class="{{ 'text-muted' if not s['enabled'] }}">
|
||||
<td><code>{{ s['slug'] }}</code></td>
|
||||
<tr class="{{ 'text-neutral-500' if not s['enabled'] }}">
|
||||
<td><code class="text-xs">{{ s['slug'] }}</code></td>
|
||||
<td>
|
||||
<form method="post" action="/sources/{{ s['id'] }}/edit" class="row g-1 align-items-center">
|
||||
<div class="col-auto">
|
||||
<input type="text" name="name" value="{{ s['name'] or '' }}" class="form-control form-control-sm source-name" style="width:170px">
|
||||
</div>
|
||||
<div class="col-auto"><button class="btn btn-sm btn-outline-secondary">💾</button></div>
|
||||
<form method="post" action="/sources/{{ s['id'] }}/edit" class="flex items-center gap-1">
|
||||
<input type="text" name="name" value="{{ s['name'] or '' }}" class="input input-sm source-name w-[170px]">
|
||||
<button class="btn btn-sm btn-outline">💾</button>
|
||||
</form>
|
||||
</td>
|
||||
<td><span class="badge text-bg-secondary">{{ s['crawler'] }}</span>
|
||||
{% if s['crawler'] == 'rss' and s['feed_url'] %}<br><small class="text-muted">{{ s['feed_url'] }}</small>{% endif %}
|
||||
{% if s['crawler'] == 'telegram' and s['channel'] %}<br><small class="text-muted">{{ s['channel'] }}</small>{% endif %}
|
||||
<td><span class="badge badge-neutral">{{ s['crawler'] }}</span>
|
||||
{% if s['crawler'] == 'rss' and s['feed_url'] %}<br><small class="text-neutral-500">{{ s['feed_url'] }}</small>{% endif %}
|
||||
{% if s['crawler'] == 'telegram' and s['channel'] %}<br><small class="text-neutral-500">{{ s['channel'] }}</small>{% endif %}
|
||||
</td>
|
||||
<td>{{ s['direction'] or '—' }}
|
||||
{% if s['error_count'] %}<br><small class="text-danger">{{ s['error_count'] }} err</small>{% endif %}
|
||||
{% if s['error_count'] %}<br><small class="text-red-600">{{ s['error_count'] }} err</small>{% endif %}
|
||||
</td>
|
||||
<td>{{ s['lang'] or 'ru' }}</td>
|
||||
<td>
|
||||
<form method="post" action="/sources/{{ s['id'] }}/edit" class="d-inline">
|
||||
<select name="priority" class="form-select form-select-sm" style="width:auto" onchange="this.form.submit()">
|
||||
<form method="post" action="/sources/{{ s['id'] }}/edit" class="inline-block">
|
||||
<select name="priority" class="select select-sm w-auto" onchange="this.form.submit()">
|
||||
{% for p in ['P0','P1','P2','P3'] %}
|
||||
<option value="{{ p }}" {{ 'selected' if s['priority'] == p else '' }}>P{{ loop.index0 }}</option>
|
||||
{% endfor %}
|
||||
@@ -135,28 +134,28 @@
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge {{ 'text-bg-success' if s['enabled'] else 'text-bg-secondary' }}">
|
||||
<span class="badge {{ 'badge-success' if s['enabled'] else 'badge-neutral' }}">
|
||||
{{ 'вкл' if s['enabled'] else 'пауза' }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
{% if s['status'] == 'dead' %}<span class="badge text-bg-danger">dead</span>
|
||||
{% elif s['status'] == 'alive' %}<span class="badge text-bg-success">alive</span>
|
||||
{% elif s['status'] == 'new' %}<span class="badge text-bg-info">new</span>
|
||||
{% else %}<span class="badge text-bg-secondary">{{ s['status'] }}</span>{% endif %}
|
||||
{% if s['enabled'] == 0 %}<span class="badge text-bg-warning">пауза</span>{% endif %}
|
||||
<td class="text-right">
|
||||
{% if s['status'] == 'dead' %}<span class="badge badge-error">dead</span>
|
||||
{% elif s['status'] == 'alive' %}<span class="badge badge-success">alive</span>
|
||||
{% elif s['status'] == 'new' %}<span class="badge badge-info">new</span>
|
||||
{% else %}<span class="badge badge-neutral">{{ s['status'] }}</span>{% endif %}
|
||||
{% if s['enabled'] == 0 %}<span class="badge badge-warning">пауза</span>{% endif %}
|
||||
</td>
|
||||
<td class="small text-muted">{{ s['last_fetch'] or '—' }}{% if s['last_error'] %}<br><span class="text-danger">{{ s['last_error'][:40] }}</span>{% endif %}</td>
|
||||
<td class="text-end">
|
||||
<form method="post" action="/sources/{{ s['id'] }}/toggle" class="d-inline">
|
||||
<button class="btn btn-sm {{ 'btn-outline-warning' if s['enabled'] else 'btn-outline-success' }}"
|
||||
<td class="text-sm text-neutral-500">{{ s['last_fetch'] or '—' }}{% if s['last_error'] %}<br><span class="text-red-600">{{ s['last_error'][:40] }}</span>{% endif %}</td>
|
||||
<td class="text-right whitespace-nowrap">
|
||||
<form method="post" action="/sources/{{ s['id'] }}/toggle" class="inline-block">
|
||||
<button class="btn btn-sm btn-outline {{ 'text-amber-600' if s['enabled'] else 'text-green-600' }}"
|
||||
title="{{ 'Пауза' if s['enabled'] else 'Возобновить' }}">
|
||||
{{ '⏸' if s['enabled'] else '▶' }}
|
||||
</button>
|
||||
</form>
|
||||
<form method="post" action="/sources/{{ s['id'] }}/delete" class="d-inline"
|
||||
<form method="post" action="/sources/{{ s['id'] }}/delete" class="inline-block"
|
||||
onsubmit="return confirm('Удалить источник {{ s['slug'] }}? Это уберёт его из sources.yaml и БД (посты останутся).')">
|
||||
<button class="btn btn-sm btn-outline-danger" title="Удалить">🗑</button>
|
||||
<button class="btn btn-sm btn-outline text-red-600" title="Удалить">🗑</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -165,4 +164,4 @@
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user