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:
Aditya Bist
2018-10-16 13:24:43 -07:00
committed by GitHub
parent ac1f7542a9
commit 425eecf692
19 changed files with 242 additions and 105 deletions

View File

@@ -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;