update: improve visuals & status list

This commit is contained in:
2023-07-02 23:03:01 +02:00
parent d4fa40af74
commit 8eb4271c04
4 changed files with 18 additions and 11 deletions

View File

@@ -51,7 +51,7 @@ class Status(db.Model):
def human_date(self): def human_date(self):
dt = datetime.datetime.fromtimestamp(self.timestamp) dt = datetime.datetime.fromtimestamp(self.timestamp)
return dt.strftime("%d-%m%-%y %H:%M") return dt.strftime("%d. %B %Y at %H:%M")
def buildReponseDict(status, service=None): def buildReponseDict(status, service=None):
@@ -91,7 +91,6 @@ def overview():
status_age = datetime.datetime.now() - status_time_parsed status_age = datetime.datetime.now() - status_time_parsed
# check service timeout # # check service timeout #
print(service.timeout, service, service.token)
timeout = datetime.timedelta(seconds=service.timeout) timeout = datetime.timedelta(seconds=service.timeout)
if status_age > timeout: if status_age > timeout:
status.status = "WARNING" status.status = "WARNING"
@@ -134,10 +133,10 @@ def service_details():
if service.owner and service.owner != user: if service.owner and service.owner != user:
return ("Services is not owned by {}".format(user)) return ("Services is not owned by {}".format(user))
status_list = db.session.query() status_list = db.session.query(Status).filter(Status.service==service.service).all()
return flask.render_template("service_info.html", service=service, flask=flask, return flask.render_template("service_info.html", service=service, flask=flask,
user=user) user=user, status_list=status_list)
@app.route("/entry-form", methods=["GET", "POST", "DELETE"]) @app.route("/entry-form", methods=["GET", "POST", "DELETE"])

View File

@@ -68,6 +68,10 @@ body{
color: pink; color: pink;
} }
.ok{
color: #5aff5a;
}
.warning{ .warning{
color: orange; color: orange;
} }

View File

@@ -36,7 +36,7 @@
{% if status.timestamp == 0 %} {% if status.timestamp == 0 %}
Service never reported in Service never reported in
{% else %} {% else %}
{{ datetime.fromtimestamp(status.timestamp).strftime("%H:%M on %d.%b.%y") }} {{ status.human_date() }}
{% endif %} {% endif %}
</small> </small>
</a> </a>

View File

@@ -12,9 +12,11 @@
<div class="last-status"> <div class="last-status">
{% if status_list | length > 0 %} {% if status_list | length > 0 %}
<p>{{ status_list[0].status }} submitted on {{ status_list[0].timestamp }}</i> <p class="{{ status_list[0].status }}">
{{ status_list[0].status }} submitted on {{ status_list[0].human_date() }}
</p>
{% else %} {% else %}
<p style="color: darkred;">No status for this service submitted</i> <p style="color: darkred;">No status for this service submitted</p>
{% endif %} {% endif %}
</div> </div>
@@ -58,11 +60,13 @@
<th>Info</th> <th>Info</th>
</thead> </thead>
<tbody> <tbody class="mt-2">
{% for status in status_list %} {% for status in status_list %}
<td>status.human_date()<td> <tr>
<td>status.status</td> <td>{{ status.human_date() }}</td>
<td>status.info</td> <td class="{{ status.status }}">{{ status.status }}</td>
<td>{{ status.info_text }}</td>
</tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>