mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-20 09:35:38 -05:00
Merge from vscode e3c4990c67c40213af168300d1cfeb71d680f877 (#16569)
This commit is contained in:
@@ -181,7 +181,7 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig
|
||||
let secondary: IAction[] = [];
|
||||
const menu = this.menuService.createMenu(MenuId.DashboardToolbar, this.contextKeyService);
|
||||
let groups = menu.getActions({ arg: this.connectionManagementService.connectionInfo.connectionProfile.toIConnectionProfile(), shouldForwardArgs: true });
|
||||
fillInActions(groups, { primary, secondary }, false, '', Number.MAX_SAFE_INTEGER, (action: SubmenuAction, group: string, groupSize: number) => group === undefined || group === '');
|
||||
fillInActions(groups, { primary, secondary }, false, g => g === '', Number.MAX_SAFE_INTEGER, (action: SubmenuAction, group: string, groupSize: number) => group === undefined || group === '');
|
||||
|
||||
primary.forEach(a => {
|
||||
if (a instanceof MenuItemAction) {
|
||||
@@ -504,7 +504,7 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig
|
||||
return [this.propertiesWidget];
|
||||
} else if (types.isArray(properties)) {
|
||||
return properties.map((item) => {
|
||||
const retVal = objects.assign({}, this.propertiesWidget);
|
||||
const retVal = Object.assign({}, this.propertiesWidget);
|
||||
retVal.edition = item.edition;
|
||||
retVal.provider = item.provider;
|
||||
retVal.widget = { 'properties-widget': { properties: item.properties } };
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import { EditorOptions, IEditorOpenContext } from 'vs/workbench/common/editor';
|
||||
import { IEditorOpenContext } from 'vs/workbench/common/editor';
|
||||
import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
|
||||
@@ -24,6 +24,7 @@ import { IConnectionManagementService } from 'sql/platform/connection/common/con
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { IQueryManagementService } from 'sql/workbench/services/query/common/queryManagement';
|
||||
import { IEditorOptions } from 'vs/platform/editor/common/editor';
|
||||
|
||||
export class DashboardEditor extends EditorPane {
|
||||
|
||||
@@ -77,7 +78,7 @@ export class DashboardEditor extends EditorPane {
|
||||
this._dashboardService.layout(dimension);
|
||||
}
|
||||
|
||||
public override async setInput(input: DashboardInput, options: EditorOptions, context: IEditorOpenContext): Promise<void> {
|
||||
public override async setInput(input: DashboardInput, options: IEditorOptions, context: IEditorOpenContext): Promise<void> {
|
||||
if (this.input && this.input.matches(input)) {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import { IThemeService, IColorTheme } from 'vs/platform/theme/common/themeServic
|
||||
import { IPointDataSet } from 'sql/workbench/contrib/charts/browser/interfaces';
|
||||
import { IInsightsView, IInsightData } from 'sql/platform/dashboard/browser/insightRegistry';
|
||||
import { ChartType, LegendPosition } from 'sql/workbench/contrib/charts/common/interfaces';
|
||||
import { createMemoizer } from 'vs/base/common/decorators';
|
||||
import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry';
|
||||
|
||||
@Component({
|
||||
@@ -35,8 +34,6 @@ import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry';
|
||||
</div>`
|
||||
})
|
||||
export abstract class ChartInsight extends Disposable implements IInsightsView {
|
||||
protected static readonly MEMOIZER = createMemoizer();
|
||||
|
||||
private _isDataAvailable: boolean = false;
|
||||
protected _hasInit: boolean = false;
|
||||
protected _hasError: boolean = false;
|
||||
@@ -132,7 +129,7 @@ export abstract class ChartInsight extends Disposable implements IInsightsView {
|
||||
|
||||
@Input() set data(data: IInsightData) {
|
||||
// unmemoize chart data as the data needs to be recalced
|
||||
ChartInsight.MEMOIZER.clear();
|
||||
this.clearMemoize();
|
||||
this._data = this.filterToTopNData(data);
|
||||
if (isValidData(data)) {
|
||||
this._isDataAvailable = true;
|
||||
@@ -170,8 +167,9 @@ export abstract class ChartInsight extends Disposable implements IInsightsView {
|
||||
}
|
||||
|
||||
protected clearMemoize(): void {
|
||||
// unmemoize getters since their result can be changed by a new config
|
||||
ChartInsight.MEMOIZER.clear();
|
||||
this._cachedChartData = undefined;
|
||||
this._cachedColors = undefined;
|
||||
this._cachedLabels = undefined;
|
||||
}
|
||||
|
||||
public setConfig(config: IChartConfig) {
|
||||
@@ -185,77 +183,85 @@ export abstract class ChartInsight extends Disposable implements IInsightsView {
|
||||
}
|
||||
|
||||
/* Typescript does not allow you to access getters/setters for super classes.
|
||||
his is a workaround that allows us to still call base getter */
|
||||
@ChartInsight.MEMOIZER
|
||||
his is a workaround that allows us to still call base getter */
|
||||
private _cachedChartData: Array<IDataSet>;
|
||||
protected getChartData(): Array<IDataSet> {
|
||||
if (this._config.dataDirection === 'horizontal') {
|
||||
if (this._config.labelFirstColumn) {
|
||||
return this._data.rows.map((row) => {
|
||||
return {
|
||||
data: row.map(item => Number(item)).slice(1),
|
||||
label: row[0]
|
||||
};
|
||||
});
|
||||
if (!this._cachedChartData) {
|
||||
if (this._config.dataDirection === 'horizontal') {
|
||||
if (this._config.labelFirstColumn) {
|
||||
this._cachedChartData = this._data.rows.map((row) => {
|
||||
return {
|
||||
data: row.map(item => Number(item)).slice(1),
|
||||
label: row[0]
|
||||
};
|
||||
});
|
||||
} else {
|
||||
this._cachedChartData = this._data.rows.map((row, i) => {
|
||||
return {
|
||||
data: row.map(item => Number(item)),
|
||||
label: 'Series' + i
|
||||
};
|
||||
});
|
||||
}
|
||||
} else {
|
||||
return this._data.rows.map((row, i) => {
|
||||
return {
|
||||
data: row.map(item => Number(item)),
|
||||
label: 'Series' + i
|
||||
};
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (this._config.columnsAsLabels) {
|
||||
return this._data.rows[0].slice(1).map((row, i) => {
|
||||
return {
|
||||
data: this._data.rows.map(row => Number(row[i + 1])),
|
||||
label: this._data.columns[i + 1]
|
||||
};
|
||||
});
|
||||
} else {
|
||||
return this._data.rows[0].slice(1).map((row, i) => {
|
||||
return {
|
||||
data: this._data.rows.map(row => Number(row[i + 1])),
|
||||
label: 'Series' + (i + 1)
|
||||
};
|
||||
});
|
||||
if (this._config.columnsAsLabels) {
|
||||
this._cachedChartData = this._data.rows[0].slice(1).map((row, i) => {
|
||||
return {
|
||||
data: this._data.rows.map(row => Number(row[i + 1])),
|
||||
label: this._data.columns[i + 1]
|
||||
};
|
||||
});
|
||||
} else {
|
||||
this._cachedChartData = this._data.rows[0].slice(1).map((row, i) => {
|
||||
return {
|
||||
data: this._data.rows.map(row => Number(row[i + 1])),
|
||||
label: 'Series' + (i + 1)
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return this._cachedChartData;
|
||||
}
|
||||
|
||||
public get chartData(): Array<IDataSet | IPointDataSet> {
|
||||
return this.getChartData();
|
||||
}
|
||||
|
||||
@ChartInsight.MEMOIZER
|
||||
private _cachedLabels: Array<string>;
|
||||
public getLabels(): Array<string> {
|
||||
if (this._config.dataDirection === 'horizontal') {
|
||||
if (this._config.labelFirstColumn) {
|
||||
return this._data.columns.slice(1);
|
||||
if (!this._cachedLabels) {
|
||||
if (this._config.dataDirection === 'horizontal') {
|
||||
if (this._config.labelFirstColumn) {
|
||||
this._cachedLabels = this._data.columns.slice(1);
|
||||
} else {
|
||||
this._cachedLabels = this._data.columns;
|
||||
}
|
||||
} else {
|
||||
return this._data.columns;
|
||||
this._cachedLabels = this._data.rows.map(row => row[0]);
|
||||
}
|
||||
} else {
|
||||
return this._data.rows.map(row => row[0]);
|
||||
}
|
||||
return this._cachedLabels;
|
||||
}
|
||||
|
||||
public get labels(): Array<string> {
|
||||
return this.getLabels();
|
||||
}
|
||||
|
||||
|
||||
@ChartInsight.MEMOIZER
|
||||
private _cachedColors: { backgroundColor: string[] }[];
|
||||
public get colors(): { backgroundColor: string[] }[] {
|
||||
if (this._config && this._config.colorMap) {
|
||||
const backgroundColor = this.labels.map((item) => {
|
||||
return this._config.colorMap[item];
|
||||
});
|
||||
const colorsMap = { backgroundColor };
|
||||
return [colorsMap];
|
||||
} else {
|
||||
return undefined;
|
||||
if (!this._cachedColors) {
|
||||
if (this._config && this._config.colorMap) {
|
||||
const backgroundColor = this.labels.map((item) => {
|
||||
return this._config.colorMap[item];
|
||||
});
|
||||
const colorsMap = { backgroundColor };
|
||||
this._cachedColors = [colorsMap];
|
||||
} else {
|
||||
this._cachedColors = undefined;
|
||||
}
|
||||
}
|
||||
return this._cachedColors;
|
||||
}
|
||||
|
||||
public set legendPosition(input: LegendPosition) {
|
||||
|
||||
@@ -50,22 +50,25 @@ export default class LineChart extends BarChart {
|
||||
|
||||
protected override clearMemoize() {
|
||||
super.clearMemoize();
|
||||
LineChart.MEMOIZER.clear();
|
||||
this._cachedPointData = undefined;
|
||||
}
|
||||
|
||||
@LineChart.MEMOIZER
|
||||
private _cachedPointData: Array<IPointDataSet>;
|
||||
protected getDataAsPoint(): Array<IPointDataSet> {
|
||||
const dataSetMap: { [label: string]: IPointDataSet } = {};
|
||||
this._data.rows.map(row => {
|
||||
if (row && row.length >= 3) {
|
||||
const legend = row[0];
|
||||
if (!dataSetMap[legend]) {
|
||||
dataSetMap[legend] = { label: legend, data: [], fill: false };
|
||||
if (!this._cachedPointData) {
|
||||
const dataSetMap: { [label: string]: IPointDataSet } = {};
|
||||
this._data.rows.map(row => {
|
||||
if (row && row.length >= 3) {
|
||||
const legend = row[0];
|
||||
if (!dataSetMap[legend]) {
|
||||
dataSetMap[legend] = { label: legend, data: [], fill: false };
|
||||
}
|
||||
dataSetMap[legend].data.push({ x: Number(row[1]), y: Number(row[2]) });
|
||||
}
|
||||
dataSetMap[legend].data.push({ x: Number(row[1]), y: Number(row[2]) });
|
||||
}
|
||||
});
|
||||
return values(dataSetMap);
|
||||
});
|
||||
this._cachedPointData = values(dataSetMap);
|
||||
}
|
||||
return this._cachedPointData;
|
||||
}
|
||||
|
||||
public override get labels(): Array<string> {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import LineChart, { ILineConfig } from './lineChart.component';
|
||||
import { defaultChartConfig } from 'sql/workbench/contrib/dashboard/browser/widgets/insights/views/charts/interfaces';
|
||||
|
||||
import { mixin, deepClone, assign } from 'vs/base/common/objects';
|
||||
import { mixin, deepClone } from 'vs/base/common/objects';
|
||||
import { Color } from 'vs/base/common/color';
|
||||
import { ChangeDetectorRef, Inject, forwardRef } from '@angular/core';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
@@ -58,7 +58,7 @@ export default class TimeSeriesChart extends LineChart {
|
||||
}
|
||||
};
|
||||
|
||||
this.options = assign({}, mixin(this.options, options));
|
||||
this.options = Object.assign({}, mixin(this.options, options));
|
||||
}
|
||||
|
||||
protected override getDataAsPoint(): Array<IPointDataSet> {
|
||||
|
||||
@@ -7,7 +7,6 @@ import { Component, Input, Inject, ChangeDetectorRef, forwardRef, ViewChild, OnI
|
||||
|
||||
import { mixin } from 'vs/base/common/objects';
|
||||
import { IInsightsView, IInsightData } from 'sql/platform/dashboard/browser/insightRegistry';
|
||||
import { startsWith } from 'vs/base/common/strings';
|
||||
|
||||
interface IConfig {
|
||||
encoding?: string;
|
||||
@@ -70,7 +69,7 @@ export default class ImageInsight implements IInsightsView, OnInit {
|
||||
|
||||
private static _hexToBase64(hexVal: string) {
|
||||
|
||||
if (startsWith(hexVal, '0x')) {
|
||||
if (hexVal.startsWith('0x')) {
|
||||
hexVal = hexVal.slice(2);
|
||||
}
|
||||
// should be able to be replaced with new Buffer(hexVal, 'hex').toString('base64')
|
||||
|
||||
Reference in New Issue
Block a user