Make logs filterable
This commit is contained in:
1 parent
e06b4ccb3f
commit
3a4c191b11
2 files changed
+75
-24
No files matched your search
@@ -16,10 +16,14 @@
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 5px 10px;
|
padding: 5px 10px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page.log .nav li.select,
|
||||||
|
.page.log .nav li.clear {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page.log .nav li:hover:not(.active) {
|
.page.log .nav li:hover:not(.active, .filter) {
|
||||||
background: rgba(255, 255, 255, 0.1);
|
background: rgba(255, 255, 255, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,13 +55,12 @@
|
|||||||
line-height: 150%;
|
line-height: 150%;
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
font-family: Lucida Console, Monaco, Nimbus Mono L, monospace, serif;
|
font-family: Lucida Console, Monaco, Nimbus Mono L, monospace, serif;
|
||||||
|
color: #FFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page.log .container .error {
|
.page.log .container select {
|
||||||
color: #FFA4A4;
|
vertical-align: top;
|
||||||
white-space: pre-wrap;
|
|
||||||
}
|
}
|
||||||
.page.log .container .debug { color: lightgrey; }
|
|
||||||
|
|
||||||
.page.log .container .time {
|
.page.log .container .time {
|
||||||
clear: both;
|
clear: both;
|
||||||
@@ -68,10 +71,25 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page.log .container .time:last-child { display: none; }
|
.page.log [data-filter=INFO] .error,
|
||||||
|
.page.log [data-filter=INFO] .debug,
|
||||||
.page.log .container .time span {
|
.page.log [data-filter=ERROR] .debug,
|
||||||
float: right;
|
.page.log [data-filter=ERROR] .info,
|
||||||
width: 86%;
|
.page.log [data-filter=DEBUG] .info,
|
||||||
|
.page.log [data-filter=DEBUG] .error {
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.page.log .container .type {
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page.log .container .message {
|
||||||
|
float: right;
|
||||||
|
width: 86%;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page.log .container .error { color: #FFA4A4; }
|
||||||
|
.page.log .container .debug { opacity: .4; }
|
||||||
|
|
||||||
@@ -27,25 +27,46 @@ Page.Log = new Class({
|
|||||||
'nr': nr
|
'nr': nr
|
||||||
},
|
},
|
||||||
'onComplete': function(json){
|
'onComplete': function(json){
|
||||||
|
self.log.set('text', '');
|
||||||
self.log.adopt(self.createLogElements(json.log));
|
self.log.adopt(self.createLogElements(json.log));
|
||||||
self.log.removeClass('loading');
|
self.log.removeClass('loading');
|
||||||
|
|
||||||
new Fx.Scroll(window, {'duration': 0}).toBottom();
|
var nav = new Element('ul.nav', {
|
||||||
|
'events': {
|
||||||
|
'click:relay(li.select)': function(e, el){
|
||||||
|
self.getLogs(parseInt(el.get('text'))-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var nav = new Element('ul.nav').inject(self.log, 'top');
|
// Type selection
|
||||||
|
new Element('li.filter').grab(
|
||||||
|
new Element('select', {
|
||||||
|
'events': {
|
||||||
|
'change': function(){
|
||||||
|
var type_filter = this.getSelected()[0].get('value');
|
||||||
|
self.log.set('data-filter', type_filter);
|
||||||
|
self.scrollToBottom();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).adopt(
|
||||||
|
new Element('option', {'value': 'ALL', 'text': 'Show all logs'}),
|
||||||
|
new Element('option', {'value': 'INFO', 'text': 'Show only INFO'}),
|
||||||
|
new Element('option', {'value': 'DEBUG', 'text': 'Show only DEBUG'}),
|
||||||
|
new Element('option', {'value': 'ERROR', 'text': 'Show only ERROR'})
|
||||||
|
)
|
||||||
|
).inject(nav);
|
||||||
|
|
||||||
|
// Selections
|
||||||
for (var i = 0; i <= json.total; i++) {
|
for (var i = 0; i <= json.total; i++) {
|
||||||
new Element('li', {
|
new Element('li', {
|
||||||
'text': i+1,
|
'text': i+1,
|
||||||
'class': nr == i ? 'active': '',
|
'class': 'select ' + (nr == i ? 'active': '')
|
||||||
'events': {
|
|
||||||
'click': function(e){
|
|
||||||
self.getLogs(e.target.get('text')-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).inject(nav);
|
}).inject(nav);
|
||||||
}
|
}
|
||||||
|
|
||||||
new Element('li', {
|
// Clear button
|
||||||
|
new Element('li.clear', {
|
||||||
'text': 'clear',
|
'text': 'clear',
|
||||||
'events': {
|
'events': {
|
||||||
'click': function(){
|
'click': function(){
|
||||||
@@ -57,7 +78,12 @@ Page.Log = new Class({
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).inject(nav)
|
}).inject(nav);
|
||||||
|
|
||||||
|
// Add to page
|
||||||
|
nav.inject(self.log, 'top');
|
||||||
|
|
||||||
|
self.scrollToBottom();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -68,17 +94,24 @@ Page.Log = new Class({
|
|||||||
var elements = [];
|
var elements = [];
|
||||||
|
|
||||||
logs.each(function(log){
|
logs.each(function(log){
|
||||||
elements.include(new Element('div.time', {
|
elements.include(new Element('div', {
|
||||||
|
'class': 'time ' + log.type.toLowerCase(),
|
||||||
'text': log.time
|
'text': log.time
|
||||||
}).grab(
|
}).adopt(
|
||||||
new Element('span', {
|
new Element('span.type', {
|
||||||
'class': log.type.toLowerCase(),
|
'text': log.type
|
||||||
|
}),
|
||||||
|
new Element('span.message', {
|
||||||
'text': log.message
|
'text': log.message
|
||||||
})
|
})
|
||||||
))
|
))
|
||||||
});
|
});
|
||||||
|
|
||||||
return elements;
|
return elements;
|
||||||
|
},
|
||||||
|
|
||||||
|
scrollToBottom: function(){
|
||||||
|
new Fx.Scroll(window, {'duration': 0}).toBottom();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
Reference in new issue
Block a user