bazarr/views/systemtasks.html

117 lines
3.6 KiB
HTML
Raw Normal View History

2020-02-20 11:41:05 +00:00
{% extends '_main.html' %}
2020-02-22 14:03:58 +00:00
{% block title %}Tasks - Bazarr{% endblock %}
2020-02-20 11:41:05 +00:00
2020-10-05 15:20:24 +00:00
{% block page_head %}
<style>
.execute {
cursor: pointer;
}
</style>
{% endblock page_head %}
2020-02-20 11:41:05 +00:00
{% block bcleft %}
2020-04-30 12:38:05 +00:00
<div class="">
<button class="btn btn-outline" id="refresh_button">
<div><i class="fas fa-sync align-top text-themecolor text-center font-20" aria-hidden="true"></i></div>
<div class="align-bottom text-themecolor small text-center">Refresh</div>
</button>
</div>
2020-02-20 11:41:05 +00:00
{% endblock bcleft %}
{% block bcright %}
{% endblock bcright %}
{% block body %}
<div class="container-fluid">
<table id="tasks" class="table table-striped" style="width:100%">
<thead>
<tr>
<th>Name</th>
<th>Execution Frequency</th>
<th>Next Execution</th>
<th></th>
</tr>
</thead>
</table>
</div>
{% endblock body %}
{% block tail %}
<script>
$(document).ready(function () {
2020-02-22 14:11:56 +00:00
events.on('event', function (event) {
var event_json = JSON.parse(event);
if (event_json.type === 'task') {
2020-02-23 14:25:24 +00:00
var rowId = table.row('#'+event_json.task);
if (rowId.length) {
$.ajax({
url: "{{ url_for('api.systemtasks') }}?taskid=" + event_json.task,
success: function (data) {
if (data.data.length) {
table.row(rowId).data(data.data[0]);
}
}
})
}
2020-02-22 14:11:56 +00:00
}
});
2020-02-20 11:41:05 +00:00
var table = $('#tasks').DataTable( {
language: {
zeroRecords: 'No Task Scheduled.',
processing: "Loading Tasks..."
},
paging: false,
lengthChange: false,
searching: false,
ordering: false,
2020-02-23 15:17:49 +00:00
info: false,
2020-02-20 11:41:05 +00:00
processing: true,
serverSide: false,
2020-02-22 14:03:58 +00:00
ajax: {
url: "{{ url_for('api.systemtasks') }}",
type: 'GET'
},
2020-02-20 11:41:05 +00:00
columns: [
{
data: 'name'
},
{ data: 'interval'
},
{ data: 'next_run_in'
},
{ data: null,
render: function(data) {
2020-02-22 14:03:58 +00:00
if (data.job_running) {
return '<i class="execute fas fa-sync fa-spin" data-taskid="'+data.job_id+'"></i>';
} else {
return '<i class="execute fas fa-sync" data-taskid="'+data.job_id+'"></i>';
}
2020-02-20 11:41:05 +00:00
}
}
]
});
2020-02-22 14:03:58 +00:00
2020-04-30 12:38:05 +00:00
$('#refresh_button').on('click', function() {
table.ajax.reload();
table.columns.adjust().draw(false);
})
2020-02-22 14:03:58 +00:00
$('#tasks').on('click', '.execute', function(e){
e.preventDefault();
const values = {
'taskid': $(this).data("taskid")
};
$.ajax({
url: "{{ url_for('api.systemtasks') }}",
method: "POST",
2020-04-15 04:02:44 +00:00
data: values
2020-02-22 14:03:58 +00:00
});
});
2020-02-20 11:41:05 +00:00
})
</script>
{% endblock tail %}