mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-17 01:25:36 -05:00
Add connection event listeners (#6540)
This commit is contained in:
@@ -7,7 +7,7 @@ import { SqlExtHostContext, SqlMainContext, ExtHostConnectionManagementShape, Ma
|
||||
import * as azdata from 'azdata';
|
||||
import { IExtHostContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
|
||||
import { IConnectionManagementService, ConnectionType } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { IConnectionManagementService, ConnectionType, IConnectionParams } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/common/objectExplorerService';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import * as TaskUtilities from 'sql/workbench/browser/taskUtilities';
|
||||
@@ -44,6 +44,45 @@ export class MainThreadConnectionManagement implements MainThreadConnectionManag
|
||||
this._toDispose = dispose(this._toDispose);
|
||||
}
|
||||
|
||||
public $registerConnectionEventListener(handle: number, providerId: string): void {
|
||||
|
||||
let stripProfile = (inputProfile: azdata.IConnectionProfile) => {
|
||||
if (!inputProfile) {
|
||||
return inputProfile;
|
||||
}
|
||||
|
||||
let outputProfile: azdata.IConnectionProfile = {
|
||||
connectionName: inputProfile.connectionName,
|
||||
serverName: inputProfile.serverName,
|
||||
databaseName: inputProfile.databaseName,
|
||||
userName: inputProfile.userName,
|
||||
password: inputProfile.password,
|
||||
authenticationType: inputProfile.authenticationType,
|
||||
savePassword: inputProfile.savePassword,
|
||||
groupFullName: inputProfile.groupFullName,
|
||||
groupId: inputProfile.groupId,
|
||||
providerName: inputProfile.providerName,
|
||||
saveProfile: inputProfile.saveProfile,
|
||||
id: inputProfile.id,
|
||||
azureTenantId: inputProfile.azureTenantId,
|
||||
options: inputProfile.options
|
||||
};
|
||||
return outputProfile;
|
||||
};
|
||||
|
||||
this._connectionManagementService.onConnect((params: IConnectionParams) => {
|
||||
this._proxy.$onConnectionEvent(handle, 'onConnect', params.connectionUri, stripProfile(params.connectionProfile));
|
||||
});
|
||||
|
||||
this._connectionManagementService.onConnectionChanged((params: IConnectionParams) => {
|
||||
this._proxy.$onConnectionEvent(handle, 'onConnectionChanged', params.connectionUri, stripProfile(params.connectionProfile));
|
||||
});
|
||||
|
||||
this._connectionManagementService.onDisconnect((params: IConnectionParams) => {
|
||||
this._proxy.$onConnectionEvent(handle, 'onDisconnect', params.connectionUri, stripProfile(params.connectionProfile));
|
||||
});
|
||||
}
|
||||
|
||||
public $getConnections(activeConnectionsOnly?: boolean): Thenable<azdata.connection.ConnectionProfile[]> {
|
||||
return Promise.resolve(this._connectionManagementService.getConnections(activeConnectionsOnly).map(profile => this.convertToConnectionProfile(profile)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user