1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-01-17 05:18:32 +01:00

Combine dropdown with dataset handler

This commit is contained in:
Barry vd. Heuvel 2024-04-01 10:04:09 +02:00
parent 5a9481d667
commit 66ad21c0b1
5 changed files with 36 additions and 30 deletions

View File

@ -10,6 +10,7 @@ use DebugBar\StandardDebugBar;
$debugbar = new StandardDebugBar(); $debugbar = new StandardDebugBar();
$debugbarRenderer = $debugbar->getJavascriptRenderer() $debugbarRenderer = $debugbar->getJavascriptRenderer()
->setBaseUrl('../src/DebugBar/Resources') ->setBaseUrl('../src/DebugBar/Resources')
->setAjaxHandlerEnableTab(true)
->setEnableJqueryNoConflict(false); ->setEnableJqueryNoConflict(false);
// //
@ -29,9 +30,8 @@ function render_demo_page(Closure $callback = null)
<script type="text/javascript"> <script type="text/javascript">
$(function() { $(function() {
$('.ajax').click(function() { $('.ajax').click(function() {
var container = $(this).parent().html('...');
$.get(this.href, function(data) { $.get(this.href, function(data) {
container.html(data); $('#ajax-result').html(data);
}); });
return false; return false;
}); });

View File

@ -31,6 +31,7 @@ render_demo_page(function() {
<li><a href="ajax.php" class="ajax">load ajax content</a></li> <li><a href="ajax.php" class="ajax">load ajax content</a></li>
<li><a href="ajax_exception.php" class="ajax">load ajax content with exception</a></li> <li><a href="ajax_exception.php" class="ajax">load ajax content with exception</a></li>
</ul> </ul>
<div id="ajax-result"></div>
<h2>IFRAMES</h2> <h2>IFRAMES</h2>
<ul> <ul>
<li><a href="iframes/index.php">load through iframes</a></li> <li><a href="iframes/index.php">load through iframes</a></li>

View File

@ -318,12 +318,11 @@ div.phpdebugbar-mini-design a.phpdebugbar-tab {
/* -------------------------------------- */ /* -------------------------------------- */
.phpdebugbar-tab-history .phpdebugbar-text { a.phpdebugbar-tab.phpdebugbar-tab-history .phpdebugbar-text {
display: inline-flex; display: none;
max-width: 200px; }
overflow: hidden; a.phpdebugbar-tab.phpdebugbar-tab-history i {
text-overflow: ellipsis; display:inline-block;
white-space: nowrap;
} }
.phpdebugbar-widgets-dataset-history table { .phpdebugbar-widgets-dataset-history table {
width: 100%; width: 100%;

View File

@ -548,8 +548,7 @@ if (typeof(PhpDebugBar) == 'undefined') {
this.$datasets = $('<select />').addClass(csscls('datasets-switcher')).attr('name', 'datasets-switcher') this.$datasets = $('<select />').addClass(csscls('datasets-switcher')).attr('name', 'datasets-switcher')
.appendTo(this.$headerRight); .appendTo(this.$headerRight);
this.$datasets.change(function() { this.$datasets.change(function() {
self.dataChangeHandler(self.datasets[this.value]); self.showDataSet(this.value);
self.showTab();
}); });
}, },
@ -948,21 +947,23 @@ if (typeof(PhpDebugBar) == 'undefined') {
var label = this.datesetTitleFormater.format(id, this.datasets[id], suffix, nb); var label = this.datesetTitleFormater.format(id, this.datasets[id], suffix, nb);
if (typeof(show) == 'undefined' || show) {
this.showDataSet(id, label);
}
if (this.datasetTab) { if (this.datasetTab) {
this.datasetTab.set('data', this.datasets); this.datasetTab.set('data', this.datasets);
this.datasetTab.set('badge', getObjectSize(this.datasets)); this.datasetTab.set('badge', getObjectSize(this.datasets));
this.datasetTab.$tab.show(); this.datasetTab.$tab.show();
} else { }
this.$datasets.append($('<option value="' + id + '">' + label + '</option>')); this.$datasets.append($('<option value="' + id + '">' + label + '</option>'));
if (this.$datasets.children().length > 1) { if (this.$datasets.children().length > 1) {
this.$datasets.show(); this.$datasets.show();
} }
if (typeof(show) == 'undefined' || show) {
this.showDataSet(id);
} }
this.resize();
return id; return id;
}, },
@ -1001,12 +1002,16 @@ if (typeof(PhpDebugBar) == 'undefined') {
* @this {DebugBar} * @this {DebugBar}
* @param {String} id * @param {String} id
*/ */
showDataSet: function(id, label) { showDataSet: function(id) {
this.dataChangeHandler(this.datasets[id]);
this.activeDatasetId = id; this.activeDatasetId = id;
this.dataChangeHandler(this.datasets[id]);
if (this.$datasets.val() !== id) {
this.$datasets.val(id);
}
if (this.datasetTab) { if (this.datasetTab) {
this.datasetTab.set('title', label); this.datasetTab.get('widget').set('id', id);
} }
}, },

View File

@ -667,6 +667,7 @@ if (typeof(PhpDebugBar) == 'undefined') {
} }
this.set(options); this.set(options);
this.set('autoshow', null); this.set('autoshow', null);
this.set('id', null);
this.set('sort', localStorage.getItem('debugbar-history-sort') || 'asc'); this.set('sort', localStorage.getItem('debugbar-history-sort') || 'asc');
this.$el.addClass(csscls('dataset-history')) this.$el.addClass(csscls('dataset-history'))
@ -724,7 +725,6 @@ if (typeof(PhpDebugBar) == 'undefined') {
.append($('<th>Date ↕</th>').css('width', '175px').click(function() { .append($('<th>Date ↕</th>').css('width', '175px').click(function() {
self.set('sort', self.get('sort') === 'asc' ? 'desc' : 'asc') self.set('sort', self.get('sort') === 'asc' ? 'desc' : 'asc')
localStorage.setItem('debugbar-history-sort', self.get('sort')) localStorage.setItem('debugbar-history-sort', self.get('sort'))
console.log('set sort', self.get('sort'))
})) }))
.append($('<th>Method</th>').css('width', '80px')) .append($('<th>Method</th>').css('width', '80px'))
.append($('<th>URL</th>')) .append($('<th>URL</th>'))
@ -749,7 +749,7 @@ if (typeof(PhpDebugBar) == 'undefined') {
}, },
render: function() { render: function() {
this.bindAttr(['data'], function() { this.bindAttr('data', function() {
if (this.get('autoshow') === null && this.get('debugbar').ajaxHandler) { if (this.get('autoshow') === null && this.get('debugbar').ajaxHandler) {
this.set('autoshow', this.get('debugbar').ajaxHandler.autoShow); this.set('autoshow', this.get('debugbar').ajaxHandler.autoShow);
} }
@ -766,18 +766,19 @@ if (typeof(PhpDebugBar) == 'undefined') {
} }
this.get('itemRenderer')(this, data); this.get('itemRenderer')(this, data);
// Switch active tab
this.$table.find('.' + csscls('active')).removeClass(csscls('active'));
this.$table.find('tr[data-id=' + this.get('debugbar').activeDatasetId+']').addClass(csscls('active'));
}); });
this.bindAttr(['itemRenderer', 'search', 'method', 'sort'], function() { this.bindAttr(['itemRenderer', 'search', 'method', 'sort'], function() {
this.renderDatasets(); this.renderDatasets();
}) })
this.bindAttr(['autoshow'], function() { this.bindAttr('autoshow', function() {
var autoshow = this.get('autoshow'); var autoshow = this.get('autoshow');
this.$autoshow.prop('checked', autoshow); this.$autoshow.prop('checked', autoshow);
}) })
this.bindAttr('id', function() {
var id = this.get('id');
this.$table.find('.' + csscls('active')).removeClass(csscls('active'));
this.$table.find('tr[data-id=' + id+']').addClass(csscls('active'));
})
}, },
/** /**