Files
azuredatastudio/extensions/agent/src/data/pickScheduleData.ts
Aditya Bist 639efbcfad Agent: Added loading component to schedule list (#5992)
* added loading component to schedule list

* changed thenable to await

* throw error
2019-06-19 12:32:14 -07:00

40 lines
1.3 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;
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);
if (result && result.success) {
this.schedules = result.schedules;
return this.schedules;
}
} catch (error) {
throw error;
}
}
public async save() {
this.selectedSchedule.jobName = this.jobName;
}
}