Added version indicator / repo link

This commit is contained in:
Daniel 2017-01-29 15:21:56 +00:00
parent a18720d3f6
commit 5604a81f1b
4 changed files with 50 additions and 5 deletions

View file

@ -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)

View file

@ -26,6 +26,7 @@ HASS_API = "http://127.0.0.1:8123/api/"
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("""<!DOCTYPE html>
@ -49,7 +50,6 @@ INDEX = Template("""<!DOCTYPE html>
width: 20%;
float: left;
font-size: 9pt;
}
#buttons {
@ -58,6 +58,11 @@ INDEX = Template("""<!DOCTYPE html>
right: 0;
}
#release {
float: right;
padding: 2px;
}
#toolbar {
position: relative;
height: 20px;
@ -90,6 +95,14 @@ INDEX = Template("""<!DOCTYPE html>
#services {
max-width: 100%;
}
.green {
color: #0f0;
}
.red {
color: #f00;
}
</style>
</head>
<body>
@ -132,6 +145,7 @@ INDEX = Template("""<!DOCTYPE html>
<button id="restart" type="button" onclick="restart_dialog()">Restart HASS</button>
<button id="help" type="button" onclick="window.open('https://home-assistant.io/getting-started/','_blank');">Help</button>
<button id="components" type="button" onclick="window.open('https://home-assistant.io/components/','_blank');">Components</button>
<a id="release" class="$versionclass" href="https://github.com/danielperna84/hass-poc-configurator/releases/latest" target="_blank">$current</a>
</div>
<div id="editor"></div>
</body>
@ -392,7 +406,15 @@ class RequestHandler(BaseHTTPRequestHandler):
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

View file

@ -25,6 +25,7 @@ SSL_KEY = None
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 @@ class RequestHandler(BaseHTTPRequestHandler):
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

View file

@ -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;
}
</style>
</head>
<body>
@ -102,6 +114,7 @@
<button id="restart" type="button" onclick="restart_dialog()">Restart HASS</button>
<button id="help" type="button" onclick="window.open('https://home-assistant.io/getting-started/','_blank');">Help</button>
<button id="components" type="button" onclick="window.open('https://home-assistant.io/components/','_blank');">Components</button>
<a id="release" class="$versionclass" href="https://github.com/danielperna84/hass-poc-configurator/releases/latest" target="_blank">$current</a>
</div>
<div id="editor"></div>
</body>