Skip to content

Commit

Permalink
showing logs again
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Jul 7, 2011
1 parent 802db38 commit 0d07295
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 87 deletions.
131 changes: 60 additions & 71 deletions lib/http/public/javascripts/caustic.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,79 +246,68 @@ View.prototype.visitUL = function(el, name){
var self = this;
this.children = [];

this[name] = {
// TODO: move these out

/**
* Add `val` to this list.
*
* @param {String|jQuery|View} val
* @return {View} for chaining
* @api public
*/

add: function(val){
var li = $('<li>');
self.children.push(val);
el.append(li.append(val.el || val));
return this;
},

/**
* Return the list item `View`s as an array.
*
* @return {Array}
* @api public
*/

items: function(){
return self.children;
},

/**
* Return the list length.
*
* @return {Number}
* @api public
*/

length: function(){
return this.items().length;
},

/**
* Iterate the list `View`s, calling `fn(item, i)`.
*
* @param {Function} fn
* @return {View} for chaining
* @api public
*/

each: function(fn){
for (var i = 0, len = self.children.length; i < len; ++i) {
fn(self.children[i], i);
}
return this;
},

/**
* Map the list `View`s, calling `fn(item, i)`.
*
* @param {String|function} fn
* @return {Array}
* @api public
*/

map: function(fn){
var ret = []
, fn = callback(fn);

for (var i = 0, len = self.children.length; i < len; ++i) {
ret.push(fn(self.children[i], i));
}
this[name] = el;

// TODO: move these out

/**
* Add `val` to this list.
*
* @param {String|jQuery|View} val
* @return {View} for chaining
* @api public
*/

el.add = function(val){
var li = $('<li>');
self.children.push(val);
el.append(li.append(val.el || val));
return this;
};

/**
* Return the list item `View`s as an array.
*
* @return {Array}
* @api public
*/

return ret;
el.items = function(){
return self.children;
};

/**
* Iterate the list `View`s, calling `fn(item, i)`.
*
* @param {Function} fn
* @return {View} for chaining
* @api public
*/

el.each = function(fn){
for (var i = 0, len = self.children.length; i < len; ++i) {
fn(self.children[i], i);
}
return this;
};

/**
* Map the list `View`s, calling `fn(item, i)`.
*
* @param {String|function} fn
* @return {Array}
* @api public
*/

el.map = function(fn){
var ret = []
, fn = callback(fn);

for (var i = 0, len = self.children.length; i < len; ++i) {
ret.push(fn(self.children[i], i));
}

return ret;
};
};

Expand Down
26 changes: 13 additions & 13 deletions lib/http/public/javascripts/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ Job.prototype.render = function(isNew){
progress.size(canvas.width);
this._progress = progress;

// // initially hide the logs
view.log().hide();
// initially hide the logs
view.log.hide();

// populate title and id
view.el.attr('id', 'job-' + id);
Expand Down Expand Up @@ -203,7 +203,7 @@ Job.prototype.renderUpdate = function(){
this.renderTimestamp('failed_at');

// inactive
if ('inactive' == this.state) view.log().remove();
if ('inactive' == this.state) view.log.remove();

// completion
if ('complete' == this.state) {
Expand All @@ -224,16 +224,16 @@ Job.prototype.renderUpdate = function(){
// progress indicator
if (showProgress) this._progress.update(this.progress).draw(this.ctx);

// // logs
// if (this.showDetails) {
// request('GET', '/job/' + this.id + '/log', function(log){
// var ul = el.find('.log').show().find('ul');
// ul.find('li').remove();
// log.forEach(function(line){
// ul.append(o('<li>%s</li>', line));
// });
// });
// }
// logs
if (this.showDetails) {
request('GET', '/job/' + this.id + '/log', function(log){
var ul = view.log.show();
ul.find('li').remove();
log.forEach(function(line){
ul.append(o('<li>%s</li>', line));
});
});
}
};

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/http/public/stylesheets/job.styl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ bar(color)

// job log

.job .log ul
.job ul.log
reset-list()
margin: 5px
padding: 10px
Expand Down
4 changes: 2 additions & 2 deletions lib/http/views/_job.jade
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@
td.failed_at
.error
pre
.log
ul
ul.log

0 comments on commit 0d07295

Please sign in to comment.