mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Jobs - New step (WIP) (#1711)
* added jobs view toolbar * create job command and dialog stub * add tab content and wire up the provider * fix the steps tab error * create job dialog 6/15 changes * general tab done * success action and retries completed * added failure action dropdown * add notification tab checkbox events * added AgentJobStepInfo objects in sqlops * create job dialog - 0618 update 1 * added model save function * width for controls and initial state for notification tab controls * refresh master and changes to work with latest code * fixed next and prev button positions * new step dialog ui finished * implemented parse button * fix package file * add validation and sub-items collections * hook up the step creation dialog - step 1 * merged master
This commit is contained in:
47
extensions/agent/client/src/agentUtils.ts
Normal file
47
extensions/agent/client/src/agentUtils.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
'use strict';
|
||||
|
||||
import * as sqlops from 'sqlops';
|
||||
|
||||
export class AgentUtils {
|
||||
|
||||
private static _agentService: sqlops.AgentServicesProvider;
|
||||
private static _connectionService: sqlops.ConnectionProvider;
|
||||
private static _fileBrowserService: sqlops.FileBrowserProvider;
|
||||
private static _queryProvider: sqlops.QueryProvider;
|
||||
|
||||
public static async getAgentService(): Promise<sqlops.AgentServicesProvider> {
|
||||
if (!AgentUtils._agentService) {
|
||||
let currentConnection = await sqlops.connection.getCurrentConnection();
|
||||
this._agentService = sqlops.dataprotocol.getProvider<sqlops.AgentServicesProvider>(currentConnection.providerName, sqlops.DataProviderType.AgentServicesProvider);
|
||||
}
|
||||
return AgentUtils._agentService;
|
||||
}
|
||||
|
||||
public static async getDatabases(ownerUri: string): Promise<string[]> {
|
||||
if (!AgentUtils._connectionService) {
|
||||
let currentConnection = await sqlops.connection.getCurrentConnection();
|
||||
this._connectionService = sqlops.dataprotocol.getProvider<sqlops.ConnectionProvider>(currentConnection.providerName, sqlops.DataProviderType.ConnectionProvider);
|
||||
}
|
||||
return AgentUtils._connectionService.listDatabases(ownerUri).then(result => {
|
||||
if (result && result.databaseNames && result.databaseNames.length > 0) {
|
||||
return result.databaseNames;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static async getFileBrowserService(ownerUri: string): Promise<sqlops.FileBrowserProvider> {
|
||||
if (!AgentUtils._fileBrowserService) {
|
||||
let currentConnection = await sqlops.connection.getCurrentConnection();
|
||||
this._fileBrowserService = sqlops.dataprotocol.getProvider<sqlops.FileBrowserProvider>(currentConnection.providerName, sqlops.DataProviderType.FileBrowserProvider);
|
||||
}
|
||||
return this._fileBrowserService;
|
||||
}
|
||||
|
||||
public static async getQueryProvider(ownerUri: string): Promise<sqlops.QueryProvider> {
|
||||
if (!AgentUtils._queryProvider) {
|
||||
let currentConnection = await sqlops.connection.getCurrentConnection();
|
||||
this._queryProvider = sqlops.dataprotocol.getProvider<sqlops.QueryProvider>(currentConnection.providerName, sqlops.DataProviderType.QueryProvider);
|
||||
}
|
||||
return this._queryProvider;
|
||||
}
|
||||
}
|
||||
147
extensions/agent/client/src/data/createJobData.ts
Normal file
147
extensions/agent/client/src/data/createJobData.ts
Normal file
@@ -0,0 +1,147 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 * as sqlops from 'sqlops';
|
||||
import { AgentUtils } from '../agentUtils';
|
||||
import { runInThisContext } from 'vm';
|
||||
|
||||
export class CreateJobData {
|
||||
|
||||
private readonly JobCompletionActionCondition_Always: string = 'When the job completes';
|
||||
private readonly JobCompletionActionCondition_OnFailure: string = 'When the job fails';
|
||||
private readonly JobCompletionActionCondition_OnSuccess: string = 'When the job succeeds';
|
||||
|
||||
// Error Messages
|
||||
private readonly CreateJobErrorMessage_NameIsEmpty = 'Job name must be provided';
|
||||
|
||||
private _ownerUri: string;
|
||||
private _jobCategories: string[];
|
||||
private _operators: string[];
|
||||
private _agentService: sqlops.AgentServicesProvider;
|
||||
private _defaultOwner: string;
|
||||
private _jobCompletionActionConditions: sqlops.CategoryValue[];
|
||||
|
||||
public name: string;
|
||||
public enabled: boolean = true;
|
||||
public description: string;
|
||||
public category: string;
|
||||
public categoryId: number;
|
||||
public owner: string;
|
||||
public emailLevel: sqlops.JobCompletionActionCondition = sqlops.JobCompletionActionCondition.OnFailure;
|
||||
public pageLevel: sqlops.JobCompletionActionCondition = sqlops.JobCompletionActionCondition.OnFailure;
|
||||
public eventLogLevel: sqlops.JobCompletionActionCondition = sqlops.JobCompletionActionCondition.OnFailure;
|
||||
public deleteLevel: sqlops.JobCompletionActionCondition = sqlops.JobCompletionActionCondition.OnSuccess;
|
||||
public operatorToEmail: string;
|
||||
public operatorToPage: string;
|
||||
public jobSteps: sqlops.AgentJobStepInfo[];
|
||||
public jobSchedules: sqlops.AgentJobScheduleInfo[];
|
||||
public alerts: sqlops.AgentAlertInfo[];
|
||||
|
||||
constructor(ownerUri: string) {
|
||||
this._ownerUri = ownerUri;
|
||||
}
|
||||
|
||||
public get jobCategories(): string[] {
|
||||
return this._jobCategories;
|
||||
}
|
||||
|
||||
public get operators(): string[] {
|
||||
return this._operators;
|
||||
}
|
||||
|
||||
public get ownerUri(): string {
|
||||
return this._ownerUri;
|
||||
}
|
||||
|
||||
public get defaultOwner(): string {
|
||||
return this._defaultOwner;
|
||||
}
|
||||
|
||||
public get JobCompletionActionConditions(): sqlops.CategoryValue[] {
|
||||
return this._jobCompletionActionConditions;
|
||||
}
|
||||
|
||||
public async initialize() {
|
||||
this._agentService = await AgentUtils.getAgentService();
|
||||
|
||||
// TODO: fetch real data using agent service
|
||||
//
|
||||
|
||||
this._jobCategories = [
|
||||
'[Uncategorized (Local)]',
|
||||
'Jobs from MSX'
|
||||
];
|
||||
|
||||
// await this._agentService.getOperators(this.ownerUri).then(result => {
|
||||
// this._operators = result.operators.map(o => o.name);
|
||||
// });
|
||||
|
||||
this._operators = ['', 'alanren'];
|
||||
this._defaultOwner = 'REDMOND\\alanren';
|
||||
|
||||
this._jobCompletionActionConditions = [{
|
||||
displayName: this.JobCompletionActionCondition_OnSuccess,
|
||||
name: sqlops.JobCompletionActionCondition.OnSuccess.toString()
|
||||
}, {
|
||||
displayName: this.JobCompletionActionCondition_OnFailure,
|
||||
name: sqlops.JobCompletionActionCondition.OnFailure.toString()
|
||||
}, {
|
||||
displayName: this.JobCompletionActionCondition_Always,
|
||||
name: sqlops.JobCompletionActionCondition.Always.toString()
|
||||
}];
|
||||
}
|
||||
|
||||
public async save() {
|
||||
await this._agentService.createJob(this.ownerUri, {
|
||||
name: this.name,
|
||||
owner: this.owner,
|
||||
description: this.description,
|
||||
EmailLevel: this.emailLevel,
|
||||
PageLevel: this.pageLevel,
|
||||
EventLogLevel: this.eventLogLevel,
|
||||
DeleteLevel: this.deleteLevel,
|
||||
OperatorToEmail: this.operatorToEmail,
|
||||
OperatorToPage: this.operatorToPage,
|
||||
enabled: this.enabled,
|
||||
category: this.category,
|
||||
Alerts: this.alerts,
|
||||
JobSchedules: this.jobSchedules,
|
||||
JobSteps: this.jobSteps,
|
||||
// The properties below are not collected from UI
|
||||
// We could consider using a seperate class for create job request
|
||||
//
|
||||
currentExecutionStatus: 0,
|
||||
lastRunOutcome: 0,
|
||||
currentExecutionStep: '',
|
||||
hasTarget: true,
|
||||
hasSchedule: false,
|
||||
hasStep: false,
|
||||
runnable: true,
|
||||
categoryId: 0,
|
||||
categoryType: 1, // LocalJob, hard-coding the value, corresponds to the target tab in SSMS
|
||||
lastRun: '',
|
||||
nextRun: '',
|
||||
jobId: ''
|
||||
}).then(result => {
|
||||
if (!result.success) {
|
||||
console.info(result.errorMessage);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public validate(): { valid: boolean, errorMessages: string[] } {
|
||||
let validationErrors: string[] = [];
|
||||
|
||||
if (!(this.name && this.name.trim())) {
|
||||
validationErrors.push(this.CreateJobErrorMessage_NameIsEmpty);
|
||||
}
|
||||
|
||||
return {
|
||||
valid: validationErrors.length > 0,
|
||||
errorMessages: validationErrors
|
||||
}
|
||||
}
|
||||
}
|
||||
71
extensions/agent/client/src/data/createStepData.ts
Normal file
71
extensions/agent/client/src/data/createStepData.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 { AgentUtils } from '../agentUtils';
|
||||
|
||||
export class CreateStepData {
|
||||
public ownerUri: string;
|
||||
public jobId: string; //
|
||||
public jobName: string;
|
||||
public script: string; //
|
||||
public scriptName: string;
|
||||
public stepName: string; //
|
||||
public subSystem: string; //
|
||||
public id: number;
|
||||
public failureAction: string; //
|
||||
public successAction: string; //
|
||||
public failStepId: number;
|
||||
public successStepId: number;
|
||||
public command: string;
|
||||
public commandExecutionSuccessCode: number;
|
||||
public databaseName: string; //
|
||||
public databaseUserName: string;
|
||||
public server: string;
|
||||
public outputFileName: string; //
|
||||
public appendToLogFile: boolean;
|
||||
public appendToStepHist: boolean;
|
||||
public writeLogToTable: boolean;
|
||||
public appendLogToTable: boolean;
|
||||
public retryAttempts: number; //
|
||||
public retryInterval: number; //
|
||||
public proxyName: string;
|
||||
|
||||
constructor(ownerUri:string) {
|
||||
this.ownerUri = ownerUri;
|
||||
}
|
||||
|
||||
public async save() {
|
||||
let agentService = await AgentUtils.getAgentService();
|
||||
agentService.createJobStep(this.ownerUri, {
|
||||
jobId: this.jobId,
|
||||
jobName: this.jobName,
|
||||
script: this.script,
|
||||
scriptName: this.scriptName,
|
||||
stepName: this.stepName,
|
||||
subSystem: this.subSystem,
|
||||
id: this.id,
|
||||
failureAction: this.failureAction,
|
||||
successAction: this.successAction,
|
||||
failStepId: this.failStepId,
|
||||
successStepId: this.successStepId,
|
||||
command: this.command,
|
||||
commandExecutionSuccessCode: this.commandExecutionSuccessCode,
|
||||
databaseName: this.databaseName,
|
||||
databaseUserName: this.databaseUserName,
|
||||
server: this.server,
|
||||
outputFileName: this.outputFileName,
|
||||
appendToLogFile: this.appendToLogFile,
|
||||
appendToStepHist: this.appendToStepHist,
|
||||
writeLogToTable: this.writeLogToTable,
|
||||
appendLogToTable: this.appendLogToTable,
|
||||
retryAttempts: this.retryAttempts,
|
||||
retryInterval: this.retryInterval,
|
||||
proxyName: this.proxyName
|
||||
}).then(result => {
|
||||
console.info(result);
|
||||
});
|
||||
}
|
||||
}
|
||||
370
extensions/agent/client/src/dialogs/createJobDialog.ts
Normal file
370
extensions/agent/client/src/dialogs/createJobDialog.ts
Normal file
@@ -0,0 +1,370 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 * as sqlops from 'sqlops';
|
||||
import { CreateJobData } from '../data/createJobData';
|
||||
import { CreateStepDialog } from './createStepDialog';
|
||||
|
||||
export class CreateJobDialog {
|
||||
|
||||
// TODO: localize
|
||||
// Top level
|
||||
//
|
||||
private readonly DialogTitle: string = 'New Job';
|
||||
private readonly OkButtonText: string = 'Ok';
|
||||
private readonly CancelButtonText: string = 'Cancel';
|
||||
private readonly GeneralTabText: string = 'General';
|
||||
private readonly StepsTabText: string = 'Steps';
|
||||
private readonly SchedulesTabText: string = 'Schedules';
|
||||
private readonly AlertsTabText: string = 'Alerts';
|
||||
private readonly NotificationsTabText: string = 'Notifications';
|
||||
|
||||
// General tab strings
|
||||
//
|
||||
private readonly NameTextBoxLabel: string = 'Name';
|
||||
private readonly OwnerTextBoxLabel: string = 'Owner';
|
||||
private readonly CategoryDropdownLabel: string = 'Category';
|
||||
private readonly DescriptionTextBoxLabel: string = 'Description';
|
||||
private readonly EnabledCheckboxLabel: string = 'Enabled';
|
||||
|
||||
// Steps tab strings
|
||||
private readonly JobStepsTopLabelString: string = 'Job step list';
|
||||
private readonly StepsTable_StepColumnString: string = 'Step';
|
||||
private readonly StepsTable_NameColumnString: string = 'Name';
|
||||
private readonly StepsTable_TypeColumnString: string = 'Type';
|
||||
private readonly StepsTable_SuccessColumnString: string = 'On Success';
|
||||
private readonly StepsTable_FailureColumnString: string = 'On Failure';
|
||||
private readonly NewStepButtonString: string = 'New...';
|
||||
private readonly InsertStepButtonString: string = 'Insert...';
|
||||
private readonly EditStepButtonString: string = 'Edit';
|
||||
private readonly DeleteStepButtonString: string = 'Delete';
|
||||
|
||||
// Notifications tab strings
|
||||
//
|
||||
private readonly NotificationsTabTopLabelString: string = 'Actions to perform when the job completes';
|
||||
private readonly EmailCheckBoxString: string = 'Email';
|
||||
private readonly PagerCheckBoxString: string = 'Page';
|
||||
private readonly EventLogCheckBoxString: string = 'Write to the Windows Application event log';
|
||||
private readonly DeleteJobCheckBoxString: string = 'Automatically delete job';
|
||||
|
||||
// UI Components
|
||||
//
|
||||
private dialog: sqlops.window.modelviewdialog.Dialog;
|
||||
private generalTab: sqlops.window.modelviewdialog.DialogTab;
|
||||
private stepsTab: sqlops.window.modelviewdialog.DialogTab;
|
||||
private alertsTab: sqlops.window.modelviewdialog.DialogTab;
|
||||
private schedulesTab: sqlops.window.modelviewdialog.DialogTab;
|
||||
private notificationsTab: sqlops.window.modelviewdialog.DialogTab;
|
||||
|
||||
// General tab controls
|
||||
//
|
||||
private nameTextBox: sqlops.InputBoxComponent;
|
||||
private ownerTextBox: sqlops.InputBoxComponent;
|
||||
private categoryDropdown: sqlops.DropDownComponent;
|
||||
private descriptionTextBox: sqlops.InputBoxComponent;
|
||||
private enabledCheckBox: sqlops.CheckBoxComponent;
|
||||
|
||||
// Steps tab controls
|
||||
private stepsTable: sqlops.TableComponent;
|
||||
private newStepButton: sqlops.ButtonComponent;
|
||||
private insertStepButton: sqlops.ButtonComponent;
|
||||
private editStepButton: sqlops.ButtonComponent;
|
||||
private deleteStepButton: sqlops.ButtonComponent;
|
||||
|
||||
// Notifications tab controls
|
||||
//
|
||||
private notificationsTabTopLabel: sqlops.TextComponent;
|
||||
private emailCheckBox: sqlops.CheckBoxComponent;
|
||||
private emailOperatorDropdown: sqlops.DropDownComponent;
|
||||
private emailConditionDropdown: sqlops.DropDownComponent;
|
||||
private pagerCheckBox: sqlops.CheckBoxComponent;
|
||||
private pagerOperatorDropdown: sqlops.DropDownComponent;
|
||||
private pagerConditionDropdown: sqlops.DropDownComponent;
|
||||
private eventLogCheckBox: sqlops.CheckBoxComponent;
|
||||
private eventLogConditionDropdown: sqlops.DropDownComponent;
|
||||
private deleteJobCheckBox: sqlops.CheckBoxComponent;
|
||||
private deleteJobConditionDropdown: sqlops.DropDownComponent;
|
||||
|
||||
private model: CreateJobData;
|
||||
|
||||
constructor(ownerUri: string) {
|
||||
this.model = new CreateJobData(ownerUri);
|
||||
}
|
||||
|
||||
public async showDialog() {
|
||||
await this.model.initialize();
|
||||
this.dialog = sqlops.window.modelviewdialog.createDialog(this.DialogTitle);
|
||||
this.generalTab = sqlops.window.modelviewdialog.createTab(this.GeneralTabText);
|
||||
this.stepsTab = sqlops.window.modelviewdialog.createTab(this.StepsTabText);
|
||||
this.alertsTab = sqlops.window.modelviewdialog.createTab(this.AlertsTabText);
|
||||
this.schedulesTab = sqlops.window.modelviewdialog.createTab(this.SchedulesTabText);
|
||||
this.notificationsTab = sqlops.window.modelviewdialog.createTab(this.NotificationsTabText);
|
||||
this.initializeGeneralTab();
|
||||
this.initializeStepsTab();
|
||||
this.initializeAlertsTab();
|
||||
this.initializeSchedulesTab();
|
||||
this.initializeNotificationsTab();
|
||||
this.dialog.content = [this.generalTab, this.stepsTab, this.schedulesTab, this.alertsTab, this.notificationsTab];
|
||||
this.dialog.okButton.onClick(async () => await this.execute());
|
||||
this.dialog.cancelButton.onClick(async () => await this.cancel());
|
||||
this.dialog.okButton.label = this.OkButtonText;
|
||||
this.dialog.cancelButton.label = this.CancelButtonText;
|
||||
|
||||
this.dialog.registerCloseValidator(() => {
|
||||
this.updateModel();
|
||||
let validationResult = this.model.validate();
|
||||
if (!validationResult.valid) {
|
||||
// TODO: Show Error Messages
|
||||
console.error(validationResult.errorMessages.join(','));
|
||||
}
|
||||
|
||||
return validationResult.valid;
|
||||
});
|
||||
|
||||
sqlops.window.modelviewdialog.openDialog(this.dialog);
|
||||
}
|
||||
|
||||
private initializeGeneralTab() {
|
||||
this.generalTab.registerContent(async view => {
|
||||
this.nameTextBox = view.modelBuilder.inputBox().component();
|
||||
this.ownerTextBox = view.modelBuilder.inputBox().component();
|
||||
this.categoryDropdown = view.modelBuilder.dropDown().component();
|
||||
this.descriptionTextBox = view.modelBuilder.inputBox().withProperties({
|
||||
multiline: true,
|
||||
height: 200
|
||||
}).component();
|
||||
this.enabledCheckBox = view.modelBuilder.checkBox()
|
||||
.withProperties({
|
||||
label: this.EnabledCheckboxLabel
|
||||
}).component();
|
||||
let formModel = view.modelBuilder.formContainer()
|
||||
.withFormItems([{
|
||||
component: this.nameTextBox,
|
||||
title: this.NameTextBoxLabel
|
||||
}, {
|
||||
component: this.ownerTextBox,
|
||||
title: this.OwnerTextBoxLabel
|
||||
}, {
|
||||
component: this.categoryDropdown,
|
||||
title: this.CategoryDropdownLabel
|
||||
}, {
|
||||
component: this.descriptionTextBox,
|
||||
title: this.DescriptionTextBoxLabel
|
||||
}, {
|
||||
component: this.enabledCheckBox,
|
||||
title: ''
|
||||
}]).withLayout({ width: '100%' }).component();
|
||||
|
||||
await view.initializeModel(formModel);
|
||||
|
||||
this.ownerTextBox.value = this.model.defaultOwner;
|
||||
this.categoryDropdown.values = this.model.jobCategories;
|
||||
this.categoryDropdown.value = this.model.jobCategories[0];
|
||||
this.enabledCheckBox.checked = this.model.enabled;
|
||||
this.descriptionTextBox.value = '';
|
||||
});
|
||||
}
|
||||
|
||||
private initializeStepsTab() {
|
||||
this.stepsTab.registerContent(async view => {
|
||||
this.stepsTable = view.modelBuilder.table()
|
||||
.withProperties({
|
||||
columns: [
|
||||
this.StepsTable_StepColumnString,
|
||||
this.StepsTable_NameColumnString,
|
||||
this.StepsTable_TypeColumnString,
|
||||
this.StepsTable_SuccessColumnString,
|
||||
this.StepsTable_FailureColumnString
|
||||
],
|
||||
data: [],
|
||||
height: 800
|
||||
}).component();
|
||||
|
||||
this.newStepButton = view.modelBuilder.button().withProperties({
|
||||
label: this.NewStepButtonString,
|
||||
width: 80
|
||||
}).component();
|
||||
|
||||
this.newStepButton.onDidClick((e)=>{
|
||||
let stepDialog =new CreateStepDialog(this.model.ownerUri, '', '', this.model);
|
||||
stepDialog.openNewStepDialog();
|
||||
});
|
||||
|
||||
this.insertStepButton = view.modelBuilder.button().withProperties({
|
||||
label: this.InsertStepButtonString,
|
||||
width: 80
|
||||
}).component();
|
||||
|
||||
this.editStepButton = view.modelBuilder.button().withProperties({
|
||||
label: this.EditStepButtonString,
|
||||
width: 80
|
||||
}).component();
|
||||
|
||||
this.deleteStepButton = view.modelBuilder.button().withProperties({
|
||||
label: this.DeleteStepButtonString,
|
||||
width: 80
|
||||
}).component();
|
||||
|
||||
let formModel = view.modelBuilder.formContainer()
|
||||
.withFormItems([{
|
||||
component: this.stepsTable,
|
||||
title: this.JobStepsTopLabelString,
|
||||
actions: [this.newStepButton, this.insertStepButton, this.editStepButton, this.deleteStepButton]
|
||||
}]).withLayout({ width: '100%' }).component();
|
||||
await view.initializeModel(formModel);
|
||||
});
|
||||
}
|
||||
|
||||
private initializeAlertsTab() {
|
||||
}
|
||||
|
||||
private initializeSchedulesTab() {
|
||||
}
|
||||
|
||||
private initializeNotificationsTab() {
|
||||
this.notificationsTab.registerContent(async view => {
|
||||
|
||||
this.notificationsTabTopLabel = view.modelBuilder.text().withProperties({ value: this.NotificationsTabTopLabelString }).component();
|
||||
this.emailCheckBox = view.modelBuilder.checkBox().withProperties({
|
||||
label: this.EmailCheckBoxString,
|
||||
width: 80
|
||||
}).component();
|
||||
|
||||
this.pagerCheckBox = view.modelBuilder.checkBox().withProperties({
|
||||
label: this.PagerCheckBoxString,
|
||||
width: 80
|
||||
}).component();
|
||||
this.eventLogCheckBox = view.modelBuilder.checkBox().withProperties({
|
||||
label: this.EventLogCheckBoxString,
|
||||
width: 250
|
||||
}).component();
|
||||
this.deleteJobCheckBox = view.modelBuilder.checkBox().withProperties({
|
||||
label: this.DeleteJobCheckBoxString,
|
||||
width: 250
|
||||
}).component();
|
||||
|
||||
this.emailCheckBox.onChanged(() => {
|
||||
this.emailConditionDropdown.enabled = this.emailCheckBox.checked;
|
||||
this.emailOperatorDropdown.enabled = this.emailCheckBox.checked;
|
||||
});
|
||||
|
||||
this.pagerCheckBox.onChanged(() => {
|
||||
this.pagerConditionDropdown.enabled = this.pagerCheckBox.checked;
|
||||
this.pagerOperatorDropdown.enabled = this.pagerCheckBox.checked;
|
||||
});
|
||||
this.eventLogCheckBox.onChanged(() => {
|
||||
this.eventLogConditionDropdown.enabled = this.eventLogCheckBox.checked;
|
||||
});
|
||||
|
||||
this.deleteJobCheckBox.onChanged(() => {
|
||||
this.deleteJobConditionDropdown.enabled = this.deleteJobCheckBox.checked;
|
||||
});
|
||||
|
||||
this.emailOperatorDropdown = view.modelBuilder.dropDown().withProperties({ width: 150 }).component();
|
||||
this.pagerOperatorDropdown = view.modelBuilder.dropDown().withProperties({ width: 150 }).component();
|
||||
this.emailConditionDropdown = view.modelBuilder.dropDown().withProperties({ width: 150 }).component();
|
||||
this.pagerConditionDropdown = view.modelBuilder.dropDown().withProperties({ width: 150 }).component();
|
||||
this.eventLogConditionDropdown = view.modelBuilder.dropDown().withProperties({ width: 150 }).component();
|
||||
this.deleteJobConditionDropdown = view.modelBuilder.dropDown().withProperties({ width: 150 }).component();
|
||||
|
||||
let emailContainer = this.createRowContainer(view).withItems([this.emailCheckBox, this.emailOperatorDropdown, this.emailConditionDropdown]).component();
|
||||
|
||||
let pagerContainer = this.createRowContainer(view).withItems([this.pagerCheckBox, this.pagerOperatorDropdown, this.pagerConditionDropdown]).component();
|
||||
|
||||
let eventLogContainer = this.createRowContainer(view).withItems([this.eventLogCheckBox, this.eventLogConditionDropdown]).component();
|
||||
|
||||
let deleteJobContainer = this.createRowContainer(view).withItems([this.deleteJobCheckBox, this.deleteJobConditionDropdown]).component();
|
||||
|
||||
let formModel = view.modelBuilder.formContainer().withFormItems([
|
||||
{
|
||||
component: this.notificationsTabTopLabel,
|
||||
title: ''
|
||||
}, {
|
||||
component: emailContainer,
|
||||
title: ''
|
||||
}, {
|
||||
component: pagerContainer,
|
||||
title: ''
|
||||
}, {
|
||||
component: eventLogContainer,
|
||||
title: ''
|
||||
}, {
|
||||
component: deleteJobContainer,
|
||||
title: ''
|
||||
}]).withLayout({ width: '100%' }).component();
|
||||
|
||||
await view.initializeModel(formModel);
|
||||
this.emailConditionDropdown.values = this.model.JobCompletionActionConditions;
|
||||
this.pagerConditionDropdown.values = this.model.JobCompletionActionConditions;
|
||||
this.eventLogConditionDropdown.values = this.model.JobCompletionActionConditions;
|
||||
this.deleteJobConditionDropdown.values = this.model.JobCompletionActionConditions;
|
||||
this.setConditionDropdownSelectedValue(this.emailConditionDropdown, this.model.emailLevel);
|
||||
this.setConditionDropdownSelectedValue(this.pagerConditionDropdown, this.model.pageLevel);
|
||||
this.setConditionDropdownSelectedValue(this.eventLogConditionDropdown, this.model.eventLogLevel);
|
||||
this.setConditionDropdownSelectedValue(this.deleteJobConditionDropdown, this.model.deleteLevel);
|
||||
this.emailOperatorDropdown.values = this.model.operators;
|
||||
this.pagerOperatorDropdown.values = this.model.operators;
|
||||
this.emailCheckBox.checked = false;
|
||||
this.pagerCheckBox.checked = false;
|
||||
this.eventLogCheckBox.checked = false;
|
||||
this.deleteJobCheckBox.checked = false;
|
||||
this.emailOperatorDropdown.enabled = false;
|
||||
this.pagerOperatorDropdown.enabled = false;
|
||||
this.emailConditionDropdown.enabled = false;
|
||||
this.pagerConditionDropdown.enabled = false;
|
||||
this.eventLogConditionDropdown.enabled = false;
|
||||
this.deleteJobConditionDropdown.enabled = false;
|
||||
});
|
||||
}
|
||||
|
||||
private createRowContainer(view: sqlops.ModelView): sqlops.FlexBuilder {
|
||||
return view.modelBuilder.flexContainer().withLayout({
|
||||
flexFlow: 'row',
|
||||
alignItems: 'left',
|
||||
justifyContent: 'space-between'
|
||||
});
|
||||
}
|
||||
|
||||
private async execute() {
|
||||
this.updateModel();
|
||||
await this.model.save();
|
||||
}
|
||||
|
||||
private async cancel() {
|
||||
|
||||
}
|
||||
|
||||
private getActualConditionValue(checkbox: sqlops.CheckBoxComponent, dropdown: sqlops.DropDownComponent): sqlops.JobCompletionActionCondition {
|
||||
return checkbox.checked ? Number(this.getDropdownValue(dropdown)) : sqlops.JobCompletionActionCondition.Never;
|
||||
}
|
||||
|
||||
private getDropdownValue(dropdown: sqlops.DropDownComponent): string {
|
||||
return (typeof dropdown.value === 'string') ? dropdown.value : dropdown.value.name;
|
||||
}
|
||||
|
||||
private setConditionDropdownSelectedValue(dropdown: sqlops.DropDownComponent, selectedValue: number) {
|
||||
let idx: number = 0;
|
||||
for (idx = 0; idx < dropdown.values.length; idx++) {
|
||||
if (Number((<sqlops.CategoryValue>dropdown.values[idx]).name) === selectedValue) {
|
||||
dropdown.value = dropdown.values[idx];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private updateModel() {
|
||||
this.model.name = this.nameTextBox.value;
|
||||
this.model.owner = this.ownerTextBox.value;
|
||||
this.model.enabled = this.enabledCheckBox.checked;
|
||||
this.model.description = this.descriptionTextBox.value;
|
||||
this.model.category = this.getDropdownValue(this.categoryDropdown);
|
||||
this.model.emailLevel = this.getActualConditionValue(this.emailCheckBox, this.emailConditionDropdown);
|
||||
this.model.operatorToEmail = this.getDropdownValue(this.emailOperatorDropdown);
|
||||
this.model.operatorToPage = this.getDropdownValue(this.pagerOperatorDropdown);
|
||||
this.model.pageLevel = this.getActualConditionValue(this.pagerCheckBox, this.pagerConditionDropdown);
|
||||
this.model.eventLogLevel = this.getActualConditionValue(this.eventLogCheckBox, this.eventLogConditionDropdown);
|
||||
this.model.deleteLevel = this.getActualConditionValue(this.deleteJobCheckBox, this.deleteJobConditionDropdown);
|
||||
}
|
||||
}
|
||||
444
extensions/agent/client/src/dialogs/createStepDialog.ts
Normal file
444
extensions/agent/client/src/dialogs/createStepDialog.ts
Normal file
@@ -0,0 +1,444 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 * as sqlops from 'sqlops';
|
||||
import * as vscode from 'vscode';
|
||||
import { CreateStepData } from '../data/createStepData';
|
||||
import { AgentUtils } from '../agentUtils';
|
||||
import { CreateJobData } from '../data/createJobData';
|
||||
|
||||
export class CreateStepDialog {
|
||||
|
||||
// TODO: localize
|
||||
// Top level
|
||||
//
|
||||
private static readonly DialogTitle: string = 'New Job Step';
|
||||
private static readonly OkButtonText: string = 'OK';
|
||||
private static readonly CancelButtonText: string = 'Cancel';
|
||||
private static readonly GeneralTabText: string = 'General';
|
||||
private static readonly AdvancedTabText: string = 'Advanced';
|
||||
private static readonly OpenCommandText: string = 'Open...';
|
||||
private static readonly ParseCommandText: string = 'Parse';
|
||||
private static readonly NextButtonText: string = 'Next';
|
||||
private static readonly PreviousButtonText: string = 'Previous';
|
||||
private static readonly SuccessAction: string = 'On success action';
|
||||
private static readonly FailureAction: string = 'On failure action';
|
||||
|
||||
|
||||
// Dropdown options
|
||||
private static readonly TSQLScript: string = 'Transact-SQL script (T-SQL)';
|
||||
private static readonly AgentServiceAccount: string = 'SQL Server Agent Service Account';
|
||||
private static readonly NextStep: string = 'Go to the next step';
|
||||
private static readonly QuitJobReportingSuccess: string = 'Quit the job reporting success';
|
||||
private static readonly QuitJobReportingFailure: string = 'Quit the job reporting failure';
|
||||
|
||||
// UI Components
|
||||
//
|
||||
private dialog: sqlops.window.modelviewdialog.Dialog;
|
||||
private generalTab: sqlops.window.modelviewdialog.DialogTab;
|
||||
private advancedTab: sqlops.window.modelviewdialog.DialogTab;
|
||||
private nameTextBox: sqlops.InputBoxComponent;
|
||||
private typeDropdown: sqlops.DropDownComponent;
|
||||
private runAsDropdown: sqlops.DropDownComponent;
|
||||
private databaseDropdown: sqlops.DropDownComponent;
|
||||
private successActionDropdown: sqlops.DropDownComponent;
|
||||
private failureActionDropdown: sqlops.DropDownComponent;
|
||||
private commandTextBox: sqlops.InputBoxComponent;
|
||||
private openButton: sqlops.ButtonComponent;
|
||||
private parseButton: sqlops.ButtonComponent;
|
||||
private nextButton: sqlops.ButtonComponent;
|
||||
private previousButton: sqlops.ButtonComponent;
|
||||
private retryAttemptsBox: sqlops.InputBoxComponent;
|
||||
private retryIntervalBox: sqlops.InputBoxComponent;
|
||||
private appendToExistingFileCheckbox: sqlops.CheckBoxComponent;
|
||||
private logToTableCheckbox: sqlops.CheckBoxComponent;
|
||||
private outputFileNameBox: sqlops.InputBoxComponent;
|
||||
private outputFileBrowserButton: sqlops.ButtonComponent;
|
||||
|
||||
private model: CreateStepData;
|
||||
private ownerUri: string;
|
||||
private jobId: string;
|
||||
private server: string;
|
||||
|
||||
private jobModel: CreateJobData;
|
||||
|
||||
constructor(
|
||||
ownerUri: string,
|
||||
jobId: string,
|
||||
server: string,
|
||||
jobModel?: CreateJobData
|
||||
) {
|
||||
this.model = new CreateStepData(ownerUri);
|
||||
this.ownerUri = ownerUri;
|
||||
this.jobId = jobId;
|
||||
this.server = server;
|
||||
this.jobModel = jobModel;
|
||||
}
|
||||
|
||||
private initializeUIComponents() {
|
||||
this.dialog = sqlops.window.modelviewdialog.createDialog(CreateStepDialog.DialogTitle);
|
||||
this.generalTab = sqlops.window.modelviewdialog.createTab(CreateStepDialog.GeneralTabText);
|
||||
this.advancedTab = sqlops.window.modelviewdialog.createTab(CreateStepDialog.AdvancedTabText);
|
||||
this.dialog.content = [this.generalTab, this.advancedTab];
|
||||
this.dialog.okButton.label = CreateStepDialog.OkButtonText;
|
||||
this.dialog.okButton.onClick(() => this.execute());
|
||||
this.dialog.cancelButton.label = CreateStepDialog.CancelButtonText;
|
||||
}
|
||||
|
||||
private createCommands(view, queryProvider: sqlops.QueryProvider) {
|
||||
this.openButton = view.modelBuilder.button()
|
||||
.withProperties({
|
||||
label: CreateStepDialog.OpenCommandText,
|
||||
width: '80px'
|
||||
}).component();
|
||||
this.parseButton = view.modelBuilder.button()
|
||||
.withProperties({
|
||||
label: CreateStepDialog.ParseCommandText,
|
||||
width: '80px'
|
||||
}).component();
|
||||
this.parseButton.onDidClick(e => {
|
||||
if (this.commandTextBox.value) {
|
||||
queryProvider.parseSyntax(this.ownerUri, this.commandTextBox.value).then(result => {
|
||||
if (result && result.parseable) {
|
||||
this.dialog.message = { text: 'The command was successfully parsed.', level: 2};
|
||||
} else if (result && !result.parseable) {
|
||||
this.dialog.message = { text: 'The command failed' };
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
this.commandTextBox = view.modelBuilder.inputBox()
|
||||
.withProperties({
|
||||
height: 300,
|
||||
width: 400,
|
||||
multiline: true,
|
||||
inputType: 'text'
|
||||
})
|
||||
.component();
|
||||
this.nextButton = view.modelBuilder.button()
|
||||
.withProperties({
|
||||
label: CreateStepDialog.NextButtonText,
|
||||
enabled: false,
|
||||
width: '80px'
|
||||
}).component();
|
||||
this.previousButton = view.modelBuilder.button()
|
||||
.withProperties({
|
||||
label: CreateStepDialog.PreviousButtonText,
|
||||
enabled: false,
|
||||
width: '80px'
|
||||
}).component();
|
||||
}
|
||||
|
||||
private createGeneralTab(databases: string[], queryProvider: sqlops.QueryProvider) {
|
||||
this.generalTab.registerContent(async (view) => {
|
||||
this.nameTextBox = view.modelBuilder.inputBox()
|
||||
.withProperties({
|
||||
}).component();
|
||||
this.typeDropdown = view.modelBuilder.dropDown()
|
||||
.withProperties({
|
||||
value: CreateStepDialog.TSQLScript,
|
||||
values: [CreateStepDialog.TSQLScript]
|
||||
})
|
||||
.component();
|
||||
this.runAsDropdown = view.modelBuilder.dropDown()
|
||||
.withProperties({
|
||||
value: '',
|
||||
values: ['']
|
||||
})
|
||||
.component();
|
||||
this.runAsDropdown.enabled = false;
|
||||
this.typeDropdown.onValueChanged((type) => {
|
||||
if (type.selected !== CreateStepDialog.TSQLScript) {
|
||||
this.runAsDropdown.value = CreateStepDialog.AgentServiceAccount;
|
||||
this.runAsDropdown.values = [this.runAsDropdown.value];
|
||||
} else {
|
||||
this.runAsDropdown.value = '';
|
||||
this.runAsDropdown.values = [''];
|
||||
}
|
||||
});
|
||||
this.databaseDropdown = view.modelBuilder.dropDown()
|
||||
.withProperties({
|
||||
value: databases[0],
|
||||
values: databases
|
||||
}).component();
|
||||
|
||||
// create the commands section
|
||||
this.createCommands(view, queryProvider);
|
||||
|
||||
let buttonContainer = view.modelBuilder.flexContainer()
|
||||
.withLayout({
|
||||
flexFlow: 'row',
|
||||
justifyContent: 'space-between',
|
||||
width: 420
|
||||
}).withItems([this.openButton, this.parseButton, this.previousButton, this.nextButton], {
|
||||
flex: '1 1 50%'
|
||||
}).component();
|
||||
|
||||
let formModel = view.modelBuilder.formContainer()
|
||||
.withFormItems([{
|
||||
component: this.nameTextBox,
|
||||
title: 'Step name'
|
||||
}, {
|
||||
component: this.typeDropdown,
|
||||
title: 'Type'
|
||||
}, {
|
||||
component: this.runAsDropdown,
|
||||
title: 'Run as'
|
||||
}, {
|
||||
component: this.databaseDropdown,
|
||||
title: 'Database'
|
||||
}, {
|
||||
component: this.commandTextBox,
|
||||
title: 'Command',
|
||||
actions: [buttonContainer]
|
||||
}], {
|
||||
horizontal: false,
|
||||
componentWidth: 420
|
||||
}).component();
|
||||
let formWrapper = view.modelBuilder.loadingComponent().withItem(formModel).component();
|
||||
formWrapper.loading = false;
|
||||
await view.initializeModel(formWrapper);
|
||||
});
|
||||
}
|
||||
|
||||
private createRunAsUserOptions(view) {
|
||||
let userInputBox = view.modelBuilder.inputBox()
|
||||
.withProperties({ inputType: 'text', width: '100px' }).component();
|
||||
let viewButton = view.modelBuilder.button()
|
||||
.withProperties({ label: '...', width: '20px' }).component();
|
||||
let viewButtonContainer = view.modelBuilder.flexContainer()
|
||||
.withLayout({ width: 100, textAlign: 'right' })
|
||||
.withItems([viewButton], { flex: '1 1 50%' }).component();
|
||||
let userInputBoxContainer = view.modelBuilder.flexContainer()
|
||||
.withLayout({ width: 200, textAlign: 'left' })
|
||||
.withItems([userInputBox], { flex: '1 1 50%' }).component();
|
||||
let runAsUserContainer = view.modelBuilder.flexContainer()
|
||||
.withLayout({ width: 200 })
|
||||
.withItems([userInputBoxContainer, viewButtonContainer], { flex: '1 1 50%' })
|
||||
.component();
|
||||
let runAsUserForm = view.modelBuilder.formContainer()
|
||||
.withFormItems([{
|
||||
component: runAsUserContainer,
|
||||
title: 'Run as user'
|
||||
}], { horizontal: true, componentWidth: 200 }).component();
|
||||
return runAsUserForm;
|
||||
}
|
||||
|
||||
private createAdvancedTab(fileBrowserService: sqlops.FileBrowserProvider) {
|
||||
this.advancedTab.registerContent(async (view) => {
|
||||
this.successActionDropdown = view.modelBuilder.dropDown()
|
||||
.withProperties({
|
||||
value: CreateStepDialog.NextStep,
|
||||
values: [CreateStepDialog.NextStep, CreateStepDialog.QuitJobReportingSuccess, CreateStepDialog.QuitJobReportingFailure]
|
||||
})
|
||||
.component();
|
||||
let retryFlexContainer = this.createRetryCounters(view);
|
||||
this.failureActionDropdown = view.modelBuilder.dropDown()
|
||||
.withProperties({
|
||||
value: CreateStepDialog.QuitJobReportingFailure,
|
||||
values: [CreateStepDialog.QuitJobReportingFailure, CreateStepDialog.NextStep, CreateStepDialog.QuitJobReportingSuccess]
|
||||
})
|
||||
.component();
|
||||
let optionsGroup = this.createTSQLOptions(view, fileBrowserService);
|
||||
let viewButton = view.modelBuilder.button()
|
||||
.withProperties({ label: 'View', width: '50px' }).component();
|
||||
viewButton.enabled = false;
|
||||
this.logToTableCheckbox = view.modelBuilder.checkBox()
|
||||
.withProperties({
|
||||
label: 'Log to table'
|
||||
}).component();
|
||||
let appendToExistingEntryInTableCheckbox = view.modelBuilder.checkBox()
|
||||
.withProperties({ label: 'Append output to existing entry in table' }).component();
|
||||
appendToExistingEntryInTableCheckbox.enabled = false;
|
||||
this.logToTableCheckbox.onChanged(e => {
|
||||
viewButton.enabled = e;
|
||||
appendToExistingEntryInTableCheckbox.enabled = e;
|
||||
});
|
||||
let appendCheckboxContainer = view.modelBuilder.groupContainer()
|
||||
.withItems([appendToExistingEntryInTableCheckbox]).component();
|
||||
let logToTableContainer = view.modelBuilder.flexContainer()
|
||||
.withLayout({ flexFlow: 'row', justifyContent: 'space-between', width: 300 })
|
||||
.withItems([this.logToTableCheckbox, viewButton]).component();
|
||||
let logStepOutputHistoryCheckbox = view.modelBuilder.checkBox()
|
||||
.withProperties({ label: 'Include step output in history' }).component();
|
||||
let runAsUserOptions = this.createRunAsUserOptions(view);
|
||||
let formModel = view.modelBuilder.formContainer()
|
||||
.withFormItems(
|
||||
[{
|
||||
component: this.successActionDropdown,
|
||||
title: CreateStepDialog.SuccessAction
|
||||
}, {
|
||||
component: retryFlexContainer,
|
||||
title: ''
|
||||
}, {
|
||||
component: this.failureActionDropdown,
|
||||
title: CreateStepDialog.FailureAction
|
||||
}, {
|
||||
component: optionsGroup,
|
||||
title: 'Transact-SQL script (T-SQL)'
|
||||
}, {
|
||||
component: logToTableContainer,
|
||||
title: ''
|
||||
}, {
|
||||
component: appendCheckboxContainer,
|
||||
title: ' '
|
||||
}, {
|
||||
component: logStepOutputHistoryCheckbox,
|
||||
title: ''
|
||||
}, {
|
||||
component: runAsUserOptions,
|
||||
title: ''
|
||||
}], {
|
||||
componentWidth: 400
|
||||
}).component();
|
||||
|
||||
let formWrapper = view.modelBuilder.loadingComponent().withItem(formModel).component();
|
||||
formWrapper.loading = false;
|
||||
view.initializeModel(formWrapper);
|
||||
});
|
||||
}
|
||||
|
||||
private createRetryCounters(view) {
|
||||
this.retryAttemptsBox = view.modelBuilder.inputBox()
|
||||
.withValidation(component => component.value >= 0)
|
||||
.withProperties({
|
||||
inputType: 'number'
|
||||
})
|
||||
.component();
|
||||
this.retryIntervalBox = view.modelBuilder.inputBox()
|
||||
.withValidation(component => component.value >= 0)
|
||||
.withProperties({
|
||||
inputType: 'number'
|
||||
}).component();
|
||||
|
||||
let retryAttemptsContainer = view.modelBuilder.formContainer()
|
||||
.withFormItems(
|
||||
[{
|
||||
component: this.retryAttemptsBox,
|
||||
title: 'Retry Attempts'
|
||||
}], {
|
||||
horizontal: false
|
||||
})
|
||||
.component();
|
||||
|
||||
let retryIntervalContainer = view.modelBuilder.formContainer()
|
||||
.withFormItems(
|
||||
[{
|
||||
component: this.retryIntervalBox,
|
||||
title: 'Retry Interval (minutes)'
|
||||
}], {
|
||||
horizontal: false
|
||||
})
|
||||
.component();
|
||||
|
||||
let retryFlexContainer = view.modelBuilder.flexContainer()
|
||||
.withLayout({
|
||||
flexFlow: 'row',
|
||||
}).withItems([retryAttemptsContainer, retryIntervalContainer]).component();
|
||||
return retryFlexContainer;
|
||||
}
|
||||
|
||||
private createTSQLOptions(view, fileBrowserService: sqlops.FileBrowserProvider) {
|
||||
this.outputFileBrowserButton = view.modelBuilder.button()
|
||||
.withProperties({ width: '20px', label: '...' }).component();
|
||||
this.outputFileBrowserButton.onDidClick(() => {
|
||||
fileBrowserService.openFileBrowser(this.ownerUri,
|
||||
'C:\\Program Files\\Microsoft SQL Server\\MSSQL14.MSSQLSERVER\\MSSQL\\Backup',
|
||||
['*'], false).then(result => {
|
||||
if (result) {
|
||||
console.log(result);
|
||||
Promise.resolve(result);
|
||||
} else {
|
||||
Promise.reject(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
this.outputFileNameBox = view.modelBuilder.inputBox()
|
||||
.withProperties({
|
||||
width: '100px',
|
||||
inputType: 'text'
|
||||
}).component();
|
||||
let outputViewButton = view.modelBuilder.button()
|
||||
.withProperties({
|
||||
width: '50px',
|
||||
label: 'View'
|
||||
}).component();
|
||||
outputViewButton.enabled = false;
|
||||
let outputButtonContainer = view.modelBuilder.flexContainer()
|
||||
.withLayout({
|
||||
flexFlow: 'row',
|
||||
textAlign: 'right',
|
||||
width: 120
|
||||
}).withItems([this.outputFileBrowserButton, outputViewButton], { flex: '1 1 50%' }).component();
|
||||
let outputFlexBox = view.modelBuilder.flexContainer()
|
||||
.withLayout({
|
||||
flexFlow: 'row',
|
||||
width: 350
|
||||
}).withItems([this.outputFileNameBox, outputButtonContainer], {
|
||||
flex: '1 1 50%'
|
||||
}).component();
|
||||
this.appendToExistingFileCheckbox = view.modelBuilder.checkBox()
|
||||
.withProperties({
|
||||
label: 'Append output to existing file'
|
||||
}).component();
|
||||
this.appendToExistingFileCheckbox.enabled = false;
|
||||
this.outputFileNameBox.onTextChanged((input) => {
|
||||
if (input !== '') {
|
||||
this.appendToExistingFileCheckbox.enabled = true;
|
||||
} else {
|
||||
this.appendToExistingFileCheckbox.enabled = false;
|
||||
}
|
||||
});
|
||||
let outputFileForm = view.modelBuilder.formContainer()
|
||||
.withFormItems([{
|
||||
component: outputFlexBox,
|
||||
title: 'Output file'
|
||||
}, {
|
||||
component: this.appendToExistingFileCheckbox,
|
||||
title: ''
|
||||
}], { horizontal: true, componentWidth: 200 }).component();
|
||||
return outputFileForm;
|
||||
}
|
||||
|
||||
private async execute() {
|
||||
this.model.jobId = this.jobId;
|
||||
this.model.server = this.server;
|
||||
this.model.stepName = this.nameTextBox.value;
|
||||
this.model.subSystem = this.typeDropdown.value as string;
|
||||
this.model.databaseName = this.databaseDropdown.value as string;
|
||||
this.model.script = this.commandTextBox.value;
|
||||
this.model.successAction = this.successActionDropdown.value as string;
|
||||
this.model.retryAttempts = +this.retryAttemptsBox.value;
|
||||
this.model.retryInterval = +this.retryIntervalBox.value;
|
||||
this.model.failureAction = this.failureActionDropdown.value as string;
|
||||
this.model.outputFileName = this.outputFileNameBox.value;
|
||||
await this.model.save();
|
||||
}
|
||||
|
||||
private openFileBrowserDialog(rootNode, selectedNode) {
|
||||
}
|
||||
|
||||
private onFileBrowserOpened(handle: number, fileBrowserOpenedParams: sqlops.FileBrowserOpenedParams) {
|
||||
if (fileBrowserOpenedParams.succeeded === true
|
||||
&& fileBrowserOpenedParams.fileTree
|
||||
&& fileBrowserOpenedParams.fileTree.rootNode
|
||||
&& fileBrowserOpenedParams.fileTree.selectedNode) {
|
||||
this.openFileBrowserDialog(fileBrowserOpenedParams.fileTree.rootNode, fileBrowserOpenedParams.fileTree.selectedNode);
|
||||
}
|
||||
}
|
||||
|
||||
public async openNewStepDialog() {
|
||||
let databases = await AgentUtils.getDatabases(this.ownerUri);
|
||||
let fileBrowserService = await AgentUtils.getFileBrowserService(this.ownerUri);
|
||||
let queryProvider = await AgentUtils.getQueryProvider(this.ownerUri);
|
||||
fileBrowserService.registerOnFileBrowserOpened((response: sqlops.FileBrowserOpenedParams) => {
|
||||
this.onFileBrowserOpened(fileBrowserService.handle, response);
|
||||
});
|
||||
this.initializeUIComponents();
|
||||
this.createGeneralTab(databases, queryProvider);
|
||||
this.createAdvancedTab(fileBrowserService);
|
||||
sqlops.window.modelviewdialog.openDialog(this.dialog);
|
||||
}
|
||||
}
|
||||
@@ -3,15 +3,15 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as data from 'sqlops';
|
||||
import { ApiWrapper } from './apiWrapper';
|
||||
import { CreateJobDialog } from './dialogs/createJobDialog';
|
||||
import { CreateStepDialog } from './dialogs/createStepDialog';
|
||||
|
||||
/**
|
||||
* The main controller class that initializes the extension
|
||||
*/
|
||||
export class MainController {
|
||||
export class MainController {
|
||||
protected _apiWrapper: ApiWrapper;
|
||||
protected _context: vscode.ExtensionContext;
|
||||
|
||||
@@ -30,9 +30,21 @@ export class MainController {
|
||||
}
|
||||
|
||||
public activate(): void {
|
||||
|
||||
this._apiWrapper.registerWebviewProvider('data-management-agent', webview => {
|
||||
webview.html = '<div><h1>SQL Agent</h1></div>';
|
||||
});
|
||||
}
|
||||
|
||||
vscode.commands.registerCommand('agent.openCreateJobDialog', (ownerUri: string) => {
|
||||
let dialog = new CreateJobDialog(ownerUri);
|
||||
dialog.showDialog();
|
||||
});
|
||||
vscode.commands.registerCommand('agent.openNewStepDialog', (ownerUri: string, jobId: string, server: string) => {
|
||||
let dialog = new CreateStepDialog(ownerUri, jobId, server);
|
||||
dialog.openNewStepDialog();
|
||||
});
|
||||
}
|
||||
|
||||
private updateJobStepDialog() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
1
extensions/agent/client/src/typings/ref.d.ts
vendored
1
extensions/agent/client/src/typings/ref.d.ts
vendored
@@ -5,4 +5,5 @@
|
||||
|
||||
/// <reference path='../../../../../src/vs/vscode.d.ts'/>
|
||||
/// <reference path='../../../../../src/sql/sqlops.d.ts'/>
|
||||
/// <reference path='../../../../../src/sql/sqlops.proposed.d.ts'/>
|
||||
/// <reference types='@types/node'/>
|
||||
Reference in New Issue
Block a user