-
Notifications
You must be signed in to change notification settings - Fork 0
admin and candidate prefinal commit #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { TestBed } from '@angular/core/testing'; | ||
| import { AppComponent } from './app.component'; | ||
|
|
||
| describe('AppComponent', () => { | ||
| beforeEach(async () => { | ||
| await TestBed.configureTestingModule({ | ||
| imports: [AppComponent], | ||
| }).compileComponents(); | ||
| }); | ||
|
|
||
| it('should create the app', () => { | ||
| const fixture = TestBed.createComponent(AppComponent); | ||
| const app = fixture.componentInstance; | ||
| expect(app).toBeTruthy(); | ||
| }); | ||
|
|
||
| it(`should have the 'otp-admin' title`, () => { | ||
| const fixture = TestBed.createComponent(AppComponent); | ||
| const app = fixture.componentInstance; | ||
| expect(app.title).toEqual('otp-admin'); | ||
| }); | ||
|
|
||
| it('should render title', () => { | ||
| const fixture = TestBed.createComponent(AppComponent); | ||
| fixture.detectChanges(); | ||
| const compiled = fixture.nativeElement as HTMLElement; | ||
| expect(compiled.querySelector('h1')?.textContent).toContain('Hello, otp-admin'); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,21 +94,27 @@ export class DashboardComponent implements OnInit, AfterViewInit { | |
| }, | ||
| error: (err) => { | ||
| console.error(err); | ||
| this.snackBar.open('Failed to load exams', '', { duration: 5000 }); | ||
| this.snackBar.open(err?.error?.message || 'Failed to load exams', '', { duration: 5000 }); | ||
| this.loading = false; | ||
| } | ||
| }); | ||
|
|
||
| // Fetch active exam count | ||
| this.examService.getActiveExamCount().subscribe({ | ||
| next: (count) => this.activeExams = count, | ||
| error: (err) => console.error(err) | ||
| error: (err) => { | ||
| console.error(err) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove console |
||
| this.snackBar.open(err?.error?.message || 'Failed to load Active Exam Count', '', { duration: 5000 }); | ||
| } | ||
| }); | ||
|
|
||
| // Fetch total active candidates | ||
| this.examService.getTotalActiveCandidates().subscribe({ | ||
| next: (count) => this.totalCandidates = count, | ||
| error: (err) => console.error(err) | ||
| error: (err) => { | ||
| console.error(err); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove console |
||
| this.snackBar.open(err?.error?.message || 'Failed to load Active Candidates', '', { duration: 5000 }); | ||
| } | ||
| }) | ||
| } | ||
|
|
||
|
|
@@ -129,12 +135,12 @@ export class DashboardComponent implements OnInit, AfterViewInit { | |
| } | ||
|
|
||
| getStatusColor(status: string): string { | ||
| const statusColorMap: { [key: string]: string } = { | ||
| upcoming: 'primary', | ||
| ongoing: 'accent', | ||
| finished: 'warn', | ||
| }; | ||
| return statusColorMap[status] || 'default'; | ||
| switch (status) { | ||
| case 'upcoming': return 'primary'; | ||
| case 'ongoing': return 'accent'; | ||
| case 'ended': return 'warn'; | ||
| default: return 'default'; | ||
| } | ||
| } | ||
|
|
||
| getStatusText(status: string): string { | ||
|
|
@@ -156,10 +162,6 @@ export class DashboardComponent implements OnInit, AfterViewInit { | |
| return 'ended'; | ||
| } | ||
|
|
||
| // viewResults(exam: Exam): void { | ||
| // this.snackBar.open(`Viewing results for ${exam.title}`, 'Close', { duration: 2000 }); | ||
| // } | ||
|
|
||
| downloadResults(exam: Exam): void { | ||
| this.examService.downloadResults(exam.id).subscribe({ | ||
| next: (blob) => { | ||
|
|
@@ -174,7 +176,7 @@ export class DashboardComponent implements OnInit, AfterViewInit { | |
| }, | ||
| error: (err) => { | ||
| console.error(err); | ||
| this.snackBar.open('Failed to download results.', '', { duration: 5000 }); | ||
| this.snackBar.open(err?.error?.message || 'Failed to download results.', '', { duration: 5000 }); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,8 +42,8 @@ export class DownloadResultsComponent implements OnInit { | |
| next: (exams) => { | ||
| this.exams = exams; | ||
| }, | ||
| error: () => { | ||
| this.snackBar.open('Failed to load completed exams.', '', { duration: 5000 }); | ||
| error: (err) => { | ||
| this.snackBar.open(err?.error?.message || 'Failed to load completed exams.', '', { duration: 5000 }); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. { } should be use if there are multiple linse, on above only single line present so use instead error: (err) => this.snackBar.open(err?.error?.message || 'Failed to load completed exams.', '', { duration: 5000 }); |
||
| } | ||
| }); | ||
| } | ||
|
|
@@ -57,8 +57,8 @@ export class DownloadResultsComponent implements OnInit { | |
| this.snackBar.open('Results downloaded!', '', { duration: 5000 }); | ||
| this.downloadingExamId = null; | ||
| }, | ||
| error: () => { | ||
| this.snackBar.open('Failed to download results.', '', { duration: 5000 }); | ||
| error: (err) => { | ||
| this.snackBar.open(err?.error?.message || 'Failed to download results.', '', { duration: 5000 }); | ||
| this.downloadingExamId = null; | ||
| } | ||
| }); | ||
|
|
@@ -70,7 +70,6 @@ export class DownloadResultsComponent implements OnInit { | |
| a.href = url; | ||
| a.download = filename; | ||
| a.click(); | ||
| a.remove(); | ||
| window.URL.revokeObjectURL(url); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,53 @@ | ||
| <p>login works!</p> | ||
| <div class="login-container"> | ||
| <div class="branding-panel"> | ||
| <div class="branding-content"> | ||
| <mat-icon class="brand-logo">school</mat-icon> | ||
| <h1 class="brand-title">NextStep Admin Portal</h1> | ||
| <p class="brand-subtitle">Online Test Platform Management</p> | ||
| </div> | ||
| </div> | ||
| <div class="login-panel"> | ||
| <mat-card class="login-card"> | ||
| <mat-card-header> | ||
| <mat-card-title> | ||
| <h2>Admin Login</h2> | ||
| </mat-card-title> | ||
| </mat-card-header> | ||
| <mat-card-content> | ||
| <form [formGroup]="loginForm" (ngSubmit)="onSubmit()"> | ||
| <mat-form-field appearance="outline" class="form-field"> | ||
| <mat-label>Username</mat-label> | ||
| <input | ||
| matInput | ||
| formControlName="username" | ||
| required | ||
| placeholder="Enter your username" | ||
| /> | ||
| <mat-icon matSuffix>person</mat-icon> | ||
| </mat-form-field> | ||
| <mat-form-field appearance="outline" class="form-field"> | ||
| <mat-label>Password</mat-label> | ||
| <input | ||
| matInput | ||
| type="password" | ||
| formControlName="password" | ||
| required | ||
| placeholder="Enter your password" | ||
| /> | ||
| <mat-icon matSuffix>lock</mat-icon> | ||
| </mat-form-field> | ||
| <button | ||
| mat-raised-button | ||
| color="primary" | ||
| class="login-button" | ||
| type="submit" | ||
| [disabled]="loginForm.invalid || loading" | ||
| > | ||
| <mat-spinner *ngIf="loading" diameter="20"></mat-spinner> | ||
| <span *ngIf="!loading">Login</span> | ||
| </button> | ||
| </form> | ||
| </mat-card-content> | ||
| </mat-card> | ||
| </div> | ||
| </div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete this file as there is no use as of now