From 2e19f5471e290dc3df0f1dabde32268b2c174381 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Sat, 3 Nov 2018 19:05:46 +0100 Subject: [PATCH] [enh] plug apps page to jobs updates --- run.py | 2 +- templates/apps.html | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/run.py b/run.py index 3c28f67..e43ab38 100644 --- a/run.py +++ b/run.py @@ -453,7 +453,7 @@ async def ws_job(request, websocket, job_id): @app.websocket('/apps-ws') async def ws_apps(request, websocket): - # subscribe(websocket, f"job-{job.id}") + subscribe(websocket, "jobs") # I need to do this because peewee strangely fuck up on join and remove the # subquery fields which breaks everything diff --git a/templates/apps.html b/templates/apps.html index 03dfbc0..8ee771a 100644 --- a/templates/apps.html +++ b/templates/apps.html @@ -76,7 +76,19 @@ if (action == "init_apps") { app.apps = data; + } else if (action == "update_job") { + for (var i = 0; i < app.apps.length; ++i) { + if (app.apps[i].job_id == data.id) { + Vue.set(app.apps[i], 'job_state', data.state); + Vue.set(app.apps[i], 'created_time', data.created_time); + Vue.set(app.apps[i], 'started_time', data.started_time); + Vue.set(app.apps[i], 'end_time', data.end_time); + } + } + } else if (action == "add_job") { + } + }; })()