mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-31 01:25:38 -05:00
Angular Individual Service Injection - Decouple bootstrap service (#1457)
* change services to be individually injected into angular * messing around with injection * change angular bootstrapping to factory style * formatting * formatting * fix imports * fix build errors * fix testsw * fix tests * fix compile errors
This commit is contained in:
@@ -5,46 +5,24 @@
|
||||
|
||||
/* Node Modules */
|
||||
import { Injectable, Inject, forwardRef, OnDestroy } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
/* SQL imports */
|
||||
import { DefaultComponentParams } from 'sql/services/bootstrap/bootstrapParams';
|
||||
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService';
|
||||
import { IDefaultComponentParams } from 'sql/services/bootstrap/bootstrapParams';
|
||||
import { IBootstrapParams } from 'sql/services/bootstrap/bootstrapService';
|
||||
import { IMetadataService } from 'sql/services/metadata/metadataService';
|
||||
import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement';
|
||||
import { ConnectionManagementInfo } from 'sql/parts/connection/common/connectionManagementInfo';
|
||||
import { IAdminService } from 'sql/parts/admin/common/adminService';
|
||||
import { IQueryManagementService } from 'sql/parts/query/common/queryManagement';
|
||||
import { toDisposableSubscription } from 'sql/parts/common/rxjsUtils';
|
||||
import { IInsightsDialogService } from 'sql/parts/insights/common/interfaces';
|
||||
import { ICapabilitiesService } from 'sql/services/capabilities/capabilitiesService';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { AngularEventType, IAngularEvent, IAngularEventingService } from 'sql/services/angularEventing/angularEventingService';
|
||||
import { IModelViewService } from 'sql/services/modelComponents/modelViewService';
|
||||
import { AngularDisposable } from 'sql/base/common/lifecycle';
|
||||
import { ConnectionContextkey } from 'sql/parts/connection/common/connectionContextKey';
|
||||
|
||||
import { ProviderMetadata, DatabaseInfo, SimpleExecuteResult } from 'sqlops';
|
||||
|
||||
/* VS imports */
|
||||
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
|
||||
import { IContextMenuService, IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
|
||||
import { ConfigurationEditingService, IConfigurationValue } from 'vs/workbench/services/configuration/node/configurationEditingService';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import * as nls from 'vs/nls';
|
||||
import { IPartService } from 'vs/workbench/services/part/common/partService';
|
||||
import { deepClone } from 'vs/base/common/objects';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { IContextKeyService, RawContextKey, IContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
|
||||
/* Wrapper for a metadata service that contains the uri string to use on each request */
|
||||
export class SingleConnectionMetadataService {
|
||||
@@ -119,115 +97,40 @@ export class SingleQueryManagementService {
|
||||
export class CommonServiceInterface extends AngularDisposable {
|
||||
protected _uniqueSelector: string;
|
||||
protected _uri: string;
|
||||
protected _bootstrapParams: DefaultComponentParams;
|
||||
|
||||
/* Static Services */
|
||||
protected _themeService = this._bootstrapService.themeService;
|
||||
protected _contextMenuService = this._bootstrapService.contextMenuService;
|
||||
protected _instantiationService = this._bootstrapService.instantiationService;
|
||||
protected _configService = this._bootstrapService.configurationService;
|
||||
protected _insightsDialogService = this._bootstrapService.insightsDialogService;
|
||||
protected _contextViewService = this._bootstrapService.contextViewService;
|
||||
protected _notificationService = this._bootstrapService.notificationService;
|
||||
protected _workspaceContextService = this._bootstrapService.workspaceContextService;
|
||||
protected _storageService = this._bootstrapService.storageService;
|
||||
protected _capabilitiesService = this._bootstrapService.capabilitiesService;
|
||||
protected _configurationEditingService = this._bootstrapService.configurationEditorService;
|
||||
protected _commandService = this._bootstrapService.commandService;
|
||||
protected _modelViewService = this._bootstrapService.modelViewService;
|
||||
protected _partService = this._bootstrapService.partService;
|
||||
protected _angularEventingService = this._bootstrapService.angularEventingService;
|
||||
protected _environmentService = this._bootstrapService.environmentService;
|
||||
|
||||
/* Special Services */
|
||||
protected _metadataService: SingleConnectionMetadataService;
|
||||
protected _connectionManagementService: SingleConnectionManagementService;
|
||||
protected _adminService: SingleAdminService;
|
||||
protected _queryManagementService: SingleQueryManagementService;
|
||||
protected _contextKeyService: IContextKeyService;
|
||||
protected _singleMetadataService: SingleConnectionMetadataService;
|
||||
protected _singleConnectionManagementService: SingleConnectionManagementService;
|
||||
protected _singleAdminService: SingleAdminService;
|
||||
protected _singleQueryManagementService: SingleQueryManagementService;
|
||||
public scopedContextKeyService: IContextKeyService;
|
||||
|
||||
protected _connectionContextKey: ConnectionContextkey;
|
||||
|
||||
constructor(
|
||||
@Inject(BOOTSTRAP_SERVICE_ID) protected _bootstrapService: IBootstrapService
|
||||
@Inject(IBootstrapParams) protected _params: IDefaultComponentParams,
|
||||
@Inject(IMetadataService) protected _metadataService: IMetadataService,
|
||||
@Inject(IConnectionManagementService) protected _connectionManagementService: IConnectionManagementService,
|
||||
@Inject(IAdminService) protected _adminService: IAdminService,
|
||||
@Inject(IQueryManagementService) protected _queryManagementService: IQueryManagementService
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
public get notificationService(): INotificationService {
|
||||
return this._notificationService;
|
||||
}
|
||||
|
||||
public get configurationEditingService(): ConfigurationEditingService {
|
||||
return this._configurationEditingService;
|
||||
}
|
||||
|
||||
public get metadataService(): SingleConnectionMetadataService {
|
||||
return this._metadataService;
|
||||
return this._singleMetadataService;
|
||||
}
|
||||
|
||||
public get connectionManagementService(): SingleConnectionManagementService {
|
||||
return this._connectionManagementService;
|
||||
}
|
||||
|
||||
public get commandService(): ICommandService {
|
||||
return this._commandService;
|
||||
}
|
||||
|
||||
public get themeService(): IWorkbenchThemeService {
|
||||
return this._themeService;
|
||||
}
|
||||
|
||||
public get contextMenuService(): IContextMenuService {
|
||||
return this._contextMenuService;
|
||||
}
|
||||
|
||||
public get instantiationService(): IInstantiationService {
|
||||
return this._instantiationService;
|
||||
}
|
||||
|
||||
public get modelViewService(): IModelViewService {
|
||||
return this._modelViewService;
|
||||
}
|
||||
|
||||
public get partService(): IPartService {
|
||||
return this._partService;
|
||||
}
|
||||
|
||||
public get contextKeyService(): IContextKeyService {
|
||||
return this._contextKeyService;
|
||||
return this._singleConnectionManagementService;
|
||||
}
|
||||
|
||||
public get adminService(): SingleAdminService {
|
||||
return this._adminService;
|
||||
return this._singleAdminService;
|
||||
}
|
||||
|
||||
public get queryManagementService(): SingleQueryManagementService {
|
||||
return this._queryManagementService;
|
||||
}
|
||||
|
||||
public get environmentService(): IEnvironmentService {
|
||||
return this._environmentService;
|
||||
}
|
||||
|
||||
public get contextViewService(): IContextViewService {
|
||||
return this._contextViewService;
|
||||
}
|
||||
|
||||
public get workspaceContextService(): IWorkspaceContextService {
|
||||
return this._workspaceContextService;
|
||||
}
|
||||
|
||||
public get storageService(): IStorageService {
|
||||
return this._storageService;
|
||||
}
|
||||
|
||||
public get capabilitiesService(): ICapabilitiesService {
|
||||
return this._capabilitiesService;
|
||||
}
|
||||
|
||||
public get angularEventingService(): IAngularEventingService {
|
||||
return this._angularEventingService;
|
||||
return this._singleQueryManagementService;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,18 +142,17 @@ export class CommonServiceInterface extends AngularDisposable {
|
||||
}
|
||||
|
||||
protected _getbootstrapParams(): void {
|
||||
this._bootstrapParams = this._bootstrapService.getBootstrapParams<DefaultComponentParams>(this._uniqueSelector);
|
||||
this._contextKeyService = this._bootstrapParams.scopedContextService;
|
||||
this._connectionContextKey = this._bootstrapParams.connectionContextKey;
|
||||
this.uri = this._bootstrapParams.ownerUri;
|
||||
this.scopedContextKeyService = this._params.scopedContextService;
|
||||
this._connectionContextKey = this._params.connectionContextKey;
|
||||
this.uri = this._params.ownerUri;
|
||||
}
|
||||
|
||||
protected setUri(uri: string) {
|
||||
this._uri = uri;
|
||||
this._metadataService = new SingleConnectionMetadataService(this._bootstrapService.metadataService, this._uri);
|
||||
this._connectionManagementService = new SingleConnectionManagementService(this._bootstrapService.connectionManagementService, this._uri, this._connectionContextKey);
|
||||
this._adminService = new SingleAdminService(this._bootstrapService.adminService, this._uri);
|
||||
this._queryManagementService = new SingleQueryManagementService(this._bootstrapService.queryManagementService, this._uri);
|
||||
this._singleMetadataService = new SingleConnectionMetadataService(this._metadataService, this._uri);
|
||||
this._singleConnectionManagementService = new SingleConnectionManagementService(this._connectionManagementService, this._uri, this._connectionContextKey);
|
||||
this._singleAdminService = new SingleAdminService(this._adminService, this._uri);
|
||||
this._singleQueryManagementService = new SingleQueryManagementService(this._queryManagementService, this._uri);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -274,6 +176,6 @@ export class CommonServiceInterface extends AngularDisposable {
|
||||
}
|
||||
|
||||
public getOriginalConnectionProfile(): IConnectionProfile {
|
||||
return this._bootstrapParams.connection;
|
||||
return this._params.connection;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user