diff --git a/dev/user-backend-nest/microservices/schedule/src/schedule/schedule.dto.ts b/dev/user-backend-nest/microservices/schedule/src/schedule/schedule.dto.ts index 585fe1b6..4adb9495 100644 --- a/dev/user-backend-nest/microservices/schedule/src/schedule/schedule.dto.ts +++ b/dev/user-backend-nest/microservices/schedule/src/schedule/schedule.dto.ts @@ -74,6 +74,7 @@ export interface Event { id: string; startDateTime: string; endDateTime: string; + planningLabel: string; course: { id: string; label: string; diff --git a/dev/user-backend-nest/microservices/schedule/src/schedule/schedule.service.ts b/dev/user-backend-nest/microservices/schedule/src/schedule/schedule.service.ts index 8fa7e995..3d7492ad 100644 --- a/dev/user-backend-nest/microservices/schedule/src/schedule/schedule.service.ts +++ b/dev/user-backend-nest/microservices/schedule/src/schedule/schedule.service.ts @@ -58,6 +58,15 @@ export class ScheduleService { this.configService.get('scheduleProviderApi'); } + private addPlanningLabelToEvent(schedule: Schedule): Schedule { + schedule.plannings.forEach((planning) => { + planning.events.forEach((event) => { + event.planningLabel = planning.label; + }); + }); + return schedule; + } + public getSchedule(query: UserScheduleQueryDto): Observable { const url = this.scheduleProviderApiConfig.apiUrl .replace( @@ -82,9 +91,7 @@ export class ScheduleService { this.logger.error(errorMessage, err); throw new RpcException(errorMessage); }), - map((res) => { - return res.data; - }), + map((res) => this.addPlanningLabelToEvent(res.data)), ); } diff --git a/dev/user-frontend-ionic/projects/schedule/src/lib/common/event-detail/event-detail.component.html b/dev/user-frontend-ionic/projects/schedule/src/lib/common/event-detail/event-detail.component.html index 3eff4430..304b8945 100644 --- a/dev/user-frontend-ionic/projects/schedule/src/lib/common/event-detail/event-detail.component.html +++ b/dev/user-frontend-ionic/projects/schedule/src/lib/common/event-detail/event-detail.component.html @@ -55,9 +55,13 @@ {{event.course.label}} + + + {{event.planningLabel}} + - {{room.label}} - {{room.building}} + {{room.label}} - {{room.building}} diff --git a/dev/user-frontend-ionic/projects/schedule/src/lib/common/event-detail/event-detail.component.ts b/dev/user-frontend-ionic/projects/schedule/src/lib/common/event-detail/event-detail.component.ts index bdf59da1..efc5c6bb 100644 --- a/dev/user-frontend-ionic/projects/schedule/src/lib/common/event-detail/event-detail.component.ts +++ b/dev/user-frontend-ionic/projects/schedule/src/lib/common/event-detail/event-detail.component.ts @@ -40,7 +40,7 @@ import { Component, Input } from '@angular/core'; import { Browser } from '@capacitor/browser'; import { take } from 'rxjs/operators'; -import { Course, Event, HiddenCourse } from '../../schedule.repository'; +import {Course, Event, HiddenCourse} from '../../schedule.repository'; import { ScheduleService } from '../../schedule.service'; @Component({ diff --git a/dev/user-frontend-ionic/projects/schedule/src/lib/schedule.repository.ts b/dev/user-frontend-ionic/projects/schedule/src/lib/schedule.repository.ts index 8e5dd5ad..497292a3 100644 --- a/dev/user-frontend-ionic/projects/schedule/src/lib/schedule.repository.ts +++ b/dev/user-frontend-ionic/projects/schedule/src/lib/schedule.repository.ts @@ -37,11 +37,11 @@ * termes. */ -import { createStore, select, Store, withProps } from '@ngneat/elf'; -import { persistState } from '@ngneat/elf-persist-state'; -import { localForageStore } from '@multi/shared'; -import { combineLatest, Observable } from 'rxjs'; -import { map } from 'rxjs/operators'; +import {createStore, select, Store, withProps} from '@ngneat/elf'; +import {persistState} from '@ngneat/elf-persist-state'; +import {localForageStore} from '@multi/shared'; +import {combineLatest, Observable} from 'rxjs'; +import {map} from 'rxjs/operators'; const STORE_NAME = 'schedule'; const STORE_NAME_2 = 'impersonated-schedule'; @@ -54,15 +54,18 @@ export interface ScheduleProps { hiddenCourseList: HiddenCourse[]; allPlanningsData: PlanningData[]; } + export interface Schedule { messages: [Message?]; plannings?: Planning[]; } + export interface Message { level: string; code: string; text: string; } + export interface Planning { id: string; label: string; @@ -76,16 +79,19 @@ export interface Planning { ] | []; events?: Event[]; } + export interface PlanningData { id: string; label: string; default: boolean; isSelected: boolean; } + export interface Event { id: string; startDateTime: string; endDateTime: string; + planningLabel: string; course: Course; rooms: [ { @@ -109,6 +115,7 @@ export interface Event { } ]; } + export interface Course { id: string; label: string; @@ -117,6 +124,7 @@ export interface Course { online: boolean; url?: string; } + export interface HiddenCourse { id: string; title: string; @@ -202,15 +210,15 @@ export class ScheduleStoreManager { .map(mapPlanningId) : activePlanningIdsInSchedule; - const updatedAllPlanningsData = state.allPlanningsData.map(planningData => { - const isActive = activePlanningIds.includes(planningData.id); - const isSelected = planningData.isSelected === null && isActive ? isActive : planningData.isSelected; + const updatedAllPlanningsData = state.allPlanningsData.map(planningData => { + const isActive = activePlanningIds.includes(planningData.id); + const isSelected = planningData.isSelected === null && isActive ? isActive : planningData.isSelected; - return { - ...planningData, - isSelected, - }; - }); + return { + ...planningData, + isSelected, + }; + }); return { ...state, @@ -219,14 +227,15 @@ export class ScheduleStoreManager { }; }); } + public setActivePlanningIds(activePlanningIds) { this.store.update((state) => { const updatedPlanningsData = state.allPlanningsData .map((planningData: PlanningData) => ({ - ...planningData, - isSelected: activePlanningIds.includes(planningData.id) - }) - ); + ...planningData, + isSelected: activePlanningIds.includes(planningData.id) + }) + ); return { ...state, @@ -241,6 +250,7 @@ export class ScheduleStoreManager { hiddenCourseList, })); } + public resetStore() { this.store.update(() => ({ schedule: null, @@ -251,12 +261,12 @@ export class ScheduleStoreManager { } public persistStore(storeName: string) { - persistState(this.store, { key: storeName, storage: localForageStore }); + persistState(this.store, {key: storeName, storage: localForageStore}); } private createStore(storeName: string): Store { return createStore( - { name: storeName }, + {name: storeName}, withProps({ schedule: null, hiddenCourseList: [], diff --git a/dev/user-frontend-ionic/projects/schedule/src/lib/widgets/next-events/next-events.component.html b/dev/user-frontend-ionic/projects/schedule/src/lib/widgets/next-events/next-events.component.html index e60198db..3470eaff 100644 --- a/dev/user-frontend-ionic/projects/schedule/src/lib/widgets/next-events/next-events.component.html +++ b/dev/user-frontend-ionic/projects/schedule/src/lib/widgets/next-events/next-events.component.html @@ -72,21 +72,28 @@ - {{event.startDateTime | localHour}} - {{event.endDateTime | localHour}} + {{ event.startDateTime | localHour }} - {{ event.endDateTime | localHour }} - {{event.course.label}} - + {{ event.course.label }} + + + + + + {{ event.planningLabel }} + + - {{room.label}} - {{room.building}} + {{room.label}} - {{room.building}} @@ -151,6 +158,14 @@ {{event.course.label}} + + + + + + {{ event.planningLabel }} + + {{room.label}} - {{room.building}}