Skip to content

Commit

Permalink
F #2410: Fix autorefresh issues (#332)
Browse files Browse the repository at this point in the history
Signed-off-by: Frederick Borges <[email protected]>
  • Loading branch information
Frederick Borges authored and rsmontero committed Oct 30, 2020
1 parent a154cc9 commit 0c7359a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
14 changes: 12 additions & 2 deletions src/sunstone/public/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,18 @@ define(function(require) {
Sunstone.showTab(PROVISION_TAB_ID);
}

Websocket.start();
FireedgeValidator.validateFireedge();
var success_function = function() {
sessionStorage.setItem(FireedgeValidator.sessionVar, "true");
Websocket.start();
};
var error_function = function() {
sessionStorage.removeItem(FireedgeValidator.sessionVar);
setTimeout(function(){
_is_fireedge_running(tries+1);
}, 1000);
}
FireedgeValidator.validateFireedgeWithFunctions(success_function,error_function);


$('#loading').hide();
});
Expand Down
17 changes: 15 additions & 2 deletions src/sunstone/public/app/utils/fireedge-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ define(function (require) {
// Recursive function to validate if Fireedge Server is running
var _is_fireedge_running = function(tries) {
var fireedge_running = sessionStorage.getItem(session_var);
if (!fireedge_running && tries <= max_tries){
if (!fireedge_running && (tries < max_tries)){
var success_function = function() {
sessionStorage.setItem(session_var, "true");
};
Expand All @@ -35,7 +35,15 @@ define(function (require) {
setTimeout(function(){
_is_fireedge_running(tries+1);
}, 1000);
}
}
_request(success_function,error_function);
}
}

// Recursive function to validate if Fireedge Server is running
var _is_fireedge_running = function(tries, success_function, error_function) {
var fireedge_running = sessionStorage.getItem(session_var);
if (!fireedge_running && (tries < max_tries)){
_request(success_function,error_function);
}
}
Expand All @@ -52,9 +60,14 @@ define(function (require) {
var _validate_fireedge = function() {
_is_fireedge_running(0);
}

var _validate_fireedge_with_functions = function(success,error) {
_is_fireedge_running(0,success,error);
}

var fireedge_validator = {
"validateFireedge": _validate_fireedge,
"validateFireedgeWithFunctions": _validate_fireedge_with_functions,
"request": _request,
"sessionVar": session_var
};
Expand Down

0 comments on commit 0c7359a

Please sign in to comment.