Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
Add loading spinner to start component
Browse files Browse the repository at this point in the history
This prevents displaying a message that no collaborations are available to this user, when truth is that they are still being collected
  • Loading branch information
bartvanb committed Feb 14, 2024
1 parent 0bd3b9b commit 681b508
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/app/pages/start/start.component.html
@@ -1,11 +1,16 @@
<app-page-header title="Choose a collaboration"></app-page-header>
<div class="tile-grid">
<button mat-raised-button *ngFor="let collaboration of collaborations" (click)="handleCollaborationClick(collaboration)">
{{ collaboration.name }}
</button>
</div>
<mat-card *ngIf="collaborations.length === 0">
<mat-card-content>
<p>{{ "start.no-collaborations" | translate }}</p>
</mat-card-content>
</mat-card>
<ng-container *ngIf="!isLoading; else loading">
<div class="tile-grid">
<button mat-raised-button *ngFor="let collaboration of collaborations" (click)="handleCollaborationClick(collaboration)">
{{ collaboration.name }}
</button>
</div>
<mat-card *ngIf="collaborations.length === 0">
<mat-card-content>
<p>{{ "start.no-collaborations" | translate }}</p>
</mat-card-content>
</mat-card>
</ng-container>
<ng-template #loading>
<mat-spinner diameter="48"></mat-spinner>
</ng-template>
4 changes: 4 additions & 0 deletions src/app/pages/start/start.component.scss
Expand Up @@ -14,3 +14,7 @@
padding: $spacing-px-16 0;
}
}

mat-spinner {
margin: auto;
}
2 changes: 2 additions & 0 deletions src/app/pages/start/start.component.ts
Expand Up @@ -14,6 +14,7 @@ import { PermissionService } from 'src/app/services/permission.service';
export class StartComponent implements OnInit {
@HostBinding('class') class = 'card-container';
collaborations: BaseCollaboration[] = [];
isLoading = true;

constructor(
private router: Router,
Expand All @@ -24,6 +25,7 @@ export class StartComponent implements OnInit {

async ngOnInit() {
await this.initData();
this.isLoading = false;
}

handleCollaborationClick(collaboration: BaseCollaboration) {
Expand Down

0 comments on commit 681b508

Please sign in to comment.