[mod] rename 'target' to 'action' in websocket protocol

This commit is contained in:
Laurent Peuch 2018-07-13 22:12:36 +02:00
parent 412fa588cd
commit 6d85d76746
2 changed files with 6 additions and 6 deletions

6
run.py
View file

@ -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()),
}))

View file

@ -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);