mirror of
https://github.com/maximebf/php-debugbar.git
synced 2025-01-16 21:08:34 +01:00
Filter collectors on MessagesWidget (#616)
This commit is contained in:
parent
ce817fa4ad
commit
bce78f928a
@ -81,7 +81,7 @@ div.phpdebugbar-widgets-messages {
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
div.phpdebugbar-widgets-messages ul.phpdebugbar-widgets-list {
|
div.phpdebugbar-widgets-messages ul.phpdebugbar-widgets-list {
|
||||||
padding-bottom: 20px;
|
padding-bottom: 45px;
|
||||||
}
|
}
|
||||||
div.phpdebugbar-widgets-messages li.phpdebugbar-widgets-list-item span.phpdebugbar-widgets-value:before {
|
div.phpdebugbar-widgets-messages li.phpdebugbar-widgets-list-item span.phpdebugbar-widgets-value:before {
|
||||||
font-family: PhpDebugbarFontAwesome;
|
font-family: PhpDebugbarFontAwesome;
|
||||||
|
@ -374,27 +374,43 @@ if (typeof(PhpDebugBar) == 'undefined') {
|
|||||||
.appendTo(this.$toolbar);
|
.appendTo(this.$toolbar);
|
||||||
|
|
||||||
this.bindAttr('data', function(data) {
|
this.bindAttr('data', function(data) {
|
||||||
this.set({ exclude: [], search: '' });
|
this.set({excludelabel: [], excludecollector: [], search: ''});
|
||||||
this.$toolbar.find(csscls('.filter')).remove();
|
this.$toolbar.find(csscls('.filter')).remove();
|
||||||
|
|
||||||
var filters = [], self = this;
|
var labels = [], collectors = [], self = this,
|
||||||
for (var i = 0; i < data.length; i++) {
|
createFilterItem = function (type, value) {
|
||||||
if (!data[i].label || $.inArray(data[i].label, filters) > -1) {
|
$('<a />')
|
||||||
continue;
|
.addClass(csscls('filter')).addClass(csscls(type))
|
||||||
|
.text(value).attr('rel', value)
|
||||||
|
.on('click', function() { self.onFilterClick(this, type); })
|
||||||
|
.appendTo(self.$toolbar)
|
||||||
|
};
|
||||||
|
|
||||||
|
data.forEach(function (item) {
|
||||||
|
if (!labels.includes(item.label || 'none')) {
|
||||||
|
labels.push(item.label || 'none');
|
||||||
}
|
}
|
||||||
filters.push(data[i].label);
|
|
||||||
$('<a />')
|
if (!collectors.includes(item.collector || 'none')) {
|
||||||
.addClass(csscls('filter'))
|
collectors.push(item.collector || 'none');
|
||||||
.text(data[i].label)
|
}
|
||||||
.attr('rel', data[i].label)
|
});
|
||||||
.on('click', function() { self.onFilterClick(this); })
|
|
||||||
.appendTo(this.$toolbar);
|
if (labels.length > 1) {
|
||||||
|
labels.forEach(label => createFilterItem('label', label));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (collectors.length === 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$('<a />').addClass(csscls('filter')).css('visibility', 'hidden').appendTo(self.$toolbar);
|
||||||
|
collectors.forEach(collector => createFilterItem('collector', collector));
|
||||||
});
|
});
|
||||||
|
|
||||||
this.bindAttr(['exclude', 'search'], function() {
|
this.bindAttr(['excludelabel', 'excludecollector', 'search'], function() {
|
||||||
var data = this.get('data'),
|
var excludelabel = this.get('excludelabel') || [],
|
||||||
exclude = this.get('exclude'),
|
excludecollector = this.get('excludecollector') || [],
|
||||||
search = this.get('search'),
|
search = this.get('search'),
|
||||||
caseless = false,
|
caseless = false,
|
||||||
fdata = [];
|
fdata = [];
|
||||||
@ -403,27 +419,31 @@ if (typeof(PhpDebugBar) == 'undefined') {
|
|||||||
caseless = true;
|
caseless = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < data.length; i++) {
|
this.get('data').forEach(function (item) {
|
||||||
var message = caseless ? data[i].message.toLowerCase() : data[i].message;
|
var message = caseless ? item.message.toLowerCase() : item.message;
|
||||||
|
|
||||||
if ((!data[i].label || $.inArray(data[i].label, exclude) === -1) && (!search || message.indexOf(search) > -1)) {
|
if (
|
||||||
fdata.push(data[i]);
|
!excludelabel.includes(item.label || undefined) &&
|
||||||
|
!excludecollector.includes(item.collector || undefined) &&
|
||||||
|
(!search || message.indexOf(search) > -1)
|
||||||
|
) {
|
||||||
|
fdata.push(item);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
this.$list.set('data', fdata);
|
this.$list.set('data', fdata);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onFilterClick: function(el) {
|
onFilterClick: function(el, type) {
|
||||||
$(el).toggleClass(csscls('excluded'));
|
$(el).toggleClass(csscls('excluded'));
|
||||||
|
|
||||||
var excludedLabels = [];
|
var excluded = [];
|
||||||
this.$toolbar.find(csscls('.filter') + csscls('.excluded')).each(function() {
|
this.$toolbar.find(csscls('.filter') + csscls('.excluded') + csscls('.' + type)).each(function() {
|
||||||
excludedLabels.push(this.rel);
|
excluded.push(this.rel === 'none' || !this.rel ? undefined : this.rel);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.set('exclude', excludedLabels);
|
this.set('exclude' + type, excluded);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user