Add session templates to profiler (#2115)

* Initial support for handling available sessions

* Displaying sessions in drop down, send session name in start profiling request

* More support for starting existing sessions

* New session dialog and session templates in user files

* Create profiler dialog and session templates

* Preliminary session template changes

* Saving some changes

* Send session templates when creating sessions

* Saving changes

* UI Fixes for dialog

* Formatting fixes

* removing comments

* Fixing PR comments

* bumping toolsservice and dataprotocolclient versions

* Fixing starting existing sessions
This commit is contained in:
Madeline MacDonald
2018-08-03 15:24:50 -07:00
committed by GitHub
parent 2a650d4d74
commit 79269cdfd5
22 changed files with 780 additions and 261 deletions

View File

@@ -118,6 +118,8 @@ export class ProfilerEditor extends BaseEditor {
private _viewTemplateSelector: SelectBox;
private _viewTemplates: Array<IProfilerViewTemplate>;
private _sessionSelector: SelectBox;
private _sessionsList: Array<string>;
private _connectionInfoText: HTMLElement;
// Actions
@@ -126,6 +128,7 @@ export class ProfilerEditor extends BaseEditor {
private _pauseAction: Actions.ProfilerPause;
private _stopAction: Actions.ProfilerStop;
private _autoscrollAction: Actions.ProfilerAutoScroll;
private _createAction: Actions.ProfilerCreate;
private _collapsedPanelAction: Actions.ProfilerCollapsablePanelAction;
@@ -186,6 +189,8 @@ export class ProfilerEditor extends BaseEditor {
this._actionBar = new Taskbar(this._header, this._contextMenuService);
this._startAction = this._instantiationService.createInstance(Actions.ProfilerStart, Actions.ProfilerStart.ID, Actions.ProfilerStart.LABEL);
this._startAction.enabled = false;
this._createAction = this._instantiationService.createInstance(Actions.ProfilerCreate, Actions.ProfilerCreate.ID, Actions.ProfilerCreate.LABEL);
this._createAction.enabled = true;
this._stopAction = this._instantiationService.createInstance(Actions.ProfilerStop, Actions.ProfilerStop.ID, Actions.ProfilerStop.LABEL);
this._stopAction.enabled = false;
this._pauseAction = this._instantiationService.createInstance(Actions.ProfilerPause, Actions.ProfilerPause.ID, Actions.ProfilerPause.LABEL);
@@ -200,10 +205,22 @@ export class ProfilerEditor extends BaseEditor {
this.input.viewTemplate = this._viewTemplates.find(i => i.name === e.selected);
}
}));
let dropdownContainer = document.createElement('div');
dropdownContainer.style.width = '150px';
dropdownContainer.style.paddingRight = '5px';
this._viewTemplateSelector.render(dropdownContainer);
let viewTemplateContainer = document.createElement('div');
viewTemplateContainer.style.width = '150px';
viewTemplateContainer.style.paddingRight = '5px';
this._viewTemplateSelector.render(viewTemplateContainer);
this._sessionsList = [''];
this._sessionSelector = new SelectBox(this._sessionsList, '', this._contextViewService);
this._register(this._sessionSelector.onDidSelect(e => {
if (this.input) {
this.input.sessionName = e.selected;
}
}));
let sessionsContainer = document.createElement('div');
sessionsContainer.style.width = '150px';
sessionsContainer.style.paddingRight = '5px';
this._sessionSelector.render(sessionsContainer);
this._connectionInfoText = document.createElement('div');
this._connectionInfoText.style.paddingRight = '5px';
@@ -213,15 +230,18 @@ export class ProfilerEditor extends BaseEditor {
this._connectionInfoText.style.alignItems = 'center';
this._register(attachSelectBoxStyler(this._viewTemplateSelector, this.themeService));
this._register(attachSelectBoxStyler(this._sessionSelector, this.themeService));
this._actionBar.setContent([
{ action: this._startAction },
{ action: this._stopAction },
{ element: sessionsContainer },
{ action: this._createAction },
{ element: Taskbar.createTaskbarSeparator() },
{ action: this._pauseAction },
{ action: this._autoscrollAction },
{ action: this._instantiationService.createInstance(Actions.ProfilerClear, Actions.ProfilerClear.ID, Actions.ProfilerClear.LABEL) },
{ element: dropdownContainer },
{ element: viewTemplateContainer },
{ element: Taskbar.createTaskbarSeparator() },
{ element: this._connectionInfoText }
]);
@@ -416,26 +436,61 @@ export class ProfilerEditor extends BaseEditor {
if (e.isConnected) {
this._connectAction.connected = this.input.state.isConnected;
if (!this.input.state.isConnected) {
this._startAction.enabled = this.input.state.isConnected;
if (this.input.state.isConnected) {
this._updateToolbar();
this._sessionSelector.enable();
this._profilerService.getXEventSessions(this.input.id).then((r) => {
this._sessionSelector.setOptions(r);
this._sessionsList = r;
if (this.input.sessionName === undefined || this.input.sessionName === '') {
this.input.sessionName = this._sessionsList[0];
}
});
} else {
this._startAction.enabled = false;
this._stopAction.enabled = false;
this._pauseAction.enabled = false;
this._sessionSelector.setOptions([]);
this._sessionSelector.disable();
return;
}
}
if (e.isPaused){
if (e.isPaused) {
this._pauseAction.paused = this.input.state.isPaused;
this._pauseAction.enabled = !this.input.state.isStopped && (this.input.state.isRunning || this.input.state.isPaused);
this._updateToolbar();
}
if (e.isStopped || e.isRunning) {
this._startAction.enabled = !this.input.state.isRunning && !this.input.state.isPaused;
this._stopAction.enabled = !this.input.state.isStopped && (this.input.state.isRunning || this.input.state.isPaused);
this._pauseAction.enabled = !this.input.state.isStopped && (this.input.state.isRunning || this.input.state.isPaused);
if (this.input.state.isRunning) {
this._updateToolbar();
this._sessionSelector.setOptions([this.input.sessionName]);
this._sessionSelector.selectWithOptionName(this.input.sessionName);
this._sessionSelector.disable();
this._viewTemplateSelector.selectWithOptionName(this.input.viewTemplate.name);
}
if (this.input.state.isStopped) {
this._updateToolbar();
this._sessionSelector.enable();
this._profilerService.getXEventSessions(this.input.id).then((r) => {
this._sessionsList = r;
this._sessionSelector.setOptions(r);
if (this.input.sessionName === undefined || this.input.sessionName === '') {
this.input.sessionName = this._sessionsList[0];
}
});
}
}
}
private _updateToolbar(): void {
this._startAction.enabled = !this.input.state.isRunning && !this.input.state.isPaused && this.input.state.isConnected;
this._createAction.enabled = !this.input.state.isRunning && !this.input.state.isPaused && this.input.state.isConnected;
this._stopAction.enabled = !this.input.state.isStopped && (this.input.state.isRunning || this.input.state.isPaused) && this.input.state.isConnected;
this._pauseAction.enabled = !this.input.state.isStopped && (this.input.state.isRunning || this.input.state.isPaused && this.input.state.isConnected);
}
public layout(dimension: DOM.Dimension): void {
this._container.style.width = dimension.width + 'px';
this._container.style.height = dimension.height + 'px';
@@ -453,7 +508,6 @@ abstract class SettingsCommand extends Command {
return activeEditor;
}
return null;
}
}