Add job namespace and remove old json_routes logic

This commit is contained in:
Patrick Jentsch
2024-12-06 11:41:36 +01:00
parent 1372c86609
commit 93344c9573
10 changed files with 82 additions and 110 deletions

View File

@ -13,14 +13,14 @@ def _delete_job(app: Flask, job_id: int):
db.session.commit()
def _restart_job(app, job_id):
def _restart_job(app: Flask, job_id: int):
with app.app_context():
job = Job.query.get(job_id)
job.restart()
db.session.commit()
class UsersNamespace(Namespace):
class JobsNamespace(Namespace):
@socketio_login_required
def on_delete(self, job_hashid: str) -> dict:
job_id = hashids.decode(job_hashid)
@ -52,7 +52,7 @@ class UsersNamespace(Namespace):
}
@socketio_admin_required
def on_log(self, job_hashid: str):
def on_log(self, job_hashid: str) -> dict:
job_id = hashids.decode(job_hashid)
if not isinstance(job_id, int):
@ -76,7 +76,7 @@ class UsersNamespace(Namespace):
}
socketio_login_required
def on_restart(self, job_hashid: str):
def on_restart(self, job_hashid: str) -> dict:
job_id = hashids.decode(job_hashid)
if not isinstance(job_id, int):