mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-15 18:46:36 -05:00
Agent/edit steps (#2846)
* steps can be now edited * edit jobs now works with steps, alerts, schedules etc * fixed bug when new step in new dialog would fail
This commit is contained in:
@@ -235,13 +235,17 @@ export class JobDialog extends AgentDialog<JobData> {
|
||||
width: 80
|
||||
}).component();
|
||||
|
||||
let stepDialog = new JobStepDialog(this.model.ownerUri, '' , data.length + 1, this.model);
|
||||
let stepDialog = new JobStepDialog(this.model.ownerUri, '' , this.model);
|
||||
stepDialog.onSuccess((step) => {
|
||||
if (!this.model.jobSteps) {
|
||||
this.model.jobSteps = [];
|
||||
}
|
||||
this.model.jobSteps.push(step);
|
||||
this.stepsTable.data = this.convertStepsToData(this.model.jobSteps);
|
||||
});
|
||||
this.newStepButton.onDidClick((e)=>{
|
||||
if (this.nameTextBox.value && this.nameTextBox.value.length > 0) {
|
||||
stepDialog.jobName = this.nameTextBox.value;
|
||||
stepDialog.openDialog();
|
||||
} else {
|
||||
this.dialog.message = { text: this.BlankJobNameErrorText };
|
||||
@@ -267,17 +271,15 @@ export class JobDialog extends AgentDialog<JobData> {
|
||||
// one step selection
|
||||
if (this.stepsTable.selectedRows.length === 1) {
|
||||
let rowNumber = this.stepsTable.selectedRows[0];
|
||||
let stepData = steps[rowNumber];
|
||||
let stepData = this.model.jobSteps[rowNumber];
|
||||
this.deleteStepButton.enabled = true;
|
||||
this.editStepButton.enabled = true;
|
||||
this.editStepButton.onDidClick((e) => {
|
||||
// implement edit steps
|
||||
|
||||
// let stepDialog = new JobStepDialog(this.model.ownerUri, this.nameTextBox.value, '' , 1, this.model);
|
||||
// stepDialog.openNewStepDialog();
|
||||
this.editStepButton.onDidClick(() => {
|
||||
let stepDialog = new JobStepDialog(this.model.ownerUri, '' , this.model, stepData);
|
||||
stepDialog.openDialog();
|
||||
});
|
||||
|
||||
this.deleteStepButton.onDidClick((e) => {
|
||||
this.deleteStepButton.onDidClick(() => {
|
||||
AgentUtils.getAgentService().then((agentService) => {
|
||||
let steps = this.model.jobSteps ? this.model.jobSteps : [];
|
||||
agentService.deleteJobStep(this.ownerUri, stepData).then((result) => {
|
||||
|
||||
@@ -10,6 +10,7 @@ import { JobStepData } from '../data/jobStepData';
|
||||
import { AgentUtils } from '../agentUtils';
|
||||
import { JobData } from '../data/jobData';
|
||||
import { AgentDialog } from './agentDialog';
|
||||
import { AgentDialogMode } from '../interfaces';
|
||||
const path = require('path');
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
@@ -19,7 +20,8 @@ export class JobStepDialog extends AgentDialog<JobStepData> {
|
||||
// TODO: localize
|
||||
// Top level
|
||||
//
|
||||
private readonly DialogTitle: string = localize('jobStepDialog.newJobStep', 'New Job Step');
|
||||
private static readonly NewDialogTitle: string = localize('jobStepDialog.newJobStep', 'New Job Step');
|
||||
private static readonly EditDialogTitle: string = localize('jobStepDialog.editJobStep', 'Edit Job Step');
|
||||
private readonly FileBrowserDialogTitle: string = localize('jobStepDialog.fileBrowserTitle', 'Locate Database Files - ');
|
||||
private readonly OkButtonText: string = localize('jobStepDialog.ok', 'OK');
|
||||
private readonly CancelButtonText: string = localize('jobStepDialog.cancel', 'Cancel');
|
||||
@@ -102,24 +104,32 @@ export class JobStepDialog extends AgentDialog<JobStepData> {
|
||||
// Checkbox
|
||||
private appendToExistingFileCheckbox: sqlops.CheckBoxComponent;
|
||||
private logToTableCheckbox: sqlops.CheckBoxComponent;
|
||||
private logStepOutputHistoryCheckbox: sqlops.CheckBoxComponent;
|
||||
|
||||
private fileBrowserTree: sqlops.FileBrowserTreeComponent;
|
||||
private jobModel: JobData;
|
||||
private jobName: string;
|
||||
public jobName: string;
|
||||
private server: string;
|
||||
private stepId: number;
|
||||
private isEdit: boolean;
|
||||
|
||||
constructor(
|
||||
ownerUri: string,
|
||||
server: string,
|
||||
stepId: number,
|
||||
jobModel?: JobData
|
||||
jobModel: JobData,
|
||||
jobStepInfo?: sqlops.AgentJobStepInfo,
|
||||
) {
|
||||
super(ownerUri, new JobStepData(ownerUri, jobModel), 'New Step');
|
||||
this.stepId = stepId;
|
||||
this.jobName = jobModel.name;
|
||||
this.server = server;
|
||||
super(ownerUri,
|
||||
jobStepInfo ? JobStepData.convertToJobStepData(jobStepInfo, jobModel) : new JobStepData(ownerUri, jobModel),
|
||||
jobStepInfo ? JobStepDialog.EditDialogTitle : JobStepDialog.NewDialogTitle);
|
||||
this.stepId = jobStepInfo ?
|
||||
jobStepInfo.id : jobModel.jobSteps ?
|
||||
jobModel.jobSteps.length + 1 : 1;
|
||||
this.isEdit = jobStepInfo ? true : false;
|
||||
this.model.dialogMode = this.isEdit ? AgentDialogMode.EDIT : AgentDialogMode.CREATE;
|
||||
this.jobModel = jobModel;
|
||||
this.jobName = this.jobName ? this.jobName : this.jobModel.name;
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
private initializeUIComponents() {
|
||||
@@ -254,6 +264,14 @@ export class JobStepDialog extends AgentDialog<JobStepData> {
|
||||
let formWrapper = view.modelBuilder.loadingComponent().withItem(formModel).component();
|
||||
formWrapper.loading = false;
|
||||
await view.initializeModel(formWrapper);
|
||||
|
||||
// Load values for edit scenario
|
||||
if (this.isEdit) {
|
||||
this.nameTextBox.value = this.model.stepName;
|
||||
this.typeDropdown.value = this.model.subSystem;
|
||||
this.databaseDropdown.value = this.model.databaseName;
|
||||
this.commandTextBox.value = this.model.command;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -290,7 +308,7 @@ export class JobStepDialog extends AgentDialog<JobStepData> {
|
||||
let logToTableContainer = view.modelBuilder.flexContainer()
|
||||
.withLayout({ flexFlow: 'row', justifyContent: 'space-between', width: 300 })
|
||||
.withItems([this.logToTableCheckbox]).component();
|
||||
let logStepOutputHistoryCheckbox = view.modelBuilder.checkBox()
|
||||
this.logStepOutputHistoryCheckbox = view.modelBuilder.checkBox()
|
||||
.withProperties({ label: this.IncludeStepOutputHistoryLabel }).component();
|
||||
this.userInputBox = view.modelBuilder.inputBox()
|
||||
.withProperties({ inputType: 'text', width: '100%' }).component();
|
||||
@@ -315,7 +333,7 @@ export class JobStepDialog extends AgentDialog<JobStepData> {
|
||||
component: appendCheckboxContainer,
|
||||
title: ' '
|
||||
}, {
|
||||
component: logStepOutputHistoryCheckbox,
|
||||
component: this.logStepOutputHistoryCheckbox,
|
||||
title: ''
|
||||
}, {
|
||||
component: this.userInputBox,
|
||||
@@ -326,7 +344,19 @@ export class JobStepDialog extends AgentDialog<JobStepData> {
|
||||
|
||||
let formWrapper = view.modelBuilder.loadingComponent().withItem(formModel).component();
|
||||
formWrapper.loading = false;
|
||||
view.initializeModel(formWrapper);
|
||||
await view.initializeModel(formWrapper);
|
||||
|
||||
if (this.isEdit) {
|
||||
this.successActionDropdown.value = this.model.successAction;
|
||||
this.retryAttemptsBox.value = this.model.retryAttempts.toString();
|
||||
this.retryIntervalBox.value = this.model.retryInterval.toString();
|
||||
this.failureActionDropdown.value = this.model.failureAction;
|
||||
this.outputFileNameBox.value = this.model.outputFileName;
|
||||
this.appendToExistingFileCheckbox.checked = this.model.appendToLogFile;
|
||||
this.logToTableCheckbox.checked = this.model.appendLogToTable;
|
||||
this.logStepOutputHistoryCheckbox.checked = this.model.appendToStepHist;
|
||||
this.userInputBox.value = this.model.databaseUserName;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -479,7 +509,6 @@ export class JobStepDialog extends AgentDialog<JobStepData> {
|
||||
this.model.jobName = this.jobName;
|
||||
this.model.id = this.stepId;
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user