You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bazarr/views/systemtasks.html

109 lines
3.5 KiB

5 years ago
{% extends '_main.html' %}
5 years ago
{% block title %}Tasks - Bazarr{% endblock %}
5 years ago
{% block bcleft %}
5 years ago
<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>
5 years ago
{% 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 () {
5 years ago
events.on('event', function (event) {
var event_json = JSON.parse(event);
if (event_json.type === 'task') {
5 years ago
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]);
}
}
})
}
5 years ago
}
});
5 years ago
var table = $('#tasks').DataTable( {
language: {
zeroRecords: 'No Task Scheduled.',
processing: "Loading Tasks..."
},
paging: false,
lengthChange: false,
searching: false,
ordering: false,
5 years ago
info: false,
5 years ago
processing: true,
serverSide: false,
5 years ago
ajax: {
url: "{{ url_for('api.systemtasks') }}",
type: 'GET'
},
5 years ago
columns: [
{
data: 'name'
},
{ data: 'interval'
},
{ data: 'next_run_in'
},
{ data: null,
render: function(data) {
5 years ago
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>';
}
5 years ago
}
}
]
});
5 years ago
5 years ago
$('#refresh_button').on('click', function() {
table.ajax.reload();
table.columns.adjust().draw(false);
})
5 years ago
$('#tasks').on('click', '.execute', function(e){
e.preventDefault();
const values = {
'taskid': $(this).data("taskid")
};
$.ajax({
url: "{{ url_for('api.systemtasks') }}",
method: "POST",
5 years ago
data: values
5 years ago
});
});
5 years ago
})
</script>
{% endblock tail %}