import log lines also included, with appropriate DB / html

This commit is contained in:
2021-01-14 12:09:32 +11:00
parent 3684f279e4
commit 2dc80d4399
2 changed files with 21 additions and 4 deletions

View File

@@ -8,6 +8,15 @@ from status import st, Status
from datetime import datetime, timedelta
import pytz
class Importlogline(db.Model):
id = db.Column(db.Integer, db.Sequence('ill_id_seq'), primary_key=True )
import_id = db.Column(db.Integer, db.ForeignKey('import.id'), primary_key=True )
log_date = db.Column(db.DateTime(timezone=True))
log = db.Column(db.String)
def __repr__(self):
return "<id: {}, import_id: {}, log: {}".format(self.id, self.import_id, self.log )
################################################################################
# Class describing Action in the database, and via sqlalchemy, connected to the DB as well
################################################################################
@@ -25,9 +34,6 @@ class Importlog(db.Model):
def __repr__(self):
return "<id: {}, start_time: {}, last_update: {}, state: {}, num_passes: {}, current_passes: {}, num_files: {}, current_file_num: {}, current_file: {}>".format(self.id, self.start_time, self.last_update, self.state, self.num_passes, self.current_pass, self.num_files, self.num_files, self.current_file_num, self.current_file)
class Importlogline(db.Model):
action_id = db.Column(db.Integer, db.ForeignKey('import.id'), primary_key=True )
log = db.Column(db.String)
################################################################################
# /imports -> show current settings
@@ -46,9 +52,10 @@ def imports():
def importlog(id):
page_title='Show Import Details'
importlog = Importlog.query.get(id)
logs=Importlogline.query.filter(Importlogline.import_id==id).all()
duration=(datetime.now(pytz.utc)-importlog.start_time)
duration= duration-timedelta(microseconds=duration.microseconds)
return render_template("importlog.html", imp=importlog, st=importlog.start_time.strftime("%d/%m/%Y %I:%M:%S %p"), duration=duration, page_title=page_title, alert=st.GetAlert(), message=st.GetMessage() )
return render_template("importlog.html", imp=importlog, logs=logs, duration=duration, page_title=page_title, alert=st.GetAlert(), message=st.GetMessage() )
###############################################################################
# This func creates a new filter in jinja2 to format the time from the db in a

View File

@@ -41,5 +41,15 @@
</div>
</div>
</div>
<div class="row col-lg-12">
<table id="import_tbl" class="table table-striped table-sm" data-toolbar="#toolbar" data-search="true">
<thead><tr class="thead-light"><th>When</th><th>Details</th></tr></thead>
<tbody>
{% for log in logs %}
<tr><td>{{log.log_date|vicdate}}</td><td>{{log.log}}</td></tr>
{% endfor %}
</tbody>
</table>
</div>
</div class="containter">
{% endblock main_content %}