Skip to content

Commit

Permalink
fixed app status display
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevnz committed Mar 8, 2012
2 parents 72c4e31 + 86a78c0 commit a06c0ba
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
8 changes: 8 additions & 0 deletions public/javascripts/lib/backbone.validation.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 24 additions & 1 deletion public/javascripts/main.js
Expand Up @@ -7,12 +7,35 @@
// --------------------

var App = Backbone.Model.extend({
// actions: start, stop, show logs, show info, destroy
initialize: function() {
var appStatus = this._parseRunning(this.get('running'));
this.set({up: appStatus[0], status: appStatus[1]});
},

// The Nodester API exposes individual apps at /app, while the list of apps
// is at /apps
url: function() {
return '/api/apps/' + this.get('name');
},
// Turn 'running' attribute into more human-friendly status
_parseRunning: function(running) {
console.log(running);
switch(running) {
case 'true':
case true:
return [true, 'running'];
break;
case 'false':
case false :
return [false, 'stopped'];
break;
case undefined:
return [false, 'unknown'];
default:
var text = running.toString().split('-').join(' ').split('_').join(' ');
return [false, text];
break;
}
}
});

Expand Down
8 changes: 2 additions & 6 deletions public/stylesheets/style.css
Expand Up @@ -38,10 +38,6 @@ p { line-height:1.2em; padding:0.5em 0; }
text-align:center;
}

span.label {
display:block;
}

.input {
border:1px solid #ccc;
font-size:18px;
Expand Down Expand Up @@ -119,8 +115,8 @@ p#incomplete {
border-top: 1px solid #D8D8D8;
border-left: 1px solid #D8D8D8;
border-right: 1px solid #D8D8D8;
font-family: Monaco,"Courier New","DejaVu Sans Mono","Bitstream Vera Sans Mono",monospace;
font-size:12px;
/*font-family: Monaco,"Courier New","DejaVu Sans Mono","Bitstream Vera Sans Mono",monospace;*/
/*font-size: 14px;*/
margin: 0;
margin-bottom: 1em;
width:99%;
Expand Down
5 changes: 3 additions & 2 deletions views/frontend-templates.jade
Expand Up @@ -3,14 +3,15 @@ script(id="app-list-tmpl", type="text/html")
tr
th name
th port
th app-status
th status
th action
a#new-app.btn.btn-primary <i class="icon-plus icon-white"></i> Create a new app

script(id="app-tmpl", type="text/html")
td.name {{name}}
td.port {{port}}
td.status {{running}}
td.status <span class="label {{#up}}label-success{{/up}}
| {{^up}}label-important{{/up}}">{{status}}</span>
td.actions
a.start(href="/app") start
a.stop(href="/app") stop
Expand Down

0 comments on commit a06c0ba

Please sign in to comment.