From 60c62dc28c4db0fd1ed412e38d6a7898f82e2327 Mon Sep 17 00:00:00 2001 From: PIPetkova19 Date: Wed, 15 Jul 2026 15:21:56 +0300 Subject: [PATCH 1/4] Include category to room view --- uniplanWeb/public/i18n/bg.json | 3 ++- uniplanWeb/public/i18n/en.json | 3 ++- uniplanWeb/src/app/config/endpoints.ts | 1 + .../src/app/core/interfaces/category-elm.ts | 5 ++++ .../src/app/core/interfaces/room-elm.ts | 5 +++- .../app/core/interfaces/room-view-model.ts | 5 ---- .../navmenu-component/navmenu-component.ts | 2 +- .../category/category-display-pipe.spec.ts | 8 ++++++ .../pipes/category/category-display-pipe.ts | 13 +++++++++ .../{ => faculty}/faculty-name-pipe.spec.ts | 2 +- .../pipes/{ => faculty}/faculty-name-pipe.ts | 0 .../src/app/features/room/room-service.ts | 4 +-- .../features/room/room-table/room-table.html | 16 +++++++++-- .../features/room/room-table/room-table.scss | 7 ++++- .../features/room/room-table/room-table.ts | 21 +++++++++++++-- .../category/category-service.spec.ts | 16 +++++++++++ .../app/services/category/category-service.ts | 27 +++++++++++++++++++ .../{ => login}/login-auth-service.spec.ts | 0 .../{ => login}/login-auth-service.ts | 0 19 files changed, 121 insertions(+), 17 deletions(-) create mode 100644 uniplanWeb/src/app/core/interfaces/category-elm.ts delete mode 100644 uniplanWeb/src/app/core/interfaces/room-view-model.ts create mode 100644 uniplanWeb/src/app/core/shared/pipes/category/category-display-pipe.spec.ts create mode 100644 uniplanWeb/src/app/core/shared/pipes/category/category-display-pipe.ts rename uniplanWeb/src/app/core/shared/pipes/{ => faculty}/faculty-name-pipe.spec.ts (73%) rename uniplanWeb/src/app/core/shared/pipes/{ => faculty}/faculty-name-pipe.ts (100%) create mode 100644 uniplanWeb/src/app/services/category/category-service.spec.ts create mode 100644 uniplanWeb/src/app/services/category/category-service.ts rename uniplanWeb/src/app/services/{ => login}/login-auth-service.spec.ts (100%) rename uniplanWeb/src/app/services/{ => login}/login-auth-service.ts (100%) diff --git a/uniplanWeb/public/i18n/bg.json b/uniplanWeb/public/i18n/bg.json index 5d3fe91..7ad6095 100644 --- a/uniplanWeb/public/i18n/bg.json +++ b/uniplanWeb/public/i18n/bg.json @@ -13,7 +13,8 @@ }, "room": { "room-number": "Номер на стая", - "no-rooms": "Няма записани стаи" + "no-rooms": "Няма записани стаи", + "category-label":"Тип на стая/Капацитет" }, "faculty": { "delete-button": "Изтрий", diff --git a/uniplanWeb/public/i18n/en.json b/uniplanWeb/public/i18n/en.json index bd15631..aabb3c3 100644 --- a/uniplanWeb/public/i18n/en.json +++ b/uniplanWeb/public/i18n/en.json @@ -13,7 +13,8 @@ }, "room": { "room-number": "Room number", - "no-rooms": "No rooms" + "no-rooms": "No rooms", + "category-label": "Room Type/Capacity" }, "faculty": { "delete-button": "Delete", diff --git a/uniplanWeb/src/app/config/endpoints.ts b/uniplanWeb/src/app/config/endpoints.ts index 53a9589..c24f4aa 100644 --- a/uniplanWeb/src/app/config/endpoints.ts +++ b/uniplanWeb/src/app/config/endpoints.ts @@ -5,4 +5,5 @@ export const API_ENDPOINTS = { courses: `${environment.baseUrl}/courses`, faculties: `${environment.baseUrl}/faculties`, majors: `${environment.baseUrl}/majors`, + categories: `${environment.baseUrl}/categories`, }; diff --git a/uniplanWeb/src/app/core/interfaces/category-elm.ts b/uniplanWeb/src/app/core/interfaces/category-elm.ts new file mode 100644 index 0000000..1de858f --- /dev/null +++ b/uniplanWeb/src/app/core/interfaces/category-elm.ts @@ -0,0 +1,5 @@ +export interface CategoryElm { + id: string; + roomType: string; + capacity: number; +} \ No newline at end of file diff --git a/uniplanWeb/src/app/core/interfaces/room-elm.ts b/uniplanWeb/src/app/core/interfaces/room-elm.ts index 655e906..3d39caa 100644 --- a/uniplanWeb/src/app/core/interfaces/room-elm.ts +++ b/uniplanWeb/src/app/core/interfaces/room-elm.ts @@ -1,5 +1,8 @@ +import { CategoryElm } from "./category-elm"; + export interface RoomElm { id: string; facultyId: string; - roomNumber: string; + roomNumber: string, + categoryId: string; } diff --git a/uniplanWeb/src/app/core/interfaces/room-view-model.ts b/uniplanWeb/src/app/core/interfaces/room-view-model.ts deleted file mode 100644 index 9acc24d..0000000 --- a/uniplanWeb/src/app/core/interfaces/room-view-model.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { RoomElm } from "./room-elm"; - -export interface RoomViewModel extends RoomElm { - position: number; -} \ No newline at end of file diff --git a/uniplanWeb/src/app/core/shared/navmenu-component/navmenu-component.ts b/uniplanWeb/src/app/core/shared/navmenu-component/navmenu-component.ts index 926e096..e2ae0d9 100644 --- a/uniplanWeb/src/app/core/shared/navmenu-component/navmenu-component.ts +++ b/uniplanWeb/src/app/core/shared/navmenu-component/navmenu-component.ts @@ -3,7 +3,7 @@ import { CommonModule } from '@angular/common'; import { RouterLink, RouterLinkActive } from '@angular/router'; import { TranslatePipe } from '@ngx-translate/core'; -import { LoginAuthService } from '../../../services/login-auth-service'; +import { LoginAuthService } from '../../../services/login/login-auth-service'; @Component({ selector: 'app-navmenu-component', diff --git a/uniplanWeb/src/app/core/shared/pipes/category/category-display-pipe.spec.ts b/uniplanWeb/src/app/core/shared/pipes/category/category-display-pipe.spec.ts new file mode 100644 index 0000000..26c897d --- /dev/null +++ b/uniplanWeb/src/app/core/shared/pipes/category/category-display-pipe.spec.ts @@ -0,0 +1,8 @@ +import { CategoryDisplayPipe } from "./category-display-pipe"; + +describe('CategoryDisplayPipe', () => { + it('create an instance', () => { + const pipe = new CategoryDisplayPipe(); + expect(pipe).toBeTruthy(); + }); +}); diff --git a/uniplanWeb/src/app/core/shared/pipes/category/category-display-pipe.ts b/uniplanWeb/src/app/core/shared/pipes/category/category-display-pipe.ts new file mode 100644 index 0000000..31f7977 --- /dev/null +++ b/uniplanWeb/src/app/core/shared/pipes/category/category-display-pipe.ts @@ -0,0 +1,13 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'categoryDisplayPipe', +}) + +export class CategoryDisplayPipe implements PipeTransform { + + transform(id: string, categoryMap: Map): string { + return categoryMap.get(id) || '—'; + } + +} diff --git a/uniplanWeb/src/app/core/shared/pipes/faculty-name-pipe.spec.ts b/uniplanWeb/src/app/core/shared/pipes/faculty/faculty-name-pipe.spec.ts similarity index 73% rename from uniplanWeb/src/app/core/shared/pipes/faculty-name-pipe.spec.ts rename to uniplanWeb/src/app/core/shared/pipes/faculty/faculty-name-pipe.spec.ts index bd0e57e..7d273cf 100644 --- a/uniplanWeb/src/app/core/shared/pipes/faculty-name-pipe.spec.ts +++ b/uniplanWeb/src/app/core/shared/pipes/faculty/faculty-name-pipe.spec.ts @@ -1,4 +1,4 @@ -import { FacultyNamePipe } from './faculty-name-pipe'; +import { FacultyNamePipe } from "./faculty-name-pipe"; describe('FacultyNamePipe', () => { it('create an instance', () => { diff --git a/uniplanWeb/src/app/core/shared/pipes/faculty-name-pipe.ts b/uniplanWeb/src/app/core/shared/pipes/faculty/faculty-name-pipe.ts similarity index 100% rename from uniplanWeb/src/app/core/shared/pipes/faculty-name-pipe.ts rename to uniplanWeb/src/app/core/shared/pipes/faculty/faculty-name-pipe.ts diff --git a/uniplanWeb/src/app/features/room/room-service.ts b/uniplanWeb/src/app/features/room/room-service.ts index d9c07c5..5aeecbe 100644 --- a/uniplanWeb/src/app/features/room/room-service.ts +++ b/uniplanWeb/src/app/features/room/room-service.ts @@ -1,7 +1,6 @@ import { Injectable, inject } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { map, Observable, shareReplay } from 'rxjs'; -import { RoomViewModel } from '../../core/interfaces/room-view-model'; import { RoomElm } from '../../core/interfaces/room-elm'; @@ -14,7 +13,7 @@ export class RoomService { http = inject(HttpClient); - getRooms(): Observable { + getRooms(): Observable { return this.http.get(this.apiUrl).pipe( map(rooms => rooms ?? []), map(rooms => @@ -22,6 +21,7 @@ export class RoomService { id: room.id, facultyId: room.facultyId, roomNumber: room.roomNumber, + categoryId: room.categoryId, position: index + 1, })) ), diff --git a/uniplanWeb/src/app/features/room/room-table/room-table.html b/uniplanWeb/src/app/features/room/room-table/room-table.html index 0c9c4df..d160e78 100644 --- a/uniplanWeb/src/app/features/room/room-table/room-table.html +++ b/uniplanWeb/src/app/features/room/room-table/room-table.html @@ -12,6 +12,12 @@ {{ 'room.room-number' | translate }} + + + {{ 'room.category-label' | translate }} + + + {{ 'features.actions-label' | translate }} @@ -38,10 +44,16 @@ {{ element.facultyId | facultyNamePipe: facultyMap }} - - {{ element.roomNumber }} + {{ element.roomNumber }} + + + + + + {{ element.categoryId | categoryDisplayPipe: categoryMap }} + diff --git a/uniplanWeb/src/app/features/room/room-table/room-table.scss b/uniplanWeb/src/app/features/room/room-table/room-table.scss index 3c2519f..bc17a36 100644 --- a/uniplanWeb/src/app/features/room/room-table/room-table.scss +++ b/uniplanWeb/src/app/features/room/room-table/room-table.scss @@ -65,10 +65,15 @@ td { } .col-room-number { - width: 260px; + width: 200px; border-right: 1px solid #e0e0e0; } +.col-categoryId { + width: 200px; +} + .col-actions { width: 150px; + border-left: 1px solid #e0e0e0; } \ No newline at end of file diff --git a/uniplanWeb/src/app/features/room/room-table/room-table.ts b/uniplanWeb/src/app/features/room/room-table/room-table.ts index e186334..afb04f0 100644 --- a/uniplanWeb/src/app/features/room/room-table/room-table.ts +++ b/uniplanWeb/src/app/features/room/room-table/room-table.ts @@ -8,7 +8,9 @@ import { TranslatePipe } from '@ngx-translate/core'; import { CommonModule } from '@angular/common'; import { FacultyService } from '../../faculty/faculty-service'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; -import { FacultyNamePipe } from '../../../core/shared/pipes/faculty-name-pipe'; +import { FacultyNamePipe } from '../../../core/shared/pipes/faculty/faculty-name-pipe'; +import { CategoryService } from '../../../services/category/category-service'; +import { CategoryDisplayPipe } from '../../../core/shared/pipes/category/category-display-pipe'; @Component({ selector: 'app-room-table', @@ -22,20 +24,24 @@ import { FacultyNamePipe } from '../../../core/shared/pipes/faculty-name-pipe'; MatDialogModule, TranslatePipe, CommonModule, - FacultyNamePipe + FacultyNamePipe, + CategoryDisplayPipe ], }) export class RoomTable { roomService = inject(RoomService); facultyService = inject(FacultyService); + categoryService = inject(CategoryService) facultyMap = new Map(); + categoryMap = new Map(); private destroyRef = inject(DestroyRef); displayedColumns: string[] = [ 'position', 'facultyId', 'roomNumber', + 'categoryId', 'actions', ]; @@ -43,6 +49,7 @@ export class RoomTable { ngOnInit() { this.loadFaculties(); + this.loadCategories(); } loadFaculties(): void { @@ -52,4 +59,14 @@ export class RoomTable { this.facultyMap = new Map(faculties.map((f) => [f.id, f.facultyName])); }); } + + loadCategories(): void { + this.categoryService.getCategories() + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe((categories) => { + this.categoryMap = new Map( + categories.map((c) => [c.id, `${c.roomType} (${c.capacity})`]) + ); + }); + } } diff --git a/uniplanWeb/src/app/services/category/category-service.spec.ts b/uniplanWeb/src/app/services/category/category-service.spec.ts new file mode 100644 index 0000000..240b9ee --- /dev/null +++ b/uniplanWeb/src/app/services/category/category-service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { CategoryService } from './category-service'; + +describe('CategoryService', () => { + let service: CategoryService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(CategoryService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/uniplanWeb/src/app/services/category/category-service.ts b/uniplanWeb/src/app/services/category/category-service.ts new file mode 100644 index 0000000..d2e2527 --- /dev/null +++ b/uniplanWeb/src/app/services/category/category-service.ts @@ -0,0 +1,27 @@ +import { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { Observable,map } from 'rxjs'; +import { CategoryElm } from '../../core/interfaces/category-elm'; +import { API_ENDPOINTS } from '../../config/endpoints'; + +@Injectable({ + providedIn: 'root' +}) + +export class CategoryService { + +constructor(private http: HttpClient) {} + + getCategories(): Observable { + return this.http.get(API_ENDPOINTS.categories).pipe( + map((categories) => + categories.map((category, index) => ({ + id: category.id, + roomType: category.roomType, + capacity: category.capacity, + position: index + 1, + })) + ) + ); + } +} diff --git a/uniplanWeb/src/app/services/login-auth-service.spec.ts b/uniplanWeb/src/app/services/login/login-auth-service.spec.ts similarity index 100% rename from uniplanWeb/src/app/services/login-auth-service.spec.ts rename to uniplanWeb/src/app/services/login/login-auth-service.spec.ts diff --git a/uniplanWeb/src/app/services/login-auth-service.ts b/uniplanWeb/src/app/services/login/login-auth-service.ts similarity index 100% rename from uniplanWeb/src/app/services/login-auth-service.ts rename to uniplanWeb/src/app/services/login/login-auth-service.ts From ad0d99f65d5848f1c5dcd3582cc6b2fd810db000 Mon Sep 17 00:00:00 2001 From: PIPetkova19 Date: Thu, 23 Jul 2026 11:28:51 +0300 Subject: [PATCH 2/4] Fix merge conflicts --- uniplanWeb/public/i18n/bg.json | 2 +- uniplanWeb/public/i18n/en.json | 2 +- .../src/app/features/room/room-service.ts | 2 +- .../features/room/room-table/room-table.html | 2 +- .../features/room/room-table/room-table.scss | 17 +++++++++-------- .../app/features/room/room-table/room-table.ts | 11 +++++------ 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/uniplanWeb/public/i18n/bg.json b/uniplanWeb/public/i18n/bg.json index c66b3ad..40af598 100644 --- a/uniplanWeb/public/i18n/bg.json +++ b/uniplanWeb/public/i18n/bg.json @@ -14,7 +14,7 @@ "room": { "room-number": "Номер на стая", "no-rooms": "Няма записани стаи", - "category-label":"Тип на стая/Капацитет" + "category-label":"Тип на стая/Капацитет", "add": { "title": "Добави стая", "failed": "Неуспешно добавяне на стаята." diff --git a/uniplanWeb/public/i18n/en.json b/uniplanWeb/public/i18n/en.json index db07db5..19e8cec 100644 --- a/uniplanWeb/public/i18n/en.json +++ b/uniplanWeb/public/i18n/en.json @@ -14,7 +14,7 @@ "room": { "room-number": "Room number", "no-rooms": "No rooms", - "category-label": "Room Type/Capacity" + "category-label": "Room Type/Capacity", "add": { "title": "Add room", "failed": "Failed to add room." diff --git a/uniplanWeb/src/app/features/room/room-service.ts b/uniplanWeb/src/app/features/room/room-service.ts index 7bd7ec1..4091651 100644 --- a/uniplanWeb/src/app/features/room/room-service.ts +++ b/uniplanWeb/src/app/features/room/room-service.ts @@ -14,7 +14,7 @@ export class RoomService { private http = inject(HttpClient); - getRooms(): Observable { + getRooms(): Observable { return this.http.get(API_ENDPOINTS.rooms).pipe( map(rooms => rooms ?? []), map(rooms => diff --git a/uniplanWeb/src/app/features/room/room-table/room-table.html b/uniplanWeb/src/app/features/room/room-table/room-table.html index 97c2d2e..d160e78 100644 --- a/uniplanWeb/src/app/features/room/room-table/room-table.html +++ b/uniplanWeb/src/app/features/room/room-table/room-table.html @@ -41,7 +41,7 @@ - {{ element.facultyId | facultyNamePipe: facultyMap() }} + {{ element.facultyId | facultyNamePipe: facultyMap }} diff --git a/uniplanWeb/src/app/features/room/room-table/room-table.scss b/uniplanWeb/src/app/features/room/room-table/room-table.scss index bc17a36..bef3d54 100644 --- a/uniplanWeb/src/app/features/room/room-table/room-table.scss +++ b/uniplanWeb/src/app/features/room/room-table/room-table.scss @@ -8,11 +8,12 @@ .table-header { width: 100%; table-layout: fixed; + padding-right: 14px; } .scrollable-body { max-height: 510px; - overflow-y: auto; + overflow-y: scroll; overflow-x: hidden; } @@ -55,25 +56,25 @@ td { } .col-position { - width: 100px; + width: 10%; border-right: 1px solid #e0e0e0; } .col-name { - width: 200px; + width: 25%; border-right: 1px solid #e0e0e0; } .col-room-number { - width: 200px; + width: 20%; border-right: 1px solid #e0e0e0; } -.col-categoryId { - width: 200px; +.col-category { + width: 30%; + border-right: 1px solid #e0e0e0; } .col-actions { - width: 150px; - border-left: 1px solid #e0e0e0; + width: 15%; } \ No newline at end of file diff --git a/uniplanWeb/src/app/features/room/room-table/room-table.ts b/uniplanWeb/src/app/features/room/room-table/room-table.ts index 7eaa6a3..f9d22bb 100644 --- a/uniplanWeb/src/app/features/room/room-table/room-table.ts +++ b/uniplanWeb/src/app/features/room/room-table/room-table.ts @@ -8,8 +8,10 @@ import { TranslatePipe } from '@ngx-translate/core'; import { CommonModule } from '@angular/common'; import { FacultyService } from '../../faculty/faculty-service'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; -import { FacultyNamePipe } from '../../../core/shared/pipes/faculty-name-pipe'; +import { FacultyNamePipe } from '../../../core/shared/pipes/faculty/faculty-name-pipe'; import { startWith, switchMap } from 'rxjs'; +import { CategoryDisplayPipe } from '../../../core/shared/pipes/category/category-display-pipe'; +import { CategoryService } from '../../../services/category/category-service'; @Component({ selector: 'app-room-table', @@ -49,16 +51,13 @@ export class RoomTable implements OnInit { this.loadCategories(); } - data$ = this.roomService.refreshNeeded.pipe( - startWith(void 0), - switchMap(() => this.roomService.getRooms()) - ); + data$ = this.roomService.getRooms(); loadFaculties(): void { this.facultyService.getFaculties() .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe((faculties) => { - this.facultyMap.set(new Map(faculties.map((f) => [f.id, f.facultyName]))); + this.facultyMap = new Map(faculties.map((f) => [f.id, f.facultyName])); }); } From 2e3c3d88d73e9d851d3514daf8466c75bc6bf0af Mon Sep 17 00:00:00 2001 From: PIPetkova19 Date: Thu, 23 Jul 2026 12:56:08 +0300 Subject: [PATCH 3/4] Remove unused imports, use inject instead of constructor, fix imports --- uniplanWeb/src/app/core/interfaces/room-elm.ts | 2 -- uniplanWeb/src/app/features/room/room-table/room-table.ts | 3 +-- uniplanWeb/src/app/services/category/category-service.ts | 5 ++--- uniplanWeb/src/app/services/login/login-auth-service.spec.ts | 2 +- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/uniplanWeb/src/app/core/interfaces/room-elm.ts b/uniplanWeb/src/app/core/interfaces/room-elm.ts index 3d39caa..7bf34f4 100644 --- a/uniplanWeb/src/app/core/interfaces/room-elm.ts +++ b/uniplanWeb/src/app/core/interfaces/room-elm.ts @@ -1,5 +1,3 @@ -import { CategoryElm } from "./category-elm"; - export interface RoomElm { id: string; facultyId: string; diff --git a/uniplanWeb/src/app/features/room/room-table/room-table.ts b/uniplanWeb/src/app/features/room/room-table/room-table.ts index f9d22bb..9044023 100644 --- a/uniplanWeb/src/app/features/room/room-table/room-table.ts +++ b/uniplanWeb/src/app/features/room/room-table/room-table.ts @@ -1,4 +1,4 @@ -import { Component, inject, ChangeDetectionStrategy, DestroyRef, OnInit, signal } from '@angular/core'; +import { Component, inject, ChangeDetectionStrategy, DestroyRef, OnInit } from '@angular/core'; import { RoomService } from '../room-service'; import { MatButtonModule } from '@angular/material/button'; import { MatIconModule } from '@angular/material/icon'; @@ -9,7 +9,6 @@ import { CommonModule } from '@angular/common'; import { FacultyService } from '../../faculty/faculty-service'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { FacultyNamePipe } from '../../../core/shared/pipes/faculty/faculty-name-pipe'; -import { startWith, switchMap } from 'rxjs'; import { CategoryDisplayPipe } from '../../../core/shared/pipes/category/category-display-pipe'; import { CategoryService } from '../../../services/category/category-service'; diff --git a/uniplanWeb/src/app/services/category/category-service.ts b/uniplanWeb/src/app/services/category/category-service.ts index d2e2527..a27ea1a 100644 --- a/uniplanWeb/src/app/services/category/category-service.ts +++ b/uniplanWeb/src/app/services/category/category-service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@angular/core'; +import { Injectable, inject } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable,map } from 'rxjs'; import { CategoryElm } from '../../core/interfaces/category-elm'; @@ -9,8 +9,7 @@ import { API_ENDPOINTS } from '../../config/endpoints'; }) export class CategoryService { - -constructor(private http: HttpClient) {} + http = inject(HttpClient); getCategories(): Observable { return this.http.get(API_ENDPOINTS.categories).pipe( diff --git a/uniplanWeb/src/app/services/login/login-auth-service.spec.ts b/uniplanWeb/src/app/services/login/login-auth-service.spec.ts index 66e46d1..5bc3bbf 100644 --- a/uniplanWeb/src/app/services/login/login-auth-service.spec.ts +++ b/uniplanWeb/src/app/services/login/login-auth-service.spec.ts @@ -1,7 +1,7 @@ import { TestBed } from '@angular/core/testing'; import { translateTestingProviders } from '@testing/translate-testing'; -import { LoginAuthService } from '../services/login-auth-service'; +import { LoginAuthService } from './login-auth-service'; describe('LoginAuthService', () => { let service: LoginAuthService; From 8e741d8b96601a76d0f24304cb300a880dbf1b82 Mon Sep 17 00:00:00 2001 From: PIPetkova19 Date: Tue, 28 Jul 2026 09:34:01 +0300 Subject: [PATCH 4/4] Rename interfaces, add position field, added refreshNeeded where needed --- .../core/interfaces/{category-elm.ts => category.ts} | 3 ++- uniplanWeb/src/app/core/interfaces/room-elm.ts | 6 ------ uniplanWeb/src/app/core/interfaces/room.ts | 7 +++++++ uniplanWeb/src/app/features/room/room-service.ts | 10 +++++----- .../src/app/features/room/room-table/room-table.ts | 7 +++++-- .../src/app/services/category/category-service.ts | 6 +++--- 6 files changed, 22 insertions(+), 17 deletions(-) rename uniplanWeb/src/app/core/interfaces/{category-elm.ts => category.ts} (54%) delete mode 100644 uniplanWeb/src/app/core/interfaces/room-elm.ts create mode 100644 uniplanWeb/src/app/core/interfaces/room.ts diff --git a/uniplanWeb/src/app/core/interfaces/category-elm.ts b/uniplanWeb/src/app/core/interfaces/category.ts similarity index 54% rename from uniplanWeb/src/app/core/interfaces/category-elm.ts rename to uniplanWeb/src/app/core/interfaces/category.ts index 1de858f..c1b25eb 100644 --- a/uniplanWeb/src/app/core/interfaces/category-elm.ts +++ b/uniplanWeb/src/app/core/interfaces/category.ts @@ -1,5 +1,6 @@ -export interface CategoryElm { +export interface Category { id: string; roomType: string; capacity: number; + position: number; } \ No newline at end of file diff --git a/uniplanWeb/src/app/core/interfaces/room-elm.ts b/uniplanWeb/src/app/core/interfaces/room-elm.ts deleted file mode 100644 index 7bf34f4..0000000 --- a/uniplanWeb/src/app/core/interfaces/room-elm.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface RoomElm { - id: string; - facultyId: string; - roomNumber: string, - categoryId: string; -} diff --git a/uniplanWeb/src/app/core/interfaces/room.ts b/uniplanWeb/src/app/core/interfaces/room.ts new file mode 100644 index 0000000..adfa581 --- /dev/null +++ b/uniplanWeb/src/app/core/interfaces/room.ts @@ -0,0 +1,7 @@ +export interface Room { + id: string; + facultyId: string; + roomNumber: string; + categoryId: string; + position: number; +} diff --git a/uniplanWeb/src/app/features/room/room-service.ts b/uniplanWeb/src/app/features/room/room-service.ts index 4091651..077a9d3 100644 --- a/uniplanWeb/src/app/features/room/room-service.ts +++ b/uniplanWeb/src/app/features/room/room-service.ts @@ -1,7 +1,7 @@ import { Injectable, inject } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { map, Observable, shareReplay } from 'rxjs'; -import { RoomElm } from '../../core/interfaces/room-elm'; +import { Room } from '../../core/interfaces/room'; import { Subject } from 'rxjs'; import { API_ENDPOINTS } from '../../config/endpoints'; @@ -14,8 +14,8 @@ export class RoomService { private http = inject(HttpClient); - getRooms(): Observable { - return this.http.get(API_ENDPOINTS.rooms).pipe( + getRooms(): Observable { + return this.http.get(API_ENDPOINTS.rooms).pipe( map(rooms => rooms ?? []), map(rooms => rooms.map((room, index) => ({ @@ -33,8 +33,8 @@ export class RoomService { createRoom(room: { roomNumber: string; facultyId: string; - }): Observable { - return this.http.post(`${(API_ENDPOINTS.rooms)}`, room).pipe( + }): Observable { + return this.http.post(`${(API_ENDPOINTS.rooms)}`, room).pipe( map((res) => { this.refreshNeeded.next(); return res; diff --git a/uniplanWeb/src/app/features/room/room-table/room-table.ts b/uniplanWeb/src/app/features/room/room-table/room-table.ts index 9044023..2c5cc68 100644 --- a/uniplanWeb/src/app/features/room/room-table/room-table.ts +++ b/uniplanWeb/src/app/features/room/room-table/room-table.ts @@ -11,7 +11,7 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { FacultyNamePipe } from '../../../core/shared/pipes/faculty/faculty-name-pipe'; import { CategoryDisplayPipe } from '../../../core/shared/pipes/category/category-display-pipe'; import { CategoryService } from '../../../services/category/category-service'; - +import { startWith, switchMap } from 'rxjs'; @Component({ selector: 'app-room-table', templateUrl: './room-table.html', @@ -50,7 +50,10 @@ export class RoomTable implements OnInit { this.loadCategories(); } - data$ = this.roomService.getRooms(); + data$ = this.roomService.refreshNeeded.pipe( + startWith(void 0), + switchMap(() => this.roomService.getRooms()) + ); loadFaculties(): void { this.facultyService.getFaculties() diff --git a/uniplanWeb/src/app/services/category/category-service.ts b/uniplanWeb/src/app/services/category/category-service.ts index a27ea1a..f243b7d 100644 --- a/uniplanWeb/src/app/services/category/category-service.ts +++ b/uniplanWeb/src/app/services/category/category-service.ts @@ -1,7 +1,7 @@ import { Injectable, inject } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable,map } from 'rxjs'; -import { CategoryElm } from '../../core/interfaces/category-elm'; +import { Category } from '../../core/interfaces/category'; import { API_ENDPOINTS } from '../../config/endpoints'; @Injectable({ @@ -11,8 +11,8 @@ import { API_ENDPOINTS } from '../../config/endpoints'; export class CategoryService { http = inject(HttpClient); - getCategories(): Observable { - return this.http.get(API_ENDPOINTS.categories).pipe( + getCategories(): Observable { + return this.http.get(API_ENDPOINTS.categories).pipe( map((categories) => categories.map((category, index) => ({ id: category.id,