185 lines
7.0 KiB
HTML
185 lines
7.0 KiB
HTML
{% extends "admin/base_site.html" %}
|
|
{% load i18n admin_urls static admin_modify %}
|
|
|
|
{% block title %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %}
|
|
|
|
{% block breadcrumbs %}
|
|
<div class="breadcrumbs">
|
|
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
|
|
› <a href="{% url 'admin:core_crawltask_changelist' %}">爬取任务</a>
|
|
› {{ title }}
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<h1>{{ title }}</h1>
|
|
|
|
<div class="results-summary" style="background: #f8f9fa; border: 1px solid #dee2e6; padding: 20px; margin-bottom: 20px; border-radius: 5px;">
|
|
<h2>任务概览</h2>
|
|
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px;">
|
|
<div>
|
|
<strong>任务名称:</strong><br>
|
|
{{ task.name }}
|
|
</div>
|
|
<div>
|
|
<strong>任务类型:</strong><br>
|
|
{{ task.get_task_type_display }}
|
|
</div>
|
|
<div>
|
|
<strong>状态:</strong><br>
|
|
<span style="color: {% if task.status == 'completed' %}green{% elif task.status == 'failed' %}red{% elif task.status == 'running' %}blue{% else %}gray{% endif %};">
|
|
{{ task.get_status_display }}
|
|
</span>
|
|
</div>
|
|
<div>
|
|
<strong>创建时间:</strong><br>
|
|
{{ task.created_at|date:"Y-m-d H:i:s" }}
|
|
</div>
|
|
{% if task.started_at %}
|
|
<div>
|
|
<strong>开始时间:</strong><br>
|
|
{{ task.started_at|date:"Y-m-d H:i:s" }}
|
|
</div>
|
|
{% endif %}
|
|
{% if task.completed_at %}
|
|
<div>
|
|
<strong>完成时间:</strong><br>
|
|
{{ task.completed_at|date:"Y-m-d H:i:s" }}
|
|
</div>
|
|
{% endif %}
|
|
{% if task.get_duration %}
|
|
<div>
|
|
<strong>执行时长:</strong><br>
|
|
{{ task.duration_display }}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="results-stats" style="background: #fff; border: 1px solid #dee2e6; padding: 20px; margin-bottom: 20px; border-radius: 5px;">
|
|
<h2>统计信息</h2>
|
|
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 15px;">
|
|
<div style="text-align: center; padding: 15px; background: #e3f2fd; border-radius: 5px;">
|
|
<div style="font-size: 24px; font-weight: bold; color: #1976d2;">{{ task.total_articles }}</div>
|
|
<div>总文章数</div>
|
|
</div>
|
|
<div style="text-align: center; padding: 15px; background: #e8f5e8; border-radius: 5px;">
|
|
<div style="font-size: 24px; font-weight: bold; color: #388e3c;">{{ task.success_count }}</div>
|
|
<div>成功数</div>
|
|
</div>
|
|
<div style="text-align: center; padding: 15px; background: #ffebee; border-radius: 5px;">
|
|
<div style="font-size: 24px; font-weight: bold; color: #d32f2f;">{{ task.failed_count }}</div>
|
|
<div>失败数</div>
|
|
</div>
|
|
{% if task.total_articles > 0 %}
|
|
<div style="text-align: center; padding: 15px; background: #fff3e0; border-radius: 5px;">
|
|
<div style="font-size: 24px; font-weight: bold; color: #f57c00;">
|
|
{% widthratio task.success_count task.total_articles 100 %}%
|
|
</div>
|
|
<div>成功率</div>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
{% if task.keyword %}
|
|
<div class="task-config" style="background: #fff; border: 1px solid #dee2e6; padding: 20px; margin-bottom: 20px; border-radius: 5px;">
|
|
<h2>任务配置</h2>
|
|
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px;">
|
|
<div>
|
|
<strong>搜索关键词:</strong><br>
|
|
{{ task.keyword }}
|
|
</div>
|
|
<div>
|
|
<strong>目标网站:</strong><br>
|
|
{{ task.get_websites_display }}
|
|
</div>
|
|
{% if task.start_date %}
|
|
<div>
|
|
<strong>开始日期:</strong><br>
|
|
{{ task.start_date }}
|
|
</div>
|
|
{% endif %}
|
|
{% if task.end_date %}
|
|
<div>
|
|
<strong>结束日期:</strong><br>
|
|
{{ task.end_date }}
|
|
</div>
|
|
{% endif %}
|
|
<div>
|
|
<strong>最大页数:</strong><br>
|
|
{{ task.max_pages }}
|
|
</div>
|
|
<div>
|
|
<strong>最大文章数:</strong><br>
|
|
{{ task.max_articles }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if task.current_website or task.current_action %}
|
|
<div class="current-status" style="background: #fff; border: 1px solid #dee2e6; padding: 20px; margin-bottom: 20px; border-radius: 5px;">
|
|
<h2>当前状态</h2>
|
|
{% if task.current_website %}
|
|
<div>
|
|
<strong>当前网站:</strong> {{ task.current_website }}
|
|
</div>
|
|
{% endif %}
|
|
{% if task.current_action %}
|
|
<div>
|
|
<strong>当前操作:</strong> {{ task.current_action }}
|
|
</div>
|
|
{% endif %}
|
|
{% if task.status == 'running' %}
|
|
<div style="margin-top: 10px;">
|
|
<div style="width: 100%; background-color: #f0f0f0; border-radius: 10px; overflow: hidden;">
|
|
<div style="width: {{ task.progress }}%; background-color: #4CAF50; height: 20px; text-align: center; line-height: 20px; color: white;">
|
|
{{ task.progress }}%
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if task.error_message %}
|
|
<div class="error-info" style="background: #ffebee; border: 1px solid #f44336; padding: 20px; margin-bottom: 20px; border-radius: 5px;">
|
|
<h2 style="color: #d32f2f;">错误信息</h2>
|
|
<pre style="white-space: pre-wrap; word-wrap: break-word;">{{ task.error_message }}</pre>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if task.result_details %}
|
|
<div class="detailed-results" style="background: #fff; border: 1px solid #dee2e6; padding: 20px; margin-bottom: 20px; border-radius: 5px;">
|
|
<h2>详细结果</h2>
|
|
{% for website, result in task.result_details.items %}
|
|
<div style="margin-bottom: 15px; padding: 10px; background: #f8f9fa; border-radius: 3px;">
|
|
<strong>{{ website }}:</strong>
|
|
<ul style="margin: 5px 0; padding-left: 20px;">
|
|
<li>找到链接: {{ result.found_urls }}</li>
|
|
<li>已处理: {{ result.processed }}</li>
|
|
<li>成功: {{ result.success }}</li>
|
|
<li>失败: {{ result.failed }}</li>
|
|
{% if result.error %}
|
|
<li style="color: red;">错误: {{ result.error }}</li>
|
|
{% endif %}
|
|
</ul>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="actions" style="text-align: center; margin-top: 30px;">
|
|
<a href="{% url 'admin:core_crawltask_changelist' %}" class="button" style="padding: 10px 20px; background: #417690; color: white; text-decoration: none; border-radius: 3px; margin-right: 10px;">
|
|
返回任务列表
|
|
</a>
|
|
{% if task.status == 'completed' %}
|
|
<a href="{% url 'admin:core_article_changelist' %}" class="button" style="padding: 10px 20px; background: #28a745; color: white; text-decoration: none; border-radius: 3px;">
|
|
查看文章
|
|
</a>
|
|
{% endif %}
|
|
</div>
|
|
|
|
{% endblock %}
|