Remove logging and clone utlities (#5309)

* remove log utility functions; remove custom mixin

* fix tests

* add log service as required by telemetry utils

* remove unused code

* replace some console.logs with logservice
This commit is contained in:
Anthony Dresser
2019-05-04 22:37:15 -07:00
committed by GitHub
parent df7645e4e5
commit ab0cd71d10
80 changed files with 439 additions and 383 deletions

View File

@@ -9,7 +9,6 @@ import { Registry } from 'vs/platform/registry/common/platform';
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/workbench/parts/dashboard/common/dashboardWidget';
import { Extensions, IInsightRegistry } from 'sql/platform/dashboard/common/insightRegistry';
import { ConnectionManagementInfo } from 'sql/platform/connection/common/connectionManagementInfo';
@@ -23,6 +22,7 @@ import { NAV_SECTION } from 'sql/workbench/parts/dashboard/containers/dashboardN
import { IDashboardContainerRegistry, Extensions as DashboardContainerExtensions } from 'sql/platform/dashboard/common/dashboardContainerRegistry';
import { SingleConnectionManagementService } from 'sql/platform/bootstrap/node/commonServiceInterface.service';
import * as Constants from 'sql/platform/connection/common/constants';
import { ILogService } from 'vs/platform/log/common/log';
const dashboardcontainerRegistry = Registry.as<IDashboardContainerRegistry>(DashboardContainerExtensions.dashboardContainerContributions);
const containerTypes = [
@@ -173,14 +173,14 @@ function hasCompatibleProvider(provider: string | string[], contextKeyService: I
* Get registered container if it is specified as the key
* @param container dashboard container
*/
export function getDashboardContainer(container: object): { result: boolean, message: string, container: object } {
export function getDashboardContainer(container: object, logService: ILogService): { result: boolean, message: string, container: object } {
const key = Object.keys(container)[0];
const containerTypeFound = containerTypes.find(c => (c === key));
if (!containerTypeFound) {
const dashboardContainer = dashboardcontainerRegistry.getRegisteredContainer(key);
if (!dashboardContainer) {
const errorMessage = nls.localize('unknownDashboardContainerError', '{0} is an unknown container.', key);
error(errorMessage);
logService.error(errorMessage);
return { result: false, message: errorMessage, container: undefined };
} else {
container = dashboardContainer.container;

View File

@@ -36,6 +36,7 @@ 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';
import { ILogService } from 'vs/platform/log/common/log';
const dashboardRegistry = Registry.as<IDashboardRegistry>(DashboardExtensions.DashboardContributions);
@@ -97,7 +98,8 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig
@Inject(IInstantiationService) private instantiationService: IInstantiationService,
@Inject(INotificationService) private notificationService: INotificationService,
@Inject(IAngularEventingService) private angularEventingService: IAngularEventingService,
@Inject(IConfigurationService) private configurationService: IConfigurationService
@Inject(IConfigurationService) private configurationService: IConfigurationService,
@Inject(ILogService) private logService: ILogService
) {
super();
}
@@ -261,7 +263,7 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig
}
private initTabComponents(value: IDashboardTab): { id: string; title: string; container: object; alwaysShow: boolean; } {
const containerResult = dashboardHelper.getDashboardContainer(value.container);
const containerResult = dashboardHelper.getDashboardContainer(value.container, this.logService);
if (!containerResult.result) {
return { id: value.id, title: value.title, container: { 'error-container': undefined }, alwaysShow: value.alwaysShow };
}

View File

@@ -18,6 +18,7 @@ import * as dashboardHelper from 'sql/workbench/parts/dashboard/common/dashboard
import { Event, Emitter } from 'vs/base/common/event';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { ILogService } from 'vs/platform/log/common/log';
@Component({
selector: 'dashboard-nav-section',
@@ -53,7 +54,8 @@ export class DashboardNavSection extends DashboardTab implements OnDestroy, OnCh
@ViewChild(PanelComponent) private _panel: PanelComponent;
constructor(
@Inject(forwardRef(() => CommonServiceInterface)) protected dashboardService: CommonServiceInterface,
@Inject(forwardRef(() => ChangeDetectorRef)) protected _cd: ChangeDetectorRef
@Inject(forwardRef(() => ChangeDetectorRef)) protected _cd: ChangeDetectorRef,
@Inject(ILogService) private logService: ILogService
) {
super();
}
@@ -91,7 +93,7 @@ export class DashboardNavSection extends DashboardTab implements OnDestroy, OnCh
private loadNewTabs(dashboardTabs: NavSectionConfig[]) {
if (dashboardTabs && dashboardTabs.length > 0) {
dashboardTabs.map(v => {
const containerResult = dashboardHelper.getDashboardContainer(v.container);
const containerResult = dashboardHelper.getDashboardContainer(v.container, this.logService);
if (!containerResult.result) {
return { id: v.id, title: v.title, container: { 'error-container': undefined } };
}

View File

@@ -14,7 +14,6 @@ import {
import { ComponentHostDirective } from 'sql/workbench/parts/dashboard/common/componentHost.directive';
import { WidgetConfig, WIDGET_CONFIG, IDashboardWidget } from 'sql/workbench/parts/dashboard/common/dashboardWidget';
import { Extensions, IInsightRegistry } from 'sql/platform/dashboard/common/insightRegistry';
import { error } from 'sql/base/common/log';
import { RefreshWidgetAction, ToggleMoreWidgetAction, DeleteWidgetAction, CollapseWidgetAction } from 'sql/workbench/parts/dashboard/common/actions';
import { AngularDisposable } from 'sql/base/node/lifecycle';
@@ -36,6 +35,7 @@ import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import { memoize } from 'vs/base/common/decorators';
import { generateUuid } from 'vs/base/common/uuid';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ILogService } from 'vs/platform/log/common/log';
const componentMap: { [x: string]: Type<IDashboardWidget> } = {
'properties-widget': PropertiesWidgetComponent,
@@ -92,7 +92,8 @@ export class DashboardWidgetWrapper extends AngularDisposable implements OnInit
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeref: ChangeDetectorRef,
@Inject(forwardRef(() => Injector)) private _injector: Injector,
@Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService,
@Inject(IInstantiationService) private instantiationService: IInstantiationService
@Inject(IInstantiationService) private instantiationService: IInstantiationService,
@Inject(ILogService) private logService: ILogService
) {
super();
}
@@ -146,13 +147,13 @@ export class DashboardWidgetWrapper extends AngularDisposable implements OnInit
private loadWidget(): void {
if (Object.keys(this._config.widget).length !== 1) {
error('Exactly 1 widget must be defined per space');
this.logService.error('Exactly 1 widget must be defined per space');
return;
}
const key = Object.keys(this._config.widget)[0];
const selector = this.getOrCreateSelector(key);
if (selector === undefined) {
error('Could not find selector', key);
this.logService.error('Could not find selector', key);
return;
}
@@ -183,7 +184,7 @@ export class DashboardWidgetWrapper extends AngularDisposable implements OnInit
this._changeref.detectChanges();
}
} catch (e) {
error('Error rendering widget', key, e);
this.logService.error('Error rendering widget', key, e);
return;
}
const el = <HTMLElement>componentRef.location.nativeElement;

View File

@@ -86,6 +86,7 @@ import { InsightsWidget } from 'sql/workbench/parts/dashboard/widgets/insights/i
import { WebviewWidget } from 'sql/workbench/parts/dashboard/widgets/webview/webviewWidget.component';
import { JobStepsViewComponent } from 'sql/workbench/parts/jobManagement/electron-browser/jobStepsView.component';
import { IInstantiationService, _util } from 'vs/platform/instantiation/common/instantiation';
import { ILogService } from 'vs/platform/log/common/log';
const widgetComponents = [
PropertiesWidgetComponent,
@@ -156,6 +157,7 @@ export const DashboardModule = (params, selector: string, instantiationService:
@Inject(forwardRef(() => ComponentFactoryResolver)) private _resolver: ComponentFactoryResolver,
@Inject(forwardRef(() => Router)) private _router: Router,
@Inject(ITelemetryService) private telemetryService: ITelemetryService,
@Inject(ILogService) private readonly logService: ILogService,
@Inject(ISelector) private selector: string
) {
}
@@ -168,7 +170,7 @@ export const DashboardModule = (params, selector: string, instantiationService:
this._router.events.subscribe(e => {
if (e instanceof NavigationEnd) {
this.navigations++;
TelemetryUtils.addTelemetry(this.telemetryService, TelemetryKeys.DashboardNavigated, {
TelemetryUtils.addTelemetry(this.telemetryService, this.logService, TelemetryKeys.DashboardNavigated, {
numberOfNavigations: this.navigations
});
}

View File

@@ -18,6 +18,7 @@ import * as nls from 'vs/nls';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ILogService } from 'vs/platform/log/common/log';
export class DatabaseDashboardPage extends DashboardPage implements OnInit {
protected propertiesWidget: WidgetConfig = {
@@ -44,9 +45,10 @@ export class DatabaseDashboardPage extends DashboardPage implements OnInit {
@Inject(IInstantiationService) instantiationService: IInstantiationService,
@Inject(INotificationService) notificationService: INotificationService,
@Inject(IAngularEventingService) angularEventingService: IAngularEventingService,
@Inject(IConfigurationService) configurationService: IConfigurationService
@Inject(IConfigurationService) configurationService: IConfigurationService,
@Inject(ILogService) logService: ILogService
) {
super(dashboardService, el, _cd, instantiationService, notificationService, angularEventingService, configurationService);
super(dashboardService, el, _cd, instantiationService, notificationService, angularEventingService, configurationService, logService);
this._register(dashboardService.onUpdatePage(() => {
this.refresh(true);
this._cd.detectChanges();

View File

@@ -18,6 +18,7 @@ import * as nls from 'vs/nls';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ILogService } from 'vs/platform/log/common/log';
export class ServerDashboardPage extends DashboardPage implements OnInit {
protected propertiesWidget: WidgetConfig = {
@@ -45,9 +46,10 @@ export class ServerDashboardPage extends DashboardPage implements OnInit {
@Inject(IInstantiationService) instantiationService: IInstantiationService,
@Inject(INotificationService) notificationService: INotificationService,
@Inject(IAngularEventingService) angularEventingService: IAngularEventingService,
@Inject(IConfigurationService) configurationService: IConfigurationService
@Inject(IConfigurationService) configurationService: IConfigurationService,
@Inject(ILogService) logService: ILogService
) {
super(dashboardService, el, _cd, instantiationService, notificationService, angularEventingService, configurationService);
super(dashboardService, el, _cd, instantiationService, notificationService, angularEventingService, configurationService, logService);
// special-case handling for MSSQL data provider
const connInfo = this.dashboardService.connectionManagementService.connectionInfo;

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Component, Input, Inject, ChangeDetectorRef, forwardRef, ElementRef, ViewChild } from '@angular/core';
import { Component, Input, Inject, ChangeDetectorRef, forwardRef, ViewChild } from '@angular/core';
import { BaseChartDirective } from 'ng2-charts';
import * as TelemetryKeys from 'sql/platform/telemetry/telemetryKeys';
@@ -16,9 +16,10 @@ import { LegendPosition, ChartType, defaultChartConfig, IChartConfig, IDataSet,
import * as colors from 'vs/platform/theme/common/colorRegistry';
import * as types from 'vs/base/common/types';
import { Disposable } from 'vs/base/common/lifecycle';
import { IColorTheme, IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import * as nls from 'vs/nls';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IThemeService, ITheme } from 'vs/platform/theme/common/themeService';
import { ILogService } from 'vs/platform/log/common/log';
declare const Chart: any;
@@ -52,16 +53,16 @@ export abstract class ChartInsight extends Disposable implements IInsightsView {
constructor(
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef,
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef,
@Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService,
@Inject(ITelemetryService) private telemetryService: ITelemetryService
@Inject(IThemeService) private themeService: IThemeService,
@Inject(ITelemetryService) private telemetryService: ITelemetryService,
@Inject(ILogService) private readonly logService: ILogService
) {
super();
}
init() {
this._register(this.themeService.onDidColorThemeChange(e => this.updateTheme(e)));
this.updateTheme(this.themeService.getColorTheme());
this._register(this.themeService.onThemeChange(e => this.updateTheme(e)));
this.updateTheme(this.themeService.getTheme());
// 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
// hence it's easier to not render until ready
@@ -75,7 +76,7 @@ export abstract class ChartInsight extends Disposable implements IInsightsView {
this._hasError = true;
this._changeRef.detectChanges();
}
TelemetryUtils.addTelemetry(this.telemetryService, TelemetryKeys.ChartCreated, { type: this.chartType });
TelemetryUtils.addTelemetry(this.telemetryService, this.logService, TelemetryKeys.ChartCreated, { type: this.chartType });
}
/**
@@ -93,7 +94,7 @@ export abstract class ChartInsight extends Disposable implements IInsightsView {
return this._options;
}
protected updateTheme(e: IColorTheme): void {
protected updateTheme(e: ITheme): void {
const foregroundColor = e.getColor(colors.editorForeground);
const foreground = foregroundColor ? foregroundColor.toString() : null;
const backgroundColor = e.getColor(colors.editorBackground);

View File

@@ -7,11 +7,12 @@ import { ChartInsight } from 'sql/workbench/parts/dashboard/widgets/insights/vie
import { mixin } from 'sql/base/common/objects';
import { ChartType, IChartConfig, customMixin } from 'sql/workbench/parts/dashboard/widgets/insights/views/charts/interfaces';
import { IColorTheme, IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import * as colors from 'vs/platform/theme/common/colorRegistry';
import { editorLineNumbers } from 'vs/editor/common/view/editorColorRegistry';
import { ChangeDetectorRef, Inject, ElementRef, forwardRef } from '@angular/core';
import { ChangeDetectorRef, Inject, forwardRef } from '@angular/core';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IThemeService, ITheme } from 'vs/platform/theme/common/themeService';
import { ILogService } from 'vs/platform/log/common/log';
export interface IBarChartConfig extends IChartConfig {
yAxisMin: number;
@@ -27,11 +28,11 @@ export default class BarChart extends ChartInsight {
constructor(
@Inject(forwardRef(() => ChangeDetectorRef)) _changeRef: ChangeDetectorRef,
@Inject(forwardRef(() => ElementRef)) _el: ElementRef,
@Inject(IWorkbenchThemeService) themeService: IWorkbenchThemeService,
@Inject(ITelemetryService) telemetryService: ITelemetryService
@Inject(IThemeService) themeService: IThemeService,
@Inject(ITelemetryService) telemetryService: ITelemetryService,
@Inject(ILogService) logService: ILogService
) {
super(_changeRef, _el, themeService, telemetryService);
super(_changeRef, themeService, telemetryService, logService);
}
public setConfig(config: IBarChartConfig): void {
@@ -126,7 +127,7 @@ export default class BarChart extends ChartInsight {
super.setConfig(config);
}
protected updateTheme(e: IColorTheme): void {
protected updateTheme(e: ITheme): void {
super.updateTheme(e);
const foregroundColor = e.getColor(colors.editorForeground);
const foreground = foregroundColor ? foregroundColor.toString() : null;

View File

@@ -3,8 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { mixin } from 'vs/base/common/objects';
import { clone } from 'sql/base/common/objects';
import { mixin, deepClone } from 'vs/base/common/objects';
import { IJSONSchema } from 'vs/base/common/jsonSchema';
import * as nls from 'vs/nls';
@@ -42,6 +41,6 @@ const properties: IJSONSchema = {
}
};
export const barChartSchema = mixin(clone(chartInsightSchema), properties) as IJSONSchema;
export const barChartSchema = mixin(deepClone(chartInsightSchema), properties) as IJSONSchema;
registerInsight('bar', '', barChartSchema, BarChart);

View File

@@ -5,19 +5,20 @@
import PieChart from './pieChart.component';
import { ChartType } from 'sql/workbench/parts/dashboard/widgets/insights/views/charts/interfaces';
import { ChangeDetectorRef, Inject, forwardRef, ElementRef } from '@angular/core';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { ChangeDetectorRef, Inject, forwardRef } from '@angular/core';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { ILogService } from 'vs/platform/log/common/log';
import { IThemeService } from 'vs/platform/theme/common/themeService';
export default class DoughnutChart extends PieChart {
protected readonly chartType: ChartType = ChartType.Doughnut;
constructor(
@Inject(forwardRef(() => ChangeDetectorRef)) _changeRef: ChangeDetectorRef,
@Inject(forwardRef(() => ElementRef)) _el: ElementRef,
@Inject(IWorkbenchThemeService) themeService: IWorkbenchThemeService,
@Inject(ITelemetryService) telemetryService: ITelemetryService
@Inject(IThemeService) themeService: IThemeService,
@Inject(ITelemetryService) telemetryService: ITelemetryService,
@Inject(ILogService) logService: ILogService
) {
super(_changeRef, _el, themeService, telemetryService);
super(_changeRef, themeService, telemetryService, logService);
}
}

View File

@@ -3,8 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { clone } from 'sql/base/common/objects';
import { mixin } from 'vs/base/common/objects';
import { mixin, deepClone } from 'vs/base/common/objects';
import { IJSONSchema } from 'vs/base/common/jsonSchema';
import { registerInsight } from 'sql/platform/dashboard/common/insightRegistry';
import { chartInsightSchema } from 'sql/workbench/parts/dashboard/widgets/insights/views/charts/chartInsight.contribution';
@@ -15,6 +14,6 @@ const properties: IJSONSchema = {
};
const doughnutChartSchema = mixin(clone(chartInsightSchema), properties) as IJSONSchema;
const doughnutChartSchema = mixin(deepClone(chartInsightSchema), properties) as IJSONSchema;
registerInsight('doughnut', '', doughnutChartSchema, DoughnutChart);

View File

@@ -5,19 +5,20 @@
import BarChart from './barChart.component';
import { ChartType } from 'sql/workbench/parts/dashboard/widgets/insights/views/charts/interfaces';
import { forwardRef, Inject, ChangeDetectorRef, ElementRef } from '@angular/core';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { forwardRef, Inject, ChangeDetectorRef } from '@angular/core';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { ILogService } from 'vs/platform/log/common/log';
export default class HorizontalBarChart extends BarChart {
protected readonly chartType: ChartType = ChartType.HorizontalBar;
constructor(
@Inject(forwardRef(() => ChangeDetectorRef)) _changeRef: ChangeDetectorRef,
@Inject(forwardRef(() => ElementRef)) _el: ElementRef,
@Inject(IWorkbenchThemeService) themeService: IWorkbenchThemeService,
@Inject(ITelemetryService) telemetryService: ITelemetryService
@Inject(IThemeService) themeService: IThemeService,
@Inject(ITelemetryService) telemetryService: ITelemetryService,
@Inject(ILogService) logService: ILogService
) {
super(_changeRef, _el, themeService, telemetryService);
super(_changeRef, themeService, telemetryService, logService);
}
}

View File

@@ -3,8 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { clone } from 'sql/base/common/objects';
import { mixin } from 'vs/base/common/objects';
import { mixin, deepClone } from 'vs/base/common/objects';
import { IJSONSchema } from 'vs/base/common/jsonSchema';
import { registerInsight } from 'sql/platform/dashboard/common/insightRegistry';
@@ -16,6 +15,6 @@ const properties: IJSONSchema = {
};
const horizontalBarSchema = mixin(clone(barChartSchema), properties) as IJSONSchema;
const horizontalBarSchema = mixin(deepClone(barChartSchema), properties) as IJSONSchema;
registerInsight('horizontalBar', '', horizontalBarSchema, HorizontalBarChart);

View File

@@ -3,21 +3,21 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { mixin } from 'vs/base/common/objects';
import { mixin, deepClone } from 'vs/base/common/objects';
import BarChart, { IBarChartConfig } from './barChart.component';
import { memoize, unmemoize } from 'sql/base/common/decorators';
import { clone } from 'sql/base/common/objects';
import { ChartType, DataType, defaultChartConfig, IDataSet, IPointDataSet } from 'sql/workbench/parts/dashboard/widgets/insights/views/charts/interfaces';
import { ChangeDetectorRef, Inject, forwardRef, ElementRef } from '@angular/core';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { ChangeDetectorRef, Inject, forwardRef } from '@angular/core';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { ILogService } from 'vs/platform/log/common/log';
export interface ILineConfig extends IBarChartConfig {
dataType?: DataType;
}
const defaultLineConfig = mixin(clone(defaultChartConfig), { dataType: 'number' }) as ILineConfig;
const defaultLineConfig = mixin(deepClone(defaultChartConfig), { dataType: 'number' }) as ILineConfig;
export default class LineChart extends BarChart {
protected readonly chartType: ChartType = ChartType.Line;
@@ -26,11 +26,11 @@ export default class LineChart extends BarChart {
constructor(
@Inject(forwardRef(() => ChangeDetectorRef)) _changeRef: ChangeDetectorRef,
@Inject(forwardRef(() => ElementRef)) _el: ElementRef,
@Inject(IWorkbenchThemeService) themeService: IWorkbenchThemeService,
@Inject(ITelemetryService) telemetryService: ITelemetryService
@Inject(IThemeService) themeService: IThemeService,
@Inject(ITelemetryService) telemetryService: ITelemetryService,
@Inject(ILogService) logService: ILogService
) {
super(_changeRef, _el, themeService, telemetryService);
super(_changeRef, themeService, telemetryService, logService);
}
public init() {

View File

@@ -3,8 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { mixin } from 'vs/base/common/objects';
import { clone } from 'sql/base/common/objects';
import { mixin, deepClone } from 'vs/base/common/objects';
import { IJSONSchema } from 'vs/base/common/jsonSchema';
import * as nls from 'vs/nls';
@@ -25,6 +24,6 @@ const properties: IJSONSchema = {
}
};
export const lineSchema = mixin(clone(barChartSchema), properties) as IJSONSchema;
export const lineSchema = mixin(deepClone(barChartSchema), properties) as IJSONSchema;
registerInsight('line', '', lineSchema, LineChart);

View File

@@ -5,19 +5,20 @@
import { ChartInsight } from 'sql/workbench/parts/dashboard/widgets/insights/views/charts/chartInsight.component';
import { ChartType } from 'sql/workbench/parts/dashboard/widgets/insights/views/charts/interfaces';
import { ChangeDetectorRef, Inject, forwardRef, ElementRef } from '@angular/core';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { ChangeDetectorRef, Inject, forwardRef } from '@angular/core';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { ILogService } from 'vs/platform/log/common/log';
export default class PieChart extends ChartInsight {
protected readonly chartType: ChartType = ChartType.Pie;
constructor(
@Inject(forwardRef(() => ChangeDetectorRef)) _changeRef: ChangeDetectorRef,
@Inject(forwardRef(() => ElementRef)) _el: ElementRef,
@Inject(IWorkbenchThemeService) themeService: IWorkbenchThemeService,
@Inject(ITelemetryService) telemetryService: ITelemetryService
@Inject(IThemeService) themeService: IThemeService,
@Inject(ITelemetryService) telemetryService: ITelemetryService,
@Inject(ILogService) logService: ILogService
) {
super(_changeRef, _el, themeService, telemetryService);
super(_changeRef, themeService, telemetryService, logService);
}
}

View File

@@ -3,8 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { mixin } from 'vs/base/common/objects';
import { clone } from 'sql/base/common/objects';
import { mixin, deepClone } from 'vs/base/common/objects';
import { IJSONSchema } from 'vs/base/common/jsonSchema';
import { registerInsight } from 'sql/platform/dashboard/common/insightRegistry';
import { chartInsightSchema } from 'sql/workbench/parts/dashboard/widgets/insights/views/charts/chartInsight.contribution';
@@ -15,6 +14,6 @@ const properties: IJSONSchema = {
};
const pieSchema = mixin(clone(chartInsightSchema), properties) as IJSONSchema;
const pieSchema = mixin(deepClone(chartInsightSchema), properties) as IJSONSchema;
registerInsight('pie', '', pieSchema, PieChart);

View File

@@ -4,15 +4,15 @@
*--------------------------------------------------------------------------------------------*/
import LineChart, { ILineConfig } from './lineChart.component';
import { clone } from 'sql/base/common/objects';
import { ChartType, defaultChartConfig } from 'sql/workbench/parts/dashboard/widgets/insights/views/charts/interfaces';
import { mixin } from 'vs/base/common/objects';
import { ChangeDetectorRef, Inject, forwardRef, ElementRef } from '@angular/core';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { mixin, deepClone } from 'vs/base/common/objects';
import { ChangeDetectorRef, Inject, forwardRef } from '@angular/core';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { ILogService } from 'vs/platform/log/common/log';
const defaultScatterConfig = mixin(clone(defaultChartConfig), { dataType: 'point', dataDirection: 'horizontal' }) as ILineConfig;
const defaultScatterConfig = mixin(deepClone(defaultChartConfig), { dataType: 'point', dataDirection: 'horizontal' }) as ILineConfig;
export default class ScatterChart extends LineChart {
protected readonly chartType: ChartType = ChartType.Scatter;
@@ -20,10 +20,10 @@ export default class ScatterChart extends LineChart {
constructor(
@Inject(forwardRef(() => ChangeDetectorRef)) _changeRef: ChangeDetectorRef,
@Inject(forwardRef(() => ElementRef)) _el: ElementRef,
@Inject(IWorkbenchThemeService) themeService: IWorkbenchThemeService,
@Inject(ITelemetryService) telemetryService: ITelemetryService
@Inject(IThemeService) themeService: IThemeService,
@Inject(ITelemetryService) telemetryService: ITelemetryService,
@Inject(ILogService) logService: ILogService
) {
super(_changeRef, _el, themeService, telemetryService);
super(_changeRef, themeService, telemetryService, logService);
}
}

View File

@@ -3,8 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { mixin } from 'vs/base/common/objects';
import { clone } from 'sql/base/common/objects';
import { mixin, deepClone } from 'vs/base/common/objects';
import { IJSONSchema } from 'vs/base/common/jsonSchema';
import { registerInsight } from 'sql/platform/dashboard/common/insightRegistry';
@@ -15,6 +14,6 @@ import ScatterChart from './scatterChart.component';
const properties: IJSONSchema = {
};
const scatterSchema = mixin(clone(barChartSchema), properties) as IJSONSchema;
const scatterSchema = mixin(deepClone(barChartSchema), properties) as IJSONSchema;
registerInsight('scatter', '', scatterSchema, ScatterChart);

View File

@@ -4,27 +4,27 @@
*--------------------------------------------------------------------------------------------*/
import LineChart, { ILineConfig } from './lineChart.component';
import { clone } from 'sql/base/common/objects';
import { ChartType, defaultChartConfig, IPointDataSet } from 'sql/workbench/parts/dashboard/widgets/insights/views/charts/interfaces';
import { mixin } from 'vs/base/common/objects';
import { mixin, deepClone } from 'vs/base/common/objects';
import { Color } from 'vs/base/common/color';
import { ChangeDetectorRef, Inject, forwardRef, ElementRef } from '@angular/core';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { ChangeDetectorRef, Inject, forwardRef } from '@angular/core';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { ILogService } from 'vs/platform/log/common/log';
const defaultTimeSeriesConfig = mixin(clone(defaultChartConfig), { dataType: 'point', dataDirection: 'horizontal' }) as ILineConfig;
const defaultTimeSeriesConfig = mixin(deepClone(defaultChartConfig), { dataType: 'point', dataDirection: 'horizontal' }) as ILineConfig;
export default class TimeSeriesChart extends LineChart {
protected _defaultConfig = defaultTimeSeriesConfig;
constructor(
@Inject(forwardRef(() => ChangeDetectorRef)) _changeRef: ChangeDetectorRef,
@Inject(forwardRef(() => ElementRef)) _el: ElementRef,
@Inject(IWorkbenchThemeService) themeService: IWorkbenchThemeService,
@Inject(ITelemetryService) telemetryService: ITelemetryService
@Inject(IThemeService) themeService: IThemeService,
@Inject(ITelemetryService) telemetryService: ITelemetryService,
@Inject(ILogService) logService: ILogService
) {
super(_changeRef, _el, themeService, telemetryService);
super(_changeRef, themeService, telemetryService, logService);
}
protected addAxisLabels(): void {

View File

@@ -3,8 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { mixin } from 'vs/base/common/objects';
import { clone } from 'sql/base/common/objects';
import { mixin, deepClone } from 'vs/base/common/objects';
import { IJSONSchema } from 'vs/base/common/jsonSchema';
import { registerInsight } from 'sql/platform/dashboard/common/insightRegistry';
@@ -15,6 +14,6 @@ import TimeSeriesChart from './timeSeriesChart.component';
const properties: IJSONSchema = {
};
const timeSeriesSchema = mixin(clone(barChartSchema), properties) as IJSONSchema;
const timeSeriesSchema = mixin(deepClone(barChartSchema), properties) as IJSONSchema;
registerInsight('timeSeries', '', timeSeriesSchema, TimeSeriesChart);

View File

@@ -9,7 +9,6 @@ import { DashboardWidget, IDashboardWidget, WidgetConfig, WIDGET_CONFIG } from '
import { CommonServiceInterface } from 'sql/platform/bootstrap/node/commonServiceInterface.service';
import { ConnectionManagementInfo } from 'sql/platform/connection/common/connectionManagementInfo';
import { toDisposableSubscription } from 'sql/base/node/rxjsUtils';
import { error } from 'sql/base/common/log';
import { IDashboardRegistry, Extensions as DashboardExtensions } from 'sql/platform/dashboard/common/dashboardRegistry';
import { DatabaseInfo, ServerInfo } from 'azdata';
@@ -18,6 +17,7 @@ import { EventType, addDisposableListener } from 'vs/base/browser/dom';
import * as types from 'vs/base/common/types';
import * as nls from 'vs/nls';
import { Registry } from 'vs/platform/registry/common/platform';
import { ILogService } from 'vs/platform/log/common/log';
export interface PropertiesConfig {
properties: Array<Property>;
@@ -72,12 +72,9 @@ export class PropertiesWidgetComponent extends DashboardWidget implements IDashb
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef,
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef,
@Inject(WIDGET_CONFIG) protected _config: WidgetConfig,
consoleError?: ((message?: any, ...optionalParams: any[]) => void)
@Inject(ILogService) private logService: ILogService
) {
super();
if (consoleError) {
this.consoleError = consoleError;
}
this.init();
}
@@ -127,7 +124,7 @@ export class PropertiesWidgetComponent extends DashboardWidget implements IDashb
const providerProperties = dashboardRegistry.getProperties(provider as string);
if (!providerProperties) {
this.consoleError('No property definitions found for provider', provider);
this.logService.error('No property definitions found for provider', provider);
return;
}
@@ -137,7 +134,7 @@ export class PropertiesWidgetComponent extends DashboardWidget implements IDashb
if (providerProperties.flavors.length === 1) {
flavor = providerProperties.flavors[0];
} else if (providerProperties.flavors.length === 0) {
this.consoleError('No flavor definitions found for "', provider,
this.logService.error('No flavor definitions found for "', provider,
'. If there are not multiple flavors of this provider, add one flavor without a condition');
return;
} else {
@@ -153,17 +150,17 @@ export class PropertiesWidgetComponent extends DashboardWidget implements IDashb
case '<=':
return condition <= item.condition.value;
default:
this.consoleError('Could not parse operator: "', item.condition.operator,
this.logService.error('Could not parse operator: "', item.condition.operator,
'" on item "', item, '"');
return false;
}
});
if (flavorArray.length === 0) {
this.consoleError('Could not determine flavor');
this.logService.error('Could not determine flavor');
return;
} else if (flavorArray.length > 1) {
this.consoleError('Multiple flavors matched correctly for this provider', provider);
this.logService.error('Multiple flavors matched correctly for this provider', provider);
return;
}
@@ -173,17 +170,17 @@ export class PropertiesWidgetComponent extends DashboardWidget implements IDashb
// determine what context we should be pulling from
if (this._config.context === 'database') {
if (!Array.isArray(flavor.databaseProperties)) {
this.consoleError('flavor', flavor.flavor, ' does not have a definition for database properties');
this.logService.error('flavor', flavor.flavor, ' does not have a definition for database properties');
}
if (!Array.isArray(flavor.serverProperties)) {
this.consoleError('flavor', flavor.flavor, ' does not have a definition for server properties');
this.logService.error('flavor', flavor.flavor, ' does not have a definition for server properties');
}
propertyArray = flavor.databaseProperties;
} else {
if (!Array.isArray(flavor.serverProperties)) {
this.consoleError('flavor', flavor.flavor, ' does not have a definition for server properties');
this.logService.error('flavor', flavor.flavor, ' does not have a definition for server properties');
}
propertyArray = flavor.serverProperties;
@@ -237,9 +234,4 @@ export class PropertiesWidgetComponent extends DashboardWidget implements IDashb
}
return val;
}
// overwrittable console.error for testing
private consoleError(message?: any, ...optionalParams: any[]): void {
error(message, optionalParams);
}
}