Files
azuredatastudio/extensions/agent/src/data/pickScheduleData.ts
Amir Omidi 462b5d1d53 Fixes bug when opening the scheduler dialog (#6624)
Checks if the loading component is loaded before using it
2019-08-14 10:51:06 -07:00

46 lines
1.4 KiB
TypeScript

/*---------------------------------------------------------------------------------------------
* 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 azdata from 'azdata';
import { AgentUtils } from '../agentUtils';
import { IAgentDialogData, AgentDialogMode } from '../interfaces';
export class PickScheduleData implements IAgentDialogData {
public dialogMode: AgentDialogMode = AgentDialogMode.VIEW;
public ownerUri: string;
public schedules: azdata.AgentJobScheduleInfo[];
public selectedSchedule: azdata.AgentJobScheduleInfo;
private jobName: string;
private initialized: boolean;
constructor(ownerUri: string, jobName: string) {
this.ownerUri = ownerUri;
this.jobName = jobName;
}
public async initialize(): Promise<azdata.AgentJobScheduleInfo[]> {
let agentService = await AgentUtils.getAgentService();
try {
let result = await agentService.getJobSchedules(this.ownerUri);
this.initialized = true;
if (result && result.success) {
this.schedules = result.schedules;
return this.schedules;
}
} catch (error) {
throw error;
}
}
public async save() {
this.selectedSchedule.jobName = this.jobName;
}
public isInitialized() {
return this.initialized;
}
}