From aa826f69333a77debfaedfc54c235018e598d208 Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Sat, 3 Jul 2021 12:29:19 +1000 Subject: [PATCH] if > 100 logs, truncate them and add button to show all logs, and stop auto-refresh too --- TODO | 3 --- job.py | 12 +++++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/TODO b/TODO index d18ef70..f4750ad 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,5 @@ ## GENERAL - * trim joblog > (say) 100 ... [DONE] - * then click for rest - * refimgs need to be done via job_mgr: - have local FS chooser of ref img, do html file upload to b/e -> job mgr -> save it to reference_images// - remove refimg menu from top-level -> sub of Person (to view/mangage?) diff --git a/job.py b/job.py index 2978f1b..1d6b372 100644 --- a/job.py +++ b/job.py @@ -105,18 +105,24 @@ def jobs(): ############################################################################### # /job/ -> GET -> shows status/history of jobs ################################################################################ -@app.route("/job/", methods=["GET"]) +@app.route("/job/", methods=["GET","POST"]) @login_required def joblog(id): page_title='Show Job Details' joblog = Job.query.get(id) - logs=Joblog.query.filter(Joblog.job_id==id).order_by(Joblog.log_date).all() + log_cnt = db.session.execute( f"select count(id) from joblog where job_id = {id}" ).first()[0] + first_logs_only = True + if request.method == 'POST': + logs=Joblog.query.filter(Joblog.job_id==id).order_by(Joblog.log_date).all() + first_logs_only = False + else: + logs=Joblog.query.filter(Joblog.job_id==id).order_by(Joblog.log_date).limit(50).all() if joblog.pa_job_state == "Completed": duration=(joblog.last_update-joblog.start_time) else: duration=(datetime.now(pytz.utc)-joblog.start_time) duration= duration-timedelta(microseconds=duration.microseconds) - return render_template("joblog.html", job=joblog, logs=logs, duration=duration, page_title=page_title) + return render_template("joblog.html", job=joblog, logs=logs, log_cnt=log_cnt, duration=duration, page_title=page_title, first_logs_only=first_logs_only) ############################################################################### # /job/ -> GET -> shows status/history of jobs