From 6b8ca305061a40f71524a0cf1f60a322c2e832cf Mon Sep 17 00:00:00 2001 From: Mia Lemoine Date: Fri, 7 Oct 2022 21:40:39 +0100 Subject: [PATCH 1/2] show a new version link when it is available --- piku_dashboard/main.py | 13 ++++++++++++- piku_dashboard/templates/home.html | 4 ++-- requirements.txt | 1 + 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/piku_dashboard/main.py b/piku_dashboard/main.py index e86b8eb..b6e2da5 100644 --- a/piku_dashboard/main.py +++ b/piku_dashboard/main.py @@ -3,6 +3,7 @@ import os from flask import Flask, request, render_template, flash, redirect, url_for from functools import wraps +import requests from piku_dashboard.host_client import info from piku_dashboard import piku_client @@ -21,6 +22,16 @@ logger.info(f"Detected self id as: {self_app}") +def get_github_sha(): + try: + response = requests.get("https://api.github.com/repos/rwnx/piku-dashboard/commits") + history = response.json() + + sha = history[0]['sha'][:6] + return sha + except: + return "invalid_sha" + def is_self(appid): return appid == self_app @@ -51,7 +62,7 @@ def home(): flash(f"Could Not fetch app list: {e}", "error") apps = [] - return render_template("home.html", apps=apps, host_info=host_info, self_app=self_app) + return render_template("home.html", apps=apps, host_info=host_info, self_app=self_app, github_sha=get_github_sha()) @app.route("/apps//config", methods=["GET"]) diff --git a/piku_dashboard/templates/home.html b/piku_dashboard/templates/home.html index 9b79c28..1b6d50f 100644 --- a/piku_dashboard/templates/home.html +++ b/piku_dashboard/templates/home.html @@ -18,7 +18,7 @@

Uptime