Skip to content

[WebProfilerBundle] Add HTTP return code in the Ajax request list table #17540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

kucharovic
Copy link
Contributor

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #17518
License MIT
Doc PR -

Q | A
---|---
Bug fix? | no
New feature? | yes
BC breaks? | no
Deprecations? | no
Tests pass? | yes
Fixed tickets | symfony#17518
License | MIT
Doc PR | -
@javiereguiluz
Copy link
Member

@kucharovic I just tested your pull request and it works perfect! Thanks for working on this.

ajax_status_before

However, to make errors stand out more prominently, what do you think of using the sf-toolbar-status CSS classes that we use elsewhere in the toolbar. This way we could show the HTTP status like this:

ajax_status_after

If you like the idea, the code would be something like this:

var statusCodeCell = document.createElement('td');
var statusCode = document.createElement('span');
if (request.statusCode > 299) {
    statusCode.setAttribute('class', 'sf-toolbar-status sf-toolbar-status-red');
} else {
    statusCode.setAttribute('class', 'sf-toolbar-status');
}
statusCode.textContent = request.statusCode || '-';
statusCodeCell.appendChild(statusCode);
row.appendChild(statusCodeCell);

@kucharovic
Copy link
Contributor Author

@javiereguiluz it looks better. Are you sure, that redirects should be red?

@javiereguiluz
Copy link
Member

@kucharovic I trusted this comment from @Jean85 who said that in Ajax there are no redirections. We probably need more comments about this or some verification.

@stloyd
Copy link
Contributor

stloyd commented Jan 26, 2016

IMO it should be:

if (request.statusCode < 300) {
    statusCode.setAttribute('class', 'sf-toolbar-status sf-toolbar-status-green');
} else if (request.statusCode < 400) {
    statusCode.setAttribute('class', 'sf-toolbar-status sf-toolbar-status-yellow');
} else {
    statusCode.setAttribute('class', 'sf-toolbar-status sf-toolbar-status-red');
}

@javiereguiluz
Copy link
Member

@kucharovic anyway, to be completely safe, we could change if (request.statusCode > 299) by if (request.statusCode > 399) and this will always work no matter what.

@kucharovic
Copy link
Contributor Author

@javiereguiluz he's right. A XMLHttpRequest should either get the resource or be told why not.

@stloyd
Copy link
Contributor

stloyd commented Jan 26, 2016

Hmmm, then maybe:

if (request.statusCode < 400) {
    statusCode.setAttribute('class', 'sf-toolbar-status sf-toolbar-status-green');
} else if (request.statusCode < 500) {
    statusCode.setAttribute('class', 'sf-toolbar-status sf-toolbar-status-yellow');
} else {
    statusCode.setAttribute('class', 'sf-toolbar-status sf-toolbar-status-red');
}

@javiereguiluz
Copy link
Member

@stloyd I like your proposal ... except for the last comment. Showing 4xx errors in yellow is inconsistent with the current toolbar. 4xx and 5xx are treated as errors and showed in red.

@Jean85
Copy link
Contributor

Jean85 commented Jan 26, 2016

Yeah, I posted that comment because I stumbled on it.. I had an issue in my code, since I was trying to catch redirects with jQuery.ajax() and I was getting always 200, didn't understand why :D

I agree with @javiereguiluz , consistency with the rest of the toolbar is better.

@fabpot
Copy link
Member

fabpot commented Jan 26, 2016

👍

@stof
Copy link
Member

stof commented Jan 26, 2016

should we really put the 2xx in green or keep it in gray instead ? I think putting colors only on errors make them stand out more than if everything is colored

@javiereguiluz
Copy link
Member

For comparison:

Color on Errors

ajax_status_after

Color on Everything

ajax_status_after_colors

@fabpot
Copy link
Member

fabpot commented Jan 26, 2016

+1 for gray instead of green

@maidmaid
Copy link
Contributor

👍

@fabpot
Copy link
Member

fabpot commented Jan 27, 2016

Thank you @kucharovic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants