Files
mario_scraper/templates/index.html
2025-04-18 10:41:32 +03:00

221 lines
10 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>Парсер mariotexno</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/styles.css') }}">
</head>
<body>
<h1>Парсер euro.com.pl</h1>
{% if feed_file_info %}
<p>🕓 <a href="{{ url_for('serve_feed') }}" target="_blank">Фід</a> оновлено: {{ feed_file_info.modified }}</p>
{% endif %}
<div class="tabs">
<div class="tab-buttons">
<button class="tab-button active" onclick="openTab('parser')">Парсер</button>
<button class="tab-button" onclick="openTab('processor')">Переклад</button>
<button class="tab-button" onclick="openTab('generator')">YML Фід</button>
<button class="tab-button" onclick="openTab('categories')">Категорії</button>
<div class="items-limit-group">
<label for="items-limit">Ліміт:</label>
<input type="number" id="items-limit" value="{{ app_settings.items_limit }}" min="-1"
onchange="updateItemsLimit(this.value)" title="Встановіть -1 для зняття обмежень">
</div>
<button onclick="refreshOldestCategory()">🔄</button>
<button onclick="translateAllCategories()">🇺🇦</button>
<button onclick="generateFullYML()">YML</button>
</div>
<!-- Вкладка парсера -->
<div id="parser" class="tab-content active">
<div class="form-group">
<label for="url">URL категорії:</label>
<input type="text" id="url" placeholder="https://www.euro.com.pl/odkurzacze-automatyczne.bhtml">
</div>
<button onclick="startParsing()" id="parseButton">Почати парсинг</button>
<div class="status" id="status">
{% if status.is_running %}
<p>Парсинг запущено для категорії: {{ status.current_category }}</p>
{% else %}
<p>Парсер не активний</p>
{% endif %}
</div>
<div class="files">
<h3>Збережені результати:</h3>
<ul>
{% for file in parsed_files %}
<li>
<div class="file-info">
<a href="{{ url_for('download_file', filename=file.name, directory='output') }}"
class="download-link" download>
{{ file.name }}
</a>
<span class="file-date">{{ file.modified }}</span>
<span class="file-size">{{ file.size }}</span>
</div>
<button class="delete-btn" onclick="deleteFile('{{ file.name }}', 'output')"
title="Видалити файл">
🗑️
</button>
</li>
{% endfor %}
</ul>
</div>
</div>
<!-- Вкладка оробки даних -->
<div id="processor" class="tab-content">
<div class="form-group">
<label for="file-select">Виберіть файл для обробки:</label>
<select id="file-select" class="file-select">
<option value="">Виберіть файл...</option>
{% for file in parsed_files %}
<option value="{{ file.name }}">{{ file.name }}</option>
{% endfor %}
</select>
</div>
<button onclick="startTranslation()" id="translateButton">Почати переклад</button>
<div class="status" id="translation-status">
{% if translation_status.is_running %}
<p>Переклад в процесі...<br>
Оброблено: {{ translation_status.processed_items }} з {{ translation_status.total_items }}</p>
{% else %}
<p>Переклад не активний</p>
{% endif %}
</div>
<div class="files">
<h3>Перекладені файли:</h3>
<ul>
{% for file in translated_files %}
<li>
<div class="file-info">
<a href="{{ url_for('download_file', filename=file.name, directory='translated') }}"
class="download-link" download>
{{ file.name }}
</a>
<span class="file-date">{{ file.modified }}</span>
<span class="file-size">{{ file.size }}</span>
</div>
<button class="delete-btn" onclick="deleteFile('{{ file.name }}', 'translated')"
title="Видалити файл">
🗑️
</button>
</li>
{% endfor %}
</ul>
</div>
</div>
<!-- Вкладка генератора YML -->
<div id="generator" class="tab-content">
<div class="yml-generation-section">
<div class="form-group">
<label for="yml-category-select">Категорія:</label>
<select id="yml-category-select" class="file-select">
<option value="">Виберіть категорію...</option>
{% for category in categories %}
<option value="{{ category.id }}">{{ category.name }}</option>
{% endfor %}
</select>
</div>
<div class="form-group">
<label for="yml-file-select">Файл для генерації:</label>
<select id="yml-file-select" class="file-select">
<option value="">Виберіть файл...</option>
{% for file in translated_files %}
<option value="{{ file.name }}">{{ file.name }}</option>
{% endfor %}
</select>
</div>
<button onclick="generateYML()" id="generateButton" class="action-button">Згенерувати YML</button>
</div>
<div class="status" id="yml-status">
<p>Генератор не активний</p>
</div>
<div class="files">
<h3>Згенеровані YML файли:</h3>
<ul>
{% for file in yml_files %}
<li>
<div class="file-info">
<a href="{{ url_for('download_file', filename=file.name|urlencode, directory='yml') }}"
class="download-link" download>
{{ file.name }}
</a>
<span class="file-date">{{ file.modified }}</span>
<span class="file-size">{{ file.size }}</span>
</div>
<button class="delete-btn" onclick="deleteFile('{{ file.name }}', 'yml')" title="Видалити файл">
🗑️
</button>
</li>
{% endfor %}
</ul>
</div>
</div>
<!-- Вкладка управления категориями -->
<div id="categories" class="tab-content">
<div class="categories-section">
<div class="category-form">
<div class="form-group">
<label for="category-name">Назва категорії:</label>
<input type="text" id="category-name" placeholder="Роботи-пилососи">
</div>
<div class="form-group">
<label for="portal-id">ID категорії Prom.ua:</label>
<input type="text" id="portal-id" placeholder="12345">
</div>
<div class="form-group">
<label for="category-url">URL категорії:</label>
<input type="text" id="category-url"
placeholder="https://www.euro.com.pl/odkurzacze-automatyczne.bhtml">
</div>
<button onclick="addCategory()" class="secondary-button">Додати категорію</button>
</div>
<div class="categories-list">
<h4>Збережені категорії:</h4>
<ul id="categories-list">
{% for category in categories %}
<li title="{{ category.url or '' }}">
<span>
{{ category.id }} - {{ category.name }}
{% if category.portal_id %} (portal_id: {{ category.portal_id }}){% endif %}
</span>
<button class="delete-btn" onclick="deleteCategory('{{ category.id }}')"
title="Видалити категорію">
🗑️
</button>
</li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"
integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
<script src="{{ url_for('static', filename='js/main.js') }}"></script>
</body>
</html>