Skip to content

Allow to configure some options of the profiler interface #27678

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

Merged
merged 1 commit into from
Jul 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

{% if colors is not defined %}
{% set colors = {
'default': '#999',
'section': '#444',
'default': '#777',
'section': '#999',
'event_listener': '#00B8F5',
'template': '#66CC00',
'doctrine': '#FF6633',
Expand Down Expand Up @@ -220,6 +220,11 @@
return query('#collector-content h2').clientWidth;
}

function getCssVarValue(varName)
{
return getComputedStyle(document.querySelector('body')).getPropertyValue(varName);
}

/**
* Draw one canvas.
*
Expand Down Expand Up @@ -272,7 +277,11 @@
ctx.lineWidth = 0;

// For each event, draw a line.
ctx.strokeStyle = "#CCC";
ctx.strokeStyle = getCssVarValue('--table-border');

// set the background color of the canvas
ctx.fillStyle = getCssVarValue('--table-background');
ctx.fillRect(0, 0, canvas.width, canvas.height);

drawableEvents.forEach(function(event) {
event.periods.forEach(function(period) {
Expand Down Expand Up @@ -379,31 +388,31 @@
// For each event, draw the label.
mainEvents.forEach(function(event) {

ctx.fillStyle = "#444";
ctx.fillStyle = getCssVarValue('--color-text');
ctx.font = "12px sans-serif";
text = event.name;
ms = " " + (event.duration < 1 ? event.duration : parseInt(event.duration, 10)) + " ms / " + event.memory + " MB";
if (x + event.starttime * ratio + ctx.measureText(text + ms).width > width) {
ctx.textAlign = "end";
ctx.font = "10px sans-serif";
ctx.fillStyle = "#777";
ctx.fillStyle = getCssVarValue('--color-muted');
xc = x + event.endtime * ratio - 1;
ctx.fillText(ms, xc, h);

xc -= ctx.measureText(ms).width;
ctx.font = "12px sans-serif";
ctx.fillStyle = "#222";
ctx.fillStyle = getCssVarValue('--color-text');
ctx.fillText(text, xc, h);
} else {
ctx.textAlign = "start";
ctx.font = "13px sans-serif";
ctx.fillStyle = "#222";
ctx.fillStyle = getCssVarValue('--color-text');
xc = x + event.starttime * ratio + 1;
ctx.fillText(text, xc, h);

xc += ctx.measureText(text).width;
ctx.font = "11px sans-serif";
ctx.fillStyle = "#777";
ctx.fillStyle = getCssVarValue('--color-muted');
ctx.fillText(ms, xc, h);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
{% endblock %}
</head>
<body>
<script async>
document.body.classList.add(localStorage.getItem('symfony/profiler/theme'), localStorage.getItem('symfony/profiler/width'));
</script>

{% block body '' %}
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@
{% endfor %}
</ul>
{% endif %}

{{ include('@WebProfiler/Profiler/settings.html.twig') }}
</div>

<div id="collector-wrapper">
Expand All @@ -142,6 +144,6 @@
event.preventDefault();
Sfjs.toggleClass(document.getElementById('sidebar'), 'expanded');
})
}())
}());
</script>
{% endblock %}
Loading