Agent: Added loading component to schedule list (#5992)

* added loading component to schedule list

* changed thenable to await

* throw error
This commit is contained in:
Aditya Bist
2019-06-19 12:32:14 -07:00
committed by GitHub
parent 1c706fdfca
commit 639efbcfad
2 changed files with 24 additions and 15 deletions

View File

@@ -20,11 +20,16 @@ export class PickScheduleData implements IAgentDialogData {
this.jobName = jobName; this.jobName = jobName;
} }
public async initialize() { public async initialize(): Promise<azdata.AgentJobScheduleInfo[]> {
let agentService = await AgentUtils.getAgentService(); let agentService = await AgentUtils.getAgentService();
let result = await agentService.getJobSchedules(this.ownerUri); try {
if (result && result.success) { let result = await agentService.getJobSchedules(this.ownerUri);
this.schedules = result.schedules; if (result && result.success) {
this.schedules = result.schedules;
return this.schedules;
}
} catch (error) {
throw error;
} }
} }

View File

@@ -27,6 +27,7 @@ export class PickScheduleDialog {
// UI Components // UI Components
private dialog: azdata.window.Dialog; private dialog: azdata.window.Dialog;
private schedulesTable: azdata.TableComponent; private schedulesTable: azdata.TableComponent;
private loadingComponent: azdata.LoadingComponent;
private model: PickScheduleData; private model: PickScheduleData;
@@ -38,7 +39,17 @@ export class PickScheduleDialog {
} }
public async showDialog() { public async showDialog() {
await this.model.initialize(); this.model.initialize().then((result) => {
this.loadingComponent.loading = false;
if (this.model.schedules) {
let data: any[][] = [];
for (let i = 0; i < this.model.schedules.length; ++i) {
let schedule = this.model.schedules[i];
data[i] = [schedule.id, schedule.name, schedule.description];
}
this.schedulesTable.data = data;
}
});
this.dialog = azdata.window.createModelViewDialog(this.DialogTitle); this.dialog = azdata.window.createModelViewDialog(this.DialogTitle);
this.initializeContent(); this.initializeContent();
this.dialog.okButton.onClick(async () => await this.execute()); this.dialog.okButton.onClick(async () => await this.execute());
@@ -68,16 +79,9 @@ export class PickScheduleDialog {
title: this.SchedulesLabelText title: this.SchedulesLabelText
}]).withLayout({ width: '100%' }).component(); }]).withLayout({ width: '100%' }).component();
await view.initializeModel(formModel); this.loadingComponent = view.modelBuilder.loadingComponent().withItem(formModel).component();
this.loadingComponent.loading = true;
if (this.model.schedules) { await view.initializeModel(this.loadingComponent);
let data: any[][] = [];
for (let i = 0; i < this.model.schedules.length; ++i) {
let schedule = this.model.schedules[i];
data[i] = [schedule.id, schedule.name, schedule.description];
}
this.schedulesTable.data = data;
}
}); });
} }