feature #21007 [WebProfilerBundle] Improve AJAX toolbar panel (ro0NL)

This PR was squashed before being merged into the 3.3-dev branch (closes #21007).

Discussion
----------

[WebProfilerBundle] Improve AJAX toolbar panel

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!--highly recommended for new features-->

Before

![image](https://cloud.githubusercontent.com/assets/1047696/21394974/072b3570-c79b-11e6-8104-23e9be365b0b.png)

![image](https://cloud.githubusercontent.com/assets/1047696/21383263/1dc484fc-c765-11e6-84e8-7133d67da324.png)

After

![image](https://cloud.githubusercontent.com/assets/1047696/21394997/1a508cb8-c79b-11e6-87de-962ac41c9022.png)

![image](https://cloud.githubusercontent.com/assets/1047696/21383308/53b4f196-c765-11e6-8993-2645f342c7e9.png)

Commits
-------

afbcaa7a32 [WebProfilerBundle] Improve AJAX toolbar panel
This commit is contained in:
Fabien Potencier 2017-03-22 11:29:13 -07:00
commit 6327b4161d
3 changed files with 10 additions and 8 deletions

View File

@ -3,7 +3,7 @@
{% block toolbar %}
{% set icon %}
{{ include('@WebProfiler/Icon/ajax.svg') }}
<span class="sf-toolbar-value sf-toolbar-ajax-requests">0</span>
<span class="sf-toolbar-value sf-toolbar-ajax-request-counter">0</span>
{% endset %}
{% set text %}

View File

@ -88,16 +88,15 @@
var successStreak = 4;
var pendingRequests = 0;
var renderAjaxRequests = function() {
var requestCounter = document.querySelector('.sf-toolbar-ajax-requests');
var requestCounter = document.querySelector('.sf-toolbar-ajax-request-counter');
if (!requestCounter) {
return;
}
requestCounter.textContent = requestStack.length;
requestCounter.className = 'sf-toolbar-ajax-requests sf-toolbar-value';
var infoSpan = document.querySelector(".sf-toolbar-ajax-info");
if (infoSpan) {
infoSpan.textContent = requestStack.length + ' AJAX request' + (requestStack.length > 1 ? 's' : '');
infoSpan.textContent = requestStack.length + ' AJAX request' + (requestStack.length !== 1 ? 's' : '');
}
var ajaxToolbarPanel = document.querySelector('.sf-toolbar-block-ajax');
@ -138,7 +137,7 @@
var statusCodeCell = document.createElement('td');
var statusCode = document.createElement('span');
statusCode.textContent = '-';
statusCode.textContent = 'n/a';
statusCodeCell.appendChild(statusCode);
row.appendChild(statusCodeCell);
@ -157,7 +156,7 @@
var durationCell = document.createElement('td');
durationCell.className = 'sf-ajax-request-duration';
durationCell.textContent = '-';
durationCell.textContent = 'n/a';
row.appendChild(durationCell);
var profilerCell = document.createElement('td');
@ -199,6 +198,8 @@
statusCodeElem.setAttribute('class', 'sf-toolbar-status sf-toolbar-status-red');
}
statusCodeElem.textContent = request.statusCode;
} else {
statusCodeElem.setAttribute('class', 'sf-toolbar-status sf-toolbar-status-red');
}
if (request.duration) {
@ -271,6 +272,7 @@
finishAjaxRequest(idx);
}, function (e){
stackElement.error = true;
finishAjaxRequest(idx);
});
startAjaxRequest(idx);
}
@ -498,7 +500,6 @@
Sfjs.addEventListener(window, 'load', function() {
Sfjs.createTabs();
Sfjs.createToggles();
Sfjs.renderAjaxRequests();
});
/*]]>*/</script>

View File

@ -91,7 +91,8 @@
}
Sfjs.setPreference('toolbar/displayState', 'block');
})
});
Sfjs.renderAjaxRequests();
},
function(xhr) {
if (xhr.status !== 0) {