Skip to content
This repository has been archived by the owner on Apr 24, 2022. It is now read-only.

Commit

Permalink
[TEAMMATES#11086] Enrolling students: show a progress indicator when …
Browse files Browse the repository at this point in the history
…enrolling a large class (TEAMMATES#11600)
  • Loading branch information
FergusMok authored Mar 27, 2022
1 parent 47a51f8 commit 5fd040c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,15 @@ <h1 id="enroll-header" class="text-break">Enroll Students for {{ courseId }}</h1
</div>
<div class="enroll-button-group">
<button
[ngClass]="{'w-50': isEnrolling}"
type="submit"
title="Enroll"
id="btn-enroll"
name="button-enroll"
class="btn btn-success float-right"
[disabled]="isEnrolling"
(click)="submitEnrollData()">
<tm-progress-bar *ngIf="isEnrolling"></tm-progress-bar>
<tm-ajax-loading *ngIf="isEnrolling"></tm-ajax-loading>
Enroll students
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@
display: inline-block;
}

.enroll-button-group * {
max-height: inherit;
}

table {
table-layout: fixed;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { AjaxPreloadModule } from '../../components/ajax-preload/ajax-preload.mo
import { LoadingRetryModule } from '../../components/loading-retry/loading-retry.module';
import { LoadingSpinnerModule } from '../../components/loading-spinner/loading-spinner.module';
import { PanelChevronModule } from '../../components/panel-chevron/panel-chevron.module';
import { ProgressBarModule } from '../../components/progress-bar/progress-bar.module';
import { StatusMessageModule } from '../../components/status-message/status-message.module';
import { InstructorCourseEnrollPageComponent } from './instructor-course-enroll-page.component';

Expand All @@ -24,6 +25,7 @@ describe('InstructorCourseEnrollPageComponent', () => {
AjaxPreloadModule,
AjaxLoadingModule,
StatusMessageModule,
ProgressBarModule,
LoadingSpinnerModule,
LoadingRetryModule,
PanelChevronModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute } from '@angular/router';

import { HotTableRegisterer } from '@handsontable/angular';
import Handsontable from 'handsontable';
import { concat, Observable } from 'rxjs';
import { finalize } from 'rxjs/operators';
import { CourseService } from '../../../services/course.service';
import { ProgressBarService } from '../../../services/progress-bar.service';
import { SimpleModalService } from '../../../services/simple-modal.service';
import { StatusMessageService } from '../../../services/status-message.service';
import { StudentService } from '../../../services/student.service';
Expand Down Expand Up @@ -95,6 +95,7 @@ export class InstructorCourseEnrollPageComponent implements OnInit {
private statusMessageService: StatusMessageService,
private courseService: CourseService,
private studentService: StudentService,
private progressBarService: ProgressBarService,
private simpleModalService: SimpleModalService) { }

ngOnInit(): void {
Expand Down Expand Up @@ -188,6 +189,7 @@ export class InstructorCourseEnrollPageComponent implements OnInit {
}),
);

this.progressBarService.updateProgress(0);
enrollRequests.pipe(finalize(() => {
this.isEnrolling = false;
})).subscribe({
Expand All @@ -206,6 +208,8 @@ export class InstructorCourseEnrollPageComponent implements OnInit {
}
}
}
const percentage: number = Math.round(100 * enrolledStudents.length / studentEnrollRequests.size);
this.progressBarService.updateProgress(percentage);
},
complete: () => {
this.showEnrollResults = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { AjaxPreloadModule } from '../../components/ajax-preload/ajax-preload.mo
import { LoadingRetryModule } from '../../components/loading-retry/loading-retry.module';
import { LoadingSpinnerModule } from '../../components/loading-spinner/loading-spinner.module';
import { PanelChevronModule } from '../../components/panel-chevron/panel-chevron.module';
import { ProgressBarModule } from '../../components/progress-bar/progress-bar.module';
import { StatusMessageModule } from '../../components/status-message/status-message.module';
import { InstructorCourseEnrollPageComponent } from './instructor-course-enroll-page.component';

Expand Down Expand Up @@ -35,6 +36,7 @@ const routes: Routes = [
RouterModule.forChild(routes),
AjaxLoadingModule,
LoadingRetryModule,
ProgressBarModule,
LoadingSpinnerModule,
PanelChevronModule,
],
Expand Down

0 comments on commit 5fd040c

Please sign in to comment.