diff --git a/run.py b/run.py index edca259..cc02301 100644 --- a/run.py +++ b/run.py @@ -68,7 +68,7 @@ async def initialize_app_list(): ) print(f"Schedule a new build for {app_id}") - Job.create( + job = Job.create( name=f"{app_id} stable", url_or_path=repo.url, target_revision=app_data["git"]["revision"], @@ -76,6 +76,12 @@ async def initialize_app_list(): state="scheduled", ) + print(job) + await broadcast({ + "action": "new_job", + "data": model_to_dict(job), + }, "jobs") + async def jobs_dispatcher(): if Worker.select().count() == 0: @@ -249,6 +255,11 @@ async def api_new_job(request): print(f"Request to add new job '{job.name}' {job}") + await broadcast({ + "action": "new_job", + "data": model_to_dict(job), + }, "jobs") + return response.text("ok") diff --git a/templates/index.html b/templates/index.html index c767ddb..f74614f 100644 --- a/templates/index.html +++ b/templates/index.html @@ -59,6 +59,8 @@ return; } } + } else if (action == "new_job") { + app.jobs.splice(0, 0, data); } }; })()