2020-02-05 20:54:30 +09:00
|
|
|
{% extends "base.html" %}
|
|
|
|
|
{% block content %}
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
.row > div {
|
|
|
|
|
padding-top: 3px;
|
|
|
|
|
padding-bottom:3px;
|
|
|
|
|
}
|
|
|
|
|
.row {
|
|
|
|
|
align-items: center;
|
|
|
|
|
word-break: break-all;
|
|
|
|
|
}
|
|
|
|
|
.row > div:nth-child(odd) {
|
|
|
|
|
align-items: right;
|
|
|
|
|
text-align: right;
|
|
|
|
|
}
|
|
|
|
|
.row > div:nth-child(even) {
|
|
|
|
|
align-items: left;
|
|
|
|
|
text-align: left;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
<table id="result_table" class="table table-sm tableRowHover">
|
|
|
|
|
<thead>
|
|
|
|
|
<tr>
|
|
|
|
|
<th style="width:5%">IDX</th>
|
2020-02-14 00:49:47 +09:00
|
|
|
<th style="width:8%">Plugin</th>
|
2020-02-05 20:54:30 +09:00
|
|
|
<th style="width:10%">시작시간</th>
|
2020-02-14 00:49:47 +09:00
|
|
|
<th style="width:10%">타입</th>
|
|
|
|
|
<th style="width:28%">제목</th>
|
2020-02-05 20:54:30 +09:00
|
|
|
<th style="width:8%">상태</th>
|
2020-02-09 18:51:58 +09:00
|
|
|
<th style="width:15%">진행률</th>
|
2020-02-05 20:54:30 +09:00
|
|
|
<th style="width:8%">진행시간</th>
|
|
|
|
|
<th style="width:8%">Action</th>
|
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody id="list"></tbody>
|
|
|
|
|
</table>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
"use strict";
|
|
|
|
|
$(function () {
|
|
|
|
|
var package_name = '{{ arg["package_name"] }}';
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: '/' + package_name + '/ajax/list',
|
|
|
|
|
type: 'POST',
|
|
|
|
|
cache: false,
|
|
|
|
|
data: { },
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
success: function (data) {
|
|
|
|
|
$('#list').html('');
|
|
|
|
|
var str = '';
|
|
|
|
|
for (var i in data) {
|
|
|
|
|
str += make_item(data[i]);
|
|
|
|
|
}
|
|
|
|
|
$('#list').html(str);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('body').on('click', '#stop', function (e) {
|
|
|
|
|
var index = $(this).data('index');
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: '/' + package_name + '/ajax/stop',
|
|
|
|
|
type: 'POST',
|
|
|
|
|
cache: false,
|
|
|
|
|
data: {
|
|
|
|
|
index: index
|
|
|
|
|
},
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
success: function (data) {
|
|
|
|
|
location.reload(); // 새로고침
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function make_item(data) {
|
|
|
|
|
var str = '<tr style="cursor: pointer;" data-toggle="collapse" data-target="#collapse_' + data.index + '" aria-expanded="true">';
|
2020-02-09 18:51:58 +09:00
|
|
|
str += '<td scope="col">' + (data.index + 1) + '</td>';
|
2020-02-14 00:49:47 +09:00
|
|
|
str += '<td scope="col">' + data.plugin + '</td>';
|
2020-02-09 18:51:58 +09:00
|
|
|
str += '<td scope="col">' + data.start_time + '</td>';
|
|
|
|
|
str += '<td scope="col">' + data.extractor + '</td>';
|
|
|
|
|
str += '<td scope="col">' + data.title + '</td>';
|
|
|
|
|
str += '<td id="status_' + data.index + '" scope="col">' + data.status_ko + '</td>';
|
|
|
|
|
var visi = 'hidden';
|
|
|
|
|
if (parseInt(data.percent) > 0 && data.status_str != 'STOP') {
|
|
|
|
|
visi = 'visible';
|
|
|
|
|
}
|
|
|
|
|
str += '<td scope="col"><div class="progress"><div id="progress_' + data.index + '" class="progress-bar" style="visibility: ' + visi + '; width:' + data.percent + '%">' + data.percent + '%</div></div></td>';
|
|
|
|
|
str += '<td id="download_time_' + data.index + '" scope="col">' + data.download_time + '</td>';
|
|
|
|
|
str += '<td id="button_' + data.index + '" scope="col" class="tableRowHoverOff">';
|
|
|
|
|
if (data.status_str == 'START' || data.status_str == 'DOWNLOADING' || data.status_str == 'FINISHED') {
|
2020-02-05 20:54:30 +09:00
|
|
|
str += '<button id="stop" class="align-middle btn btn-outline-danger btn-sm" data-index="' + data.index + '">중지</button>';
|
|
|
|
|
}
|
|
|
|
|
str += '</td>';
|
|
|
|
|
str += '</tr>';
|
|
|
|
|
str += '<tr class="collapse tableRowHoverOff" style="cursor: pointer;" id="collapse_' + data.index + '">';
|
|
|
|
|
str += '<td colspan="8">';
|
|
|
|
|
str += '<div id="detail_' + data.index + '">';
|
|
|
|
|
str += get_detail(data);
|
|
|
|
|
str += '</div>';
|
|
|
|
|
str += '</td>';
|
|
|
|
|
str += '</tr>';
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function get_detail(data) {
|
2020-02-09 18:51:58 +09:00
|
|
|
var str = info_html('URL', data.url, data.url);
|
|
|
|
|
str += info_html('업로더', data.uploader, data.uploader_url);
|
|
|
|
|
str += info_html('임시폴더', data.temp_path);
|
|
|
|
|
str += info_html('저장폴더', data.save_path);
|
2020-02-05 20:54:30 +09:00
|
|
|
str += info_html('종료시간', data.end_time);
|
2020-02-09 18:51:58 +09:00
|
|
|
if (data.status_str == 'DOWNLOADING') {
|
|
|
|
|
str += info_html('', '<b>현재 다운로드 중인 파일에 대한 정보</b>');
|
|
|
|
|
str += info_html('파일명', data.filename);
|
|
|
|
|
str += info_html('진행률(current/total)', data.percent + '% (' + data.downloaded_bytes_str + ' / ' + data.total_bytes_str + ')');
|
|
|
|
|
str += info_html('남은 시간', data.eta + '초');
|
|
|
|
|
str += info_html('다운 속도', data.speed_str);
|
|
|
|
|
}
|
2020-02-05 20:54:30 +09:00
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-09 18:51:58 +09:00
|
|
|
function info_html(left, right, option) {
|
2020-02-05 20:54:30 +09:00
|
|
|
var str = '<div class="row">';
|
|
|
|
|
str += '<div class="col-sm-2">';
|
|
|
|
|
str += '<b>' + left + '</b>';
|
|
|
|
|
str += '</div>';
|
|
|
|
|
str += '<div class="col-sm-10">';
|
|
|
|
|
str += '<div class="input-group col-sm-9">';
|
|
|
|
|
str += '<span class="text-left" style="padding-left:10px; padding-top:3px">';
|
2020-02-09 18:51:58 +09:00
|
|
|
if (left == 'URL' || left == '업로더') {
|
|
|
|
|
str += '<a href="' + option + '" target="_blank">';
|
2020-02-05 20:54:30 +09:00
|
|
|
}
|
|
|
|
|
str += right;
|
2020-02-09 18:51:58 +09:00
|
|
|
if (left == 'URL' || left == '업로더') {
|
2020-02-05 20:54:30 +09:00
|
|
|
str += '</a>';
|
|
|
|
|
}
|
|
|
|
|
str += '</span></div></div></div>';
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
{% endblock %}
|