mirror of
https://github.com/maximebf/php-debugbar.git
synced 2025-07-25 10:41:55 +02:00
Sort requests
This commit is contained in:
@@ -667,6 +667,7 @@ if (typeof(PhpDebugBar) == 'undefined') {
|
|||||||
}
|
}
|
||||||
this.set(options);
|
this.set(options);
|
||||||
this.set('autoshow', null);
|
this.set('autoshow', null);
|
||||||
|
this.set('sort', localStorage.getItem('debugbar-history-sort') || 'asc');
|
||||||
this.$el.addClass(csscls('dataset-history'))
|
this.$el.addClass(csscls('dataset-history'))
|
||||||
|
|
||||||
this.renderHead();
|
this.renderHead();
|
||||||
@@ -715,12 +716,20 @@ if (typeof(PhpDebugBar) == 'undefined') {
|
|||||||
|
|
||||||
|
|
||||||
this.$table = $('<tbody />');
|
this.$table = $('<tbody />');
|
||||||
$('<table><thead><tr>' +
|
|
||||||
'<th style="width: 20px;"></th>' +
|
$('<table/>')
|
||||||
'<th style="width: 175px;">Date</th>' +
|
.append($('<thead/>')
|
||||||
'<th style="width: 80px;">Method</th>' +
|
.append($('<tr/>')
|
||||||
'<th>URL</th><th width="40%">Data</th>' +
|
.append($('<th></th>').css('width', '20px'))
|
||||||
'</tr></thead></table>')
|
.append($('<th>Date ↕</th>').css('width', '175px').click(function() {
|
||||||
|
self.set('sort', self.get('sort') === 'asc' ? 'desc' : 'asc')
|
||||||
|
localStorage.setItem('debugbar-history-sort', self.get('sort'))
|
||||||
|
console.log('set sort', self.get('sort'))
|
||||||
|
}))
|
||||||
|
.append($('<th>Method</th>').css('width', '80px'))
|
||||||
|
.append($('<th>URL</th>'))
|
||||||
|
.append($('<th width="40%">Data</th>')))
|
||||||
|
)
|
||||||
.append(this.$table)
|
.append(this.$table)
|
||||||
.appendTo(this.$el);
|
.appendTo(this.$el);
|
||||||
|
|
||||||
@@ -762,7 +771,7 @@ if (typeof(PhpDebugBar) == 'undefined') {
|
|||||||
this.$table.find('.' + csscls('active')).removeClass(csscls('active'));
|
this.$table.find('.' + csscls('active')).removeClass(csscls('active'));
|
||||||
this.$table.find('tr[data-id=' + this.get('debugbar').activeDatasetId+']').addClass(csscls('active'));
|
this.$table.find('tr[data-id=' + this.get('debugbar').activeDatasetId+']').addClass(csscls('active'));
|
||||||
});
|
});
|
||||||
this.bindAttr(['itemRenderer', 'search', 'method'], function() {
|
this.bindAttr(['itemRenderer', 'search', 'method', 'sort'], function() {
|
||||||
this.renderDatasets();
|
this.renderDatasets();
|
||||||
})
|
})
|
||||||
this.bindAttr(['autoshow'], function() {
|
this.bindAttr(['autoshow'], function() {
|
||||||
@@ -780,9 +789,16 @@ if (typeof(PhpDebugBar) == 'undefined') {
|
|||||||
var meta = data.__meta;
|
var meta = data.__meta;
|
||||||
|
|
||||||
var $badges = $('<td />');
|
var $badges = $('<td />');
|
||||||
var tr = $('<tr />')
|
var tr = $('<tr />');
|
||||||
.appendTo(widget.$table)
|
console.log('sorting ' , widget.get('sort'));
|
||||||
.attr('data-id', meta['id'])
|
if (widget.get('sort') === 'asc') {
|
||||||
|
tr.appendTo(widget.$table);
|
||||||
|
} else {
|
||||||
|
console.log('prepend');
|
||||||
|
tr.prependTo(widget.$table);
|
||||||
|
}
|
||||||
|
|
||||||
|
tr.attr('data-id', meta['id'])
|
||||||
.append('<td>#' + meta['nb'] + '</td>')
|
.append('<td>#' + meta['nb'] + '</td>')
|
||||||
.append('<td>' + meta['datetime'] + '</td>')
|
.append('<td>' + meta['datetime'] + '</td>')
|
||||||
.append('<td>' + meta['method'] + '</td>')
|
.append('<td>' + meta['method'] + '</td>')
|
||||||
|
Reference in New Issue
Block a user