Skip to content

Commit

Permalink
feature #21007 [WebProfilerBundle] Improve AJAX toolbar panel (ro0NL)
Browse files Browse the repository at this point in the history
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
-------

afbcaa7 [WebProfilerBundle] Improve AJAX toolbar panel
  • Loading branch information
fabpot committed Mar 22, 2017
2 parents d378947 + afbcaa7 commit 6327b41
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
Expand Up @@ -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 %}
Expand Down
Expand Up @@ -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');
Expand Down Expand Up @@ -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);
Expand All @@ -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');
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -271,6 +272,7 @@
finishAjaxRequest(idx);
}, function (e){
stackElement.error = true;
finishAjaxRequest(idx);
});
startAjaxRequest(idx);
}
Expand Down Expand Up @@ -498,7 +500,6 @@
Sfjs.addEventListener(window, 'load', function() {
Sfjs.createTabs();
Sfjs.createToggles();
Sfjs.renderAjaxRequests();
});
/*]]>*/</script>
Expand Up @@ -91,7 +91,8 @@
}
Sfjs.setPreference('toolbar/displayState', 'block');
})
});
Sfjs.renderAjaxRequests();
},
function(xhr) {
if (xhr.status !== 0) {
Expand Down

0 comments on commit 6327b41

Please sign in to comment.