init
This commit is contained in:
157
templates/transmission/torrents.html
Normal file
157
templates/transmission/torrents.html
Normal file
@@ -0,0 +1,157 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Transmission 种子列表 - PT Manager{% endblock %}
|
||||
|
||||
{% block page_title %}Transmission 种子列表{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="bg-white rounded-lg shadow-md p-6">
|
||||
{% if error %}
|
||||
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4">
|
||||
{{ error }}
|
||||
</div>
|
||||
<a href="{{ url_for('transmission.transmission_index') }}"
|
||||
class="bg-gray-500 hover:bg-gray-700 text-white font-bold py-2 px-4 rounded">
|
||||
返回 Transmission 管理
|
||||
</a>
|
||||
{% elif torrents %}
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full divide-y divide-gray-200">
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">名称</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">大小</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">进度</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">状态</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">做种/下载</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="bg-white divide-y divide-gray-200">
|
||||
{% for torrent in torrents %}
|
||||
<tr>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="text-sm font-medium text-gray-900">{{ torrent.name }}</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||
{{ torrent.totalSize }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="flex items-center">
|
||||
<div class="w-full bg-gray-200 rounded-full h-2">
|
||||
<div class="bg-blue-600 h-2 rounded-full" style="width: {{ torrent.percentDone * 100 }}%"></div>
|
||||
</div>
|
||||
<span class="text-sm text-gray-500 ml-2">{{ (torrent.percentDone * 100)|round(1) }}%</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full
|
||||
{% if torrent.status == 6 %}bg-green-100 text-green-800
|
||||
{% elif torrent.status == 4 %}bg-blue-100 text-blue-800
|
||||
{% elif torrent.status == 0 %}bg-yellow-100 text-yellow-800
|
||||
{% else %}bg-gray-100 text-gray-800{% endif %}">
|
||||
{{ torrent.statusString }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||
<div>做种: {{ torrent.peersSendingToUs }}</div>
|
||||
<div>下载: {{ torrent.peersGettingFromUs }}</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
|
||||
{% if torrent.status == 0 %}
|
||||
<button onclick="startTorrent({{ torrent.id }})"
|
||||
class="text-green-600 hover:text-green-900 mr-3">
|
||||
开始
|
||||
</button>
|
||||
{% else %}
|
||||
<button onclick="stopTorrent({{ torrent.id }})"
|
||||
class="text-yellow-600 hover:text-yellow-900 mr-3">
|
||||
暂停
|
||||
</button>
|
||||
{% endif %}
|
||||
<button onclick="removeTorrent({{ torrent.id }})"
|
||||
class="text-red-600 hover:text-red-900">
|
||||
删除
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="text-center py-12">
|
||||
<i class="fas fa-inbox text-gray-400 text-4xl mb-4"></i>
|
||||
<h3 class="text-lg font-medium text-gray-900 mb-1">暂无种子</h3>
|
||||
<p class="text-gray-500">Transmission 客户端中没有种子任务</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function stopTorrent(torrentId) {
|
||||
fetch(`/transmission/torrent/${torrentId}/stop`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert('种子已暂停');
|
||||
location.reload();
|
||||
} else {
|
||||
alert('操作失败: ' + data.error);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
alert('操作失败: ' + error.message);
|
||||
});
|
||||
}
|
||||
|
||||
function startTorrent(torrentId) {
|
||||
fetch(`/transmission/torrent/${torrentId}/start`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert('种子已开始');
|
||||
location.reload();
|
||||
} else {
|
||||
alert('操作失败: ' + data.error);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
alert('操作失败: ' + error.message);
|
||||
});
|
||||
}
|
||||
|
||||
function removeTorrent(torrentId) {
|
||||
if (confirm('确定要删除这个种子吗?这将同时删除下载的文件。')) {
|
||||
fetch(`/transmission/torrent/${torrentId}/remove`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert('种子已删除');
|
||||
location.reload();
|
||||
} else {
|
||||
alert('删除失败: ' + data.error);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
alert('删除失败: ' + error.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user