mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Refresh master with initial release/0.24 snapshot (#332)
* Initial port of release/0.24 source code * Fix additional headers * Fix a typo in launch.json
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { ProfilerInput } from 'sql/parts/profiler/editor/profilerInput';
|
||||
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
@@ -23,7 +24,7 @@ export interface IProfilerSession {
|
||||
/**
|
||||
* Called by the service when more rows are available to render
|
||||
*/
|
||||
onMoreRows(rowCount: number, data: data.IProfilerTableRow);
|
||||
onMoreRows(events: data.ProfilerSessionEvents);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,12 +35,12 @@ export interface IProfilerService {
|
||||
/**
|
||||
* Registers a backend provider for profiler session. ex: mssql
|
||||
*/
|
||||
registerProvider(providerId: string, provider: data.IProfilerProvider): void;
|
||||
registerProvider(providerId: string, provider: data.ProfilerProvider): void;
|
||||
/**
|
||||
* Registers a session with the service that acts as the UI for a profiler session
|
||||
* @returns An unique id that should be used to make subsequent calls to this service
|
||||
*/
|
||||
registerSession(uri: string, session: IProfilerSession): ProfilerSessionID;
|
||||
registerSession(uri: string, connectionProfile: IConnectionProfile, session: IProfilerSession): ProfilerSessionID;
|
||||
/**
|
||||
* Connects the session specified by the id
|
||||
*/
|
||||
@@ -63,7 +64,7 @@ export interface IProfilerService {
|
||||
/**
|
||||
* The method called by the service provider for when more rows are available to render
|
||||
*/
|
||||
onMoreRows(params: data.IProfilerMoreRowsNotificationParams): void;
|
||||
onMoreRows(params: data.ProfilerSessionEvents): void;
|
||||
/**
|
||||
* Gets a list of the session templates that are specified in the settings
|
||||
* @param provider An optional string to limit the session template to a specific
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement';
|
||||
import { IConnectionManagementService, IConnectionCompletionOptions, ConnectionType, RunQueryOnConnectionMode } from 'sql/parts/connection/common/connectionManagement';
|
||||
import {
|
||||
ProfilerSessionID, IProfilerSession, IProfilerService, IProfilerSessionTemplate,
|
||||
PROFILER_SETTINGS, IProfilerSettings
|
||||
} from './interfaces';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { ProfilerInput } from 'sql/parts/profiler/editor/profilerInput';
|
||||
import { ProfilerColumnEditorDialog } from 'sql/parts/profiler/dialog/profilerColumnEditorDialog';
|
||||
|
||||
@@ -43,7 +44,7 @@ class TwoWayMap<T, K> {
|
||||
|
||||
export class ProfilerService implements IProfilerService {
|
||||
public _serviceBrand: any;
|
||||
private _providers = new Map<string, data.IProfilerProvider>();
|
||||
private _providers = new Map<string, data.ProfilerProvider>();
|
||||
private _idMap = new TwoWayMap<ProfilerSessionID, string>();
|
||||
private _sessionMap = new Map<ProfilerSessionID, IProfilerSession>();
|
||||
private _dialog: ProfilerColumnEditorDialog;
|
||||
@@ -54,18 +55,31 @@ export class ProfilerService implements IProfilerService {
|
||||
@IInstantiationService private _instantiationService: IInstantiationService
|
||||
) { }
|
||||
|
||||
public registerProvider(providerId: string, provider: data.IProfilerProvider): void {
|
||||
public registerProvider(providerId: string, provider: data.ProfilerProvider): void {
|
||||
this._providers.set(providerId, provider);
|
||||
}
|
||||
|
||||
public registerSession(uri: string, session: IProfilerSession): ProfilerSessionID {
|
||||
public registerSession(uri: string, connectionProfile: IConnectionProfile, session: IProfilerSession): ProfilerSessionID {
|
||||
let options: IConnectionCompletionOptions = {
|
||||
params: { connectionType: ConnectionType.default, runQueryOnCompletion: RunQueryOnConnectionMode.none, input: undefined },
|
||||
saveTheConnection: false,
|
||||
showDashboard: false,
|
||||
showConnectionDialogOnError: false,
|
||||
showFirewallRuleOnError: true
|
||||
};
|
||||
this._connectionService.connect(connectionProfile, uri, options).then(() => {
|
||||
|
||||
}).catch(connectionError => {
|
||||
|
||||
});
|
||||
this._sessionMap.set(uri, session);
|
||||
this._idMap.set(uri, uri);
|
||||
return uri;
|
||||
}
|
||||
|
||||
public onMoreRows(params: data.IProfilerMoreRowsNotificationParams): void {
|
||||
this._sessionMap.get(this._idMap.reverseGet(params.uri)).onMoreRows(params.rowCount, params.data);
|
||||
public onMoreRows(params: data.ProfilerSessionEvents): void {
|
||||
|
||||
this._sessionMap.get(this._idMap.reverseGet(params.sessionId)).onMoreRows(params);
|
||||
}
|
||||
|
||||
public connectSession(id: ProfilerSessionID): Thenable<boolean> {
|
||||
@@ -88,9 +102,9 @@ export class ProfilerService implements IProfilerService {
|
||||
return this._runAction(id, provider => provider.stopSession(this._idMap.get(id)));
|
||||
}
|
||||
|
||||
private _runAction<T>(id: ProfilerSessionID, action: (handler: data.IProfilerProvider) => Thenable<T>): Thenable<T> {
|
||||
private _runAction<T>(id: ProfilerSessionID, action: (handler: data.ProfilerProvider) => Thenable<T>): Thenable<T> {
|
||||
// let providerId = this._connectionService.getProviderIdFromUri(this._idMap.get(id));
|
||||
let providerId = 'default';
|
||||
let providerId = 'MSSQL';
|
||||
|
||||
if (!providerId) {
|
||||
return TPromise.wrapError(new Error('Connection is required in order to interact with queries'));
|
||||
|
||||
@@ -30,7 +30,7 @@ const columns = [
|
||||
'BinaryData'
|
||||
];
|
||||
|
||||
export class ProfilerTestBackend implements data.IProfilerProvider {
|
||||
export class ProfilerTestBackend implements data.ProfilerProvider {
|
||||
private index = 0;
|
||||
private timeOutMap = new Map<string, number>();
|
||||
private testData: Array<Array<string>> = new Array<Array<string>>();
|
||||
@@ -43,6 +43,10 @@ export class ProfilerTestBackend implements data.IProfilerProvider {
|
||||
return TPromise.as(true);
|
||||
}
|
||||
|
||||
registerOnSessionEventsAvailable(handler: (response: data.ProfilerSessionEvents) => any) {
|
||||
return;
|
||||
}
|
||||
|
||||
private intervalFn(guid: string): number {
|
||||
return setTimeout(() => {
|
||||
let data = this.testData[this.index++];
|
||||
@@ -54,7 +58,9 @@ export class ProfilerTestBackend implements data.IProfilerProvider {
|
||||
formattedData[columns[i]] = data[i];
|
||||
}
|
||||
|
||||
this._profilerService.onMoreRows({ uri: guid, rowCount: 1, data: formattedData });
|
||||
//this._profilerService.onMoreRows({ uri: guid, rowCount: 1, data: formattedData });
|
||||
|
||||
|
||||
if (this.index >= this.testData.length) {
|
||||
this.index = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user