Skip to content

Commit 5e5d483

Browse files
committed
Redo panel selector columns as a table to fix width/alignment issues with large time/size values.
Also remove border radius from console panel stuff.
1 parent 0a5f938 commit 5e5d483

File tree

4 files changed

+118
-91
lines changed

4 files changed

+118
-91
lines changed

TracyDebugger.module.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static function getModuleInfo() {
2727
'summary' => __('Tracy debugger from Nette with many PW specific custom tools.', __FILE__),
2828
'author' => 'Adrian Jones',
2929
'href' => 'https://processwire.com/talk/forum/58-tracy-debugger/',
30-
'version' => '4.26.75',
30+
'version' => '4.26.76',
3131
'autoload' => 100000, // in PW 3.0.114+ higher numbers are loaded first - we want Tracy first
3232
'singular' => true,
3333
'requires' => 'ProcessWire>=2.7.2, PHP>=5.4.4',

panels/ConsolePanel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,7 @@ function loadFAIfNotAlreadyLoaded() {
16141614
$out .= '
16151615
<div style="margin-bottom: 7px">
16161616
<span style="display: inline-block; padding: 0 10px 5px 0">
1617-
<input id="reloadSnippet" title="Reload current snippet from disk" class="disabledButton" style="font-family: FontAwesome !important; padding: 3px 8px !important; border-radius: 3px !important;" type="submit" onclick="tracyConsole.reloadSnippet()" value="&#xf021" disabled="true" />&nbsp;&nbsp;
1617+
<input id="reloadSnippet" title="Reload current snippet from disk" class="disabledButton" style="font-family: FontAwesome !important; padding: 3px 8px !important;" type="submit" onclick="tracyConsole.reloadSnippet()" value="&#xf021" disabled="true" />&nbsp;&nbsp;
16181618
<input style="font-family: FontAwesome !important" title="Go back (ALT + PageUp)" id="historyBack" class="disabledButton" disabled="true" type="submit" onclick="tracyConsole.loadHistory(\'back\')" value="&#xf060;" />&nbsp;
16191619
<input style="font-family: FontAwesome !important" title="Go forward (ALT + PageDown)" id="historyForward" class="disabledButton" disabled="true" type="submit" onclick="tracyConsole.loadHistory(\'forward\')" value="&#xf061;" />&nbsp;
16201620
</span>
@@ -1641,7 +1641,7 @@ function loadFAIfNotAlreadyLoaded() {
16411641

16421642
$out .= '
16431643
<span style="display:inline-block; padding-right: 5px;">
1644-
<input title="Clear results" type="submit" class="clearResults" style="border-radius: 3px !important; padding: 3px 5px !important" onclick="tracyConsole.clearResults()" value="&#10006; Clear results" />
1644+
<input title="Clear results" type="submit" class="clearResults" style="padding: 3px 5px !important" onclick="tracyConsole.clearResults()" value="&#10006; Clear results" />
16451645
<select name="includeCode" style="height: 25px !important" title="When to execute code" onchange="tracyConsole.tracyIncludeCode(this)" />
16461646
<option value="off"' . (!$this->tracyIncludeCode || $this->tracyIncludeCode['when'] === 'off' ? ' selected' : '') . '>@ Run</option>
16471647
<option value="init"' . ($this->tracyIncludeCode && $this->tracyIncludeCode['when'] === 'init' ? ' selected' : '') . '>@ Init</option>

panels/PanelSelectorPanel.php

Lines changed: 114 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,14 @@ public function getTab() {
3737
<path d="M320.83,140.434l-1.759-0.627l-6.87-16.399l0.745-1.685c20.812-47.201,19.377-48.609,15.925-52.031L301.11,42.61 c-1.135-1.126-3.128-1.918-4.846-1.918c-1.562,0-6.293,0-47.294,18.57L247.326,60l-16.916-6.812l-0.679-1.684 C210.45,3.762,208.475,3.762,203.677,3.762h-39.205c-4.78,0-6.957,0-24.836,47.825l-0.673,1.741l-16.828,6.86l-1.609-0.669 C92.774,47.819,76.57,41.886,72.346,41.886c-1.714,0-3.714,0.769-4.854,1.892l-27.787,27.16 c-3.525,3.477-4.987,4.933,16.915,51.149l0.805,1.714l-6.881,16.381l-1.684,0.651C0,159.715,0,161.556,0,166.474v38.418 c0,4.931,0,6.979,48.957,24.524l1.75,0.618l6.882,16.333l-0.739,1.669c-20.812,47.223-19.492,48.501-15.949,52.025L68.62,327.18 c1.162,1.117,3.173,1.915,4.888,1.915c1.552,0,6.272,0,47.3-18.561l1.643-0.769l16.927,6.846l0.658,1.693 c19.293,47.726,21.275,47.726,26.076,47.726h39.217c4.924,0,6.966,0,24.859-47.857l0.667-1.742l16.855-6.814l1.604,0.654 c27.729,11.733,43.925,17.654,48.122,17.654c1.699,0,3.717-0.745,4.876-1.893l27.832-27.219 c3.501-3.495,4.96-4.924-16.981-51.096l-0.816-1.734l6.869-16.31l1.64-0.643c48.938-18.981,48.938-20.831,48.938-25.755v-38.395 C369.793,159.95,369.793,157.914,320.83,140.434z M184.896,247.203c-35.038,0-63.542-27.959-63.542-62.3 c0-34.342,28.505-62.264,63.542-62.264c35.023,0,63.522,27.928,63.522,62.264C248.419,219.238,219.92,247.203,184.896,247.203z" fill="'.($this->wire('input')->cookie->tracyGuestDumps ? \TracyDebugger::COLOR_WARN : \TracyDebugger::COLOR_NORMAL).'"/>
3838
</svg>';
3939

40-
4140
return '
4241
<span title="Panel Selector">
4342
' . $this->icon . (\TracyDebugger::getDataValue('showPanelLabels') ? '&nbsp;Panel Selector' : '') . '
4443
</span>
4544
';
4645
}
4746

48-
4947
protected function isOnce($name, $defaultPanels) {
50-
5148
$masterPanels = empty(\TracyDebugger::$stickyPanels) ? $defaultPanels : \TracyDebugger::$stickyPanels;
5249

5350
if(empty(\TracyDebugger::$oncePanels)) {
@@ -64,6 +61,65 @@ protected function isOnce($name, $defaultPanels) {
6461
}
6562
}
6663

64+
private function renderPanelCell($panel, $defaultPanels, $showPanels, $onceIcon) {
65+
if(!$panel) {
66+
return '<td></td>';
67+
}
68+
69+
$name = $panel['name'];
70+
$label = $panel['label'];
71+
$seconds = isset(\TracyDebugger::$panelGenerationTime[$name]['time']) ? \TracyDebugger::$panelGenerationTime[$name]['time'] : '';
72+
$size = isset(\TracyDebugger::$panelGenerationTime[$name]['size']) ? \TracyDebugger::human_filesize(\TracyDebugger::$panelGenerationTime[$name]['size']) : '';
73+
74+
$out = '<td style="vertical-align: top; padding: 4px 10px; white-space: nowrap;">';
75+
76+
// Use flexbox container for the entire cell content
77+
$out .= '<div style="display: flex; align-items: center; justify-content: space-between; width: 100%;">';
78+
79+
// Left side: label with controls
80+
$out .= '<label style="display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;">';
81+
82+
// once icon or spacer
83+
$out .= $this->isOnce($name, $defaultPanels) ? $onceIcon : '<span style="display:inline-block; width:15px;"></span>';
84+
85+
// settings link or spaces
86+
if (!empty(\TracyDebugger::$externalPanels) || !array_key_exists($name, \TracyDebugger::$externalPanels)) {
87+
if (array_key_exists($name, $this->panelSettingsLinks)) {
88+
$out .= \TracyDebugger::generatePanelSettingsLink($this->panelSettingsLinks[$name]);
89+
}
90+
else {
91+
$out .= str_repeat('&nbsp;', 6);
92+
}
93+
$out .= '<span style="font-size:16px; font-weight:600;">
94+
<a title="Panel Info" href="https://adrianbj.github.io/TracyDebugger/#/debug-bar?id=' . str_replace(' ', '-', strtolower($label)) . '" target="_blank">ℹ</a>
95+
</span>';
96+
}
97+
else {
98+
$out .= str_repeat('&nbsp;', 9);
99+
}
100+
101+
// checkbox input
102+
$out .= '<input type="checkbox" name="selectedPanels[]" ' .
103+
($name == 'panelSelector' || in_array($name, \TracyDebugger::getDataValue('nonToggleablePanels')) ? 'disabled="disabled"' : '') .
104+
' value="' . $name . '" ' . (in_array($name, $showPanels) ? 'checked="checked"' : '') . ' />';
105+
106+
// label text + asterisk if default
107+
$out .= '<span style="white-space: nowrap;">&nbsp;' . $label . (in_array($name, $defaultPanels) ? '&nbsp;<strong>*</strong>' : '') . '</span>';
108+
109+
$out .= '</label>';
110+
111+
// Right side: timing and size info (only if exists)
112+
if ($seconds) {
113+
$out .= '<span style="color: #999; font-size: 11px; white-space: nowrap; margin-left: 8px; flex-shrink: 0;">' . \TracyDebugger::formatTime($seconds);
114+
if ($size) $out .= ', ' . $size;
115+
$out .= '</span>';
116+
}
117+
118+
$out .= '</div>'; // Close flexbox container
119+
$out .= '</td>';
120+
121+
return $out;
122+
}
67123

68124
public function getPanel() {
69125

@@ -152,64 +208,65 @@ function getCookie(name) {
152208
<div class="tracy-inner">
153209
<fieldset>
154210
<legend>*Panels with asterisk are on by default</legend><br />';
155-
$defaultPanels = $this->wire('page')->template == "admin" ? \TracyDebugger::getDataValue('backendPanels') : \TracyDebugger::getDataValue('frontendPanels');
156-
$showPanels = \TracyDebugger::$showPanels;
157-
$out .= '<label><input type="checkbox" onchange="toggleAllTracyPanels(this)" ' . (count($showPanels) == count(\TracyDebugger::$allPanels) ? 'checked="checked"' : '') . ' /> Toggle All</label><br />';
158-
$out .= '<div style="-webkit-column-count: 2; -moz-column-count: 2; column-count: 2; -webkit-column-gap: 40px; -moz-column-gap: 40px; column-gap: 40px;">';
159-
foreach(\TracyDebugger::$allPanels as $name => $label) {
160-
161-
if(in_array($name, \TracyDebugger::$restrictedUserDisabledPanels)) continue;
162-
if(in_array($name, \TracyDebugger::$superUserOnlyPanels) && !\TracyDebugger::$allowedSuperuser && !\TracyDebugger::$validLocalUser && !\TracyDebugger::$validSwitchedUser) continue;
163-
// special additional check for adminer
164-
if($name == 'adminer' && !\TracyDebugger::$allowedSuperuser) continue;
165-
if($name == 'userSwitcher') {
166-
if(\TracyDebugger::getDataValue('userSwitchSession') != '') $userSwitchSession = \TracyDebugger::getDataValue('userSwitchSession');
167-
if(!\TracyDebugger::$allowedSuperuser && (!$this->wire('session')->tracyUserSwitcherId || (isset($userSwitchSession[$this->wire('session')->tracyUserSwitcherId]) && $userSwitchSession[$this->wire('session')->tracyUserSwitcherId] <= time()))) continue;
168-
}
169211

170-
$seconds = isset(\TracyDebugger::$panelGenerationTime[$name]['time']) ? \TracyDebugger::$panelGenerationTime[$name]['time'] : '';
171-
$size = isset(\TracyDebugger::$panelGenerationTime[$name]['size']) ? \TracyDebugger::human_filesize(\TracyDebugger::$panelGenerationTime[$name]['size']) : '';
172-
$out .= '
173-
<label style="'.($this->wire('page')->template == 'admin' && in_array($name, \TracyDebugger::$hideInAdmin) ? ' visibility:hidden;position: absolute; left: -999em;' : '').'">' .
174-
($this->isOnce($name, $defaultPanels) ? $onceIcon .'&nbsp;' : '<span style="display:inline-block;width:18px">&nbsp;</span>');
175-
if(!empty(\TracyDebugger::$externalPanels) || !array_key_exists($name, \TracyDebugger::$externalPanels)) {
176-
if(array_key_exists($name, $this->panelSettingsLinks)) {
177-
$out .= \TracyDebugger::generatePanelSettingsLink($this->panelSettingsLinks[$name]);
178-
}
179-
else {
180-
$out .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
181-
}
182-
$out .= '<span style="font-size:16px; font-weight:600"><a title="Panel Info" href="https://adrianbj.github.io/TracyDebugger/#/debug-bar?id='.str_replace(' ', '-', strtolower($label)).'" target="_blank">ℹ</a></span>';
183-
}
184-
else {
185-
$out .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
186-
}
187-
$out .= '&nbsp;<input type="checkbox" name="selectedPanels[]" ' . ($name == 'panelSelector' || in_array($name, \TracyDebugger::getDataValue('nonToggleablePanels')) ? 'disabled="disabled"' : '') . ' value="'.$name.'" ' . (in_array($name, $showPanels) ? 'checked="checked"' : '') . ' /> '
188-
. $label . (in_array($name, $defaultPanels) ? '&nbsp;<strong>*</strong>' : '') . ($seconds ? '<span style="color:#999999; font-size:11px; float:right; margin-left:20px">&nbsp;' . \TracyDebugger::formatTime($seconds) . ($size ? ', '.$size : '') . '</span>' : '') . '
189-
</label>';
190-
}
191-
$out .= '
192-
</div>
193-
<br />
194-
<span style="float:left">
195-
<input type="submit" onclick="changeTracyPanels(\'Once\')" value="Once" />&nbsp;
196-
<input type="submit" onclick="changeTracyPanels(\'Sticky\')" value="Sticky" />&nbsp;
197-
<input type="submit" onclick="resetTracyPanels()" value="Reset" />
198-
</span>
199-
<span style="float:right">';
200-
$out .= '<input type="submit" style="'.($this->wire('input')->cookie->tracyGuestDumps ? 'color:'.\TracyDebugger::COLOR_WARN : '').'" onclick="toggleGuestDumps()" value="' . ($this->wire('input')->cookie->tracyGuestDumps ? 'Disable' : 'Enable') .' Guest Dumps" />&nbsp;&nbsp;';
201-
if(!\TracyDebugger::getDataValue('strictMode')) {
202-
$out .= '<input type="submit" onclick="toggleStrictMode()" value="' . ($this->wire('input')->cookie->tracyStrictMode ? 'Disable' : 'Enable') .' Strict Mode" />&nbsp;&nbsp;';
203-
}
204-
if(\TracyDebugger::getDataValue('panelSelectorTracyTogglerButton')) {
205-
$out .= '<input type="submit" onclick="disableTracy()" value="Disable Tracy" />';
206-
}
207-
$out .= '
208-
</span>
212+
$defaultPanels = $this->wire('page')->template == "admin" ? \TracyDebugger::getDataValue('backendPanels') : \TracyDebugger::getDataValue('frontendPanels');
213+
$showPanels = \TracyDebugger::$showPanels;
214+
215+
$out .= '<label><input type="checkbox" onchange="toggleAllTracyPanels(this)" ' .
216+
(count($showPanels) == count(\TracyDebugger::$allPanels) ? 'checked="checked"' : '') . ' /> Toggle All</label><br />';
217+
218+
$out .= '<table style="border-collapse: collapse; width: max-content; min-width: 100%;">';
219+
220+
// split panels into two roughly equal halves
221+
$panels = [];
222+
foreach(\TracyDebugger::$allPanels as $name => $label) {
223+
224+
if(in_array($name, \TracyDebugger::$restrictedUserDisabledPanels)) continue;
225+
if(in_array($name, \TracyDebugger::$superUserOnlyPanels) && !\TracyDebugger::$allowedSuperuser && !\TracyDebugger::$validLocalUser && !\TracyDebugger::$validSwitchedUser) continue;
226+
if($name == 'adminer' && !\TracyDebugger::$allowedSuperuser) continue;
227+
if($name == 'userSwitcher') {
228+
if(\TracyDebugger::getDataValue('userSwitchSession') != '') $userSwitchSession = \TracyDebugger::getDataValue('userSwitchSession');
229+
if(!\TracyDebugger::$allowedSuperuser && (!$this->wire('session')->tracyUserSwitcherId || (isset($userSwitchSession[$this->wire('session')->tracyUserSwitcherId]) && $userSwitchSession[$this->wire('session')->tracyUserSwitcherId] <= time()))) continue;
230+
}
231+
$panels[] = ['name' => $name, 'label' => $label];
232+
}
233+
234+
$half = ceil(count($panels)/2);
235+
$leftPanels = array_slice($panels, 0, $half);
236+
$rightPanels = array_slice($panels, $half);
237+
238+
$maxRows = max(count($leftPanels), count($rightPanels));
239+
240+
for($i=0; $i < $maxRows; $i++) {
241+
$out .= '<tr>';
242+
$out .= $this->renderPanelCell(isset($leftPanels[$i]) ? $leftPanels[$i] : null, $defaultPanels, $showPanels, $onceIcon);
243+
$out .= $this->renderPanelCell(isset($rightPanels[$i]) ? $rightPanels[$i] : null, $defaultPanels, $showPanels, $onceIcon);
244+
$out .= '</tr>';
245+
}
246+
247+
$out .= '</table>';
248+
249+
$out .= '
250+
<br />
251+
<span style="float:left">
252+
<input type="submit" onclick="changeTracyPanels(\'Once\')" value="Once" />&nbsp;
253+
<input type="submit" onclick="changeTracyPanels(\'Sticky\')" value="Sticky" />&nbsp;
254+
<input type="submit" onclick="resetTracyPanels()" value="Reset" />
255+
</span>
256+
<span style="float:right">';
257+
$out .= '<input type="submit" style="' . ($this->wire('input')->cookie->tracyGuestDumps ? 'color:' . \TracyDebugger::COLOR_WARN : '') . '" onclick="toggleGuestDumps()" value="' . ($this->wire('input')->cookie->tracyGuestDumps ? 'Disable' : 'Enable') . ' Guest Dumps" />&nbsp;&nbsp;';
258+
if(!\TracyDebugger::getDataValue('strictMode')) {
259+
$out .= '<input type="submit" onclick="toggleStrictMode()" value="' . ($this->wire('input')->cookie->tracyStrictMode ? 'Disable' : 'Enable') . ' Strict Mode" />&nbsp;&nbsp;';
260+
}
261+
if(\TracyDebugger::getDataValue('panelSelectorTracyTogglerButton')) {
262+
$out .= '<input type="submit" onclick="disableTracy()" value="Disable Tracy" />';
263+
}
264+
$out .= '
265+
</span>
209266
210267
</fieldset>';
211268

212-
$out .= \TracyDebugger::generatePanelFooter('panelSelector', \Tracy\Debugger::timer('panelSelector'), strlen($out), 'panelSelectorPanel');
269+
$out .= \TracyDebugger::generatePanelFooter('panelSelector', \Tracy\Debugger::timer('panelSelector'), strlen($out), 'panelSelectorPanel');
213270

214271
$out .= '
215272
</div>';

styles/styles.css

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ body.tracyHidden:before {
327327
}
328328

329329
#tracy-debug tr:nth-child(2n) td {
330-
background: #e6ebf2 !important;
330+
background:rgba(0, 0, 0, 0.02) !important;
331331
}
332332

333333
#tracy-debug td {
@@ -403,9 +403,6 @@ table.apiExplorerTable th:nth-child(4) {
403403
margin: 0 !important;
404404
padding: 3px !important;
405405
border: 1px solid #D2D2D2 !important;
406-
-webkit-border-radius: 3px !important;
407-
-moz-border-radius: 3px !important;
408-
border-radius: 3px !important;
409406
cursor: pointer !important;
410407
text-transform: none !important;
411408
font: normal normal 13px/1.3 Arial, sans-serif;
@@ -568,20 +565,6 @@ td pre.tracy-dump {
568565
line-height: 1.75 !important;
569566
}
570567

571-
#tracy-debug-panel-PanelSelectorPanel fieldset div label {
572-
display: block !important;
573-
width: 300px !important;
574-
border-bottom: 1px solid #e4e4e4;
575-
-webkit-column-break-inside: avoid;
576-
page-break-inside: avoid;
577-
break-inside: avoid-column;
578-
}
579-
580-
#tracy-debug-panel-PanelSelectorPanel fieldset div label>span:last-child {
581-
position: relative;
582-
top: 5px;
583-
}
584-
585568
#tracy-debug-panel-PanelSelectorPanel fieldset div label:hover {
586569
background: #E2E9EF !important;
587570
}
@@ -636,7 +619,6 @@ ul.pw-info-links {
636619
margin: 0 !important;
637620
height: 29px !important;
638621
width: 100% !important;
639-
border-radius: 3px !important;
640622
-webkit-box-sizing: border-box;
641623
/* Safari/Chrome, other WebKit */
642624
-moz-box-sizing: border-box;
@@ -1024,18 +1006,6 @@ ul.pw-info-links {
10241006
margin-right: 7px !important;
10251007
}
10261008

1027-
#tracy-debug #runInjectButton {
1028-
border-radius: 3px !important;
1029-
}
1030-
1031-
#tracy-debug #historyBack {
1032-
border-radius: 3px 0 0 3px !important;
1033-
}
1034-
1035-
#tracy-debug #historyForward {
1036-
border-radius: 0 3px 3px 0 !important;
1037-
}
1038-
10391009
#tracy-debug #runInjectButton:hover,
10401010
#tracy-debug #historyBack:hover,
10411011
#tracy-debug #historyForward:hover {

0 commit comments

Comments
 (0)