Inital platform relayering (#6385)

* moving test files and inital refactoring

* relayer extension host code

* fix imports

* make insights work

* relayer dashboard

* relayer notebooks

* moveing more code around

* formatting

* accept angular as browser

* fix serializer

* add missing files

* remove declarations from extensions

* fix build errors

* more relayering

* change urls to relative to help code relayering

* remove layering to prep for merge

* fix hygiene errors

* fix hygiene errors

* fix tests
This commit is contained in:
Anthony Dresser
2019-07-18 17:29:17 -07:00
committed by GitHub
parent 45c13116de
commit c23738f935
576 changed files with 2090 additions and 2788 deletions

View File

@@ -1,27 +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 { IInsightDialogActionContext } from 'sql/workbench/services/insights/common/insightsDialogService';
import { Action } from 'vs/base/common/actions';
import * as nls from 'vs/nls';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
export class CopyInsightDialogSelectionAction extends Action {
public static ID = 'workbench.action.insights.copySelection';
public static LABEL = nls.localize('workbench.action.insights.copySelection', "Copy Cell");
constructor(
id: string, label: string,
@IClipboardService private _clipboardService: IClipboardService
) {
super(id, label);
}
public run(event?: IInsightDialogActionContext): Promise<any> {
this._clipboardService.writeText(event.cellData);
return Promise.resolve(void 0);
}
}

View File

@@ -5,10 +5,8 @@
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
import { IInsightsConfigDetails } from 'sql/workbench/parts/dashboard/widgets/insights/interfaces';
import QueryRunner from 'sql/platform/query/common/queryRunner';
import * as Utils from 'sql/platform/connection/common/utils';
import { IInsightsDialogModel } from 'sql/workbench/services/insights/common/insightsDialogService';
import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService';
import { resolveQueryFilePath } from './insightsUtils';
@@ -22,6 +20,8 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
import { ILogService } from 'vs/platform/log/common/log';
import { IFileService } from 'vs/platform/files/common/files';
import { URI } from 'vs/base/common/uri';
import { IInsightsDialogModel } from 'sql/workbench/services/insights/browser/insightsDialogService';
import { IInsightsConfigDetails } from 'sql/platform/dashboard/browser/insightRegistry';
export class InsightsDialogController {
private _queryRunner: QueryRunner;

View File

@@ -1,128 +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 { IInsightsDialogModel, ListResource } from 'sql/workbench/services/insights/common/insightsDialogService';
import { IInsightsConfigDetails, IInsightsLabel } from 'sql/workbench/parts/dashboard/widgets/insights/interfaces';
import { Conditional } from 'sql/workbench/parts/dashboard/common/interfaces';
import { Event, Emitter } from 'vs/base/common/event';
export class InsightsDialogModel implements IInsightsDialogModel {
private _rows: string[][];
private _columns: string[];
private _insight: IInsightsConfigDetails;
private _onDataChangeEmitter: Emitter<void> = new Emitter<void>();
private _onDataChangeEvent: Event<void> = this._onDataChangeEmitter.event;
public onDataChange: Event<void> = Event.debounce(this._onDataChangeEvent, (last, event) => event, 75, false);
public set insight(insight: IInsightsConfigDetails) {
this._insight = insight;
}
public set rows(val: string[][]) {
this._rows = val;
this._onDataChangeEmitter.fire();
}
public get rows(): string[][] {
return this._rows;
}
public set columns(val: string[]) {
this._columns = val;
this._onDataChangeEmitter.fire();
}
public get columns(): string[] {
return this._columns;
}
public reset(): void {
this._columns = [];
this._rows = [];
this._onDataChangeEmitter.fire();
}
public getListResources(labelIndex: number, valueIndex: number): ListResource[] {
return this.rows.map((item) => {
let label = item[labelIndex];
let value = item[valueIndex];
let state = this.calcInsightState(value);
let data = item;
let icon = typeof this._insight.label === 'object' ? this._insight.label.icon : undefined;
let rval = { title: false, label, value, icon, data };
if (state) {
rval[state.type] = state.val;
}
return rval;
});
}
/**
* Calculates the state of the item value passed based on the insight conditions
* @param item item to determine state for
* @returns json that specifies whether the state is an icon or color and the val of that state
*/
private calcInsightState(item: string): { type: 'stateColor' | 'stateIcon', val: string } {
if (typeof this._insight.label === 'string') {
return undefined;
} else {
let label = <IInsightsLabel>this._insight.label;
for (let cond of label.state) {
switch (Conditional[cond.condition.if]) {
case Conditional.always:
return cond.color
? { type: 'stateColor', val: cond.color }
: { type: 'stateIcon', val: cond.icon };
case Conditional.equals:
if (item === cond.condition.equals) {
return cond.color
? { type: 'stateColor', val: cond.color }
: { type: 'stateIcon', val: cond.icon };
}
break;
case Conditional.notEquals:
if (item !== cond.condition.equals) {
return cond.color
? { type: 'stateColor', val: cond.color }
: { type: 'stateIcon', val: cond.icon };
}
break;
case Conditional.greaterThanOrEquals:
if (parseInt(item) >= parseInt(cond.condition.equals)) {
return cond.color
? { type: 'stateColor', val: cond.color }
: { type: 'stateIcon', val: cond.icon };
}
break;
case Conditional.greaterThan:
if (parseInt(item) > parseInt(cond.condition.equals)) {
return cond.color
? { type: 'stateColor', val: cond.color }
: { type: 'stateIcon', val: cond.icon };
}
break;
case Conditional.lessThanOrEquals:
if (parseInt(item) <= parseInt(cond.condition.equals)) {
return cond.color
? { type: 'stateColor', val: cond.color }
: { type: 'stateIcon', val: cond.icon };
}
break;
case Conditional.lessThan:
if (parseInt(item) < parseInt(cond.condition.equals)) {
return cond.color
? { type: 'stateColor', val: cond.color }
: { type: 'stateIcon', val: cond.icon };
}
break;
}
}
}
// if we got to this point, there was no matching conditionals therefore no valid state
return undefined;
}
}

View File

@@ -1,43 +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 { Event } from 'vs/base/common/event';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IInsightsConfigDetails, IInsightsConfig } from 'sql/workbench/parts/dashboard/widgets/insights/interfaces';
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
import { BaseActionContext } from 'sql/workbench/common/actions';
export interface IInsightsDialogModel {
rows: string[][];
columns: string[];
getListResources(labelIndex: number, valueIndex: number): ListResource[];
reset(): void;
onDataChange: Event<void>;
insight: IInsightsConfigDetails;
}
export interface ListResource {
value: string;
label: string;
icon?: string;
data?: string[];
stateColor?: string;
stateIcon?: string;
}
export const IInsightsDialogService = createDecorator<IInsightsDialogService>('insightsDialogService');
export interface IInsightsDialogService {
_serviceBrand: any;
show(input: IInsightsConfig, connectionProfile: IConnectionProfile): void;
close();
}
export interface IInsightDialogActionContext extends BaseActionContext {
cellData: string;
}
/* Regex that matches the form `${value}` */
export const insertValueRegex: RegExp = /\${(.*?)\}/;