Add queued tasks modal

This commit is contained in:
JonnyWong16 2018-10-22 22:01:16 -07:00
commit d731ad851c
6 changed files with 154 additions and 17 deletions

View file

@ -3367,6 +3367,34 @@ pre::-webkit-scrollbar-thumb {
.notification-params tr:nth-child(even) td {
background-color: rgba(255,255,255,0.010);
}
.activity-queue {
width: 100%;
margin-top: 10px;
background-color: #282828;
}
.activity-queue th {
padding-left: 10px;
height: 30px;
}
.activity-queue th:first-child {
width: 268px;
}
.activity-queue th:nth-child(2) {
width: 125px;
}
.activity-queue th:nth-child(3) {
width: 175px;
}
.activity-queue td {
height: 25px;
padding: 5px 10px;
}
.activity-queue tr:nth-child(odd) td {
background-color: rgba(255,255,255,0.035);
}
.activity-queue tr:nth-child(even) td {
background-color: rgba(255,255,255,0.010);
}
#days-selection label,
#months-selection label {
margin-bottom: 0;

View file

@ -0,0 +1,66 @@
<%
import arrow
from plexpy.activity_handler import ACTIVITY_SCHED, schedule_callback
if queue == 'active sessions':
filter_key = 'session_key-'
title_format = '{2} / {1} ({0})'
title_key = title_format.format('Session Key', 'Title', 'User')
description = 'Queue to flush stuck active sessions to the database.'
else:
filter_key = 'rating_key-'
title_format = '{1} ({0})'
title_key = title_format.format('Rating Key', 'Title')
description = 'Queue to flush recently added items to the database and send notifications if enabled.'
scheduled_jobs = [j.id for j in ACTIVITY_SCHED.get_jobs() if j.id.startswith(filter_key)]
%>
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-remove"></i></button>
<h4 class="modal-title">${queue.title()} Queue</h4>
</div>
<div class="modal-body">
<p class="help-block">
${description}
</p>
<table class="activity-queue">
<thead>
<tr>
<th>
${title_key}
</th>
<th>
Next Flush In
</th>
<th>
Next Flush Time
</th>
</tr>
</thead>
<tbody>
% if scheduled_jobs:
% for job in scheduled_jobs:
<%
sched_job = ACTIVITY_SCHED.get_job(job)
next_run_in = arrow.get(sched_job.next_run_time).timestamp - arrow.now().timestamp
%>
<tr>
<td><strong>${title_format.format(*sched_job.args)}</strong></td>
<td>${arrow.get(next_run_in).format('HH:mm:ss')}</td>
<td>${arrow.get(sched_job.next_run_time).format('YYYY-MM-DD HH:mm:ss')}</td>
</tr>
% endfor
% else:
<tr>
<td colspan="3" style="text-align: center;"><i class="fa fa-check"></i>&nbsp; Nothing in the ${queue} queue</td>
</tr>
% endif
</tbody>
</table>
</div>
<div class="modal-footer">
</div>
</div>
</div>

View file

@ -44,7 +44,13 @@ DOCUMENTATION :: END
</tr>
% elif job in ('Check for server response', 'Check for active sessions', 'Check for recently added items') and plexpy.WS_CONNECTED:
<tr>
% if job == 'Check for active sessions':
<td><a class="queue-modal-link" href="#" data-queue="active sessions">${job}</a></td>
% elif job == 'Check for recently added items':
<td><a class="queue-modal-link" href="#" data-queue="recently added">${job}</a></td>
% else:
<td>${job}</td>
% endif
<td><i class="fa fa-sm fa-fw fa-check"></i> Websocket</td>
<td>N/A</td>
<td>N/A</td>
@ -61,4 +67,21 @@ DOCUMENTATION :: END
% endif
% endfor
</tbody>
</table>
</table>
<script>
$('.queue-modal-link').on('click', function (e) {
e.preventDefault();
$.ajax({
url: 'get_queue_modal',
data: {
queue: $(this).data('queue')
},
cache: false,
async: true,
complete: function(xhr, status) {
$("#queue-modal").html(xhr.responseText);
$('#queue-modal').modal();
}
});
});
</script>

View file

@ -1316,6 +1316,7 @@
</%def>
<%def name="modalIncludes()">
<div id="queue-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="queue-modal"></div>
<div id="guidelines-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="guidelines-modal">
<div class="modal-dialog" role="document">
<div class="modal-content">