SQL Operations Studio Public Preview 1 (0.23) release source code

This commit is contained in:
Karl Burtram
2017-11-09 14:30:27 -08:00
parent b88ecb8d93
commit 3cdac41339
8829 changed files with 759707 additions and 286 deletions

View File

@@ -0,0 +1,28 @@
/*---------------------------------------------------------------------------------------------
* 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/parts/insights/common/interfaces';
import { Action } from 'vs/base/common/actions';
import * as nls from 'vs/nls';
import { TPromise } from 'vs/base/common/winjs.base';
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): TPromise<any> {
this._clipboardService.writeText(event.cellData);
return TPromise.as(void 0);
}
}

View File

@@ -0,0 +1,128 @@
/*---------------------------------------------------------------------------------------------
* 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 './interfaces';
import { IInsightsConfigDetails, IInsightsLabel } from 'sql/parts/dashboard/widgets/insights/interfaces';
import { Conditional } from 'sql/parts/dashboard/common/interfaces';
import Event, { Emitter, debounceEvent } 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> = debounceEvent(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

@@ -0,0 +1,40 @@
/*---------------------------------------------------------------------------------------------
* 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/parts/dashboard/widgets/insights/interfaces';
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
import { ITaskActionContext } 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 ITaskActionContext {
cellData: string;
}