diff --git a/changelog.txt b/changelog.txt index 7867dcd..a0279a9 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,7 @@ Version 0.0.6 (2017-01-29) - Added SSL support -- Added restart button +- Added HASS restart button +- Added version indicator with link to repo Version 0.0.5 (2017-01-27) - Ugly workaround to run configurator.py from somewhere else than HASS-dir (Issue #1) diff --git a/configurator.py b/configurator.py index 95152a9..92e3e71 100755 --- a/configurator.py +++ b/configurator.py @@ -26,6 +26,7 @@ HASS_API_PASSWORD = None ### End of options +RELEASEURL = "https://api.github.com/repos/danielperna84/hass-poc-configurator/releases/latest" VERSION = "0.0.6" BASEDIR = "." INDEX = Template(""" @@ -49,7 +50,6 @@ width: 20%; float: left; font-size: 9pt; - } #buttons { @@ -58,6 +58,11 @@ right: 0; } + #release { + float: right; + padding: 2px; + } + #toolbar { position: relative; height: 20px; @@ -90,6 +95,14 @@ #services { max-width: 100%; } + + .green { + color: #0f0; + } + + .red { + color: #f00; + } @@ -132,6 +145,7 @@ + $current
@@ -392,7 +406,15 @@ def do_GET(self): except Exception as err: print(err) - html = INDEX.safe_substitute(bootstrap=boot) + color = "green" + try: + response = urllib.request.urlopen(RELEASEURL) + latest = json.loads(response.read().decode('utf-8'))['tag_name'] + if VERSION != latest: + color = "red" + except Exception as err: + print(err) + html = INDEX.safe_substitute(bootstrap=boot, current=VERSION, versionclass=color) self.wfile.write(bytes(html, "utf8")) return diff --git a/dev/configurator.py b/dev/configurator.py index 2723227..dcc6c3f 100755 --- a/dev/configurator.py +++ b/dev/configurator.py @@ -25,6 +25,7 @@ HASS_API = "http://127.0.0.1:8123/api/" ### End of options +RELEASEURL = "https://api.github.com/repos/danielperna84/hass-poc-configurator/releases/latest" VERSION = "0.0.6" BASEDIR = "." @@ -115,7 +116,15 @@ def do_GET(self): except Exception as err: print(err) - html = html.safe_substitute(bootstrap=boot) + color = "green" + try: + response = urllib.request.urlopen(RELEASEURL) + latest = json.loads(response.read().decode('utf-8'))['tag_name'] + if VERSION != latest: + color = "red" + except Exception as err: + print(err) + html = INDEX.safe_substitute(bootstrap=boot, current=VERSION, versionclass=color) self.wfile.write(bytes(html, "utf8")) return diff --git a/dev/index.html b/dev/index.html index 9eb3816..35fffba 100644 --- a/dev/index.html +++ b/dev/index.html @@ -19,7 +19,6 @@ width: 20%; float: left; font-size: 9pt; - } #buttons { @@ -28,6 +27,11 @@ right: 0; } + #release { + float: right; + padding: 2px; + } + #toolbar { position: relative; height: 20px; @@ -60,6 +64,14 @@ #services { max-width: 100%; } + + .green { + color: #0f0; + } + + .red { + color: #f00; + } @@ -102,6 +114,7 @@ + $current