schedules now get added in edit job (#2915)

This commit is contained in:
Aditya Bist
2018-10-16 22:51:54 -07:00
committed by GitHub
parent 67514ccc5f
commit 7ba14a3925
6 changed files with 23 additions and 17 deletions

View File

@@ -136,8 +136,13 @@ export class JobData implements IAgentDialogData {
}
public addJobSchedule(schedule: sqlops.AgentJobScheduleInfo) {
let existingSchedule = this.jobSchedules.find(item => item.name === schedule.name);
if (!existingSchedule) {
if (this.jobSchedules) {
let existingSchedule = this.jobSchedules.find(item => item.name === schedule.name);
if (!existingSchedule) {
this.jobSchedules.push(schedule);
}
} else {
this.jobSchedules = [];
this.jobSchedules.push(schedule);
}
}

View File

@@ -13,9 +13,11 @@ export class PickScheduleData implements IAgentDialogData {
public ownerUri: string;
public schedules: sqlops.AgentJobScheduleInfo[];
public selectedSchedule: sqlops.AgentJobScheduleInfo;
private jobName: string;
constructor(ownerUri:string) {
constructor(ownerUri:string, jobName: string) {
this.ownerUri = ownerUri;
this.jobName = jobName;
}
public async initialize() {
@@ -27,5 +29,8 @@ export class PickScheduleData implements IAgentDialogData {
}
public async save() {
let agentService = await AgentUtils.getAgentService();
this.selectedSchedule.jobName = this.jobName;
let result = await agentService.createJobSchedule(this.ownerUri, this.selectedSchedule);
}
}

View File

@@ -108,12 +108,14 @@ export class JobDialog extends AgentDialog<JobData> {
// Alert tab controls
private alertsTable: sqlops.TableComponent;
private newAlertButton: sqlops.ButtonComponent;
private isEdit: boolean = false;
constructor(ownerUri: string, jobInfo: sqlops.AgentJobInfo = undefined) {
super(
ownerUri,
new JobData(ownerUri, jobInfo),
jobInfo ? JobDialog.EditDialogTitle : JobDialog.CreateDialogTitle);
this.isEdit = jobInfo ? true : false;
}
protected async initializeDialog() {
@@ -373,12 +375,12 @@ export class JobDialog extends AgentDialog<JobData> {
label: this.PickScheduleButtonString,
width: 80
}).component();
this.pickScheduleButton.onDidClick((e)=>{
let pickScheduleDialog = new PickScheduleDialog(this.model.ownerUri);
let pickScheduleDialog = new PickScheduleDialog(this.model.ownerUri, this.model.name);
pickScheduleDialog.onSuccess((dialogModel) => {
let selectedSchedule = dialogModel.selectedSchedule;
if (selectedSchedule) {
selectedSchedule.jobName = this.model.name;
this.model.addJobSchedule(selectedSchedule);
this.populateScheduleTable();
}

View File

@@ -33,8 +33,8 @@ export class PickScheduleDialog {
private _onSuccess: vscode.EventEmitter<PickScheduleData> = new vscode.EventEmitter<PickScheduleData>();
public readonly onSuccess: vscode.Event<PickScheduleData> = this._onSuccess.event;
constructor(ownerUri: string) {
this.model = new PickScheduleData(ownerUri);
constructor(ownerUri: string, jobName: string) {
this.model = new PickScheduleData(ownerUri, jobName);
}
public async showDialog() {

View File

@@ -41,12 +41,12 @@ export class MainController {
let dialog = new JobDialog(ownerUri, jobInfo);
dialog.openDialog();
});
vscode.commands.registerCommand('agent.openNewStepDialog', (ownerUri: string, server: string, jobData: JobData) => {
let dialog = new JobStepDialog(ownerUri, server, jobData);
vscode.commands.registerCommand('agent.openNewStepDialog', (ownerUri: string, server: string, jobData: JobData, jobStepInfo: sqlops.AgentJobStepInfo) => {
let dialog = new JobStepDialog(ownerUri, server, jobData, jobStepInfo);
dialog.openDialog();
});
vscode.commands.registerCommand('agent.openPickScheduleDialog', (ownerUri: string) => {
let dialog = new PickScheduleDialog(ownerUri);
vscode.commands.registerCommand('agent.openPickScheduleDialog', (ownerUri: string, jobName: string) => {
let dialog = new PickScheduleDialog(ownerUri, jobName);
dialog.showDialog();
});
vscode.commands.registerCommand('agent.openAlertDialog', (ownerUri: string, alertInfo: sqlops.AgentAlertInfo, jobs: string[]) => {