Skip to content
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

Internal Changes #827

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
28 changes: 28 additions & 0 deletions plugin/trace_viewer/tf_trace_viewer/tf-trace-viewer.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@
overflow-wrap: anywhere;
}

a.button {
padding: 1px 6px;
border: 1px outset buttonborder;
border-radius: 3px;
color: buttontext;
background-color: buttonface;
text-decoration: none;
}
</style>

<div class="no-webcomponents-container hidden">
Expand Down Expand Up @@ -288,6 +296,7 @@
_replaceModel: {type: Boolean, value: true},
_hosts: {type: Array, value: []},
_showFilterForm: {type: Boolean, value: true},
_enableTrimmedSessionCreation: {type: Boolean, value: false},
},

ready: function() {
Expand Down Expand Up @@ -348,6 +357,9 @@
this._resolution = Number(value);
} else if (key === 'enable_filter') {
this._showFilterForm = !(value === 'false');
} else if (key === 'enable_trim') {
console.log('1111 setting enable trim to true...')
this._enableTrimmedSessionCreation = true;
}
}.bind(this));

Expand Down Expand Up @@ -430,6 +442,19 @@
}
},

createTrimmedSessionButton: function(event) {
// Contract: using start and duration field in the event object
const startTimeNs = Math.round(event.start * 10**6);
const endTimeNs = Math.round(startTimeNs + event.duration * 10**6);
// Constract: example traceDataUrl: /trace_viewer.json?session_id=narges-8993794330573677829&hosts=uybui3
const traceViewerLink = new URL(window.location.origin + this.traceDataUrl);
const host = traceViewerLink.searchParams.get('hosts').split(',')[0];
const trimmedSessionLink = new URL(`${window.top.location.origin}/trimmed_session?session_id=${this._sessionId}&host=${host}&range_start_ns=${startTimeNs}&range_end_ns=${endTimeNs}`);
const trimmedSessionCreationLinkElement = document.createElement('div');
trimmedSessionCreationLinkElement.innerHTML = `Create session trimmed on ${event.title}: <a href="${trimmedSessionLink.href}" target="_blank" class="button">Create</a>`;
this._eventDetails.appendChild(trimmedSessionCreationLinkElement);
},

createCrossToolLink: function(toolName, toolLabel, params, text) {
const toolLink =
new URL(`${window.location.origin}/${toolName}/${this._sessionId}`);
Expand Down Expand Up @@ -580,6 +605,9 @@
event.args['group_id'];
this._eventDetails.appendChild(traceViewerStepLinkElement);
}
if (this._sessionId && this._enableTrimmedSessionCreation) {
this.createTrimmedSessionButton(event);
}
}
},

Expand Down
Loading