Skip to content

Commit

Permalink
update missing export for no data (#385)
Browse files Browse the repository at this point in the history
Signed-off-by: David <daveclaveau@gmail.com>
  • Loading branch information
davidclaveau authored Oct 4, 2024
1 parent 997157e commit e1f7849
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
29 changes: 22 additions & 7 deletions src/app/export-reports/export-reports.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class ExportReportsComponent implements OnDestroy {
STANDBY: 0,
GENERATING: 1,
READY_TO_DOWNLOAD: 2,
NO_DATA: 3,
RETRYING: 98,
ERROR: 99,
};
Expand Down Expand Up @@ -174,6 +175,11 @@ export class ExportReportsComponent implements OnDestroy {
this.setExportMessage(res);
}
this.status = res.error.msg;
} else if (res?.jobObj?.progressState === 'no_data') {
this.setState(this.stateDictionary.NO_DATA);
this.percentageComplete = res?.jobObj?.progressPercentage;
this.status = res?.jobObj?.progressDescription;
this.setExportMessage(res);
} else {
if (this.currentState !== 0) {
if (res?.jobObj?.progressState === 'complete') {
Expand Down Expand Up @@ -264,6 +270,14 @@ export class ExportReportsComponent implements OnDestroy {
this.currentState = 2;
this.progressBarColour = 'success';
break;
case 3:
this.animated = false;
this.progressBarTextOverride = undefined;
this.disableGenerate = false;
this.disableDownload = true;
this.currentState = 3;
this.progressBarColour = 'info';
break;
case 98:
this.animated = true;
this.status = 'Error, retrying.';
Expand Down Expand Up @@ -332,7 +346,7 @@ export class ExportReportsComponent implements OnDestroy {
res &&
(this.currentState === 0 ||
this.currentState === 2 ||
this.percentageComplete === 100)
this.percentageComplete === 100 && this.currentState !== 3)
) {
if (res?.jobObj?.dateGenerated) {
if (res.jobObj.progressState === 'error') {
Expand All @@ -347,13 +361,9 @@ export class ExportReportsComponent implements OnDestroy {
} else {
this.exportMessage = 'No previous report found. Click generate report.';
}
} else {
} else if (res && this.currentState === 3) {
this.dateGenerated = undefined;
if (this.currentState !== 0 && this.currentState !== 2) {
this.exportMessage = 'Exporter running.';
} else {
this.exportMessage = 'No previous report found. Click generate report.';
}
this.exportMessage = 'No previous report found. Click generate report.';
}
this.cd.detectChanges();
}
Expand All @@ -365,6 +375,11 @@ export class ExportReportsComponent implements OnDestroy {
) {
return true;
}

if (this.currentState === 3) {
return false;
}

if (![0, 2, 99].includes(this.currentState)) {
return true;
}
Expand Down
8 changes: 8 additions & 0 deletions src/app/services/export.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,18 @@ export class ExportService {
}
// Every time we poll, we update the data service.
this.dataService.setItemValue(pollObj.dataId, res);

// If no data, retun and stop polling
if (res.jobObj && res.jobObj?.progressState == 'no_data') {
tickObj.state = 'finished';
return tickObj;
}

if (res.jobObj && res.jobObj?.progressState !== 'complete') {
await this.delay(this.pollingRate);
return tickObj;
}

tickObj.state = 'finished';
return tickObj;
}
Expand Down

0 comments on commit e1f7849

Please sign in to comment.