Compare commits

..

18 Commits

Author SHA1 Message Date
Karl Burtram
a64a0d1db6 Bump SQL Ops to 0.32.1 for August iteration 2018-07-19 11:43:32 -07:00
Anthony Dresser
feab43f16d add ' to escape strings for html (#1974) 2018-07-19 14:42:29 -04:00
Karl Burtram
0d60fe775f Update Readme and Changelog (#1968) 2018-07-19 01:21:06 -04:00
Leila Lali
6680be6a73 adding task integration with wizard and dialog framework (#1929)
* adding task integration with wizard and dialog framework
2018-07-18 16:28:36 -07:00
Karl Burtram
e026ab85a7 Escape the aria string for Edit Data grid (#1958) 2018-07-17 18:45:10 -07:00
Karl Burtram
e53c903205 Update tools service to 1.5.0-alpha.12 2018-07-17 18:44:45 -07:00
Matt Irvine
03dbe8565f Set element text instead of HTML where possible (#1956) 2018-07-17 16:48:38 -07:00
Karl Burtram
708793cb23 Update tools service to 1.5.0-alpha.11 2018-07-17 16:47:31 -07:00
Aditya Bist
43ae4fb0aa Fixed 2 bugs in Agent Steps page. (#1953)
* fixed bug where steps werent being shown

* fixed customer reported issue
2018-07-17 15:49:38 -07:00
Aditya Bist
6b1d552277 Agent/step finishes (#1948)
* misc fixes in dialogs

* removed unused import

* disabled more advanced options
2018-07-17 10:51:31 -07:00
Madeline MacDonald
f24f576b72 Profiler display fixes (#1949)
* Fixing details tab, window resizing, and having profiler options in object explorer

* Fixing displaying connection names

* spacing

* Removing unnecessary code
2018-07-16 17:20:13 -07:00
Matt Irvine
c23328564f Hide correct element when hiding buttons (#1945) 2018-07-16 17:09:44 -07:00
Karl Burtram
cd6dd3dafa Bump Tools Service to 1.5.0-alpha.10 (#1947) 2018-07-16 15:40:41 -07:00
Aditya Bist
4081e15bef misc fixes in dialogs (#1942)
* misc fixes in dialogs

* removed unused import
2018-07-16 15:25:11 -07:00
Karl Burtram
b05e3813d1 Bump product version to 0.31.4 from July Public Preview (#1944) 2018-07-16 15:13:10 -07:00
Karl Burtram
3048311f40 Bump agent extension version to 0.31.4 (#1943) 2018-07-16 15:12:54 -07:00
Madeline MacDonald
1045392d91 Escaping profiler text (#1940) 2018-07-16 13:20:56 -07:00
Madeline MacDonald
7b23ca8ee7 Improving profiler controls and toolbar (#1931)
* Profiler toolbar improvements

* Fixing formatting issues
2018-07-16 11:44:14 -07:00
61 changed files with 840 additions and 176 deletions

View File

@@ -1,5 +1,26 @@
# Change Log
## Version 0.31.4
* Release date: July 19, 2018
* Release status: Public Preview
## What's new in this version
* SQL Server Agent for SQL Operations Studio extension improvements
* Added view of Alerts, Operators, and Proxies and icons on left pane
* Added dialogs for New Job, New Job Step, New Alert, and New Operator
* Added Delete Job, Delete Alert, and Delete Operator (right-click)
* Added Previous Runs visualization
* Added Filters for each column name
* SQL Server Profiler for SQL Operations Studio extension improvements
* Added Hotkeys to quickly launch and start/stop Profiler
* Added 5 Default Templates to view Extended Events
* Added Server/Database connection name
* Added support for Azure SQL Database instances
* Added suggestion to exit Profiler when tab is closed when Profiler is still running
* Release of Combine Scripts Extension
* Wizard and Dialog Extensibility
* Fix GitHub Issues
## Version 0.30.6
* Release date: June 20, 2018
* Release status: Public Preview

View File

@@ -8,12 +8,12 @@ SQL Operations Studio is a data management tool that enables you to work with SQ
Platform | Link
-- | --
Windows Setup Installer | https://go.microsoft.com/fwlink/?linkid=875602
Windows ZIP | https://go.microsoft.com/fwlink/?linkid=875603
macOS ZIP | https://go.microsoft.com/fwlink/?linkid=875604
Linux TAR.GZ | https://go.microsoft.com/fwlink/?linkid=875605
Linux RPM | https://go.microsoft.com/fwlink/?linkid=875606
Linux DEB | https://go.microsoft.com/fwlink/?linkid=875607
Windows Setup Installer | https://go.microsoft.com/fwlink/?linkid=2005949
Windows ZIP | https://go.microsoft.com/fwlink/?linkid=2005950
macOS ZIP | https://go.microsoft.com/fwlink/?linkid=2005959
Linux TAR.GZ | https://go.microsoft.com/fwlink/?linkid=2005960
Linux RPM | https://go.microsoft.com/fwlink/?linkid=2006083
Linux DEB | https://go.microsoft.com/fwlink/?linkid=2006084
Go to our [download page](https://aka.ms/sqlopsstudio) for more specific instructions.
@@ -85,7 +85,7 @@ We would like to thank all our users who raised issues, and in particular the fo
* Chinese (Traditional): Bruce Chen, Chiayi Yen, Kevin Yang, Winnie Lin, 保哥 Will, 謝政廷
* Korean: Do-Kyun Kim, Evelyn Kim, Helen Jung, Hong Jmee, jeongwoo choi, Jun Hyoung Lee, Jungsun Kim정선, Justin Yoo, Kavrith mucha, Kiwoong Youm, MinGyu Ju, MVP_JUNO BEA, Sejun Kim, SOONMAN KWON, sung man ko, Yeongrak Choi, younggun kim, Youngjae Kim, 소영 이
* Russian: Andrey Veselov, Anton Fontanov, Anton Savin, Elena Ostrovskaia, Igor Babichev, Maxim Zelensky, Rodion Fedechkin, Tasha T, Vladimir Zyryanov
* Portuguese Brazil: Daniel de Sousa, Diogo Duarte, Douglas Correa, Douglas Eccker, José Emanuel Mendes, Marcelo Fernandes, Marcondes Alexandre, Roberto Fonseca, Rodrigo Crespi
* Portuguese Brazil: Daniel de Sousa, Diogo Duarte, Douglas Correa, Douglas Eccker, José Emanuel Mendes, Marcelo Fernandes, Marcondes Alexandre, Roberto Fonseca, Rodrigo Crespi
And of course we'd like to thank the authors of all upstream dependencies. Please see a full list in the [ThirdPartyNotices.txt](https://raw.githubusercontent.com/Microsoft/sqlopsstudio/master/ThirdPartyNotices.txt)

View File

@@ -2,7 +2,7 @@
"name": "agent",
"displayName": "SQL Server Agent",
"description": "Manage and troubleshoot SQL Server Agent jobs",
"version": "0.31.1",
"version": "0.31.4",
"publisher": "Microsoft",
"preview": true,
"license": "https://raw.githubusercontent.com/Microsoft/sqlopsstudio/master/LICENSE.txt",

View File

@@ -63,8 +63,9 @@ export class AlertDialog extends AgentDialog<AlertData> {
private static readonly AlertTypes: string[] = [
AlertData.AlertTypeSqlServerEventString,
AlertData.AlertTypePerformanceConditionString,
AlertData.AlertTypeWmiEventString
// Disabled until next release
// AlertData.AlertTypePerformanceConditionString,
// AlertData.AlertTypeWmiEventString
];
private static readonly AlertSeverities: string[] = [

View File

@@ -219,6 +219,9 @@ export class JobDialog extends AgentDialog<JobData> {
width: 80
}).component();
this.moveStepUpButton.enabled = false;
this.moveStepDownButton.enabled = false;
this.newStepButton = view.modelBuilder.button().withProperties({
label: this.NewStepButtonString,
width: 80

View File

@@ -30,6 +30,7 @@ export class JobStepDialog {
private readonly PreviousButtonText: string = localize('jobStepDialog.previous','Previous');
private readonly SuccessfulParseText: string = localize('jobStepDialog.successParse', 'The command was successfully parsed.');
private readonly FailureParseText: string = localize('jobStepDialog.failParse', 'The command failed.');
private readonly BlankStepNameErrorText: string = localize('jobStepDialog.blankStepName', 'The step name cannot be left blank');
// General Control Titles
private readonly StepNameLabelString: string = localize('jobStepDialog.stepNameLabel', 'Step Name');
@@ -139,12 +140,15 @@ export class JobStepDialog {
this.openButton = view.modelBuilder.button()
.withProperties({
label: this.OpenCommandText,
width: '80px'
width: '80px',
isFile: true
}).component();
this.openButton.enabled = false;
this.parseButton = view.modelBuilder.button()
.withProperties({
label: this.ParseCommandText,
width: '80px'
width: '80px',
isFile: false
}).component();
this.parseButton.onDidClick(e => {
if (this.commandTextBox.value) {
@@ -185,6 +189,12 @@ export class JobStepDialog {
.withProperties({
}).component();
this.nameTextBox.required = true;
this.nameTextBox.onTextChanged(() => {
if (this.nameTextBox.value.length > 0) {
this.dialog.message = null;
}
});
this.typeDropdown = view.modelBuilder.dropDown()
.withProperties({
value: this.TSQLScript,
@@ -465,7 +475,12 @@ export class JobStepDialog {
return outputFileForm;
}
private async execute() {
protected execute() {
this.model.stepName = this.nameTextBox.value;
if (!this.model.stepName || this.model.stepName.length === 0) {
this.dialog.message = this.dialog.message = { text: this.BlankStepNameErrorText };
return;
}
this.model.jobName = this.jobName;
this.model.id = this.stepId;
this.model.server = this.server;
@@ -479,7 +494,6 @@ export class JobStepDialog {
this.model.failureAction = this.failureActionDropdown.value as string;
this.model.outputFileName = this.outputFileNameBox.value;
this.model.appendToLogFile = this.appendToExistingFileCheckbox.checked;
await this.model.save();
}
public async openNewStepDialog() {

View File

@@ -658,7 +658,7 @@
}
},
"dependencies": {
"dataprotocol-client": "github:Microsoft/sqlops-dataprotocolclient#0.1.9",
"dataprotocol-client": "github:Microsoft/sqlops-dataprotocolclient#0.2.0",
"opener": "^1.4.3",
"service-downloader": "github:anthonydresser/service-downloader#0.1.2",
"vscode-extension-telemetry": "^0.0.15"

View File

@@ -1,6 +1,6 @@
{
"downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/v{#version#}/microsoft.sqltools.servicelayer-{#fileName#}",
"version": "1.5.0-alpha.9",
"version": "1.5.0-alpha.12",
"downloadFileNames": {
"Windows_86": "win-x86-netcoreapp2.1.zip",
"Windows_64": "win-x64-netcoreapp2.1.zip",

View File

@@ -49,9 +49,9 @@ core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
"dataprotocol-client@github:Microsoft/sqlops-dataprotocolclient#0.1.9":
version "0.1.9"
resolved "https://codeload.github.com/Microsoft/sqlops-dataprotocolclient/tar.gz/a1a79895cb79658b75d78aa5cfd745855019148d"
"dataprotocol-client@github:Microsoft/sqlops-dataprotocolclient#0.2.0":
version "0.2.0"
resolved "https://codeload.github.com/Microsoft/sqlops-dataprotocolclient/tar.gz/c7a691c7fc5ad54a147090784a7f11efda301f4b"
dependencies:
vscode-languageclient "3.5.0"

View File

@@ -1,6 +1,6 @@
{
"name": "sqlops",
"version": "0.31.3",
"version": "0.32.1",
"distro": "8c3e97e3425cc9814496472ab73e076de2ba99ee",
"author": {
"name": "Microsoft Corporation"

View File

@@ -69,10 +69,10 @@ export default class MainController implements vscode.Disposable {
private async getTabContent(view: sqlops.ModelView, customButton1: sqlops.window.modelviewdialog.Button, customButton2: sqlops.window.modelviewdialog.Button, componentWidth: number | string): Promise<void> {
let inputBox = view.modelBuilder.inputBox()
.withProperties({
multiline: true,
height: 100
}).component();
.withProperties({
multiline: true,
height: 100
}).component();
let inputBoxWrapper = view.modelBuilder.loadingComponent().withItem(inputBox).component();
inputBoxWrapper.loading = false;
customButton1.onClick(() => {
@@ -145,8 +145,8 @@ export default class MainController implements vscode.Disposable {
component: inputBox4,
title: 'inputBox4'
}], {
horizontal: true
}).component();
horizontal: true
}).component();
let groupModel1 = view.modelBuilder.groupContainer()
.withLayout({
}).withItems([
@@ -178,8 +178,8 @@ export default class MainController implements vscode.Disposable {
}).component();
let declarativeTable = view.modelBuilder.declarativeTable()
.withProperties({
columns: [{
.withProperties({
columns: [{
displayName: 'Column 1',
valueType: sqlops.DeclarativeDataType.string,
width: '20px',
@@ -204,12 +204,12 @@ export default class MainController implements vscode.Disposable {
{ name: 'options2', displayName: 'option 2' }
]
}
],
data: [
['Data00', 'Data01', false, 'options2'],
['Data10', 'Data11', true, 'options1']
]
}).component();
],
data: [
['Data00', 'Data01', false, 'options2'],
['Data10', 'Data11', true, 'options1']
]
}).component();
declarativeTable.onDataChanged(e => {
inputBox2.value = e.row.toString() + ' ' + e.column.toString() + ' ' + e.value.toString();
@@ -223,7 +223,7 @@ export default class MainController implements vscode.Disposable {
height: 150
}).withItems([
radioButton, groupModel1, radioButton2]
, { flex: '1 1 50%' }).component();
, { flex: '1 1 50%' }).component();
let formModel = view.modelBuilder.formContainer()
.withFormItems([{
component: inputBoxWrapper,
@@ -254,9 +254,9 @@ export default class MainController implements vscode.Disposable {
component: listBox,
title: 'List Box'
}], {
horizontal: false,
componentWidth: componentWidth
}).component();
horizontal: false,
componentWidth: componentWidth
}).component();
let formWrapper = view.modelBuilder.loadingComponent().withItem(formModel).component();
formWrapper.loading = false;
customButton2.onClick(() => {
@@ -301,6 +301,17 @@ export default class MainController implements vscode.Disposable {
page1.registerContent(async (view) => {
await this.getTabContent(view, customButton1, customButton2, 800);
});
wizard.registerOperation({
displayName: 'test task',
description: 'task description',
isCancelable: true
}, op => {
op.updateStatus(sqlops.TaskStatus.InProgress);
op.updateStatus(sqlops.TaskStatus.InProgress, 'Task is running');
setTimeout(() => {
op.updateStatus(sqlops.TaskStatus.Succeeded);
}, 5000);
});
wizard.pages = [page1, page2];
wizard.open();
}
@@ -378,13 +389,14 @@ export default class MainController implements vscode.Disposable {
let monitorLightPath = vscode.Uri.file(path.join(__dirname, '..', 'media', 'monitor.svg'));
let monitorIcon = {
light: monitorLightPath,
dark: path.join(__dirname, '..', 'media', 'monitor_inverse.svg') };
dark: path.join(__dirname, '..', 'media', 'monitor_inverse.svg')
};
let monitorButton = view.modelBuilder.button()
.withProperties({
label: 'Monitor',
iconPath: monitorIcon
}).component();
.withProperties({
label: 'Monitor',
iconPath: monitorIcon
}).component();
let toolbarModel = view.modelBuilder.toolbarContainer()
.withToolbarItems([{
component: inputBox,

View File

@@ -33,7 +33,7 @@ export function appendRowLink(container: Builder, label: string, labelClass: str
container.element('tr', {}, (rowContainer) => {
rowContainer.element('td', { class: labelClass }, (labelCellContainer) => {
labelCellContainer.div({}, (labelContainer) => {
labelContainer.innerHtml(label);
labelContainer.text(label);
});
});
rowContainer.element('td', { class: cellContainerClass }, (inputCellContainer) => {

View File

@@ -150,8 +150,8 @@ export class OptionsDialog extends Modal {
private onOptionLinkClicked(optionName: string): void {
var option = this._optionElements[optionName].option;
this._optionTitle.innerHtml(option.displayName);
this._optionDescription.innerHtml(option.description);
this._optionTitle.text(option.displayName);
this._optionDescription.text(option.description);
}
private fillInOptions(container: Builder, options: sqlops.ServiceOption[]): void {

View File

@@ -62,7 +62,7 @@ export class TabHeaderComponent extends Disposable implements AfterContentInit,
tabLabelcontainer.classList.add(this.tab.iconClass);
} else {
tabLabelcontainer.className = 'tabLabel';
tabLabelcontainer.innerHTML = this.tab.title;
tabLabelcontainer.textContent = this.tab.title;
}
tabLabelcontainer.title = this.tab.title;
}

View File

@@ -6,6 +6,7 @@ import { mixin } from 'vs/base/common/objects';
import { SlickGrid } from 'angular2-slickgrid';
import { Button } from '../../button/button';
import { attachButtonStyler } from 'sql/common/theme/styler';
import { escape } from 'sql/base/common/strings';
import { IThemeService } from 'vs/platform/theme/common/themeService';
export class HeaderFilter {
@@ -174,7 +175,7 @@ export class HeaderFilter {
if (filterItems[i] && filterItems[i].indexOf('Error:') < 0) {
filterOptions += '<label><input type="checkbox" value="' + i + '"'
+ (filtered ? ' checked="checked"' : '')
+ '/>' + filterItems[i] + '</label>';
+ '/>' + escape(filterItems[i]) + '</label>';
}
}
let $filter = $('<div class="filter">')

View File

@@ -1,5 +1,6 @@
// Adopted and converted to typescript from https://github.com/6pac/SlickGrid/blob/master/plugins/slick.rowdetailview.js
// heavily modified
import { escape } from 'sql/base/common/strings';
import { mixin } from 'vs/base/common/objects';
import * as nls from 'vs/nls';
@@ -354,7 +355,7 @@ export class RowDetailView {
html.push("style='height:", dataContext._height, "px;"); //set total height of padding
html.push("top:", rowHeight, "px'>"); //shift detail below 1st row
html.push("<div id='detailViewContainer_", dataContext.id, "' class='detail-container' style='max-height:" + (dataContext._height - rowHeight + bottomMargin) + "px'>"); //sub ctr for custom styling
html.push("<div id='innerDetailView_", dataContext.id, "'>", dataContext._detailContent, "</div></div>");
html.push("<div id='innerDetailView_", dataContext.id, "'>", escape(dataContext._detailContent), "</div></div>");
//&omit a final closing detail container </div> that would come next
return html.join('');

View File

@@ -82,7 +82,7 @@ export class Taskbar {
public static createTaskbarText(inputText: string): HTMLElement {
let element = document.createElement('div');
element.className = 'taskbarTextSeparator';
element.innerHTML = inputText;
element.textContent = inputText;
return element;
}

View File

@@ -15,6 +15,7 @@ export function escape(html: string): string {
case '>': return '&gt;';
case '&': return '&amp;';
case '"': return '&quot;';
case '\'': return '&#39';
default: return match;
}
});

View File

@@ -100,7 +100,7 @@ export class AutoOAuthDialog extends Modal {
let inputBox: InputBox;
container.div({ class: 'dialog-input-section' }, (inputContainer) => {
inputContainer.div({ class: 'dialog-label' }, (labelContainer) => {
labelContainer.innerHtml(label);
labelContainer.text(label);
});
inputContainer.div({ class: 'dialog-input' }, (inputCellContainer) => {

View File

@@ -145,7 +145,7 @@ export class FirewallRuleDialog extends Modal {
subnetIPRangeSection = subnetIPRangeContainer.getHTMLElement();
subnetIPRangeContainer.div({ 'class': 'dialog-input-section' }, (inputContainer) => {
inputContainer.div({ 'class': 'dialog-label' }, (labelContainer) => {
labelContainer.innerHtml(LocalizedStrings.FROM);
labelContainer.text(LocalizedStrings.FROM);
});
inputContainer.div({ 'class': 'dialog-input' }, (inputCellContainer) => {
@@ -155,7 +155,7 @@ export class FirewallRuleDialog extends Modal {
});
inputContainer.div({ 'class': 'dialog-label' }, (labelContainer) => {
labelContainer.innerHtml(LocalizedStrings.TO);
labelContainer.text(LocalizedStrings.TO);
});
inputContainer.div({ 'class': 'dialog-input' }, (inputCellContainer) => {
@@ -234,7 +234,7 @@ export class FirewallRuleDialog extends Modal {
className += ' header';
}
container.div({ 'class': className }, (labelContainer) => {
labelContainer.innerHtml(content);
labelContainer.text(content);
});
}

View File

@@ -320,12 +320,13 @@ export enum MetadataType {
}
export enum TaskStatus {
notStarted = 0,
inProgress = 1,
succeeded = 2,
succeededWithWarning = 3,
failed = 4,
canceled = 5
NotStarted = 0,
InProgress = 1,
Succeeded = 2,
SucceededWithWarning = 3,
Failed = 4,
Canceled = 5,
Canceling = 6
}
export interface IConnectionParams {

View File

@@ -262,7 +262,7 @@ export class ConnectionDialogWidget extends Modal {
let recentHistoryLabel = localize('recentHistory', 'Recent history');
recentConnectionContainer.div({ class: 'recent-titles-container' }, (container) => {
container.div({ class: 'connection-history-label' }, (recentTitle) => {
recentTitle.innerHtml(recentHistoryLabel);
recentTitle.text(recentHistoryLabel);
});
container.div({ class: 'connection-history-actions' }, (actionsContainer) => {
this._actionbar = this._register(new ActionBar(actionsContainer.getHTMLElement(), { animated: false }));
@@ -303,7 +303,7 @@ export class ConnectionDialogWidget extends Modal {
this._noRecentConnectionBuilder.div({ class: 'connection-recent-content' }, (noRecentConnectionContainer) => {
let noRecentHistoryLabel = localize('noRecentConnections', 'No recent connection');
noRecentConnectionContainer.div({ class: 'no-recent-connections' }, (noRecentTitle) => {
noRecentTitle.innerHtml(noRecentHistoryLabel);
noRecentTitle.text(noRecentHistoryLabel);
});
});
}
@@ -335,7 +335,7 @@ export class ConnectionDialogWidget extends Modal {
this._noSavedConnectionBuilder.div({ class: 'connection-saved-content' }, (noSavedConnectionContainer) => {
let noSavedConnectionLabel = localize('noSavedConnections', 'No saved connection');
noSavedConnectionContainer.div({ class: 'no-saved-connections' }, (titleContainer) => {
titleContainer.innerHtml(noSavedConnectionLabel);
titleContainer.text(noSavedConnectionLabel);
});
});
}

View File

@@ -163,7 +163,7 @@ export class NewDashboardTabDialog extends Modal {
this._noExtensionViewContainer = DOM.$('.no-extension-view');
let noExtensionTitle = DOM.append(this._noExtensionViewContainer, DOM.$('.no-extensionTab-label'));
let noExtensionLabel = localize('newdashboardTabDialog.noExtensionLabel', 'No dashboard extensions are installed at this time. Go to Extension Manager to explore recommended extensions.');
noExtensionTitle.innerHTML = noExtensionLabel;
noExtensionTitle.textContent = noExtensionLabel;
DOM.append(container, this._noExtensionViewContainer);
}

View File

@@ -179,8 +179,8 @@ export class RestoreDialogController implements IRestoreDialogController {
private isSuccessfulRestore(response: TaskNode): boolean {
return (response.taskName === this._restoreTaskName &&
response.message === this._restoreCompleted &&
(response.status === TaskStatus.succeeded ||
response.status === TaskStatus.succeededWithWarning) &&
(response.status === TaskStatus.Succeeded ||
response.status === TaskStatus.SucceededWithWarning) &&
(response.taskExecutionMode === TaskExecutionMode.execute ||
response.taskExecutionMode === TaskExecutionMode.executeAndScript));
}

View File

@@ -226,7 +226,7 @@ export class RestoreDialog extends Modal {
destinationContainer.div({ class: 'dialog-input-section' }, (inputContainer) => {
inputContainer.div({ class: 'dialog-label' }, (labelContainer) => {
labelContainer.innerHtml(LocalizedStrings.TARGETDATABASE);
labelContainer.text(LocalizedStrings.TARGETDATABASE);
});
inputContainer.div({ class: 'dialog-input' }, (inputCellContainer) => {
@@ -471,7 +471,7 @@ export class RestoreDialog extends Modal {
className += ' header';
}
container.div({ class: className }, (labelContainer) => {
labelContainer.innerHtml(content);
labelContainer.text(content);
});
}
@@ -535,7 +535,7 @@ export class RestoreDialog extends Modal {
let selectBox: SelectBox;
container.div({ class: 'dialog-input-section' }, (inputContainer) => {
inputContainer.div({ class: 'dialog-label' }, (labelContainer) => {
labelContainer.innerHtml(label);
labelContainer.text(label);
});
inputContainer.div({ class: 'dialog-input' }, (inputCellContainer) => {

View File

@@ -198,7 +198,7 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
rowIndex++;
return {
values: row.cells.map(c => {
return mixin({ ariaLabel: c.displayValue }, c);
return mixin({ ariaLabel: escape(c.displayValue) }, c);
}), row: row.id
};
});

View File

@@ -154,7 +154,7 @@
</td>
</tr>
</table>
<div #jobsteps>
<div #jobsteps style="height: 100%">
<jobstepsview-component *ngIf="showSteps === true"></jobstepsview-component>
</div>
<h3 *ngIf="showSteps === false">No Steps Available</h3>

View File

@@ -174,10 +174,12 @@ export class JobHistoryComponent extends JobManagementView implements OnInit {
if (self.agentJobHistoryInfo) {
self.agentJobHistoryInfo.runDate = self.formatTime(self.agentJobHistoryInfo.runDate);
if (self.agentJobHistoryInfo.steps) {
let jobStepStatus = this.didJobFail(self.agentJobHistoryInfo);
self._stepRows = self.agentJobHistoryInfo.steps.map(step => {
let stepViewRow = new JobStepsViewRow();
stepViewRow.message = step.message;
stepViewRow.runStatus = JobManagementUtilities.convertToStatusString(step.runStatus);
stepViewRow.runStatus = jobStepStatus ? JobManagementUtilities.convertToStatusString(0) :
JobManagementUtilities.convertToStatusString(step.runStatus);
self._runStatus = JobManagementUtilities.convertToStatusString(self.agentJobHistoryInfo.runStatus);
stepViewRow.stepName = step.stepName;
stepViewRow.stepID = step.stepId.toString();
@@ -191,6 +193,15 @@ export class JobHistoryComponent extends JobManagementView implements OnInit {
}
}
private didJobFail(job: sqlops.AgentJobHistoryInfo): boolean {
for (let i = 0; i < job.steps.length; i++) {
if (job.steps[i].runStatus === 0) {
return true;
}
}
return false;
}
private buildHistoryTree(self: any, jobHistories: sqlops.AgentJobHistoryInfo[]) {
self._treeController.jobHistories = jobHistories;
self._jobCacheObject.setJobHistory(self._agentViewComponent.jobId, jobHistories);

View File

@@ -104,7 +104,6 @@ export interface IListTemplate {
}
export class JobHistoryRenderer implements tree.IRenderer {
private _statusIcon: HTMLElement;
public getHeight(tree: tree.ITree, element: JobHistoryRow): number {
return 30;
@@ -121,11 +120,10 @@ export class JobHistoryRenderer implements tree.IRenderer {
public renderTemplate(tree: tree.ITree, templateId: string, container: HTMLElement): IListTemplate {
let row = DOM.$('.list-row');
let label = DOM.$('.label');
this._statusIcon = this.createStatusIcon();
row.appendChild(this._statusIcon);
let statusIcon = this.createStatusIcon();
row.appendChild(statusIcon);
row.appendChild(label);
container.appendChild(row);
let statusIcon = this._statusIcon;
return { statusIcon, label };
}
@@ -133,13 +131,13 @@ export class JobHistoryRenderer implements tree.IRenderer {
templateData.label.innerHTML = element.runDate + '&nbsp;&nbsp;' + element.runStatus;
let statusClass: string;
if (element.runStatus === 'Succeeded') {
statusClass = ' job-passed';
statusClass = 'status-icon job-passed';
} else if (element.runStatus === 'Failed') {
statusClass = ' job-failed';
statusClass = 'status-icon job-failed';
} else {
statusClass = ' job-unknown';
statusClass = 'status-icon job-unknown';
}
this._statusIcon.className += statusClass;
templateData.statusIcon.className = statusClass;
}
public disposeTemplate(tree: tree.ITree, templateId: string, templateData: IListTemplate): void {
@@ -148,7 +146,6 @@ export class JobHistoryRenderer implements tree.IRenderer {
private createStatusIcon(): HTMLElement {
let statusIcon: HTMLElement = DOM.$('div');
statusIcon.className += ' status-icon';
return statusIcon;
}
}

View File

@@ -88,15 +88,6 @@ export class JobStepsViewComponent extends JobManagementView implements OnInit,
}
public layout() {
let jobsViewToolbar = $('jobhistory-component .actionbar-container').get(0);
let statusBar = $('.part.statusbar').get(0);
if (jobsViewToolbar && statusBar) {
let toolbarBottom = jobsViewToolbar.getBoundingClientRect().bottom;
let statusTop = statusBar.getBoundingClientRect().top;
this._table.layout(new dom.Dimension(
dom.getContentWidth(this._tableContainer.nativeElement),
statusTop - toolbarBottom));
}
}
}

View File

@@ -35,6 +35,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
import { IAction } from 'vs/base/common/actions';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IDashboardService } from 'sql/services/dashboard/common/dashboardService';
import { escape } from 'sql/base/common/strings';
export const JOBSVIEW_SELECTOR: string = 'jobsview-component';
export const ROW_HEIGHT: number = 45;
@@ -485,7 +486,7 @@ export class JobsViewComponent extends JobManagementView implements OnInit {
return '<table class="jobview-jobnametable"><tr class="jobview-jobnamerow">' +
'<td nowrap class=' + resultIndicatorClass + '></td>' +
'<td nowrap class="jobview-jobnametext">' + dataContext.name + '</td>' +
'<td nowrap class="jobview-jobnametext">' + escape(dataContext.name) + '</td>' +
'</tr></table>';
}

View File

@@ -4,8 +4,8 @@
*--------------------------------------------------------------------------------------------*/
import 'vs/css!./button';
import {
Component, Input, Inject, ChangeDetectorRef, forwardRef, ComponentFactoryResolver,
ViewChild, ViewChildren, ElementRef, Injector, OnDestroy, QueryList, AfterViewInit
Component, Input, Inject, ChangeDetectorRef, forwardRef,
ViewChild, ElementRef, OnDestroy, AfterViewInit
} from '@angular/core';
import * as sqlops from 'sqlops';
@@ -24,7 +24,13 @@ import { Color } from 'vs/base/common/color';
@Component({
selector: 'modelview-button',
template: `
<div #input style="width: 100%"></div>
<div>
<label for={{this.label}}>
<div #input style="width: 100%">
<input *ngIf="this.isFile === true" id={{this.label}} type="file" style="display: none">
</div>
</label>
</div>
`
})
export default class ButtonComponent extends ComponentWithIconBase implements IComponent, OnDestroy, AfterViewInit {
@@ -119,9 +125,19 @@ export default class ButtonComponent extends ComponentWithIconBase implements IC
this.setPropertyFromUI<sqlops.ButtonProperties, string>(this.setValueProperties, newValue);
}
private get isFile(): boolean {
return this.getPropertyOrDefault<sqlops.ButtonProperties, boolean>((props) => props.isFile, false);
}
private set isFile(newValue: boolean) {
this.setPropertyFromUI<sqlops.ButtonProperties, boolean>(this.setFileProperties, newValue);
}
private setValueProperties(properties: sqlops.ButtonProperties, label: string): void {
properties.label = label;
}
private setFileProperties(properties: sqlops.ButtonProperties, isFile: boolean): void {
properties.isFile = isFile;
}
}

View File

@@ -25,7 +25,7 @@ import { IContextViewService } from 'vs/platform/contextview/browser/contextView
template: `
<div [style.width]="getWidth()">
<div [style.display]="getEditableDisplay()" #editableDropDown style="width: 100%;"></div>
<div [style.display]="getEditableDisplay()" #editableDropDown style="width: 100%;"></div>
<div [style.display]="getNotEditableDisplay()" #dropDown style="width: 100%;"></div>
</div>
`
@@ -79,7 +79,6 @@ export default class DropDownComponent extends ComponentBase implements ICompone
this._selectBox = new SelectBox(this.getValues(), this.getSelectedValue(), this.contextViewService, this._dropDownContainer.nativeElement);
this._selectBox.render(this._dropDownContainer.nativeElement);
this._register(this._selectBox);
this._register(attachSelectBoxStyler(this._selectBox, this.themeService));
this._register(this._selectBox.onDidSelect(e => {
if (!this.editable) {

View File

@@ -4,8 +4,8 @@
*--------------------------------------------------------------------------------------------*/
import {
Component, Input, Inject, ChangeDetectorRef, forwardRef, ComponentFactoryResolver,
ViewChild, ViewChildren, ElementRef, Injector, OnDestroy, QueryList, AfterViewInit
Component, Input, Inject, ChangeDetectorRef, forwardRef,
ViewChild, ElementRef, OnDestroy, AfterViewInit
} from '@angular/core';
import * as sqlops from 'sqlops';

View File

@@ -16,7 +16,6 @@ import { Table } from 'sql/base/browser/ui/table/table';
import { TableDataView } from 'sql/base/browser/ui/table/tableDataView';
import { attachTableStyler } from 'sql/common/theme/styler';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { getContentHeight, getContentWidth, Dimension } from 'vs/base/browser/dom';
import { RowSelectionModel } from 'sql/base/browser/ui/table/plugins/rowSelectionModel.plugin';

View File

@@ -79,7 +79,7 @@ export class ServerGroupDialog extends Modal {
// Connection Group Name
let serverGroupNameLabel = localize('connectionGroupName', 'Server group name');
this._bodyBuilder.div({ class: 'dialog-label' }, (labelContainer) => {
labelContainer.innerHtml(serverGroupNameLabel);
labelContainer.text(serverGroupNameLabel);
});
this._bodyBuilder.div({ class: 'input-divider' }, (inputCellContainer) => {
let errorMessage = localize('MissingGroupNameError', 'Group name is required.');
@@ -94,7 +94,7 @@ export class ServerGroupDialog extends Modal {
// Connection Group Description
let groupDescriptionLabel = localize('groupDescription', 'Group description');
this._bodyBuilder.div({ class: 'dialog-label' }, (labelContainer) => {
labelContainer.innerHtml(groupDescriptionLabel);
labelContainer.text(groupDescriptionLabel);
});
this._bodyBuilder.div({ class: 'input-divider' }, (inputCellContainer) => {
this._groupDescriptionInputBox = new InputBox(inputCellContainer.getHTMLElement(), this._contextViewService, {
@@ -105,7 +105,7 @@ export class ServerGroupDialog extends Modal {
// Connection Group Color
this._bodyBuilder.div({ class: 'dialog-label' }, (labelContainer) => {
let groupColorLabel = localize('groupColor', 'Group color');
labelContainer.innerHtml(groupColorLabel);
labelContainer.text(groupColorLabel);
});
this._bodyBuilder.div({ class: 'group-color-options' }, (groupColorContainer) => {

View File

@@ -77,7 +77,6 @@ export class ProfilerStart extends Action {
}
public run(input: ProfilerInput): TPromise<boolean> {
this.enabled = false;
input.data.clear();
return TPromise.wrap(this._profilerService.startSession(input.id));
}
@@ -127,7 +126,6 @@ export class ProfilerStop extends Action {
}
public run(input: ProfilerInput): TPromise<boolean> {
this.enabled = false;
return TPromise.wrap(this._profilerService.stopSession(input.id));
}
}
@@ -137,7 +135,7 @@ export class ProfilerClear extends Action {
public static LABEL = nls.localize('profiler.clear', "Clear Data");
constructor(id: string, label: string) {
super(id, label, 'stop');
super(id, label);
}
run(input: ProfilerInput): TPromise<void> {
@@ -148,14 +146,15 @@ export class ProfilerClear extends Action {
export class ProfilerAutoScroll extends Action {
public static ID = 'profiler.autoscroll';
public static LABEL = nls.localize('profiler.toggleAutoscroll', "Toggle Auto Scroll");
public static LABEL = nls.localize('profiler.autoscrollOn', "Auto Scroll: On");
constructor(id: string, label: string) {
super(id, label, 'stop');
super(id, label);
}
run(input: ProfilerInput): TPromise<boolean> {
this.checked = !this.checked;
this._setLabel(this.checked ? nls.localize('profilerAction.autoscrollOn', "Auto Scroll: On") : nls.localize('profilerAction.autoscrollOff', "Auto Scroll: Off"));
input.state.change({ autoscroll: this.checked });
return TPromise.as(true);
}

View File

@@ -166,6 +166,7 @@ export class ProfilerTableEditor extends BaseEditor implements IProfilerControll
public layout(dimension: Dimension): void {
this._currentDimensions = dimension;
this._profilerTable.layout(dimension);
this._profilerTable.autosizeColumns();
this._onDidChangeConfiguration.fire({ layoutInfo: true });
}

View File

@@ -50,6 +50,7 @@ class BasicView extends View {
private _previousSize: number;
private _collapsed: boolean;
public headerSize: number;
constructor(
initialSize: number,
private _element: HTMLElement,
@@ -58,6 +59,7 @@ class BasicView extends View {
opts: IViewOptions
) {
super(initialSize, opts);
this._previousSize = initialSize;
}
render(container: HTMLElement, orientation: Orientation): void {
@@ -116,6 +118,7 @@ export class ProfilerEditor extends BaseEditor {
private _viewTemplateSelector: SelectBox;
private _viewTemplates: Array<IProfilerViewTemplate>;
private _connectionInfoText: HTMLElement;
// Actions
private _connectAction: Actions.ProfilerConnect;
@@ -199,8 +202,16 @@ export class ProfilerEditor extends BaseEditor {
}));
let dropdownContainer = document.createElement('div');
dropdownContainer.style.width = '150px';
dropdownContainer.style.paddingRight = '5px';
this._viewTemplateSelector.render(dropdownContainer);
this._connectionInfoText = document.createElement('div');
this._connectionInfoText.style.paddingRight = '5px';
this._connectionInfoText.innerText = '';
this._connectionInfoText.style.textAlign = 'center';
this._connectionInfoText.style.display = 'flex';
this._connectionInfoText.style.alignItems = 'center';
this._register(attachSelectBoxStyler(this._viewTemplateSelector, this.themeService));
this._actionBar.setContent([
@@ -211,6 +222,8 @@ export class ProfilerEditor extends BaseEditor {
{ action: this._autoscrollAction },
{ action: this._instantiationService.createInstance(Actions.ProfilerClear, Actions.ProfilerClear.ID, Actions.ProfilerClear.LABEL) },
{ element: dropdownContainer },
{ element: Taskbar.createTaskbarSeparator() },
{ element: this._connectionInfoText }
]);
}
@@ -361,6 +374,7 @@ export class ProfilerEditor extends BaseEditor {
autoscroll: true,
isPanelCollapsed: true
});
this._connectionInfoText.innerText = input.connectionName;
this._profilerTableEditor.updateState();
this._splitView.layout();
this._profilerTableEditor.focus();

View File

@@ -9,6 +9,7 @@ import { ProfilerState } from './profilerState';
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
import * as sqlops from 'sqlops';
import * as nls from 'vs/nls';
import { TPromise } from 'vs/base/common/winjs.base';
import { EditorInput } from 'vs/workbench/common/editor';
@@ -17,8 +18,8 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { INotificationService } from 'vs/platform/notification/common/notification';
import { Event, Emitter } from 'vs/base/common/event';
import { generateUuid } from 'vs/base/common/uuid';
import * as nls from 'vs/nls';
import { IDialogService, IConfirmation, IConfirmationResult } from 'vs/platform/dialogs/common/dialogs';
import { escape } from 'sql/base/common/strings';
export class ProfilerInput extends EditorInput implements IProfilerSession {
@@ -40,7 +41,8 @@ export class ProfilerInput extends EditorInput implements IProfilerSession {
private _connection: IConnectionProfile,
@IInstantiationService private _instantiationService: IInstantiationService,
@IProfilerService private _profilerService: IProfilerService,
@INotificationService private _notificationService: INotificationService
@INotificationService private _notificationService: INotificationService,
@IDialogService private _dialogService: IDialogService
) {
super();
this._state = new ProfilerState();
@@ -64,6 +66,23 @@ export class ProfilerInput extends EditorInput implements IProfilerSession {
return ret;
};
this._data = new TableDataView<Slick.SlickData>(undefined, searchFn);
this.onDispose(() => {
if (this._state.isRunning || this.state.isPaused) {
let confirm: IConfirmation = {
message: nls.localize('confirmStopProfilerSession', "Would you like to stop the running XEvent session?"),
primaryButton: nls.localize('profilerClosingActions.yes', 'Yes'),
secondaryButton: nls.localize('profilerClosingActions.no', 'No'),
type: 'question'
};
this._dialogService.confirm(confirm).then(result => {
if (result.confirmed) {
this._profilerService.stopSession(this.id);
}
});
}
});
}
public set viewTemplate(template: IProfilerViewTemplate) {
@@ -130,6 +149,19 @@ export class ProfilerInput extends EditorInput implements IProfilerSession {
this._onColumnsChanged.fire(this.columns);
}
public get connectionName(): string {
if (this._connection !== null) {
if (this._connection.databaseName) {
return `${ this._connection.serverName } ${ this._connection.databaseName }`;
} else {
return `${ this._connection.serverName }`;
}
}
else {
return nls.localize('profilerInput.notConnected', "Not connected");
}
}
public get id(): ProfilerSessionID {
return this._id;
}
@@ -171,7 +203,7 @@ export class ProfilerInput extends EditorInput implements IProfilerSession {
let columnName = this._columnMapping[key];
if (columnName) {
let value = e.values[key];
data[columnName] = value;
data[columnName] = escape(value);
}
}
this._data.push(data);

View File

@@ -98,7 +98,6 @@ export interface IProfilerSettings {
export interface IColumnViewTemplate {
name: string;
width: string;
eventsMapped: Array<string>;
}

View File

@@ -17,6 +17,7 @@ import * as sqlops from 'sqlops';
import { TPromise } from 'vs/base/common/winjs.base';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { INotificationService } from 'vs/platform/notification/common/notification';
class TwoWayMap<T, K> {
private forwardMap: Map<T, K>;
@@ -52,7 +53,8 @@ export class ProfilerService implements IProfilerService {
constructor(
@IConnectionManagementService private _connectionService: IConnectionManagementService,
@IConfigurationService public _configurationService: IConfigurationService,
@IInstantiationService private _instantiationService: IInstantiationService
@IInstantiationService private _instantiationService: IInstantiationService,
@INotificationService private _notificationService: INotificationService
) { }
public registerProvider(providerId: string, provider: sqlops.ProfilerProvider): void {
@@ -99,6 +101,8 @@ export class ProfilerService implements IProfilerService {
return this._runAction(id, provider => provider.startSession(this._idMap.get(id))).then(() => {
this._sessionMap.get(this._idMap.reverseGet(id)).onSessionStateChanged({ isRunning: true, isStopped: false, isPaused: false });
return true;
}, (reason) => {
this._notificationService.error(reason.message);
});
}
@@ -110,6 +114,8 @@ export class ProfilerService implements IProfilerService {
return this._runAction(id, provider => provider.stopSession(this._idMap.get(id))).then(() => {
this._sessionMap.get(this._idMap.reverseGet(id)).onSessionStateChanged({ isStopped: true, isPaused: false, isRunning: false });
return true;
}, (reason) => {
this._notificationService.error(reason.message);
});
}

View File

@@ -7,13 +7,13 @@ import { StopWatch } from 'vs/base/common/stopwatch';
import { generateUuid } from 'vs/base/common/uuid';
export enum TaskStatus {
notStarted = 0,
inProgress = 1,
succeeded = 2,
succeededWithWarning = 3,
failed = 4,
canceled = 5,
canceling = 6
NotStarted = 0,
InProgress = 1,
Succeeded = 2,
SucceededWithWarning = 3,
Failed = 4,
Canceled = 5,
Canceling = 6
}
export enum TaskExecutionMode {
@@ -107,7 +107,7 @@ export class TaskNode {
this.databaseName = databaseName;
this.timer = StopWatch.create();
this.startTime = new Date().toLocaleTimeString();
this.status = TaskStatus.inProgress;
this.status = TaskStatus.InProgress;
this.hasChildren = false;
this.taskExecutionMode = taskExecutionMode;
this.isCancelable = isCancelable;

View File

@@ -14,6 +14,7 @@ import { localize } from 'vs/nls';
import Severity from 'vs/base/common/severity';
import { TPromise } from 'vs/base/common/winjs.base';
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement';
export const SERVICE_ID = 'taskHistoryService';
export const ITaskService = createDecorator<ITaskService>(SERVICE_ID);
@@ -27,6 +28,8 @@ export interface ITaskService {
getAllTasks(): TaskNode;
getNumberOfInProgressTasks(): number;
onNewTaskCreated(handle: number, taskInfo: sqlops.TaskInfo);
createNewTask(taskInfo: sqlops.TaskInfo);
updateTask(taskProgressInfo: sqlops.TaskProgressInfo);
onTaskStatusChanged(handle: number, taskProgressInfo: sqlops.TaskProgressInfo);
cancelTask(providerId: string, taskId: string): Thenable<boolean>;
/**
@@ -52,7 +55,8 @@ export class TaskService implements ITaskService {
constructor(
@ILifecycleService lifecycleService: ILifecycleService,
@IDialogService private dialogService: IDialogService,
@IQueryEditorService private queryEditorService: IQueryEditorService
@IQueryEditorService private queryEditorService: IQueryEditorService,
@IConnectionManagementService private connectionManagementService: IConnectionManagementService
) {
this._taskQueue = new TaskNode('Root', undefined, undefined);
this._onTaskComplete = new Emitter<TaskNode>();
@@ -70,12 +74,27 @@ export class TaskService implements ITaskService {
}
public onNewTaskCreated(handle: number, taskInfo: sqlops.TaskInfo) {
let node: TaskNode = new TaskNode(taskInfo.name, taskInfo.serverName, taskInfo.databaseName, taskInfo.taskId, taskInfo.taskExecutionMode, taskInfo.isCancelable);
this.createNewTask(taskInfo);
}
public createNewTask(taskInfo: sqlops.TaskInfo) {
let databaseName: string = taskInfo.databaseName;
let serverName: string = taskInfo.serverName;
if (taskInfo && taskInfo.connection) {
let connectionProfile = this.connectionManagementService.getConnectionProfile(taskInfo.connection.connectionId);
if (connectionProfile && !!databaseName) {
databaseName = connectionProfile.databaseName;
}
if (connectionProfile && !!serverName) {
serverName = connectionProfile.serverName;
}
}
let node: TaskNode = new TaskNode(taskInfo.name, serverName, databaseName, taskInfo.taskId, taskInfo.taskExecutionMode, taskInfo.isCancelable);
node.providerName = taskInfo.providerName;
this.handleNewTask(node);
}
public onTaskStatusChanged(handle: number, taskProgressInfo: sqlops.TaskProgressInfo) {
public updateTask(taskProgressInfo: sqlops.TaskProgressInfo) {
this.handleTaskComplete({
taskId: taskProgressInfo.taskId,
status: taskProgressInfo.status,
@@ -84,15 +103,23 @@ export class TaskService implements ITaskService {
});
}
public onTaskStatusChanged(handle: number, taskProgressInfo: sqlops.TaskProgressInfo) {
this.updateTask(taskProgressInfo);
}
public cancelTask(providerId: string, taskId: string): Thenable<boolean> {
let task = this.getTaskInQueue(taskId);
task.status = TaskStatus.canceling;
task.status = TaskStatus.Canceling;
this._onTaskComplete.fire(task);
let provider = this._providers[providerId];
if (provider) {
return provider.cancelTask({
taskId: taskId
});
if (providerId) {
let provider = this._providers[providerId];
if (provider && provider.cancelTask) {
return provider.cancelTask({
taskId: taskId
});
}
} else {
return Promise.resolve(true);
}
return Promise.resolve(undefined);
}
@@ -100,7 +127,7 @@ export class TaskService implements ITaskService {
private cancelAllTasks(): Thenable<void> {
return new TPromise<void>((resolve, reject) => {
let promises = this._taskQueue.children.map(task => {
if (task.status === TaskStatus.inProgress || task.status === TaskStatus.notStarted) {
if (task.status === TaskStatus.InProgress || task.status === TaskStatus.NotStarted) {
return this.cancelTask(task.providerName, task.id);
}
return Promise.resolve(true);
@@ -173,10 +200,10 @@ export class TaskService implements ITaskService {
task.message = eventArgs.message;
}
switch (task.status) {
case TaskStatus.canceled:
case TaskStatus.succeeded:
case TaskStatus.succeededWithWarning:
case TaskStatus.failed:
case TaskStatus.Canceled:
case TaskStatus.Succeeded:
case TaskStatus.SucceededWithWarning:
case TaskStatus.Failed:
task.endTime = new Date().toLocaleTimeString();
task.timer.stop();
this._onTaskComplete.fire(task);
@@ -185,7 +212,7 @@ export class TaskService implements ITaskService {
break;
}
if ((task.status === TaskStatus.succeeded || task.status === TaskStatus.succeededWithWarning)
if ((task.status === TaskStatus.Succeeded || task.status === TaskStatus.SucceededWithWarning)
&& eventArgs.script && eventArgs.script !== '') {
if (task.taskExecutionMode === TaskExecutionMode.script) {
this.queryEditorService.newSqlEditor(eventArgs.script);
@@ -214,7 +241,7 @@ export class TaskService implements ITaskService {
public getNumberOfInProgressTasks(): number {
if (this._taskQueue.hasChildren) {
var inProgressTasks = this._taskQueue.children.filter(x => x.status === TaskStatus.inProgress);
var inProgressTasks = this._taskQueue.children.filter(x => x.status === TaskStatus.InProgress);
return inProgressTasks ? inProgressTasks.length : 0;
}
return 0;

View File

@@ -52,12 +52,12 @@ export class TaskHistoryActionProvider extends ContributableActionProvider {
var actions = [];
// get actions for tasks in progress
if (element.status === TaskStatus.inProgress && element.isCancelable) {
if (element.status === TaskStatus.InProgress && element.isCancelable) {
actions.push(this._instantiationService.createInstance(CancelAction, CancelAction.ID, CancelAction.LABEL));
}
// get actions for tasks succeeded
if (element.status === TaskStatus.succeeded || element.status === TaskStatus.succeededWithWarning) {
if (element.status === TaskStatus.Succeeded || element.status === TaskStatus.SucceededWithWarning) {
if (element.taskExecutionMode === TaskExecutionMode.executeAndScript) {
actions.push(this._instantiationService.createInstance(ScriptAction, ScriptAction.ID, ScriptAction.LABEL));
}

View File

@@ -67,27 +67,27 @@ export class TaskHistoryRenderer implements IRenderer {
if (taskNode) {
templateData.icon.className = TaskHistoryRenderer.ICON_CLASS;
switch (taskNode.status) {
case TaskStatus.succeeded:
case TaskStatus.Succeeded:
templateData.icon.classList.add(TaskHistoryRenderer.SUCCESS_CLASS);
taskStatus = localize('succeeded', "succeeded");
break;
case TaskStatus.failed:
case TaskStatus.Failed:
templateData.icon.classList.add(TaskHistoryRenderer.FAIL_CLASS);
taskStatus = localize('failed', "failed");
break;
case TaskStatus.inProgress:
case TaskStatus.InProgress:
templateData.icon.classList.add(TaskHistoryRenderer.INPROGRESS_CLASS);
taskStatus = localize('inProgress', "in progress");
break;
case TaskStatus.notStarted:
case TaskStatus.NotStarted:
templateData.icon.classList.add(TaskHistoryRenderer.NOTSTARTED_CLASS);
taskStatus = localize('notStarted', "not started");
break;
case TaskStatus.canceled:
case TaskStatus.Canceled:
templateData.icon.classList.add(TaskHistoryRenderer.CANCELED_CLASS);
taskStatus = localize('canceled', "canceled");
break;
case TaskStatus.canceling:
case TaskStatus.Canceling:
templateData.icon.classList.add(TaskHistoryRenderer.INPROGRESS_CLASS);
taskStatus = localize('canceling', "canceling");
break;
@@ -117,7 +117,7 @@ export class TaskHistoryRenderer implements IRenderer {
public timer(taskNode: TaskNode, templateData: ITaskHistoryTemplateData) {
let timeLabel = '';
if (taskNode.status === TaskStatus.failed) {
if (taskNode.status === TaskStatus.Failed) {
timeLabel += taskNode.startTime + ' Error: ' + taskNode.message;
} else {
if (taskNode.startTime) {

View File

@@ -141,9 +141,9 @@ export class TaskHistoryView {
let isMouseOrigin = event.payload && (event.payload.origin === 'mouse');
let isDoubleClick = isMouseOrigin && event.payload.originalEvent && event.payload.originalEvent.detail === 2;
if (isDoubleClick) {
if (task.status === TaskStatus.failed) {
if (task.status === TaskStatus.Failed) {
var err = task.taskName + ': ' + task.message;
this._errorMessageService.showDialog(Severity.Error, nls.localize('taskError','Task error'), err);
this._errorMessageService.showDialog(Severity.Error, nls.localize('taskError', 'Task error'), err);
}
}
}

View File

@@ -105,7 +105,7 @@ export class DialogModal extends Modal {
private updateButtonElement(buttonElement: Button, dialogButton: DialogButton, requireDialogValid: boolean = false) {
buttonElement.label = dialogButton.label;
buttonElement.enabled = requireDialogValid ? dialogButton.enabled && this._dialog.valid : dialogButton.enabled;
dialogButton.hidden ? buttonElement.element.classList.add('dialogModal-hidden') : buttonElement.element.classList.remove('dialogModal-hidden');
dialogButton.hidden ? buttonElement.element.parentElement.classList.add('dialogModal-hidden') : buttonElement.element.parentElement.classList.remove('dialogModal-hidden');
}
protected renderBody(container: HTMLElement): void {

View File

@@ -119,7 +119,7 @@ export class WizardModal extends Modal {
private updateButtonElement(buttonElement: Button, dialogButton: DialogButton, requirePageValid: boolean = false) {
buttonElement.label = dialogButton.label;
buttonElement.enabled = requirePageValid ? dialogButton.enabled && this._wizard.pages[this._wizard.currentPage].valid : dialogButton.enabled;
dialogButton.hidden ? buttonElement.element.classList.add('dialogModal-hidden') : buttonElement.element.classList.remove('dialogModal-hidden');
dialogButton.hidden ? buttonElement.element.parentElement.classList.add('dialogModal-hidden') : buttonElement.element.parentElement.classList.remove('dialogModal-hidden');
}
protected renderBody(container: HTMLElement): void {

17
src/sql/sqlops.d.ts vendored
View File

@@ -1531,12 +1531,13 @@ declare module 'sqlops' {
// Task service interfaces ----------------------------------------------------------------------------
export enum TaskStatus {
notStarted = 0,
inProgress = 1,
succeeded = 2,
succeededWithWarning = 3,
failed = 4,
canceled = 5
NotStarted = 0,
InProgress = 1,
Succeeded = 2,
SucceededWithWarning = 3,
Failed = 4,
Canceled = 5,
Canceling = 6
}
export enum TaskExecutionMode {
@@ -1550,6 +1551,7 @@ declare module 'sqlops' {
}
export interface TaskInfo {
connection?: connection.Connection;
taskId: string;
status: TaskStatus;
taskExecutionMode: TaskExecutionMode;
@@ -1573,8 +1575,7 @@ declare module 'sqlops' {
taskId: string;
status: TaskStatus;
message: string;
script: string;
duration: number;
script?: string;
}
export interface TaskServicesProvider extends DataProvider {

View File

@@ -436,6 +436,7 @@ declare module 'sqlops' {
export interface ButtonProperties extends ComponentProperties, ComponentWithIcon {
label?: string;
isFile?: boolean;
}
export interface LoadingComponentProperties {
@@ -711,6 +712,12 @@ declare module 'sqlops' {
* done. Return true to allow the dialog to close or false to block it from closing
*/
registerCloseValidator(validator: () => boolean | Thenable<boolean>): void;
/**
* Register an operation to run in the background when the dialog is done
* @param operationInfo Operation Information
*/
registerOperation(operationInfo: BackgroundOperationInfo): void;
}
export interface DialogTab extends ModelViewPanel {
@@ -894,6 +901,12 @@ declare module 'sqlops' {
* undefined or the text is empty or undefined. The default level is error.
*/
message: DialogMessage
/**
* Register an operation to run in the background when the wizard is done
* @param operationInfo Operation Information
*/
registerOperation(operationInfo: BackgroundOperationInfo): void;
}
}
}
@@ -1000,4 +1013,69 @@ declare module 'sqlops' {
nodeInfo: NodeInfo;
}
/**
* Background Operation
*/
export interface BackgroundOperation {
/**
* Updates the operation status or adds progress message
* @param status Operation Status
* @param message Progress message
*/
updateStatus(status: TaskStatus, message?: string): void;
/**
* Operation Id
*/
id: string;
/**
* Event raised when operation is canceled in UI
*/
onCanceled: vscode.Event<void>;
}
/**
* Operation Information
*/
export interface BackgroundOperationInfo {
/**
* The operation id. A unique id will be assigned to it If not specified a
*/
operationId?: string;
/**
* Connection information
*/
connection: connection.Connection;
/**
* Operation Display Name
*/
displayName: string;
/**
* Operation Description
*/
description: string;
/**
* True if the operation is cancelable
*/
isCancelable: boolean;
/**
* The actual operation to execute
*/
operation: (operation: BackgroundOperation) => void
}
namespace tasks {
/**
* Starts an operation to run in the background
* @param operationInfo Operation Information
*/
export function startBackgroundOperation(operationInfo: BackgroundOperationInfo): void;
}
}

View File

@@ -39,12 +39,13 @@ export enum EditRowState {
}
export enum TaskStatus {
notStarted = 0,
inProgress = 1,
succeeded = 2,
succeededWithWarning = 3,
failed = 4,
canceled = 5
NotStarted = 0,
InProgress = 1,
Succeeded = 2,
SucceededWithWarning = 3,
Failed = 4,
Canceled = 5,
Canceling = 6
}
export enum TaskExecutionMode {
@@ -99,7 +100,7 @@ export enum AlertType {
}
export enum FrequencyTypes {
Unknown ,
Unknown,
OneTime = 1 << 1,
Daily = 1 << 2,
Weekly = 1 << 3,
@@ -275,7 +276,7 @@ export enum DeclarativeDataType {
}
export enum CardType {
VerticalButton = 'VerticalButton',
VerticalButton = 'VerticalButton',
Details = 'Details'
}
export class SqlThemeIcon {

View File

@@ -0,0 +1,113 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { IMainContext } from 'vs/workbench/api/node/extHost.protocol';
import { ExtHostBackgroundTaskManagementShape, SqlMainContext, MainThreadBackgroundTaskManagementShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
import * as sqlops from 'sqlops';
import * as vscode from 'vscode';
import { Emitter } from 'vs/base/common/event';
import { generateUuid } from 'vs/base/common/uuid';
export enum TaskStatus {
NotStarted = 0,
InProgress = 1,
Succeeded = 2,
SucceededWithWarning = 3,
Failed = 4,
Canceled = 5,
Canceling = 6
}
export class ExtBackgroundOperation implements sqlops.BackgroundOperation {
private readonly _proxy: MainThreadBackgroundTaskManagementShape;
private _onCanceled = new Emitter<void>();
constructor(
private _id: string,
mainContext: IMainContext
) {
this._proxy = mainContext.getProxy(SqlMainContext.MainThreadBackgroundTaskManagement);
}
public updateStatus(status: TaskStatus, message?: string): void {
this._proxy.$updateTask({
message: message,
status: status,
taskId: this.id
});
}
public get onCanceled(): vscode.Event<void> {
return this._onCanceled.event;
}
public cancel(): void {
this._onCanceled.fire();
}
public get id(): string {
return this._id;
}
}
export class ExtHostBackgroundTaskManagement implements ExtHostBackgroundTaskManagementShape {
private readonly _proxy: MainThreadBackgroundTaskManagementShape;
private readonly _handlers = new Map<string, sqlops.BackgroundOperationInfo>();
private readonly _operations = new Map<string, ExtBackgroundOperation>();
private readonly _mainContext: IMainContext;
constructor(
mainContext: IMainContext
) {
this._proxy = mainContext.getProxy(SqlMainContext.MainThreadBackgroundTaskManagement);
this._mainContext = mainContext;
}
$onTaskRegistered(operationId: string): void {
let extOperationInfo = new ExtBackgroundOperation(operationId, this._mainContext);
this._operations.set(operationId, extOperationInfo);
let operationInfo = this._handlers.get(operationId);
if (operationInfo) {
operationInfo.operation(extOperationInfo);
}
}
$onTaskCanceled(operationId: string): void {
let operation = this._operations.get(operationId);
if (operation) {
operation.cancel();
}
}
$registerTask(operationInfo: sqlops.BackgroundOperationInfo): void {
let operationId = operationInfo.operationId || `OperationId${generateUuid()}`;
if (this._handlers.has(operationId)) {
throw new Error(`operation '${operationId}' already exists`);
}
this._handlers.set(operationId, operationInfo);
let taskInfo: sqlops.TaskInfo = {
databaseName: undefined,
serverName: undefined,
description: operationInfo.description,
isCancelable: operationInfo.isCancelable,
name: operationInfo.displayName,
providerName: undefined, //setting provider name will cause the task to be processed by the provider. But this task is created in the extension and needs to be handled
//by the extension
taskExecutionMode: 0,
taskId: operationId,
status: TaskStatus.NotStarted,
connection: operationInfo.connection
};
this._proxy.$registerTask(taskInfo);
}
$removeTask(operationId: string) {
if (this._handlers.has(operationId)) {
this._handlers.delete(operationId);
}
}
}

View File

@@ -8,11 +8,12 @@ import { IMainContext } from 'vs/workbench/api/node/extHost.protocol';
import { Event, Emitter } from 'vs/base/common/event';
import { deepClone } from 'vs/base/common/objects';
import * as nls from 'vs/nls';
import { generateUuid } from 'vs/base/common/uuid';
import * as vscode from 'vscode';
import * as sqlops from 'sqlops';
import { SqlMainContext, ExtHostModelViewDialogShape, MainThreadModelViewDialogShape, ExtHostModelViewShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
import { SqlMainContext, ExtHostModelViewDialogShape, MainThreadModelViewDialogShape, ExtHostModelViewShape, ExtHostBackgroundTaskManagementShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
import { IItemConfig, ModelComponentTypes, IComponentShape } from 'sql/workbench/api/common/sqlExtHostTypes';
const DONE_LABEL = nls.localize('dialogDoneLabel', 'Done');
@@ -95,12 +96,22 @@ class DialogImpl extends ModelViewPanelImpl implements sqlops.window.modelviewdi
public customButtons: sqlops.window.modelviewdialog.Button[];
private _message: sqlops.window.modelviewdialog.DialogMessage;
private _closeValidator: () => boolean | Thenable<boolean>;
private _operationHandler: BackgroundOperationHandler;
constructor(extHostModelViewDialog: ExtHostModelViewDialog,
extHostModelView: ExtHostModelViewShape) {
extHostModelView: ExtHostModelViewShape,
extHostTaskManagement: ExtHostBackgroundTaskManagementShape) {
super('modelViewDialog', extHostModelViewDialog, extHostModelView);
this.okButton = this._extHostModelViewDialog.createButton(DONE_LABEL);
this.cancelButton = this._extHostModelViewDialog.createButton(CANCEL_LABEL);
this._operationHandler = new BackgroundOperationHandler('dialog', extHostTaskManagement);
this.okButton.onClick(() => {
this._operationHandler.createOperation();
});
}
public registerOperation(operationInfo: sqlops.BackgroundOperationInfo): void {
this._operationHandler.registerOperation(operationInfo);
}
public setModelViewId(value: string) {
@@ -192,13 +203,40 @@ class ButtonImpl implements sqlops.window.modelviewdialog.Button {
}
}
class BackgroundOperationHandler {
private _operationInfo: sqlops.BackgroundOperationInfo;
constructor(
private _name: string,
private _extHostTaskManagement: ExtHostBackgroundTaskManagementShape) {
}
public createOperation(): void {
if (!this._operationInfo.operationId) {
let uniqueId = generateUuid();
this._operationInfo.operationId = 'OperationId' + uniqueId + this._name;
}
if (this._operationInfo && this._operationInfo.operation) {
this._extHostTaskManagement.$registerTask(this._operationInfo);
}
}
public registerOperation(operationInfo: sqlops.BackgroundOperationInfo): void {
this._operationInfo = operationInfo;
}
}
class WizardPageImpl extends ModelViewPanelImpl implements sqlops.window.modelviewdialog.WizardPage {
public customButtons: sqlops.window.modelviewdialog.Button[];
private _enabled: boolean = true;
private _description: string;
constructor(public title: string, _extHostModelViewDialog: ExtHostModelViewDialog, _extHostModelView: ExtHostModelViewShape) {
super('modelViewWizardPage', _extHostModelViewDialog, _extHostModelView);
constructor(public title: string,
extHostModelViewDialog: ExtHostModelViewDialog,
extHostModelView: ExtHostModelViewShape) {
super('modelViewWizardPage', extHostModelViewDialog, extHostModelView);
}
public get enabled(): boolean {
@@ -253,8 +291,9 @@ class WizardImpl implements sqlops.window.modelviewdialog.Wizard {
private _navigationValidator: (info: sqlops.window.modelviewdialog.WizardPageChangeInfo) => boolean | Thenable<boolean>;
private _message: sqlops.window.modelviewdialog.DialogMessage;
private _displayPageTitles: boolean = true;
private _operationHandler: BackgroundOperationHandler;
constructor(public title: string, private _extHostModelViewDialog: ExtHostModelViewDialog) {
constructor(public title: string, private _extHostModelViewDialog: ExtHostModelViewDialog, extHostTaskManagement: ExtHostBackgroundTaskManagementShape) {
this.doneButton = this._extHostModelViewDialog.createButton(DONE_LABEL);
this.cancelButton = this._extHostModelViewDialog.createButton(CANCEL_LABEL);
this.generateScriptButton = this._extHostModelViewDialog.createButton(GENERATE_SCRIPT_LABEL);
@@ -263,6 +302,14 @@ class WizardImpl implements sqlops.window.modelviewdialog.Wizard {
this._extHostModelViewDialog.registerWizardPageInfoChangedCallback(this, info => this.handlePageInfoChanged(info));
this._currentPage = 0;
this.onPageChanged(info => this._currentPage = info.newPage);
this._operationHandler = new BackgroundOperationHandler('wizard' + this.title, extHostTaskManagement);
this.doneButton.onClick(() => {
this._operationHandler.createOperation();
});
}
public registerOperation(operationInfo: sqlops.BackgroundOperationInfo): void {
this._operationHandler.registerOperation(operationInfo);
}
public get currentPage(): number {
@@ -344,7 +391,8 @@ export class ExtHostModelViewDialog implements ExtHostModelViewDialogShape {
constructor(
mainContext: IMainContext,
private _extHostModelView: ExtHostModelViewShape
private _extHostModelView: ExtHostModelViewShape,
private _extHostTaskManagement: ExtHostBackgroundTaskManagementShape
) {
this._proxy = mainContext.getProxy(SqlMainContext.MainThreadModelViewDialog);
}
@@ -473,7 +521,7 @@ export class ExtHostModelViewDialog implements ExtHostModelViewDialogShape {
}
public createDialog(title: string): sqlops.window.modelviewdialog.Dialog {
let dialog = new DialogImpl(this, this._extHostModelView);
let dialog = new DialogImpl(this, this._extHostModelView, this._extHostTaskManagement);
dialog.title = title;
dialog.handle = this.getHandle(dialog);
return dialog;
@@ -516,7 +564,7 @@ export class ExtHostModelViewDialog implements ExtHostModelViewDialogShape {
}
public createWizard(title: string): sqlops.window.modelviewdialog.Wizard {
let wizard = new WizardImpl(title, this);
let wizard = new WizardImpl(title, this, this._extHostTaskManagement);
this.getHandle(wizard);
return wizard;
}

View File

@@ -0,0 +1,52 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { ITaskService } from 'sql/parts/taskHistory/common/taskService';
import { MainThreadBackgroundTaskManagementShape, SqlMainContext, ExtHostBackgroundTaskManagementShape, SqlExtHostContext } from 'sql/workbench/api/node/sqlExtHost.protocol';
import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
import { IExtHostContext } from 'vs/workbench/api/node/extHost.protocol';
import { Disposable } from 'vs/base/common/lifecycle';
import * as sqlops from 'sqlops';
export enum TaskStatus {
NotStarted = 0,
InProgress = 1,
Succeeded = 2,
SucceededWithWarning = 3,
Failed = 4,
Canceled = 5,
Canceling = 6
}
@extHostNamedCustomer(SqlMainContext.MainThreadBackgroundTaskManagement)
export class MainThreadBackgroundTaskManagement extends Disposable implements MainThreadBackgroundTaskManagementShape {
private readonly _proxy: ExtHostBackgroundTaskManagementShape;
constructor(
context: IExtHostContext,
@ITaskService private _taskService: ITaskService
) {
super();
this._proxy = context.getProxy(SqlExtHostContext.ExtHostBackgroundTaskManagement);
this._register(this._taskService.onTaskComplete(task => {
if (task.status === TaskStatus.Canceling) {
this._proxy.$onTaskCanceled(task.id);
}
}));
}
$registerTask(taskInfo: sqlops.TaskInfo): void {
this._taskService.createNewTask(taskInfo);
this._proxy.$onTaskRegistered(taskInfo.taskId);
}
$updateTask(taskProgressInfo: sqlops.TaskProgressInfo): void {
this._taskService.updateTask(taskProgressInfo);
}
}

View File

@@ -34,6 +34,7 @@ import { ExtHostObjectExplorer } from 'sql/workbench/api/node/extHostObjectExplo
import { ExtHostLogService } from 'vs/workbench/api/node/extHostLogService';
import { ExtHostModelViewDialog } from 'sql/workbench/api/node/extHostModelViewDialog';
import { ExtHostQueryEditor } from 'sql/workbench/api/node/extHostQueryEditor';
import { ExtHostBackgroundTaskManagement } from './extHostBackgroundTaskManagement';
export interface ISqlExtensionApiFactory {
vsCodeFactory(extension: IExtensionDescription): typeof vscode;
@@ -63,10 +64,11 @@ export function createApiFactory(
const extHostResourceProvider = rpcProtocol.set(SqlExtHostContext.ExtHostResourceProvider, new ExtHostResourceProvider(rpcProtocol));
const extHostModalDialogs = rpcProtocol.set(SqlExtHostContext.ExtHostModalDialogs, new ExtHostModalDialogs(rpcProtocol));
const extHostTasks = rpcProtocol.set(SqlExtHostContext.ExtHostTasks, new ExtHostTasks(rpcProtocol, logService));
const extHostBackgroundTaskManagement = rpcProtocol.set(SqlExtHostContext.ExtHostBackgroundTaskManagement, new ExtHostBackgroundTaskManagement(rpcProtocol));
const extHostWebviewWidgets = rpcProtocol.set(SqlExtHostContext.ExtHostDashboardWebviews, new ExtHostDashboardWebviews(rpcProtocol));
const extHostModelView = rpcProtocol.set(SqlExtHostContext.ExtHostModelView, new ExtHostModelView(rpcProtocol));
const extHostDashboard = rpcProtocol.set(SqlExtHostContext.ExtHostDashboard, new ExtHostDashboard(rpcProtocol));
const extHostModelViewDialog = rpcProtocol.set(SqlExtHostContext.ExtHostModelViewDialog, new ExtHostModelViewDialog(rpcProtocol, extHostModelView));
const extHostModelViewDialog = rpcProtocol.set(SqlExtHostContext.ExtHostModelViewDialog, new ExtHostModelViewDialog(rpcProtocol, extHostModelView, extHostBackgroundTaskManagement));
const extHostQueryEditor = rpcProtocol.set(SqlExtHostContext.ExtHostQueryEditor, new ExtHostQueryEditor(rpcProtocol));
@@ -334,6 +336,9 @@ export function createApiFactory(
const tasks: typeof sqlops.tasks = {
registerTask(id: string, task: (...args: any[]) => any, thisArgs?: any): vscode.Disposable {
return extHostTasks.registerTask(id, task, thisArgs);
},
startBackgroundOperation(operationInfo: sqlops.BackgroundOperationInfo): void {
extHostBackgroundTaskManagement.$registerTask(operationInfo);
}
};

View File

@@ -14,6 +14,7 @@ import 'sql/workbench/api/node/mainThreadConnectionManagement';
import 'sql/workbench/api/node/mainThreadCredentialManagement';
import 'sql/workbench/api/node/mainThreadDataProtocol';
import 'sql/workbench/api/node/mainThreadObjectExplorer';
import 'sql/workbench/api/node/mainThreadBackgroundTaskManagement';
import 'sql/workbench/api/node/mainThreadSerializationProvider';
import 'sql/workbench/api/node/mainThreadResourceProvider';
import 'sql/workbench/api/electron-browser/mainThreadTasks';

View File

@@ -496,6 +496,7 @@ export const SqlMainContext = {
MainThreadCredentialManagement: createMainId<MainThreadCredentialManagementShape>('MainThreadCredentialManagement'),
MainThreadDataProtocol: createMainId<MainThreadDataProtocolShape>('MainThreadDataProtocol'),
MainThreadObjectExplorer: createMainId<MainThreadObjectExplorerShape>('MainThreadObjectExplorer'),
MainThreadBackgroundTaskManagement: createMainId<MainThreadBackgroundTaskManagementShape>('MainThreadBackgroundTaskManagement'),
MainThreadSerializationProvider: createMainId<MainThreadSerializationProviderShape>('MainThreadSerializationProvider'),
MainThreadResourceProvider: createMainId<MainThreadResourceProviderShape>('MainThreadResourceProvider'),
MainThreadModalDialog: createMainId<MainThreadModalDialogShape>('MainThreadModalDialog'),
@@ -517,6 +518,7 @@ export const SqlExtHostContext = {
ExtHostResourceProvider: createExtId<ExtHostResourceProviderShape>('ExtHostResourceProvider'),
ExtHostModalDialogs: createExtId<ExtHostModalDialogsShape>('ExtHostModalDialogs'),
ExtHostTasks: createExtId<ExtHostTasksShape>('ExtHostTasks'),
ExtHostBackgroundTaskManagement: createExtId<ExtHostBackgroundTaskManagementShape>('ExtHostBackgroundTaskManagement'),
ExtHostDashboardWebviews: createExtId<ExtHostDashboardWebviewsShape>('ExtHostDashboardWebviews'),
ExtHostModelView: createExtId<ExtHostModelViewShape>('ExtHostModelView'),
ExtHostDashboard: createExtId<ExtHostDashboardShape>('ExtHostDashboard'),
@@ -578,6 +580,18 @@ export interface ExtHostModelViewShape {
$runCustomValidations(handle: number, id: string): Thenable<boolean>;
}
export interface ExtHostBackgroundTaskManagementShape {
$onTaskRegistered(operationId: string): void;
$onTaskCanceled(operationId: string): void;
$registerTask(operationInfo: sqlops.BackgroundOperationInfo): void;
$removeTask(operationId: string): void;
}
export interface MainThreadBackgroundTaskManagementShape extends IDisposable {
$registerTask(taskInfo: sqlops.TaskInfo): void;
$updateTask(taskProgressInfo: sqlops.TaskProgressInfo): void;
}
export interface MainThreadModelViewShape extends IDisposable {
$registerProvider(id: string): void;
$initializeModel(handle: number, rootComponent: IComponentShape): Thenable<void>;

View File

@@ -0,0 +1,107 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as sqlops from 'sqlops';
import * as assert from 'assert';
import { Mock, It, Times } from 'typemoq';
import { ExtHostBackgroundTaskManagement, TaskStatus } from 'sql/workbench/api/node/extHostBackgroundTaskManagement';
import { MainThreadBackgroundTaskManagementShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
import { IMainContext } from 'vs/workbench/api/node/extHost.protocol';
'use strict';
suite('ExtHostBackgroundTaskManagement Tests', () => {
let extHostBackgroundTaskManagement: ExtHostBackgroundTaskManagement;
let mockProxy: Mock<MainThreadBackgroundTaskManagementShape>;
let nothing: void;
let operationId = 'operation is';
setup(() => {
mockProxy = Mock.ofInstance(<MainThreadBackgroundTaskManagementShape>{
$registerTask: (taskInfo: sqlops.TaskInfo) => nothing,
$updateTask: (taskProgressInfo: sqlops.TaskProgressInfo) => nothing
});
let mainContext = <IMainContext>{
getProxy: proxyType => mockProxy.object
};
mockProxy.setup(x => x.$registerTask(It.isAny())).callback(() => {
extHostBackgroundTaskManagement.$onTaskRegistered(operationId);
});
extHostBackgroundTaskManagement = new ExtHostBackgroundTaskManagement(mainContext);
});
test('RegisterTask should successfully create background task and update status', () => {
let operationInfo: sqlops.BackgroundOperationInfo = {
connection: undefined,
description: 'description',
displayName: 'displayName',
isCancelable: true,
operation: (op: sqlops.BackgroundOperation) => { op.updateStatus(TaskStatus.Succeeded); },
operationId: operationId
};
extHostBackgroundTaskManagement.$registerTask(operationInfo);
mockProxy.verify(x => x.$registerTask(It.is(
t => t.name === operationInfo.displayName &&
t.description === operationInfo.description &&
t.taskId === operationId &&
t.isCancelable === operationInfo.isCancelable &&
t.providerName === undefined
)), Times.once());
mockProxy.verify(x => x.$updateTask(It.is(t => t.status === TaskStatus.Succeeded)), Times.once());
extHostBackgroundTaskManagement.$removeTask(operationId);
});
test('Canceling the task should notify the extension', () => {
let operationInfo: sqlops.BackgroundOperationInfo = {
connection: undefined,
description: 'description',
displayName: 'displayName',
isCancelable: true,
operation: (op: sqlops.BackgroundOperation) => {
op.onCanceled(() => {
op.updateStatus(TaskStatus.Canceled);
})
},
operationId: operationId
};
extHostBackgroundTaskManagement.$registerTask(operationInfo);
extHostBackgroundTaskManagement.$onTaskCanceled(operationId);
mockProxy.verify(x => x.$updateTask(It.is(t => t.status === TaskStatus.Canceled)), Times.once());
extHostBackgroundTaskManagement.$removeTask(operationId);
});
test('RegisterTask should assign unique id to the operation is not assigned', () => {
let operationInfo: sqlops.BackgroundOperationInfo = {
connection: undefined,
description: 'description',
displayName: 'displayName',
isCancelable: true,
operation: (op: sqlops.BackgroundOperation) => { op.updateStatus(TaskStatus.Succeeded); },
operationId: undefined
};
extHostBackgroundTaskManagement.$registerTask(operationInfo);
mockProxy.verify(x => x.$registerTask(It.is(t => t.taskId !== undefined)), Times.once());
extHostBackgroundTaskManagement.$removeTask(operationId);
});
test('RegisterTask should fail given id of an existing operation', () => {
let operationInfo: sqlops.BackgroundOperationInfo = {
connection: undefined,
description: 'description',
displayName: 'displayName',
isCancelable: true,
operation: (op: sqlops.BackgroundOperation) => { op.updateStatus(TaskStatus.Succeeded); },
operationId: operationId
};
extHostBackgroundTaskManagement.$registerTask(operationInfo);
mockProxy.verify(x => x.$registerTask(It.is(t => t.taskId === operationId)), Times.once());
assert.throws(() => extHostBackgroundTaskManagement.$registerTask(operationInfo));
extHostBackgroundTaskManagement.$removeTask(operationId);
});
});

View File

@@ -37,7 +37,7 @@ suite('ExtHostModelViewDialog Tests', () => {
extHostModelView = Mock.ofInstance(<ExtHostModelViewShape>{
$registerProvider: (widget, handler) => undefined
});
extHostModelViewDialog = new ExtHostModelViewDialog(mainContext, extHostModelView.object);
extHostModelViewDialog = new ExtHostModelViewDialog(mainContext, extHostModelView.object, undefined);
});
test('Creating a dialog returns a dialog with initialized ok and cancel buttons and the given title', () => {

View File

@@ -0,0 +1,97 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as sqlops from 'sqlops';
import * as assert from 'assert';
import { Mock, It, Times } from 'typemoq';
import { MainThreadBackgroundTaskManagement, TaskStatus } from 'sql/workbench/api/node/mainThreadBackgroundTaskManagement';
import { ExtHostBackgroundTaskManagementShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
import { ITaskService } from 'sql/parts/taskHistory/common/taskService';
import { IExtHostContext } from 'vs/workbench/api/node/extHost.protocol';
import { TaskNode } from 'sql/parts/taskHistory/common/taskNode';
import { Event, Emitter } from 'vs/base/common/event';
'use strict';
suite('MainThreadBackgroundTaskManagement Tests', () => {
let mainThreadBackgroundTaskManagement: MainThreadBackgroundTaskManagement;
let mockProxy: Mock<ExtHostBackgroundTaskManagementShape>;
let taskService: Mock<ITaskService>;
let nothing: void;
let operationId = 'operation is';
let onTaskComplete = new Emitter<TaskNode>();
setup(() => {
mockProxy = Mock.ofInstance(<ExtHostBackgroundTaskManagementShape>{
$onTaskRegistered: (operationId: string) => nothing,
$onTaskCanceled: (operationId: string) => nothing,
$registerTask: (operationInfo: sqlops.BackgroundOperationInfo) => nothing,
$removeTask: (operationId: string) => nothing,
});
taskService = Mock.ofInstance(<ITaskService>{
_serviceBrand: undefined,
onTaskComplete: undefined,
onAddNewTask: undefined,
handleNewTask: undefined,
handleTaskComplete: undefined,
getAllTasks: undefined,
getNumberOfInProgressTasks: undefined,
onNewTaskCreated: undefined,
createNewTask: (taskInfo: sqlops.TaskInfo) => nothing,
updateTask: (taskProgressInfo: sqlops.TaskProgressInfo) => nothing,
onTaskStatusChanged: undefined,
cancelTask: undefined,
registerProvider: undefined
});
let mainContext = <IExtHostContext>{
getProxy: proxyType => mockProxy.object
};
taskService.setup(x => x.onTaskComplete).returns(() => onTaskComplete.event);
mainThreadBackgroundTaskManagement = new MainThreadBackgroundTaskManagement(mainContext, taskService.object);
});
test('RegisterTask should successfully create background task', () => {
let taskInfo: sqlops.TaskInfo = {
taskId: operationId,
databaseName: undefined,
description: undefined,
isCancelable: true,
name: 'task name',
providerName: undefined,
serverName: undefined,
status: TaskStatus.NotStarted,
taskExecutionMode: 0
};
mainThreadBackgroundTaskManagement.$registerTask(taskInfo);
taskService.verify(x => x.createNewTask(It.is(t => t.status === TaskStatus.NotStarted)), Times.once());
mockProxy.verify(x => x.$onTaskRegistered(operationId), Times.once());
});
test('UpdateTask should successfully update the background task status', () => {
let taskInfo: sqlops.TaskProgressInfo = {
taskId: operationId,
status: TaskStatus.InProgress,
message: undefined,
};
mainThreadBackgroundTaskManagement.$updateTask(taskInfo);
taskService.verify(x => x.updateTask(It.is(t => t.status === TaskStatus.InProgress)), Times.once());
});
test('Canceling the task should notify the proxy', () => {
let taskInfo: sqlops.TaskProgressInfo = {
taskId: operationId,
status: TaskStatus.InProgress,
message: undefined,
};
let taskNode = new TaskNode('', '', '', operationId, undefined);
taskNode.status = TaskStatus.Canceling;
onTaskComplete.fire(taskNode);
mainThreadBackgroundTaskManagement.$updateTask(taskInfo);
mockProxy.verify(x => x.$onTaskCanceled(It.is(t => t === operationId)), Times.once());
});
});