mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-01 01:25:38 -05:00
refactor model components to not reference any dashboard services (#1168)
* refactor model components to not reference any dashboard services
This commit is contained in:
@@ -9,6 +9,7 @@ import 'sql/parts/dashboard/common/dashboardPanelStyles';
|
||||
import { Component, Inject, forwardRef, ViewChild, ElementRef, ViewChildren, QueryList, OnDestroy, ChangeDetectorRef } from '@angular/core';
|
||||
|
||||
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
|
||||
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
|
||||
import { WidgetConfig, TabConfig, TabSettingConfig } from 'sql/parts/dashboard/common/dashboardWidget';
|
||||
import { Extensions, IInsightRegistry } from 'sql/platform/dashboard/common/insightRegistry';
|
||||
import { DashboardWidgetWrapper } from 'sql/parts/dashboard/contents/dashboardWidgetWrapper.component';
|
||||
@@ -85,13 +86,15 @@ export abstract class DashboardPage extends AngularDisposable {
|
||||
|
||||
protected abstract propertiesWidget: WidgetConfig;
|
||||
protected abstract get context(): string;
|
||||
protected dashboardService: DashboardServiceInterface;
|
||||
|
||||
constructor(
|
||||
@Inject(forwardRef(() => DashboardServiceInterface)) protected dashboardService: DashboardServiceInterface,
|
||||
@Inject(forwardRef(() => CommonServiceInterface)) protected commonService: CommonServiceInterface,
|
||||
@Inject(forwardRef(() => ElementRef)) protected _el: ElementRef,
|
||||
@Inject(forwardRef(() => ChangeDetectorRef)) protected _cd: ChangeDetectorRef
|
||||
) {
|
||||
super();
|
||||
this.dashboardService = commonService as DashboardServiceInterface;
|
||||
}
|
||||
|
||||
protected init() {
|
||||
|
||||
@@ -9,6 +9,7 @@ import { Component, Inject, Input, forwardRef, ViewChild, ElementRef, ViewChildr
|
||||
import { NgGridConfig, NgGrid, NgGridItem } from 'angular2-grid';
|
||||
|
||||
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
|
||||
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
|
||||
import { TabConfig, WidgetConfig } from 'sql/parts/dashboard/common/dashboardWidget';
|
||||
import { DashboardWidgetWrapper } from 'sql/parts/dashboard/contents/dashboardWidgetWrapper.component';
|
||||
import { subscriptionToDisposable } from 'sql/base/common/lifecycle';
|
||||
@@ -153,7 +154,7 @@ export class DashboardGridContainer extends DashboardTab implements OnDestroy {
|
||||
@ViewChildren(DashboardWidgetWrapper) private _widgets: QueryList<DashboardWidgetWrapper>;
|
||||
@ViewChildren(WebviewContent) private _webViews: QueryList<WebviewContent>;
|
||||
constructor(
|
||||
@Inject(forwardRef(() => DashboardServiceInterface)) protected dashboardService: DashboardServiceInterface,
|
||||
@Inject(forwardRef(() => CommonServiceInterface)) protected dashboardService: CommonServiceInterface,
|
||||
@Inject(forwardRef(() => ElementRef)) protected _el: ElementRef,
|
||||
@Inject(forwardRef(() => ChangeDetectorRef)) protected _cd: ChangeDetectorRef
|
||||
) {
|
||||
|
||||
@@ -11,6 +11,7 @@ import { DashboardWidgetContainer } from 'sql/parts/dashboard/containers/dashboa
|
||||
import { DashboardTab } from 'sql/parts/dashboard/common/interfaces';
|
||||
import { WidgetConfig } from 'sql/parts/dashboard/common/dashboardWidget';
|
||||
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
|
||||
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
|
||||
import { AngularEventType } from '../../../services/angularEventing/angularEventingService';
|
||||
import { DashboardWidgetWrapper } from 'sql/parts/dashboard/contents/dashboardWidgetWrapper.component';
|
||||
import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
|
||||
@@ -30,12 +31,15 @@ export class DashboardHomeContainer extends DashboardWidgetContainer {
|
||||
@Input() private properties: WidgetConfig;
|
||||
@ViewChild('propertiesClass') private _propertiesClass: DashboardWidgetWrapper;
|
||||
|
||||
private dashboardService: DashboardServiceInterface;
|
||||
|
||||
constructor(
|
||||
@Inject(forwardRef(() => ChangeDetectorRef)) _cd: ChangeDetectorRef,
|
||||
@Inject(forwardRef(() => DashboardServiceInterface)) protected dashboardService: DashboardServiceInterface,
|
||||
@Inject(forwardRef(() => CommonServiceInterface)) protected commonService: CommonServiceInterface,
|
||||
|
||||
) {
|
||||
super(_cd);
|
||||
this.dashboardService = commonService as DashboardServiceInterface;
|
||||
}
|
||||
|
||||
ngAfterContentInit() {
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'vs/css!./dashboardNavSection';
|
||||
import { Component, Inject, Input, forwardRef, ViewChild, ElementRef, ViewChildren, QueryList, OnDestroy, ChangeDetectorRef, EventEmitter, OnChanges, AfterContentInit } from '@angular/core';
|
||||
|
||||
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
|
||||
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
|
||||
import { WidgetConfig, TabConfig, NavSectionConfig } from 'sql/parts/dashboard/common/dashboardWidget';
|
||||
import { PanelComponent, IPanelOptions, NavigationBarLayout } from 'sql/base/browser/ui/panel/panel.component';
|
||||
import { TabComponent } from 'sql/base/browser/ui/panel/tab.component';
|
||||
@@ -53,7 +54,7 @@ export class DashboardNavSection extends DashboardTab implements OnDestroy, OnCh
|
||||
@ViewChildren(DashboardTab) private _tabs: QueryList<DashboardTab>;
|
||||
@ViewChild(PanelComponent) private _panel: PanelComponent;
|
||||
constructor(
|
||||
@Inject(forwardRef(() => DashboardServiceInterface)) protected dashboardService: DashboardServiceInterface,
|
||||
@Inject(forwardRef(() => CommonServiceInterface)) protected dashboardService: CommonServiceInterface,
|
||||
@Inject(forwardRef(() => ChangeDetectorRef)) protected _cd: ChangeDetectorRef
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -13,6 +13,7 @@ import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { DashboardTab } from 'sql/parts/dashboard/common/interfaces';
|
||||
import { TabConfig } from 'sql/parts/dashboard/common/dashboardWidget';
|
||||
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
|
||||
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
|
||||
|
||||
import * as sqlops from 'sqlops';
|
||||
import { memoize } from 'vs/base/common/decorators';
|
||||
@@ -37,7 +38,7 @@ export class ControlHostContent {
|
||||
@ViewChild('agent') private _agentViewComponent: AgentViewComponent;
|
||||
|
||||
constructor(
|
||||
@Inject(forwardRef(() => DashboardServiceInterface)) private _dashboardService: DashboardServiceInterface,
|
||||
@Inject(forwardRef(() => CommonServiceInterface)) private _dashboardService: CommonServiceInterface,
|
||||
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef,
|
||||
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef
|
||||
) {
|
||||
|
||||
@@ -25,6 +25,7 @@ import { InsightsWidget } from 'sql/parts/dashboard/widgets/insights/insightsWid
|
||||
import { WebviewWidget } from 'sql/parts/dashboard/widgets/webview/webviewWidget.component';
|
||||
|
||||
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
|
||||
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
|
||||
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IColorTheme } from 'vs/workbench/services/themes/common/workbenchThemeService';
|
||||
@@ -88,7 +89,7 @@ export class DashboardWidgetWrapper extends AngularDisposable implements OnInit
|
||||
constructor(
|
||||
@Inject(forwardRef(() => ComponentFactoryResolver)) private _componentFactoryResolver: ComponentFactoryResolver,
|
||||
@Inject(forwardRef(() => ElementRef)) private _ref: ElementRef,
|
||||
@Inject(forwardRef(() => DashboardServiceInterface)) private _bootstrap: DashboardServiceInterface,
|
||||
@Inject(forwardRef(() => CommonServiceInterface)) private _bootstrap: CommonServiceInterface,
|
||||
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeref: ChangeDetectorRef,
|
||||
@Inject(forwardRef(() => Injector)) private _injector: Injector
|
||||
) {
|
||||
|
||||
@@ -16,6 +16,7 @@ import { memoize } from 'vs/base/common/decorators';
|
||||
import { DashboardTab } from 'sql/parts/dashboard/common/interfaces';
|
||||
import { TabConfig } from 'sql/parts/dashboard/common/dashboardWidget';
|
||||
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
|
||||
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
|
||||
import { IDashboardWebview } from 'sql/services/dashboard/common/dashboardViewService';
|
||||
import { AngularDisposable } from 'sql/base/common/lifecycle';
|
||||
|
||||
@@ -36,13 +37,15 @@ export class WebviewContent extends AngularDisposable implements OnInit, IDashbo
|
||||
private _onMessageDisposable: IDisposable;
|
||||
private _webview: Webview;
|
||||
private _html: string;
|
||||
private _dashboardService: DashboardServiceInterface;
|
||||
|
||||
constructor(
|
||||
@Inject(forwardRef(() => DashboardServiceInterface)) private _dashboardService: DashboardServiceInterface,
|
||||
@Inject(forwardRef(() => CommonServiceInterface)) private commonService: CommonServiceInterface,
|
||||
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef,
|
||||
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef
|
||||
) {
|
||||
super();
|
||||
this._dashboardService = commonService as DashboardServiceInterface;
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
@@ -9,6 +9,7 @@ import { Component, Inject, Input, forwardRef, ViewChild, ViewChildren, QueryLis
|
||||
import { NgGridConfig, NgGrid, NgGridItem } from 'angular2-grid';
|
||||
|
||||
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
|
||||
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
|
||||
import { WidgetConfig } from 'sql/parts/dashboard/common/dashboardWidget';
|
||||
import { DashboardWidgetWrapper } from 'sql/parts/dashboard/contents/dashboardWidgetWrapper.component';
|
||||
import { subscriptionToDisposable, AngularDisposable } from 'sql/base/common/lifecycle';
|
||||
@@ -111,11 +112,14 @@ export class WidgetContent extends AngularDisposable implements AfterViewInit {
|
||||
@ViewChildren(NgGridItem) private _items: QueryList<NgGridItem>;
|
||||
@ViewChild('scrollable', { read: ElementRef }) private _scrollable: ElementRef;
|
||||
@ViewChild('scrollContainer', { read: ElementRef }) private _scrollContainer: ElementRef;
|
||||
|
||||
protected dashboardService: DashboardServiceInterface;
|
||||
constructor(
|
||||
@Inject(forwardRef(() => DashboardServiceInterface)) protected dashboardService: DashboardServiceInterface,
|
||||
@Inject(forwardRef(() => CommonServiceInterface)) protected commonService: CommonServiceInterface,
|
||||
@Inject(forwardRef(() => ChangeDetectorRef)) protected _cd: ChangeDetectorRef
|
||||
) {
|
||||
super();
|
||||
this.dashboardService = commonService as DashboardServiceInterface;
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
|
||||
@@ -9,6 +9,7 @@ import { OnInit, Component, Inject, forwardRef, ElementRef, ChangeDetectorRef, O
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { DashboardServiceInterface } from './services/dashboardServiceInterface.service';
|
||||
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import * as Utils from 'sql/parts/connection/common/utils';
|
||||
import { RefreshWidgetAction, EditDashboardAction } from 'sql/parts/dashboard/common/actions';
|
||||
@@ -36,7 +37,7 @@ export class DashboardComponent extends AngularDisposable implements OnInit {
|
||||
private editDisposable: IDisposable;
|
||||
|
||||
constructor(
|
||||
@Inject(forwardRef(() => DashboardServiceInterface)) private _bootstrapService: DashboardServiceInterface,
|
||||
@Inject(forwardRef(() => CommonServiceInterface)) private _bootstrapService: CommonServiceInterface,
|
||||
@Inject(forwardRef(() => Router)) private _router: Router,
|
||||
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef
|
||||
) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import * as TelemetryKeys from 'sql/common/telemetryKeys';
|
||||
/* Services */
|
||||
import { BreadcrumbService } from 'sql/parts/dashboard/services/breadcrumb.service';
|
||||
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
|
||||
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
|
||||
|
||||
/* Directives */
|
||||
import { ComponentHostDirective } from 'sql/parts/dashboard/common/componentHost.directive';
|
||||
@@ -53,9 +54,9 @@ import { AgentViewComponent } from 'sql/parts/jobManagement/agent/agentView.comp
|
||||
import { JobHistoryComponent } from 'sql/parts/jobManagement/views/jobHistory.component';
|
||||
|
||||
let baseComponents = [DashboardHomeContainer, DashboardComponent, DashboardWidgetWrapper, DashboardWebviewContainer,
|
||||
DashboardWidgetContainer, DashboardGridContainer, DashboardErrorContainer, DashboardNavSection, ModelViewContent, WebviewContent, WidgetContent,
|
||||
ComponentHostDirective, BreadcrumbComponent, ControlHostContent, DashboardControlHostContainer,
|
||||
JobsViewComponent, AgentViewComponent, JobHistoryComponent, JobStepsViewComponent, DashboardModelViewContainer, ModelComponentWrapper];
|
||||
DashboardWidgetContainer, DashboardGridContainer, DashboardErrorContainer, DashboardNavSection, ModelViewContent, WebviewContent, WidgetContent,
|
||||
ComponentHostDirective, BreadcrumbComponent, ControlHostContent, DashboardControlHostContainer,
|
||||
JobsViewComponent, AgentViewComponent, JobHistoryComponent, JobStepsViewComponent, DashboardModelViewContainer, ModelComponentWrapper];
|
||||
|
||||
/* Panel */
|
||||
import { PanelModule } from 'sql/base/browser/ui/panel/panel.module';
|
||||
@@ -128,18 +129,19 @@ const appRoutes: Routes = [
|
||||
providers: [
|
||||
{ provide: APP_BASE_HREF, useValue: '/' },
|
||||
{ provide: IBreadcrumbService, useClass: BreadcrumbService },
|
||||
DashboardServiceInterface,
|
||||
{ provide: CommonServiceInterface, useClass: DashboardServiceInterface },
|
||||
{ provide: UrlSerializer, useClass: CustomUrlSerializer }
|
||||
]
|
||||
})
|
||||
export class DashboardModule {
|
||||
|
||||
private _bootstrap: DashboardServiceInterface;
|
||||
constructor(
|
||||
@Inject(forwardRef(() => ComponentFactoryResolver)) private _resolver: ComponentFactoryResolver,
|
||||
@Inject(BOOTSTRAP_SERVICE_ID) private _bootstrapService: IBootstrapService,
|
||||
@Inject(forwardRef(() => DashboardServiceInterface)) private _bootstrap: DashboardServiceInterface,
|
||||
@Inject(forwardRef(() => CommonServiceInterface)) bootstrap: CommonServiceInterface,
|
||||
@Inject(forwardRef(() => Router)) private _router: Router
|
||||
) {
|
||||
this._bootstrap = bootstrap as DashboardServiceInterface;
|
||||
}
|
||||
|
||||
ngDoBootstrap(appRef: ApplicationRef) {
|
||||
|
||||
@@ -14,6 +14,7 @@ import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/
|
||||
|
||||
import * as colors from 'vs/platform/theme/common/colorRegistry';
|
||||
import * as nls from 'vs/nls';
|
||||
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
|
||||
|
||||
export class DatabaseDashboardPage extends DashboardPage implements OnInit {
|
||||
protected propertiesWidget: WidgetConfig = {
|
||||
@@ -35,7 +36,7 @@ export class DatabaseDashboardPage extends DashboardPage implements OnInit {
|
||||
|
||||
constructor(
|
||||
@Inject(forwardRef(() => IBreadcrumbService)) private _breadcrumbService: IBreadcrumbService,
|
||||
@Inject(forwardRef(() => DashboardServiceInterface)) dashboardService: DashboardServiceInterface,
|
||||
@Inject(forwardRef(() => CommonServiceInterface)) dashboardService: DashboardServiceInterface,
|
||||
@Inject(forwardRef(() => ChangeDetectorRef)) _cd: ChangeDetectorRef,
|
||||
@Inject(forwardRef(() => ElementRef)) el: ElementRef
|
||||
) {
|
||||
|
||||
@@ -10,6 +10,7 @@ import { BreadcrumbClass } from 'sql/parts/dashboard/services/breadcrumb.service
|
||||
import { IBreadcrumbService } from 'sql/base/browser/ui/breadcrumb/interfaces';
|
||||
import { WidgetConfig } from 'sql/parts/dashboard/common/dashboardWidget';
|
||||
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
|
||||
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
|
||||
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService';
|
||||
|
||||
import * as colors from 'vs/platform/theme/common/colorRegistry';
|
||||
@@ -36,7 +37,7 @@ export class ServerDashboardPage extends DashboardPage implements OnInit {
|
||||
|
||||
constructor(
|
||||
@Inject(forwardRef(() => IBreadcrumbService)) private breadcrumbService: IBreadcrumbService,
|
||||
@Inject(forwardRef(() => DashboardServiceInterface)) dashboardService: DashboardServiceInterface,
|
||||
@Inject(forwardRef(() => CommonServiceInterface)) dashboardService: CommonServiceInterface,
|
||||
@Inject(forwardRef(() => ChangeDetectorRef)) _cd: ChangeDetectorRef,
|
||||
@Inject(forwardRef(() => ElementRef)) el: ElementRef
|
||||
) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import { Injectable, forwardRef, Inject, OnDestroy } from '@angular/core';
|
||||
import { Subject } from 'rxjs/Subject';
|
||||
|
||||
import { DashboardServiceInterface } from './dashboardServiceInterface.service';
|
||||
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
|
||||
import { MenuItem, IBreadcrumbService } from 'sql/base/browser/ui/breadcrumb/interfaces';
|
||||
import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile';
|
||||
|
||||
@@ -23,9 +24,11 @@ export class BreadcrumbService implements IBreadcrumbService {
|
||||
public breadcrumbItem: Subject<MenuItem[]>;
|
||||
private itemBreadcrums: MenuItem[];
|
||||
private _currentPage: BreadcrumbClass;
|
||||
private _bootstrap: DashboardServiceInterface;
|
||||
|
||||
constructor( @Inject(forwardRef(() => DashboardServiceInterface)) private _bootstrap: DashboardServiceInterface) {
|
||||
_bootstrap.onUpdatePage(() => {
|
||||
constructor( @Inject(forwardRef(() => CommonServiceInterface)) private commonService: CommonServiceInterface) {
|
||||
this._bootstrap = commonService as DashboardServiceInterface;
|
||||
this._bootstrap.onUpdatePage(() => {
|
||||
this.setBreadcrumbs(this._currentPage);
|
||||
});
|
||||
this.breadcrumbItem = new Subject<MenuItem[]>();
|
||||
|
||||
@@ -26,6 +26,8 @@ import { TabSettingConfig } from 'sql/parts/dashboard/common/dashboardWidget';
|
||||
import { IDashboardViewService } from 'sql/services/dashboard/common/dashboardViewService';
|
||||
import { AngularDisposable } from 'sql/base/common/lifecycle';
|
||||
import { ConnectionContextkey } from 'sql/parts/connection/common/connectionContextKey';
|
||||
import { SingleConnectionMetadataService, SingleConnectionManagementService, SingleAdminService, SingleQueryManagementService, CommonServiceInterface }
|
||||
from 'sql/services/common/commonServiceInterface.service';
|
||||
|
||||
import { ProviderMetadata, DatabaseInfo, SimpleExecuteResult } from 'sqlops';
|
||||
|
||||
@@ -50,68 +52,6 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
|
||||
|
||||
const DASHBOARD_SETTINGS = 'dashboard';
|
||||
|
||||
/* Wrapper for a metadata service that contains the uri string to use on each request */
|
||||
export class SingleConnectionMetadataService {
|
||||
|
||||
constructor(
|
||||
private _metadataService: IMetadataService,
|
||||
private _uri: string
|
||||
) { }
|
||||
|
||||
get metadata(): Observable<ProviderMetadata> {
|
||||
return Observable.fromPromise(this._metadataService.getMetadata(this._uri));
|
||||
}
|
||||
|
||||
get databaseNames(): Observable<string[]> {
|
||||
return Observable.fromPromise(this._metadataService.getDatabaseNames(this._uri));
|
||||
}
|
||||
}
|
||||
|
||||
/* Wrapper for a connection service that contains the uri string to use on each request */
|
||||
export class SingleConnectionManagementService {
|
||||
|
||||
constructor(
|
||||
private _connectionService: IConnectionManagementService,
|
||||
private _uri: string,
|
||||
private _contextKey: ConnectionContextkey
|
||||
) { }
|
||||
|
||||
public changeDatabase(name: string): Thenable<boolean> {
|
||||
return this._connectionService.changeDatabase(this._uri, name).then(e => {
|
||||
// we need to update our context
|
||||
this._contextKey.set(this.connectionInfo.connectionProfile);
|
||||
return e;
|
||||
});
|
||||
}
|
||||
|
||||
public get connectionInfo(): ConnectionManagementInfo {
|
||||
return this._connectionService.getConnectionInfo(this._uri);
|
||||
}
|
||||
}
|
||||
|
||||
export class SingleAdminService {
|
||||
|
||||
constructor(
|
||||
private _adminService: IAdminService,
|
||||
private _uri: string
|
||||
) { }
|
||||
|
||||
public get databaseInfo(): Observable<DatabaseInfo> {
|
||||
return Observable.fromPromise(this._adminService.getDatabaseInfo(this._uri));
|
||||
}
|
||||
}
|
||||
|
||||
export class SingleQueryManagementService {
|
||||
constructor(
|
||||
private _queryManagementService: IQueryManagementService,
|
||||
private _uri: string
|
||||
) { }
|
||||
|
||||
public runQueryAndReturn(queryString: string): Thenable<SimpleExecuteResult> {
|
||||
return this._queryManagementService.runQueryAndReturn(this._uri, queryString);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Providers a interface between a dashboard interface and the rest of carbon.
|
||||
Stores the uri and unique selector of a dashboard instance and uses that
|
||||
@@ -120,35 +60,12 @@ export class SingleQueryManagementService {
|
||||
usage of a widget.
|
||||
*/
|
||||
@Injectable()
|
||||
export class DashboardServiceInterface extends AngularDisposable {
|
||||
private _uniqueSelector: string;
|
||||
private _uri: string;
|
||||
private _bootstrapParams: DashboardComponentParams;
|
||||
export class DashboardServiceInterface extends CommonServiceInterface {
|
||||
|
||||
/* Static Services */
|
||||
private _themeService = this._bootstrapService.themeService;
|
||||
private _contextMenuService = this._bootstrapService.contextMenuService;
|
||||
private _instantiationService = this._bootstrapService.instantiationService;
|
||||
private _configService = this._bootstrapService.configurationService;
|
||||
private _insightsDialogService = this._bootstrapService.insightsDialogService;
|
||||
private _contextViewService = this._bootstrapService.contextViewService;
|
||||
private _notificationService = this._bootstrapService.notificationService;
|
||||
private _workspaceContextService = this._bootstrapService.workspaceContextService;
|
||||
private _storageService = this._bootstrapService.storageService;
|
||||
private _capabilitiesService = this._bootstrapService.capabilitiesService;
|
||||
private _configurationEditingService = this._bootstrapService.configurationEditorService;
|
||||
private _commandService = this._bootstrapService.commandService;
|
||||
private _dashboardViewService = this._bootstrapService.dashboardViewService;
|
||||
private _partService = this._bootstrapService.partService;
|
||||
private _angularEventingService = this._bootstrapService.angularEventingService;
|
||||
private _environmentService = this._bootstrapService.environmentService;
|
||||
|
||||
/* Special Services */
|
||||
private _metadataService: SingleConnectionMetadataService;
|
||||
private _connectionManagementService: SingleConnectionManagementService;
|
||||
private _adminService: SingleAdminService;
|
||||
private _queryManagementService: SingleQueryManagementService;
|
||||
private _contextKeyService: IContextKeyService;
|
||||
private _dashboardViewService = this._bootstrapService.dashboardViewService;
|
||||
|
||||
|
||||
private _updatePage = new Emitter<void>();
|
||||
public readonly onUpdatePage: Event<void> = this._updatePage.event;
|
||||
@@ -168,93 +85,19 @@ export class DashboardServiceInterface extends AngularDisposable {
|
||||
private _dashboardContextKey = new RawContextKey<string>('dashboardContext', undefined);
|
||||
public dashboardContextKey: IContextKey<string>;
|
||||
|
||||
private _connectionContextKey: ConnectionContextkey;
|
||||
|
||||
private _numberOfPageNavigations = 0;
|
||||
|
||||
constructor(
|
||||
@Inject(BOOTSTRAP_SERVICE_ID) private _bootstrapService: IBootstrapService,
|
||||
@Inject(BOOTSTRAP_SERVICE_ID) bootstrapService: IBootstrapService,
|
||||
@Inject(forwardRef(() => Router)) private _router: Router,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
public get notificationService(): INotificationService {
|
||||
return this._notificationService;
|
||||
}
|
||||
|
||||
public get configurationEditingService(): ConfigurationEditingService {
|
||||
return this._configurationEditingService;
|
||||
}
|
||||
|
||||
public get metadataService(): SingleConnectionMetadataService {
|
||||
return this._metadataService;
|
||||
}
|
||||
|
||||
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;
|
||||
super(bootstrapService);
|
||||
}
|
||||
|
||||
public get dashboardViewService(): IDashboardViewService {
|
||||
return this._dashboardViewService;
|
||||
}
|
||||
|
||||
public get partService(): IPartService {
|
||||
return this._partService;
|
||||
}
|
||||
|
||||
public get contextKeyService(): IContextKeyService {
|
||||
return this._contextKeyService;
|
||||
}
|
||||
|
||||
public get adminService(): SingleAdminService {
|
||||
return this._adminService;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the selector for this dashboard instance, should only be set once
|
||||
*/
|
||||
@@ -263,7 +106,7 @@ export class DashboardServiceInterface extends AngularDisposable {
|
||||
this._getbootstrapParams();
|
||||
}
|
||||
|
||||
private _getbootstrapParams(): void {
|
||||
protected _getbootstrapParams(): void {
|
||||
this._bootstrapParams = this._bootstrapService.getBootstrapParams<DashboardComponentParams>(this._uniqueSelector);
|
||||
this._contextKeyService = this._bootstrapParams.scopedContextService;
|
||||
this._connectionContextKey = this._bootstrapParams.connectionContextKey;
|
||||
@@ -275,27 +118,11 @@ export class DashboardServiceInterface extends AngularDisposable {
|
||||
* Set the uri for this dashboard instance, should only be set once
|
||||
* Inits all the services that depend on knowing a uri
|
||||
*/
|
||||
private set uri(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);
|
||||
protected set uri(uri: string) {
|
||||
super.setUri(uri);
|
||||
this._register(toDisposableSubscription(this._bootstrapService.angularEventingService.onAngularEvent(this._uri, (event) => this.handleDashboardEvent(event))));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the underlying Uri for dashboard
|
||||
* In general don't use this, use specific services instances exposed publically
|
||||
*/
|
||||
public getUnderlyingUri(): string {
|
||||
return this._uri;
|
||||
}
|
||||
|
||||
public getOriginalConnectionProfile(): IConnectionProfile {
|
||||
return this._bootstrapParams.connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of page navigation
|
||||
*/
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Router } from '@angular/router';
|
||||
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { MetadataType } from 'sql/parts/connection/common/connectionManagement';
|
||||
import { SingleConnectionManagementService } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
|
||||
import { SingleConnectionManagementService } from 'sql/services/common/commonServiceInterface.service';
|
||||
import {
|
||||
NewQueryAction, ScriptSelectAction, EditDataAction, ScriptCreateAction, ScriptExecuteAction, ScriptAlterAction,
|
||||
BackupAction, ManageActionContext, BaseActionContext, ManageAction, RestoreAction
|
||||
|
||||
@@ -12,6 +12,7 @@ import { Router } from '@angular/router';
|
||||
|
||||
import { DashboardWidget, IDashboardWidget, WidgetConfig, WIDGET_CONFIG } from 'sql/parts/dashboard/common/dashboardWidget';
|
||||
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
|
||||
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
|
||||
import { toDisposableSubscription } from 'sql/parts/common/rxjsUtils';
|
||||
import { ExplorerFilter, ExplorerRenderer, ExplorerDataSource, ExplorerController, ObjectMetadataWrapper, ExplorerModel } from './explorerTree';
|
||||
import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile';
|
||||
@@ -49,7 +50,7 @@ export class ExplorerWidget extends DashboardWidget implements IDashboardWidget,
|
||||
@ViewChild('table') private _tableContainer: ElementRef;
|
||||
|
||||
constructor(
|
||||
@Inject(forwardRef(() => DashboardServiceInterface)) private _bootstrap: DashboardServiceInterface,
|
||||
@Inject(forwardRef(() => CommonServiceInterface)) private _bootstrap: CommonServiceInterface,
|
||||
@Inject(forwardRef(() => Router)) private _router: Router,
|
||||
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef,
|
||||
@Inject(WIDGET_CONFIG) protected _config: WidgetConfig,
|
||||
|
||||
@@ -10,6 +10,7 @@ import { Observable } from 'rxjs/Observable';
|
||||
|
||||
import { DashboardWidget, IDashboardWidget, WIDGET_CONFIG, WidgetConfig } from 'sql/parts/dashboard/common/dashboardWidget';
|
||||
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
|
||||
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
|
||||
import { ComponentHostDirective } from 'sql/parts/dashboard/common/componentHost.directive';
|
||||
import { InsightAction, InsightActionContext } from 'sql/workbench/common/actions';
|
||||
import { toDisposableSubscription } from 'sql/parts/common/rxjsUtils';
|
||||
@@ -57,7 +58,7 @@ export class InsightsWidget extends DashboardWidget implements IDashboardWidget,
|
||||
|
||||
constructor(
|
||||
@Inject(forwardRef(() => ComponentFactoryResolver)) private _componentFactoryResolver: ComponentFactoryResolver,
|
||||
@Inject(forwardRef(() => DashboardServiceInterface)) private dashboardService: DashboardServiceInterface,
|
||||
@Inject(forwardRef(() => CommonServiceInterface)) private dashboardService: CommonServiceInterface,
|
||||
@Inject(WIDGET_CONFIG) protected _config: WidgetConfig,
|
||||
@Inject(forwardRef(() => ViewContainerRef)) private viewContainerRef: ViewContainerRef,
|
||||
@Inject(forwardRef(() => ChangeDetectorRef)) private _cd: ChangeDetectorRef
|
||||
|
||||
@@ -7,6 +7,7 @@ import { Component, Inject, forwardRef, ChangeDetectorRef, OnInit, ElementRef, V
|
||||
|
||||
import { DashboardWidget, IDashboardWidget, WidgetConfig, WIDGET_CONFIG } from 'sql/parts/dashboard/common/dashboardWidget';
|
||||
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
|
||||
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
|
||||
import { ConnectionManagementInfo } from 'sql/parts/connection/common/connectionManagementInfo';
|
||||
import { toDisposableSubscription } from 'sql/parts/common/rxjsUtils';
|
||||
import { error } from 'sql/base/common/log';
|
||||
@@ -68,7 +69,7 @@ export class PropertiesWidgetComponent extends DashboardWidget implements IDashb
|
||||
@ViewChild('parent', { read: ElementRef }) private _parent: ElementRef;
|
||||
|
||||
constructor(
|
||||
@Inject(forwardRef(() => DashboardServiceInterface)) private _bootstrap: DashboardServiceInterface,
|
||||
@Inject(forwardRef(() => CommonServiceInterface)) private _bootstrap: CommonServiceInterface,
|
||||
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef,
|
||||
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef,
|
||||
@Inject(WIDGET_CONFIG) protected _config: WidgetConfig,
|
||||
|
||||
@@ -12,6 +12,7 @@ import { DomSanitizer } from '@angular/platform-browser';
|
||||
/* SQL imports */
|
||||
import { DashboardWidget, IDashboardWidget, WidgetConfig, WIDGET_CONFIG } from 'sql/parts/dashboard/common/dashboardWidget';
|
||||
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
|
||||
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
|
||||
import { TaskRegistry } from 'sql/platform/tasks/common/tasks';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { BaseActionContext } from 'sql/workbench/common/actions';
|
||||
@@ -57,7 +58,7 @@ export class TasksWidget extends DashboardWidget implements IDashboardWidget, On
|
||||
@ViewChild('container', { read: ElementRef }) private _container: ElementRef;
|
||||
|
||||
constructor(
|
||||
@Inject(forwardRef(() => DashboardServiceInterface)) private _bootstrap: DashboardServiceInterface,
|
||||
@Inject(forwardRef(() => CommonServiceInterface)) private _bootstrap: CommonServiceInterface,
|
||||
@Inject(forwardRef(() => DomSanitizer)) private _sanitizer: DomSanitizer,
|
||||
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeref: ChangeDetectorRef,
|
||||
@Inject(WIDGET_CONFIG) protected _config: WidgetConfig
|
||||
|
||||
@@ -13,6 +13,7 @@ import { memoize } from 'vs/base/common/decorators';
|
||||
|
||||
import { DashboardWidget, IDashboardWidget, WidgetConfig, WIDGET_CONFIG } from 'sql/parts/dashboard/common/dashboardWidget';
|
||||
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
|
||||
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
|
||||
import { IDashboardWebview } from 'sql/services/dashboard/common/dashboardViewService';
|
||||
|
||||
import * as sqlops from 'sqlops';
|
||||
@@ -35,15 +36,17 @@ export class WebviewWidget extends DashboardWidget implements IDashboardWidget,
|
||||
private _onMessage = new Emitter<string>();
|
||||
public readonly onMessage: Event<string> = this._onMessage.event;
|
||||
private _onMessageDisposable: IDisposable;
|
||||
private _dashboardService: DashboardServiceInterface;
|
||||
|
||||
constructor(
|
||||
@Inject(forwardRef(() => DashboardServiceInterface)) private _dashboardService: DashboardServiceInterface,
|
||||
@Inject(forwardRef(() => CommonServiceInterface)) private commonService: CommonServiceInterface,
|
||||
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef,
|
||||
@Inject(WIDGET_CONFIG) protected _config: WidgetConfig,
|
||||
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef
|
||||
) {
|
||||
super();
|
||||
this._id = (_config.widget[selector] as IWebviewWidgetConfig).id;
|
||||
this._dashboardService = commonService as DashboardServiceInterface;
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
@@ -19,6 +19,7 @@ import { PanelComponent } from 'sql/base/browser/ui/panel/panel.component';
|
||||
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService';
|
||||
import { IJobManagementService } from '../common/interfaces';
|
||||
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
|
||||
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
|
||||
import { AgentViewComponent } from 'sql/parts/jobManagement/agent/agentView.component';
|
||||
import { JobHistoryController, JobHistoryDataSource,
|
||||
JobHistoryRenderer, JobHistoryFilter, JobHistoryModel, JobHistoryRow } from 'sql/parts/jobManagement/views/jobHistoryTree';
|
||||
@@ -63,7 +64,7 @@ export class JobHistoryComponent extends Disposable implements OnInit {
|
||||
@Inject(BOOTSTRAP_SERVICE_ID) private bootstrapService: IBootstrapService,
|
||||
@Inject(forwardRef(() => ElementRef)) el: ElementRef,
|
||||
@Inject(forwardRef(() => ChangeDetectorRef)) private _cd: ChangeDetectorRef,
|
||||
@Inject(forwardRef(() => DashboardServiceInterface)) private _dashboardService: DashboardServiceInterface,
|
||||
@Inject(forwardRef(() => CommonServiceInterface)) private _dashboardService: CommonServiceInterface,
|
||||
@Inject(forwardRef(() => AgentViewComponent)) private _agentViewComponent: AgentViewComponent
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Router } from '@angular/router';
|
||||
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { MetadataType } from 'sql/parts/connection/common/connectionManagement';
|
||||
import { SingleConnectionManagementService } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
|
||||
import { SingleConnectionManagementService } from 'sql/services/common/commonServiceInterface.service';
|
||||
import {
|
||||
NewQueryAction, ScriptSelectAction, EditDataAction, ScriptCreateAction, ScriptExecuteAction, ScriptAlterAction,
|
||||
BackupAction, ManageActionContext, BaseActionContext, ManageAction, RestoreAction
|
||||
|
||||
@@ -14,6 +14,7 @@ import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService';
|
||||
import { IJobManagementService } from '../common/interfaces';
|
||||
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
|
||||
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
|
||||
import { AgentJobHistoryInfo } from 'sqlops';
|
||||
import { JobStepsViewController, JobStepsViewDataSource, JobStepsViewFilter,
|
||||
JobStepsViewRenderer, JobStepsViewRow, JobStepsViewModel} from 'sql/parts/jobManagement/views/jobStepsViewTree';
|
||||
@@ -42,7 +43,7 @@ export class JobStepsViewComponent extends Disposable implements OnInit, AfterCo
|
||||
@Inject(BOOTSTRAP_SERVICE_ID) private bootstrapService: IBootstrapService,
|
||||
@Inject(forwardRef(() => ElementRef)) el: ElementRef,
|
||||
@Inject(forwardRef(() => ChangeDetectorRef)) private _cd: ChangeDetectorRef,
|
||||
@Inject(forwardRef(() => DashboardServiceInterface)) private _dashboardService: DashboardServiceInterface,
|
||||
@Inject(forwardRef(() => CommonServiceInterface)) private _dashboardService: CommonServiceInterface,
|
||||
@Inject(forwardRef(() => JobHistoryComponent)) private _jobHistoryComponent: JobHistoryComponent
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Router } from '@angular/router';
|
||||
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { MetadataType } from 'sql/parts/connection/common/connectionManagement';
|
||||
import { SingleConnectionManagementService } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
|
||||
import { SingleConnectionManagementService } from 'sql/services/common/commonServiceInterface.service';
|
||||
import {
|
||||
NewQueryAction, ScriptSelectAction, EditDataAction, ScriptCreateAction, ScriptExecuteAction, ScriptAlterAction,
|
||||
BackupAction, ManageActionContext, BaseActionContext, ManageAction, RestoreAction
|
||||
|
||||
@@ -21,6 +21,7 @@ import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService';
|
||||
import { IJobManagementService } from '../common/interfaces';
|
||||
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
|
||||
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
|
||||
import * as sqlops from 'sqlops';
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vs/nls';
|
||||
@@ -74,7 +75,7 @@ export class JobsViewComponent implements AfterContentChecked {
|
||||
|
||||
constructor(
|
||||
@Inject(BOOTSTRAP_SERVICE_ID) private bootstrapService: IBootstrapService,
|
||||
@Inject(forwardRef(() => DashboardServiceInterface)) private _dashboardService: DashboardServiceInterface,
|
||||
@Inject(forwardRef(() => CommonServiceInterface)) private _dashboardService: CommonServiceInterface,
|
||||
@Inject(forwardRef(() => ChangeDetectorRef)) private _cd: ChangeDetectorRef,
|
||||
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef,
|
||||
@Inject(forwardRef(() => AgentViewComponent)) private _agentViewComponent: AgentViewComponent
|
||||
|
||||
@@ -13,6 +13,7 @@ import { ComponentHostDirective } from 'sql/parts/dashboard/common/componentHost
|
||||
import { error } from 'sql/base/common/log';
|
||||
import { AngularDisposable } from 'sql/base/common/lifecycle';
|
||||
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
|
||||
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
|
||||
import { IComponent, IComponentConfig, IComponentDescriptor, IModelStore, COMPONENT_CONFIG } from './interfaces';
|
||||
import { Extensions, IComponentRegistry } from 'sql/platform/dashboard/common/modelComponentRegistry';
|
||||
|
||||
@@ -27,7 +28,7 @@ import { memoize } from 'vs/base/common/decorators';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import * as nls from 'vs/nls';
|
||||
|
||||
const componentRegistry = <IComponentRegistry> Registry.as(Extensions.ComponentContribution);
|
||||
const componentRegistry = <IComponentRegistry>Registry.as(Extensions.ComponentContribution);
|
||||
|
||||
@Component({
|
||||
selector: 'model-component-wrapper',
|
||||
@@ -52,7 +53,7 @@ export class ModelComponentWrapper extends AngularDisposable implements OnInit {
|
||||
constructor(
|
||||
@Inject(forwardRef(() => ComponentFactoryResolver)) private _componentFactoryResolver: ComponentFactoryResolver,
|
||||
@Inject(forwardRef(() => ElementRef)) private _ref: ElementRef,
|
||||
@Inject(forwardRef(() => DashboardServiceInterface)) private _bootstrap: DashboardServiceInterface,
|
||||
@Inject(forwardRef(() => CommonServiceInterface)) private _bootstrap: CommonServiceInterface,
|
||||
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeref: ChangeDetectorRef,
|
||||
@Inject(forwardRef(() => Injector)) private _injector: Injector
|
||||
) {
|
||||
|
||||
@@ -15,7 +15,7 @@ import nls = require('vs/nls');
|
||||
|
||||
import { DashboardTab } from 'sql/parts/dashboard/common/interfaces';
|
||||
import { TabConfig } from 'sql/parts/dashboard/common/dashboardWidget';
|
||||
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
|
||||
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
|
||||
import { IModelView } from 'sql/services/model/modelViewService';
|
||||
import { AngularDisposable } from 'sql/base/common/lifecycle';
|
||||
|
||||
@@ -42,14 +42,14 @@ export class ModelViewContent extends ViewBase implements OnInit, IModelView {
|
||||
private _onMessageDisposable: IDisposable;
|
||||
|
||||
constructor(
|
||||
@Inject(forwardRef(() => DashboardServiceInterface)) private _dashboardService: DashboardServiceInterface,
|
||||
@Inject(forwardRef(() => CommonServiceInterface)) private _commonService: CommonServiceInterface,
|
||||
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef
|
||||
) {
|
||||
super(changeRef);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this._dashboardService.dashboardViewService.registerModelView(this);
|
||||
this._commonService.modelViewService.registerModelView(this);
|
||||
this._register(addDisposableListener(window, EventType.RESIZE, e => {
|
||||
this.layout();
|
||||
}));
|
||||
@@ -64,7 +64,7 @@ export class ModelViewContent extends ViewBase implements OnInit, IModelView {
|
||||
|
||||
@memoize
|
||||
public get connection(): sqlops.connection.Connection {
|
||||
let currentConnection = this._dashboardService.connectionManagementService.connectionInfo.connectionProfile;
|
||||
let currentConnection = this._commonService.connectionManagementService.connectionInfo.connectionProfile;
|
||||
let connection: sqlops.connection.Connection = {
|
||||
providerName: currentConnection.providerName,
|
||||
connectionId: currentConnection.id,
|
||||
@@ -75,6 +75,6 @@ export class ModelViewContent extends ViewBase implements OnInit, IModelView {
|
||||
|
||||
@memoize
|
||||
public get serverInfo(): sqlops.ServerInfo {
|
||||
return this._dashboardService.connectionManagementService.connectionInfo.serverInfo;
|
||||
return this._commonService.connectionManagementService.connectionInfo.serverInfo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,13 +19,16 @@ export interface EditDataComponentParams extends BootstrapParams {
|
||||
dataService: DataService;
|
||||
}
|
||||
|
||||
export interface DashboardComponentParams extends BootstrapParams {
|
||||
export interface DefaultComponentParams extends BootstrapParams {
|
||||
connection: IConnectionProfile;
|
||||
ownerUri: string;
|
||||
scopedContextService: IContextKeyService;
|
||||
connectionContextKey: ConnectionContextkey;
|
||||
}
|
||||
|
||||
export interface DashboardComponentParams extends DefaultComponentParams {
|
||||
}
|
||||
|
||||
export interface TaskDialogComponentParams extends BootstrapParams {
|
||||
ownerUri: string;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { IJobManagementService } from 'sql/parts/jobManagement/common/interfaces';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { IModelViewService } from 'sql/services/modelComponents/modelViewService';
|
||||
|
||||
export const BOOTSTRAP_SERVICE_ID = 'bootstrapService';
|
||||
export const IBootstrapService = createDecorator<IBootstrapService>(BOOTSTRAP_SERVICE_ID);
|
||||
@@ -94,6 +95,7 @@ export interface IBootstrapService {
|
||||
configurationEditorService: ConfigurationEditingService;
|
||||
commandService: ICommandService;
|
||||
dashboardViewService: IDashboardViewService;
|
||||
modelViewService: IModelViewService;
|
||||
jobManagementService: IJobManagementService;
|
||||
environmentService: IEnvironmentService;
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import { IFileBrowserService, IFileBrowserDialogController } from 'sql/parts/fil
|
||||
import { IClipboardService } from 'sql/platform/clipboard/common/clipboardService';
|
||||
import { ICapabilitiesService } from 'sql/services/capabilities/capabilitiesService';
|
||||
import { IDashboardViewService } from 'sql/services/dashboard/common/dashboardViewService';
|
||||
import { IModelViewService } from 'sql/services/modelComponents/modelViewService';
|
||||
|
||||
import { $ } from 'vs/base/browser/dom';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
@@ -103,6 +104,7 @@ export class BootstrapService implements IBootstrapService {
|
||||
@ICapabilitiesService public capabilitiesService: ICapabilitiesService,
|
||||
@ICommandService public commandService: ICommandService,
|
||||
@IDashboardViewService public dashboardViewService: IDashboardViewService,
|
||||
@IModelViewService public modelViewService: IModelViewService,
|
||||
@IJobManagementService public jobManagementService: IJobManagementService,
|
||||
@IEnvironmentService public environmentService: IEnvironmentService
|
||||
) {
|
||||
|
||||
279
src/sql/services/common/commonServiceInterface.service.ts
Normal file
279
src/sql/services/common/commonServiceInterface.service.ts
Normal file
@@ -0,0 +1,279 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
/* 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 { 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 {
|
||||
|
||||
constructor(
|
||||
private _metadataService: IMetadataService,
|
||||
private _uri: string
|
||||
) { }
|
||||
|
||||
get metadata(): Observable<ProviderMetadata> {
|
||||
return Observable.fromPromise(this._metadataService.getMetadata(this._uri));
|
||||
}
|
||||
|
||||
get databaseNames(): Observable<string[]> {
|
||||
return Observable.fromPromise(this._metadataService.getDatabaseNames(this._uri));
|
||||
}
|
||||
}
|
||||
|
||||
/* Wrapper for a connection service that contains the uri string to use on each request */
|
||||
export class SingleConnectionManagementService {
|
||||
|
||||
constructor(
|
||||
private _connectionService: IConnectionManagementService,
|
||||
private _uri: string,
|
||||
private _contextKey: ConnectionContextkey
|
||||
) { }
|
||||
|
||||
public changeDatabase(name: string): Thenable<boolean> {
|
||||
return this._connectionService.changeDatabase(this._uri, name).then(e => {
|
||||
// we need to update our context
|
||||
this._contextKey.set(this.connectionInfo.connectionProfile);
|
||||
return e;
|
||||
});
|
||||
}
|
||||
|
||||
public get connectionInfo(): ConnectionManagementInfo {
|
||||
return this._connectionService.getConnectionInfo(this._uri);
|
||||
}
|
||||
}
|
||||
|
||||
export class SingleAdminService {
|
||||
|
||||
constructor(
|
||||
private _adminService: IAdminService,
|
||||
private _uri: string
|
||||
) { }
|
||||
|
||||
public get databaseInfo(): Observable<DatabaseInfo> {
|
||||
return Observable.fromPromise(this._adminService.getDatabaseInfo(this._uri));
|
||||
}
|
||||
}
|
||||
|
||||
export class SingleQueryManagementService {
|
||||
constructor(
|
||||
private _queryManagementService: IQueryManagementService,
|
||||
private _uri: string
|
||||
) { }
|
||||
|
||||
public runQueryAndReturn(queryString: string): Thenable<SimpleExecuteResult> {
|
||||
return this._queryManagementService.runQueryAndReturn(this._uri, queryString);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Providers a interface between a UI interface and the rest of carbon.
|
||||
Stores the uri and unique selector of a UI instance and uses that
|
||||
whenever a call to a carbon service needs this information, so that the widgets
|
||||
don't need to be aware of the uri or selector. Simplifies the initialization and
|
||||
usage of a widget.
|
||||
*/
|
||||
@Injectable()
|
||||
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 _connectionContextKey: ConnectionContextkey;
|
||||
|
||||
constructor(
|
||||
@Inject(BOOTSTRAP_SERVICE_ID) protected _bootstrapService: IBootstrapService
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
public get notificationService(): INotificationService {
|
||||
return this._notificationService;
|
||||
}
|
||||
|
||||
public get configurationEditingService(): ConfigurationEditingService {
|
||||
return this._configurationEditingService;
|
||||
}
|
||||
|
||||
public get metadataService(): SingleConnectionMetadataService {
|
||||
return this._metadataService;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public get adminService(): SingleAdminService {
|
||||
return this._adminService;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the selector for this instance, should only be set once
|
||||
*/
|
||||
public set selector(selector: string) {
|
||||
this._uniqueSelector = selector;
|
||||
this._getbootstrapParams();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the uri for this instance, should only be set once
|
||||
* Inits all the services that depend on knowing a uri
|
||||
*/
|
||||
protected set uri(uri: string) {
|
||||
this.setUri(uri);
|
||||
}
|
||||
|
||||
protected get uri(): string {
|
||||
return this._uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the underlying Uri
|
||||
* In general don't use this, use specific services instances exposed publicly
|
||||
*/
|
||||
public getUnderlyingUri(): string {
|
||||
return this._uri;
|
||||
}
|
||||
|
||||
public getOriginalConnectionProfile(): IConnectionProfile {
|
||||
return this._bootstrapParams.connection;
|
||||
}
|
||||
}
|
||||
23
src/sql/services/modelComponents/modelViewService.ts
Normal file
23
src/sql/services/modelComponents/modelViewService.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import Event from 'vs/base/common/event';
|
||||
|
||||
import * as sqlops from 'sqlops';
|
||||
import { IItemConfig, IComponentShape } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { IView, IModelView } from 'sql/services/model/modelViewService';
|
||||
|
||||
export const SERVICE_ID = 'modelViewService';
|
||||
|
||||
export interface IModelViewService {
|
||||
_serviceBrand: any;
|
||||
onRegisteredModelView: Event<IModelView>;
|
||||
registerModelView(widget: IModelView);
|
||||
}
|
||||
|
||||
export const IModelViewService = createDecorator<IModelViewService>(SERVICE_ID);
|
||||
21
src/sql/services/modelComponents/modelViewServiceImpl.ts
Normal file
21
src/sql/services/modelComponents/modelViewServiceImpl.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { IModelViewService } from 'sql/services/modelComponents/modelViewService';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { IModelView } from 'sql/services/model/modelViewService';
|
||||
|
||||
export class ModelViewService implements IModelViewService {
|
||||
_serviceBrand: any;
|
||||
|
||||
private _onRegisteredModelView = new Emitter<IModelView>();
|
||||
public readonly onRegisteredModelView: Event<IModelView> = this._onRegisteredModelView.event;
|
||||
|
||||
public registerModelView(view: IModelView) {
|
||||
this._onRegisteredModelView.fire(view);
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import { IExtHostContext } from 'vs/workbench/api/node/extHost.protocol';
|
||||
|
||||
import * as sqlops from 'sqlops';
|
||||
|
||||
import { IDashboardViewService } from 'sql/services/dashboard/common/dashboardViewService';
|
||||
import { IModelViewService } from 'sql/services/modelComponents/modelViewService';
|
||||
import { IItemConfig, ModelComponentTypes, IComponentShape } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { IModelView } from 'sql/services/model/modelViewService';
|
||||
|
||||
@@ -26,7 +26,7 @@ export class MainThreadModelView implements MainThreadModelViewShape {
|
||||
|
||||
constructor(
|
||||
context: IExtHostContext,
|
||||
@IDashboardViewService viewService: IDashboardViewService
|
||||
@IModelViewService viewService: IModelViewService
|
||||
) {
|
||||
this._proxy = context.getProxy(SqlExtHostContext.ExtHostModelView);
|
||||
viewService.onRegisteredModelView(view => {
|
||||
|
||||
Reference in New Issue
Block a user