Skip to content

Commit

Permalink
Merge pull request #162 from jeremypoulter/loading_progress
Browse files Browse the repository at this point in the history
Quick report of the loading progress.
  • Loading branch information
glynhudson authored Mar 7, 2018
2 parents fe1ce5c + f34249f commit 68d6a12
Show file tree
Hide file tree
Showing 9 changed files with 807 additions and 800 deletions.
2 changes: 1 addition & 1 deletion src/data/home.htm

Large diffs are not rendered by default.

72 changes: 36 additions & 36 deletions src/data/home.js

Large diffs are not rendered by default.

717 changes: 358 additions & 359 deletions src/data/lib.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/html/home.htm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h3>WiFi</h3>
</div>

<div class="container" data-bind="visible: !initialised()">
Loading, please wait...
Loading, please wait... (<span data-bind="text: itemsLoaded"></span>/<span data-bind="text: itemsTotal"></span>)
</div>

<div class="container" data-bind="visible: initialised" style="display: none">
Expand Down
10 changes: 6 additions & 4 deletions src/html/view_models/OpenEvseViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ function OpenEvseViewModel(baseEndpoint, statusViewModel) {
self.delayTimerStop(stop);
}); },
];
var updateCount = -1;
self.updateCount = ko.observable(0);
self.updateTotal = ko.observable(updateList.length);

self.updateCurrentCapacity = function () {
return self.openevse.current_capacity_range(function (min, max) {
Expand Down Expand Up @@ -388,13 +389,14 @@ function OpenEvseViewModel(baseEndpoint, statusViewModel) {
};

self.update = function (after = function () { }) {
updateCount = 0;
self.updateCount(0);
self.nextUpdate(after);
};
self.nextUpdate = function (after) {
var updateFn = updateList[updateCount];
var updateFn = updateList[self.updateCount()];
updateFn().always(function () {
if(++updateCount < updateList.length) {
self.updateCount(self.updateCount() + 1);
if(self.updateCount() < updateList.length) {
self.nextUpdate(after);
} else {
self.subscribe();
Expand Down
9 changes: 8 additions & 1 deletion src/html/view_models/OpenEvseWiFiViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function OpenEvseWiFiViewModel(baseHost, basePort, baseProtocol)
}
return endpoint;
});

self.wsEndpoint = ko.pureComputed(function () {
var endpoint = "ws://" + self.baseHost();
if("https:" === self.baseProtocol()){
Expand Down Expand Up @@ -95,10 +95,17 @@ function OpenEvseWiFiViewModel(baseHost, basePort, baseProtocol)
// -----------------------------------------------------------------------
// Initialise the app
// -----------------------------------------------------------------------
self.loadedCount = ko.observable(0);
self.itemsLoaded = ko.pureComputed(function () {
return self.loadedCount() + self.openevse.updateCount();
});
self.itemsTotal = ko.observable(2 + self.openevse.updateTotal());
self.start = function () {
self.updating(true);
self.status.update(function () {
self.loadedCount(self.loadedCount() + 1);
self.config.update(function () {
self.loadedCount(self.loadedCount() + 1);
// If we are accessing on a .local domain try and redirect
if(self.baseHost().endsWith(".local") && "" !== self.status.ipaddress()) {
if("" === self.config.www_username())
Expand Down
2 changes: 1 addition & 1 deletion src/web_server.home.htm.h

Large diffs are not rendered by default.

76 changes: 38 additions & 38 deletions src/web_server.home.js.h

Large diffs are not rendered by default.

717 changes: 358 additions & 359 deletions src/web_server.lib.js.h

Large diffs are not rendered by default.

0 comments on commit 68d6a12

Please sign in to comment.