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:
@@ -4,10 +4,9 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { EditorDescriptor } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { EditorDescriptor, Extensions as EditorExtensions, IEditorRegistry } from 'vs/workbench/browser/editor';
|
||||
import { IJSONSchema } from 'vs/base/common/jsonSchema';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/common/editor';
|
||||
import { IConfigurationRegistry, Extensions as ConfigurationExtensions, IConfigurationNode } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import * as nls from 'vs/nls';
|
||||
@@ -17,9 +16,8 @@ import { ProfilerEditor } from 'sql/parts/profiler/editor/profilerEditor';
|
||||
import { PROFILER_SESSION_TEMPLATE_SETTINGS, IProfilerSessionTemplate } from 'sql/parts/profiler/service/interfaces';
|
||||
|
||||
const profilerDescriptor = new EditorDescriptor(
|
||||
ProfilerEditor,
|
||||
ProfilerEditor.ID,
|
||||
'Profiler',
|
||||
'sql/parts/profiler/editor/profilerEditor',
|
||||
'ProfilerEditor'
|
||||
);
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import { registerTask } from 'sql/platform/tasks/taskRegistry';
|
||||
import { NewProfilerAction } from './profilerActions';
|
||||
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actionRegistry';
|
||||
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions';
|
||||
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
||||
import * as nls from 'vs/nls';
|
||||
import { IJSONSchema } from 'vs/base/common/jsonSchema';
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
import { IProfilerService } from 'sql/parts/profiler/service/interfaces';
|
||||
import { IProfilerController } from 'sql/parts/profiler/editor/controller/interfaces';
|
||||
import { ProfilerInput } from 'sql/parts/profiler/editor/profilerInput';
|
||||
import { ITaskActionContext, TaskAction } from 'sql/workbench/common/actions';
|
||||
import { BaseActionContext } from 'sql/workbench/common/actions';
|
||||
import { TaskAction } from 'sql/platform/tasks/taskRegistry';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
@@ -235,10 +236,10 @@ export class NewProfilerAction extends TaskAction {
|
||||
super(id, label, icon);
|
||||
}
|
||||
|
||||
run(actionContext: ITaskActionContext): TPromise<boolean> {
|
||||
run(actionContext: BaseActionContext): TPromise<boolean> {
|
||||
let profilerInput = this._instantiationService.createInstance(ProfilerInput, actionContext.profile);
|
||||
return this._editorService.openEditor(profilerInput, { pinned: true }, false).then(() => {
|
||||
return TPromise.as(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ import * as nls from 'vs/nls';
|
||||
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
|
||||
export class GlobalNewProfilerAction extends Action {
|
||||
public static ID = 'explorer.newProfiler';
|
||||
@@ -20,13 +22,31 @@ export class GlobalNewProfilerAction extends Action {
|
||||
constructor(
|
||||
id: string, label: string,
|
||||
@IWorkbenchEditorService private _editorService: IWorkbenchEditorService,
|
||||
@IInstantiationService private _instantiationService: IInstantiationService
|
||||
@IInstantiationService private _instantiationService: IInstantiationService,
|
||||
@IConnectionManagementService private _connectionService: IConnectionManagementService
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
run(context?: any): TPromise<boolean> {
|
||||
let profilerInput = this._instantiationService.createInstance(ProfilerInput, context ? context.connectionProfile : undefined);
|
||||
// TODO: for test-only, grab the first MSSQL active connection for the profiler session
|
||||
// TODO: when finishing the feature the connection should come from the launch context
|
||||
let connectionProfile: IConnectionProfile;
|
||||
if (context && context.connectionProfile) {
|
||||
connectionProfile = context.connectionProfile;
|
||||
} else {
|
||||
let activeConnections = this._connectionService.getActiveConnections();
|
||||
if (activeConnections) {
|
||||
for (let i = 0; i < activeConnections.length; ++i) {
|
||||
if (activeConnections[i].providerName === 'MSSQL') {
|
||||
connectionProfile = activeConnections[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let profilerInput = this._instantiationService.createInstance(ProfilerInput, connectionProfile);
|
||||
return this._editorService.openEditor(profilerInput, { pinned: true }, false).then(() => TPromise.as(true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
|
||||
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ProfilerResourceEditor } from './profilerResourceEditor';
|
||||
import { SplitView, View, Orientation, IViewOptions } from 'vs/base/browser/ui/splitview/splitview';
|
||||
import { SplitView, View, Orientation, IViewOptions } from 'sql/base/browser/ui/splitview/splitview';
|
||||
import { IContextMenuService, IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IModel, ICommonCodeEditor } from 'vs/editor/common/editorCommon';
|
||||
import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorInput';
|
||||
@@ -141,7 +141,7 @@ export class ProfilerEditor extends BaseEditor {
|
||||
|
||||
protected createEditor(parent: Builder): void {
|
||||
// test backend
|
||||
this._profilerService.registerProvider('default', this._instantiationService.createInstance(ProfilerTestBackend));
|
||||
//this._profilerService.registerProvider('default', this._instantiationService.createInstance(ProfilerTestBackend));
|
||||
|
||||
this._container = document.createElement('div');
|
||||
this._container.className = 'carbon-profiler';
|
||||
|
||||
@@ -41,13 +41,14 @@ export class ProfilerInput extends EditorInput implements IProfilerSession {
|
||||
this._state = new ProfilerState();
|
||||
// set inital state
|
||||
this.state.change({
|
||||
isConnected: false,
|
||||
isConnected: true,
|
||||
isStopped: false,
|
||||
isPaused: false,
|
||||
isRunning: false,
|
||||
autoscroll: true
|
||||
});
|
||||
this._id = this._profilerService.registerSession(generateUuid(), this);
|
||||
|
||||
this._id = this._profilerService.registerSession(generateUuid(), _connection, this);
|
||||
let searchFn = (val: { [x: string]: string }, exp: string): Array<number> => {
|
||||
let ret = new Array<number>();
|
||||
for (let i = 0; i < this._columns.length; i++) {
|
||||
@@ -124,13 +125,16 @@ export class ProfilerInput extends EditorInput implements IProfilerSession {
|
||||
return this._state;
|
||||
}
|
||||
|
||||
public onMoreRows(rowCount: number, data: data.IProfilerTableRow) {
|
||||
let validColumns = this.sessionTemplate.view.events.find(i => i.name === data.EventClass).columns;
|
||||
Object.keys(rowCount).forEach(k => {
|
||||
if (!validColumns.includes(k)) {
|
||||
delete rowCount[k];
|
||||
}
|
||||
});
|
||||
this._data.push(data);
|
||||
public onMoreRows(events: data.ProfilerSessionEvents) {
|
||||
|
||||
events = undefined;
|
||||
|
||||
// let validColumns = this.sessionTemplate.view.events.find(i => i.name === data.EventClass).columns;
|
||||
// Object.keys(rowCount).forEach(k => {
|
||||
// if (!validColumns.includes(k)) {
|
||||
// delete rowCount[k];
|
||||
// }
|
||||
// });
|
||||
// this._data.push(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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