Skip to content

Commit

Permalink
Added version indicator / repo link
Browse files Browse the repository at this point in the history
  • Loading branch information
danielperna84 committed Jan 29, 2017
1 parent a18720d commit 5604a81
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 5 deletions.
3 changes: 2 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
26 changes: 24 additions & 2 deletions configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("""<!DOCTYPE html>
Expand All @@ -49,7 +50,6 @@
width: 20%;
float: left;
font-size: 9pt;
}
#buttons {
Expand All @@ -58,6 +58,11 @@
right: 0;
}
#release {
float: right;
padding: 2px;
}
#toolbar {
position: relative;
height: 20px;
Expand Down Expand Up @@ -90,6 +95,14 @@
#services {
max-width: 100%;
}
.green {
color: #0f0;
}
.red {
color: #f00;
}
</style>
</head>
<body>
Expand Down Expand Up @@ -132,6 +145,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>
Expand Down Expand Up @@ -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

Expand Down
11 changes: 10 additions & 1 deletion dev/configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "."

Expand Down Expand Up @@ -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

Expand Down
15 changes: 14 additions & 1 deletion dev/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
width: 20%;
float: left;
font-size: 9pt;

}

#buttons {
Expand All @@ -28,6 +27,11 @@
right: 0;
}

#release {
float: right;
padding: 2px;
}

#toolbar {
position: relative;
height: 20px;
Expand Down Expand Up @@ -60,6 +64,14 @@
#services {
max-width: 100%;
}

.green {
color: #0f0;
}

.red {
color: #f00;
}
</style>
</head>
<body>
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 5604a81

Please sign in to comment.