Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed the false status of apps being online returned sometimes by Nod…

…ester API
  • Loading branch information...
commit cbcd4e5e1bf9e9d80dceb49b85e925af88ad1508 1 parent bf8ce40
@roskoff authored
Showing with 31 additions and 12 deletions.
  1. +1 −1  manifest.json
  2. +30 −11 popup.js
View
2  manifest.json
@@ -12,6 +12,6 @@
"16": "/img/naw-icon16.png"
},
"permissions": [
- "http://nodester.com/"
+ "http://*.nodester.com/"
]
}
View
41 popup.js
@@ -55,21 +55,40 @@ function renderList(data) {
'<div class="span6"><h4>Status</h4></div>' +
'</div>' +
'</div>');
+ var appRunning;
$.each(list, function(index, app) {
- appsList.append(
- '<div class="span12">' +
- '<div class="row-fluid">' +
- '<div class="span6"><a href="http://'+app.name+'.nodester.com" target="_blank">'+app.name+'</a></div>' +
- '<div class="span6"><img id="img_'+app.name+'" width="24" src="/img/rocket-running-'+app.running+'.png"></div>' +
- '</div>' +
- '</div>');
- var status = app.running === 'true' ? "running! \\m/" : "down :(";
- $("#img_"+app.name).tooltip({"title":"App is " + status, "placement":"right"});
- console.log(app.name+' - '+app.running);
- });
+ // Double check if app is running, sometimes Nodester API reports the
+ // process is still running, but actually the service is unavailable.
+ // See jaydeepw reported issue: https://github.com/roskoff/nodesterappswatcher/issues/2
+ $.ajax({
+ type: 'GET',
+ url: 'http://'+app.name+'.nodester.com/',
+ success: function(data, status, xhr){
+ var appRunning = app.running === "true" && xhr.status !== "503";
+ appRow(appsList, app.name, appRunning);
+ },
+ error: function(xhr, err){
+ appRow(appsList, app.name, 'false');
+ }
+ });
+ })
+}
+
+function appRow(list, name, status){
+ list.append(
+ '<div class="span12">' +
+ '<div class="row-fluid">' +
+ '<div class="span6"><a href="http://'+name+'.nodester.com" target="_blank">'+name+'</a></div>' +
+ '<div class="span6"><img id="img_'+name+'" width="24" src="/img/rocket-running-'+status+'.png"></div>' +
+ '</div>' +
+ '</div>');
+ var s = status === 'true' ? "running! \\m/" : "down :(";
+ $("#img_"+name).tooltip({"title":"App is " + s, "placement":"right"});
+ console.log(name+' - '+status);
}
function renderStatus(data) {
+ console.log('renderStatus');
var serverStatus = $("#serverStatus");
var statusLabel = data.status === "up" ? "success" : "important";
serverStatus.empty();

3 comments on commit cbcd4e5

@jaydeepw

wow! we have the handle to XHR here.
I will also add a check for 401 to see if some user activity has deleted the
passwords in localStorage.

btw, thanks for the update.
@roskoff
Owner

Great! Just do a PM when you finish so I can take a look a it, then we can release an update to the Web Store.

@jaydeepw

It will take me sometime though, I think we should make a release with recently added chages
in it.

Please sign in to comment.
Something went wrong with that request. Please try again.