mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-24 16:52:06 +00:00
WIP
This commit is contained in:
parent
f32836d82e
commit
fcbb2300a3
4 changed files with 30 additions and 5 deletions
|
@ -66,8 +66,20 @@ class Languages(Resource):
|
|||
|
||||
class SystemTasks(Resource):
|
||||
def get(self):
|
||||
taskid = request.args.get('taskid')
|
||||
|
||||
task_list = scheduler.get_task_list()
|
||||
|
||||
for item in task_list:
|
||||
# Add Datatables rowId
|
||||
item.update({"DT_RowId": item['job_id']})
|
||||
|
||||
if taskid:
|
||||
for item in task_list:
|
||||
if item['job_id'] == taskid:
|
||||
task_list = [item]
|
||||
continue
|
||||
|
||||
return jsonify(data=task_list)
|
||||
|
||||
|
||||
|
|
|
@ -39,12 +39,12 @@ class Scheduler:
|
|||
def task_listener_add(event):
|
||||
if event.job_id not in self.__running_tasks:
|
||||
self.__running_tasks.append(event.job_id)
|
||||
event_stream.write(type='task')
|
||||
event_stream.write(type='task', task=event.job_id)
|
||||
|
||||
def task_listener_remove(event):
|
||||
if event.job_id in self.__running_tasks:
|
||||
self.__running_tasks.remove(event.job_id)
|
||||
event_stream.write(type='task')
|
||||
event_stream.write(type='task', task=event.job_id)
|
||||
|
||||
self.aps_scheduler.add_listener(task_listener_add, EVENT_JOB_SUBMITTED)
|
||||
self.aps_scheduler.add_listener(task_listener_remove, EVENT_JOB_EXECUTED | EVENT_JOB_ERROR)
|
||||
|
|
|
@ -10,7 +10,7 @@ class EventStream:
|
|||
def __init__(self):
|
||||
pass
|
||||
|
||||
def write(self, type=None, action=None, series=None, episode=None, movie=None):
|
||||
def write(self, type=None, action=None, series=None, episode=None, movie=None, task=None):
|
||||
"""
|
||||
:param type: The type of element.
|
||||
:type type: str
|
||||
|
@ -22,8 +22,11 @@ class EventStream:
|
|||
:type episode: str
|
||||
:param movie: The movie id.
|
||||
:type movie: str
|
||||
:param task: The task id.
|
||||
:type task: str
|
||||
"""
|
||||
socketio.emit('event', json.dumps({"type": type, "action": action, "series": series, "episode": episode, "movie": movie}), broadcast=True)
|
||||
socketio.emit('event', json.dumps({"type": type, "action": action, "series": series, "episode": episode,
|
||||
"movie": movie, "task": task}), broadcast=True)
|
||||
|
||||
|
||||
event_stream = EventStream()
|
||||
|
|
|
@ -31,7 +31,17 @@
|
|||
events.on('event', function (event) {
|
||||
var event_json = JSON.parse(event);
|
||||
if (event_json.type === 'task') {
|
||||
table.ajax.reload();
|
||||
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]);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue