Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2b4d365

Browse files
committed
[WebProfilerBundle] Add settings to have the profiler follow the browser.
Often during development, we load a page, check some informations in the profiler, see something wrong, fix, reload the page, reload the profiler.That mean that we often reload the profiler page.If we can use the 'latest' token it's ok, but if there is another controller called (for example a webmanifest), we either need to search for it or close the tab, then reopen a new tab.This change use the BroadcastChannel javascript api to broadcast to other tabs that a toolbar have loaded or that an ajax request have finished.The profiler page listen to this broadcast and show a toolbar with the new profiler page based on the token broadcasted.A new setting allow to choose if :- We don't want this behavior- We want to follow only the main requests where a toolbar is shown (default)- We also want to follow ajax call captured by the toolbar
1 parent13ab9eb commit2b4d365

File tree

8 files changed

+121
-1
lines changed

8 files changed

+121
-1
lines changed

‎src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CHANGELOG
55
---
66

77
* Set`XDEBUG_IGNORE` query parameter when sending toolbar XHR
8+
* Add settings to have the profiler follow the browser.
89

910
6.4
1011
---
Lines changed: 7 additions & 0 deletions
Loading
Lines changed: 6 additions & 0 deletions
Loading
Lines changed: 5 additions & 0 deletions
Loading

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@
1818
}, with_context=false) }}
1919
{%endif %}
2020
{%endblock %}
21+
22+
<divclass="status status-compact"id="status-browser-tracking">
23+
<spanclass="icon">{{source('@WebProfiler/Icon/settings-follow-main.svg') }}</span>
24+
25+
Browser is now at token <ahref="#"id="status-browser-tracking-link"></a> (<spanclass="help"id="status-browser-tracking-help"></span>).
26+
</div>
27+
28+
{%ifapp.request.query.has('reloaded') %}
29+
<divclass="status status-compact status-warning"id="status-browser-tracking-reload-warning">
30+
<spanclass="icon">{{source('@WebProfiler/Icon/settings-follow-main.svg') }}</span>
31+
32+
This page was reloaded to follow the browser.
33+
<ahref="#"diff-84bdbbc00a80f6a3151d87276c235af2f6b90d8ad63da4b648a8a09d980a9b8f-20-34-0" data-selected="false" role="gridcell" tabindex="-1" valign="top">
34+
</div>
35+
{%endif %}
2136
</div>
2237

2338
<divid="content">

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,6 +1396,10 @@ tr.status-warning td {
13961396
width: 100%;
13971397
}
13981398

1399+
#summary #status-browser-tracking {
1400+
display: none;
1401+
}
1402+
13991403
{# Sidebar
14001404
=========================================================================#}
14011405
#sidebar {

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/settings.html.twig

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,38 @@
250250
</p>
251251
</label>
252252
</div>
253+
254+
<h4>Follow Browser</h4>
255+
256+
<divclass="settings-group">
257+
<labelfor="settings-follow-nothing">
258+
<inputclass="config-option"type="radio"name="follow"value="nothing"id="settings-follow-nothing">
259+
<p>
260+
{{source('@WebProfiler/Icon/settings-follow-nothing.svg') }}
261+
<span>Don't follow</span>
262+
</p>
263+
</label>
264+
265+
<labelfor="settings-follow-main">
266+
<inputclass="config-option"type="radio"name="follow"value="main"id="settings-follow-main">
267+
<p>
268+
{{source('@WebProfiler/Icon/settings-follow-main.svg') }}
269+
<span>Follow main pages</span>
270+
</p>
271+
</label>
272+
273+
<labelfor="settings-follow-all">
274+
<inputclass="config-option"type="radio"name="follow"value="all"id="settings-follow-all">
275+
<p>
276+
{{source('@WebProfiler/Icon/settings-follow-all.svg') }}
277+
<span>Follow main pages and ajax</span>
278+
</p>
279+
</label>
280+
</div>
281+
<labelfor="settings-follow-without-prompt">
282+
<inputclass="config-option"type="checkbox"name="follow-without-prompt"value="on"id="settings-follow-without-prompt">
283+
<span>Follow without prompting</span>
284+
</label>
253285
</div>
254286
</div>
255287
</div>
@@ -260,7 +292,7 @@
260292
[...configOptions].forEach(option=> {
261293
option.addEventListener('change',function (event) {
262294
constoptionName=option.name;
263-
constoptionValue=option.value;
295+
constoptionValue=(option.type!=='checkbox'||option.checked)?option.value:'off';
264296
constsettingName='symfony/profiler/'+ optionName;
265297
constsettingValue= optionName+'-'+ optionValue;
266298
@@ -295,6 +327,8 @@
295327
openModalButton.addEventListener('click',function(event) {
296328
document.getElementById('settings-'+ (localStorage.getItem('symfony/profiler/theme')||'theme-auto')).checked='checked';
297329
document.getElementById('settings-'+ (localStorage.getItem('symfony/profiler/width')||'width-normal')).checked='checked';
330+
document.getElementById('settings-'+ (localStorage.getItem('symfony/profiler/follow')||'follow-main')).checked='checked';
331+
document.getElementById('settings-follow-without-prompt').checked=localStorage.getItem('symfony/profiler/follow-without-prompt')==='follow-without-prompt-on';
298332
299333
modalWindow.classList.toggle('visible');
300334
setTimeout(()=>closeModalButton.focus(),30);
@@ -312,5 +346,39 @@
312346
closeModal();
313347
}
314348
});
349+
350+
constreloadedBrowserPanel=document.getElementById('status-browser-tracking-reload-warning');
351+
if (reloadedBrowserPanel) {
352+
{# Request animation to wait until user have seen thescreen #}
353+
requestAnimationFrame(function(){
354+
setTimeout(()=>reloadedBrowserPanel.style.display='none',10_000);
355+
});
356+
}
357+
358+
constfollowBrowserPanel=document.getElementById('status-browser-tracking');
359+
constfollowBrowserHelp=document.getElementById('status-browser-tracking-help');
360+
constfollowBrowserLink=document.getElementById('status-browser-tracking-link');
361+
(newBroadcastChannel('symfony_profiler')).addEventListener('message',function ({data}) {
362+
let types= [];
363+
switch (localStorage.getItem('symfony/profiler/follow')||"follow-main") {
364+
case"follow-nothing":return;
365+
case"follow-main": types=['main'];break;
366+
case"follow-all": types=['main','ajax'];break;
367+
}
368+
if (types.includes(data.type)) {
369+
if (localStorage.getItem('symfony/profiler/follow-without-prompt')==='follow-without-prompt-on') {
370+
consthrefSuffix=!document.location.search.includes("reloaded=1")? (document.location.search?"&":"?")+"reloaded=1":"";
371+
372+
document.location.href='{{ url("_profiler_home")|escape('js') }}'+data.token+document.location.search+ hrefSuffix;
373+
return;
374+
}
375+
376+
followBrowserPanel.style.display='block';
377+
followBrowserLink.href='{{ url("_profiler_home")|escape('js') }}'+data.token+document.location.search;
378+
followBrowserLink.innerText=data.token;
379+
followBrowserHelp.innerText=data.help;
380+
setTimeout(()=>followBrowserLink.focus(),30);
381+
}
382+
});
315383
})();
316384
</script>

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@
248248
}
249249
}
250250
}
251+
elseif(request.profile) {
252+
broadCastToken(request.profile,"ajax",request.url);
253+
}
251254
252255
pendingRequests--;
253256
var row=request.DOMNode;
@@ -396,6 +399,16 @@
396399
}
397400
{% endif%}
398401
402+
functionbroadCastToken(token,type,help) {
403+
if (!window.hasOwnProperty('BroadcastChannel'))return;
404+
405+
(newBroadcastChannel('symfony_profiler')).postMessage({
406+
token: token,
407+
type: type,
408+
help: help
409+
});
410+
}
411+
399412
return {
400413
hasClass: hasClass,
401414
@@ -510,6 +523,7 @@
510523
511524
setPreference('toolbar/displayState','block');
512525
});
526+
broadCastToken(token,'main', (document.getElementById('sfToolbarMainContent-'+ token).querySelector(".sf-toolbar-block-request .sf-toolbar-label")?.innerText??"")+ (document.getElementById('sfToolbarMainContent-'+ token).querySelector(".sf-toolbar-block-request .sf-toolbar-info-piece-additional")?.innerText??""));
513527
},
514528
515529
loadToolbar:function(token,newToken) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp