Skip to content

Commit 4706757

Browse files
Profiler Teamcopybara-github
Profiler Team
authored andcommitted
Added a expand all/collapse all button to xprof trace viewer
This will save the user from manually expanding or collapsing every track. PiperOrigin-RevId: 708410517
1 parent 12e5c48 commit 4706757

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

plugin/trace_viewer/tf_trace_viewer/tf-trace-viewer.html

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,9 @@
290290
}
291291
#view_console_button.right-controls-button,
292292
#backend_toggle_button,
293-
#button.right-controls-button {
293+
#button.right-controls-button,
294+
#expand_all_button,
295+
#collapse_all_button{
294296
height: 36px;
295297
background-color: #f8f8f8;
296298
border: #f8f8f8 solid 0.5px;
@@ -308,6 +310,18 @@
308310
background-color: white;
309311
border: #dadce0 solid 0.5px;
310312
}
313+
#expand_collapse_all_text_bar {
314+
height: 36px;
315+
margin-left: 2px;
316+
align-items: center;
317+
text-align: center;
318+
padding-left: 25px;
319+
padding-right: 5px;
320+
padding-top: 2px;
321+
display: flex;
322+
justify-content: center;
323+
font-size: 14px;
324+
}
311325
#dialog.right-controls-dialog {
312326
padding:0px;
313327
min-width:150px;
@@ -1286,6 +1300,39 @@
12861300
}
12871301
},
12881302

1303+
// Expand or collapse all processes thread tracks
1304+
_expandOrCollapseAll: function(shouldExpand) {
1305+
const processes = document.getElementsByClassName('process-track-base');
1306+
for(let i = 0; i < processes.length; ++i)
1307+
{
1308+
processes[i].expanded = shouldExpand;
1309+
}
1310+
},
1311+
1312+
_addExpandAndCollapseAllButtons: function() {
1313+
//Add text bar next to buttons
1314+
const textBar = document.createElement('div');
1315+
textBar.textContent = 'Processes:';
1316+
textBar.setAttribute('id', 'expand_collapse_all_text_bar');
1317+
1318+
var expandAllButton = document.createElement('tr-ui-b-toolbar-button');
1319+
expandAllButton.textContent = 'Expand All';
1320+
1321+
var collapseAllButton = document.createElement('tr-ui-b-toolbar-button');
1322+
collapseAllButton.textContent = 'Collapse All';
1323+
1324+
expandAllButton.setAttribute('id', 'expand_all_button');
1325+
collapseAllButton.setAttribute('id', 'collapse_all_button');
1326+
1327+
// Add event listener to buttons
1328+
expandAllButton.addEventListener('click', () => this._expandOrCollapseAll(true));
1329+
collapseAllButton.addEventListener('click', () => this._expandOrCollapseAll(false));
1330+
// Append buttons to the DOM (inside the same parent element)
1331+
this._traceViewer.leftControls.appendChild(textBar);
1332+
this._traceViewer.leftControls.appendChild(expandAllButton);
1333+
this._traceViewer.leftControls.appendChild(collapseAllButton);
1334+
},
1335+
12891336
// Overwrite and fine tune the inherited catapult/tracing UI
12901337
_adjustUI: function() {
12911338
// 1. Adjust styles of the leftControl and its children
@@ -1294,6 +1341,9 @@
12941341
const searchBar = document.getElementById('view_find_control');
12951342
Polymer.dom(this._traceViewer.leftControls).appendChild(searchBar);
12961343
const searchInput = document.getElementById('filter');
1344+
1345+
this._addExpandAndCollapseAllButtons();
1346+
12971347
searchInput.placeholder = 'Find Events...';
12981348

12991349
// 2. Adjust styles of the rightControl and its children

0 commit comments

Comments
 (0)