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:
Anthony Dresser
2018-05-23 16:51:02 -07:00
committed by GitHub
parent cd0f9b71c5
commit 1359354387
68 changed files with 1011 additions and 1116 deletions
@@ -5,8 +5,8 @@
import { ChangeDetectorRef, ElementRef, Component, forwardRef, Inject } from '@angular/core'; import { ChangeDetectorRef, ElementRef, Component, forwardRef, Inject } from '@angular/core';
import { NgForm } from '@angular/forms'; import { NgForm } from '@angular/forms';
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService';
import { TaskDialogComponentParams } from 'sql/services/bootstrap/bootstrapParams'; import { ITaskDialogComponentParams } from 'sql/services/bootstrap/bootstrapParams';
import { ConnectionManagementInfo } from 'sql/parts/connection/common/connectionManagementInfo'; import { ConnectionManagementInfo } from 'sql/parts/connection/common/connectionManagementInfo';
import { IAdminService } from 'sql/parts/admin/common/adminService'; import { IAdminService } from 'sql/parts/admin/common/adminService';
import { ITaskDialogComponent } from 'sql/parts/tasks/common/tasks'; import { ITaskDialogComponent } from 'sql/parts/tasks/common/tasks';
@@ -31,8 +31,6 @@ export interface DatabaseFile {
}) })
export class CreateDatabaseComponent implements ITaskDialogComponent { export class CreateDatabaseComponent implements ITaskDialogComponent {
private _adminService: IAdminService;
public formSubmitted: boolean = false; public formSubmitted: boolean = false;
public ownerUri: string; public ownerUri: string;
@@ -49,9 +47,8 @@ export class CreateDatabaseComponent implements ITaskDialogComponent {
constructor( constructor(
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef, @Inject(forwardRef(() => ElementRef)) private _el: ElementRef,
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeDetectorRef: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) private _changeDetectorRef: ChangeDetectorRef,
@Inject(BOOTSTRAP_SERVICE_ID) private _bootstrapService: IBootstrapService @Inject(IAdminService) private _adminService: IAdminService
) { ) {
this._adminService = this._bootstrapService.adminService;
} }
private getDatabaseInfo(form: NgForm): sqlops.DatabaseInfo { private getDatabaseInfo(form: NgForm): sqlops.DatabaseInfo {
@@ -77,7 +74,7 @@ export class CreateDatabaseComponent implements ITaskDialogComponent {
public onSelectOwner(): void { } public onSelectOwner(): void { }
public injectBootstapper(parameters: TaskDialogComponentParams): void { public injectBootstapper(parameters: ITaskDialogComponentParams): void {
let self = this; let self = this;
this.ownerUri = parameters.ownerUri; this.ownerUri = parameters.ownerUri;
this._adminService.getDefaultDatabaseInfo(this.ownerUri).then(dbInfo => { this._adminService.getDefaultDatabaseInfo(this.ownerUri).then(dbInfo => {
@@ -4,8 +4,8 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { ElementRef, Component, Inject, forwardRef } from '@angular/core'; import { ElementRef, Component, Inject, forwardRef } from '@angular/core';
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService'; import { IBootstrapParams } from 'sql/services/bootstrap/bootstrapService';
import { DashboardComponentParams } from 'sql/services/bootstrap/bootstrapParams'; import { IDashboardComponentParams } from 'sql/services/bootstrap/bootstrapParams';
import { ConnectionManagementInfo } from 'sql/parts/connection/common/connectionManagementInfo'; import { ConnectionManagementInfo } from 'sql/parts/connection/common/connectionManagementInfo';
export const CREATELOGIN_SELECTOR: string = 'createlogin-component'; export const CREATELOGIN_SELECTOR: string = 'createlogin-component';
@@ -22,9 +22,7 @@ export class CreateLoginComponent {
constructor( constructor(
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef, @Inject(forwardRef(() => ElementRef)) private _el: ElementRef,
@Inject(BOOTSTRAP_SERVICE_ID) private _bootstrapService: IBootstrapService @Inject(IBootstrapParams) private _params: IDashboardComponentParams
) { ) {
let parameters: DashboardComponentParams = this._bootstrapService.getBootstrapParams(this._el.nativeElement.tagName);
} }
} }
@@ -3,14 +3,16 @@
* Licensed under the Source EULA. See License.txt in the project root for license information. * Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { NgModule, Inject, forwardRef, ApplicationRef, ComponentFactoryResolver } from '@angular/core'; import { NgModule, Inject, forwardRef, ApplicationRef, ComponentFactoryResolver, Type } from '@angular/core';
import { APP_BASE_HREF, CommonModule } from '@angular/common'; import { APP_BASE_HREF, CommonModule } from '@angular/common';
import { BrowserModule } from '@angular/platform-browser'; import { BrowserModule } from '@angular/platform-browser';
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService'; import { IBootstrapParams } from 'sql/services/bootstrap/bootstrapService';
import { CreateLoginComponent, CREATELOGIN_SELECTOR } from 'sql/parts/admin/security/createLogin.component'; import { CreateLoginComponent, CREATELOGIN_SELECTOR } from 'sql/parts/admin/security/createLogin.component';
// Connection Dashboard main angular module // Connection Dashboard main angular module
export const CreateLoginModule = (params: IBootstrapParams, selector: string): Type<any> => {
@NgModule({ @NgModule({
declarations: [ declarations: [
CreateLoginComponent CreateLoginComponent
@@ -20,20 +22,24 @@ import { CreateLoginComponent, CREATELOGIN_SELECTOR } from 'sql/parts/admin/secu
CommonModule, CommonModule,
BrowserModule BrowserModule
], ],
providers: [{ provide: APP_BASE_HREF, useValue: '/' }] providers: [
{ provide: APP_BASE_HREF, useValue: '/' },
{ provide: IBootstrapParams, useValue: params }
]
}) })
export class CreateLoginModule { class ModuleClass {
constructor( constructor(
@Inject(forwardRef(() => ComponentFactoryResolver)) private _resolver: ComponentFactoryResolver, @Inject(forwardRef(() => ComponentFactoryResolver)) private _resolver: ComponentFactoryResolver
@Inject(BOOTSTRAP_SERVICE_ID) private _bootstrapService: IBootstrapService
) { ) {
} }
ngDoBootstrap(appRef: ApplicationRef) { ngDoBootstrap(appRef: ApplicationRef) {
const factory = this._resolver.resolveComponentFactory(CreateLoginComponent); const factory = this._resolver.resolveComponentFactory(CreateLoginComponent);
const uniqueSelector: string = this._bootstrapService.getUniqueSelector(CREATELOGIN_SELECTOR); (<any>factory).factory.selector = selector;
(<any>factory).factory.selector = uniqueSelector;
appRef.bootstrap(factory); appRef.bootstrap(factory);
} }
} }
return ModuleClass;
};
@@ -17,8 +17,7 @@ import { IConnectionManagementService } from 'sql/parts/connection/common/connec
import { IMetadataService } from 'sql/services/metadata/metadataService'; import { IMetadataService } from 'sql/services/metadata/metadataService';
import { IScriptingService } from 'sql/services/scripting/scriptingService'; import { IScriptingService } from 'sql/services/scripting/scriptingService';
import { IQueryEditorService } from 'sql/parts/query/common/queryEditorService'; import { IQueryEditorService } from 'sql/parts/query/common/queryEditorService';
import { IBootstrapService } from 'sql/services/bootstrap/bootstrapService'; import { bootstrapAngular, IBootstrapParams } from 'sql/services/bootstrap/bootstrapService';
import { BootstrapParams } from 'sql/services/bootstrap/bootstrapParams';
import { CREATELOGIN_SELECTOR } from 'sql/parts/admin/security/createLogin.component'; import { CREATELOGIN_SELECTOR } from 'sql/parts/admin/security/createLogin.component';
export class CreateLoginEditor extends BaseEditor { export class CreateLoginEditor extends BaseEditor {
@@ -32,8 +31,7 @@ export class CreateLoginEditor extends BaseEditor {
@IConnectionManagementService private _connectionService: IConnectionManagementService, @IConnectionManagementService private _connectionService: IConnectionManagementService,
@IMetadataService private _metadataService: IMetadataService, @IMetadataService private _metadataService: IMetadataService,
@IScriptingService private _scriptingService: IScriptingService, @IScriptingService private _scriptingService: IScriptingService,
@IQueryEditorService private _queryEditorService: IQueryEditorService, @IQueryEditorService private _queryEditorService: IQueryEditorService
@IBootstrapService private _bootstrapService: IBootstrapService
) { ) {
super(CreateLoginEditor.ID, telemetryService, themeService); super(CreateLoginEditor.ID, telemetryService, themeService);
} }
@@ -96,11 +94,11 @@ export class CreateLoginEditor extends BaseEditor {
private bootstrapAngular(input: CreateLoginInput): void { private bootstrapAngular(input: CreateLoginInput): void {
// Get the bootstrap params and perform the bootstrap // Get the bootstrap params and perform the bootstrap
let params: BootstrapParams = { let params: IBootstrapParams = {
connection: input.getConnectionProfile(), connection: input.getConnectionProfile(),
ownerUri: input.getUri() ownerUri: input.getUri()
}; };
let uniqueSelector = this._bootstrapService.bootstrap( let uniqueSelector = this.instantiationService.invokeFunction(bootstrapAngular,
CreateLoginModule, CreateLoginModule,
this.getContainer().getHTMLElement(), this.getContainer().getHTMLElement(),
CREATELOGIN_SELECTOR, CREATELOGIN_SELECTOR,
@@ -5,8 +5,10 @@
import * as types from 'vs/base/common/types'; import * as types from 'vs/base/common/types';
import { generateUuid } from 'vs/base/common/uuid'; import { generateUuid } from 'vs/base/common/uuid';
import { Registry } from 'vs/platform/registry/common/platform'; import { Registry } from 'vs/platform/registry/common/platform';
import { error } from 'sql/base/common/log';
import * as nls from 'vs/nls'; import * as nls from 'vs/nls';
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { error } from 'sql/base/common/log';
import { WidgetConfig } from 'sql/parts/dashboard/common/dashboardWidget'; import { WidgetConfig } from 'sql/parts/dashboard/common/dashboardWidget';
import { Extensions, IInsightRegistry } from 'sql/platform/dashboard/common/insightRegistry'; import { Extensions, IInsightRegistry } from 'sql/platform/dashboard/common/insightRegistry';
import { ConnectionManagementInfo } from 'sql/parts/connection/common/connectionManagementInfo'; import { ConnectionManagementInfo } from 'sql/parts/connection/common/connectionManagementInfo';
@@ -19,7 +21,7 @@ import { CONTROLHOST_CONTAINER } from 'sql/parts/dashboard/containers/dashboardC
import { NAV_SECTION } from 'sql/parts/dashboard/containers/dashboardNavSection.contribution'; import { NAV_SECTION } from 'sql/parts/dashboard/containers/dashboardNavSection.contribution';
import { IDashboardContainerRegistry, Extensions as DashboardContainerExtensions, IDashboardContainer, registerContainerType } from 'sql/platform/dashboard/common/dashboardContainerRegistry'; import { IDashboardContainerRegistry, Extensions as DashboardContainerExtensions, IDashboardContainer, registerContainerType } from 'sql/platform/dashboard/common/dashboardContainerRegistry';
import { IDashboardTab } from 'sql/platform/dashboard/common/dashboardRegistry'; import { IDashboardTab } from 'sql/platform/dashboard/common/dashboardRegistry';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { SingleConnectionManagementService } from 'sql/services/common/commonServiceInterface.service';
const dashboardcontainerRegistry = Registry.as<IDashboardContainerRegistry>(DashboardContainerExtensions.dashboardContainerContributions); const dashboardcontainerRegistry = Registry.as<IDashboardContainerRegistry>(DashboardContainerExtensions.dashboardContainerContributions);
const containerTypes = [ const containerTypes = [
@@ -118,8 +120,8 @@ export function initExtensionConfigs(configurations: WidgetConfig[]): Array<Widg
* Add provider to the passed widgets and returns the new widgets * Add provider to the passed widgets and returns the new widgets
* @param widgets Array of widgets to add provider onto * @param widgets Array of widgets to add provider onto
*/ */
export function addProvider(config: WidgetConfig[], dashboardService: DashboardServiceInterface): Array<WidgetConfig> { export function addProvider<T extends { connectionManagementService: SingleConnectionManagementService }>(config: WidgetConfig[], collection: T): Array<WidgetConfig> {
let provider = dashboardService.connectionManagementService.connectionInfo.providerId; let provider = collection.connectionManagementService.connectionInfo.providerId;
return config.map((item) => { return config.map((item) => {
if (item.provider === undefined) { if (item.provider === undefined) {
item.provider = provider; item.provider = provider;
@@ -132,8 +134,8 @@ export function addProvider(config: WidgetConfig[], dashboardService: DashboardS
* Adds the edition to the passed widgets and returns the new widgets * Adds the edition to the passed widgets and returns the new widgets
* @param widgets Array of widgets to add edition onto * @param widgets Array of widgets to add edition onto
*/ */
export function addEdition(config: WidgetConfig[], dashboardService: DashboardServiceInterface): Array<WidgetConfig> { export function addEdition<T extends { connectionManagementService: SingleConnectionManagementService }>(config: WidgetConfig[], collection: DashboardServiceInterface): Array<WidgetConfig> {
let connectionInfo: ConnectionManagementInfo = dashboardService.connectionManagementService.connectionInfo; let connectionInfo: ConnectionManagementInfo = collection.connectionManagementService.connectionInfo;
let edition = connectionInfo.serverInfo.engineEditionId; let edition = connectionInfo.serverInfo.engineEditionId;
return config.map((item) => { return config.map((item) => {
if (item.edition === undefined) { if (item.edition === undefined) {
@@ -147,7 +149,7 @@ export function addEdition(config: WidgetConfig[], dashboardService: DashboardSe
* Adds the context to the passed widgets and returns the new widgets * Adds the context to the passed widgets and returns the new widgets
* @param widgets Array of widgets to add context to * @param widgets Array of widgets to add context to
*/ */
export function addContext(config: WidgetConfig[], dashboardServer: DashboardServiceInterface, context: string): Array<WidgetConfig> { export function addContext(config: WidgetConfig[], collection: any, context: string): Array<WidgetConfig> {
return config.map((item) => { return config.map((item) => {
if (item.context === undefined) { if (item.context === undefined) {
item.context = context; item.context = context;
@@ -160,12 +162,12 @@ export function addContext(config: WidgetConfig[], dashboardServer: DashboardSer
* Returns a filtered version of the widgets passed based on edition and provider * Returns a filtered version of the widgets passed based on edition and provider
* @param config widgets to filter * @param config widgets to filter
*/ */
export function filterConfigs<T extends { when?: string }>(config: T[], dashboardService: DashboardServiceInterface): Array<T> { export function filterConfigs<T extends { when?: string }, K extends { contextKeyService: IContextKeyService }>(config: T[], collection: K): Array<T> {
return config.filter((item) => { return config.filter((item) => {
if (!item.when) { if (!item.when) {
return true; return true;
} else { } else {
return dashboardService.contextKeyService.contextMatchesRules(ContextKeyExpr.deserialize(item.when)); return collection.contextKeyService.contextMatchesRules(ContextKeyExpr.deserialize(item.when));
} }
}); });
} }
@@ -9,7 +9,7 @@ import 'sql/parts/dashboard/common/dashboardPanelStyles';
import { Component, Inject, forwardRef, ViewChild, ElementRef, ViewChildren, QueryList, OnDestroy, ChangeDetectorRef } from '@angular/core'; import { Component, Inject, forwardRef, ViewChild, ElementRef, ViewChildren, QueryList, OnDestroy, ChangeDetectorRef } from '@angular/core';
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service'; import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service'; import { CommonServiceInterface, SingleConnectionManagementService } from 'sql/services/common/commonServiceInterface.service';
import { WidgetConfig, TabConfig, TabSettingConfig } from 'sql/parts/dashboard/common/dashboardWidget'; import { WidgetConfig, TabConfig, TabSettingConfig } from 'sql/parts/dashboard/common/dashboardWidget';
import { Extensions, IInsightRegistry } from 'sql/platform/dashboard/common/insightRegistry'; import { Extensions, IInsightRegistry } from 'sql/platform/dashboard/common/insightRegistry';
import { DashboardWidgetWrapper } from 'sql/parts/dashboard/contents/dashboardWidgetWrapper.component'; import { DashboardWidgetWrapper } from 'sql/parts/dashboard/contents/dashboardWidgetWrapper.component';
@@ -18,8 +18,7 @@ import { PanelComponent } from 'sql/base/browser/ui/panel/panel.component';
import { IDashboardRegistry, Extensions as DashboardExtensions, IDashboardTab } from 'sql/platform/dashboard/common/dashboardRegistry'; import { IDashboardRegistry, Extensions as DashboardExtensions, IDashboardTab } from 'sql/platform/dashboard/common/dashboardRegistry';
import { PinUnpinTabAction, AddFeatureTabAction } from './actions'; import { PinUnpinTabAction, AddFeatureTabAction } from './actions';
import { TabComponent, TabChild } from 'sql/base/browser/ui/panel/tab.component'; import { TabComponent, TabChild } from 'sql/base/browser/ui/panel/tab.component';
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService'; import { AngularEventType, IAngularEventingService } from 'sql/services/angularEventing/angularEventingService';
import { AngularEventType } from 'sql/services/angularEventing/angularEventingService';
import { DashboardTab } from 'sql/parts/dashboard/common/interfaces'; import { DashboardTab } from 'sql/parts/dashboard/common/interfaces';
import * as dashboardHelper from 'sql/parts/dashboard/common/dashboardHelper'; import * as dashboardHelper from 'sql/parts/dashboard/common/dashboardHelper';
import { WIDGETS_CONTAINER } from 'sql/parts/dashboard/containers/dashboardWidgetContainer.contribution'; import { WIDGETS_CONTAINER } from 'sql/parts/dashboard/containers/dashboardWidgetContainer.contribution';
@@ -40,9 +39,16 @@ import Event, { Emitter } from 'vs/base/common/event';
import { Action } from 'vs/base/common/actions'; import { Action } from 'vs/base/common/actions';
import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration'; import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
import Severity from 'vs/base/common/severity'; import Severity from 'vs/base/common/severity';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
const dashboardRegistry = Registry.as<IDashboardRegistry>(DashboardExtensions.DashboardContributions); const dashboardRegistry = Registry.as<IDashboardRegistry>(DashboardExtensions.DashboardContributions);
interface IConfigModifierCollection {
connectionManagementService: SingleConnectionManagementService;
contextKeyService: IContextKeyService;
}
@Component({ @Component({
selector: 'dashboard-page', selector: 'dashboard-page',
@@ -71,7 +77,7 @@ export abstract class DashboardPage extends AngularDisposable {
private readonly homeTabTitle: string = nls.localize('home', 'Home'); private readonly homeTabTitle: string = nls.localize('home', 'Home');
// a set of config modifiers // a set of config modifiers
private readonly _configModifiers: Array<(item: Array<WidgetConfig>, dashboardServer: DashboardServiceInterface, context: string) => Array<WidgetConfig>> = [ private readonly _configModifiers: Array<(item: Array<WidgetConfig>, collection: IConfigModifierCollection, context: string) => Array<WidgetConfig>> = [
dashboardHelper.removeEmpty, dashboardHelper.removeEmpty,
dashboardHelper.initExtensionConfigs, dashboardHelper.initExtensionConfigs,
dashboardHelper.addProvider, dashboardHelper.addProvider,
@@ -80,27 +86,36 @@ export abstract class DashboardPage extends AngularDisposable {
dashboardHelper.filterConfigs dashboardHelper.filterConfigs
]; ];
public get connectionManagementService(): SingleConnectionManagementService {
return this.dashboardService.connectionManagementService;
}
public get contextKeyService(): IContextKeyService {
return this.dashboardService.scopedContextKeyService;
}
private readonly _gridModifiers: Array<(item: Array<WidgetConfig>, originalConfig: Array<WidgetConfig>) => Array<WidgetConfig>> = [ private readonly _gridModifiers: Array<(item: Array<WidgetConfig>, originalConfig: Array<WidgetConfig>) => Array<WidgetConfig>> = [
dashboardHelper.validateGridConfig dashboardHelper.validateGridConfig
]; ];
protected abstract propertiesWidget: WidgetConfig; protected abstract propertiesWidget: WidgetConfig;
protected abstract get context(): string; protected abstract get context(): string;
protected dashboardService: DashboardServiceInterface;
constructor( constructor(
@Inject(forwardRef(() => CommonServiceInterface)) protected commonService: CommonServiceInterface, @Inject(forwardRef(() => CommonServiceInterface)) protected dashboardService: DashboardServiceInterface,
@Inject(forwardRef(() => ElementRef)) protected _el: ElementRef, @Inject(forwardRef(() => ElementRef)) protected _el: ElementRef,
@Inject(forwardRef(() => ChangeDetectorRef)) protected _cd: ChangeDetectorRef @Inject(forwardRef(() => ChangeDetectorRef)) protected _cd: ChangeDetectorRef,
@Inject(IInstantiationService) private instantiationService: IInstantiationService,
@Inject(INotificationService) private notificationService: INotificationService,
@Inject(IAngularEventingService) private angularEventingService: IAngularEventingService
) { ) {
super(); super();
this.dashboardService = commonService as DashboardServiceInterface;
} }
protected init() { protected init() {
this.dashboardService.dashboardContextKey.set(this.context); this.dashboardService.dashboardContextKey.set(this.context);
if (!this.dashboardService.connectionManagementService.connectionInfo) { if (!this.dashboardService.connectionManagementService.connectionInfo) {
this.dashboardService.notificationService.notify({ this.notificationService.notify({
severity: Severity.Error, severity: Severity.Error,
message: nls.localize('missingConnectionInfo', 'No connection information could be found for this dashboard') message: nls.localize('missingConnectionInfo', 'No connection information could be found for this dashboard')
}); });
@@ -110,8 +125,8 @@ export abstract class DashboardPage extends AngularDisposable {
this._originalConfig = objects.deepClone(tempWidgets); this._originalConfig = objects.deepClone(tempWidgets);
let properties = this.getProperties(); let properties = this.getProperties();
this._configModifiers.forEach((cb) => { this._configModifiers.forEach((cb) => {
tempWidgets = cb.apply(this, [tempWidgets, this.dashboardService, this.context]); tempWidgets = cb.apply(this, [tempWidgets, this, this.context]);
properties = properties ? cb.apply(this, [properties, this.dashboardService, this.context]) : undefined; properties = properties ? cb.apply(this, [properties, this, this.context]) : undefined;
}); });
this._gridModifiers.forEach(cb => { this._gridModifiers.forEach(cb => {
tempWidgets = cb.apply(this, [tempWidgets, this._originalConfig]); tempWidgets = cb.apply(this, [tempWidgets, this._originalConfig]);
@@ -143,7 +158,7 @@ export abstract class DashboardPage extends AngularDisposable {
}; };
this.addNewTab(homeTab); this.addNewTab(homeTab);
let allTabs = dashboardHelper.filterConfigs(dashboardRegistry.tabs, this.dashboardService); let allTabs = dashboardHelper.filterConfigs(dashboardRegistry.tabs, this);
// Load tab setting configs // Load tab setting configs
this._tabSettingConfigs = this.dashboardService.getSettings<Array<TabSettingConfig>>([this.context, 'tabs'].join('.')); this._tabSettingConfigs = this.dashboardService.getSettings<Array<TabSettingConfig>>([this.context, 'tabs'].join('.'));
@@ -171,7 +186,7 @@ export abstract class DashboardPage extends AngularDisposable {
// Set panel actions // Set panel actions
let openedTabs = [...pinnedDashboardTabs, ...alwaysShowTabs]; let openedTabs = [...pinnedDashboardTabs, ...alwaysShowTabs];
let addNewTabAction = this.dashboardService.instantiationService.createInstance(AddFeatureTabAction, allTabs, openedTabs, this.dashboardService.getUnderlyingUri()); let addNewTabAction = this.instantiationService.createInstance(AddFeatureTabAction, allTabs, openedTabs, this.dashboardService.getUnderlyingUri());
this._tabsDispose.push(addNewTabAction); this._tabsDispose.push(addNewTabAction);
this.panelActions = [addNewTabAction]; this.panelActions = [addNewTabAction];
this._cd.detectChanges(); this._cd.detectChanges();
@@ -232,7 +247,7 @@ export abstract class DashboardPage extends AngularDisposable {
} else if (v.alwaysShow) { } else if (v.alwaysShow) {
isPinned = true; isPinned = true;
} }
actions.push(this.dashboardService.instantiationService.createInstance(PinUnpinTabAction, v.id, this.dashboardService.getUnderlyingUri(), isPinned)); actions.push(this.instantiationService.createInstance(PinUnpinTabAction, v.id, this.dashboardService.getUnderlyingUri(), isPinned));
let config = v as TabConfig; let config = v as TabConfig;
config.context = this.context; config.context = this.context;
@@ -318,6 +333,6 @@ export abstract class DashboardPage extends AngularDisposable {
let index = this.tabs.findIndex(i => i.id === tab.identifier); let index = this.tabs.findIndex(i => i.id === tab.identifier);
this.tabs.splice(index, 1); this.tabs.splice(index, 1);
this._cd.detectChanges(); this._cd.detectChanges();
this.dashboardService.angularEventingService.sendAngularEvent(this.dashboardService.getUnderlyingUri(), AngularEventType.CLOSE_TAB, { id: tab.identifier }); this.angularEventingService.sendAngularEvent(this.dashboardService.getUnderlyingUri(), AngularEventType.CLOSE_TAB, { id: tab.identifier });
} }
} }
@@ -12,12 +12,12 @@ import { DashboardTab } from 'sql/parts/dashboard/common/interfaces';
import { WidgetConfig } from 'sql/parts/dashboard/common/dashboardWidget'; import { WidgetConfig } from 'sql/parts/dashboard/common/dashboardWidget';
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service'; import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service'; import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
import { AngularEventType } from 'sql/services/angularEventing/angularEventingService'; import { AngularEventType, IAngularEventingService } from 'sql/services/angularEventing/angularEventingService';
import { DashboardWidgetWrapper } from 'sql/parts/dashboard/contents/dashboardWidgetWrapper.component'; import { DashboardWidgetWrapper } from 'sql/parts/dashboard/contents/dashboardWidgetWrapper.component';
import { ScrollableDirective } from 'sql/base/browser/ui/scrollable/scrollable.directive'; import { ScrollableDirective } from 'sql/base/browser/ui/scrollable/scrollable.directive';
import { TabChild } from 'sql/base/browser/ui/panel/tab.component'; import { TabChild } from 'sql/base/browser/ui/panel/tab.component';
import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration'; import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ScrollbarVisibility } from 'vs/base/common/scrollable'; import { ScrollbarVisibility } from 'vs/base/common/scrollable';
@Component({ @Component({
@@ -44,7 +44,9 @@ export class DashboardHomeContainer extends DashboardWidgetContainer {
constructor( constructor(
@Inject(forwardRef(() => ChangeDetectorRef)) _cd: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) _cd: ChangeDetectorRef,
@Inject(forwardRef(() => CommonServiceInterface)) protected dashboardService: DashboardServiceInterface @Inject(forwardRef(() => CommonServiceInterface)) protected dashboardService: DashboardServiceInterface,
@Inject(IConfigurationService) private _configurationService: IConfigurationService,
@Inject(IAngularEventingService) private angularEventingService: IAngularEventingService
) { ) {
super(_cd); super(_cd);
} }
@@ -54,14 +56,12 @@ export class DashboardHomeContainer extends DashboardWidgetContainer {
if (collapsedVal === 'collapsed') { if (collapsedVal === 'collapsed') {
this._propertiesClass.collapsed = true; this._propertiesClass.collapsed = true;
} }
this.dashboardService.angularEventingService.onAngularEvent(this.dashboardService.getUnderlyingUri(), event => { this.angularEventingService.onAngularEvent(this.dashboardService.getUnderlyingUri(), event => {
if (event.event === AngularEventType.COLLAPSE_WIDGET && this._propertiesClass && event.payload === this._propertiesClass.guid) { if (event.event === AngularEventType.COLLAPSE_WIDGET && this._propertiesClass && event.payload === this._propertiesClass.guid) {
this._propertiesClass.collapsed = !this._propertiesClass.collapsed; this._propertiesClass.collapsed = !this._propertiesClass.collapsed;
this._cd.detectChanges(); this._cd.detectChanges();
this.dashboardService.configurationEditingService.writeConfiguration(ConfigurationTarget.USER, { this._configurationService.updateValue(`dashboard.${this.properties.context}.properties`,
key: `dashboard.${this.properties.context}.properties`, this._propertiesClass.collapsed ? 'collapsed' : true, ConfigurationTarget.USER);
value: this._propertiesClass.collapsed ? 'collapsed' : true
});
} }
}); });
} }
@@ -28,7 +28,7 @@ import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboar
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service'; import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
import { IDisposable } from 'vs/base/common/lifecycle'; import { IDisposable } from 'vs/base/common/lifecycle';
import { IColorTheme } from 'vs/workbench/services/themes/common/workbenchThemeService'; import { IColorTheme, IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import * as colors from 'vs/platform/theme/common/colorRegistry'; import * as colors from 'vs/platform/theme/common/colorRegistry';
import * as themeColors from 'vs/workbench/common/theme'; import * as themeColors from 'vs/workbench/common/theme';
import { Action } from 'vs/base/common/actions'; import { Action } from 'vs/base/common/actions';
@@ -37,6 +37,7 @@ import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import { memoize } from 'vs/base/common/decorators'; import { memoize } from 'vs/base/common/decorators';
import { generateUuid } from 'vs/base/common/uuid'; import { generateUuid } from 'vs/base/common/uuid';
import { Emitter } from 'vs/base/common/event'; import { Emitter } from 'vs/base/common/event';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
const componentMap: { [x: string]: Type<IDashboardWidget> } = { const componentMap: { [x: string]: Type<IDashboardWidget> } = {
'properties-widget': PropertiesWidgetComponent, 'properties-widget': PropertiesWidgetComponent,
@@ -91,20 +92,22 @@ export class DashboardWidgetWrapper extends AngularDisposable implements OnInit
@Inject(forwardRef(() => ElementRef)) private _ref: ElementRef, @Inject(forwardRef(() => ElementRef)) private _ref: ElementRef,
@Inject(forwardRef(() => CommonServiceInterface)) private _bootstrap: CommonServiceInterface, @Inject(forwardRef(() => CommonServiceInterface)) private _bootstrap: CommonServiceInterface,
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeref: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) private _changeref: ChangeDetectorRef,
@Inject(forwardRef(() => Injector)) private _injector: Injector @Inject(forwardRef(() => Injector)) private _injector: Injector,
@Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService,
@Inject(IInstantiationService) private instantiationService: IInstantiationService
) { ) {
super(); super();
} }
ngOnInit() { ngOnInit() {
let self = this; let self = this;
this._register(self._bootstrap.themeService.onDidColorThemeChange((event: IColorTheme) => { this._register(self.themeService.onDidColorThemeChange((event: IColorTheme) => {
self.updateTheme(event); self.updateTheme(event);
})); }));
} }
ngAfterViewInit() { ngAfterViewInit() {
this.updateTheme(this._bootstrap.themeService.getColorTheme()); this.updateTheme(this.themeService.getColorTheme());
if (this.componentHost) { if (this.componentHost) {
this.loadWidget(); this.loadWidget();
} }
@@ -112,10 +115,10 @@ export class DashboardWidgetWrapper extends AngularDisposable implements OnInit
this._actionbar = new ActionBar(this._actionbarRef.nativeElement); this._actionbar = new ActionBar(this._actionbarRef.nativeElement);
if (this._actions) { if (this._actions) {
if (this.collapsable) { if (this.collapsable) {
this._collapseAction = this._bootstrap.instantiationService.createInstance(CollapseWidgetAction, this._bootstrap.getUnderlyingUri(), this.guid, this.collapsed); this._collapseAction = this.instantiationService.createInstance(CollapseWidgetAction, this._bootstrap.getUnderlyingUri(), this.guid, this.collapsed);
this._actionbar.push(this._collapseAction, { icon: true, label: false }); this._actionbar.push(this._collapseAction, { icon: true, label: false });
} }
this._actionbar.push(this._bootstrap.instantiationService.createInstance(ToggleMoreWidgetAction, this._actions, this._component.actionsContext), { icon: true, label: false }); this._actionbar.push(this.instantiationService.createInstance(ToggleMoreWidgetAction, this._actions, this._component.actionsContext), { icon: true, label: false });
} }
this.layout(); this.layout();
} }
@@ -137,7 +140,7 @@ export class DashboardWidgetWrapper extends AngularDisposable implements OnInit
} }
public enableEdit(): void { public enableEdit(): void {
this._actionbar.push(this._bootstrap.instantiationService.createInstance(DeleteWidgetAction, this._config.id, this._bootstrap.getUnderlyingUri()), { icon: true, label: false }); this._actionbar.push(this.instantiationService.createInstance(DeleteWidgetAction, this._config.id, this._bootstrap.getUnderlyingUri()), { icon: true, label: false });
} }
public disableEdit(): void { public disableEdit(): void {
@@ -8,15 +8,18 @@ import { Component, forwardRef, Input, OnInit, Inject, ChangeDetectorRef, Elemen
import Event, { Emitter } from 'vs/base/common/event'; import Event, { Emitter } from 'vs/base/common/event';
import { Webview } from 'vs/workbench/parts/html/browser/webview'; import { Webview } from 'vs/workbench/parts/html/browser/webview';
import { Parts } from 'vs/workbench/services/part/common/partService'; import { Parts, IPartService } from 'vs/workbench/services/part/common/partService';
import { IDisposable, Disposable } from 'vs/base/common/lifecycle'; import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
import { addDisposableListener, EventType } from 'vs/base/browser/dom'; import { addDisposableListener, EventType } from 'vs/base/browser/dom';
import { memoize } from 'vs/base/common/decorators'; import { memoize } from 'vs/base/common/decorators';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { TabConfig } from 'sql/parts/dashboard/common/dashboardWidget'; import { TabConfig } from 'sql/parts/dashboard/common/dashboardWidget';
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service'; import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service'; import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
import { IDashboardWebview } from 'sql/services/dashboard/common/dashboardViewService'; import { IDashboardWebview, IDashboardViewService } from 'sql/services/dashboard/common/dashboardViewService';
import { AngularDisposable } from 'sql/base/common/lifecycle'; import { AngularDisposable } from 'sql/base/common/lifecycle';
import * as sqlops from 'sqlops'; import * as sqlops from 'sqlops';
@@ -40,13 +43,18 @@ export class WebviewContent extends AngularDisposable implements OnInit, IDashbo
constructor( constructor(
@Inject(forwardRef(() => CommonServiceInterface)) private _dashboardService: DashboardServiceInterface, @Inject(forwardRef(() => CommonServiceInterface)) private _dashboardService: DashboardServiceInterface,
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef,
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef @Inject(forwardRef(() => ElementRef)) private _el: ElementRef,
@Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService,
@Inject(IContextViewService) private contextViewService: IContextViewService,
@Inject(IDashboardViewService) private dashboardViewService: IDashboardViewService,
@Inject(IPartService) private partService: IPartService,
@Inject(IEnvironmentService) private environmentService: IEnvironmentService
) { ) {
super(); super();
} }
ngOnInit() { ngOnInit() {
this._dashboardService.dashboardViewService.registerWebview(this); this.dashboardViewService.registerWebview(this);
this._createWebview(); this._createWebview();
this._register(addDisposableListener(window, EventType.RESIZE, e => { this._register(addDisposableListener(window, EventType.RESIZE, e => {
this.layout(); this.layout();
@@ -101,10 +109,10 @@ export class WebviewContent extends AngularDisposable implements OnInit, IDashbo
} }
this._webview = new Webview(this._el.nativeElement, this._webview = new Webview(this._el.nativeElement,
this._dashboardService.partService.getContainer(Parts.EDITOR_PART), this.partService.getContainer(Parts.EDITOR_PART),
this._dashboardService.themeService, this.themeService,
this._dashboardService.environmentService, this.environmentService,
this._dashboardService.contextViewService, this.contextViewService,
undefined, undefined,
undefined, undefined,
{ {
@@ -117,7 +125,7 @@ export class WebviewContent extends AngularDisposable implements OnInit, IDashbo
this._onMessageDisposable = this._webview.onMessage(e => { this._onMessageDisposable = this._webview.onMessage(e => {
this._onMessage.fire(e); this._onMessage.fire(e);
}); });
this._webview.style(this._dashboardService.themeService.getTheme()); this._webview.style(this.themeService.getTheme());
if (this._html) { if (this._html) {
this._webview.contents = this._html; this._webview.contents = this._html;
} }
@@ -16,7 +16,7 @@ import { RefreshWidgetAction, EditDashboardAction } from 'sql/parts/dashboard/co
import { DashboardPage } from 'sql/parts/dashboard/common/dashboardPage.component'; import { DashboardPage } from 'sql/parts/dashboard/common/dashboardPage.component';
import { AngularDisposable } from 'sql/base/common/lifecycle'; import { AngularDisposable } from 'sql/base/common/lifecycle';
import { IColorTheme } from 'vs/workbench/services/themes/common/workbenchThemeService'; import { IColorTheme, IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { IDisposable } from 'vs/base/common/lifecycle'; import { IDisposable } from 'vs/base/common/lifecycle';
import * as themeColors from 'vs/workbench/common/theme'; import * as themeColors from 'vs/workbench/common/theme';
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar'; import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
@@ -39,14 +39,15 @@ export class DashboardComponent extends AngularDisposable implements OnInit {
constructor( constructor(
@Inject(forwardRef(() => CommonServiceInterface)) private _bootstrapService: CommonServiceInterface, @Inject(forwardRef(() => CommonServiceInterface)) private _bootstrapService: CommonServiceInterface,
@Inject(forwardRef(() => Router)) private _router: Router, @Inject(forwardRef(() => Router)) private _router: Router,
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef @Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef,
@Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService
) { ) {
super(); super();
} }
ngOnInit() { ngOnInit() {
this._register(this._bootstrapService.themeService.onDidColorThemeChange(this.updateTheme, this)); this._register(this.themeService.onDidColorThemeChange(this.updateTheme, this));
this.updateTheme(this._bootstrapService.themeService.getColorTheme()); this.updateTheme(this.themeService.getColorTheme());
let profile: IConnectionProfile = this._bootstrapService.getOriginalConnectionProfile(); let profile: IConnectionProfile = this._bootstrapService.getOriginalConnectionProfile();
this.actionbar = new ActionBar(this.actionbarContainer.nativeElement); this.actionbar = new ActionBar(this.actionbarContainer.nativeElement);
this.actionbar.push(new RefreshWidgetAction(this.refresh, this), { this.actionbar.push(new RefreshWidgetAction(this.refresh, this), {
+14 -10
View File
@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information. * Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { Inject, NgModule, forwardRef, ApplicationRef, ComponentFactoryResolver } from '@angular/core'; import { Inject, NgModule, forwardRef, ApplicationRef, ComponentFactoryResolver, NgModuleRef, NgModuleFactory } from '@angular/core';
import { CommonModule, APP_BASE_HREF } from '@angular/common'; import { CommonModule, APP_BASE_HREF } from '@angular/common';
import { BrowserModule } from '@angular/platform-browser'; import { BrowserModule } from '@angular/platform-browser';
import { RouterModule, Routes, UrlSerializer, Router, NavigationEnd } from '@angular/router'; import { RouterModule, Routes, UrlSerializer, Router, NavigationEnd } from '@angular/router';
@@ -12,9 +12,9 @@ import { NgGridModule } from 'angular2-grid';
import { ChartsModule } from 'ng2-charts/ng2-charts'; import { ChartsModule } from 'ng2-charts/ng2-charts';
import CustomUrlSerializer from 'sql/common/urlSerializer'; import CustomUrlSerializer from 'sql/common/urlSerializer';
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService';
import { Extensions, IInsightRegistry } from 'sql/platform/dashboard/common/insightRegistry'; import { Extensions, IInsightRegistry } from 'sql/platform/dashboard/common/insightRegistry';
import { Extensions as ComponentExtensions, IComponentRegistry } from 'sql/platform/dashboard/common/modelComponentRegistry'; import { Extensions as ComponentExtensions, IComponentRegistry } from 'sql/platform/dashboard/common/modelComponentRegistry';
import { IBootstrapParams } from 'sql/services/bootstrap/bootstrapService';
import { Registry } from 'vs/platform/registry/common/platform'; import { Registry } from 'vs/platform/registry/common/platform';
@@ -104,6 +104,7 @@ const appRoutes: Routes = [
]; ];
// Connection Dashboard main angular module // Connection Dashboard main angular module
export const DashboardModule = (params, selector: string): any => {
@NgModule({ @NgModule({
declarations: [ declarations: [
...baseComponents, ...baseComponents,
@@ -133,31 +134,31 @@ const appRoutes: Routes = [
{ provide: APP_BASE_HREF, useValue: '/' }, { provide: APP_BASE_HREF, useValue: '/' },
{ provide: IBreadcrumbService, useClass: BreadcrumbService }, { provide: IBreadcrumbService, useClass: BreadcrumbService },
{ provide: CommonServiceInterface, useClass: DashboardServiceInterface }, { provide: CommonServiceInterface, useClass: DashboardServiceInterface },
{ provide: UrlSerializer, useClass: CustomUrlSerializer } { provide: UrlSerializer, useClass: CustomUrlSerializer },
{ provide: IBootstrapParams, useValue: params }
] ]
}) })
export class DashboardModule { class ModuleClass {
private _bootstrap: DashboardServiceInterface; private _bootstrap: DashboardServiceInterface;
constructor( constructor(
@Inject(forwardRef(() => ComponentFactoryResolver)) private _resolver: ComponentFactoryResolver, @Inject(forwardRef(() => ComponentFactoryResolver)) private _resolver: ComponentFactoryResolver,
@Inject(BOOTSTRAP_SERVICE_ID) private _bootstrapService: IBootstrapService,
@Inject(forwardRef(() => CommonServiceInterface)) bootstrap: CommonServiceInterface, @Inject(forwardRef(() => CommonServiceInterface)) bootstrap: CommonServiceInterface,
@Inject(forwardRef(() => Router)) private _router: Router @Inject(forwardRef(() => Router)) private _router: Router,
@Inject(ITelemetryService) private telemetryService: ITelemetryService
) { ) {
this._bootstrap = bootstrap as DashboardServiceInterface; this._bootstrap = bootstrap as DashboardServiceInterface;
} }
ngDoBootstrap(appRef: ApplicationRef) { ngDoBootstrap(appRef: ApplicationRef) {
const factory = this._resolver.resolveComponentFactory(DashboardComponent); const factory = this._resolver.resolveComponentFactory(DashboardComponent);
const uniqueSelector: string = this._bootstrapService.getUniqueSelector(DASHBOARD_SELECTOR); this._bootstrap.selector = selector;
this._bootstrap.selector = uniqueSelector; (<any>factory).factory.selector = selector;
(<any>factory).factory.selector = uniqueSelector;
appRef.bootstrap(factory); appRef.bootstrap(factory);
this._router.events.subscribe(e => { this._router.events.subscribe(e => {
if (e instanceof NavigationEnd) { if (e instanceof NavigationEnd) {
this._bootstrap.handlePageNavigation(); this._bootstrap.handlePageNavigation();
TelemetryUtils.addTelemetry(this._bootstrapService.telemetryService, TelemetryKeys.DashboardNavigated, { TelemetryUtils.addTelemetry(this.telemetryService, TelemetryKeys.DashboardNavigated, {
numberOfNavigations: this._bootstrap.getNumberOfPageNavigations(), numberOfNavigations: this._bootstrap.getNumberOfPageNavigations(),
routeUrl: e.url routeUrl: e.url
}); });
@@ -165,3 +166,6 @@ export class DashboardModule {
}); });
} }
} }
return ModuleClass;
};
+4 -5
View File
@@ -15,8 +15,8 @@ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { DashboardInput } from './dashboardInput'; import { DashboardInput } from './dashboardInput';
import { DashboardModule } from './dashboard.module'; import { DashboardModule } from './dashboard.module';
import { IBootstrapService } from 'sql/services/bootstrap/bootstrapService'; import { bootstrapAngular } from 'sql/services/bootstrap/bootstrapService';
import { DashboardComponentParams } from 'sql/services/bootstrap/bootstrapParams'; import { IDashboardComponentParams } from 'sql/services/bootstrap/bootstrapParams';
import { DASHBOARD_SELECTOR } from 'sql/parts/dashboard/dashboard.component'; import { DASHBOARD_SELECTOR } from 'sql/parts/dashboard/dashboard.component';
import { ConnectionContextkey } from 'sql/parts/connection/common/connectionContextKey'; import { ConnectionContextkey } from 'sql/parts/connection/common/connectionContextKey';
import { IDashboardService } from 'sql/services/dashboard/common/dashboardService'; import { IDashboardService } from 'sql/services/dashboard/common/dashboardService';
@@ -34,7 +34,6 @@ export class DashboardEditor extends BaseEditor {
@ITelemetryService telemetryService: ITelemetryService, @ITelemetryService telemetryService: ITelemetryService,
@IWorkbenchThemeService themeService: IWorkbenchThemeService, @IWorkbenchThemeService themeService: IWorkbenchThemeService,
@IInstantiationService private instantiationService: IInstantiationService, @IInstantiationService private instantiationService: IInstantiationService,
@IBootstrapService private _bootstrapService: IBootstrapService,
@IContextKeyService private _contextKeyService: IContextKeyService, @IContextKeyService private _contextKeyService: IContextKeyService,
@IDashboardService private _dashboardService: IDashboardService, @IDashboardService private _dashboardService: IDashboardService,
@IConnectionManagementService private _connMan: IConnectionManagementService @IConnectionManagementService private _connMan: IConnectionManagementService
@@ -114,7 +113,7 @@ export class DashboardEditor extends BaseEditor {
let connectionContextKey = new ConnectionContextkey(scopedContextService); let connectionContextKey = new ConnectionContextkey(scopedContextService);
connectionContextKey.set(input.connectionProfile); connectionContextKey.set(input.connectionProfile);
let params: DashboardComponentParams = { let params: IDashboardComponentParams = {
connection: input.connectionProfile, connection: input.connectionProfile,
ownerUri: input.uri, ownerUri: input.uri,
scopedContextService, scopedContextService,
@@ -123,7 +122,7 @@ export class DashboardEditor extends BaseEditor {
input.hasBootstrapped = true; input.hasBootstrapped = true;
let uniqueSelector = this._bootstrapService.bootstrap( let uniqueSelector = this.instantiationService.invokeFunction(bootstrapAngular,
DashboardModule, DashboardModule,
this._dashboardContainer, this._dashboardContainer,
DASHBOARD_SELECTOR, DASHBOARD_SELECTOR,
@@ -10,11 +10,14 @@ import { BreadcrumbClass } from 'sql/parts/dashboard/services/breadcrumb.service
import { IBreadcrumbService } from 'sql/base/browser/ui/breadcrumb/interfaces'; import { IBreadcrumbService } from 'sql/base/browser/ui/breadcrumb/interfaces';
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service'; import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
import { WidgetConfig } from 'sql/parts/dashboard/common/dashboardWidget'; import { WidgetConfig } from 'sql/parts/dashboard/common/dashboardWidget';
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService'; import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
import { IAngularEventingService } from 'sql/services/angularEventing/angularEventingService';
import * as colors from 'vs/platform/theme/common/colorRegistry'; import * as colors from 'vs/platform/theme/common/colorRegistry';
import * as nls from 'vs/nls'; import * as nls from 'vs/nls';
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
export class DatabaseDashboardPage extends DashboardPage implements OnInit { export class DatabaseDashboardPage extends DashboardPage implements OnInit {
protected propertiesWidget: WidgetConfig = { protected propertiesWidget: WidgetConfig = {
@@ -38,9 +41,12 @@ export class DatabaseDashboardPage extends DashboardPage implements OnInit {
@Inject(forwardRef(() => IBreadcrumbService)) private _breadcrumbService: IBreadcrumbService, @Inject(forwardRef(() => IBreadcrumbService)) private _breadcrumbService: IBreadcrumbService,
@Inject(forwardRef(() => CommonServiceInterface)) dashboardService: DashboardServiceInterface, @Inject(forwardRef(() => CommonServiceInterface)) dashboardService: DashboardServiceInterface,
@Inject(forwardRef(() => ChangeDetectorRef)) _cd: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) _cd: ChangeDetectorRef,
@Inject(forwardRef(() => ElementRef)) el: ElementRef @Inject(forwardRef(() => ElementRef)) el: ElementRef,
@Inject(IInstantiationService) instantiationService: IInstantiationService,
@Inject(INotificationService) notificationService: INotificationService,
@Inject(IAngularEventingService) angularEventingService: IAngularEventingService
) { ) {
super(dashboardService, el, _cd); super(dashboardService, el, _cd, instantiationService, notificationService, angularEventingService);
this._register(dashboardService.onUpdatePage(() => { this._register(dashboardService.onUpdatePage(() => {
this.refresh(true); this.refresh(true);
this._cd.detectChanges(); this._cd.detectChanges();
@@ -11,10 +11,13 @@ import { IBreadcrumbService } from 'sql/base/browser/ui/breadcrumb/interfaces';
import { WidgetConfig } from 'sql/parts/dashboard/common/dashboardWidget'; import { WidgetConfig } from 'sql/parts/dashboard/common/dashboardWidget';
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service'; import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service'; import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService'; import { IAngularEventingService } from 'sql/services/angularEventing/angularEventingService';
import * as colors from 'vs/platform/theme/common/colorRegistry'; import * as colors from 'vs/platform/theme/common/colorRegistry';
import * as nls from 'vs/nls'; import * as nls from 'vs/nls';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
export class ServerDashboardPage extends DashboardPage implements OnInit { export class ServerDashboardPage extends DashboardPage implements OnInit {
protected propertiesWidget: WidgetConfig = { protected propertiesWidget: WidgetConfig = {
@@ -37,11 +40,14 @@ export class ServerDashboardPage extends DashboardPage implements OnInit {
constructor( constructor(
@Inject(forwardRef(() => IBreadcrumbService)) private breadcrumbService: IBreadcrumbService, @Inject(forwardRef(() => IBreadcrumbService)) private breadcrumbService: IBreadcrumbService,
@Inject(forwardRef(() => CommonServiceInterface)) dashboardService: CommonServiceInterface, @Inject(forwardRef(() => CommonServiceInterface)) dashboardService: DashboardServiceInterface,
@Inject(forwardRef(() => ChangeDetectorRef)) _cd: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) _cd: ChangeDetectorRef,
@Inject(forwardRef(() => ElementRef)) el: ElementRef @Inject(forwardRef(() => ElementRef)) el: ElementRef,
@Inject(IInstantiationService) instantiationService: IInstantiationService,
@Inject(INotificationService) notificationService: INotificationService,
@Inject(IAngularEventingService) angularEventingService: IAngularEventingService
) { ) {
super(dashboardService, el, _cd); super(dashboardService, el, _cd, instantiationService, notificationService, angularEventingService);
// revert back to default database // revert back to default database
this._letDashboardPromise = this.dashboardService.connectionManagementService.changeDatabase('master'); this._letDashboardPromise = this.dashboardService.connectionManagementService.changeDatabase('master');
} }
@@ -9,8 +9,8 @@ import { Router } from '@angular/router';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
/* SQL imports */ /* SQL imports */
import { DashboardComponentParams } from 'sql/services/bootstrap/bootstrapParams'; import { IDashboardComponentParams } from 'sql/services/bootstrap/bootstrapParams';
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService'; import { IBootstrapParams } from 'sql/services/bootstrap/bootstrapService';
import { IMetadataService } from 'sql/services/metadata/metadataService'; import { IMetadataService } from 'sql/services/metadata/metadataService';
import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement'; import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement';
import { ConnectionManagementInfo } from 'sql/parts/connection/common/connectionManagementInfo'; import { ConnectionManagementInfo } from 'sql/parts/connection/common/connectionManagementInfo';
@@ -64,9 +64,6 @@ export class DashboardServiceInterface extends CommonServiceInterface {
/* Static Services */ /* Static Services */
private _dashboardViewService = this._bootstrapService.dashboardViewService;
private _updatePage = new Emitter<void>(); private _updatePage = new Emitter<void>();
public readonly onUpdatePage: Event<void> = this._updatePage.event; public readonly onUpdatePage: Event<void> = this._updatePage.event;
@@ -88,14 +85,21 @@ export class DashboardServiceInterface extends CommonServiceInterface {
private _numberOfPageNavigations = 0; private _numberOfPageNavigations = 0;
constructor( constructor(
@Inject(BOOTSTRAP_SERVICE_ID) bootstrapService: IBootstrapService,
@Inject(forwardRef(() => Router)) private _router: Router, @Inject(forwardRef(() => Router)) private _router: Router,
@Inject(INotificationService) private _notificationService: INotificationService,
@Inject(IMetadataService) metadataService: IMetadataService,
@Inject(IConnectionManagementService) connectionManagementService: IConnectionManagementService,
@Inject(IAdminService) adminService: IAdminService,
@Inject(IQueryManagementService) queryManagementService: IQueryManagementService,
@Inject(IAngularEventingService) private angularEventingService: IAngularEventingService,
@Inject(IConfigurationService) private _configService: IConfigurationService,
@Inject(IBootstrapParams) _params: IDashboardComponentParams
) { ) {
super(bootstrapService); super(_params, metadataService, connectionManagementService, adminService, queryManagementService);
} }
public get dashboardViewService(): IDashboardViewService { private get params(): IDashboardComponentParams {
return this._dashboardViewService; return this._params;
} }
/** /**
@@ -107,11 +111,10 @@ export class DashboardServiceInterface extends CommonServiceInterface {
} }
protected _getbootstrapParams(): void { protected _getbootstrapParams(): void {
this._bootstrapParams = this._bootstrapService.getBootstrapParams<DashboardComponentParams>(this._uniqueSelector); this.scopedContextKeyService = this.params.scopedContextService;
this._contextKeyService = this._bootstrapParams.scopedContextService; this._connectionContextKey = this.params.connectionContextKey;
this._connectionContextKey = this._bootstrapParams.connectionContextKey; this.dashboardContextKey = this._dashboardContextKey.bindTo(this.scopedContextKeyService);
this.dashboardContextKey = this._dashboardContextKey.bindTo(this._contextKeyService); this.uri = this.params.ownerUri;
this.uri = this._bootstrapParams.ownerUri;
} }
/** /**
@@ -120,7 +123,7 @@ export class DashboardServiceInterface extends CommonServiceInterface {
*/ */
protected set uri(uri: string) { protected set uri(uri: string) {
super.setUri(uri); super.setUri(uri);
this._register(toDisposableSubscription(this._bootstrapService.angularEventingService.onAngularEvent(this._uri, (event) => this.handleDashboardEvent(event)))); this._register(toDisposableSubscription(this.angularEventingService.onAngularEvent(this._uri, (event) => this.handleDashboardEvent(event))));
} }
/** /**
@@ -147,7 +150,7 @@ export class DashboardServiceInterface extends CommonServiceInterface {
} }
public writeSettings(type: string, value: any, target: ConfigurationTarget) { public writeSettings(type: string, value: any, target: ConfigurationTarget) {
this._configurationEditingService.writeConfiguration(target, { key: [DASHBOARD_SETTINGS, type].join('.'), value }); this._configService.updateValue([DASHBOARD_SETTINGS, type].join('.'), value, target);
} }
private handleDashboardEvent(event: IAngularEvent): void { private handleDashboardEvent(event: IAngularEvent): void {
@@ -16,6 +16,7 @@ import { CommonServiceInterface } from 'sql/services/common/commonServiceInterfa
import { toDisposableSubscription } from 'sql/parts/common/rxjsUtils'; import { toDisposableSubscription } from 'sql/parts/common/rxjsUtils';
import { ExplorerFilter, ExplorerRenderer, ExplorerDataSource, ExplorerController, ObjectMetadataWrapper, ExplorerModel } from './explorerTree'; import { ExplorerFilter, ExplorerRenderer, ExplorerDataSource, ExplorerController, ObjectMetadataWrapper, ExplorerModel } from './explorerTree';
import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile'; import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile';
import { ICapabilitiesService } from 'sql/services/capabilities/capabilitiesService';
import { InputBox, IInputOptions } from 'vs/base/browser/ui/inputbox/inputBox'; import { InputBox, IInputOptions } from 'vs/base/browser/ui/inputbox/inputBox';
import { attachInputBoxStyler, attachListStyler } from 'vs/platform/theme/common/styler'; import { attachInputBoxStyler, attachListStyler } from 'vs/platform/theme/common/styler';
@@ -23,6 +24,9 @@ import * as nls from 'vs/nls';
import { Tree } from 'vs/base/parts/tree/browser/treeImpl'; import { Tree } from 'vs/base/parts/tree/browser/treeImpl';
import { getContentHeight } from 'vs/base/browser/dom'; import { getContentHeight } from 'vs/base/browser/dom';
import { Delayer } from 'vs/base/common/async'; import { Delayer } from 'vs/base/common/async';
import { IContextViewService, IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
@Component({ @Component({
selector: 'explorer-widget', selector: 'explorer-widget',
@@ -36,9 +40,9 @@ export class ExplorerWidget extends DashboardWidget implements IDashboardWidget,
this._bootstrap.getUnderlyingUri(), this._bootstrap.getUnderlyingUri(),
this._bootstrap.connectionManagementService, this._bootstrap.connectionManagementService,
this._router, this._router,
this._bootstrap.contextMenuService, this.contextMenuService,
this._bootstrap.capabilitiesService, this.capabilitiesService,
this._bootstrap.instantiationService this.instantiationService
); );
private _treeRenderer = new ExplorerRenderer(); private _treeRenderer = new ExplorerRenderer();
private _treeDataSource = new ExplorerDataSource(); private _treeDataSource = new ExplorerDataSource();
@@ -54,7 +58,12 @@ export class ExplorerWidget extends DashboardWidget implements IDashboardWidget,
@Inject(forwardRef(() => Router)) private _router: Router, @Inject(forwardRef(() => Router)) private _router: Router,
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef,
@Inject(WIDGET_CONFIG) protected _config: WidgetConfig, @Inject(WIDGET_CONFIG) protected _config: WidgetConfig,
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef @Inject(forwardRef(() => ElementRef)) private _el: ElementRef,
@Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService,
@Inject(IContextViewService) private contextViewService: IContextViewService,
@Inject(IInstantiationService) private instantiationService: IInstantiationService,
@Inject(IContextMenuService) private contextMenuService: IContextMenuService,
@Inject(ICapabilitiesService) private capabilitiesService: ICapabilitiesService
) { ) {
super(); super();
this.init(); this.init();
@@ -69,7 +78,7 @@ export class ExplorerWidget extends DashboardWidget implements IDashboardWidget,
placeholder: placeholderLabel, placeholder: placeholderLabel,
ariaLabel: placeholderLabel ariaLabel: placeholderLabel
}; };
this._input = new InputBox(this._inputContainer.nativeElement, this._bootstrap.contextViewService, inputOptions); this._input = new InputBox(this._inputContainer.nativeElement, this.contextViewService, inputOptions);
this._register(this._input.onDidChange(e => { this._register(this._input.onDidChange(e => {
this._filterDelayer.trigger(() => { this._filterDelayer.trigger(() => {
this._treeFilter.filterString = e; this._treeFilter.filterString = e;
@@ -84,9 +93,9 @@ export class ExplorerWidget extends DashboardWidget implements IDashboardWidget,
}); });
this._tree.layout(getContentHeight(this._tableContainer.nativeElement)); this._tree.layout(getContentHeight(this._tableContainer.nativeElement));
this._register(this._input); this._register(this._input);
this._register(attachInputBoxStyler(this._input, this._bootstrap.themeService)); this._register(attachInputBoxStyler(this._input, this.themeService));
this._register(this._tree); this._register(this._tree);
this._register(attachListStyler(this._tree, this._bootstrap.themeService)); this._register(attachListStyler(this._tree, this.themeService));
} }
private init(): void { private init(): void {
@@ -109,7 +118,7 @@ export class ExplorerWidget extends DashboardWidget implements IDashboardWidget,
this._register(toDisposableSubscription(this._bootstrap.metadataService.databaseNames.subscribe( this._register(toDisposableSubscription(this._bootstrap.metadataService.databaseNames.subscribe(
data => { data => {
let profileData = data.map(d => { let profileData = data.map(d => {
let profile = new ConnectionProfile(this._bootstrap.capabilitiesService, currentProfile); let profile = new ConnectionProfile(this.capabilitiesService, currentProfile);
profile.databaseName = d; profile.databaseName = d;
return profile; return profile;
}); });
@@ -26,8 +26,10 @@ import * as types from 'vs/base/common/types';
import * as pfs from 'vs/base/node/pfs'; import * as pfs from 'vs/base/node/pfs';
import * as nls from 'vs/nls'; import * as nls from 'vs/nls';
import { Registry } from 'vs/platform/registry/common/platform'; import { Registry } from 'vs/platform/registry/common/platform';
import { WorkbenchState } from 'vs/platform/workspace/common/workspace'; import { WorkbenchState, IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IntervalTimer } from 'vs/base/common/async'; import { IntervalTimer } from 'vs/base/common/async';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IStorageService } from 'vs/platform/storage/common/storage';
const insightRegistry = Registry.as<IInsightRegistry>(Extensions.InsightContribution); const insightRegistry = Registry.as<IInsightRegistry>(Extensions.InsightContribution);
@@ -63,7 +65,11 @@ export class InsightsWidget extends DashboardWidget implements IDashboardWidget,
@Inject(forwardRef(() => CommonServiceInterface)) private dashboardService: CommonServiceInterface, @Inject(forwardRef(() => CommonServiceInterface)) private dashboardService: CommonServiceInterface,
@Inject(WIDGET_CONFIG) protected _config: WidgetConfig, @Inject(WIDGET_CONFIG) protected _config: WidgetConfig,
@Inject(forwardRef(() => ViewContainerRef)) private viewContainerRef: ViewContainerRef, @Inject(forwardRef(() => ViewContainerRef)) private viewContainerRef: ViewContainerRef,
@Inject(forwardRef(() => ChangeDetectorRef)) private _cd: ChangeDetectorRef @Inject(forwardRef(() => ChangeDetectorRef)) private _cd: ChangeDetectorRef,
@Inject(IInstantiationService) private instantiationService: IInstantiationService,
@Inject(IStorageService) private storageService: IStorageService,
@Inject(IWorkspaceContextService) private workspaceContextService: IWorkspaceContextService,
) { ) {
super(); super();
this.insightConfig = <IInsightsConfig>this._config.widget['insights-widget']; this.insightConfig = <IInsightsConfig>this._config.widget['insights-widget'];
@@ -128,9 +134,9 @@ export class InsightsWidget extends DashboardWidget implements IDashboardWidget,
get actions(): Array<Action> { get actions(): Array<Action> {
let actions: Array<Action> = []; let actions: Array<Action> = [];
if (this.insightConfig.details && (this.insightConfig.details.query || this.insightConfig.details.queryFile)) { if (this.insightConfig.details && (this.insightConfig.details.query || this.insightConfig.details.queryFile)) {
actions.push(this.dashboardService.instantiationService.createInstance(InsightAction, InsightAction.ID, InsightAction.LABEL)); actions.push(this.instantiationService.createInstance(InsightAction, InsightAction.ID, InsightAction.LABEL));
} }
actions.push(this.dashboardService.instantiationService.createInstance(RunInsightQueryAction, RunInsightQueryAction.ID, RunInsightQueryAction.LABEL)); actions.push(this.instantiationService.createInstance(RunInsightQueryAction, RunInsightQueryAction.ID, RunInsightQueryAction.LABEL));
return actions; return actions;
} }
@@ -150,14 +156,14 @@ export class InsightsWidget extends DashboardWidget implements IDashboardWidget,
}; };
this.lastUpdated = nls.localize('insights.lastUpdated', "Last Updated: {0} {1}", currentTime.toLocaleTimeString(), currentTime.toLocaleDateString()); this.lastUpdated = nls.localize('insights.lastUpdated', "Last Updated: {0} {1}", currentTime.toLocaleTimeString(), currentTime.toLocaleDateString());
this._cd.detectChanges(); this._cd.detectChanges();
this.dashboardService.storageService.store(this._getStorageKey(), JSON.stringify(store)); this.storageService.store(this._getStorageKey(), JSON.stringify(store));
} }
return result; return result;
} }
private _checkStorage(): boolean { private _checkStorage(): boolean {
if (this.insightConfig.cacheId) { if (this.insightConfig.cacheId) {
let storage = this.dashboardService.storageService.get(this._getStorageKey()); let storage = this.storageService.get(this._getStorageKey());
if (storage) { if (storage) {
let storedResult: IStorageResult = JSON.parse(storage); let storedResult: IStorageResult = JSON.parse(storage);
let date = new Date(storedResult.date); let date = new Date(storedResult.date);
@@ -272,15 +278,15 @@ export class InsightsWidget extends DashboardWidget implements IDashboardWidget,
filePath = filePath.replace(match[0], ''); filePath = filePath.replace(match[0], '');
//filePath = this.dashboardService.workspaceContextService.toResource(filePath).fsPath; //filePath = this.dashboardService.workspaceContextService.toResource(filePath).fsPath;
switch (this.dashboardService.workspaceContextService.getWorkbenchState()) { switch (this.workspaceContextService.getWorkbenchState()) {
case WorkbenchState.FOLDER: case WorkbenchState.FOLDER:
filePath = this.dashboardService.workspaceContextService.getWorkspace().folders[0].toResource(filePath).fsPath; filePath = this.workspaceContextService.getWorkspace().folders[0].toResource(filePath).fsPath;
break; break;
case WorkbenchState.WORKSPACE: case WorkbenchState.WORKSPACE:
let filePathArray = filePath.split('/'); let filePathArray = filePath.split('/');
// filter out empty sections // filter out empty sections
filePathArray = filePathArray.filter(i => !!i); filePathArray = filePathArray.filter(i => !!i);
let folder = this.dashboardService.workspaceContextService.getWorkspace().folders.find(i => i.name === filePathArray[0]); let folder = this.workspaceContextService.getWorkspace().folders.find(i => i.name === filePathArray[0]);
if (!folder) { if (!folder) {
return Promise.reject<void[]>(new Error(`Could not find workspace folder ${filePathArray[0]}`)); return Promise.reject<void[]>(new Error(`Could not find workspace folder ${filePathArray[0]}`));
} }
@@ -5,22 +5,19 @@
import { Component, Input, Inject, ChangeDetectorRef, forwardRef, ElementRef, ViewChild } from '@angular/core'; import { Component, Input, Inject, ChangeDetectorRef, forwardRef, ElementRef, ViewChild } from '@angular/core';
import { BaseChartDirective } from 'ng2-charts/ng2-charts'; import { BaseChartDirective } from 'ng2-charts/ng2-charts';
/* SQL Imports */
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService';
import * as TelemetryKeys from 'sql/common/telemetryKeys'; import * as TelemetryKeys from 'sql/common/telemetryKeys';
import * as TelemetryUtils from 'sql/common/telemetryUtilities'; import * as TelemetryUtils from 'sql/common/telemetryUtilities';
import { IInsightsView, IInsightData } from 'sql/parts/dashboard/widgets/insights/interfaces'; import { IInsightsView, IInsightData } from 'sql/parts/dashboard/widgets/insights/interfaces';
import { memoize, unmemoize } from 'sql/base/common/decorators'; import { memoize, unmemoize } from 'sql/base/common/decorators';
/* VS Imports */
import * as colors from 'vs/platform/theme/common/colorRegistry';
import { mixin } from 'sql/base/common/objects'; import { mixin } from 'sql/base/common/objects';
import * as colors from 'vs/platform/theme/common/colorRegistry';
import { Color } from 'vs/base/common/color'; import { Color } from 'vs/base/common/color';
import * as types from 'vs/base/common/types'; import * as types from 'vs/base/common/types';
import { Disposable } from 'vs/base/common/lifecycle'; import { Disposable } from 'vs/base/common/lifecycle';
import { IColorTheme } from 'vs/workbench/services/themes/common/workbenchThemeService'; import { IColorTheme, IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import * as nls from 'vs/nls'; import * as nls from 'vs/nls';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
export enum ChartType { export enum ChartType {
Bar = 'bar', Bar = 'bar',
@@ -121,14 +118,15 @@ export abstract class ChartInsight extends Disposable implements IInsightsView {
constructor( constructor(
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef,
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef, @Inject(forwardRef(() => ElementRef)) private _el: ElementRef,
@Inject(BOOTSTRAP_SERVICE_ID) protected _bootstrapService: IBootstrapService @Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService,
@Inject(ITelemetryService) private telemetryService: ITelemetryService
) { ) {
super(); super();
} }
init() { init() {
this._register(this._bootstrapService.themeService.onDidColorThemeChange(e => this.updateTheme(e))); this._register(this.themeService.onDidColorThemeChange(e => this.updateTheme(e)));
this.updateTheme(this._bootstrapService.themeService.getColorTheme()); this.updateTheme(this.themeService.getColorTheme());
// Note: must use a boolean to not render the canvas until all properties such as the labels and chart type are set. // Note: must use a boolean to not render the canvas until all properties such as the labels and chart type are set.
// This is because chart.js doesn't auto-update anything other than dataset when re-rendering so defaults are used // This is because chart.js doesn't auto-update anything other than dataset when re-rendering so defaults are used
// hence it's easier to not render until ready // hence it's easier to not render until ready
@@ -142,7 +140,7 @@ export abstract class ChartInsight extends Disposable implements IInsightsView {
this._hasError = true; this._hasError = true;
this._changeRef.detectChanges(); this._changeRef.detectChanges();
} }
TelemetryUtils.addTelemetry(this._bootstrapService.telemetryService, TelemetryKeys.ChartCreated, { type: this.chartType }); TelemetryUtils.addTelemetry(this.telemetryService, TelemetryKeys.ChartCreated, { type: this.chartType });
} }
/** /**
@@ -7,16 +7,16 @@ import { Component, Input, Inject, ChangeDetectorRef, forwardRef, ElementRef, On
import { getContentHeight, getContentWidth } from 'vs/base/browser/dom'; import { getContentHeight, getContentWidth } from 'vs/base/browser/dom';
import { Dimension } from 'vs/base/browser/builder'; import { Dimension } from 'vs/base/browser/builder';
import { Disposable } from 'vs/base/common/lifecycle'; import { Disposable } from 'vs/base/common/lifecycle';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { IInsightsView, IInsightData } from 'sql/parts/dashboard/widgets/insights/interfaces'; import { IInsightsView, IInsightData } from 'sql/parts/dashboard/widgets/insights/interfaces';
import { Table } from 'sql/base/browser/ui/table/table'; import { Table } from 'sql/base/browser/ui/table/table';
import { TableDataView } from 'sql/base/browser/ui/table/tableDataView'; import { TableDataView } from 'sql/base/browser/ui/table/tableDataView';
import { DragCellSelectionModel } from 'sql/base/browser/ui/table/plugins/dragCellSelectionModel.plugin'; import { DragCellSelectionModel } from 'sql/base/browser/ui/table/plugins/dragCellSelectionModel.plugin';
import { attachTableStyler} from 'sql/common/theme/styler'; import { attachTableStyler} from 'sql/common/theme/styler';
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
@Component({ @Component({
template: '<span></span>' template: ''
}) })
export default class TableInsight extends Disposable implements IInsightsView, OnInit { export default class TableInsight extends Disposable implements IInsightsView, OnInit {
private table: Table<any>; private table: Table<any>;
@@ -26,7 +26,7 @@ export default class TableInsight extends Disposable implements IInsightsView, O
constructor( constructor(
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef,
@Inject(forwardRef(() => ElementRef)) private _elementRef: ElementRef, @Inject(forwardRef(() => ElementRef)) private _elementRef: ElementRef,
@Inject(forwardRef(() => CommonServiceInterface)) private _bootstrap: CommonServiceInterface, @Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService
) { ) {
super(); super();
this._elementRef.nativeElement.className = 'slickgridContainer'; this._elementRef.nativeElement.className = 'slickgridContainer';
@@ -65,7 +65,7 @@ export default class TableInsight extends Disposable implements IInsightsView, O
if (!this.table) { if (!this.table) {
this.table = new Table(this._elementRef.nativeElement, this.dataView, this.columns, { showRowNumber: true }); this.table = new Table(this._elementRef.nativeElement, this.dataView, this.columns, { showRowNumber: true });
this.table.setSelectionModel(new DragCellSelectionModel()); this.table.setSelectionModel(new DragCellSelectionModel());
this._register(attachTableStyler(this.table, this._bootstrap.themeService)); this._register(attachTableStyler(this.table, this.themeService));
} }
} }
} }
@@ -29,9 +29,9 @@ import { ScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElemen
import { ScrollbarVisibility } from 'vs/base/common/scrollable'; import { ScrollbarVisibility } from 'vs/base/common/scrollable';
import { $, Builder } from 'vs/base/browser/builder'; import { $, Builder } from 'vs/base/browser/builder';
import * as DOM from 'vs/base/browser/dom'; import * as DOM from 'vs/base/browser/dom';
import { CommandsRegistry, ICommand } from 'vs/platform/commands/common/commands'; import { CommandsRegistry, ICommand, ICommandService } from 'vs/platform/commands/common/commands';
import { MenuRegistry, ICommandAction } from 'vs/platform/actions/common/actions'; import { MenuRegistry, ICommandAction } from 'vs/platform/actions/common/actions';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { KeyCode } from 'vs/base/common/keyCodes'; import { KeyCode } from 'vs/base/common/keyCodes';
@@ -62,7 +62,9 @@ export class TasksWidget extends DashboardWidget implements IDashboardWidget, On
@Inject(forwardRef(() => CommonServiceInterface)) private _bootstrap: CommonServiceInterface, @Inject(forwardRef(() => CommonServiceInterface)) private _bootstrap: CommonServiceInterface,
@Inject(forwardRef(() => DomSanitizer)) private _sanitizer: DomSanitizer, @Inject(forwardRef(() => DomSanitizer)) private _sanitizer: DomSanitizer,
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeref: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) private _changeref: ChangeDetectorRef,
@Inject(WIDGET_CONFIG) protected _config: WidgetConfig @Inject(ICommandService) private commandService: ICommandService,
@Inject(WIDGET_CONFIG) protected _config: WidgetConfig,
@Inject(IContextKeyService) contextKeyService: IContextKeyService
) { ) {
super(); super();
this._profile = this._bootstrap.connectionManagementService.connectionInfo.connectionProfile; this._profile = this._bootstrap.connectionManagementService.connectionInfo.connectionProfile;
@@ -76,7 +78,7 @@ export class TasksWidget extends DashboardWidget implements IDashboardWidget, On
return i; return i;
} }
} else { } else {
if (tasks.includes(i.name) && _bootstrap.contextKeyService.contextMatchesRules(ContextKeyExpr.deserialize(i.when))) { if (tasks.includes(i.name) && contextKeyService.contextMatchesRules(ContextKeyExpr.deserialize(i.when))) {
return i.name; return i.name;
} }
} }
@@ -165,7 +167,7 @@ export class TasksWidget extends DashboardWidget implements IDashboardWidget, On
public runTask(task: ICommandAction) { public runTask(task: ICommandAction) {
let serverInfo = this._bootstrap.connectionManagementService.connectionInfo.serverInfo; let serverInfo = this._bootstrap.connectionManagementService.connectionInfo.serverInfo;
this._bootstrap.commandService.executeCommand(task.id, this._profile); this.commandService.executeCommand(task.id, this._profile);
} }
public layout(): void { public layout(): void {
@@ -6,7 +6,7 @@
import { Component, Inject, forwardRef, ChangeDetectorRef, OnInit, ViewChild, ElementRef } from '@angular/core'; import { Component, Inject, forwardRef, ChangeDetectorRef, OnInit, ViewChild, ElementRef } from '@angular/core';
import { Webview } from 'vs/workbench/parts/html/browser/webview'; import { Webview } from 'vs/workbench/parts/html/browser/webview';
import { Parts } from 'vs/workbench/services/part/common/partService'; import { Parts, IPartService } from 'vs/workbench/services/part/common/partService';
import Event, { Emitter } from 'vs/base/common/event'; import Event, { Emitter } from 'vs/base/common/event';
import { IDisposable } from 'vs/base/common/lifecycle'; import { IDisposable } from 'vs/base/common/lifecycle';
import { memoize } from 'vs/base/common/decorators'; import { memoize } from 'vs/base/common/decorators';
@@ -14,9 +14,12 @@ import { memoize } from 'vs/base/common/decorators';
import { DashboardWidget, IDashboardWidget, WidgetConfig, WIDGET_CONFIG } from 'sql/parts/dashboard/common/dashboardWidget'; import { DashboardWidget, IDashboardWidget, WidgetConfig, WIDGET_CONFIG } from 'sql/parts/dashboard/common/dashboardWidget';
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service'; import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service'; import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
import { IDashboardWebview } from 'sql/services/dashboard/common/dashboardViewService'; import { IDashboardWebview, IDashboardViewService } from 'sql/services/dashboard/common/dashboardViewService';
import * as sqlops from 'sqlops'; import * as sqlops from 'sqlops';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
interface IWebviewWidgetConfig { interface IWebviewWidgetConfig {
id: string; id: string;
@@ -36,21 +39,24 @@ export class WebviewWidget extends DashboardWidget implements IDashboardWidget,
private _onMessage = new Emitter<string>(); private _onMessage = new Emitter<string>();
public readonly onMessage: Event<string> = this._onMessage.event; public readonly onMessage: Event<string> = this._onMessage.event;
private _onMessageDisposable: IDisposable; private _onMessageDisposable: IDisposable;
private _dashboardService: DashboardServiceInterface;
constructor( constructor(
@Inject(forwardRef(() => CommonServiceInterface)) private commonService: CommonServiceInterface, @Inject(forwardRef(() => CommonServiceInterface)) private _dashboardService: DashboardServiceInterface,
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef,
@Inject(WIDGET_CONFIG) protected _config: WidgetConfig, @Inject(WIDGET_CONFIG) protected _config: WidgetConfig,
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef @Inject(forwardRef(() => ElementRef)) private _el: ElementRef,
@Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService,
@Inject(IContextViewService) private contextViewService: IContextViewService,
@Inject(IDashboardViewService) private dashboardViewService: IDashboardViewService,
@Inject(IPartService) private partService: IPartService,
@Inject(IEnvironmentService) private environmentService: IEnvironmentService
) { ) {
super(); super();
this._id = (_config.widget[selector] as IWebviewWidgetConfig).id; this._id = (_config.widget[selector] as IWebviewWidgetConfig).id;
this._dashboardService = commonService as DashboardServiceInterface;
} }
ngOnInit() { ngOnInit() {
this._dashboardService.dashboardViewService.registerWebview(this); this.dashboardViewService.registerWebview(this);
this._createWebview(); this._createWebview();
} }
@@ -101,10 +107,10 @@ export class WebviewWidget extends DashboardWidget implements IDashboardWidget,
} }
this._webview = new Webview( this._webview = new Webview(
this._el.nativeElement, this._el.nativeElement,
this._dashboardService.partService.getContainer(Parts.EDITOR_PART), this.partService.getContainer(Parts.EDITOR_PART),
this._dashboardService.themeService, this.themeService,
this._dashboardService.environmentService, this.environmentService,
this._dashboardService.contextViewService, this.contextViewService,
undefined, undefined,
undefined, undefined,
{ {
@@ -115,7 +121,7 @@ export class WebviewWidget extends DashboardWidget implements IDashboardWidget,
this._onMessageDisposable = this._webview.onMessage(e => { this._onMessageDisposable = this._webview.onMessage(e => {
this._onMessage.fire(e); this._onMessage.fire(e);
}); });
this._webview.style(this._dashboardService.themeService.getTheme()); this._webview.style(this.themeService.getTheme());
if (this._html) { if (this._html) {
this._webview.contents = this._html; this._webview.contents = this._html;
} }
@@ -19,8 +19,9 @@ import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
import * as BackupConstants from 'sql/parts/disasterRecovery/backup/constants'; import * as BackupConstants from 'sql/parts/disasterRecovery/backup/constants';
import { IBackupService, IBackupUiService, TaskExecutionMode } from 'sql/parts/disasterRecovery/backup/common/backupService'; import { IBackupService, IBackupUiService, TaskExecutionMode } from 'sql/parts/disasterRecovery/backup/common/backupService';
import FileValidationConstants = require('sql/parts/fileBrowser/common/fileValidationServiceConstants'); import FileValidationConstants = require('sql/parts/fileBrowser/common/fileValidationServiceConstants');
import { DashboardComponentParams } from 'sql/services/bootstrap/bootstrapParams'; import { IDashboardComponentParams } from 'sql/services/bootstrap/bootstrapParams';
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService'; import { IFileBrowserDialogController } from 'sql/parts/fileBrowser/common/interfaces';
import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement';
import { MessageType } from 'vs/base/browser/ui/inputbox/inputBox'; import { MessageType } from 'vs/base/browser/ui/inputbox/inputBox';
import * as lifecycle from 'vs/base/common/lifecycle'; import * as lifecycle from 'vs/base/common/lifecycle';
@@ -30,6 +31,9 @@ import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { KeyCode } from 'vs/base/common/keyCodes'; import { KeyCode } from 'vs/base/common/keyCodes';
import * as types from 'vs/base/common/types'; import * as types from 'vs/base/common/types';
import * as strings from 'vs/base/common/strings'; import * as strings from 'vs/base/common/strings';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
export const BACKUP_SELECTOR: string = 'backup-component'; export const BACKUP_SELECTOR: string = 'backup-component';
@@ -143,8 +147,6 @@ export class BackupComponent {
private localizedStrings = LocalizedStrings; private localizedStrings = LocalizedStrings;
private _backupService: IBackupService;
private _backupUiService: IBackupUiService;
private _uri: string; private _uri: string;
private _toDispose: lifecycle.IDisposable[] = []; private _toDispose: lifecycle.IDisposable[] = [];
private _advancedHeaderSize = 32; private _advancedHeaderSize = 32;
@@ -199,10 +201,14 @@ export class BackupComponent {
constructor( constructor(
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef, @Inject(forwardRef(() => ElementRef)) private _el: ElementRef,
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeDetectorRef: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) private _changeDetectorRef: ChangeDetectorRef,
@Inject(BOOTSTRAP_SERVICE_ID) private _bootstrapService: IBootstrapService, @Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService,
@Inject(IContextViewService) private contextViewService: IContextViewService,
@Inject(IFileBrowserDialogController) private fileBrowserDialogService: IFileBrowserDialogController,
@Inject(IBackupUiService) private _backupUiService: IBackupUiService,
@Inject(IBackupService) private _backupService: IBackupService,
@Inject(IClipboardService) private clipboardService: IClipboardService,
@Inject(IConnectionManagementService) private connectionManagementService: IConnectionManagementService
) { ) {
this._backupService = _bootstrapService.backupService;
this._backupUiService = _bootstrapService.backupUiService;
this._backupUiService.onShowBackupEvent((param) => this.onGetBackupConfigInfo(param)); this._backupUiService.onShowBackupEvent((param) => this.onGetBackupConfigInfo(param));
} }
@@ -210,12 +216,12 @@ export class BackupComponent {
let self = this; let self = this;
this.addFooterButtons(); this.addFooterButtons();
this.recoveryBox = new InputBox(this.recoveryModelElement.nativeElement, this._bootstrapService.contextViewService, { this.recoveryBox = new InputBox(this.recoveryModelElement.nativeElement, this.contextViewService, {
placeholder: this.recoveryModel, placeholder: this.recoveryModel,
ariaLabel: LocalizedStrings.RECOVERY_MODEL ariaLabel: LocalizedStrings.RECOVERY_MODEL
}); });
// Set backup type // Set backup type
this.backupTypeSelectBox = new SelectBox([], '', this._bootstrapService.contextViewService); this.backupTypeSelectBox = new SelectBox([], '', this.contextViewService);
this.backupTypeSelectBox.render(this.backupTypeElement.nativeElement); this.backupTypeSelectBox.render(this.backupTypeElement.nativeElement);
// Set copy-only check box // Set copy-only check box
@@ -259,12 +265,12 @@ export class BackupComponent {
}); });
// Set backup name // Set backup name
this.backupNameBox = new InputBox(this.backupNameElement.nativeElement, this._bootstrapService.contextViewService, { this.backupNameBox = new InputBox(this.backupNameElement.nativeElement, this.contextViewService, {
ariaLabel: LocalizedStrings.BACKUP_NAME ariaLabel: LocalizedStrings.BACKUP_NAME
}); });
// Set backup path list // Set backup path list
this.pathListBox = new ListBox([], '', this._bootstrapService.contextViewService, this._bootstrapService.clipboardService); this.pathListBox = new ListBox([], '', this.contextViewService, this.clipboardService);
this.pathListBox.render(this.pathElement.nativeElement); this.pathListBox.render(this.pathElement.nativeElement);
// Set backup path add/remove buttons // Set backup path add/remove buttons
@@ -277,18 +283,18 @@ export class BackupComponent {
this.removePathButton.title = localize('removeFile', 'Remove files'); this.removePathButton.title = localize('removeFile', 'Remove files');
// Set compression // Set compression
this.compressionSelectBox = new SelectBox(this.compressionOptions, this.compressionOptions[0], this._bootstrapService.contextViewService); this.compressionSelectBox = new SelectBox(this.compressionOptions, this.compressionOptions[0], this.contextViewService);
this.compressionSelectBox.render(this.compressionElement.nativeElement); this.compressionSelectBox.render(this.compressionElement.nativeElement);
// Set encryption // Set encryption
this.algorithmSelectBox = new SelectBox(this.encryptionAlgorithms, this.encryptionAlgorithms[0], this._bootstrapService.contextViewService); this.algorithmSelectBox = new SelectBox(this.encryptionAlgorithms, this.encryptionAlgorithms[0], this.contextViewService);
this.algorithmSelectBox.render(this.encryptionAlgorithmElement.nativeElement); this.algorithmSelectBox.render(this.encryptionAlgorithmElement.nativeElement);
this.encryptorSelectBox = new SelectBox([], '', this._bootstrapService.contextViewService); this.encryptorSelectBox = new SelectBox([], '', this.contextViewService);
this.encryptorSelectBox.render(this.encryptorElement.nativeElement); this.encryptorSelectBox.render(this.encryptorElement.nativeElement);
// Set media // Set media
this.mediaNameBox = new InputBox(this.mediaNameElement.nativeElement, this.mediaNameBox = new InputBox(this.mediaNameElement.nativeElement,
this._bootstrapService.contextViewService, this.contextViewService,
{ {
validationOptions: { validationOptions: {
validation: (value: string) => !value ? ({ type: MessageType.ERROR, content: LocalizedStrings.MEDIA_NAME_REQUIRED_ERROR }) : null validation: (value: string) => !value ? ({ type: MessageType.ERROR, content: LocalizedStrings.MEDIA_NAME_REQUIRED_ERROR }) : null
@@ -297,14 +303,14 @@ export class BackupComponent {
} }
); );
this.mediaDescriptionBox = new InputBox(this.mediaDescriptionElement.nativeElement, this._bootstrapService.contextViewService, { this.mediaDescriptionBox = new InputBox(this.mediaDescriptionElement.nativeElement, this.contextViewService, {
ariaLabel: LocalizedStrings.NEW_MEDIA_SET_DESCRIPTION ariaLabel: LocalizedStrings.NEW_MEDIA_SET_DESCRIPTION
}); });
// Set backup retain days // Set backup retain days
let invalidInputMessage = localize('backupComponent.invalidInput', 'Invalid input. Value must be greater than or equal 0.'); let invalidInputMessage = localize('backupComponent.invalidInput', 'Invalid input. Value must be greater than or equal 0.');
this.backupRetainDaysBox = new InputBox(this.backupDaysElement.nativeElement, this.backupRetainDaysBox = new InputBox(this.backupDaysElement.nativeElement,
this._bootstrapService.contextViewService, this.contextViewService,
{ {
placeholder: '0', placeholder: '0',
type: 'number', type: 'number',
@@ -387,21 +393,21 @@ export class BackupComponent {
this.scriptButton = new Button(this.scriptButtonElement.nativeElement); this.scriptButton = new Button(this.scriptButtonElement.nativeElement);
this.scriptButton.label = localize('backupComponent.script', 'Script'); this.scriptButton.label = localize('backupComponent.script', 'Script');
this.addButtonClickHandler(this.scriptButton, () => this.onScript()); this.addButtonClickHandler(this.scriptButton, () => this.onScript());
this._toDispose.push(attachButtonStyler(this.scriptButton, this._bootstrapService.themeService)); this._toDispose.push(attachButtonStyler(this.scriptButton, this.themeService));
this.scriptButton.enabled = false; this.scriptButton.enabled = false;
// Set backup footer button // Set backup footer button
this.backupButton = new Button(this.backupButtonElement.nativeElement); this.backupButton = new Button(this.backupButtonElement.nativeElement);
this.backupButton.label = localize('backupComponent.backup', 'Backup'); this.backupButton.label = localize('backupComponent.backup', 'Backup');
this.addButtonClickHandler(this.backupButton, () => this.onOk()); this.addButtonClickHandler(this.backupButton, () => this.onOk());
this._toDispose.push(attachButtonStyler(this.backupButton, this._bootstrapService.themeService)); this._toDispose.push(attachButtonStyler(this.backupButton, this.themeService));
this.backupEnabled = false; this.backupEnabled = false;
// Set cancel footer button // Set cancel footer button
this.cancelButton = new Button(this.cancelButtonElement.nativeElement); this.cancelButton = new Button(this.cancelButtonElement.nativeElement);
this.cancelButton.label = localize('backupComponent.cancel', 'Cancel'); this.cancelButton.label = localize('backupComponent.cancel', 'Cancel');
this.addButtonClickHandler(this.cancelButton, () => this.onCancel()); this.addButtonClickHandler(this.cancelButton, () => this.onCancel());
this._toDispose.push(attachButtonStyler(this.cancelButton, this._bootstrapService.themeService)); this._toDispose.push(attachButtonStyler(this.cancelButton, this.themeService));
} }
private initialize(isMetadataPopulated: boolean): void { private initialize(isMetadataPopulated: boolean): void {
@@ -505,18 +511,18 @@ export class BackupComponent {
private registerListeners(): void { private registerListeners(): void {
// Theme styler // Theme styler
this._toDispose.push(attachInputBoxStyler(this.backupNameBox, this._bootstrapService.themeService)); this._toDispose.push(attachInputBoxStyler(this.backupNameBox, this.themeService));
this._toDispose.push(attachInputBoxStyler(this.recoveryBox, this._bootstrapService.themeService)); this._toDispose.push(attachInputBoxStyler(this.recoveryBox, this.themeService));
this._toDispose.push(attachSelectBoxStyler(this.backupTypeSelectBox, this._bootstrapService.themeService)); this._toDispose.push(attachSelectBoxStyler(this.backupTypeSelectBox, this.themeService));
this._toDispose.push(attachListBoxStyler(this.pathListBox, this._bootstrapService.themeService)); this._toDispose.push(attachListBoxStyler(this.pathListBox, this.themeService));
this._toDispose.push(attachButtonStyler(this.addPathButton, this._bootstrapService.themeService)); this._toDispose.push(attachButtonStyler(this.addPathButton, this.themeService));
this._toDispose.push(attachButtonStyler(this.removePathButton, this._bootstrapService.themeService)); this._toDispose.push(attachButtonStyler(this.removePathButton, this.themeService));
this._toDispose.push(attachSelectBoxStyler(this.compressionSelectBox, this._bootstrapService.themeService)); this._toDispose.push(attachSelectBoxStyler(this.compressionSelectBox, this.themeService));
this._toDispose.push(attachSelectBoxStyler(this.algorithmSelectBox, this._bootstrapService.themeService)); this._toDispose.push(attachSelectBoxStyler(this.algorithmSelectBox, this.themeService));
this._toDispose.push(attachSelectBoxStyler(this.encryptorSelectBox, this._bootstrapService.themeService)); this._toDispose.push(attachSelectBoxStyler(this.encryptorSelectBox, this.themeService));
this._toDispose.push(attachInputBoxStyler(this.mediaNameBox, this._bootstrapService.themeService)); this._toDispose.push(attachInputBoxStyler(this.mediaNameBox, this.themeService));
this._toDispose.push(attachInputBoxStyler(this.mediaDescriptionBox, this._bootstrapService.themeService)); this._toDispose.push(attachInputBoxStyler(this.mediaDescriptionBox, this.themeService));
this._toDispose.push(attachInputBoxStyler(this.backupRetainDaysBox, this._bootstrapService.themeService)); this._toDispose.push(attachInputBoxStyler(this.backupRetainDaysBox, this.themeService));
this._toDispose.push(this.backupTypeSelectBox.onDidSelect(selected => this.onBackupTypeChanged())); this._toDispose.push(this.backupTypeSelectBox.onDidSelect(selected => this.onBackupTypeChanged()));
this.addButtonClickHandler(this.addPathButton, () => this.onAddClick()); this.addButtonClickHandler(this.addPathButton, () => this.onAddClick());
@@ -528,7 +534,7 @@ export class BackupComponent {
this.backupRetainDaysChanged(days); this.backupRetainDaysChanged(days);
})); }));
this._toDispose.push(this._bootstrapService.themeService.onDidColorThemeChange(e => this.updateTheme())); this._toDispose.push(this.themeService.onDidColorThemeChange(e => this.updateTheme()));
} }
// Update theming that is specific to backup dialog // Update theming that is specific to backup dialog
@@ -566,7 +572,7 @@ export class BackupComponent {
private onCancel(): void { private onCancel(): void {
this.close(); this.close();
this._bootstrapService.connectionManagementService.disconnect(this._uri); this.connectionManagementService.disconnect(this._uri);
} }
private close(): void { private close(): void {
@@ -629,7 +635,7 @@ export class BackupComponent {
} }
private onAddClick(): void { private onAddClick(): void {
this._bootstrapService.fileBrowserDialogService.showDialog(this._uri, this.fileBrowserDialogService.showDialog(this._uri,
this.defaultNewBackupFolder, this.defaultNewBackupFolder,
BackupConstants.fileFiltersSet, BackupConstants.fileFiltersSet,
FileValidationConstants.backup, FileValidationConstants.backup,
@@ -3,18 +3,21 @@
* Licensed under the Source EULA. See License.txt in the project root for license information. * Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { ApplicationRef, ComponentFactoryResolver, ModuleWithProviders, NgModule, import {
Inject, forwardRef } from '@angular/core'; ApplicationRef, ComponentFactoryResolver, ModuleWithProviders, NgModule,
Inject, forwardRef, Type
} from '@angular/core';
import { APP_BASE_HREF, CommonModule } from '@angular/common'; import { APP_BASE_HREF, CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser'; import { BrowserModule } from '@angular/platform-browser';
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService'; import { IBootstrapParams } from 'sql/services/bootstrap/bootstrapService';
import { BackupComponent, BACKUP_SELECTOR } from 'sql/parts/disasterRecovery/backup/backup.component'; import { BackupComponent, BACKUP_SELECTOR } from 'sql/parts/disasterRecovery/backup/backup.component';
// work around // work around
const BrowserAnimationsModule = (<any>require.__$__nodeRequire('@angular/platform-browser/animations')).BrowserAnimationsModule; const BrowserAnimationsModule = (<any>require.__$__nodeRequire('@angular/platform-browser/animations')).BrowserAnimationsModule;
// Backup wizard main angular module // Backup wizard main angular module
export const BackupModule = (params: IBootstrapParams, selector: string): Type<any> => {
@NgModule({ @NgModule({
declarations: [ declarations: [
BackupComponent BackupComponent
@@ -26,20 +29,24 @@ const BrowserAnimationsModule = (<any> require.__$__nodeRequire('@angular/platfo
BrowserModule, BrowserModule,
BrowserAnimationsModule, BrowserAnimationsModule,
], ],
providers: [{ provide: APP_BASE_HREF, useValue: '/' }] providers: [
{ provide: APP_BASE_HREF, useValue: '/' },
{ provide: IBootstrapParams, useValue: params }
]
}) })
export class BackupModule { class ModuleClass {
constructor( constructor(
@Inject(forwardRef(() => ComponentFactoryResolver)) private _resolver: ComponentFactoryResolver, @Inject(forwardRef(() => ComponentFactoryResolver)) private _resolver: ComponentFactoryResolver
@Inject(BOOTSTRAP_SERVICE_ID) private _bootstrapService: IBootstrapService
) { ) {
} }
ngDoBootstrap(appRef: ApplicationRef) { ngDoBootstrap(appRef: ApplicationRef) {
const factory = this._resolver.resolveComponentFactory(BackupComponent); const factory = this._resolver.resolveComponentFactory(BackupComponent);
const uniqueSelector: string = this._bootstrapService.getUniqueSelector(BACKUP_SELECTOR); (<any>factory).factory.selector = selector;
(<any>factory).factory.selector = uniqueSelector;
appRef.bootstrap(factory); appRef.bootstrap(factory);
} }
} }
return ModuleClass;
};
@@ -7,7 +7,6 @@ import { Modal } from 'sql/base/browser/ui/modal/modal';
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces'; import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
import { BackupModule } from 'sql/parts/disasterRecovery/backup/backup.module'; import { BackupModule } from 'sql/parts/disasterRecovery/backup/backup.module';
import { BACKUP_SELECTOR } from 'sql/parts/disasterRecovery/backup/backup.component'; import { BACKUP_SELECTOR } from 'sql/parts/disasterRecovery/backup/backup.component';
import { IBootstrapService } from 'sql/services/bootstrap/bootstrapService';
import { attachModalDialogStyler } from 'sql/common/theme/styler'; import { attachModalDialogStyler } from 'sql/common/theme/styler';
import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement'; import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement';
import * as TelemetryKeys from 'sql/common/telemetryKeys'; import * as TelemetryKeys from 'sql/common/telemetryKeys';
@@ -17,6 +16,8 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IPartService } from 'vs/workbench/services/part/common/partService'; import { IPartService } from 'vs/workbench/services/part/common/partService';
import { Builder } from 'vs/base/browser/builder'; import { Builder } from 'vs/base/browser/builder';
import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { bootstrapAngular } from 'sql/services/bootstrap/bootstrapService';
export class BackupDialog extends Modal { export class BackupDialog extends Modal {
private _bodyBuilder: Builder; private _bodyBuilder: Builder;
@@ -25,12 +26,12 @@ export class BackupDialog extends Modal {
private _moduleRef: any; private _moduleRef: any;
constructor( constructor(
@IBootstrapService private _bootstrapService: IBootstrapService,
@IThemeService private _themeService: IThemeService, @IThemeService private _themeService: IThemeService,
@IPartService partService: IPartService, @IPartService partService: IPartService,
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService, @IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
@ITelemetryService telemetryService: ITelemetryService, @ITelemetryService telemetryService: ITelemetryService,
@IContextKeyService contextKeyService: IContextKeyService @IContextKeyService contextKeyService: IContextKeyService,
@IInstantiationService private _instantiationService: IInstantiationService
) { ) {
super('', TelemetryKeys.Backup, partService, telemetryService, contextKeyService, { isAngular: true, hasErrors: true }); super('', TelemetryKeys.Backup, partService, telemetryService, contextKeyService, { isAngular: true, hasErrors: true });
} }
@@ -53,7 +54,7 @@ export class BackupDialog extends Modal {
* Get the bootstrap params and perform the bootstrap * Get the bootstrap params and perform the bootstrap
*/ */
private bootstrapAngular(bodyContainer: HTMLElement) { private bootstrapAngular(bodyContainer: HTMLElement) {
this._uniqueSelector = this._bootstrapService.bootstrap( this._uniqueSelector = this._instantiationService.invokeFunction(bootstrapAngular,
BackupModule, BackupModule,
bodyContainer, bodyContainer,
BACKUP_SELECTOR, BACKUP_SELECTOR,
@@ -9,7 +9,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
import Event from 'vs/base/common/event'; import Event from 'vs/base/common/event';
import * as sqlops from 'sqlops'; import * as sqlops from 'sqlops';
import { DashboardComponentParams } from 'sql/services/bootstrap/bootstrapParams'; import { IDashboardComponentParams } from 'sql/services/bootstrap/bootstrapParams';
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces'; import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
@@ -14,7 +14,7 @@ import { IBackupService, TaskExecutionMode, IBackupUiService } from 'sql/parts/d
import { BackupDialog } from 'sql/parts/disasterRecovery/backup/backupDialog'; import { BackupDialog } from 'sql/parts/disasterRecovery/backup/backupDialog';
import { OptionsDialog } from 'sql/base/browser/ui/modal/optionsDialog'; import { OptionsDialog } from 'sql/base/browser/ui/modal/optionsDialog';
import Event, { Emitter } from 'vs/base/common/event'; import Event, { Emitter } from 'vs/base/common/event';
import { DashboardComponentParams } from 'sql/services/bootstrap/bootstrapParams'; import { IDashboardComponentParams } from 'sql/services/bootstrap/bootstrapParams';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IPartService } from 'vs/workbench/services/part/common/partService'; import { IPartService } from 'vs/workbench/services/part/common/partService';
import { ICapabilitiesService } from 'sql/services/capabilities/capabilitiesService'; import { ICapabilitiesService } from 'sql/services/capabilities/capabilitiesService';
@@ -22,7 +22,6 @@ import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
import { TPromise } from 'vs/base/common/winjs.base'; import { TPromise } from 'vs/base/common/winjs.base';
import * as ConnectionUtils from 'sql/parts/connection/common/utils'; import * as ConnectionUtils from 'sql/parts/connection/common/utils';
import { ProviderConnectionInfo } from 'sql/parts/connection/common/providerConnectionInfo'; import { ProviderConnectionInfo } from 'sql/parts/connection/common/providerConnectionInfo';
import { ServiceOption } from 'sqlops';
export class BackupService implements IBackupService { export class BackupService implements IBackupService {
@@ -96,11 +95,13 @@ export class BackupUiService implements IBackupUiService {
private _onShowBackupEvent: Emitter<{ connection: IConnectionProfile, ownerUri: string }>; private _onShowBackupEvent: Emitter<{ connection: IConnectionProfile, ownerUri: string }>;
public get onShowBackupEvent(): Event<{ connection: IConnectionProfile, ownerUri: string }> { return this._onShowBackupEvent.event; } public get onShowBackupEvent(): Event<{ connection: IConnectionProfile, ownerUri: string }> { return this._onShowBackupEvent.event; }
constructor( @IInstantiationService private _instantiationService: IInstantiationService, constructor(
@IInstantiationService private _instantiationService: IInstantiationService,
@IPartService private _partService: IPartService, @IPartService private _partService: IPartService,
@ICapabilitiesService private _capabilitiesService: ICapabilitiesService, @ICapabilitiesService private _capabilitiesService: ICapabilitiesService,
@IBackupService private _disasterRecoveryService: IBackupService, @IBackupService private _disasterRecoveryService: IBackupService,
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService) { @IConnectionManagementService private _connectionManagementService: IConnectionManagementService
) {
this._onShowBackupEvent = new Emitter<{ connection: IConnectionProfile, ownerUri: string }>(); this._onShowBackupEvent = new Emitter<{ connection: IConnectionProfile, ownerUri: string }>();
} }
@@ -115,7 +116,7 @@ export class BackupUiService implements IBackupUiService {
}); });
} }
private getOptions(provider: string): ServiceOption[] { private getOptions(provider: string): sqlops.ServiceOption[] {
let feature = this._capabilitiesService.getLegacyCapabilities(this._currentProvider).features.find(f => f.featureName === 'backup'); let feature = this._capabilitiesService.getLegacyCapabilities(this._currentProvider).features.find(f => f.featureName === 'backup');
if (feature) { if (feature) {
return feature.optionsMetadata; return feature.optionsMetadata;
@@ -17,6 +17,11 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IPartService } from 'vs/workbench/services/part/common/partService'; import { IPartService } from 'vs/workbench/services/part/common/partService';
import { localize } from 'vs/nls'; import { localize } from 'vs/nls';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { mixin } from 'vs/base/common/objects';
import * as DOM from 'vs/base/browser/dom';
import * as strings from 'vs/base/common/strings';
import * as sqlops from 'sqlops';
import { Button } from 'sql/base/browser/ui/button/button'; import { Button } from 'sql/base/browser/ui/button/button';
import { Checkbox } from 'sql/base/browser/ui/checkbox/checkbox'; import { Checkbox } from 'sql/base/browser/ui/checkbox/checkbox';
@@ -33,14 +38,10 @@ import * as TelemetryKeys from 'sql/common/telemetryKeys';
import * as BackupConstants from 'sql/parts/disasterRecovery/backup/constants'; import * as BackupConstants from 'sql/parts/disasterRecovery/backup/constants';
import { RestoreViewModel, RestoreOptionParam, SouceDatabaseNamesParam } from 'sql/parts/disasterRecovery/restore/restoreViewModel'; import { RestoreViewModel, RestoreOptionParam, SouceDatabaseNamesParam } from 'sql/parts/disasterRecovery/restore/restoreViewModel';
import * as FileValidationConstants from 'sql/parts/fileBrowser/common/fileValidationServiceConstants'; import * as FileValidationConstants from 'sql/parts/fileBrowser/common/fileValidationServiceConstants';
import { IBootstrapService } from 'sql/services/bootstrap/bootstrapService';
import { Dropdown } from 'sql/base/browser/ui/editableDropdown/dropdown'; import { Dropdown } from 'sql/base/browser/ui/editableDropdown/dropdown';
import { TabbedPanel, PanelTabIdentifier } from 'sql/base/browser/ui/panel/panel'; import { TabbedPanel, PanelTabIdentifier } from 'sql/base/browser/ui/panel/panel';
import * as DOM from 'vs/base/browser/dom';
import * as sqlops from 'sqlops';
import * as strings from 'vs/base/common/strings';
import { ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes'; import { ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
import { mixin } from 'vs/base/common/objects'; import { IFileBrowserDialogController } from 'sql/parts/fileBrowser/common/interfaces';
interface FileListElement { interface FileListElement {
logicalFileName: string; logicalFileName: string;
@@ -130,9 +131,9 @@ export class RestoreDialog extends Modal {
@IPartService partService: IPartService, @IPartService partService: IPartService,
@IThemeService private _themeService: IThemeService, @IThemeService private _themeService: IThemeService,
@IContextViewService private _contextViewService: IContextViewService, @IContextViewService private _contextViewService: IContextViewService,
@IBootstrapService private _bootstrapService: IBootstrapService,
@ITelemetryService telemetryService: ITelemetryService, @ITelemetryService telemetryService: ITelemetryService,
@IContextKeyService contextKeyService: IContextKeyService @IContextKeyService contextKeyService: IContextKeyService,
@IFileBrowserDialogController private fileBrowserDialogService: IFileBrowserDialogController
) { ) {
super(localize('RestoreDialogTitle', 'Restore database'), TelemetryKeys.Restore, partService, telemetryService, contextKeyService, { hasErrors: true, isWide: true, hasSpinner: true }); super(localize('RestoreDialogTitle', 'Restore database'), TelemetryKeys.Restore, partService, telemetryService, contextKeyService, { hasErrors: true, isWide: true, hasSpinner: true });
this._restoreTitle = localize('restoreDialog.restoreTitle', 'Restore database'); this._restoreTitle = localize('restoreDialog.restoreTitle', 'Restore database');
@@ -656,7 +657,7 @@ export class RestoreDialog extends Modal {
} }
private onFileBrowserRequested(): void { private onFileBrowserRequested(): void {
this._bootstrapService.fileBrowserDialogService.showDialog(this._ownerUri, this.fileBrowserDialogService.showDialog(this._ownerUri,
this.viewModel.defaultBackupFolder, this.viewModel.defaultBackupFolder,
BackupConstants.fileFiltersSet, BackupConstants.fileFiltersSet,
FileValidationConstants.restore, FileValidationConstants.restore,
@@ -33,10 +33,6 @@ import { IConnectionManagementService } from 'sql/parts/connection/common/connec
import { import {
RefreshTableAction, StopRefreshTableAction, ChangeMaxRowsAction, ChangeMaxRowsActionItem, ShowQueryPaneAction RefreshTableAction, StopRefreshTableAction, ChangeMaxRowsAction, ChangeMaxRowsActionItem, ShowQueryPaneAction
} from 'sql/parts/editData/execution/editDataActions'; } from 'sql/parts/editData/execution/editDataActions';
import { EditDataModule } from 'sql/parts/grid/views/editData/editData.module';
import { IBootstrapService } from 'sql/services/bootstrap/bootstrapService';
import { EDITDATA_SELECTOR } from 'sql/parts/grid/views/editData/editData.component';
import { EditDataComponentParams } from 'sql/services/bootstrap/bootstrapParams';
import { TextResourceEditor } from 'vs/workbench/browser/parts/editor/textResourceEditor'; import { TextResourceEditor } from 'vs/workbench/browser/parts/editor/textResourceEditor';
import { CodeEditor } from 'vs/editor/browser/codeEditor'; import { CodeEditor } from 'vs/editor/browser/codeEditor';
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
@@ -93,8 +89,7 @@ export class EditDataEditor extends BaseEditor {
@IEditorDescriptorService private _editorDescriptorService: IEditorDescriptorService, @IEditorDescriptorService private _editorDescriptorService: IEditorDescriptorService,
@IEditorGroupService private _editorGroupService: IEditorGroupService, @IEditorGroupService private _editorGroupService: IEditorGroupService,
@IContextKeyService contextKeyService: IContextKeyService, @IContextKeyService contextKeyService: IContextKeyService,
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService, @IConnectionManagementService private _connectionManagementService: IConnectionManagementService
@IBootstrapService private _bootstrapService: IBootstrapService
) { ) {
super(EditDataEditor.ID, _telemetryService, themeService); super(EditDataEditor.ID, _telemetryService, themeService);
@@ -1,3 +1,9 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { Dimension, Builder } from 'vs/base/browser/builder'; import { Dimension, Builder } from 'vs/base/browser/builder';
import { EditorOptions } from 'vs/workbench/common/editor'; import { EditorOptions } from 'vs/workbench/common/editor';
import { TPromise } from 'vs/base/common/winjs.base'; import { TPromise } from 'vs/base/common/winjs.base';
@@ -5,14 +11,15 @@ import { getZoomLevel } from 'vs/base/browser/browser';
import { Configuration } from 'vs/editor/browser/config/configuration'; import { Configuration } from 'vs/editor/browser/config/configuration';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IQueryModelService } from 'sql/parts/query/execution/queryModel';
import { IBootstrapService } from 'sql/services/bootstrap/bootstrapService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { BareResultsGridInfo } from 'sql/parts/query/editor/queryResultsEditor';
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor'; import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import * as dom from 'vs/base/browser/dom'; import * as dom from 'vs/base/browser/dom';
import * as types from 'vs/base/common/types'; import * as types from 'vs/base/common/types';
import { EditDataComponentParams } from 'sql/services/bootstrap/bootstrapParams';
import { IQueryModelService } from 'sql/parts/query/execution/queryModel';
import { bootstrapAngular } from 'sql/services/bootstrap/bootstrapService';
import { BareResultsGridInfo } from 'sql/parts/query/editor/queryResultsEditor';
import { IEditDataComponentParams } from 'sql/services/bootstrap/bootstrapParams';
import { EditDataModule } from 'sql/parts/grid/views/editData/editData.module'; import { EditDataModule } from 'sql/parts/grid/views/editData/editData.module';
import { EDITDATA_SELECTOR } from 'sql/parts/grid/views/editData/editData.component'; import { EDITDATA_SELECTOR } from 'sql/parts/grid/views/editData/editData.component';
import { EditDataResultsInput } from 'sql/parts/editData/common/editDataResultsInput'; import { EditDataResultsInput } from 'sql/parts/editData/common/editDataResultsInput';
@@ -28,8 +35,8 @@ export class EditDataResultsEditor extends BaseEditor {
@ITelemetryService telemetryService: ITelemetryService, @ITelemetryService telemetryService: ITelemetryService,
@IThemeService themeService: IThemeService, @IThemeService themeService: IThemeService,
@IQueryModelService private _queryModelService: IQueryModelService, @IQueryModelService private _queryModelService: IQueryModelService,
@IBootstrapService private _bootstrapService: IBootstrapService, @IConfigurationService private _configurationService: IConfigurationService,
@IConfigurationService private _configurationService: IConfigurationService @IInstantiationService private _instantiationService: IInstantiationService
) { ) {
super(EditDataResultsEditor.ID, telemetryService, themeService); super(EditDataResultsEditor.ID, telemetryService, themeService);
this._rawOptions = BareResultsGridInfo.createFromRawSettings(this._configurationService.getValue('resultsGrid'), getZoomLevel()); this._rawOptions = BareResultsGridInfo.createFromRawSettings(this._configurationService.getValue('resultsGrid'), getZoomLevel());
@@ -102,8 +109,8 @@ export class EditDataResultsEditor extends BaseEditor {
// Otherwise many components will be left around and be subscribed // Otherwise many components will be left around and be subscribed
// to events from the backing data service // to events from the backing data service
const parent = input.container; const parent = input.container;
let params: EditDataComponentParams = { dataService: dataService }; let params: IEditDataComponentParams = { dataService: dataService };
this._bootstrapService.bootstrap( this._instantiationService.invokeFunction(bootstrapAngular,
EditDataModule, EditDataModule,
parent, parent,
EDITDATA_SELECTOR, EDITDATA_SELECTOR,
@@ -17,15 +17,22 @@ import { IGridDataRow, VirtualizedCollection } from 'angular2-slickgrid';
import { IGridDataSet } from 'sql/parts/grid/common/interfaces'; import { IGridDataSet } from 'sql/parts/grid/common/interfaces';
import * as Services from 'sql/parts/grid/services/sharedServices'; import * as Services from 'sql/parts/grid/services/sharedServices';
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService'; import { IEditDataComponentParams } from 'sql/services/bootstrap/bootstrapParams';
import { EditDataComponentParams } from 'sql/services/bootstrap/bootstrapParams';
import { GridParentComponent } from 'sql/parts/grid/views/gridParentComponent'; import { GridParentComponent } from 'sql/parts/grid/views/gridParentComponent';
import { EditDataGridActionProvider } from 'sql/parts/grid/views/editData/editDataGridActions'; import { EditDataGridActionProvider } from 'sql/parts/grid/views/editData/editDataGridActions';
import { error } from 'sql/base/common/log'; import { error } from 'sql/base/common/log';
import { clone } from 'sql/base/common/objects'; import { clone } from 'sql/base/common/objects';
import { IQueryEditorService } from 'sql/parts/query/common/queryEditorService';
import { IBootstrapParams } from 'sql/services/bootstrap/bootstrapService';
import { INotificationService } from 'vs/platform/notification/common/notification'; import { INotificationService } from 'vs/platform/notification/common/notification';
import Severity from 'vs/base/common/severity'; import Severity from 'vs/base/common/severity';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { KeyCode } from 'vs/base/common/keyCodes'; import { KeyCode } from 'vs/base/common/keyCodes';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
@@ -59,8 +66,6 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
private removingNewRow: boolean; private removingNewRow: boolean;
private rowIdMappings: { [gridRowId: number]: number } = {}; private rowIdMappings: { [gridRowId: number]: number } = {};
private notificationService: INotificationService;
// Edit Data functions // Edit Data functions
public onActiveCellChanged: (event: { row: number, column: number }) => void; public onActiveCellChanged: (event: { row: number, column: number }) => void;
public onCellEditEnd: (event: { row: number, column: number, newValue: any }) => void; public onCellEditEnd: (event: { row: number, column: number, newValue: any }) => void;
@@ -75,14 +80,20 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
constructor( constructor(
@Inject(forwardRef(() => ElementRef)) el: ElementRef, @Inject(forwardRef(() => ElementRef)) el: ElementRef,
@Inject(forwardRef(() => ChangeDetectorRef)) cd: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) cd: ChangeDetectorRef,
@Inject(BOOTSTRAP_SERVICE_ID) bootstrapService: IBootstrapService @Inject(IBootstrapParams) params: IEditDataComponentParams,
@Inject(IInstantiationService) private instantiationService: IInstantiationService,
@Inject(INotificationService) private notificationService: INotificationService,
@Inject(IContextMenuService) contextMenuService: IContextMenuService,
@Inject(IKeybindingService) keybindingService: IKeybindingService,
@Inject(IContextKeyService) contextKeyService: IContextKeyService,
@Inject(IConfigurationService) configurationService: IConfigurationService,
@Inject(IClipboardService) clipboardService: IClipboardService,
@Inject(IQueryEditorService) queryEditorService: IQueryEditorService
) { ) {
super(el, cd, bootstrapService); super(el, cd, contextMenuService, keybindingService, contextKeyService, configurationService, clipboardService, queryEditorService);
this._el.nativeElement.className = 'slickgridContainer'; this._el.nativeElement.className = 'slickgridContainer';
let editDataParameters: EditDataComponentParams = this._bootstrapService.getBootstrapParams(this._el.nativeElement.tagName); this.dataService = params.dataService;
this.dataService = editDataParameters.dataService; this.actionProvider = this.instantiationService.createInstance(EditDataGridActionProvider, this.dataService, this.onGridSelectAll(), this.onDeleteRow(), this.onRevertRow());
this.actionProvider = this._bootstrapService.instantiationService.createInstance(EditDataGridActionProvider, this.dataService, this.onGridSelectAll(), this.onDeleteRow(), this.onRevertRow());
this.notificationService = bootstrapService.notificationService;
} }
/** /**
@@ -4,13 +4,15 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { ApplicationRef, ComponentFactoryResolver, NgModule, Inject, forwardRef } from '@angular/core'; import { ApplicationRef, ComponentFactoryResolver, NgModule, Inject, forwardRef, Type } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { BrowserModule } from '@angular/platform-browser'; import { BrowserModule } from '@angular/platform-browser';
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService';
import { EditDataComponent, EDITDATA_SELECTOR } from 'sql/parts/grid/views/editData/editData.component'; import { EditDataComponent, EDITDATA_SELECTOR } from 'sql/parts/grid/views/editData/editData.component';
import { SlickGrid } from 'angular2-slickgrid'; import { SlickGrid } from 'angular2-slickgrid';
import { IBootstrapParams } from 'sql/services/bootstrap/bootstrapService';
export const EditDataModule = (params: IBootstrapParams, selector: string): Type<any> => {
@NgModule({ @NgModule({
@@ -26,20 +28,24 @@ import { SlickGrid } from 'angular2-slickgrid';
entryComponents: [ entryComponents: [
EditDataComponent EditDataComponent
],
providers: [
{ provide: IBootstrapParams, useValue: params }
] ]
}) })
export class EditDataModule { class ModuleClass {
constructor( constructor(
@Inject(forwardRef(() => ComponentFactoryResolver)) private _resolver: ComponentFactoryResolver, @Inject(forwardRef(() => ComponentFactoryResolver)) private _resolver: ComponentFactoryResolver
@Inject(BOOTSTRAP_SERVICE_ID) private _bootstrapService: IBootstrapService
) { ) {
} }
ngDoBootstrap(appRef: ApplicationRef) { ngDoBootstrap(appRef: ApplicationRef) {
const factory = this._resolver.resolveComponentFactory(EditDataComponent); const factory = this._resolver.resolveComponentFactory(EditDataComponent);
const uniqueSelector: string = this._bootstrapService.getUniqueSelector(EDITDATA_SELECTOR); (<any>factory).factory.selector = selector;
(<any>factory).factory.selector = uniqueSelector;
appRef.bootstrap(factory); appRef.bootstrap(factory);
} }
} }
return ModuleClass;
};
+16 -15
View File
@@ -24,8 +24,8 @@ import * as actions from 'sql/parts/grid/views/gridActions';
import * as Services from 'sql/parts/grid/services/sharedServices'; import * as Services from 'sql/parts/grid/services/sharedServices';
import * as GridContentEvents from 'sql/parts/grid/common/gridContentEvents'; import * as GridContentEvents from 'sql/parts/grid/common/gridContentEvents';
import { ResultsVisibleContext, ResultsGridFocussedContext, ResultsMessagesFocussedContext, QueryEditorVisibleContext } from 'sql/parts/query/common/queryContext'; import { ResultsVisibleContext, ResultsGridFocussedContext, ResultsMessagesFocussedContext, QueryEditorVisibleContext } from 'sql/parts/query/common/queryContext';
import { IBootstrapService } from 'sql/services/bootstrap/bootstrapService';
import { error } from 'sql/base/common/log'; import { error } from 'sql/base/common/log';
import { IQueryEditorService } from 'sql/parts/query/common/queryEditorService';
import { IAction } from 'vs/base/common/actions'; import { IAction } from 'vs/base/common/actions';
import { ResolvedKeybinding } from 'vs/base/common/keyCodes'; import { ResolvedKeybinding } from 'vs/base/common/keyCodes';
@@ -35,6 +35,8 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView
import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { AutoColumnSize } from 'sql/base/browser/ui/table/plugins/autoSizeColumns.plugin'; import { AutoColumnSize } from 'sql/base/browser/ui/table/plugins/autoSizeColumns.plugin';
import { DragCellSelectionModel } from 'sql/base/browser/ui/table/plugins/dragCellSelectionModel.plugin'; import { DragCellSelectionModel } from 'sql/base/browser/ui/table/plugins/dragCellSelectionModel.plugin';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
export abstract class GridParentComponent { export abstract class GridParentComponent {
@@ -63,9 +65,6 @@ export abstract class GridParentComponent {
// FIELDS // FIELDS
// Service for interaction with the IQueryModel // Service for interaction with the IQueryModel
protected dataService: DataService; protected dataService: DataService;
protected keybindingService: IKeybindingService;
protected scopedContextKeyService: IContextKeyService;
protected contextMenuService: IContextMenuService;
protected actionProvider: actions.GridActionProvider; protected actionProvider: actions.GridActionProvider;
protected toDispose: IDisposable[]; protected toDispose: IDisposable[];
@@ -114,7 +113,12 @@ export abstract class GridParentComponent {
constructor( constructor(
protected _el: ElementRef, protected _el: ElementRef,
protected _cd: ChangeDetectorRef, protected _cd: ChangeDetectorRef,
protected _bootstrapService: IBootstrapService protected contextMenuService: IContextMenuService,
protected keybindingService: IKeybindingService,
protected contextKeyService: IContextKeyService,
protected configurationService: IConfigurationService,
protected clipboardService: IClipboardService,
protected queryEditorService: IQueryEditorService
) { ) {
this.toDispose = []; this.toDispose = [];
} }
@@ -122,8 +126,8 @@ export abstract class GridParentComponent {
protected baseInit(): void { protected baseInit(): void {
const self = this; const self = this;
this.initShortcutsBase(); this.initShortcutsBase();
if (this._bootstrapService.configurationService) { if (this.configurationService) {
let sqlConfig = this._bootstrapService.configurationService.getValue('sql'); let sqlConfig = this.configurationService.getValue('sql');
if (sqlConfig) { if (sqlConfig) {
this._messageActive = sqlConfig['messagesDefaultOpen']; this._messageActive = sqlConfig['messagesDefaultOpen'];
} }
@@ -181,10 +185,7 @@ export abstract class GridParentComponent {
} }
}); });
this.contextMenuService = this._bootstrapService.contextMenuService; this.bindKeys(this.contextKeyService);
this.keybindingService = this._bootstrapService.keybindingService;
this.bindKeys(this._bootstrapService.contextKeyService);
} }
/* /*
@@ -201,7 +202,7 @@ export abstract class GridParentComponent {
this.queryEditorVisible = QueryEditorVisibleContext.bindTo(contextKeyService); this.queryEditorVisible = QueryEditorVisibleContext.bindTo(contextKeyService);
this.queryEditorVisible.set(true); this.queryEditorVisible.set(true);
let gridContextKeyService = this._bootstrapService.contextKeyService.createScoped(this._el.nativeElement); let gridContextKeyService = this.contextKeyService.createScoped(this._el.nativeElement);
this.toDispose.push(gridContextKeyService); this.toDispose.push(gridContextKeyService);
this.resultsVisibleContextKey = ResultsVisibleContext.bindTo(gridContextKeyService); this.resultsVisibleContextKey = ResultsVisibleContext.bindTo(gridContextKeyService);
this.resultsVisibleContextKey.set(true); this.resultsVisibleContextKey.set(true);
@@ -246,7 +247,7 @@ export abstract class GridParentComponent {
private copySelection(): void { private copySelection(): void {
let messageText = this.getMessageText(); let messageText = this.getMessageText();
if (messageText.length > 0) { if (messageText.length > 0) {
this._bootstrapService.clipboardService.writeText(messageText); this.clipboardService.writeText(messageText);
} else { } else {
let activeGrid = this.activeGrid; let activeGrid = this.activeGrid;
let selection = this.slickgrids.toArray()[activeGrid].getSelectedRanges(); let selection = this.slickgrids.toArray()[activeGrid].getSelectedRanges();
@@ -269,7 +270,7 @@ export abstract class GridParentComponent {
messageText = this.getMessageText(); messageText = this.getMessageText();
} }
if (messageText.length > 0) { if (messageText.length > 0) {
this._bootstrapService.clipboardService.writeText(messageText); this.clipboardService.writeText(messageText);
} }
} }
@@ -533,7 +534,7 @@ export abstract class GridParentComponent {
private handleQueryPlanLink(cellRef: string, value: string): void { private handleQueryPlanLink(cellRef: string, value: string): void {
const self = this; const self = this;
$(cellRef).children('.xmlLink').click(function (): void { $(cellRef).children('.xmlLink').click(function (): void {
self._bootstrapService.queryEditorService.newQueryPlanEditor(value); self.queryEditorService.newQueryPlanEditor(value);
}); });
} }
@@ -14,7 +14,6 @@ import { Taskbar } from 'sql/base/browser/ui/taskbar/taskbar';
import { Checkbox } from 'sql/base/browser/ui/checkbox/checkbox'; import { Checkbox } from 'sql/base/browser/ui/checkbox/checkbox';
import { ComponentHostDirective } from 'sql/parts/dashboard/common/componentHost.directive'; import { ComponentHostDirective } from 'sql/parts/dashboard/common/componentHost.directive';
import { IGridDataSet } from 'sql/parts/grid/common/interfaces'; import { IGridDataSet } from 'sql/parts/grid/common/interfaces';
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService';
import { IInsightData, IInsightsView, IInsightsConfig } from 'sql/parts/dashboard/widgets/insights/interfaces'; import { IInsightData, IInsightsView, IInsightsConfig } from 'sql/parts/dashboard/widgets/insights/interfaces';
import { Extensions, IInsightRegistry } from 'sql/platform/dashboard/common/insightRegistry'; import { Extensions, IInsightRegistry } from 'sql/platform/dashboard/common/insightRegistry';
import { QueryEditor } from 'sql/parts/query/editor/queryEditor'; import { QueryEditor } from 'sql/parts/query/editor/queryEditor';
@@ -24,6 +23,8 @@ import { IChartViewActionContext, CopyAction, CreateInsightAction, SaveImageActi
import * as WorkbenchUtils from 'sql/workbench/common/sqlWorkbenchUtils'; import * as WorkbenchUtils from 'sql/workbench/common/sqlWorkbenchUtils';
import * as Constants from 'sql/parts/query/common/constants'; import * as Constants from 'sql/parts/query/common/constants';
import { SelectBox as AngularSelectBox } from 'sql/base/browser/ui/selectBox/selectBox.component'; import { SelectBox as AngularSelectBox } from 'sql/base/browser/ui/selectBox/selectBox.component';
import { IQueryModelService } from 'sql/parts/query/execution/queryModel';
import { IClipboardService } from 'sql/platform/clipboard/common/clipboardService';
/* Insights */ /* Insights */
import { import {
@@ -40,6 +41,13 @@ import { mixin } from 'vs/base/common/objects';
import * as paths from 'vs/base/common/paths'; import * as paths from 'vs/base/common/paths';
import * as pfs from 'vs/base/node/pfs'; import * as pfs from 'vs/base/node/pfs';
import { ISelectData } from 'vs/base/browser/ui/selectBox/selectBox'; import { ISelectData } from 'vs/base/browser/ui/selectBox/selectBox';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IWindowsService, IWindowService } from 'vs/platform/windows/common/windows';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
const insightRegistry = Registry.as<IInsightRegistry>(Extensions.InsightContribution); const insightRegistry = Registry.as<IInsightRegistry>(Extensions.InsightContribution);
@@ -94,8 +102,17 @@ export class ChartViewerComponent implements OnInit, OnDestroy, IChartViewAction
constructor( constructor(
@Inject(forwardRef(() => ComponentFactoryResolver)) private _componentFactoryResolver: ComponentFactoryResolver, @Inject(forwardRef(() => ComponentFactoryResolver)) private _componentFactoryResolver: ComponentFactoryResolver,
@Inject(forwardRef(() => ViewContainerRef)) private _viewContainerRef: ViewContainerRef, @Inject(forwardRef(() => ViewContainerRef)) private _viewContainerRef: ViewContainerRef,
@Inject(BOOTSTRAP_SERVICE_ID) private _bootstrapService: IBootstrapService, @Inject(forwardRef(() => ChangeDetectorRef)) private _cd: ChangeDetectorRef,
@Inject(forwardRef(() => ChangeDetectorRef)) private _cd: ChangeDetectorRef @Inject(IInstantiationService) private instantiationService: IInstantiationService,
@Inject(INotificationService) private notificationService: INotificationService,
@Inject(IContextMenuService) private contextMenuService: IContextMenuService,
@Inject(IClipboardService) private clipboardService: IClipboardService,
@Inject(IConfigurationService) private configurationService: IConfigurationService,
@Inject(IWindowsService) private windowsService: IWindowsService,
@Inject(IWorkspaceContextService) private workspaceContextService: IWorkspaceContextService,
@Inject(IWindowService) private windowService: IWindowService,
@Inject(IQueryModelService) private queryModelService: IQueryModelService,
@Inject(IWorkbenchEditorService) private editorService: IWorkbenchEditorService
) { ) {
this.setDefaultChartConfig(); this.setDefaultChartConfig();
} }
@@ -116,8 +133,8 @@ export class ChartViewerComponent implements OnInit, OnDestroy, IChartViewAction
private getDefaultChartType(): string { private getDefaultChartType(): string {
let defaultChartType = Constants.chartTypeHorizontalBar; let defaultChartType = Constants.chartTypeHorizontalBar;
if (this._bootstrapService.configurationService) { if (this.configurationService) {
let chartSettings = WorkbenchUtils.getSqlConfigSection(this._bootstrapService.configurationService, 'chart'); let chartSettings = WorkbenchUtils.getSqlConfigSection(this.configurationService, 'chart');
// Only use the value if it's a known chart type. Ideally could query this dynamically but can't figure out how // Only use the value if it's a known chart type. Ideally could query this dynamically but can't figure out how
if (chartSettings && Constants.allChartTypes.indexOf(chartSettings[Constants.defaultChartType]) > -1) { if (chartSettings && Constants.allChartTypes.indexOf(chartSettings[Constants.defaultChartType]) > -1) {
defaultChartType = chartSettings[Constants.defaultChartType]; defaultChartType = chartSettings[Constants.defaultChartType];
@@ -127,12 +144,12 @@ export class ChartViewerComponent implements OnInit, OnDestroy, IChartViewAction
} }
private _initActionBar() { private _initActionBar() {
this._createInsightAction = this._bootstrapService.instantiationService.createInstance(CreateInsightAction); this._createInsightAction = this.instantiationService.createInstance(CreateInsightAction);
this._copyAction = this._bootstrapService.instantiationService.createInstance(CopyAction); this._copyAction = this.instantiationService.createInstance(CopyAction);
this._saveAction = this._bootstrapService.instantiationService.createInstance(SaveImageAction); this._saveAction = this.instantiationService.createInstance(SaveImageAction);
let taskbar = <HTMLElement>this.taskbarContainer.nativeElement; let taskbar = <HTMLElement>this.taskbarContainer.nativeElement;
this._actionBar = new Taskbar(taskbar, this._bootstrapService.contextMenuService); this._actionBar = new Taskbar(taskbar, this.contextMenuService);
this._actionBar.context = this; this._actionBar.context = this;
this._actionBar.setContent([ this._actionBar.setContent([
{ action: this._createInsightAction }, { action: this._createInsightAction },
@@ -180,7 +197,7 @@ export class ChartViewerComponent implements OnInit, OnDestroy, IChartViewAction
return; return;
} }
this._bootstrapService.clipboardService.writeImageDataUrl(data); this.clipboardService.writeImageDataUrl(data);
} }
public saveChart(): void { public saveChart(): void {
@@ -197,8 +214,8 @@ export class ChartViewerComponent implements OnInit, OnDestroy, IChartViewAction
this.showError(err.message); this.showError(err.message);
} else { } else {
let fileUri = URI.from({ scheme: PathUtilities.FILE_SCHEMA, path: filePath }); let fileUri = URI.from({ scheme: PathUtilities.FILE_SCHEMA, path: filePath });
this._bootstrapService.windowsService.openExternal(fileUri.toString()); this.windowsService.openExternal(fileUri.toString());
this._bootstrapService.notificationService.notify({ this.notificationService.notify({
severity: Severity.Error, severity: Severity.Error,
message: nls.localize('chartSaved', 'Saved Chart to path: {0}', filePath) message: nls.localize('chartSaved', 'Saved Chart to path: {0}', filePath)
}); });
@@ -209,9 +226,9 @@ export class ChartViewerComponent implements OnInit, OnDestroy, IChartViewAction
} }
private promptForFilepath(): Thenable<string> { private promptForFilepath(): Thenable<string> {
let filepathPlaceHolder = PathUtilities.resolveCurrentDirectory(this.getActiveUriString(), PathUtilities.getRootPath(this._bootstrapService.workspaceContextService)); let filepathPlaceHolder = PathUtilities.resolveCurrentDirectory(this.getActiveUriString(), PathUtilities.getRootPath(this.workspaceContextService));
filepathPlaceHolder = paths.join(filepathPlaceHolder, 'chart.png'); filepathPlaceHolder = paths.join(filepathPlaceHolder, 'chart.png');
return this._bootstrapService.windowService.showSaveDialog({ return this.windowService.showSaveDialog({
title: nls.localize('chartViewer.saveAsFileTitle', 'Choose Results File'), title: nls.localize('chartViewer.saveAsFileTitle', 'Choose Results File'),
defaultPath: paths.normalize(filepathPlaceHolder, true) defaultPath: paths.normalize(filepathPlaceHolder, true)
}); });
@@ -230,7 +247,7 @@ export class ChartViewerComponent implements OnInit, OnDestroy, IChartViewAction
} }
let uri: URI = URI.parse(uriString); let uri: URI = URI.parse(uriString);
let dataService = this._bootstrapService.queryModelService.getDataService(uriString); let dataService = this.queryModelService.getDataService(uriString);
if (!dataService) { if (!dataService) {
this.showError(nls.localize('createInsightNoDataService', 'Cannot create insight, backing data model not found')); this.showError(nls.localize('createInsightNoDataService', 'Cannot create insight, backing data model not found'));
return; return;
@@ -259,7 +276,7 @@ export class ChartViewerComponent implements OnInit, OnDestroy, IChartViewAction
} }
private showError(errorMsg: string) { private showError(errorMsg: string) {
this._bootstrapService.notificationService.notify({ this.notificationService.notify({
severity: Severity.Error, severity: Severity.Error,
message: errorMsg message: errorMsg
}); });
@@ -274,7 +291,7 @@ export class ChartViewerComponent implements OnInit, OnDestroy, IChartViewAction
} }
private getActiveUriString(): string { private getActiveUriString(): string {
let editorService = this._bootstrapService.editorService; let editorService = this.editorService;
let editor = editorService.getActiveEditor(); let editor = editorService.getActiveEditor();
if (editor && editor instanceof QueryEditor) { if (editor && editor instanceof QueryEditor) {
let queryEditor: QueryEditor = editor; let queryEditor: QueryEditor = editor;
@@ -22,16 +22,22 @@ import * as Services from 'sql/parts/grid/services/sharedServices';
import { IGridIcon, IMessage, IGridDataSet } from 'sql/parts/grid/common/interfaces'; import { IGridIcon, IMessage, IGridDataSet } from 'sql/parts/grid/common/interfaces';
import { GridParentComponent } from 'sql/parts/grid/views/gridParentComponent'; import { GridParentComponent } from 'sql/parts/grid/views/gridParentComponent';
import { GridActionProvider } from 'sql/parts/grid/views/gridActions'; import { GridActionProvider } from 'sql/parts/grid/views/gridActions';
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService'; import { IQueryComponentParams } from 'sql/services/bootstrap/bootstrapParams';
import { QueryComponentParams } from 'sql/services/bootstrap/bootstrapParams';
import { error } from 'sql/base/common/log'; import { error } from 'sql/base/common/log';
import { TabChild } from 'sql/base/browser/ui/panel/tab.component'; import { TabChild } from 'sql/base/browser/ui/panel/tab.component';
import { clone } from 'sql/base/common/objects'; import { clone } from 'sql/base/common/objects';
import { IQueryEditorService } from 'sql/parts/query/common/queryEditorService';
import * as strings from 'vs/base/common/strings'; import * as strings from 'vs/base/common/strings';
import * as DOM from 'vs/base/browser/dom'; import * as DOM from 'vs/base/browser/dom';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { KeyCode } from 'vs/base/common/keyCodes'; import { KeyCode } from 'vs/base/common/keyCodes';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
export const QUERY_SELECTOR: string = 'query-component'; export const QUERY_SELECTOR: string = 'query-component';
@@ -149,7 +155,7 @@ export class QueryComponent extends GridParentComponent implements OnInit, OnDes
public showChartRequested: EventEmitter<IGridDataSet> = new EventEmitter<IGridDataSet>(); public showChartRequested: EventEmitter<IGridDataSet> = new EventEmitter<IGridDataSet>();
public goToNextQueryOutputTabRequested: EventEmitter<void> = new EventEmitter<void>(); public goToNextQueryOutputTabRequested: EventEmitter<void> = new EventEmitter<void>();
@Input() public queryParameters: QueryComponentParams; @Input() public queryParameters: IQueryComponentParams;
@ViewChildren('slickgrid') slickgrids: QueryList<SlickGrid>; @ViewChildren('slickgrid') slickgrids: QueryList<SlickGrid>;
// tslint:disable-next-line:no-unused-variable // tslint:disable-next-line:no-unused-variable
@@ -159,14 +165,20 @@ export class QueryComponent extends GridParentComponent implements OnInit, OnDes
constructor( constructor(
@Inject(forwardRef(() => ElementRef)) el: ElementRef, @Inject(forwardRef(() => ElementRef)) el: ElementRef,
@Inject(forwardRef(() => ChangeDetectorRef)) cd: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) cd: ChangeDetectorRef,
@Inject(BOOTSTRAP_SERVICE_ID) bootstrapService: IBootstrapService @Inject(IInstantiationService) private instantiationService: IInstantiationService,
@Inject(IContextMenuService) contextMenuService: IContextMenuService,
@Inject(IKeybindingService) keybindingService: IKeybindingService,
@Inject(IContextKeyService) contextKeyService: IContextKeyService,
@Inject(IConfigurationService) configurationService: IConfigurationService,
@Inject(IClipboardService) clipboardService: IClipboardService,
@Inject(IQueryEditorService) queryEditorService: IQueryEditorService
) { ) {
super(el, cd, bootstrapService); super(el, cd, contextMenuService, keybindingService, contextKeyService, configurationService, clipboardService, queryEditorService);
this._el.nativeElement.className = 'slickgridContainer'; this._el.nativeElement.className = 'slickgridContainer';
this.rowHeight = bootstrapService.configurationService.getValue<any>('resultsGrid').rowHeight; this.rowHeight = configurationService.getValue<any>('resultsGrid').rowHeight;
bootstrapService.configurationService.onDidChangeConfiguration(e => { configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('resultsGrid')) { if (e.affectsConfiguration('resultsGrid')) {
this.rowHeight = bootstrapService.configurationService.getValue<any>('resultsGrid').rowHeight; this.rowHeight = configurationService.getValue<any>('resultsGrid').rowHeight;
this.slickgrids.forEach(i => { this.slickgrids.forEach(i => {
i.rowHeight = this.rowHeight; i.rowHeight = this.rowHeight;
}); });
@@ -182,7 +194,7 @@ export class QueryComponent extends GridParentComponent implements OnInit, OnDes
const self = this; const self = this;
this.dataService = this.queryParameters.dataService; this.dataService = this.queryParameters.dataService;
this.actionProvider = this._bootstrapService.instantiationService.createInstance(GridActionProvider, this.dataService, this.onGridSelectAll()); this.actionProvider = this.instantiationService.createInstance(GridActionProvider, this.dataService, this.onGridSelectAll());
this.baseInit(); this.baseInit();
this.setupResizeBind(); this.setupResizeBind();
@@ -15,7 +15,6 @@ import { IDisposable } from 'vs/base/common/lifecycle';
import * as themeColors from 'vs/workbench/common/theme'; import * as themeColors from 'vs/workbench/common/theme';
import { DashboardPage } from 'sql/parts/dashboard/common/dashboardPage.component'; import { DashboardPage } from 'sql/parts/dashboard/common/dashboardPage.component';
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar'; import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService';
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service'; import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
import { AgentJobInfo, AgentJobHistoryInfo } from 'sqlops'; import { AgentJobInfo, AgentJobHistoryInfo } from 'sqlops';
import { PanelComponent, IPanelOptions, NavigationBarLayout } from 'sql/base/browser/ui/panel/panel.component'; import { PanelComponent, IPanelOptions, NavigationBarLayout } from 'sql/base/browser/ui/panel/panel.component';
@@ -7,16 +7,12 @@ import 'vs/css!./jobHistory';
import 'vs/css!sql/media/icons/common-icons'; import 'vs/css!sql/media/icons/common-icons';
import { OnInit, OnChanges, Component, Inject, Input, forwardRef, ElementRef, ChangeDetectorRef, ViewChild, ChangeDetectionStrategy, Injectable } from '@angular/core'; import { OnInit, OnChanges, Component, Inject, Input, forwardRef, ElementRef, ChangeDetectorRef, ViewChild, ChangeDetectionStrategy, Injectable } from '@angular/core';
import { AgentJobHistoryInfo, AgentJobInfo } from 'sqlops'; import { AgentJobHistoryInfo, AgentJobInfo } from 'sqlops';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { attachListStyler } from 'vs/platform/theme/common/styler'; import { Taskbar, ITaskbarContent } from 'sql/base/browser/ui/taskbar/taskbar';
import { Tree } from 'vs/base/parts/tree/browser/treeImpl'; import { RunJobAction, StopJobAction } from 'sql/parts/jobManagement/views/jobHistoryActions';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { JobCacheObject } from 'sql/parts/jobManagement/common/jobManagementService';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle'; import { AgentJobUtilities } from '../common/agentJobUtilities';
import { localize } from 'vs/nls';
import { INotificationService } from 'vs/platform/notification/common/notification';
import Severity from 'vs/base/common/severity';
import { PanelComponent } from 'sql/base/browser/ui/panel/panel.component'; 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 { IJobManagementService } from '../common/interfaces';
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service'; import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service'; import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
@@ -25,12 +21,19 @@ import { JobHistoryController, JobHistoryDataSource,
JobHistoryRenderer, JobHistoryFilter, JobHistoryModel, JobHistoryRow } from 'sql/parts/jobManagement/views/jobHistoryTree'; JobHistoryRenderer, JobHistoryFilter, JobHistoryModel, JobHistoryRow } from 'sql/parts/jobManagement/views/jobHistoryTree';
import { JobStepsViewComponent } from 'sql/parts/jobManagement/views/jobStepsView.component'; import { JobStepsViewComponent } from 'sql/parts/jobManagement/views/jobStepsView.component';
import { JobStepsViewRow } from './jobStepsViewTree'; import { JobStepsViewRow } from './jobStepsViewTree';
import { JobCacheObject } from 'sql/parts/jobManagement/common/jobManagementService';
import { AgentJobUtilities } from '../common/agentJobUtilities'; import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { attachListStyler } from 'vs/platform/theme/common/styler';
import { Tree } from 'vs/base/parts/tree/browser/treeImpl';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { localize } from 'vs/nls';
import { INotificationService } from 'vs/platform/notification/common/notification';
import Severity from 'vs/base/common/severity';
import { ITreeOptions } from 'vs/base/parts/tree/browser/tree'; import { ITreeOptions } from 'vs/base/parts/tree/browser/tree';
import { ScrollbarVisibility } from 'vs/base/common/scrollable'; import { ScrollbarVisibility } from 'vs/base/common/scrollable';
import { Taskbar, ITaskbarContent } from 'sql/base/browser/ui/taskbar/taskbar'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { RunJobAction, StopJobAction } from 'sql/parts/jobManagement/views/jobHistoryActions';
export const DASHBOARD_SELECTOR: string = 'jobhistory-component'; export const DASHBOARD_SELECTOR: string = 'jobhistory-component';
@@ -42,7 +45,6 @@ export const DASHBOARD_SELECTOR: string = 'jobhistory-component';
@Injectable() @Injectable()
export class JobHistoryComponent extends Disposable implements OnInit { export class JobHistoryComponent extends Disposable implements OnInit {
private _jobManagementService: IJobManagementService;
private _tree: Tree; private _tree: Tree;
private _treeController: JobHistoryController; private _treeController: JobHistoryController;
private _treeDataSource: JobHistoryDataSource; private _treeDataSource: JobHistoryDataSource;
@@ -63,24 +65,25 @@ export class JobHistoryComponent extends Disposable implements OnInit {
private _showPreviousRuns: boolean = undefined; private _showPreviousRuns: boolean = undefined;
private _runStatus: string = undefined; private _runStatus: string = undefined;
private _jobCacheObject: JobCacheObject; private _jobCacheObject: JobCacheObject;
private _notificationService: INotificationService;
private _agentJobInfo: AgentJobInfo; private _agentJobInfo: AgentJobInfo;
private _noJobsAvailable: boolean = false; private _noJobsAvailable: boolean = false;
constructor( constructor(
@Inject(BOOTSTRAP_SERVICE_ID) private bootstrapService: IBootstrapService,
@Inject(forwardRef(() => ElementRef)) el: ElementRef, @Inject(forwardRef(() => ElementRef)) el: ElementRef,
@Inject(forwardRef(() => ChangeDetectorRef)) private _cd: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) private _cd: ChangeDetectorRef,
@Inject(forwardRef(() => CommonServiceInterface)) private _dashboardService: CommonServiceInterface, @Inject(forwardRef(() => CommonServiceInterface)) private _dashboardService: CommonServiceInterface,
@Inject(forwardRef(() => AgentViewComponent)) private _agentViewComponent: AgentViewComponent @Inject(forwardRef(() => AgentViewComponent)) private _agentViewComponent: AgentViewComponent,
@Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService,
@Inject(INotificationService) private _notificationService: INotificationService,
@Inject(IInstantiationService) private instantiationService: IInstantiationService,
@Inject(IContextMenuService) private contextMenuService: IContextMenuService,
@Inject(IJobManagementService) private _jobManagementService: IJobManagementService
) { ) {
super(); super();
this._treeController = new JobHistoryController(); this._treeController = new JobHistoryController();
this._treeDataSource = new JobHistoryDataSource(); this._treeDataSource = new JobHistoryDataSource();
this._treeRenderer = new JobHistoryRenderer(); this._treeRenderer = new JobHistoryRenderer();
this._treeFilter = new JobHistoryFilter(); this._treeFilter = new JobHistoryFilter();
this._jobManagementService = bootstrapService.jobManagementService;
this._notificationService = bootstrapService.notificationService;
let jobCacheObjectMap = this._jobManagementService.jobCacheObjectMap; let jobCacheObjectMap = this._jobManagementService.jobCacheObjectMap;
let serverName = _dashboardService.connectionManagementService.connectionInfo.connectionProfile.serverName; let serverName = _dashboardService.connectionManagementService.connectionInfo.connectionProfile.serverName;
let jobCache = jobCacheObjectMap[serverName]; let jobCache = jobCacheObjectMap[serverName];
@@ -129,7 +132,7 @@ export class JobHistoryComponent extends Disposable implements OnInit {
filter: this._treeFilter, filter: this._treeFilter,
renderer: this._treeRenderer renderer: this._treeRenderer
}, {verticalScrollMode: ScrollbarVisibility.Visible}); }, {verticalScrollMode: ScrollbarVisibility.Visible});
this._register(attachListStyler(this._tree, this.bootstrapService.themeService)); this._register(attachListStyler(this._tree, this.themeService));
this._tree.layout(1024); this._tree.layout(1024);
this._initActionBar(); this._initActionBar();
} }
@@ -267,10 +270,10 @@ export class JobHistoryComponent extends Disposable implements OnInit {
private _initActionBar() { private _initActionBar() {
let runJobAction = this.bootstrapService.instantiationService.createInstance(RunJobAction); let runJobAction = this.instantiationService.createInstance(RunJobAction);
let stopJobAction = this.bootstrapService.instantiationService.createInstance(StopJobAction); let stopJobAction = this.instantiationService.createInstance(StopJobAction);
let taskbar = <HTMLElement>this._actionbarContainer.nativeElement; let taskbar = <HTMLElement>this._actionbarContainer.nativeElement;
this._actionBar = new Taskbar(taskbar, this.bootstrapService.contextMenuService); this._actionBar = new Taskbar(taskbar, this.contextMenuService);
this._actionBar.context = this; this._actionBar.context = this;
this._actionBar.setContent([ this._actionBar.setContent([
{ action: runJobAction }, { action: runJobAction },
@@ -6,20 +6,23 @@
import 'vs/css!./jobStepsView'; import 'vs/css!./jobStepsView';
import { OnInit, Component, Inject, forwardRef, ElementRef, ChangeDetectorRef, ViewChild, Injectable, AfterContentChecked } from '@angular/core'; import { OnInit, Component, Inject, forwardRef, ElementRef, ChangeDetectorRef, ViewChild, Injectable, AfterContentChecked } from '@angular/core';
import { AgentJobHistoryInfo } from 'sqlops';
import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IThemeService } from 'vs/platform/theme/common/themeService';
import { attachListStyler } from 'vs/platform/theme/common/styler'; import { attachListStyler } from 'vs/platform/theme/common/styler';
import { Tree } from 'vs/base/parts/tree/browser/treeImpl'; import { Tree } from 'vs/base/parts/tree/browser/treeImpl';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle'; import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService'; import { ScrollbarVisibility } from 'vs/base/common/scrollable';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { IJobManagementService } from '../common/interfaces'; import { IJobManagementService } from '../common/interfaces';
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service'; import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service'; import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
import { AgentJobHistoryInfo } from 'sqlops';
import { JobStepsViewController, JobStepsViewDataSource, JobStepsViewFilter, import { JobStepsViewController, JobStepsViewDataSource, JobStepsViewFilter,
JobStepsViewRenderer, JobStepsViewRow, JobStepsViewModel} from 'sql/parts/jobManagement/views/jobStepsViewTree'; JobStepsViewRenderer, JobStepsViewRow, JobStepsViewModel} from 'sql/parts/jobManagement/views/jobStepsViewTree';
import { JobHistoryComponent } from 'sql/parts/jobManagement/views/jobHistory.component'; import { JobHistoryComponent } from 'sql/parts/jobManagement/views/jobHistory.component';
import { ScrollbarVisibility } from 'vs/base/common/scrollable';
export const JOBSTEPSVIEW_SELECTOR: string = 'jobstepsview-component'; export const JOBSTEPSVIEW_SELECTOR: string = 'jobstepsview-component';
@@ -29,7 +32,6 @@ export const JOBSTEPSVIEW_SELECTOR: string = 'jobstepsview-component';
}) })
export class JobStepsViewComponent extends Disposable implements OnInit, AfterContentChecked { export class JobStepsViewComponent extends Disposable implements OnInit, AfterContentChecked {
private _jobManagementService: IJobManagementService;
private _tree: Tree; private _tree: Tree;
private _treeController = new JobStepsViewController(); private _treeController = new JobStepsViewController();
private _treeDataSource = new JobStepsViewDataSource(); private _treeDataSource = new JobStepsViewDataSource();
@@ -41,14 +43,13 @@ export class JobStepsViewComponent extends Disposable implements OnInit, AfterCo
constructor( constructor(
@Inject(BOOTSTRAP_SERVICE_ID) private bootstrapService: IBootstrapService,
@Inject(forwardRef(() => ElementRef)) el: ElementRef, @Inject(forwardRef(() => ElementRef)) el: ElementRef,
@Inject(forwardRef(() => ChangeDetectorRef)) private _cd: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) private _cd: ChangeDetectorRef,
@Inject(forwardRef(() => CommonServiceInterface)) private _dashboardService: CommonServiceInterface, @Inject(forwardRef(() => CommonServiceInterface)) private _dashboardService: CommonServiceInterface,
@Inject(forwardRef(() => JobHistoryComponent)) private _jobHistoryComponent: JobHistoryComponent @Inject(forwardRef(() => JobHistoryComponent)) private _jobHistoryComponent: JobHistoryComponent,
@Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService
) { ) {
super(); super();
this._jobManagementService = bootstrapService.jobManagementService;
} }
ngAfterContentChecked() { ngAfterContentChecked() {
@@ -61,7 +62,7 @@ export class JobStepsViewComponent extends Disposable implements OnInit, AfterCo
filter: this._treeFilter, filter: this._treeFilter,
renderer: this._treeRenderer renderer: this._treeRenderer
}, { verticalScrollMode: ScrollbarVisibility.Visible }); }, { verticalScrollMode: ScrollbarVisibility.Visible });
this._register(attachListStyler(this._tree, this.bootstrapService.themeService)); this._register(attachListStyler(this._tree, this.themeService));
} }
this._tree.layout(JobStepsViewComponent._pageSize); this._tree.layout(JobStepsViewComponent._pageSize);
this._tree.setInput(new JobStepsViewModel()); this._tree.setInput(new JobStepsViewModel());
@@ -78,7 +79,7 @@ export class JobStepsViewComponent extends Disposable implements OnInit, AfterCo
filter: this._treeFilter, filter: this._treeFilter,
renderer: this._treeRenderer renderer: this._treeRenderer
}, {verticalScrollMode: ScrollbarVisibility.Visible}); }, {verticalScrollMode: ScrollbarVisibility.Visible});
this._register(attachListStyler(this._tree, this.bootstrapService.themeService)); this._register(attachListStyler(this._tree, this.themeService));
} }
} }
@@ -12,21 +12,18 @@ import 'vs/css!../common/media/jobs';
import 'vs/css!sql/media/icons/common-icons'; import 'vs/css!sql/media/icons/common-icons';
import { Component, Inject, forwardRef, ElementRef, ChangeDetectorRef, ViewChild, AfterContentChecked } from '@angular/core'; import { Component, Inject, forwardRef, ElementRef, ChangeDetectorRef, ViewChild, AfterContentChecked } from '@angular/core';
import * as Utils from 'sql/parts/connection/common/utils'; import { FieldType, IObservableCollection, CollectionChange, SlickGrid } from 'angular2-slickgrid';
import * as sqlops from 'sqlops';
import * as vscode from 'vscode';
import { IColorTheme } from 'vs/workbench/services/themes/common/workbenchThemeService'; import { IColorTheme } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { IDisposable } from 'vs/base/common/lifecycle'; import { IDisposable } from 'vs/base/common/lifecycle';
import * as themeColors from 'vs/workbench/common/theme'; import * as themeColors from 'vs/workbench/common/theme';
import { DashboardPage } from 'sql/parts/dashboard/common/dashboardPage.component';
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar'; 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'; import * as nls from 'vs/nls';
import { IGridDataSet } from 'sql/parts/grid/common/interfaces'; import { IGridDataSet } from 'sql/parts/grid/common/interfaces';
import { FieldType, IObservableCollection, CollectionChange, SlickGrid } from 'angular2-slickgrid';
import { Table } from 'sql/base/browser/ui/table/table'; import { Table } from 'sql/base/browser/ui/table/table';
import { attachTableStyler } from 'sql/common/theme/styler'; import { attachTableStyler } from 'sql/common/theme/styler';
import { JobHistoryComponent } from './jobHistory.component'; import { JobHistoryComponent } from './jobHistory.component';
@@ -34,6 +31,11 @@ import { AgentViewComponent } from '../agent/agentView.component';
import { RowDetailView } from 'sql/base/browser/ui/table/plugins/rowdetailview'; import { RowDetailView } from 'sql/base/browser/ui/table/plugins/rowdetailview';
import { JobCacheObject } from 'sql/parts/jobManagement/common/jobManagementService'; import { JobCacheObject } from 'sql/parts/jobManagement/common/jobManagementService';
import { AgentJobUtilities } from '../common/agentJobUtilities'; import { AgentJobUtilities } from '../common/agentJobUtilities';
import * as Utils from 'sql/parts/connection/common/utils';
import { IJobManagementService } from '../common/interfaces';
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
import { DashboardPage } from 'sql/parts/dashboard/common/dashboardPage.component';
export const JOBSVIEW_SELECTOR: string = 'jobsview-component'; export const JOBSVIEW_SELECTOR: string = 'jobsview-component';
@@ -45,7 +47,6 @@ export const JOBSVIEW_SELECTOR: string = 'jobsview-component';
export class JobsViewComponent implements AfterContentChecked { export class JobsViewComponent implements AfterContentChecked {
private _jobManagementService: IJobManagementService;
private _jobCacheObject: JobCacheObject; private _jobCacheObject: JobCacheObject;
private _disposables = new Array<vscode.Disposable>(); private _disposables = new Array<vscode.Disposable>();
@@ -77,13 +78,12 @@ export class JobsViewComponent implements AfterContentChecked {
private _tabHeight: number; private _tabHeight: number;
constructor( constructor(
@Inject(BOOTSTRAP_SERVICE_ID) private bootstrapService: IBootstrapService,
@Inject(forwardRef(() => CommonServiceInterface)) private _dashboardService: CommonServiceInterface, @Inject(forwardRef(() => CommonServiceInterface)) private _dashboardService: CommonServiceInterface,
@Inject(forwardRef(() => ChangeDetectorRef)) private _cd: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) private _cd: ChangeDetectorRef,
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef, @Inject(forwardRef(() => ElementRef)) private _el: ElementRef,
@Inject(forwardRef(() => AgentViewComponent)) private _agentViewComponent: AgentViewComponent @Inject(forwardRef(() => AgentViewComponent)) private _agentViewComponent: AgentViewComponent,
@Inject(IJobManagementService) private _jobManagementService: IJobManagementService
) { ) {
this._jobManagementService = bootstrapService.jobManagementService;
let jobCacheObjectMap = this._jobManagementService.jobCacheObjectMap; let jobCacheObjectMap = this._jobManagementService.jobCacheObjectMap;
this._serverName = _dashboardService.connectionManagementService.connectionInfo.connectionProfile.serverName; this._serverName = _dashboardService.connectionManagementService.connectionInfo.connectionProfile.serverName;
let jobCache = jobCacheObjectMap[this._serverName]; let jobCache = jobCacheObjectMap[this._serverName];
@@ -13,11 +13,12 @@ import Event, { Emitter } from 'vs/base/common/event';
import { ComponentBase } from 'sql/parts/modelComponents/componentBase'; import { ComponentBase } from 'sql/parts/modelComponents/componentBase';
import { IComponent, IComponentDescriptor, IModelStore, ComponentEventType } from 'sql/parts/modelComponents/interfaces'; import { IComponent, IComponentDescriptor, IModelStore, ComponentEventType } from 'sql/parts/modelComponents/interfaces';
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
import { attachListStyler } from 'vs/platform/theme/common/styler';
import { attachButtonStyler } from 'sql/common/theme/styler'; import { attachButtonStyler } from 'sql/common/theme/styler';
import { Button } from 'sql/base/browser/ui/button/button'; import { Button } from 'sql/base/browser/ui/button/button';
import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme'; import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { attachListStyler } from 'vs/platform/theme/common/styler';
@Component({ @Component({
selector: 'button', selector: 'button',
@@ -32,8 +33,9 @@ export default class ButtonComponent extends ComponentBase implements IComponent
@ViewChild('input', { read: ElementRef }) private _inputContainer: ElementRef; @ViewChild('input', { read: ElementRef }) private _inputContainer: ElementRef;
constructor( constructor(
@Inject(forwardRef(() => CommonServiceInterface)) private _commonService: CommonServiceInterface, @Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef) { @Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService
) {
super(changeRef); super(changeRef);
} }
@@ -49,7 +51,7 @@ export default class ButtonComponent extends ComponentBase implements IComponent
this._button = new Button(this._inputContainer.nativeElement); this._button = new Button(this._inputContainer.nativeElement);
this._register(this._button); this._register(this._button);
this._register(attachButtonStyler(this._button, this._commonService.themeService, { this._register(attachButtonStyler(this._button, this.themeService, {
buttonBackground: SIDE_BAR_BACKGROUND, buttonHoverBackground: SIDE_BAR_BACKGROUND buttonBackground: SIDE_BAR_BACKGROUND, buttonHoverBackground: SIDE_BAR_BACKGROUND
})); }));
this._register(this._button.onDidClick(e => { this._register(this._button.onDidClick(e => {
@@ -9,14 +9,14 @@ import { Component, Input, Inject, ChangeDetectorRef, forwardRef, ComponentFacto
} from '@angular/core'; } from '@angular/core';
import * as sqlops from 'sqlops'; import * as sqlops from 'sqlops';
import { ITheme, ICssStyleCollector } from 'vs/platform/theme/common/themeService'; import { ITheme, ICssStyleCollector } from 'vs/platform/theme/common/themeService';
import * as colors from 'vs/platform/theme/common/colorRegistry'; import * as colors from 'vs/platform/theme/common/colorRegistry';
import { IColorTheme, IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service'; import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
import { ComponentBase } from 'sql/parts/modelComponents/componentBase'; import { ComponentBase } from 'sql/parts/modelComponents/componentBase';
import { IComponent, IComponentDescriptor, IModelStore, ComponentEventType } from 'sql/parts/modelComponents/interfaces'; import { IComponent, IComponentDescriptor, IModelStore, ComponentEventType } from 'sql/parts/modelComponents/interfaces';
import { BOOTSTRAP_SERVICE_ID, IBootstrapService } from 'sql/services/bootstrap/bootstrapService';
import { IColorTheme } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { StatusIndicator, CardProperties, ActionDescriptor } from 'sql/workbench/api/common/sqlExtHostTypes'; import { StatusIndicator, CardProperties, ActionDescriptor } from 'sql/workbench/api/common/sqlExtHostTypes';
@Component({ @Component({
@@ -30,15 +30,15 @@ export default class CardComponent extends ComponentBase implements IComponent,
constructor(@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef, constructor(@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef, @Inject(forwardRef(() => ElementRef)) private _el: ElementRef,
@Inject(BOOTSTRAP_SERVICE_ID) private _bootstrapService: IBootstrapService @Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService
) { ) {
super(changeRef); super(changeRef);
} }
ngOnInit(): void { ngOnInit(): void {
this.baseInit(); this.baseInit();
this._register(this._bootstrapService.themeService.onDidColorThemeChange(this.updateTheme, this)); this._register(this.themeService.onDidColorThemeChange(this.updateTheme, this));
this.updateTheme(this._bootstrapService.themeService.getColorTheme()); this.updateTheme(this.themeService.getColorTheme());
} }
@@ -9,16 +9,19 @@ import {
} from '@angular/core'; } from '@angular/core';
import * as sqlops from 'sqlops'; import * as sqlops from 'sqlops';
import Event, { Emitter } from 'vs/base/common/event';
import { ComponentBase } from 'sql/parts/modelComponents/componentBase'; import { ComponentBase } from 'sql/parts/modelComponents/componentBase';
import { IComponent, IComponentDescriptor, IModelStore, ComponentEventType } from 'sql/parts/modelComponents/interfaces'; import { IComponent, IComponentDescriptor, IModelStore, ComponentEventType } from 'sql/parts/modelComponents/interfaces';
import { Dropdown, IDropdownOptions } from 'sql/base/browser/ui/editableDropdown/dropdown'; import { Dropdown, IDropdownOptions } from 'sql/base/browser/ui/editableDropdown/dropdown';
import { SelectBox } from 'sql/base/browser/ui/selectBox/selectBox'; import { SelectBox } from 'sql/base/browser/ui/selectBox/selectBox';
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service'; import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
import { attachListStyler } from 'vs/platform/theme/common/styler';
import { attachEditableDropdownStyler , attachSelectBoxStyler} from 'sql/common/theme/styler'; import { attachEditableDropdownStyler , attachSelectBoxStyler} from 'sql/common/theme/styler';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import Event, { Emitter } from 'vs/base/common/event';
import { attachListStyler } from 'vs/platform/theme/common/styler';
@Component({ @Component({
selector: 'dropdown', selector: 'dropdown',
template: ` template: `
@@ -38,8 +41,10 @@ export default class DropDownComponent extends ComponentBase implements ICompone
@ViewChild('editableDropDown', { read: ElementRef }) private _editableDropDownContainer: ElementRef; @ViewChild('editableDropDown', { read: ElementRef }) private _editableDropDownContainer: ElementRef;
@ViewChild('dropDown', { read: ElementRef }) private _dropDownContainer: ElementRef; @ViewChild('dropDown', { read: ElementRef }) private _dropDownContainer: ElementRef;
constructor( constructor(
@Inject(forwardRef(() => CommonServiceInterface)) private _commonService: CommonServiceInterface, @Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef) { @Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService,
@Inject(IContextViewService) private contextViewService: IContextViewService
) {
super(changeRef); super(changeRef);
} }
@@ -56,11 +61,11 @@ export default class DropDownComponent extends ComponentBase implements ICompone
maxHeight: 125, maxHeight: 125,
ariaLabel: '' ariaLabel: ''
}; };
this._editableDropdown = new Dropdown(this._editableDropDownContainer.nativeElement, this._commonService.contextViewService, this._commonService.themeService, this._editableDropdown = new Dropdown(this._editableDropDownContainer.nativeElement, this.contextViewService, this.themeService,
dropdownOptions); dropdownOptions);
this._register(this._editableDropdown); this._register(this._editableDropdown);
this._register(attachEditableDropdownStyler(this._editableDropdown, this._commonService.themeService)); this._register(attachEditableDropdownStyler(this._editableDropdown, this.themeService));
this._register(this._editableDropdown.onValueChange(e => { this._register(this._editableDropdown.onValueChange(e => {
if (this.editable) { if (this.editable) {
this.value = this._editableDropdown.value; this.value = this._editableDropdown.value;
@@ -72,11 +77,11 @@ export default class DropDownComponent extends ComponentBase implements ICompone
})); }));
} }
if (this._dropDownContainer) { if (this._dropDownContainer) {
this._selectBox = new SelectBox(this.values || [], this.value, this._commonService.contextViewService, this._dropDownContainer.nativeElement); this._selectBox = new SelectBox(this.values || [], this.value, this.contextViewService, this._dropDownContainer.nativeElement);
this._selectBox.render(this._dropDownContainer.nativeElement); this._selectBox.render(this._dropDownContainer.nativeElement);
this._register(this._selectBox); this._register(this._selectBox);
this._register(attachSelectBoxStyler(this._selectBox, this._commonService.themeService)); this._register(attachSelectBoxStyler(this._selectBox, this.themeService));
this._register(this._selectBox.onDidSelect(e => { this._register(this._selectBox.onDidSelect(e => {
if (!this.editable) { if (!this.editable) {
this.value = this._selectBox.value; this.value = this._selectBox.value;
@@ -9,14 +9,16 @@ import {
} from '@angular/core'; } from '@angular/core';
import * as sqlops from 'sqlops'; import * as sqlops from 'sqlops';
import Event, { Emitter } from 'vs/base/common/event';
import * as nls from 'vs/nls';
import { ComponentBase } from 'sql/parts/modelComponents/componentBase'; import { ComponentBase } from 'sql/parts/modelComponents/componentBase';
import { IComponent, IComponentDescriptor, IModelStore, ComponentEventType } from 'sql/parts/modelComponents/interfaces'; import { IComponent, IComponentDescriptor, IModelStore, ComponentEventType } from 'sql/parts/modelComponents/interfaces';
import { InputBox, IInputOptions, MessageType } from 'vs/base/browser/ui/inputbox/inputBox'; import { InputBox, IInputOptions, MessageType } from 'vs/base/browser/ui/inputbox/inputBox';
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
import { attachInputBoxStyler, attachListStyler } from 'vs/platform/theme/common/styler'; import { attachInputBoxStyler, attachListStyler } from 'vs/platform/theme/common/styler';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import Event, { Emitter } from 'vs/base/common/event';
import * as nls from 'vs/nls';
@Component({ @Component({
selector: 'inputBox', selector: 'inputBox',
@@ -31,8 +33,10 @@ export default class InputBoxComponent extends ComponentBase implements ICompone
@ViewChild('input', { read: ElementRef }) private _inputContainer: ElementRef; @ViewChild('input', { read: ElementRef }) private _inputContainer: ElementRef;
constructor( constructor(
@Inject(forwardRef(() => CommonServiceInterface)) private _commonService: CommonServiceInterface, @Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef) { @Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService,
@Inject(IContextViewService) private contextViewService: IContextViewService
) {
super(changeRef); super(changeRef);
} }
@@ -61,11 +65,11 @@ export default class InputBoxComponent extends ComponentBase implements ICompone
useDefaultValidation: true useDefaultValidation: true
}; };
this._input = new InputBox(this._inputContainer.nativeElement, this._commonService.contextViewService, inputOptions); this._input = new InputBox(this._inputContainer.nativeElement, this.contextViewService, inputOptions);
this._validations.push(() => !this._input.inputElement.validationMessage); this._validations.push(() => !this._input.inputElement.validationMessage);
this._register(this._input); this._register(this._input);
this._register(attachInputBoxStyler(this._input, this._commonService.themeService)); this._register(attachInputBoxStyler(this._input, this.themeService));
this._register(this._input.onDidChange(e => { this._register(this._input.onDidChange(e => {
this.value = this._input.value; this.value = this._input.value;
this._onEventEmitter.fire({ this._onEventEmitter.fire({
@@ -13,12 +13,11 @@ import { ComponentHostDirective } from 'sql/parts/dashboard/common/componentHost
import { error } from 'sql/base/common/log'; import { error } from 'sql/base/common/log';
import { AngularDisposable } from 'sql/base/common/lifecycle'; import { AngularDisposable } from 'sql/base/common/lifecycle';
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service'; 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 { IComponent, IComponentConfig, IComponentDescriptor, IModelStore, COMPONENT_CONFIG } from './interfaces';
import { Extensions, IComponentRegistry } from 'sql/platform/dashboard/common/modelComponentRegistry'; import { Extensions, IComponentRegistry } from 'sql/platform/dashboard/common/modelComponentRegistry';
import { IDisposable } from 'vs/base/common/lifecycle'; import { IDisposable } from 'vs/base/common/lifecycle';
import { IColorTheme } from 'vs/workbench/services/themes/common/workbenchThemeService'; import { IColorTheme, IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import * as colors from 'vs/platform/theme/common/colorRegistry'; import * as colors from 'vs/platform/theme/common/colorRegistry';
import * as themeColors from 'vs/workbench/common/theme'; import * as themeColors from 'vs/workbench/common/theme';
import { Action } from 'vs/base/common/actions'; import { Action } from 'vs/base/common/actions';
@@ -53,22 +52,22 @@ export class ModelComponentWrapper extends AngularDisposable implements OnInit {
constructor( constructor(
@Inject(forwardRef(() => ComponentFactoryResolver)) private _componentFactoryResolver: ComponentFactoryResolver, @Inject(forwardRef(() => ComponentFactoryResolver)) private _componentFactoryResolver: ComponentFactoryResolver,
@Inject(forwardRef(() => ElementRef)) private _ref: ElementRef, @Inject(forwardRef(() => ElementRef)) private _ref: ElementRef,
@Inject(forwardRef(() => CommonServiceInterface)) private _bootstrap: CommonServiceInterface,
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeref: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) private _changeref: ChangeDetectorRef,
@Inject(forwardRef(() => Injector)) private _injector: Injector @Inject(forwardRef(() => Injector)) private _injector: Injector,
@Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService
) { ) {
super(); super();
} }
ngOnInit() { ngOnInit() {
let self = this; let self = this;
this._register(self._bootstrap.themeService.onDidColorThemeChange((event: IColorTheme) => { this._register(self.themeService.onDidColorThemeChange((event: IColorTheme) => {
self.updateTheme(event); self.updateTheme(event);
})); }));
} }
ngAfterViewInit() { ngAfterViewInit() {
this.updateTheme(this._bootstrap.themeService.getColorTheme()); this.updateTheme(this.themeService.getColorTheme());
if (this.componentHost) { if (this.componentHost) {
this.loadComponent(); this.loadComponent();
} }
@@ -12,9 +12,10 @@ import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { Dimension } from 'vs/workbench/services/part/common/partService'; import { Dimension } from 'vs/workbench/services/part/common/partService';
import { EditorOptions } from 'vs/workbench/common/editor'; import { EditorOptions } from 'vs/workbench/common/editor';
import * as DOM from 'vs/base/browser/dom'; import * as DOM from 'vs/base/browser/dom';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ModelViewInput } from 'sql/parts/modelComponents/modelEditor/modelViewInput'; import { ModelViewInput } from 'sql/parts/modelComponents/modelEditor/modelViewInput';
import { IBootstrapService } from 'sql/services/bootstrap/bootstrapService'; import { bootstrapAngular } from 'sql/services/bootstrap/bootstrapService';
import { Dialog } from 'sql/platform/dialog/dialogTypes'; import { Dialog } from 'sql/platform/dialog/dialogTypes';
import { DialogPane } from 'sql/platform/dialog/dialogPane'; import { DialogPane } from 'sql/platform/dialog/dialogPane';
@@ -26,7 +27,7 @@ export class ModelViewEditor extends BaseEditor {
constructor( constructor(
@ITelemetryService telemetryService: ITelemetryService, @ITelemetryService telemetryService: ITelemetryService,
@IThemeService themeService: IThemeService, @IThemeService themeService: IThemeService,
@IBootstrapService private _bootstrapService: IBootstrapService @IInstantiationService private _instantiationService: IInstantiationService
) { ) {
super(ModelViewEditor.ID, telemetryService, themeService); super(ModelViewEditor.ID, telemetryService, themeService);
} }
@@ -52,7 +53,7 @@ export class ModelViewEditor extends BaseEditor {
if (!this._modelViewMap.get(input.modelViewId)) { if (!this._modelViewMap.get(input.modelViewId)) {
let modelViewContainer = DOM.$('div.model-view-container'); let modelViewContainer = DOM.$('div.model-view-container');
let dialogPane = new DialogPane(input.title, input.modelViewId, () => undefined, this._bootstrapService); let dialogPane = new DialogPane(input.title, input.modelViewId, () => undefined, this._instantiationService);
dialogPane.createBody(modelViewContainer); dialogPane.createBody(modelViewContainer);
this._modelViewMap.set(input.modelViewId, modelViewContainer); this._modelViewMap.set(input.modelViewId, modelViewContainer);
} }
@@ -17,9 +17,10 @@ import { TabConfig } from 'sql/parts/dashboard/common/dashboardWidget';
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service'; import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
import { IModelView } from 'sql/services/model/modelViewService'; import { IModelView } from 'sql/services/model/modelViewService';
import { AngularDisposable } from 'sql/base/common/lifecycle'; import { AngularDisposable } from 'sql/base/common/lifecycle';
import { ViewBase } from 'sql/parts/modelComponents/viewBase';
import { IModelViewService } from 'sql/services/modelComponents/modelViewService';
import * as sqlops from 'sqlops'; import * as sqlops from 'sqlops';
import { ViewBase } from 'sql/parts/modelComponents/viewBase';
@Component({ @Component({
selector: 'modelview-content', selector: 'modelview-content',
@@ -42,13 +43,14 @@ export class ModelViewContent extends ViewBase implements OnInit, IModelView {
constructor( constructor(
@Inject(forwardRef(() => CommonServiceInterface)) private _commonService: CommonServiceInterface, @Inject(forwardRef(() => CommonServiceInterface)) private _commonService: CommonServiceInterface,
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef @Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
@Inject(IModelViewService) private modelViewService: IModelViewService
) { ) {
super(changeRef); super(changeRef);
} }
ngOnInit() { ngOnInit() {
this._commonService.modelViewService.registerModelView(this); this.modelViewService.registerModelView(this);
this._register(addDisposableListener(window, EventType.RESIZE, e => { this._register(addDisposableListener(window, EventType.RESIZE, e => {
this.layout(); this.layout();
})); }));
@@ -12,11 +12,14 @@ import * as sqlops from 'sqlops';
import Event, { Emitter } from 'vs/base/common/event'; import Event, { Emitter } from 'vs/base/common/event';
import { Webview } from 'vs/workbench/parts/html/browser/webview'; import { Webview } from 'vs/workbench/parts/html/browser/webview';
import { addDisposableListener, EventType } from 'vs/base/browser/dom'; import { addDisposableListener, EventType } from 'vs/base/browser/dom';
import { Parts } from 'vs/workbench/services/part/common/partService'; import { Parts, IPartService } from 'vs/workbench/services/part/common/partService';
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { ComponentBase } from 'sql/parts/modelComponents/componentBase'; import { ComponentBase } from 'sql/parts/modelComponents/componentBase';
import { IComponent, IComponentDescriptor, IModelStore, ComponentEventType } from 'sql/parts/modelComponents/interfaces'; import { IComponent, IComponentDescriptor, IModelStore, ComponentEventType } from 'sql/parts/modelComponents/interfaces';
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
@Component({ @Component({
template: '', template: '',
@@ -33,7 +36,12 @@ export default class WebViewComponent extends ComponentBase implements IComponen
constructor( constructor(
@Inject(forwardRef(() => CommonServiceInterface)) private _commonService: CommonServiceInterface, @Inject(forwardRef(() => CommonServiceInterface)) private _commonService: CommonServiceInterface,
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef) { @Inject(forwardRef(() => ElementRef)) private _el: ElementRef,
@Inject(IPartService) private partService: IPartService,
@Inject(IThemeService) private themeService: IThemeService,
@Inject(IEnvironmentService) private environmentService: IEnvironmentService,
@Inject(IContextViewService) private contextViewService: IContextViewService
) {
super(changeRef); super(changeRef);
} }
@@ -47,10 +55,10 @@ export default class WebViewComponent extends ComponentBase implements IComponen
private _createWebview(): void { private _createWebview(): void {
this._webview = this._register(new Webview(this._el.nativeElement, this._webview = this._register(new Webview(this._el.nativeElement,
this._commonService.partService.getContainer(Parts.EDITOR_PART), this.partService.getContainer(Parts.EDITOR_PART),
this._commonService.themeService, this.themeService,
this._commonService.environmentService, this.environmentService,
this._commonService.contextViewService, this.contextViewService,
undefined, undefined,
undefined, undefined,
{ {
@@ -67,7 +75,7 @@ export default class WebViewComponent extends ComponentBase implements IComponen
}); });
})); }));
this._webview.style(this._commonService.themeService.getTheme()); this._webview.style(this.themeService.getTheme());
this.setHtml(); this.setHtml();
} }
@@ -21,10 +21,11 @@ import * as types from 'vs/base/common/types';
import { QueryResultsInput } from 'sql/parts/query/common/queryResultsInput'; import { QueryResultsInput } from 'sql/parts/query/common/queryResultsInput';
import { IQueryModelService } from 'sql/parts/query/execution/queryModel'; import { IQueryModelService } from 'sql/parts/query/execution/queryModel';
import { IBootstrapService } from 'sql/services/bootstrap/bootstrapService'; import { bootstrapAngular } from 'sql/services/bootstrap/bootstrapService';
import { QueryComponentParams } from 'sql/services/bootstrap/bootstrapParams'; import { IQueryComponentParams } from 'sql/services/bootstrap/bootstrapParams';
import { QueryOutputModule } from 'sql/parts/query/views/queryOutput.module'; import { QueryOutputModule } from 'sql/parts/query/views/queryOutput.module';
import { QUERY_OUTPUT_SELECTOR } from 'sql/parts/query/views/queryOutput.component'; import { QUERY_OUTPUT_SELECTOR } from 'sql/parts/query/views/queryOutput.component';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
export const RESULTS_GRID_DEFAULTS = { export const RESULTS_GRID_DEFAULTS = {
cellPadding: [6, 10, 5], cellPadding: [6, 10, 5],
@@ -99,8 +100,8 @@ export class QueryResultsEditor extends BaseEditor {
@ITelemetryService telemetryService: ITelemetryService, @ITelemetryService telemetryService: ITelemetryService,
@IThemeService themeService: IThemeService, @IThemeService themeService: IThemeService,
@IQueryModelService private _queryModelService: IQueryModelService, @IQueryModelService private _queryModelService: IQueryModelService,
@IBootstrapService private _bootstrapService: IBootstrapService, @IConfigurationService private _configurationService: IConfigurationService,
@IConfigurationService private _configurationService: IConfigurationService @IInstantiationService private _instantiationService: IInstantiationService
) { ) {
super(QueryResultsEditor.ID, telemetryService, themeService); super(QueryResultsEditor.ID, telemetryService, themeService);
this._rawOptions = BareResultsGridInfo.createFromRawSettings(this._configurationService.getValue('resultsGrid'), getZoomLevel()); this._rawOptions = BareResultsGridInfo.createFromRawSettings(this._configurationService.getValue('resultsGrid'), getZoomLevel());
@@ -168,8 +169,8 @@ export class QueryResultsEditor extends BaseEditor {
// Note: pass in input so on disposal this is cleaned up. // Note: pass in input so on disposal this is cleaned up.
// Otherwise many components will be left around and be subscribed // Otherwise many components will be left around and be subscribed
// to events from the backing data service // to events from the backing data service
let params: QueryComponentParams = { dataService: dataService }; let params: IQueryComponentParams = { dataService: dataService };
this._bootstrapService.bootstrap( this._instantiationService.invokeFunction(bootstrapAngular,
QueryOutputModule, QueryOutputModule,
this.getContainer().getHTMLElement(), this.getContainer().getHTMLElement(),
QUERY_OUTPUT_SELECTOR, QUERY_OUTPUT_SELECTOR,
@@ -12,8 +12,8 @@ import 'vs/css!sql/parts/grid/media/slick.grid';
import 'vs/css!sql/parts/grid/media/slickGrid'; import 'vs/css!sql/parts/grid/media/slickGrid';
import { ElementRef, ChangeDetectorRef, OnInit, OnDestroy, Component, Inject, forwardRef, ViewChild } from '@angular/core'; import { ElementRef, ChangeDetectorRef, OnInit, OnDestroy, Component, Inject, forwardRef, ViewChild } from '@angular/core';
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService'; import { IBootstrapParams } from 'sql/services/bootstrap/bootstrapService';
import { QueryComponentParams } from 'sql/services/bootstrap/bootstrapParams'; import { IQueryComponentParams } from 'sql/services/bootstrap/bootstrapParams';
import { QueryComponent } from 'sql/parts/grid/views/query/query.component'; import { QueryComponent } from 'sql/parts/grid/views/query/query.component';
import { QueryPlanComponent } from 'sql/parts/queryPlan/queryPlan.component'; import { QueryPlanComponent } from 'sql/parts/queryPlan/queryPlan.component';
import { TopOperationsComponent } from 'sql/parts/queryPlan/topOperations.component'; import { TopOperationsComponent } from 'sql/parts/queryPlan/topOperations.component';
@@ -61,16 +61,13 @@ export class QueryOutputComponent implements OnDestroy {
showTabsWhenOne: false showTabsWhenOne: false
}; };
public queryParameters: QueryComponentParams;
private _disposables: Array<IDisposable> = []; private _disposables: Array<IDisposable> = [];
constructor( constructor(
@Inject(forwardRef(() => ElementRef)) el: ElementRef, @Inject(forwardRef(() => ElementRef)) el: ElementRef,
@Inject(forwardRef(() => ChangeDetectorRef)) private _cd: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) private _cd: ChangeDetectorRef,
@Inject(BOOTSTRAP_SERVICE_ID) bootstrapService: IBootstrapService @Inject(IBootstrapParams) public queryParameters: IQueryComponentParams
) { ) {
this.queryParameters = bootstrapService.getBootstrapParams(el.nativeElement.tagName);
} }
/** /**
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { ApplicationRef, ComponentFactoryResolver, forwardRef, NgModule, Inject } from '@angular/core'; import { ApplicationRef, ComponentFactoryResolver, forwardRef, NgModule, Inject, Type } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { BrowserModule } from '@angular/platform-browser'; import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
@@ -13,7 +13,7 @@ import { ChartsModule } from 'ng2-charts/ng2-charts';
const BrowserAnimationsModule = (<any>require.__$__nodeRequire('@angular/platform-browser/animations')).BrowserAnimationsModule; const BrowserAnimationsModule = (<any>require.__$__nodeRequire('@angular/platform-browser/animations')).BrowserAnimationsModule;
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService'; import { IBootstrapParams } from 'sql/services/bootstrap/bootstrapService';
import { Extensions, IInsightRegistry } from 'sql/platform/dashboard/common/insightRegistry'; import { Extensions, IInsightRegistry } from 'sql/platform/dashboard/common/insightRegistry';
import { Registry } from 'vs/platform/registry/common/platform'; import { Registry } from 'vs/platform/registry/common/platform';
@@ -41,6 +41,8 @@ let baseComponents = [QueryComponent, ComponentHostDirective, QueryOutputCompone
/* Insights */ /* Insights */
let insightComponents = Registry.as<IInsightRegistry>(Extensions.InsightContribution).getAllCtors(); let insightComponents = Registry.as<IInsightRegistry>(Extensions.InsightContribution).getAllCtors();
export const QueryOutputModule = (params: IBootstrapParams, selector: string): Type<any> => {
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, CommonModule,
@@ -63,20 +65,24 @@ let insightComponents = Registry.as<IInsightRegistry>(Extensions.InsightContribu
entryComponents: [ entryComponents: [
QueryOutputComponent, QueryOutputComponent,
...insightComponents ...insightComponents
],
providers: [
{ provide: IBootstrapParams, useValue: params }
] ]
}) })
export class QueryOutputModule { class ModuleClass {
constructor( constructor(
@Inject(forwardRef(() => ComponentFactoryResolver)) private _resolver: ComponentFactoryResolver, @Inject(forwardRef(() => ComponentFactoryResolver)) private _resolver: ComponentFactoryResolver
@Inject(BOOTSTRAP_SERVICE_ID) private _bootstrapService: IBootstrapService
) { ) {
} }
ngDoBootstrap(appRef: ApplicationRef) { ngDoBootstrap(appRef: ApplicationRef) {
const factory = this._resolver.resolveComponentFactory(QueryOutputComponent); const factory = this._resolver.resolveComponentFactory(QueryOutputComponent);
const uniqueSelector: string = this._bootstrapService.getUniqueSelector(QUERY_OUTPUT_SELECTOR); (<any>factory).factory.selector = selector;
(<any>factory).factory.selector = uniqueSelector;
appRef.bootstrap(factory); appRef.bootstrap(factory);
} }
} }
return ModuleClass;
};
@@ -8,8 +8,8 @@ import 'vs/css!sql/parts/grid/load/css/qp';
import { ElementRef, Component, Inject, forwardRef, OnDestroy, OnInit, ViewChild } from '@angular/core'; import { ElementRef, Component, Inject, forwardRef, OnDestroy, OnInit, ViewChild } from '@angular/core';
import * as QP from 'html-query-plan'; import * as QP from 'html-query-plan';
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService'; import { IBootstrapParams } from 'sql/services/bootstrap/bootstrapService';
import { QueryPlanParams } from 'sql/services/bootstrap/bootstrapParams'; import { IQueryPlanParams } from 'sql/services/bootstrap/bootstrapParams';
import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { registerThemingParticipant, ICssStyleCollector, ITheme } from 'vs/platform/theme/common/themeService'; import { registerThemingParticipant, ICssStyleCollector, ITheme } from 'vs/platform/theme/common/themeService';
@@ -32,7 +32,7 @@ export class QueryPlanComponent implements OnDestroy, OnInit {
constructor( constructor(
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef, @Inject(forwardRef(() => ElementRef)) private _el: ElementRef,
@Inject(BOOTSTRAP_SERVICE_ID) private _bootstrapService: IBootstrapService @Inject(IBootstrapParams) private _params: IQueryPlanParams
) { } ) { }
ngOnDestroy() { ngOnDestroy() {
@@ -40,9 +40,8 @@ export class QueryPlanComponent implements OnDestroy, OnInit {
} }
ngOnInit() { ngOnInit() {
let parameters: QueryPlanParams = this._bootstrapService.getBootstrapParams(this._el.nativeElement.tagName); if (this._params) {
if (parameters) { this.planXml = this._params.planXml;
this.planXml = parameters.planXml;
} }
this._disposables.push(registerThemingParticipant(this._updateTheme)); this._disposables.push(registerThemingParticipant(this._updateTheme));
} }
+14 -8
View File
@@ -3,13 +3,15 @@
* Licensed under the Source EULA. See License.txt in the project root for license information. * Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { NgModule, Inject, forwardRef, ApplicationRef, ComponentFactoryResolver } from '@angular/core'; import { NgModule, Inject, forwardRef, ApplicationRef, ComponentFactoryResolver, Type } from '@angular/core';
import { APP_BASE_HREF, CommonModule } from '@angular/common'; import { APP_BASE_HREF, CommonModule } from '@angular/common';
import { BrowserModule } from '@angular/platform-browser'; import { BrowserModule } from '@angular/platform-browser';
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService'; import { IBootstrapParams } from 'sql/services/bootstrap/bootstrapService';
import { QueryPlanComponent, QUERYPLAN_SELECTOR } from 'sql/parts/queryPlan/queryPlan.component'; import { QueryPlanComponent, QUERYPLAN_SELECTOR } from 'sql/parts/queryPlan/queryPlan.component';
// Connection Dashboard main angular module // Connection Dashboard main angular module
export const QueryPlanModule = (params: IBootstrapParams, selector: string): Type<any> => {
@NgModule({ @NgModule({
declarations: [ declarations: [
QueryPlanComponent QueryPlanComponent
@@ -19,20 +21,24 @@ import { QueryPlanComponent, QUERYPLAN_SELECTOR } from 'sql/parts/queryPlan/quer
CommonModule, CommonModule,
BrowserModule BrowserModule
], ],
providers: [{ provide: APP_BASE_HREF, useValue: '/' }] providers: [
{ provide: APP_BASE_HREF, useValue: '/' },
{ provide: IBootstrapParams, useValue: params }
]
}) })
export class QueryPlanModule { class ModuleClass {
constructor( constructor(
@Inject(forwardRef(() => ComponentFactoryResolver)) private _resolver: ComponentFactoryResolver, @Inject(forwardRef(() => ComponentFactoryResolver)) private _resolver: ComponentFactoryResolver
@Inject(BOOTSTRAP_SERVICE_ID) private _bootstrapService: IBootstrapService
) { ) {
} }
ngDoBootstrap(appRef: ApplicationRef) { ngDoBootstrap(appRef: ApplicationRef) {
const factory = this._resolver.resolveComponentFactory(QueryPlanComponent); const factory = this._resolver.resolveComponentFactory(QueryPlanComponent);
const uniqueSelector: string = this._bootstrapService.getUniqueSelector(QUERYPLAN_SELECTOR); (<any>factory).factory.selector = selector;
(<any>factory).factory.selector = uniqueSelector;
appRef.bootstrap(factory); appRef.bootstrap(factory);
} }
} }
return ModuleClass;
};
+5 -6
View File
@@ -18,8 +18,8 @@ import { IConnectionManagementService } from 'sql/parts/connection/common/connec
import { IMetadataService } from 'sql/services/metadata/metadataService'; import { IMetadataService } from 'sql/services/metadata/metadataService';
import { IScriptingService } from 'sql/services/scripting/scriptingService'; import { IScriptingService } from 'sql/services/scripting/scriptingService';
import { IQueryEditorService } from 'sql/parts/query/common/queryEditorService'; import { IQueryEditorService } from 'sql/parts/query/common/queryEditorService';
import { IBootstrapService } from 'sql/services/bootstrap/bootstrapService'; import { bootstrapAngular } from 'sql/services/bootstrap/bootstrapService';
import { QueryPlanParams } from 'sql/services/bootstrap/bootstrapParams'; import { IQueryPlanParams } from 'sql/services/bootstrap/bootstrapParams';
import { QUERYPLAN_SELECTOR } from 'sql/parts/queryPlan/queryPlan.component'; import { QUERYPLAN_SELECTOR } from 'sql/parts/queryPlan/queryPlan.component';
declare let QP; declare let QP;
@@ -35,8 +35,7 @@ export class QueryPlanEditor extends BaseEditor {
@IConnectionManagementService private _connectionService: IConnectionManagementService, @IConnectionManagementService private _connectionService: IConnectionManagementService,
@IMetadataService private _metadataService: IMetadataService, @IMetadataService private _metadataService: IMetadataService,
@IScriptingService private _scriptingService: IScriptingService, @IScriptingService private _scriptingService: IScriptingService,
@IQueryEditorService private _queryEditorService: IQueryEditorService, @IQueryEditorService private _queryEditorService: IQueryEditorService
@IBootstrapService private _bootstrapService: IBootstrapService
) { ) {
super(QueryPlanEditor.ID, telemetryService, themeService); super(QueryPlanEditor.ID, telemetryService, themeService);
} }
@@ -109,11 +108,11 @@ export class QueryPlanEditor extends BaseEditor {
*/ */
private bootstrapAngular(input: QueryPlanInput): void { private bootstrapAngular(input: QueryPlanInput): void {
// Get the bootstrap params and perform the bootstrap // Get the bootstrap params and perform the bootstrap
let params: QueryPlanParams = { let params: IQueryPlanParams = {
planXml: input.planXml planXml: input.planXml
}; };
let uniqueSelector = this._bootstrapService.bootstrap( let uniqueSelector = this.instantiationService.invokeFunction(bootstrapAngular,
QueryPlanModule, QueryPlanModule,
this.getContainer().getHTMLElement(), this.getContainer().getHTMLElement(),
QUERYPLAN_SELECTOR, QUERYPLAN_SELECTOR,
@@ -10,14 +10,14 @@ import { PlanXmlParser, PlanNode } from 'sql/parts/queryPlan/planXmlParser';
import { TabChild } from 'sql/base/browser/ui/panel/tab.component'; import { TabChild } from 'sql/base/browser/ui/panel/tab.component';
import { Table } from 'sql/base/browser/ui/table/table'; import { Table } from 'sql/base/browser/ui/table/table';
import { attachTableStyler } from 'sql/common/theme/styler'; import { attachTableStyler } from 'sql/common/theme/styler';
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService'; import { IQueryComponentParams } from 'sql/services/bootstrap/bootstrapParams';
import { QueryComponentParams } from 'sql/services/bootstrap/bootstrapParams';
import * as GridContentEvents from 'sql/parts/grid/common/gridContentEvents'; import * as GridContentEvents from 'sql/parts/grid/common/gridContentEvents';
import { DataService } from 'sql/parts/grid/services/dataService'; import { DataService } from 'sql/parts/grid/services/dataService';
import { toDisposableSubscription } from 'sql/parts/common/rxjsUtils'; import { toDisposableSubscription } from 'sql/parts/common/rxjsUtils';
import { localize } from 'vs/nls'; import { localize } from 'vs/nls';
import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
export const TOP_OPERATIONS_SELECTOR: string = 'top-operations-component'; export const TOP_OPERATIONS_SELECTOR: string = 'top-operations-component';
@@ -50,14 +50,13 @@ export class TopOperationsComponent extends TabChild implements OnDestroy, OnIni
{ name: localize('topOperations.partitioned', 'Partitioned'), field: 'partitioned' } { name: localize('topOperations.partitioned', 'Partitioned'), field: 'partitioned' }
]; ];
@Input() public queryParameters: QueryComponentParams; @Input() public queryParameters: IQueryComponentParams;
private _disposables: Array<IDisposable> = []; private _disposables: Array<IDisposable> = [];
constructor( constructor(
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef, @Inject(forwardRef(() => ElementRef)) private _el: ElementRef,
@Inject(BOOTSTRAP_SERVICE_ID) private _bootstrapService: IBootstrapService, @Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService
) { ) {
super(); super();
} }
@@ -105,7 +104,7 @@ export class TopOperationsComponent extends TabChild implements OnDestroy, OnIni
return column; return column;
}); });
this._table = new Table(this._el.nativeElement, data, columns); this._table = new Table(this._el.nativeElement, data, columns);
this._disposables.push(attachTableStyler(this._table, this._bootstrapService.themeService)); this._disposables.push(attachTableStyler(this._table, this.themeService));
} }
} }
+2 -2
View File
@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information. * Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { TaskDialogComponentParams } from 'sql/services/bootstrap/bootstrapParams'; import { ITaskDialogComponentParams } from 'sql/services/bootstrap/bootstrapParams';
/** /**
* Interface for task dialog component events * Interface for task dialog component events
*/ */
@@ -14,5 +14,5 @@ export interface ITaskDialogComponent {
onCancel(): void; onCancel(): void;
injectBootstapper(parameters: TaskDialogComponentParams ): void; injectBootstapper(parameters: ITaskDialogComponentParams ): void;
} }
@@ -3,11 +3,11 @@
* Licensed under the Source EULA. See License.txt in the project root for license information. * Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService';
import { ConnectionManagementInfo } from 'sql/parts/connection/common/connectionManagementInfo'; import { ConnectionManagementInfo } from 'sql/parts/connection/common/connectionManagementInfo';
import { ITaskDialogComponent } from 'sql/parts/tasks/common/tasks'; import { ITaskDialogComponent } from 'sql/parts/tasks/common/tasks';
import { TaskDialogComponentParams } from 'sql/services/bootstrap/bootstrapParams'; import { ITaskDialogComponentParams } from 'sql/services/bootstrap/bootstrapParams';
import { ElementRef, Component, Inject, forwardRef } from '@angular/core'; import { ElementRef, Component, Inject, forwardRef } from '@angular/core';
import { IBootstrapParams } from 'sql/services/bootstrap/bootstrapService';
export const TASKDIALOG_SELECTOR: string = 'taskdialog-component'; export const TASKDIALOG_SELECTOR: string = 'taskdialog-component';
@@ -19,17 +19,14 @@ export class TaskDialogComponent {
private _currentComponent: ITaskDialogComponent; private _currentComponent: ITaskDialogComponent;
private _parameters: TaskDialogComponentParams;
public ownerUri: string; public ownerUri: string;
public connection: ConnectionManagementInfo; public connection: ConnectionManagementInfo;
constructor( constructor(
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef, @Inject(forwardRef(() => ElementRef)) private _el: ElementRef,
@Inject(BOOTSTRAP_SERVICE_ID) private _bootstrapService: IBootstrapService @Inject(IBootstrapParams) private _parameters: ITaskDialogComponentParams
) { ) {
this._parameters = this._bootstrapService.getBootstrapParams(this._el.nativeElement.tagName);
this.ownerUri = this._parameters.ownerUri; this.ownerUri = this._parameters.ownerUri;
} }
+16 -10
View File
@@ -4,15 +4,17 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { Routes, RouterModule } from '@angular/router'; import { Routes, RouterModule } from '@angular/router';
import { ApplicationRef, ComponentFactoryResolver, ModuleWithProviders, NgModule, import {
Inject, forwardRef } from '@angular/core'; ApplicationRef, ComponentFactoryResolver, ModuleWithProviders, NgModule,
Inject, forwardRef, Type
} from '@angular/core';
import { APP_BASE_HREF, CommonModule } from '@angular/common'; import { APP_BASE_HREF, CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser'; import { BrowserModule } from '@angular/platform-browser';
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService';
import { TaskDialogComponent, TASKDIALOG_SELECTOR } from 'sql/parts/tasks/dialog/taskDialog.component'; import { TaskDialogComponent, TASKDIALOG_SELECTOR } from 'sql/parts/tasks/dialog/taskDialog.component';
import { CreateDatabaseComponent } from 'sql/parts/admin/database/create/createDatabase.component'; import { CreateDatabaseComponent } from 'sql/parts/admin/database/create/createDatabase.component';
import { IBootstrapParams } from 'sql/services/bootstrap/bootstrapService';
// Setup routes for various child components // Setup routes for various child components
const appRoutes: Routes = [ const appRoutes: Routes = [
@@ -25,7 +27,7 @@ const appRoutes: Routes = [
{ path: '**', component: CreateDatabaseComponent } { path: '**', component: CreateDatabaseComponent }
]; ];
export const TaskDialogModule = (params: IBootstrapParams, selector: string): Type<any> => {
@NgModule({ @NgModule({
declarations: [ declarations: [
TaskDialogComponent, TaskDialogComponent,
@@ -38,20 +40,24 @@ const appRoutes: Routes = [
BrowserModule, BrowserModule,
<ModuleWithProviders>RouterModule.forRoot(appRoutes) <ModuleWithProviders>RouterModule.forRoot(appRoutes)
], ],
providers: [{ provide: APP_BASE_HREF, useValue: '/' }] providers: [
{ provide: APP_BASE_HREF, useValue: '/' },
{ provide: IBootstrapParams, useValue: params }
]
}) })
export class TaskDialogModule { class ModuleClass {
constructor( constructor(
@Inject(forwardRef(() => ComponentFactoryResolver)) private _resolver: ComponentFactoryResolver, @Inject(forwardRef(() => ComponentFactoryResolver)) private _resolver: ComponentFactoryResolver
@Inject(BOOTSTRAP_SERVICE_ID) private _bootstrapService: IBootstrapService
) { ) {
} }
ngDoBootstrap(appRef: ApplicationRef) { ngDoBootstrap(appRef: ApplicationRef) {
const factory = this._resolver.resolveComponentFactory(TaskDialogComponent); const factory = this._resolver.resolveComponentFactory(TaskDialogComponent);
const uniqueSelector: string = this._bootstrapService.getUniqueSelector(TASKDIALOG_SELECTOR); (<any>factory).factory.selector = selector;
(<any>factory).factory.selector = uniqueSelector;
appRef.bootstrap(factory); appRef.bootstrap(factory);
} }
} }
return ModuleClass;
};
@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import 'vs/css!sql/parts/query/editor/media/queryEditor'; import 'vs/css!sql/parts/query/editor/media/queryEditor';
import { TPromise } from 'vs/base/common/winjs.base'; import { TPromise } from 'vs/base/common/winjs.base';
import { Dimension, Builder } from 'vs/base/browser/builder'; import { Dimension, Builder } from 'vs/base/browser/builder';
import { EditorOptions } from 'vs/workbench/common/editor'; import { EditorOptions } from 'vs/workbench/common/editor';
@@ -11,11 +12,12 @@ import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { TaskDialogInput } from './taskDialogInput'; import { TaskDialogInput } from './taskDialogInput';
import { IBootstrapService } from 'sql/services/bootstrap/bootstrapService'; import { ITaskDialogComponentParams } from 'sql/services/bootstrap/bootstrapParams';
import { TaskDialogComponentParams } from 'sql/services/bootstrap/bootstrapParams';
import { TaskDialogModule } from 'sql/parts/tasks/dialog/taskDialog.module'; import { TaskDialogModule } from 'sql/parts/tasks/dialog/taskDialog.module';
import { TASKDIALOG_SELECTOR } from 'sql/parts/tasks/dialog/taskDialog.component'; import { TASKDIALOG_SELECTOR } from 'sql/parts/tasks/dialog/taskDialog.component';
import { bootstrapAngular } from 'sql/services/bootstrap/bootstrapService';
export class TaskDialogEditor extends BaseEditor { export class TaskDialogEditor extends BaseEditor {
@@ -24,8 +26,7 @@ export class TaskDialogEditor extends BaseEditor {
constructor( constructor(
@ITelemetryService telemetryService: ITelemetryService, @ITelemetryService telemetryService: ITelemetryService,
@IThemeService themeService: IThemeService, @IThemeService themeService: IThemeService,
@IInstantiationService private instantiationService: IInstantiationService, @IInstantiationService private instantiationService: IInstantiationService
@IBootstrapService private _bootstrapService: IBootstrapService
) { ) {
super(TaskDialogEditor.ID, telemetryService, themeService); super(TaskDialogEditor.ID, telemetryService, themeService);
} }
@@ -88,10 +89,10 @@ export class TaskDialogEditor extends BaseEditor {
private bootstrapAngular(input: TaskDialogInput): void { private bootstrapAngular(input: TaskDialogInput): void {
// Get the bootstrap params and perform the bootstrap // Get the bootstrap params and perform the bootstrap
let params: TaskDialogComponentParams = { let params: ITaskDialogComponentParams = {
ownerUri: input.getUri() ownerUri: input.getUri()
}; };
let uniqueSelector = this._bootstrapService.bootstrap( let uniqueSelector = this.instantiationService.invokeFunction(bootstrapAngular,
TaskDialogModule, TaskDialogModule,
this.getContainer().getHTMLElement(), this.getContainer().getHTMLElement(),
TASKDIALOG_SELECTOR, TASKDIALOG_SELECTOR,
+12 -6
View File
@@ -16,13 +16,14 @@ import { Extensions, IComponentRegistry } from 'sql/platform/dashboard/common/mo
import { ModelViewContent } from 'sql/parts/modelComponents/modelViewContent.component'; import { ModelViewContent } from 'sql/parts/modelComponents/modelViewContent.component';
import { ModelComponentWrapper } from 'sql/parts/modelComponents/modelComponentWrapper.component'; import { ModelComponentWrapper } from 'sql/parts/modelComponents/modelComponentWrapper.component';
import { ComponentHostDirective } from 'sql/parts/dashboard/common/componentHost.directive'; import { ComponentHostDirective } from 'sql/parts/dashboard/common/componentHost.directive';
import { BOOTSTRAP_SERVICE_ID, IBootstrapService } from 'sql/services/bootstrap/bootstrapService'; import { IBootstrapParams } from 'sql/services/bootstrap/bootstrapService';
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service'; import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
import { Registry } from 'vs/platform/registry/common/platform'; import { Registry } from 'vs/platform/registry/common/platform';
/* Model-backed components */ /* Model-backed components */
let extensionComponents = Registry.as<IComponentRegistry>(Extensions.ComponentContribution).getAllCtors(); let extensionComponents = Registry.as<IComponentRegistry>(Extensions.ComponentContribution).getAllCtors();
export const DialogModule = (params, selector: string): any => {
@NgModule({ @NgModule({
declarations: [ declarations: [
DialogContainer, DialogContainer,
@@ -37,21 +38,26 @@ let extensionComponents = Registry.as<IComponentRegistry>(Extensions.ComponentCo
CommonModule, CommonModule,
BrowserModule BrowserModule
], ],
providers: [{ provide: APP_BASE_HREF, useValue: '/' }, CommonServiceInterface] providers: [
{ provide: APP_BASE_HREF, useValue: '/' },
CommonServiceInterface,
{ provide: IBootstrapParams, useValue: params }
]
}) })
export class DialogModule { class ModuleClass {
constructor( constructor(
@Inject(forwardRef(() => ComponentFactoryResolver)) private _resolver: ComponentFactoryResolver, @Inject(forwardRef(() => ComponentFactoryResolver)) private _resolver: ComponentFactoryResolver,
@Inject(BOOTSTRAP_SERVICE_ID) private _bootstrapService: IBootstrapService,
@Inject(forwardRef(() => CommonServiceInterface)) bootstrap: CommonServiceInterface, @Inject(forwardRef(() => CommonServiceInterface)) bootstrap: CommonServiceInterface,
) { ) {
} }
ngDoBootstrap(appRef: ApplicationRef) { ngDoBootstrap(appRef: ApplicationRef) {
const factoryWrapper: any = this._resolver.resolveComponentFactory(DialogContainer); const factoryWrapper: any = this._resolver.resolveComponentFactory(DialogContainer);
const uniqueSelector: string = this._bootstrapService.getUniqueSelector('dialog-modelview-container'); factoryWrapper.factory.selector = selector;
factoryWrapper.factory.selector = uniqueSelector;
appRef.bootstrap(factoryWrapper); appRef.bootstrap(factoryWrapper);
} }
} }
return ModuleClass;
};
@@ -8,12 +8,11 @@
import 'vs/css!./media/dialogModal'; import 'vs/css!./media/dialogModal';
import { Component, AfterContentInit, ViewChild, Input, Inject, forwardRef, ElementRef } from '@angular/core'; import { Component, AfterContentInit, ViewChild, Input, Inject, forwardRef, ElementRef } from '@angular/core';
import { ModelViewContent } from 'sql/parts/modelComponents/modelViewContent.component'; import { ModelViewContent } from 'sql/parts/modelComponents/modelViewContent.component';
import { BootstrapParams } from 'sql/services/bootstrap/bootstrapParams'; import { IBootstrapParams } from 'sql/services/bootstrap/bootstrapService';
import { BOOTSTRAP_SERVICE_ID, IBootstrapService } from 'sql/services/bootstrap/bootstrapService';
import Event, { Emitter } from 'vs/base/common/event'; import Event, { Emitter } from 'vs/base/common/event';
import { ComponentEventType } from '../../parts/modelComponents/interfaces'; import { ComponentEventType } from '../../parts/modelComponents/interfaces';
export interface DialogComponentParams extends BootstrapParams { export interface DialogComponentParams extends IBootstrapParams {
modelViewId: string; modelViewId: string;
validityChangedCallback: (valid: boolean) => void; validityChangedCallback: (valid: boolean) => void;
} }
@@ -29,14 +28,12 @@ export interface DialogComponentParams extends BootstrapParams {
export class DialogContainer implements AfterContentInit { export class DialogContainer implements AfterContentInit {
private _onResize = new Emitter<void>(); private _onResize = new Emitter<void>();
public readonly onResize: Event<void> = this._onResize.event; public readonly onResize: Event<void> = this._onResize.event;
private _params: DialogComponentParams;
public modelViewId: string; public modelViewId: string;
@ViewChild(ModelViewContent) private _modelViewContent: ModelViewContent; @ViewChild(ModelViewContent) private _modelViewContent: ModelViewContent;
constructor( constructor(
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef, @Inject(forwardRef(() => ElementRef)) private _el: ElementRef,
@Inject(BOOTSTRAP_SERVICE_ID) bootstrapService: IBootstrapService) { @Inject(IBootstrapParams) private _params: DialogComponentParams) {
this._params = bootstrapService.getBootstrapParams(_el.nativeElement.tagName) as DialogComponentParams;
this.modelViewId = this._params.modelViewId; this.modelViewId = this._params.modelViewId;
} }
+4 -3
View File
@@ -10,7 +10,7 @@ import { Modal, IModalOptions } from 'sql/base/browser/ui/modal/modal';
import { attachModalDialogStyler } from 'sql/common/theme/styler'; import { attachModalDialogStyler } from 'sql/common/theme/styler';
import { Dialog, DialogButton } from 'sql/platform/dialog/dialogTypes'; import { Dialog, DialogButton } from 'sql/platform/dialog/dialogTypes';
import { DialogPane } from 'sql/platform/dialog/dialogPane'; import { DialogPane } from 'sql/platform/dialog/dialogPane';
import { IBootstrapService } from 'sql/services/bootstrap/bootstrapService';
import { Builder } from 'vs/base/browser/builder'; import { Builder } from 'vs/base/browser/builder';
import { IPartService } from 'vs/workbench/services/part/common/partService'; import { IPartService } from 'vs/workbench/services/part/common/partService';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
@@ -23,6 +23,7 @@ import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';
import { localize } from 'vs/nls'; import { localize } from 'vs/nls';
import Event, { Emitter } from 'vs/base/common/event'; import Event, { Emitter } from 'vs/base/common/event';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
export class DialogModal extends Modal { export class DialogModal extends Modal {
private _dialogPane: DialogPane; private _dialogPane: DialogPane;
@@ -41,7 +42,7 @@ export class DialogModal extends Modal {
@IWorkbenchThemeService private _themeService: IWorkbenchThemeService, @IWorkbenchThemeService private _themeService: IWorkbenchThemeService,
@ITelemetryService telemetryService: ITelemetryService, @ITelemetryService telemetryService: ITelemetryService,
@IContextKeyService contextKeyService: IContextKeyService, @IContextKeyService contextKeyService: IContextKeyService,
@IBootstrapService private _bootstrapService: IBootstrapService @IInstantiationService private _instantiationService: IInstantiationService
) { ) {
super(_dialog.title, name, partService, telemetryService, contextKeyService, options); super(_dialog.title, name, partService, telemetryService, contextKeyService, options);
} }
@@ -99,7 +100,7 @@ export class DialogModal extends Modal {
}); });
this._dialogPane = new DialogPane(this._dialog.title, this._dialog.content, this._dialogPane = new DialogPane(this._dialog.title, this._dialog.content,
valid => this._dialog.notifyValidityChanged(valid), this._bootstrapService); valid => this._dialog.notifyValidityChanged(valid), this._instantiationService);
this._dialogPane.createBody(body); this._dialogPane.createBody(body);
} }
+7 -3
View File
@@ -6,17 +6,21 @@
'use strict'; 'use strict';
import 'vs/css!./media/dialogModal'; import 'vs/css!./media/dialogModal';
import { NgModuleRef } from '@angular/core'; import { NgModuleRef } from '@angular/core';
import { IModalDialogStyles } from 'sql/base/browser/ui/modal/modal'; import { IModalDialogStyles } from 'sql/base/browser/ui/modal/modal';
import { Dialog, DialogTab } from 'sql/platform/dialog/dialogTypes'; import { Dialog, DialogTab } from 'sql/platform/dialog/dialogTypes';
import { TabbedPanel, IPanelTab, IPanelView } from 'sql/base/browser/ui/panel/panel'; import { TabbedPanel, IPanelTab, IPanelView } from 'sql/base/browser/ui/panel/panel';
import { IBootstrapService } from 'sql/services/bootstrap/bootstrapService'; import { bootstrapAngular } from 'sql/services/bootstrap/bootstrapService';
import { DialogModule } from 'sql/platform/dialog/dialog.module'; import { DialogModule } from 'sql/platform/dialog/dialog.module';
import { DialogComponentParams } from 'sql/platform/dialog/dialogContainer.component'; import { DialogComponentParams } from 'sql/platform/dialog/dialogContainer.component';
import { Builder } from 'vs/base/browser/builder'; import { Builder } from 'vs/base/browser/builder';
import { IThemable } from 'vs/platform/theme/common/styler'; import { IThemable } from 'vs/platform/theme/common/styler';
import { Disposable } from 'vs/base/common/lifecycle'; import { Disposable } from 'vs/base/common/lifecycle';
import Event, { Emitter } from 'vs/base/common/event'; import Event, { Emitter } from 'vs/base/common/event';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
export class DialogPane extends Disposable implements IThemable { export class DialogPane extends Disposable implements IThemable {
private _tabbedPanel: TabbedPanel; private _tabbedPanel: TabbedPanel;
@@ -35,7 +39,7 @@ export class DialogPane extends Disposable implements IThemable {
private _title: string, private _title: string,
private _content: string | DialogTab[], private _content: string | DialogTab[],
private _validityChangedCallback: (valid: boolean) => void, private _validityChangedCallback: (valid: boolean) => void,
private _bootstrapService: IBootstrapService private _instantiationService: IInstantiationService
) { ) {
super(); super();
this._tabs = []; this._tabs = [];
@@ -80,7 +84,7 @@ export class DialogPane extends Disposable implements IThemable {
* Bootstrap angular for the dialog's model view controller with the given model view ID * Bootstrap angular for the dialog's model view controller with the given model view ID
*/ */
private initializeModelViewContainer(bodyContainer: HTMLElement, modelViewId: string, tab?: DialogTab) { private initializeModelViewContainer(bodyContainer: HTMLElement, modelViewId: string, tab?: DialogTab) {
this._bootstrapService.bootstrap( this._instantiationService.invokeFunction(bootstrapAngular,
DialogModule, DialogModule,
bodyContainer, bodyContainer,
'dialog-modelview-container', 'dialog-modelview-container',
+4 -3
View File
@@ -10,7 +10,7 @@ import { Modal, IModalOptions } from 'sql/base/browser/ui/modal/modal';
import { attachModalDialogStyler } from 'sql/common/theme/styler'; import { attachModalDialogStyler } from 'sql/common/theme/styler';
import { Wizard, Dialog, DialogButton, WizardPage } from 'sql/platform/dialog/dialogTypes'; import { Wizard, Dialog, DialogButton, WizardPage } from 'sql/platform/dialog/dialogTypes';
import { DialogPane } from 'sql/platform/dialog/dialogPane'; import { DialogPane } from 'sql/platform/dialog/dialogPane';
import { IBootstrapService } from 'sql/services/bootstrap/bootstrapService'; import { bootstrapAngular } from 'sql/services/bootstrap/bootstrapService';
import { Button } from 'vs/base/browser/ui/button/button'; import { Button } from 'vs/base/browser/ui/button/button';
import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme'; import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';
import { Builder } from 'vs/base/browser/builder'; import { Builder } from 'vs/base/browser/builder';
@@ -23,6 +23,7 @@ import { attachButtonStyler } from 'vs/platform/theme/common/styler';
import { localize } from 'vs/nls'; import { localize } from 'vs/nls';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { Emitter } from 'vs/base/common/event'; import { Emitter } from 'vs/base/common/event';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
export class WizardModal extends Modal { export class WizardModal extends Modal {
private _dialogPanes = new Map<WizardPage, DialogPane>(); private _dialogPanes = new Map<WizardPage, DialogPane>();
@@ -47,7 +48,7 @@ export class WizardModal extends Modal {
@IWorkbenchThemeService private _themeService: IWorkbenchThemeService, @IWorkbenchThemeService private _themeService: IWorkbenchThemeService,
@ITelemetryService telemetryService: ITelemetryService, @ITelemetryService telemetryService: ITelemetryService,
@IContextKeyService contextKeyService: IContextKeyService, @IContextKeyService contextKeyService: IContextKeyService,
@IBootstrapService private _bootstrapService: IBootstrapService @IInstantiationService private _instantiationService: IInstantiationService
) { ) {
super(_wizard.title, name, partService, telemetryService, contextKeyService, options); super(_wizard.title, name, partService, telemetryService, contextKeyService, options);
} }
@@ -116,7 +117,7 @@ export class WizardModal extends Modal {
} }
private registerPage(page: WizardPage): void { private registerPage(page: WizardPage): void {
let dialogPane = new DialogPane(page.title, page.content, valid => page.notifyValidityChanged(valid), this._bootstrapService); let dialogPane = new DialogPane(page.title, page.content, valid => page.notifyValidityChanged(valid), this._instantiationService);
dialogPane.createBody(this._body); dialogPane.createBody(this._body);
this._dialogPanes.set(page, dialogPane); this._dialogPanes.set(page, dialogPane);
page.onUpdate(() => this.setButtonsForPage(this._wizard.currentPage)); page.onUpdate(() => this.setButtonsForPage(this._wizard.currentPage));
@@ -7,32 +7,30 @@ import { DataService } from 'sql/parts/grid/services/dataService';
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces'; import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey'; import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { ConnectionContextkey } from 'sql/parts/connection/common/connectionContextKey'; import { ConnectionContextkey } from 'sql/parts/connection/common/connectionContextKey';
import { IBootstrapParams } from './bootstrapService';
export interface BootstrapParams { export interface IQueryComponentParams extends IBootstrapParams {
}
export interface QueryComponentParams extends BootstrapParams {
dataService: DataService; dataService: DataService;
} }
export interface EditDataComponentParams extends BootstrapParams { export interface IEditDataComponentParams extends IBootstrapParams {
dataService: DataService; dataService: DataService;
} }
export interface DefaultComponentParams extends BootstrapParams { export interface IDefaultComponentParams extends IBootstrapParams {
connection: IConnectionProfile; connection: IConnectionProfile;
ownerUri: string; ownerUri: string;
scopedContextService: IContextKeyService; scopedContextService: IContextKeyService;
connectionContextKey: ConnectionContextkey; connectionContextKey: ConnectionContextkey;
} }
export interface DashboardComponentParams extends DefaultComponentParams { export interface IDashboardComponentParams extends IDefaultComponentParams {
} }
export interface TaskDialogComponentParams extends BootstrapParams { export interface ITaskDialogComponentParams extends IBootstrapParams {
ownerUri: string; ownerUri: string;
} }
export interface QueryPlanParams extends BootstrapParams { export interface IQueryPlanParams extends IBootstrapParams {
planXml: string; planXml: string;
} }
+106 -88
View File
@@ -3,20 +3,21 @@
* Licensed under the Source EULA. See License.txt in the project root for license information. * Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { NgModuleRef, InjectionToken } from '@angular/core'; import { NgModuleRef, enableProdMode, InjectionToken, ReflectiveInjector, Type, PlatformRef } from '@angular/core';
import { BootstrapParams } from 'sql/services/bootstrap/bootstrapParams'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { IConnectionManagementService, IConnectionDialogService, IErrorMessageService } import { IConnectionManagementService, IConnectionDialogService, IErrorMessageService }
from 'sql/parts/connection/common/connectionManagement'; from 'sql/parts/connection/common/connectionManagement';
import { IMetadataService } from 'sql/services/metadata/metadataService'; import { IMetadataService } from 'sql/services/metadata/metadataService';
import { IObjectExplorerService } from 'sql/parts/objectExplorer/common/objectExplorerService'; import { IObjectExplorerService } from 'sql/parts/objectExplorer/common/objectExplorerService';
import { IQueryEditorService } from 'sql/parts/query/common/queryEditorService'; import { IQueryEditorService } from 'sql/parts/query/common/queryEditorService';
import { IAngularEventingService } from 'sql/services/angularEventing/angularEventingService';
import { IScriptingService } from 'sql/services/scripting/scriptingService'; import { IScriptingService } from 'sql/services/scripting/scriptingService';
import { IQueryModelService } from 'sql/parts/query/execution/queryModel';
import { IQueryManagementService } from 'sql/parts/query/common/queryManagement'; import { IQueryManagementService } from 'sql/parts/query/common/queryManagement';
import { IQueryModelService } from 'sql/parts/query/execution/queryModel';
import { IAdminService } from 'sql/parts/admin/common/adminService'; import { IAdminService } from 'sql/parts/admin/common/adminService';
import { IRestoreDialogController, IRestoreService } from 'sql/parts/disasterRecovery/restore/common/restoreService'; import { IRestoreDialogController, IRestoreService } from 'sql/parts/disasterRecovery/restore/common/restoreService';
import { IBackupService, IBackupUiService } from 'sql/parts/disasterRecovery/backup/common/backupService'; import { IBackupService, IBackupUiService } from 'sql/parts/disasterRecovery/backup/common/backupService';
import { IAngularEventingService } from 'sql/services/angularEventing/angularEventingService';
import { IInsightsDialogService } from 'sql/parts/insights/common/interfaces'; import { IInsightsDialogService } from 'sql/parts/insights/common/interfaces';
import { ISqlOAuthService } from 'sql/common/sqlOAuthService'; import { ISqlOAuthService } from 'sql/common/sqlOAuthService';
import { IFileBrowserService, IFileBrowserDialogController } from 'sql/parts/fileBrowser/common/interfaces'; import { IFileBrowserService, IFileBrowserDialogController } from 'sql/parts/fileBrowser/common/interfaces';
@@ -24,105 +25,122 @@ import { IClipboardService } from 'sql/platform/clipboard/common/clipboardServic
import { ICapabilitiesService } from 'sql/services/capabilities/capabilitiesService'; import { ICapabilitiesService } from 'sql/services/capabilities/capabilitiesService';
import { IDashboardViewService } from 'sql/services/dashboard/common/dashboardViewService'; import { IDashboardViewService } from 'sql/services/dashboard/common/dashboardViewService';
import { IModelViewService } from 'sql/services/modelComponents/modelViewService'; import { IModelViewService } from 'sql/services/modelComponents/modelViewService';
import { IJobManagementService } from 'sql/parts/jobManagement/common/interfaces';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IContextMenuService, IContextViewService } from 'vs/platform/contextview/browser/contextView'; import { IContextMenuService, IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IEditorInput } from 'vs/platform/editor/common/editor';
import { createDecorator, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IPartService } from 'vs/workbench/services/part/common/partService'; import { IPartService } from 'vs/workbench/services/part/common/partService';
import { IEditorInput } from 'vs/platform/editor/common/editor';
import { IInstantiationService, ServicesAccessor, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IAccountManagementService } from 'sql/services/accountManagement/interfaces'; import { IAccountManagementService } from 'sql/services/accountManagement/interfaces';
import { IWindowsService, IWindowService } from 'vs/platform/windows/common/windows'; import { IWindowsService, IWindowService } from 'vs/platform/windows/common/windows';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IStorageService } from 'vs/platform/storage/common/storage'; import { IStorageService } from 'vs/platform/storage/common/storage';
import { ConfigurationEditingService } from 'vs/workbench/services/configuration/node/configurationEditingService';
import { ICommandService } from 'vs/platform/commands/common/commands'; 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 { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { INotificationService } from 'vs/platform/notification/common/notification'; import { INotificationService } from 'vs/platform/notification/common/notification';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { IClipboardService as vsIClipboardService } from 'vs/platform/clipboard/common/clipboardService';
export const BOOTSTRAP_SERVICE_ID = 'bootstrapService'; const selectorCounter = new Map<string, number>();
export const IBootstrapService = createDecorator<IBootstrapService>(BOOTSTRAP_SERVICE_ID);
/* export const IBootstrapParams = new InjectionToken('bootstrap_params');
* Handles logic for bootstrapping and passing singleton services to Angular components. export interface IBootstrapParams {
*/ }
export interface IBootstrapService {
export type IModuleFactory<T> = (params: IBootstrapParams, selector: string) => Type<T>;
_serviceBrand: any;
function createUniqueSelector(selector: string): string {
connectionManagementService: IConnectionManagementService; let num: number;
metadataService: IMetadataService; if (selectorCounter.has(selector)) {
objectExplorerService: IObjectExplorerService; num = selectorCounter.get(selector);
scriptingService: IScriptingService; } else {
queryEditorService: IQueryEditorService; num = 0;
connectionDialogService: IConnectionDialogService; }
queryModelService: IQueryModelService; selectorCounter.set(selector, num + 1);
adminService: IAdminService; return `${selector}_${num}`;
backupService: IBackupService; }
backupUiService: IBackupUiService;
restoreService: IRestoreService; let platform: PlatformRef;
keybindingService: IKeybindingService;
contextKeyService: IContextKeyService; export function bootstrapAngular<T>(collection: ServicesAccessor, moduleType: IModuleFactory<T>, container: HTMLElement, selectorString: string, params: IBootstrapParams, input?: IEditorInput, callbackSetModule?: (value: NgModuleRef<T>) => void): string {
contextMenuService: IContextMenuService; // Create the uniqueSelectorString
themeService: IWorkbenchThemeService; let uniqueSelectorString = createUniqueSelector(selectorString);
editorService: IWorkbenchEditorService; let selector = document.createElement(uniqueSelectorString);
errorMessageService: IErrorMessageService; container.appendChild(selector);
partService: IPartService;
queryManagementService: IQueryManagementService; if (!platform) {
instantiationService: IInstantiationService; // Perform the bootsrap
angularEventingService: IAngularEventingService; const providers: { provide: ServiceIdentifier<any> | InjectionToken<any>, useValue: any }[] = [
configurationService: IConfigurationService; // sql services
insightsDialogService: IInsightsDialogService; { provide: IConnectionManagementService, useValue: collection.get(IConnectionManagementService) },
contextViewService: IContextViewService; { provide: IConnectionDialogService, useValue: collection.get(IConnectionDialogService) },
restoreDialogService: IRestoreDialogController; { provide: IErrorMessageService, useValue: collection.get(IErrorMessageService) },
notificationService: INotificationService; { provide: IMetadataService, useValue: collection.get(IMetadataService) },
workspaceContextService: IWorkspaceContextService; { provide: IObjectExplorerService, useValue: collection.get(IObjectExplorerService) },
accountManagementService: IAccountManagementService; { provide: IQueryEditorService, useValue: collection.get(IQueryEditorService) },
windowsService: IWindowsService; { provide: IScriptingService, useValue: collection.get(IScriptingService) },
sqlOAuthService: ISqlOAuthService; { provide: IQueryManagementService, useValue: collection.get(IQueryManagementService) },
windowService: IWindowService; { provide: IQueryModelService, useValue: collection.get(IQueryModelService) },
fileBrowserService: IFileBrowserService; { provide: IAdminService, useValue: collection.get(IAdminService) },
fileBrowserDialogService: IFileBrowserDialogController; { provide: IRestoreDialogController, useValue: collection.get(IRestoreDialogController) },
telemetryService: ITelemetryService; { provide: IRestoreService, useValue: collection.get(IRestoreService) },
storageService: IStorageService; { provide: IBackupService, useValue: collection.get(IBackupService) },
clipboardService: IClipboardService; { provide: IBackupUiService, useValue: collection.get(IBackupUiService) },
capabilitiesService: ICapabilitiesService; { provide: IAngularEventingService, useValue: collection.get(IAngularEventingService) },
configurationEditorService: ConfigurationEditingService; { provide: IInsightsDialogService, useValue: collection.get(IInsightsDialogService) },
commandService: ICommandService; { provide: ISqlOAuthService, useValue: collection.get(ISqlOAuthService) },
dashboardViewService: IDashboardViewService; { provide: IFileBrowserService, useValue: collection.get(IFileBrowserService) },
modelViewService: IModelViewService; { provide: IFileBrowserDialogController, useValue: collection.get(IFileBrowserDialogController) },
jobManagementService: IJobManagementService; { provide: IClipboardService, useValue: collection.get(IClipboardService) },
environmentService: IEnvironmentService; { provide: ICapabilitiesService, useValue: collection.get(ICapabilitiesService) },
{ provide: IDashboardViewService, useValue: collection.get(IDashboardViewService) },
/* { provide: IModelViewService, useValue: collection.get(IModelViewService) },
* Bootstraps the Angular module described. Components that need singleton services should inject the
* 'BootstrapService' dependency to obtain a reference to this class. Components that need dynamic parameters // vscode services
* should wrap them in an object and pass them in through the "params" parameter. { provide: vsIClipboardService, useValue: collection.get(vsIClipboardService) },
* { provide: IKeybindingService, useValue: collection.get(IKeybindingService) },
* moduleType: The TypeScript type of the module to bootstrap { provide: IContextKeyService, useValue: collection.get(IContextKeyService) },
* container: The HTML container to append the selector HTMLElement { provide: IContextMenuService, useValue: collection.get(IContextMenuService) },
* selectorString: The tag name and class used to create the element, e.g. 'tagName.cssClassName' { provide: IContextViewService, useValue: collection.get(IContextViewService) },
* params: The parameters to be associated with the given id { provide: IWorkbenchEditorService, useValue: collection.get(IWorkbenchEditorService) },
* input: Optional editor input. If specified, will listen to its onDispose event and destroy the module when this happens { provide: IPartService, useValue: collection.get(IPartService) },
* callbackSetModule:Optional. If specified, will be used to set the moduleRef { provide: IInstantiationService, useValue: collection.get(IInstantiationService) },
* Returns the unique selector string that this module will bootstrap with. { provide: IConfigurationService, useValue: collection.get(IConfigurationService) },
*/ { provide: IWorkspaceContextService, useValue: collection.get(IWorkspaceContextService) },
bootstrap(moduleType: any, container: HTMLElement, selectorString: string, params: BootstrapParams, input?: IEditorInput, callbackSetModule?: (value: NgModuleRef<{}>) => void): string; { provide: IAccountManagementService, useValue: collection.get(IAccountManagementService) },
{ provide: IWindowsService, useValue: collection.get(IWindowsService) },
/* { provide: IWindowService, useValue: collection.get(IWindowService) },
* Gets the "params" entry associated with the given id and unassociates the id/entry pair. { provide: ITelemetryService, useValue: collection.get(ITelemetryService) },
* Returns undefined if no entry is found. { provide: IStorageService, useValue: collection.get(IStorageService) },
*/ { provide: ICommandService, useValue: collection.get(ICommandService) },
getBootstrapParams<T extends BootstrapParams>(id: string): T; { provide: IJobManagementService, useValue: collection.get(IJobManagementService) },
{ provide: IEnvironmentService, useValue: collection.get(IEnvironmentService) },
/* { provide: INotificationService, useValue: collection.get(INotificationService) },
* Gets the next unique selector given the baseSelectorString. A unique selector is the baseSelectorString with a { provide: IWorkbenchThemeService, useValue: collection.get(IWorkbenchThemeService) }
* number appended. E.g. if baseSelectorString='query', valid unique selectors could be query0, query1, query2, etc. ];
*/
getUniqueSelector(baseSelectorString: string): string; platform = platformBrowserDynamic(providers);
}
platform.bootstrapModule(moduleType(params, uniqueSelectorString)).then(moduleRef => {
if (input) {
input.onDispose(() => {
moduleRef.destroy();
});
}
if (callbackSetModule) {
callbackSetModule(moduleRef);
}
});
return uniqueSelectorString;
}
if (!process.env['VSCODE_DEV']) {
enableProdMode();
} }
@@ -1,199 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { NgModuleRef, enableProdMode } from '@angular/core';
import { platformBrowserDynamic, } from '@angular/platform-browser-dynamic';
import { BootstrapParams } from 'sql/services/bootstrap/bootstrapParams';
import { IConnectionManagementService, IConnectionDialogService, IErrorMessageService }
from 'sql/parts/connection/common/connectionManagement';
import { IMetadataService } from 'sql/services/metadata/metadataService';
import { IObjectExplorerService } from 'sql/parts/objectExplorer/common/objectExplorerService';
import { IQueryEditorService } from 'sql/parts/query/common/queryEditorService';
import { IScriptingService } from 'sql/services/scripting/scriptingService';
import { IQueryManagementService } from 'sql/parts/query/common/queryManagement';
import { IQueryModelService } from 'sql/parts/query/execution/queryModel';
import { IAdminService } from 'sql/parts/admin/common/adminService';
import { IRestoreDialogController, IRestoreService } from 'sql/parts/disasterRecovery/restore/common/restoreService';
import { IBackupService, IBackupUiService } from 'sql/parts/disasterRecovery/backup/common/backupService';
import { IAngularEventingService } from 'sql/services/angularEventing/angularEventingService';
import { IInsightsDialogService } from 'sql/parts/insights/common/interfaces';
import { ISqlOAuthService } from 'sql/common/sqlOAuthService';
import { IFileBrowserService, IFileBrowserDialogController } from 'sql/parts/fileBrowser/common/interfaces';
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';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IContextMenuService, IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IPartService } from 'vs/workbench/services/part/common/partService';
import { IEditorInput } from 'vs/platform/editor/common/editor';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from './bootstrapService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IAccountManagementService } from 'sql/services/accountManagement/interfaces';
import { IWindowsService, IWindowService } from 'vs/platform/windows/common/windows';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { ConfigurationEditingService } from 'vs/workbench/services/configuration/node/configurationEditingService';
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 { IThemeService } from 'vs/platform/theme/common/themeService';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
export class BootstrapService implements IBootstrapService {
public _serviceBrand: any;
// Maps uniqueSelectors (as opposed to selectors) to BootstrapParams
private _bootstrapParameterMap: Map<string, BootstrapParams>;
// Maps selectors (as opposed to uniqueSelectors) to a queue of uniqueSelectors
private _selectorQueueMap: Map<string, string[]>;
// Maps selectors (as opposed to uniqueSelectors) to the next available uniqueSelector ID number
private _selectorCountMap: Map<string, number>;
public configurationEditorService: ConfigurationEditingService;
constructor(
@IConnectionManagementService public connectionManagementService: IConnectionManagementService,
@IMetadataService public metadataService: IMetadataService,
@IObjectExplorerService public objectExplorerService: IObjectExplorerService,
@IScriptingService public scriptingService: IScriptingService,
@IQueryEditorService public queryEditorService: IQueryEditorService,
@IAdminService public adminService: IAdminService,
@IWorkbenchThemeService public themeService: IWorkbenchThemeService,
@IWorkbenchEditorService public editorService: IWorkbenchEditorService,
@IBackupService public backupService: IBackupService,
@IBackupUiService public backupUiService: IBackupUiService,
@IRestoreDialogController public restoreDialogService: IRestoreDialogController,
@IRestoreService public restoreService: IRestoreService,
@IConnectionDialogService public connectionDialogService: IConnectionDialogService,
@IQueryModelService public queryModelService: IQueryModelService,
@IKeybindingService public keybindingService: IKeybindingService,
@IContextKeyService public contextKeyService: IContextKeyService,
@IContextMenuService public contextMenuService: IContextMenuService,
@IErrorMessageService public errorMessageService: IErrorMessageService,
@IPartService public partService: IPartService,
@IQueryManagementService public queryManagementService: IQueryManagementService,
@IInstantiationService public instantiationService: IInstantiationService,
@IAngularEventingService public angularEventingService: IAngularEventingService,
@IConfigurationService public configurationService: IConfigurationService,
@IInsightsDialogService public insightsDialogService: IInsightsDialogService,
@IContextViewService public contextViewService: IContextViewService,
@INotificationService public notificationService: INotificationService,
@IWorkspaceContextService public workspaceContextService: IWorkspaceContextService,
@IAccountManagementService public accountManagementService: IAccountManagementService,
@IWindowsService public windowsService: IWindowsService,
@ISqlOAuthService public sqlOAuthService: ISqlOAuthService,
@IFileBrowserService public fileBrowserService: IFileBrowserService,
@IFileBrowserDialogController public fileBrowserDialogService: IFileBrowserDialogController,
@IWindowService public windowService: IWindowService,
@ITelemetryService public telemetryService: ITelemetryService,
@IStorageService public storageService: IStorageService,
@IClipboardService public clipboardService: IClipboardService,
@ICapabilitiesService public capabilitiesService: ICapabilitiesService,
@ICommandService public commandService: ICommandService,
@IDashboardViewService public dashboardViewService: IDashboardViewService,
@IModelViewService public modelViewService: IModelViewService,
@IJobManagementService public jobManagementService: IJobManagementService,
@IEnvironmentService public environmentService: IEnvironmentService
) {
this.configurationEditorService = this.instantiationService.createInstance(ConfigurationEditingService);
this._bootstrapParameterMap = new Map<string, BootstrapParams>();
this._selectorQueueMap = new Map<string, string[]>();
this._selectorCountMap = new Map<string, number>();
}
public bootstrap(moduleType: any, container: HTMLElement, selectorString: string, params: BootstrapParams, input?: IEditorInput, callbackSetModule?: (value: NgModuleRef<{}>) => void): string {
// Create the uniqueSelectorString
let uniqueSelectorString: string = this._getUniqueSelectorString(selectorString);
let selector: HTMLElement = $(uniqueSelectorString);
container.appendChild(selector);
// Associate the elementId
this._setUniqueSelector(selectorString, uniqueSelectorString);
// Associate the params
this._bootstrapParameterMap.set(uniqueSelectorString, params);
// Perform the bootsrap
let providers = [
{ provide: BOOTSTRAP_SERVICE_ID, useValue: this },
{ provide: IWorkbenchThemeService, useValue: this.themeService },
{ provide: IContextViewService, useValue: this.contextViewService }
];
platformBrowserDynamic(providers).bootstrapModule(moduleType).then(moduleRef => {
if (input) {
input.onDispose(() => {
moduleRef.destroy();
});
}
if (callbackSetModule) {
callbackSetModule(moduleRef);
}
});
return uniqueSelectorString;
}
public getBootstrapParams(id: string): any {
let idLowercase = id.toLowerCase();
let params: BootstrapParams = this._bootstrapParameterMap.get(idLowercase);
this._bootstrapParameterMap.delete(idLowercase);
return params;
}
public getUniqueSelector(selectorString: string): string {
let idArray = this._selectorQueueMap.get(selectorString);
if (!idArray) {
return undefined;
}
let id: string = idArray.shift();
if (idArray.length === 0) {
this._selectorQueueMap.delete(selectorString);
} else {
this._selectorQueueMap.set(selectorString, idArray);
}
return id;
}
private _getUniqueSelectorString(selectorString: string): string {
let count: number = this._selectorCountMap.get(selectorString);
if (!count) {
this._selectorCountMap.set(selectorString, 1);
count = 0;
} else {
this._selectorCountMap.set(selectorString, count + 1);
}
let casedString = selectorString + count.toString();
return casedString.toLowerCase();
}
private _setUniqueSelector(selectorString: string, elementId: string) {
let idArray = this._selectorQueueMap.get(selectorString);
if (!idArray) {
idArray = [];
}
idArray.push(elementId);
this._selectorQueueMap.set(selectorString, idArray);
}
}
if (!process.env['VSCODE_DEV']) {
enableProdMode();
}
@@ -5,46 +5,24 @@
/* Node Modules */ /* Node Modules */
import { Injectable, Inject, forwardRef, OnDestroy } from '@angular/core'; import { Injectable, Inject, forwardRef, OnDestroy } from '@angular/core';
import { Router } from '@angular/router';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
/* SQL imports */ /* SQL imports */
import { DefaultComponentParams } from 'sql/services/bootstrap/bootstrapParams'; import { IDefaultComponentParams } from 'sql/services/bootstrap/bootstrapParams';
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService'; import { IBootstrapParams } from 'sql/services/bootstrap/bootstrapService';
import { IMetadataService } from 'sql/services/metadata/metadataService'; import { IMetadataService } from 'sql/services/metadata/metadataService';
import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement'; import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement';
import { ConnectionManagementInfo } from 'sql/parts/connection/common/connectionManagementInfo'; import { ConnectionManagementInfo } from 'sql/parts/connection/common/connectionManagementInfo';
import { IAdminService } from 'sql/parts/admin/common/adminService'; import { IAdminService } from 'sql/parts/admin/common/adminService';
import { IQueryManagementService } from 'sql/parts/query/common/queryManagement'; 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 { 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 { AngularDisposable } from 'sql/base/common/lifecycle';
import { ConnectionContextkey } from 'sql/parts/connection/common/connectionContextKey'; import { ConnectionContextkey } from 'sql/parts/connection/common/connectionContextKey';
import { ProviderMetadata, DatabaseInfo, SimpleExecuteResult } from 'sqlops'; import { ProviderMetadata, DatabaseInfo, SimpleExecuteResult } from 'sqlops';
/* VS imports */ /* 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 { 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 */ /* Wrapper for a metadata service that contains the uri string to use on each request */
export class SingleConnectionMetadataService { export class SingleConnectionMetadataService {
@@ -119,115 +97,40 @@ export class SingleQueryManagementService {
export class CommonServiceInterface extends AngularDisposable { export class CommonServiceInterface extends AngularDisposable {
protected _uniqueSelector: string; protected _uniqueSelector: string;
protected _uri: 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 */ /* Special Services */
protected _metadataService: SingleConnectionMetadataService; protected _singleMetadataService: SingleConnectionMetadataService;
protected _connectionManagementService: SingleConnectionManagementService; protected _singleConnectionManagementService: SingleConnectionManagementService;
protected _adminService: SingleAdminService; protected _singleAdminService: SingleAdminService;
protected _queryManagementService: SingleQueryManagementService; protected _singleQueryManagementService: SingleQueryManagementService;
protected _contextKeyService: IContextKeyService; public scopedContextKeyService: IContextKeyService;
protected _connectionContextKey: ConnectionContextkey; protected _connectionContextKey: ConnectionContextkey;
constructor( 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(); super();
} }
public get notificationService(): INotificationService {
return this._notificationService;
}
public get configurationEditingService(): ConfigurationEditingService {
return this._configurationEditingService;
}
public get metadataService(): SingleConnectionMetadataService { public get metadataService(): SingleConnectionMetadataService {
return this._metadataService; return this._singleMetadataService;
} }
public get connectionManagementService(): SingleConnectionManagementService { public get connectionManagementService(): SingleConnectionManagementService {
return this._connectionManagementService; return this._singleConnectionManagementService;
}
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 { public get adminService(): SingleAdminService {
return this._adminService; return this._singleAdminService;
} }
public get queryManagementService(): SingleQueryManagementService { public get queryManagementService(): SingleQueryManagementService {
return this._queryManagementService; return this._singleQueryManagementService;
}
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;
} }
/** /**
@@ -239,18 +142,17 @@ export class CommonServiceInterface extends AngularDisposable {
} }
protected _getbootstrapParams(): void { protected _getbootstrapParams(): void {
this._bootstrapParams = this._bootstrapService.getBootstrapParams<DefaultComponentParams>(this._uniqueSelector); this.scopedContextKeyService = this._params.scopedContextService;
this._contextKeyService = this._bootstrapParams.scopedContextService; this._connectionContextKey = this._params.connectionContextKey;
this._connectionContextKey = this._bootstrapParams.connectionContextKey; this.uri = this._params.ownerUri;
this.uri = this._bootstrapParams.ownerUri;
} }
protected setUri(uri: string) { protected setUri(uri: string) {
this._uri = uri; this._uri = uri;
this._metadataService = new SingleConnectionMetadataService(this._bootstrapService.metadataService, this._uri); this._singleMetadataService = new SingleConnectionMetadataService(this._metadataService, this._uri);
this._connectionManagementService = new SingleConnectionManagementService(this._bootstrapService.connectionManagementService, this._uri, this._connectionContextKey); this._singleConnectionManagementService = new SingleConnectionManagementService(this._connectionManagementService, this._uri, this._connectionContextKey);
this._adminService = new SingleAdminService(this._bootstrapService.adminService, this._uri); this._singleAdminService = new SingleAdminService(this._adminService, this._uri);
this._queryManagementService = new SingleQueryManagementService(this._bootstrapService.queryManagementService, this._uri); this._singleQueryManagementService = new SingleQueryManagementService(this._queryManagementService, this._uri);
} }
/** /**
@@ -274,6 +176,6 @@ export class CommonServiceInterface extends AngularDisposable {
} }
public getOriginalConnectionProfile(): IConnectionProfile { public getOriginalConnectionProfile(): IConnectionProfile {
return this._bootstrapParams.connection; return this._params.connection;
} }
} }
+18 -15
View File
@@ -6,23 +6,23 @@
import * as assert from 'assert'; import * as assert from 'assert';
import { Mock, It, Times } from 'typemoq'; import { Mock, It, Times } from 'typemoq';
import { Dialog, DialogTab } from 'sql/platform/dialog/dialogTypes'; import { Dialog, DialogTab } from 'sql/platform/dialog/dialogTypes';
import { IBootstrapService } from 'sql/services/bootstrap/bootstrapService';
import { DialogPane } from 'sql/platform/dialog/dialogPane'; import { DialogPane } from 'sql/platform/dialog/dialogPane';
import { DialogComponentParams } from 'sql/platform/dialog/dialogContainer.component'; import { DialogComponentParams } from 'sql/platform/dialog/dialogContainer.component';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
'use strict'; 'use strict';
suite('Dialog Pane Tests', () => { suite('Dialog Pane Tests', () => {
let dialog: Dialog; let dialog: Dialog;
let mockBootstrapService: Mock<IBootstrapService>; let mockInstantiationService: Mock<IInstantiationService>;
let container: HTMLElement; let container: HTMLElement;
setup(() => { setup(() => {
dialog = new Dialog('test_dialog'); dialog = new Dialog('test_dialog');
mockBootstrapService = Mock.ofInstance({ mockInstantiationService = Mock.ofInstance({
bootstrap: () => undefined invokeFunction: () => undefined
} as any); } as any);
mockBootstrapService.setup(x => x.bootstrap(It.isAny(), It.isAny(), It.isAny(), It.isAny(), undefined, It.isAny())); mockInstantiationService.setup(x => x.invokeFunction(It.isAny(), It.isAny(), It.isAny(), It.isAny(), It.isAny(), undefined, It.isAny()));
container = document.createElement('div'); container = document.createElement('div');
}); });
@@ -30,11 +30,12 @@ suite('Dialog Pane Tests', () => {
// If I fill in a dialog's content with the ID of a specific model view provider and then render the dialog // If I fill in a dialog's content with the ID of a specific model view provider and then render the dialog
let modelViewId = 'test_content'; let modelViewId = 'test_content';
dialog.content = modelViewId; dialog.content = modelViewId;
let dialogPane = new DialogPane(dialog.title, dialog.content, () => undefined, mockBootstrapService.object); let dialogPane = new DialogPane(dialog.title, dialog.content, () => undefined, mockInstantiationService.object);
dialogPane.createBody(container); dialogPane.createBody(container);
// Then a single dialog-modelview-container element is added directly to the dialog pane // Then a single dialog-modelview-container element is added directly to the dialog pane
mockBootstrapService.verify(x => x.bootstrap( mockInstantiationService.verify(x => x.invokeFunction(
It.isAny(),
It.isAny(), It.isAny(),
It.isAny(), It.isAny(),
It.isAny(), It.isAny(),
@@ -47,11 +48,12 @@ suite('Dialog Pane Tests', () => {
// If I fill in a dialog's content with a single tab and then render the dialog // If I fill in a dialog's content with a single tab and then render the dialog
let modelViewId = 'test_content'; let modelViewId = 'test_content';
dialog.content = [new DialogTab('', modelViewId)]; dialog.content = [new DialogTab('', modelViewId)];
let dialogPane = new DialogPane(dialog.title, dialog.content, () => undefined, mockBootstrapService.object); let dialogPane = new DialogPane(dialog.title, dialog.content, () => undefined, mockInstantiationService.object);
dialogPane.createBody(container); dialogPane.createBody(container);
// Then a single dialog-modelview-container element is added directly to the dialog pane // Then a single dialog-modelview-container element is added directly to the dialog pane
mockBootstrapService.verify(x => x.bootstrap( mockInstantiationService.verify(x => x.invokeFunction(
It.isAny(),
It.isAny(), It.isAny(),
It.isAny(), It.isAny(),
It.isAny(), It.isAny(),
@@ -65,11 +67,12 @@ suite('Dialog Pane Tests', () => {
let modelViewId1 = 'test_content_1'; let modelViewId1 = 'test_content_1';
let modelViewId2 = 'test_content_2'; let modelViewId2 = 'test_content_2';
dialog.content = [new DialogTab('tab1', modelViewId1), new DialogTab('tab2', modelViewId2)]; dialog.content = [new DialogTab('tab1', modelViewId1), new DialogTab('tab2', modelViewId2)];
let dialogPane = new DialogPane(dialog.title, dialog.content, () => undefined, mockBootstrapService.object); let dialogPane = new DialogPane(dialog.title, dialog.content, () => undefined, mockInstantiationService.object);
dialogPane.createBody(container); dialogPane.createBody(container);
// Then a dialog-modelview-container element is added for the first tab (subsequent ones get added when the tab is actually clicked) // Then a dialog-modelview-container element is added for the first tab (subsequent ones get added when the tab is actually clicked)
mockBootstrapService.verify(x => x.bootstrap( mockInstantiationService.verify(x => x.invokeFunction(
It.isAny(),
It.isAny(), It.isAny(),
It.isAny(), It.isAny(),
It.isAny(), It.isAny(),
@@ -81,16 +84,16 @@ suite('Dialog Pane Tests', () => {
test('Dialog validation gets set based on the validity of the model view content', () => { test('Dialog validation gets set based on the validity of the model view content', () => {
// Set up the mock bootstrap service to intercept validation callbacks // Set up the mock bootstrap service to intercept validation callbacks
let validationCallbacks: ((valid: boolean) => void)[] = []; let validationCallbacks: ((valid: boolean) => void)[] = [];
mockBootstrapService.reset(); mockInstantiationService.reset();
mockBootstrapService.setup(x => x.bootstrap(It.isAny(), It.isAny(), It.isAny(), It.isAny(), undefined, It.isAny())).callback( mockInstantiationService.setup(x => x.invokeFunction(It.isAny(), It.isAny(), It.isAny(), It.isAny(), It.isAny(), undefined, It.isAny())).callback(
(moduleType, container, selectorString, params: DialogComponentParams, input, callbackSetModule) => { (collection, moduleType, container, selectorString, params: DialogComponentParams, input, callbackSetModule) => {
validationCallbacks.push(params.validityChangedCallback); validationCallbacks.push(params.validityChangedCallback);
}); });
let modelViewId1 = 'test_content_1'; let modelViewId1 = 'test_content_1';
let modelViewId2 = 'test_content_2'; let modelViewId2 = 'test_content_2';
dialog.content = [new DialogTab('tab1', modelViewId1), new DialogTab('tab2', modelViewId2)]; dialog.content = [new DialogTab('tab1', modelViewId1), new DialogTab('tab2', modelViewId2)];
let dialogPane = new DialogPane(dialog.title, dialog.content, valid => dialog.notifyValidityChanged(valid), mockBootstrapService.object); let dialogPane = new DialogPane(dialog.title, dialog.content, valid => dialog.notifyValidityChanged(valid), mockInstantiationService.object);
dialogPane.createBody(container); dialogPane.createBody(container);
let validityChanges: boolean[] = []; let validityChanges: boolean[] = [];
@@ -113,9 +113,7 @@ import { ConnectionDialogService } from 'sql/parts/connection/connectionDialog/c
import { ErrorMessageService } from 'sql/workbench/errorMessageDialog/errorMessageService'; import { ErrorMessageService } from 'sql/workbench/errorMessageDialog/errorMessageService';
import { ServerGroupController } from 'sql/parts/objectExplorer/serverGroupDialog/serverGroupController'; import { ServerGroupController } from 'sql/parts/objectExplorer/serverGroupDialog/serverGroupController';
import { IBootstrapService } from 'sql/services/bootstrap/bootstrapService';
import { IAngularEventingService, AngularEventingService } from 'sql/services/angularEventing/angularEventingService'; import { IAngularEventingService, AngularEventingService } from 'sql/services/angularEventing/angularEventingService';
import { BootstrapService } from 'sql/services/bootstrap/bootstrapServiceImpl';
import { ICapabilitiesService, CapabilitiesService } from 'sql/services/capabilities/capabilitiesService'; import { ICapabilitiesService, CapabilitiesService } from 'sql/services/capabilities/capabilitiesService';
import { ICredentialsService, CredentialsService } from 'sql/services/credentials/credentialsService'; import { ICredentialsService, CredentialsService } from 'sql/services/credentials/credentialsService';
import { ISerializationService, SerializationService } from 'sql/services/serialization/serializationService'; import { ISerializationService, SerializationService } from 'sql/services/serialization/serializationService';
@@ -715,7 +713,6 @@ export class Workbench implements IPartService {
let accountManagementService = this.instantiationService.createInstance(AccountManagementService, undefined); let accountManagementService = this.instantiationService.createInstance(AccountManagementService, undefined);
serviceCollection.set(IAccountManagementService, accountManagementService); serviceCollection.set(IAccountManagementService, accountManagementService);
serviceCollection.set(IAccountPickerService, this.instantiationService.createInstance(AccountPickerService)); serviceCollection.set(IAccountPickerService, this.instantiationService.createInstance(AccountPickerService));
serviceCollection.set(IBootstrapService, this.instantiationService.createInstance(BootstrapService));
serviceCollection.set(IProfilerService, this.instantiationService.createInstance(ProfilerService)); serviceCollection.set(IProfilerService, this.instantiationService.createInstance(ProfilerService));
this.toUnbind.push({ dispose: () => connectionManagementService.shutdown() }); this.toUnbind.push({ dispose: () => connectionManagementService.shutdown() });