Skip to content

Commit

Permalink
Add loader for download answers action #257 (#261)
Browse files Browse the repository at this point in the history
* Add loader for download answers action #257

* Feature: answer.component.html download button disabled if data is loading
  • Loading branch information
aamanunin authored Oct 5, 2020
1 parent 1ac03b6 commit ed60490
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion frontend/src/app/components/answer/answer.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@
<div class="list-header col-md-12">
<h3>{{((answerState | async)?.urgent ? 'URGENT_HEADER' : 'NOT_URGENT_HEADER') | translate}}</h3>
<h5>{{((answerState | async)?.urgent ? 'URGENT_SUBHEADER' : 'NOT_URGENT_SUBHEADER') | translate}}</h5>
<button (click)="downloadAnswers()" class="btn btn-default mb-2">{{'DOWNLOAD_ANSWERS' | translate }}</button>
<button (click)="downloadAnswers()" class="btn btn-default mb-2" [disabled]="isLoading">
<ng-container *ngIf="isLoading">
<i class="fa fa-circle-o-notch fa-spin" style="font-size:14px"></i>
</ng-container >
{{'DOWNLOAD_ANSWERS' | translate }}
</button>
</div>
<div class="col-md-3">
<app-answer-list [answerState]="answerState | async" (reload)="redoAnswerListAction()"
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/app/components/answer/answer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class AnswerComponent implements OnInit {
isUrgent: boolean;
fromTime: string;
toTime: string;
isLoading: boolean;

constructor(private store: Store<AppState>,
private answersService: AnswersService,
Expand Down Expand Up @@ -115,8 +116,12 @@ export class AnswerComponent implements OnInit {
filter.to = this.toTime;
}

this.isLoading = true;
return this.answersService.downloadAnswers(filter).subscribe(res => {
this.isLoading = false;
FileSaver.saveAs(res, 'answsers.xlsx');
}, error => {
this.isLoading = false;
});
}

Expand Down

1 comment on commit ed60490

@vercel
Copy link

@vercel vercel bot commented on ed60490 Oct 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.