diff --git a/ui/winstudentgoaltracker/src/app/desktop/pages/components/student-card-list/student-card-list.ts b/ui/winstudentgoaltracker/src/app/desktop/pages/components/student-card-list/student-card-list.ts index 15c7b4c..7474611 100644 --- a/ui/winstudentgoaltracker/src/app/desktop/pages/components/student-card-list/student-card-list.ts +++ b/ui/winstudentgoaltracker/src/app/desktop/pages/components/student-card-list/student-card-list.ts @@ -1,7 +1,7 @@ import { Component, inject, signal } from '@angular/core'; import { StudentCard } from '../student-card/student-card'; -import { StudentService } from '../../../../shared/services/student.service'; -import { StudentCardDto } from '../../../../shared/models/dto/student-card.dto'; +import { StudentService } from '../../../../shared/services/dummy-student.service'; +import { StudentCardDto } from '../../../../shared/classes/student-card.dto'; export type DisplayMode = 'card' | 'list'; @@ -25,6 +25,8 @@ export class StudentCardList { protected readonly students = signal([]); protected readonly displayMode = signal('card'); + public errorMessage = signal(null); + // ************************** Properties *************************** // ************************ Public Methods ************************* @@ -41,8 +43,17 @@ export class StudentCardList { // Loads students from the service and populates the students signal. // ***************************************************************** private loadStudents() { - this.studentService.getStudentCards().subscribe(data => { - this.students.set(data); + this.studentService.getStudentCards().then(data => { + + if(!data.success) + { + this.errorMessage.set(data.message); + } + else + { + this.students.set(data.payload || []) + } + }); } } diff --git a/ui/winstudentgoaltracker/src/app/desktop/pages/components/student-card/student-card.ts b/ui/winstudentgoaltracker/src/app/desktop/pages/components/student-card/student-card.ts index 061f528..8621df3 100644 --- a/ui/winstudentgoaltracker/src/app/desktop/pages/components/student-card/student-card.ts +++ b/ui/winstudentgoaltracker/src/app/desktop/pages/components/student-card/student-card.ts @@ -1,6 +1,6 @@ import { Component, input } from '@angular/core'; import { DatePipe } from '@angular/common'; -import { StudentCardDto } from '../../../../shared/models/dto/student-card.dto'; +import { StudentCardDto } from '../../../../shared/classes/student-card.dto'; @Component({ selector: 'app-student-card', diff --git a/ui/winstudentgoaltracker/src/app/mobile/components/student-card/student-card.ts b/ui/winstudentgoaltracker/src/app/mobile/components/student-card/student-card.ts index 7111147..6f88cbc 100644 --- a/ui/winstudentgoaltracker/src/app/mobile/components/student-card/student-card.ts +++ b/ui/winstudentgoaltracker/src/app/mobile/components/student-card/student-card.ts @@ -1,6 +1,6 @@ import { Component, inject, input } from '@angular/core'; import { Router } from '@angular/router'; -import { StudentCardDto } from '../../../shared/models/dto/student-card.dto'; +import { StudentCardDto } from '../../../shared/classes/student-card.dto'; @Component({ selector: 'app-student-card', diff --git a/ui/winstudentgoaltracker/src/app/mobile/pages/home/home.ts b/ui/winstudentgoaltracker/src/app/mobile/pages/home/home.ts index 96b1711..a98953f 100644 --- a/ui/winstudentgoaltracker/src/app/mobile/pages/home/home.ts +++ b/ui/winstudentgoaltracker/src/app/mobile/pages/home/home.ts @@ -1,6 +1,7 @@ import { Component, inject, signal } from '@angular/core'; import { RouterOutlet } from '@angular/router'; -import { DummyMobileHomeMeta, MobileHomeMeta } from '../../../shared/services/dummy-mobile-home-meta.service'; +import { DummyMobileHomeMeta } from '../../../shared/services/dummy-mobile-home-meta.service'; +import { MobileHomeMeta } from '../../../shared/classes/mobile-home-meta'; import { Auth } from '../../../shared/services/auth'; @Component({ diff --git a/ui/winstudentgoaltracker/src/app/mobile/pages/student-goals/student-goals.ts b/ui/winstudentgoaltracker/src/app/mobile/pages/student-goals/student-goals.ts index 6f7e925..80150b6 100644 --- a/ui/winstudentgoaltracker/src/app/mobile/pages/student-goals/student-goals.ts +++ b/ui/winstudentgoaltracker/src/app/mobile/pages/student-goals/student-goals.ts @@ -1,6 +1,7 @@ import { Component, inject, signal } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; -import { DummyStudentGoalService, StudentGoalSummary } from '../../../shared/services/dummy-student-goal.service'; +import { DummyStudentGoalService } from '../../../shared/services/dummy-student-goal.service'; +import { StudentGoalSummary } from '../../../shared/classes/student-goal'; @Component({ selector: 'app-student-goals', diff --git a/ui/winstudentgoaltracker/src/app/mobile/pages/students/students.ts b/ui/winstudentgoaltracker/src/app/mobile/pages/students/students.ts index 074b1c2..664effc 100644 --- a/ui/winstudentgoaltracker/src/app/mobile/pages/students/students.ts +++ b/ui/winstudentgoaltracker/src/app/mobile/pages/students/students.ts @@ -1,7 +1,7 @@ import { Component, inject, signal } from '@angular/core'; import { StudentCard } from '../../components/student-card/student-card'; -import { StudentService } from '../../../shared/services/student.service'; -import { StudentCardDto } from '../../../shared/models/dto/student-card.dto'; +import { StudentService } from '../../../shared/services/dummy-student.service'; +import { StudentCardDto } from '../../../shared/classes/student-card.dto'; @Component({ selector: 'app-students', @@ -22,6 +22,8 @@ export class Students { private readonly studentService = inject(StudentService); protected readonly students = signal([]); + public errorMessage = signal(null); + // ************************** Properties *************************** // ************************ Public Methods ************************* @@ -34,8 +36,16 @@ export class Students { // Loads the list of students assigned to the current user. // ***************************************************************** private loadStudents() { - this.studentService.getDummyStudentsForUser().subscribe(data => { - this.students.set(data); + this.studentService.getDummyStudentsForUser().then(data => { + + if (!data.success) + { + this.errorMessage.set(data.message); + } + else + { + this.students.set(data.payload || []); + } }); } } diff --git a/ui/winstudentgoaltracker/src/app/shared/models/auth.models.ts b/ui/winstudentgoaltracker/src/app/shared/classes/auth.models.ts similarity index 100% rename from ui/winstudentgoaltracker/src/app/shared/models/auth.models.ts rename to ui/winstudentgoaltracker/src/app/shared/classes/auth.models.ts diff --git a/ui/winstudentgoaltracker/src/app/shared/classes/mobile-home-meta.ts b/ui/winstudentgoaltracker/src/app/shared/classes/mobile-home-meta.ts new file mode 100644 index 0000000..c2f440f --- /dev/null +++ b/ui/winstudentgoaltracker/src/app/shared/classes/mobile-home-meta.ts @@ -0,0 +1,4 @@ +export interface MobileHomeMeta { + programName: string; // program.name — varchar(255) + userName: string; // user.name — varchar(255) +} diff --git a/ui/winstudentgoaltracker/src/app/shared/models/dto/student-card.dto.ts b/ui/winstudentgoaltracker/src/app/shared/classes/student-card.dto.ts similarity index 100% rename from ui/winstudentgoaltracker/src/app/shared/models/dto/student-card.dto.ts rename to ui/winstudentgoaltracker/src/app/shared/classes/student-card.dto.ts diff --git a/ui/winstudentgoaltracker/src/app/shared/classes/student-goal.ts b/ui/winstudentgoaltracker/src/app/shared/classes/student-goal.ts new file mode 100644 index 0000000..6c982b3 --- /dev/null +++ b/ui/winstudentgoaltracker/src/app/shared/classes/student-goal.ts @@ -0,0 +1,12 @@ +export interface StudentGoalSummary { + studentIdentifier: string; // student.identifier — varchar(50) + goals: StudentGoalItem[]; +} + +export interface StudentGoalItem { + goalId: string; // goal.id_goal — char(36) + title: string; // goal.title — varchar(255) + description: string; // goal.description — text + category: string; // goal.category — varchar(100) + progressEventCount: number; // count of progress_event rows for this goal +} diff --git a/ui/winstudentgoaltracker/src/app/shared/services/api.ts b/ui/winstudentgoaltracker/src/app/shared/services/api.ts index 8d208e7..9f43e38 100644 --- a/ui/winstudentgoaltracker/src/app/shared/services/api.ts +++ b/ui/winstudentgoaltracker/src/app/shared/services/api.ts @@ -10,7 +10,7 @@ import { SelectProgramRequest, SelectProgramResponse, TokenRefreshResponse, -} from '../models/auth.models'; +} from '../classes/auth.models'; @Injectable({ providedIn: 'root', diff --git a/ui/winstudentgoaltracker/src/app/shared/services/auth.ts b/ui/winstudentgoaltracker/src/app/shared/services/auth.ts index 31ff73f..c5b97a3 100644 --- a/ui/winstudentgoaltracker/src/app/shared/services/auth.ts +++ b/ui/winstudentgoaltracker/src/app/shared/services/auth.ts @@ -8,7 +8,7 @@ import { SelectProgramResponse, TokenRefreshResponse, UserProgramSummary, -} from '../models/auth.models'; +} from '../classes/auth.models'; import { Api } from './api'; const STORAGE_KEYS = { diff --git a/ui/winstudentgoaltracker/src/app/shared/services/dummy-mobile-home-meta.service.ts b/ui/winstudentgoaltracker/src/app/shared/services/dummy-mobile-home-meta.service.ts index b707da0..2e18609 100644 --- a/ui/winstudentgoaltracker/src/app/shared/services/dummy-mobile-home-meta.service.ts +++ b/ui/winstudentgoaltracker/src/app/shared/services/dummy-mobile-home-meta.service.ts @@ -1,17 +1,12 @@ import { Injectable } from '@angular/core'; -import { Observable, of } from 'rxjs'; import { ApiResult } from '../classes/api-result'; +import { MobileHomeMeta } from '../classes/mobile-home-meta'; // ***************************************************************** // TODO: This dummy service should be replaced by MobileHomeMeta, // which will fetch real data from the API. // ***************************************************************** -export interface MobileHomeMeta { - programName: string; // program.name — varchar(255) - userName: string; // user.name — varchar(255) -} - @Injectable({ providedIn: 'root', }) diff --git a/ui/winstudentgoaltracker/src/app/shared/services/dummy-student-goal.service.ts b/ui/winstudentgoaltracker/src/app/shared/services/dummy-student-goal.service.ts index 0597aee..f1db355 100644 --- a/ui/winstudentgoaltracker/src/app/shared/services/dummy-student-goal.service.ts +++ b/ui/winstudentgoaltracker/src/app/shared/services/dummy-student-goal.service.ts @@ -1,24 +1,12 @@ import { Injectable } from '@angular/core'; import { ApiResult } from '../classes/api-result'; +import { StudentGoalSummary } from '../classes/student-goal'; // ***************************************************************** // TODO: This dummy service should be replaced by StudentGoalService, // which will fetch real data from the API. // ***************************************************************** -export interface StudentGoalSummary { - studentIdentifier: string; // student.identifier — varchar(50) - goals: StudentGoalItem[]; -} - -export interface StudentGoalItem { - goalId: string; // goal.id_goal — char(36) - title: string; // goal.title — varchar(255) - description: string; // goal.description — text - category: string; // goal.category — varchar(100) - progressEventCount: number; // count of progress_event rows for this goal -} - @Injectable({ providedIn: 'root', }) diff --git a/ui/winstudentgoaltracker/src/app/shared/services/student.service.ts b/ui/winstudentgoaltracker/src/app/shared/services/dummy-student.service.ts similarity index 86% rename from ui/winstudentgoaltracker/src/app/shared/services/student.service.ts rename to ui/winstudentgoaltracker/src/app/shared/services/dummy-student.service.ts index b5a9475..685c5a7 100644 --- a/ui/winstudentgoaltracker/src/app/shared/services/student.service.ts +++ b/ui/winstudentgoaltracker/src/app/shared/services/dummy-student.service.ts @@ -1,6 +1,7 @@ import { Injectable } from '@angular/core'; import { Observable, of } from 'rxjs'; -import { StudentCardDto } from '../models/dto/student-card.dto'; +import { StudentCardDto } from '../classes/student-card.dto'; +import { ApiResult } from '../classes/api-result'; @Injectable({ providedIn: 'root', @@ -19,8 +20,8 @@ export class StudentService { // Returns student card summaries. Currently returns dummy data // until the API endpoint is available. // ***************************************************************** - getStudentCards(): Observable { - return of([ + async getStudentCards(): Promise> { + var payload = [ { studentId: '1', identifier: 'J.B', @@ -45,7 +46,9 @@ export class StudentService { goalCount: 2, progressEventCount: 0, }, - ]); + ]; + + return ApiResult.ok(payload); } // ***************************************************************** @@ -54,14 +57,16 @@ export class StudentService { // Returns students assigned to the current user with their // identifier, age, goal count, and progress event count. // ***************************************************************** - getDummyStudentsForUser(): Observable { - return of([ + async getDummyStudentsForUser(): Promise> { + var payload = [ { studentId: '1', identifier: 'J.B', age: 21, lastEntryDate: '2026-02-21', goalCount: 3, progressEventCount: 5 }, { studentId: '2', identifier: 'M.K', age: 19, lastEntryDate: '2026-02-25', goalCount: 4, progressEventCount: 8 }, { studentId: '3', identifier: 'A.R', age: 22, lastEntryDate: null, goalCount: 2, progressEventCount: 0 }, { studentId: '4', identifier: 'T.W', age: 20, lastEntryDate: '2026-02-18', goalCount: 5, progressEventCount: 12 }, { studentId: '5', identifier: 'L.C', age: 18, lastEntryDate: '2026-02-27', goalCount: 1, progressEventCount: 2 }, - ]); + ]; + + return ApiResult.ok(payload); } // ************************ Event Handlers *************************