Skip to content

Commit

Permalink
Test release update
Browse files Browse the repository at this point in the history
  • Loading branch information
omersiar committed Mar 8, 2018
1 parent f082c11 commit 5e3e96a
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ deploy:
api_key:
secure: DVtDvBE9D2FiTxNkACdJoYrQ0ApV+3HwTMUyLOqZu9uJUtbDX1eqlcfaSoIEyTEyKlzDkWpIbkBN9YeHBQ69jAIxvvmnnwJ9iqc9S80BrGaPzGJ7lMPnHm+88OxXHrv7SDVZf9+0Lv59NNyl1vS9euBV2oBHBM7gMb3wz65thWkePsXT4HlksxMjd7F24dYeZ82nVAhUMYuV0vfOu6ySnQlRq5T9ZxLQcXcSLNg80MZOZI6L3Ptd1L7BYizJrV+yoqq2xpTrKiRLJM7YGIWRXIvohuwrIMpCd5GA/m2KySWEU8slXedlRWy5xSkdpWlGKLdIwCxRCaWWWCZDy6Eze4o+O0WVfNsgvXtg6dYOtwsneQrIuTOiZSuWCdjg7v03nKaiX/DkrdiPgyPHCK9dU9yynb4wKQ9kmXgiG/IDvxSltGLTQ2Y9kJtICY2Xqt+vBizr9HZ97es0dPXpopbaCds+zArxcfVu0oMr9e9c1Twwy3K5d941x5ncQ9hzK0JAkN/lbFvNs+uW88Oq//Xaz+FXamkkfydtBJ8LFCW64JVb4iZwWEXc44ihK3iTG1wubsGWma48DvirijtJrltZLyVzVr3fXF+moAw6kBMrHaQOLYKeR2Qbecx+FV4Alh/FY+zpiZ6FTW3ufZExolmLuGsUsGBWqMTNYOlT3hMsgnk=
file_glob: true
file: bin/*
file: bin/firmware.bin
on:
repo: omersiar/esp-rfid
all_branches: true
condition: $TRAVIS_TAG =~ ^[0-9]+\.[0-9]+$
condition: $TRAVIS_TAG =~ ^[0-9]+\.[0-9]+\.[0-9]+$
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.

## [Unreleased]
#### Added
- [webui] Update checker

## [0.5hotfix2] - 2018-03-07
#### Added
- [webui] Factory reset within Web UI.
- [webui] + [firmware] Event logging is now live.

Expand Down
24 changes: 22 additions & 2 deletions src/websrc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ <h1>
<a href="#" id="reset"><i class="glyphicon glyphicon-repeat"></i>Factory Reset</a>
</li>
<li>
<a href="#" class="noimp"><i class="glyphicon glyphicon-open"></i>Update</a>
<a data-toggle="modal" href="#update"><i class="glyphicon glyphicon-open"></i>Update</a>
</li>
</ul>
<ul class="list-unstyled CTAs">
Expand Down Expand Up @@ -146,7 +146,6 @@ <h4 class="modal-title">Are you absolutely sure?</h4>
This action <strong>cannot</strong> be undone. This will permanently delete <strong>all the user data and settings.</strong> Please make sure you made a backup first.
</p>
<p>Please type in the hostname of the device to confirm.</p>

<p>
<input type="text" class="form-control input-block" id="compare" oninput="compareDestroy()">
</p>
Expand All @@ -157,6 +156,27 @@ <h4 class="modal-title">Are you absolutely sure?</h4>
</div>
</div>
</div>
<div id="update" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Update Firmware</h4>
</div>
<div class="alert alert-warning">
<strong>Warning!</strong> Please make sure you made a backup first
</div>
<div class="modal-body">
<pre id="releaseinfo">Getting update information from GitHub...</pre>

</div>
<div class="modal-footer">
<a id="downloadupdate"><button type="button" class="btn btn-success">Download</button></a>
</div>
</div>
</div>
</div>
</div>
<footer class="footer">
<div id="commit" class="container">
Expand Down
34 changes: 33 additions & 1 deletion src/websrc/js/esprfid.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ var config = {
"general": {
"hostnm": "esp-rfid",
"restart": "0",
"pswd": "admin"
"pswd": "admin",
"version": "v0.5.3"
},
"mqtt": {
"enabled": "0",
Expand Down Expand Up @@ -1066,6 +1067,37 @@ function logout() {
return false;
}

$("#update").on("shown.bs.modal", function (e) {
GetLatestReleaseInfo();
})

function GetLatestReleaseInfo() {
$.getJSON("https://api.github.com/repos/omersiar/esp-rfid/releases/latest").done(function(release) {
var asset = release.assets[0];
var downloadCount = 0;
/*
console.log(asset);
for (var i = 0; i < release.assets.length; i++) {
downloadCount += release.assets[i].download_count;
}
*/
var oneHour = 60 * 60 * 1000;
var oneDay = 24 * oneHour;
var dateDiff = new Date() - new Date(release.published_at);
var timeAgo;
if (dateDiff < oneDay) {
timeAgo = (dateDiff / oneHour).toFixed(1) + " hours ago";
} else {
timeAgo = (dateDiff / oneDay).toFixed(1) + " days ago";
}

var releaseInfo = release.name + " was updated " + timeAgo + " and downloaded " + downloadCount.toLocaleString() + " times." + release.body;
$("#downloadupdate").attr("href", release.url);
$("#releaseinfo").text(releaseInfo);
$("#releaseinfo").fadeIn("slow");
});
}

function start() {
if (window.location.protocol === "https:") {
wsUri = "wss:https://" + window.location.hostname + "/ws";
Expand Down

0 comments on commit 5e3e96a

Please sign in to comment.