173 lines
7.8 KiB
HTML
173 lines
7.8 KiB
HTML
{% extends "admin/base_site.html" %}
|
|
{% load i18n static %}
|
|
|
|
{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/dashboard.css" %}">{% endblock %}
|
|
|
|
{% block coltype %}colMS{% endblock %}
|
|
|
|
{% block bodyclass %}{{ block.super }} dashboard{% endblock %}
|
|
|
|
{% block breadcrumbs %}{% endblock %}
|
|
|
|
{% block nav-sidebar %}{% endblock %}
|
|
|
|
{% block content %}
|
|
<div id="content-main">
|
|
|
|
{% if app_list %}
|
|
{% for app in app_list %}
|
|
<div class="app-{{ app.app_label }} module">
|
|
<table>
|
|
<caption>
|
|
<a href="{{ app.app_url }}" class="section" title="{% blocktranslate with name=app.name %}Models in the {{ name }} application{% endblocktranslate %}">{{ app.name }}</a>
|
|
</caption>
|
|
{% for model in app.models %}
|
|
<tr class="model-{{ model.object_name|lower }}">
|
|
{% if model.admin_url %}
|
|
<th scope="row"><a href="{{ model.admin_url }}"{% if model.add_url %} class="addlink"{% endif %}>{{ model.name }}</a></th>
|
|
{% else %}
|
|
<th scope="row">{{ model.name }}</th>
|
|
{% endif %}
|
|
|
|
{% if model.add_url %}
|
|
<td><a href="{{ model.add_url }}" class="addlink">{% translate 'Add' %}</a></td>
|
|
{% else %}
|
|
<td> </td>
|
|
{% endif %}
|
|
|
|
{% if model.admin_url %}
|
|
{% if model.view_only %}
|
|
<td><a href="{{ model.admin_url }}" class="viewlink">{% translate 'View' %}</a></td>
|
|
{% else %}
|
|
<td><a href="{{ model.admin_url }}" class="changelink">{% translate 'Change' %}</a></td>
|
|
{% endif %}
|
|
{% else %}
|
|
<td> </td>
|
|
{% endif %}
|
|
</tr>
|
|
{% endfor %}
|
|
</table>
|
|
</div>
|
|
{% endfor %}
|
|
{% else %}
|
|
<p>{% translate "You don't have permission to view or edit anything." %}</p>
|
|
{% endif %}
|
|
|
|
<!-- 自定义快速操作区域 -->
|
|
<div class="module" style="margin-top: 20px;">
|
|
<h2>快速创建爬取任务</h2>
|
|
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 15px; margin-top: 15px;">
|
|
<div style="border: 1px solid #ddd; padding: 15px; border-radius: 5px; text-align: center;">
|
|
<h3 style="margin-top: 0; color: #417690;">关键词搜索</h3>
|
|
<p style="color: #666; font-size: 14px;">根据关键词搜索并爬取相关文章</p>
|
|
<a href="{% url 'admin:create_keyword_task' %}" class="button" style="background: #417690; color: white; padding: 8px 16px; text-decoration: none; border-radius: 3px; display: inline-block;">
|
|
创建任务
|
|
</a>
|
|
</div>
|
|
|
|
<div style="border: 1px solid #ddd; padding: 15px; border-radius: 5px; text-align: center;">
|
|
<h3 style="margin-top: 0; color: #28a745;">历史文章</h3>
|
|
<p style="color: #666; font-size: 14px;">爬取指定日期范围的历史文章</p>
|
|
<a href="{% url 'admin:create_historical_task' %}" class="button" style="background: #28a745; color: white; padding: 8px 16px; text-decoration: none; border-radius: 3px; display: inline-block;">
|
|
创建任务
|
|
</a>
|
|
</div>
|
|
|
|
<div style="border: 1px solid #ddd; padding: 15px; border-radius: 5px; text-align: center;">
|
|
<h3 style="margin-top: 0; color: #dc3545;">全站爬取</h3>
|
|
<p style="color: #666; font-size: 14px;">爬取整个网站的所有文章</p>
|
|
<a href="{% url 'admin:create_full_site_task' %}" class="button" style="background: #dc3545; color: white; padding: 8px 16px; text-decoration: none; border-radius: 3px; display: inline-block;">
|
|
创建任务
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 最近任务状态 -->
|
|
<div class="module" style="margin-top: 20px;">
|
|
<h2>最近任务状态</h2>
|
|
<div style="margin-top: 15px;">
|
|
{% load core_extras %}
|
|
{% get_recent_tasks as recent_tasks %}
|
|
{% if recent_tasks %}
|
|
<table style="width: 100%;">
|
|
<thead>
|
|
<tr style="background: #f8f9fa;">
|
|
<th style="padding: 8px; text-align: left;">任务名称</th>
|
|
<th style="padding: 8px; text-align: left;">类型</th>
|
|
<th style="padding: 8px; text-align: left;">状态</th>
|
|
<th style="padding: 8px; text-align: left;">进度</th>
|
|
<th style="padding: 8px; text-align: left;">创建时间</th>
|
|
<th style="padding: 8px; text-align: left;">操作</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for task in recent_tasks %}
|
|
<tr>
|
|
<td style="padding: 8px;">{{ task.name }}</td>
|
|
<td style="padding: 8px;">{{ task.get_task_type_display }}</td>
|
|
<td style="padding: 8px;">
|
|
<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>
|
|
</td>
|
|
<td style="padding: 8px;">
|
|
{% if task.status == 'running' %}
|
|
<div style="width: 100px; background-color: #f0f0f0; border-radius: 3px; overflow: hidden;">
|
|
<div style="width: {{ task.progress }}%; background-color: #4CAF50; height: 16px; text-align: center; line-height: 16px; color: white; font-size: 12px;">
|
|
{{ task.progress }}%
|
|
</div>
|
|
</div>
|
|
{% else %}
|
|
-
|
|
{% endif %}
|
|
</td>
|
|
<td style="padding: 8px;">{{ task.created_at|date:"m-d H:i" }}</td>
|
|
<td style="padding: 8px;">
|
|
<a href="{% url 'admin:core_crawltask_change' task.id %}" style="color: #417690; text-decoration: none;">查看</a>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
{% else %}
|
|
<p style="color: #666; text-align: center; padding: 20px;">暂无任务</p>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block sidebar %}
|
|
<div id="content-related">
|
|
<div class="module" id="recent-actions-module">
|
|
<h2>{% translate 'Recent actions' %}</h2>
|
|
<h3>{% translate 'My actions' %}</h3>
|
|
{% load log %}
|
|
{% get_admin_log 10 as admin_log for_user user %}
|
|
{% if not admin_log %}
|
|
<p>{% translate 'None available' %}</p>
|
|
{% else %}
|
|
<ul class="actionlist">
|
|
{% for entry in admin_log %}
|
|
<li class="{% if entry.is_addition %}addlink{% endif %}{% if entry.is_change %}changelink{% endif %}{% if entry.is_deletion %}deletelink{% endif %}">
|
|
{% if entry.is_deletion or not entry.get_admin_url %}
|
|
{{ entry.object_repr }}
|
|
{% else %}
|
|
<a href="{{ entry.get_admin_url }}">{{ entry.object_repr }}</a>
|
|
{% endif %}
|
|
<br>
|
|
{% if entry.content_type %}
|
|
<span class="mini quiet">{% filter capfirst %}{{ entry.content_type.name }}{% endfilter %}</span>
|
|
{% else %}
|
|
<span class="mini quiet">{% translate 'Unknown content' %}</span>
|
|
{% endif %}
|
|
</li>
|
|
{% endfor %}
|
|
</ul>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|