mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
fix for stop session error and session selection lost issue (#3167)
* fix for stop session error and session selection lost issue * remove the console.error call
This commit is contained in:
@@ -468,34 +468,16 @@ export class ProfilerEditor extends BaseEditor {
|
|||||||
this._connectAction.connected = this.input.state.isConnected;
|
this._connectAction.connected = this.input.state.isConnected;
|
||||||
|
|
||||||
if (this.input.state.isConnected) {
|
if (this.input.state.isConnected) {
|
||||||
|
|
||||||
this._updateToolbar();
|
this._updateToolbar();
|
||||||
this._sessionSelector.enable();
|
|
||||||
this._profilerService.getXEventSessions(this.input.id).then((r) => {
|
|
||||||
// set undefined result to empty list
|
|
||||||
if (!r) {
|
|
||||||
r = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
this._sessionSelector.setOptions(r);
|
// Launch the create session dialog if openning a new window.
|
||||||
this._sessionsList = r;
|
let uiState = this._profilerService.getSessionViewState(this.input.id);
|
||||||
if ((this.input.sessionName === undefined || this.input.sessionName === '') && this._sessionsList.length > 0) {
|
let previousSessionName = uiState && uiState.previousSessionName;
|
||||||
let sessionIndex: number = 0;
|
if (!this.input.sessionName && !previousSessionName) {
|
||||||
let uiState = this._profilerService.getSessionViewState(this.input.id);
|
this._profilerService.launchCreateSessionDialog(this.input);
|
||||||
if (uiState && uiState.previousSessionName) {
|
}
|
||||||
sessionIndex = this._sessionsList.indexOf(uiState.previousSessionName);
|
|
||||||
} else {
|
|
||||||
this._profilerService.launchCreateSessionDialog(this.input);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sessionIndex < 0) {
|
this._updateSessionSelector(previousSessionName);
|
||||||
sessionIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.input.sessionName = this._sessionsList[sessionIndex];
|
|
||||||
this._sessionSelector.selectWithOptionName(this.input.sessionName);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
this._startAction.enabled = false;
|
this._startAction.enabled = false;
|
||||||
this._stopAction.enabled = false;
|
this._stopAction.enabled = false;
|
||||||
@@ -521,28 +503,35 @@ export class ProfilerEditor extends BaseEditor {
|
|||||||
}
|
}
|
||||||
if (this.input.state.isStopped) {
|
if (this.input.state.isStopped) {
|
||||||
this._updateToolbar();
|
this._updateToolbar();
|
||||||
this._sessionSelector.enable();
|
this._updateSessionSelector();
|
||||||
this._profilerService.getXEventSessions(this.input.id).then((r) => {
|
|
||||||
// set undefined result to empty list
|
|
||||||
if (!r) {
|
|
||||||
r = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
this._sessionsList = r;
|
|
||||||
this._sessionSelector.setOptions(r);
|
|
||||||
if ((this.input.sessionName === undefined || this.input.sessionName === '') && this._sessionsList.length > 0) {
|
|
||||||
this.input.sessionName = this._sessionsList[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.input.sessionName) {
|
|
||||||
this._sessionSelector.selectWithOptionName(this.input.sessionName);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _updateSessionSelector(previousSessionName: string = undefined) {
|
||||||
|
this._sessionSelector.enable();
|
||||||
|
this._profilerService.getXEventSessions(this.input.id).then((r) => {
|
||||||
|
if (!r) {
|
||||||
|
r = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
this._sessionSelector.setOptions(r);
|
||||||
|
this._sessionsList = r;
|
||||||
|
if (this._sessionsList.length > 0) {
|
||||||
|
if (!this.input.sessionName) {
|
||||||
|
this.input.sessionName = previousSessionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._sessionsList.indexOf(this.input.sessionName) === -1) {
|
||||||
|
this.input.sessionName = this._sessionsList[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
this._sessionSelector.selectWithOptionName(this.input.sessionName);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private _updateToolbar(): void {
|
private _updateToolbar(): void {
|
||||||
this._startAction.enabled = !this.input.state.isRunning && !this.input.state.isPaused && this.input.state.isConnected;
|
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._createAction.enabled = !this.input.state.isRunning && !this.input.state.isPaused && this.input.state.isConnected;
|
||||||
|
|||||||
@@ -141,7 +141,10 @@ export class ProfilerService implements IProfilerService {
|
|||||||
this._sessionMap.get(this._idMap.reverseGet(id)).onSessionStateChanged({ isStopped: true, isPaused: false, isRunning: false });
|
this._sessionMap.get(this._idMap.reverseGet(id)).onSessionStateChanged({ isStopped: true, isPaused: false, isRunning: false });
|
||||||
return true;
|
return true;
|
||||||
}, (reason) => {
|
}, (reason) => {
|
||||||
this._notificationService.error(reason.message);
|
// The error won't be actionable to the user, so only log it to console.
|
||||||
|
// In case of error, the state of the UI is not usable, makes more sense to
|
||||||
|
// set it to stopped so that user can restart it or pick a different session
|
||||||
|
this._sessionMap.get(this._idMap.reverseGet(id)).onSessionStateChanged({ isStopped: true, isPaused: false, isRunning: false });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user