mylar/data/interfaces/default/queue_management.html

259 lines
14 KiB
HTML
Executable File

<%inherit file="base.html"/>
<%
import mylar
%>
<%def name="headerIncludes()">
<div id="subhead_container">
<div id="subhead_menu">
<a id="menu_link_refresh" href="#" title="Restart stalled queue" onclick="doAjaxCall('ddl_requeue?mode=restart_queue',$(this),'table')" data-success="Restarted Queue">Restart Queue</a>
</div>
</div>
</%def>
<%def name="body()">
<div id="paddingheader">
<h1 class="clearfix">QUEUE MANAGEMENT</h1></br>
</div>
<div style="text-align:center;">
<h2><center><bold>ACTIVE</bold></center></h2>
<div id="active_message" align="center" style="display:none;">
<div id="amessage" align="center"></div>
<div id="queuebuttons"><div id="queue_menu" style="display:none;"></br>
<a id="arestartddl" name="restartddl" href="#" title="Restart stalled download" data-success="Restarted Download">Restart Download</a>
<a id="aresumeddl" name="resumeddl" href="#" title="Resume download" data-success="Resumed Download">Resume Download</a>
<a id="aabortddl" name="abortddl" href="#" title="Abort download" data-success="Aborted Download">Abort Download</a>
</div></div>
</div>
<div id="active_queue" style="display:none;">
<table width="100%" cellpadding="5" cellspacing="5">
<tbody>
<div style="display: flex; justify-content: flex-end">
<div id="queuebuttons"><div id="queue_menu">
<a id="qrestartddl" name="restartddl" href="#" title="Restart stalled download" data-success="Restarted Download">Restart Download</a></br>
<a id="qresumeddl" name="resumeddl" href="#" title="Resume download" data-success="Resumed Download">Resume Download</a></br>
<a id="qabortddl" name="abortddl" href="#" title="Abort download" data-success="Aborted Download">Abort Download</a>
</div></div>
</div>
<tr><td id="series" align="center" style="text-align:center"></td></tr>
<tr><td id="filename" align="center" style="text-align:center"></td></tr>
<tr><td id="size" align="center" style="text-align:center"></td></tr>
<tr><td align="center" style="text-align:center">
<div style="display:table;position:relative;margin:auto;top:0px;"><span id="progress_percent"></span><div class="progress-container complete"><div id="prog_width"><span class="progressbar-front-text" style="margin:auto;top:-3px;" id="progress" name="progress" value="0%"></span></div></div></div>
</td></tr>
<tr><td id="status" align="center" style="text-align:center"></td></tr>
</tbody>
</table>
</div>
</div>
</br></br>
<h2><center><bold>HISTORY</bold></center></h2>
%if type(resultlist) == str:
<center>${resultlist}</center></br>
%else:
<div class="table_wrapper">
<table class="display" id="queue_table">
<thead>
<tr>
<th id="qcomicid">ComicID</th>
<th id="qseries">Series</th>
<th id="qsize">Size</th>
<th id="qprogress">%</th>
<th id="qstatus">Status</th>
<th id="qdate">Updated</th>
<th id="qoptions">Options</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
%endif
</%def>
<%def name="headIncludes()">
<link rel="stylesheet" href="interfaces/default/css/data_table.css">
</%def>
<%def name="javascriptIncludes()">
<script src="js/libs/jquery.dataTables.min.js"></script>
<script src="js/libs/full_numbers_no_ellipses.js"></script>
<script>
var ImportTimer = setInterval(activecheck, 5000);
function activecheck() {
$.get('check_ActiveDDL',
function(data){
if (data.error != undefined) {
alert(data.error);
return;
};
var obj = JSON.parse(data);
var percent = obj['percent'];
var status = obj['status'];
var aid = obj['a_id'];
if (status == 'Downloading') {
acm = document.getElementById("active_message");
acm.style.display = "none";
acq = document.getElementById("active_queue");
acq.style.display = "unset";
document.getElementById("prog_width").style.width=percent;
$("#progress").html(percent);
document.getElementById("series").innerHTML = obj['a_series'];
document.getElementById("filename").innerHTML = obj['a_filename'];
document.getElementById("size").innerHTML = obj['a_size'];
document.getElementById("status").innerHTML = status;
qmm = document.getElementById("queue_menu");
qmm.style.display = "inline-block";
$("#qrestartddl").attr('onClick', "ajaxcallit('restart', '"+aid+"')");
$("#qresumeddl").attr('onClick', "ajaxcallit('resume', '"+aid+"')");
$("#qabortddl").attr('onClick', "ajaxcallit('abort', '"+aid+"')");
} else if ( status.indexOf("File does not exist") > -1){
acm = document.getElementById("active_message");
acm.style.display = "inline-block";
acq = document.getElementById("active_queue");
acq.style.display = "none";
document.getElementById("amessage").innerHTML = status;
qmm = document.getElementById("queue_menu");
qmm.style.display = "inline-block";
$("#arestartddl").attr('onClick', "ajaxcallit('restart', '"+aid+"')");
$("#aresumeddl").attr('onClick', "ajaxcallit('resume', '"+aid+"')");
$("#aabortddl").attr('onClick', "ajaxcallit('abort', '"+aid+"')");
} else {
acm = document.getElementById("active_message");
acm.style.display = "inline-block";
acq = document.getElementById("active_queue");
acq.style.display = "none";
qmm = document.getElementById("queue_menu");
qmm.style.display = "none";
document.getElementById("amessage").innerHTML = status;
}
if (percent == '100%') {
clearInterval(ImportTimer);
$('#queue_table').DataTable().ajax.reload(null, false);
ImportTimer = setInterval(activecheck, 5000);
}
});
};
function ajaxcallit(qmode, queueid) {
$.get("ddl_requeue",
{ mode: qmode, id: queueid },
function(data){
if (data.error != undefined) {
alert(data.error);
return;
}
var objd = JSON.parse(data);
if (qmode == 'restart') {
$('#ajaxMsg').html("<div class='msg'><span class='ui-icon ui-icon-check'></span>"+objd['message']+"</div>");
} else if (qmode == 'resume') {
$('#ajaxMsg').html("<div class='msg'><span class='ui-icon ui-icon-check'></span>"+objd['message']+"</div>");
} else if (qmode == 'abort') {
$('#ajaxMsg').html("<div class='msg'><span class='ui-icon ui-icon-check'></span>"+objd['message']+"</div>");
} else if (qmode == 'remove') {
$('#ajaxMsg').html("<div class='msg'><span class='ui-icon ui-icon-check'></span>"+objd['message']+"</div>");
} else if (qmode == 'restart-queue') {
$('#ajaxMsg').html("<div class='msg'><span class='ui-icon ui-icon-check'></span>"+objd['message']+"</div>");
}
});
$('#ajaxMsg').addClass('success').fadeIn().delay(3000).fadeOut();
$('#queue_table').DataTable().ajax.reload(null, false);
};
function initThisPage() {
initActions();
$("#queuebuttons #queue_menu #arestartddl, #qrestartddl").button({ icons: { primary: "ui-icon-refresh" } });
$("#queuebuttons #queue_menu #aresumeddl, #qresumeddl").button({ icons: { primary: "ui-icon-pencil" } });
$("#queuebuttons #queue_menu #aabortddl, #qabortddl").button({ icons: { primary: "ui-icon-pencil" } });
if ( $.fn.dataTable.isDataTable( '#queue_table' ) ) {
$('#queue_table').DataTable().ajax.reload(null, false);
} else {
$('#queue_table').DataTable( {
"processing": true,
"serverSide": true,
"ajaxSource": 'queueManageIt',
"paginationType": "full_numbers",
"sorting": [[0, 'desc']],
"displayLength": 15,
"stateSave": false,
"columnDefs": [
{
"sortable": false,
"targets": [ 0 ],
"visible": false,
},
{
"sortable": true,
"targets": [ 1 ],
"visible": true,
"data": "Series",
"render":function (data,type,full) {
return '<span title="' + full[1] + '"></span><a href="comicDetails?ComicID=' + full[0] + '">' + full[1] + '</a>';
}
},
{
"sortable": false,
"targets": [ 6 ],
"visible": true,
"render":function (data,type,full) {
val = full[4]
var restartline = "('ddl_requeue?mode=restart&id="+String(full[6])+"',$(this));"
var resumeline = "('ddl_requeue?mode=resume&id="+String(full[6])+"',$(this));"
var removeline = "('ddl_requeue?mode=remove&id="+String(full[6])+"',$(this));"
if (val == 'Completed' || val == 'Failed' || val == 'Downloading'){
return '<span title="Restart"></span><a href="#" onclick="doAjaxCall'+restartline+'">Restart</a><span title="Remove"></span><a href="#" onclick="doAjaxCall'+removeline+'"><span class="ui-icon ui-icon-plus"></span>Remove</a>';
} else if (val == 'Incomplete') {
return '<span title="Restart"></span><a href="#" onclick="doAjaxCall'+restartline+'">Restart</a><span title="Resume"></span><a href="#" onclick="doAjaxCall'+resumeline+'"><span class="ui-icon ui-icon-plus"></span>Resume</a>';
} else if (val == 'Queued') {
return '<span title="Start"></span><a href="#" onclick="doAjaxCall'+restartline+'">Start</a>';
}
}
},
],
"language": {
"search":"Filter:",
"lengthMenu":"Show _MENU_ items per page",
"emptyTable": "No information available",
"info":"Showing _START_ to _END_ of _TOTAL_ items",
"infoEmpty":"Showing 0 to 0 of 0 lines",
"infoFiltered":"(filtered from _MAX_ total items)"
},
"rowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
if (aData[4] === "Completed") {
$('td', nRow).closest('tr').addClass("gradeA");
} else if (aData[4] === "Queued") {
$('td', nRow).closest('tr').addClass("gradeL");
} else if (aData[4] === "Incomplete" || aData[4] == "Failed") {
$('td', nRow).closest('tr').addClass("gradeX");
}
nRow.children[0].id = 'qcomicid';
nRow.children[1].id = 'qseries';
nRow.children[2].id = 'qsize';
nRow.children[3].id = 'qprogress';
nRow.children[4].id = 'qstatus';
nRow.children[5].id = 'qdate';
return nRow;
},
"drawCallback": function (o) {
// Jump to top of page
$('html,body').scrollTop(0);
},
"serverData": function ( sSource, aoData, fnCallback ) {
/* Add some extra data to the sender */
$.getJSON(sSource, aoData, function (json) {
fnCallback(json)
});
},
"fnInitComplete": function(oSettings, json)
{
},
});
};
activecheck();
};
$(document).ready(function() {
initThisPage();
});
</script>
</%def>