diff --git a/run.py b/run.py index 0ea62b8..2e584b5 100644 --- a/run.py +++ b/run.py @@ -114,7 +114,7 @@ async def jobs_dispatcher(): async def run_job(worker, job): await broadcast({ - "target": "job", + "action": "job", "data": model_to_dict(job), }, "jobs") @@ -143,7 +143,7 @@ async def run_job(worker, job): worker.save() await broadcast({ - "target": "update_job", + "action": "update_job", "id": job.id, "data": model_to_dict(job), }, "jobs") @@ -172,7 +172,7 @@ async def index_ws(request, websocket): subscribe(websocket, "jobs") await websocket.send(ujson.dumps({ - "target": "init_jobs", + "action": "init_jobs", "data": map(model_to_dict, Job.select()), })) diff --git a/templates/index.html b/templates/index.html index 6e043f9..354a6d3 100644 --- a/templates/index.html +++ b/templates/index.html @@ -44,11 +44,11 @@ ws.onmessage = function (event) { var message = JSON.parse(event.data); var data = message.data; - var target = message.target; + var action = message.action; - if (target == "init_jobs") { + if (action == "init_jobs") { app.jobs = data; - } else if (target == "update_job") { + } else if (action == "update_job") { for (var i = 0; i < app.jobs.length; ++i) { if (app.jobs[i].id == data.id) { Vue.set(app.jobs, i, data);