8000 feature #31876 [WebProfilerBundle] Add clear button to ajax tab (Matts) · symfony/symfony@dc56389 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit dc56389

Browse files
committed
feature #31876 [WebProfilerBundle] Add clear button to ajax tab (Matts)
This PR was squashed before being merged into the 4.4 branch (closes #31876). Discussion ---------- [WebProfilerBundle] Add clear button to ajax tab | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #31839 | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> For pages that have been open for a long time, the profiler ajax tab can start filling up fast. In #31839 the request to allow the history to be cleared with one click. The reason why I did not align the button to the right, is because after looking at the other tabs. None of them had items that were aligned to the right. Moved the addEventListener ab 8000 ove the ajax tab logic to keep the code consistent. Ps. Please be nice, this is my first contribution 🍰 <!-- Replace this notice by a short README for your feature/bugfix. This will help people understand your PR and can be used as a start for the documentation. Additionally (see https://symfony.com/roadmap): - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against branch 4.4. - Legacy code removals go to the master branch. --> Commits ------- 6bff4db [WebProfilerBundle] Add clear button to ajax tab
2 parents a22eeb3 + 6bff4db commit dc56389

File tree

3 files changed

+28
-14
lines changed

3 files changed

+28
-14
lines changed

src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
CHANGELOG
22
=========
33

4+
4.4.0
5+
-----
6+
* Added button to clear the ajax request tab
7+
48
4.3.0
59
-----
610

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/ajax.html.twig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88

99
{% set text %}
1010
<div class="sf-toolbar-info-piece">
11-
<b class="sf-toolbar-ajax-info"></b>
11+
<span class="sf-toolbar-header">
12+
<b class="sf-toolbar-ajax-info"></b>
13+
<b class="sf-toolbar-action">(<a class="sf-toolbar-ajax-clear" href="javascript:void(0);">Clear</a>)</b>
14+
</span>
1215
</div>
1316
<div class="sf-toolbar-info-piece">
1417
<table class="sf-toolbar-ajax-requests">

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@
2424
2525
var profilerStorageKey = 'symfony/profiler/';
2626
27+
var addEventListener;
28+
29+
var el = document.createElement('div');
30+
if (!('addEventListener' in el)) {
31+
addEventListener = function (element, eventName, callback) {
32+
element.attachEvent('on' + eventName, callback);
33+
};
34+
} else {
35+
addEventListener = function (element, eventName, callback) {
36+
element.addEventListener(eventName, callback, false);
37+
};
38+
}
39+
2740
var request = function(url, onSuccess, onError, payload, options) {
2841
var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
2942
options = options || {};
@@ -118,6 +131,13 @@
118131
removeClass(ajaxToolbarPanel, 'sf-ajax-request-loading');
119132
removeClass(ajaxToolbarPanel, 'sf-toolbar-status-red');
120133
}
134+
135+
addEventListener(document.querySelector('.sf-toolbar-ajax-clear'), 'click', function() {
136+
requestStack = [];
137+
renderAjaxRequests();
138+
successStreak = 4;
139+
document.querySelector('.sf-toolbar-ajax-request-list').innerHTML = '';
140+
});
121141
};
122142
123143
var startAjaxRequest = function(index) {
@@ -255,19 +275,6 @@
255275
renderAjaxRequests();
256276
};
257277
258-
var addEventListener;
259-
260-
var el = document.createElement('div');
261-
if (!('addEventListener' in el)) {
262-
addEventListener = function (element, eventName, callback) {
263-
element.attachEvent('on' + eventName, callback);
264-
};
265-
} else {
266-
addEventListener = function (element, eventName, callback) {
267-
element.addEventListener(eventName, callback, false);
268-
};
269-
}
270-
271278
{% if excluded_ajax_paths is defined %}
272279
if (window.fetch && window.fetch.polyfill === undefined) {
273280
var oldFetch = window.fetch;

0 commit comments

Comments
 (0)
0