mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Refresh master with initial release/0.24 snapshot (#332)
* Initial port of release/0.24 source code * Fix additional headers * Fix a typo in launch.json
This commit is contained in:
@@ -4,27 +4,27 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import 'vs/css!sql/parts/insights/browser/media/insightsDialog';
|
||||
|
||||
import { Button } from 'sql/base/browser/ui/button/button';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { Modal } from 'sql/base/browser/ui/modal/modal';
|
||||
import { IInsightsConfigDetails } from 'sql/parts/dashboard/widgets/insights/interfaces';
|
||||
import { attachModalDialogStyler, attachTableStyler } from 'sql/common/theme/styler';
|
||||
import { attachButtonStyler, attachModalDialogStyler, attachTableStyler } from 'sql/common/theme/styler';
|
||||
import { ITaskRegistry, Extensions as TaskExtensions } from 'sql/platform/tasks/taskRegistry';
|
||||
import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile';
|
||||
import * as TelemetryKeys from 'sql/common/telemetryKeys';
|
||||
import { IInsightsDialogModel, ListResource, IInsightDialogActionContext } from 'sql/parts/insights/common/interfaces';
|
||||
import { IInsightsDialogModel, ListResource, IInsightDialogActionContext, insertValueRegex } from 'sql/parts/insights/common/interfaces';
|
||||
import { TableCollapsibleView } from 'sql/base/browser/ui/table/tableView';
|
||||
import { TableDataView } from 'sql/base/browser/ui/table/tableDataView';
|
||||
import { RowSelectionModel } from 'sql/base/browser/ui/table/plugins/rowSelectionModel.plugin';
|
||||
import { error } from 'sql/base/common/log';
|
||||
import { Table } from 'sql/base/browser/ui/table/table';
|
||||
import { CopyInsightDialogSelectionAction } from 'sql/parts/insights/common/insightDialogActions';
|
||||
import { SplitView, ViewSizing } from 'sql/base/browser/ui/splitview/splitview';
|
||||
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IPartService } from 'vs/workbench/services/part/common/partService';
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import { SplitView, ViewSizing } from 'vs/base/browser/ui/splitview/splitview';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { attachButtonStyler } from 'vs/platform/theme/common/styler';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { IListService } from 'vs/platform/list/browser/listService';
|
||||
import * as nls from 'vs/nls';
|
||||
@@ -35,10 +35,8 @@ import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import * as types from 'vs/base/common/types';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { Button } from 'vs/base/browser/ui/button/button';
|
||||
|
||||
/* Regex that matches the form `${value}` */
|
||||
export const insertValueRegex: RegExp = /\${(.*?)\}/;
|
||||
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
|
||||
const labelDisplay = nls.localize("item", "Item");
|
||||
const valueDisplay = nls.localize("value", "Value");
|
||||
@@ -81,6 +79,7 @@ export class InsightsDialogView extends Modal {
|
||||
private _insight: IInsightsConfigDetails;
|
||||
private _splitView: SplitView;
|
||||
private _container: HTMLElement;
|
||||
private _closeButton: Button;
|
||||
private _topTable: Table<ListResource>;
|
||||
private _topTableData: TableDataView<ListResource>;
|
||||
private _bottomTable: Table<ListResource>;
|
||||
@@ -213,12 +212,45 @@ export class InsightsDialogView extends Modal {
|
||||
|
||||
this._register(attachTableStyler(this._topTable, this._themeService));
|
||||
this._register(attachTableStyler(this._bottomTable, this._themeService));
|
||||
|
||||
this._topTable.grid.onKeyDown.subscribe((e: KeyboardEvent) => {
|
||||
let event = new StandardKeyboardEvent(e);
|
||||
if (event.equals(KeyMod.Shift | KeyCode.Tab)) {
|
||||
topTableView.focus();
|
||||
e.stopImmediatePropagation();
|
||||
} else if (event.equals(KeyCode.Tab)) {
|
||||
bottomTableView.focus();
|
||||
e.stopImmediatePropagation();
|
||||
}
|
||||
});
|
||||
|
||||
this._bottomTable.grid.onKeyDown.subscribe((e: KeyboardEvent) => {
|
||||
let event = new StandardKeyboardEvent(e);
|
||||
if (event.equals(KeyMod.Shift | KeyCode.Tab)) {
|
||||
bottomTableView.focus();
|
||||
e.stopImmediatePropagation();
|
||||
} else if (event.equals(KeyCode.Tab)) {
|
||||
let buttonFound = false;
|
||||
for (let index = 0; index < this._taskButtonDisposables.length; index++) {
|
||||
let element = this._taskButtonDisposables[index];
|
||||
if (element instanceof Button && element.enabled) {
|
||||
buttonFound = true;
|
||||
element.focus();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!buttonFound) {
|
||||
this._closeButton.focus();
|
||||
}
|
||||
e.stopImmediatePropagation();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public render() {
|
||||
super.render();
|
||||
let button = this.addFooterButton('Close', () => this.close());
|
||||
this._register(attachButtonStyler(button, this._themeService));
|
||||
this._closeButton = this.addFooterButton('Close', () => this.close());
|
||||
this._register(attachButtonStyler(this._closeButton, this._themeService));
|
||||
this._register(attachModalDialogStyler(this, this._themeService));
|
||||
}
|
||||
|
||||
@@ -274,6 +306,9 @@ export class InsightsDialogView extends Modal {
|
||||
}
|
||||
}
|
||||
this.layout();
|
||||
|
||||
// Select and focus the top row
|
||||
this._topTable.grid.gotoCell(0, 1);
|
||||
}
|
||||
|
||||
public reset(): void {
|
||||
|
||||
@@ -7,7 +7,7 @@ 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';
|
||||
import { BaseActionContext } from 'sql/workbench/common/actions';
|
||||
|
||||
export interface IInsightsDialogModel {
|
||||
rows: string[][];
|
||||
@@ -35,6 +35,9 @@ export interface IInsightsDialogService {
|
||||
close();
|
||||
}
|
||||
|
||||
export interface IInsightDialogActionContext extends ITaskActionContext {
|
||||
export interface IInsightDialogActionContext extends BaseActionContext {
|
||||
cellData: string;
|
||||
}
|
||||
|
||||
/* Regex that matches the form `${value}` */
|
||||
export const insertValueRegex: RegExp = /\${(.*?)\}/;
|
||||
|
||||
@@ -6,11 +6,12 @@
|
||||
import { IConnectionManagementService, IErrorMessageService } from 'sql/parts/connection/common/connectionManagement';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { IInsightsConfigDetails } from 'sql/parts/dashboard/widgets/insights/interfaces';
|
||||
import QueryRunner from 'sql/parts/query/execution/queryRunner';
|
||||
import QueryRunner, { EventType as QREvents } from 'sql/parts/query/execution/queryRunner';
|
||||
import * as Utils from 'sql/parts/connection/common/utils';
|
||||
import { IInsightsDialogModel } from 'sql/parts/insights/common/interfaces';
|
||||
import { IInsightsDialogModel, insertValueRegex } from 'sql/parts/insights/common/interfaces';
|
||||
import { error } from 'sql/base/common/log';
|
||||
|
||||
import { DbCellValue, IDbColumn, IResultMessage, QueryExecuteSubsetResult } from 'data';
|
||||
import { DbCellValue, IDbColumn, QueryExecuteSubsetResult } from 'data';
|
||||
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import * as types from 'vs/base/common/types';
|
||||
@@ -18,7 +19,7 @@ import * as pfs from 'vs/base/node/pfs';
|
||||
import * as nls from 'vs/nls';
|
||||
import { IMessageService } from 'vs/platform/message/common/message';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { error } from 'sql/base/common/log';
|
||||
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
|
||||
|
||||
export class InsightsDialogController {
|
||||
private _queryRunner: QueryRunner;
|
||||
@@ -33,6 +34,7 @@ export class InsightsDialogController {
|
||||
@IErrorMessageService private _errorMessageService: IErrorMessageService,
|
||||
@IInstantiationService private _instantiationService: IInstantiationService,
|
||||
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
|
||||
@IWorkspaceContextService private _workspaceContextService: IWorkspaceContextService
|
||||
) { }
|
||||
|
||||
public update(input: IInsightsConfigDetails, connectionProfile: IConnectionProfile): Thenable<void> {
|
||||
@@ -44,18 +46,45 @@ export class InsightsDialogController {
|
||||
}
|
||||
if (types.isStringArray(input.query)) {
|
||||
return this.createQuery(input.query.join(' '), connectionProfile).catch(e => {
|
||||
this._errorMessageService.showDialog(Severity.Error, nls.localize("insightsError", "Insights Error"), e);
|
||||
this._errorMessageService.showDialog(Severity.Error, nls.localize("insightsError", "Insights error"), e);
|
||||
}).then(() => undefined);
|
||||
} else if (types.isString(input.query)) {
|
||||
return this.createQuery(input.query, connectionProfile).catch(e => {
|
||||
this._errorMessageService.showDialog(Severity.Error, nls.localize("insightsError", "Insights Error"), e);
|
||||
this._errorMessageService.showDialog(Severity.Error, nls.localize("insightsError", "Insights error"), e);
|
||||
}).then(() => undefined);
|
||||
} else if (types.isString(input.queryFile)) {
|
||||
let filePath = input.queryFile;
|
||||
// check for workspace relative path
|
||||
let match = filePath.match(insertValueRegex);
|
||||
if (match && match.length > 0 && match[1] === 'workspaceRoot') {
|
||||
filePath = filePath.replace(match[0], '');
|
||||
|
||||
switch (this._workspaceContextService.getWorkbenchState()) {
|
||||
case WorkbenchState.FOLDER:
|
||||
filePath = this._workspaceContextService.getWorkspace().folders[0].toResource(filePath).fsPath;
|
||||
break;
|
||||
case WorkbenchState.WORKSPACE:
|
||||
let filePathArray = filePath.split('/');
|
||||
// filter out empty sections
|
||||
filePathArray = filePathArray.filter(i => !!i);
|
||||
let folder = this._workspaceContextService.getWorkspace().folders.find(i => i.name === filePathArray[0]);
|
||||
if (!folder) {
|
||||
return Promise.reject<void>(new Error(`Could not find workspace folder ${filePathArray[0]}`));
|
||||
}
|
||||
// remove the folder name from the filepath
|
||||
filePathArray.shift();
|
||||
// rejoin the filepath after doing the work to find the right folder
|
||||
filePath = '/' + filePathArray.join('/');
|
||||
filePath = folder.toResource(filePath).fsPath;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
pfs.readFile(input.queryFile).then(
|
||||
pfs.readFile(filePath).then(
|
||||
buffer => {
|
||||
this.createQuery(buffer.toString(), connectionProfile).catch(e => {
|
||||
this._errorMessageService.showDialog(Severity.Error, nls.localize("insightsError", "Insights Error"), e);
|
||||
this._errorMessageService.showDialog(Severity.Error, nls.localize("insightsError", "Insights error"), e);
|
||||
}).then(() => resolve());
|
||||
},
|
||||
error => {
|
||||
@@ -115,14 +144,14 @@ export class InsightsDialogController {
|
||||
}
|
||||
|
||||
private addQueryEventListeners(queryRunner: QueryRunner): void {
|
||||
queryRunner.eventEmitter.on('complete', () => {
|
||||
queryRunner.addListener(QREvents.COMPLETE, () => {
|
||||
this.queryComplete().catch(error => {
|
||||
this._errorMessageService.showDialog(Severity.Error, nls.localize("insightsError", "Insights Error"), error);
|
||||
this._errorMessageService.showDialog(Severity.Error, nls.localize("insightsError", "Insights error"), error);
|
||||
});
|
||||
});
|
||||
queryRunner.eventEmitter.on('message', (message: IResultMessage) => {
|
||||
queryRunner.addListener(QREvents.MESSAGE, message => {
|
||||
if (message.isError) {
|
||||
this._errorMessageService.showDialog(Severity.Error, nls.localize("insightsError", "Insights Error"), message.message);
|
||||
this._errorMessageService.showDialog(Severity.Error, nls.localize("insightsError", "Insights error"), message.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user