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..903d103 100644 --- a/uniplanWeb/src/app/core/shared/navmenu-component/navmenu-component.ts +++ b/uniplanWeb/src/app/core/shared/navmenu-component/navmenu-component.ts @@ -1,4 +1,4 @@ -import { Component, HostListener, OnInit, ChangeDetectionStrategy } from '@angular/core'; +import { Component, HostListener, OnInit, ChangeDetectionStrategy, inject } from '@angular/core'; import { CommonModule } from '@angular/common'; import { RouterLink, RouterLinkActive } from '@angular/router'; import { TranslatePipe } from '@ngx-translate/core'; @@ -17,7 +17,8 @@ export class NavmenuComponent implements OnInit { isSidebarCollapsed = false; isMobileView = window.innerWidth <= 768; - constructor(public authService: LoginAuthService) {} + public authService = inject(LoginAuthService); + public viewService = inject(ViewService); ngOnInit(): void { this.checkViewport(); diff --git a/uniplanWeb/src/app/features/faculty/faculty-add-form/faculty-add-form.ts b/uniplanWeb/src/app/features/faculty/faculty-add-form/faculty-add-form.ts index 8b75138..0bcc189 100644 --- a/uniplanWeb/src/app/features/faculty/faculty-add-form/faculty-add-form.ts +++ b/uniplanWeb/src/app/features/faculty/faculty-add-form/faculty-add-form.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core'; +import { Component, OnInit, ChangeDetectionStrategy, inject } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { MatDialogModule, MatDialogRef } from '@angular/material/dialog'; import { MatFormField, MatLabel } from '@angular/material/form-field'; @@ -37,11 +37,9 @@ export class FacultyAddForm implements OnInit { universityId = ''; universities: UniversityElm[] = []; - constructor( - private dialogRef: MatDialogRef, - private facultyService: FacultyService, - private universityService: UniversityService - ) { } + private dialogRef = inject(MatDialogRef); + private facultyService = inject(FacultyService); + private universityService = inject(UniversityService); ngOnInit(): void { this.universityService.getAllUniversities().subscribe({ diff --git a/uniplanWeb/src/app/features/faculty/faculty-delete-form/faculty-delete-form.ts b/uniplanWeb/src/app/features/faculty/faculty-delete-form/faculty-delete-form.ts index 853c1a5..de3d875 100644 --- a/uniplanWeb/src/app/features/faculty/faculty-delete-form/faculty-delete-form.ts +++ b/uniplanWeb/src/app/features/faculty/faculty-delete-form/faculty-delete-form.ts @@ -1,4 +1,4 @@ -import { Component, Inject, ChangeDetectionStrategy } from '@angular/core'; +import {Component, ChangeDetectionStrategy, inject} from '@angular/core'; import { DeleteForm } from '../../../core/shared/delete-form/delete-form'; import { MAT_DIALOG_DATA, @@ -16,12 +16,10 @@ import { TranslatePipe } from '@ngx-translate/core'; imports: [DeleteForm, MatDialogModule, TranslatePipe], }) export class FacultyDeleteForm { - constructor( - private facultyService: FacultyService, - private dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) - public data: { id: string; facultyName: string } - ) { } + + private facultyService = inject(FacultyService); + private dialogRef = inject(MatDialogRef); + public data = inject<{ id: string; facultyName: string }>(MAT_DIALOG_DATA); deleteFaculty(): void { this.facultyService.deleteFaculty(this.data.id).subscribe({ diff --git a/uniplanWeb/src/app/features/faculty/faculty-edit/faculty-edit.ts b/uniplanWeb/src/app/features/faculty/faculty-edit/faculty-edit.ts index 41636a6..33b44fc 100644 --- a/uniplanWeb/src/app/features/faculty/faculty-edit/faculty-edit.ts +++ b/uniplanWeb/src/app/features/faculty/faculty-edit/faculty-edit.ts @@ -1,4 +1,4 @@ -import { Component, Inject, ChangeDetectionStrategy } from '@angular/core'; +import { Component, ChangeDetectionStrategy, inject } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { MatDialogModule, @@ -32,25 +32,19 @@ import { TranslatePipe } from '@ngx-translate/core'; ], }) export class FacultyEdit { - facultyName = ''; - location = ''; - universityId = ''; - constructor( - private dialogRef: MatDialogRef, - private facultyService: FacultyService, - @Inject(MAT_DIALOG_DATA) - public data: { - id: string; - facultyName: string; - location: string; - universityId: string; - } - ) { - this.facultyName = data.facultyName; - this.location = data.location; - this.universityId = data.universityId; - } + private dialogRef = inject(MatDialogRef); + private facultyService = inject(FacultyService); + public data = inject<{ + id: string; + facultyName: string; + location: string; + universityId: string; + }>(MAT_DIALOG_DATA); + + facultyName = this.data.facultyName; + location = this.data.location; + universityId = this.data.universityId; save() { if (!this.facultyName.trim()) { diff --git a/uniplanWeb/src/app/features/faculty/faculty-options/faculty-options.ts b/uniplanWeb/src/app/features/faculty/faculty-options/faculty-options.ts index 78bb40f..f0c2b48 100644 --- a/uniplanWeb/src/app/features/faculty/faculty-options/faculty-options.ts +++ b/uniplanWeb/src/app/features/faculty/faculty-options/faculty-options.ts @@ -1,5 +1,5 @@ -import { Component, ChangeDetectionStrategy } from '@angular/core'; +import { Component, ChangeDetectionStrategy, inject } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { MatIconModule } from '@angular/material/icon'; import { MatTableModule } from '@angular/material/table'; @@ -20,7 +20,7 @@ import { AddButton } from '../../../core/shared/add-button/add-button'; ], }) export class FacultyOptions { - constructor(private dialog: MatDialog) { } + private dialog = inject(MatDialog); openAddForm() { this.dialog.open(FacultyAddForm, { diff --git a/uniplanWeb/src/app/features/faculty/faculty-service.ts b/uniplanWeb/src/app/features/faculty/faculty-service.ts index 1c423f0..b78eb75 100644 --- a/uniplanWeb/src/app/features/faculty/faculty-service.ts +++ b/uniplanWeb/src/app/features/faculty/faculty-service.ts @@ -1,5 +1,5 @@ import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { Injectable, inject } from '@angular/core'; import { map, Observable, Subject } from 'rxjs'; import { FacultyElm } from '../../core/interfaces/faculty-elm'; import {API_ENDPOINTS} from '../../config/endpoints'; @@ -10,7 +10,7 @@ import {API_ENDPOINTS} from '../../config/endpoints'; export class FacultyService { refreshNeeded = new Subject(); - constructor(private http: HttpClient) {} + private http = inject(HttpClient); getFaculties(): Observable { return this.http.get(API_ENDPOINTS.faculties).pipe( diff --git a/uniplanWeb/src/app/features/faculty/faculty-table/faculty-table.ts b/uniplanWeb/src/app/features/faculty/faculty-table/faculty-table.ts index 11f4e80..989e515 100644 --- a/uniplanWeb/src/app/features/faculty/faculty-table/faculty-table.ts +++ b/uniplanWeb/src/app/features/faculty/faculty-table/faculty-table.ts @@ -1,5 +1,5 @@ -import { Component, ChangeDetectionStrategy, signal } from '@angular/core'; +import { Component, ChangeDetectionStrategy, inject } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { MatIconModule } from '@angular/material/icon'; import { MatTableModule } from '@angular/material/table'; @@ -32,10 +32,8 @@ export class FacultyTable { ]; dataSource = signal([]); - constructor( - private facultyService: FacultyService, - private dialog: MatDialog - ) { } + private facultyService = inject(FacultyService); + private dialog = inject(MatDialog); ngOnInit(): void { this.loadFaculties(); diff --git a/uniplanWeb/src/app/features/major/major-add-form/major-add-form.ts b/uniplanWeb/src/app/features/major/major-add-form/major-add-form.ts index 997af68..c86d3cc 100644 --- a/uniplanWeb/src/app/features/major/major-add-form/major-add-form.ts +++ b/uniplanWeb/src/app/features/major/major-add-form/major-add-form.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core'; +import { Component, OnInit, ChangeDetectionStrategy, inject } from '@angular/core'; import { AddForm } from '../../../core/shared/add-form/add-form'; import { MatDialogModule, MatDialogRef } from '@angular/material/dialog'; import { @@ -40,11 +40,9 @@ export class MajorAddForm implements OnInit { faculties: FacultyElm[] = []; - constructor( - private dialogRef: MatDialogRef, - private majorService: MajorService, - private facultyService: FacultyService - ) { } + private dialogRef = inject(MatDialogRef); + private majorService = inject(MajorService); + private facultyService = inject(FacultyService); ngOnInit(): void { this.facultyService.getFaculties().subscribe({ diff --git a/uniplanWeb/src/app/features/major/major-delete-form/major-delete-form.ts b/uniplanWeb/src/app/features/major/major-delete-form/major-delete-form.ts index 8daf4d0..a11d819 100644 --- a/uniplanWeb/src/app/features/major/major-delete-form/major-delete-form.ts +++ b/uniplanWeb/src/app/features/major/major-delete-form/major-delete-form.ts @@ -1,4 +1,4 @@ -import { Component, Inject, ChangeDetectionStrategy } from '@angular/core'; +import { Component, ChangeDetectionStrategy, inject } from '@angular/core'; import { DeleteForm } from '../../../core/shared/delete-form/delete-form'; import { MAT_DIALOG_DATA, @@ -18,12 +18,10 @@ import { TranslatePipe } from '@ngx-translate/core'; TranslatePipe], }) export class MajorDeleteForm { - constructor( - private majorService: MajorService, - private dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) - public data: { id: string; name: string } - ) {} + + private majorService = inject(MajorService); + private dialogRef = inject(MatDialogRef); + public data = inject<{ id: string; courseId: string; name: string }>(MAT_DIALOG_DATA); deleteMajor(): void { this.majorService diff --git a/uniplanWeb/src/app/features/major/major-edit-form/major-edit-form.ts b/uniplanWeb/src/app/features/major/major-edit-form/major-edit-form.ts index f3ee936..4c8522d 100644 --- a/uniplanWeb/src/app/features/major/major-edit-form/major-edit-form.ts +++ b/uniplanWeb/src/app/features/major/major-edit-form/major-edit-form.ts @@ -1,4 +1,4 @@ -import { Component, Inject, OnInit, ChangeDetectionStrategy } from '@angular/core'; +import { Component, OnInit, ChangeDetectionStrategy, inject } from '@angular/core'; import { EditForm } from '../../../core/shared/edit-form/edit-form'; import { MatFormField, MatLabel } from '@angular/material/form-field'; import { @@ -32,25 +32,20 @@ import { TranslatePipe } from '@ngx-translate/core'; TranslatePipe], }) export class MajorEditForm implements OnInit { - majorName = ''; - facultyId = ''; faculties: FacultyElm[] = []; - constructor( - private dialogRef: MatDialogRef, - private majorService: MajorService, - private facultyService: FacultyService, - @Inject(MAT_DIALOG_DATA) - public data: { - id: string; - majorName: string; - facultyId?: string; - } - ) { - this.majorName = data.majorName; - this.facultyId = data.facultyId || ''; - } + private dialogRef = inject(MatDialogRef); + private majorService = inject(MajorService); + private facultyService = inject(FacultyService); + public data = inject<{ + id: string; + majorName: string; + facultyId?: string; + }>(MAT_DIALOG_DATA); + + majorName = this.data.majorName; + facultyId = this.data.facultyId || ''; ngOnInit(): void { this.facultyService.getFaculties().subscribe({ diff --git a/uniplanWeb/src/app/features/major/major-options/major-options.ts b/uniplanWeb/src/app/features/major/major-options/major-options.ts index e5a0660..6c81952 100644 --- a/uniplanWeb/src/app/features/major/major-options/major-options.ts +++ b/uniplanWeb/src/app/features/major/major-options/major-options.ts @@ -1,4 +1,4 @@ -import { Component, ChangeDetectionStrategy } from '@angular/core'; +import { Component, ChangeDetectionStrategy, inject } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; import { MajorAddForm } from '../major-add-form/major-add-form'; @@ -20,7 +20,7 @@ import { AddButton } from '../../../core/shared/add-button/add-button'; styleUrl: './major-options.scss', }) export class MajorOptions { - constructor(private dialog: MatDialog) {} + private dialog = inject(MatDialog); openAddForm() { this.dialog.open(MajorAddForm, { diff --git a/uniplanWeb/src/app/features/major/major-service.ts b/uniplanWeb/src/app/features/major/major-service.ts index c7a4626..5db3746 100644 --- a/uniplanWeb/src/app/features/major/major-service.ts +++ b/uniplanWeb/src/app/features/major/major-service.ts @@ -1,5 +1,5 @@ import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { Injectable, inject } from '@angular/core'; import { map, Observable, Subject, switchMap } from 'rxjs'; import { MajorElm } from '../../core/interfaces/major-elm'; import {environment} from '../../../environments/environment'; @@ -11,7 +11,7 @@ import {API_ENDPOINTS} from '../../config/endpoints'; export class MajorService { refreshNeeded = new Subject(); - constructor(private http: HttpClient) {} + private http = inject(HttpClient); getMajors(): Observable { return this.http.get(API_ENDPOINTS.majors).pipe( diff --git a/uniplanWeb/src/app/features/major/major-table/major-table.ts b/uniplanWeb/src/app/features/major/major-table/major-table.ts index 23b9b4e..56f1f48 100644 --- a/uniplanWeb/src/app/features/major/major-table/major-table.ts +++ b/uniplanWeb/src/app/features/major/major-table/major-table.ts @@ -1,5 +1,5 @@ -import { Component, Input, OnInit, ChangeDetectionStrategy, signal } from '@angular/core'; +import { Component, Input, OnInit, ChangeDetectionStrategy, inject } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { MatIconModule } from '@angular/material/icon'; import { MatTableModule } from '@angular/material/table'; @@ -36,11 +36,9 @@ export class MajorTable implements OnInit { @Input() type: string = ''; @Input() subtype: string = ''; - constructor( - private dialog: MatDialog, - private service: MajorService, - private facultyService: FacultyService - ) { } + private dialog = inject(MatDialog); + private service = inject(MajorService); + private facultyService = inject(FacultyService); ngOnInit(): void { this.loadMajors(); diff --git a/uniplanWeb/src/app/features/student/student-add-form/student-add-form.ts b/uniplanWeb/src/app/features/student/student-add-form/student-add-form.ts index cf22217..dad4e6d 100644 --- a/uniplanWeb/src/app/features/student/student-add-form/student-add-form.ts +++ b/uniplanWeb/src/app/features/student/student-add-form/student-add-form.ts @@ -1,4 +1,4 @@ -import { Component, ChangeDetectionStrategy } from '@angular/core'; +import { Component, ChangeDetectionStrategy, inject } from '@angular/core'; import { AddForm } from '../../../core/shared/add-form/add-form'; import { MatDialogModule, MatDialogRef } from '@angular/material/dialog'; import { @@ -32,7 +32,7 @@ export class StudentAddForm { course = ''; type = ''; - constructor(private dialogRef: MatDialogRef) { } + private dialogRef = inject(MatDialogRef); save() { if (!this.studentName.trim()) { diff --git a/uniplanWeb/src/app/features/student/student-options/student-options.ts b/uniplanWeb/src/app/features/student/student-options/student-options.ts index 04b7c24..469964c 100644 --- a/uniplanWeb/src/app/features/student/student-options/student-options.ts +++ b/uniplanWeb/src/app/features/student/student-options/student-options.ts @@ -1,4 +1,4 @@ -import { Component, ChangeDetectionStrategy } from '@angular/core'; +import { Component, ChangeDetectionStrategy, inject } from '@angular/core'; import { AddButton } from '../../../core/shared/add-button/add-button'; import { MatDialog } from '@angular/material/dialog'; import { StudentAddForm } from '../student-add-form/student-add-form'; @@ -11,7 +11,7 @@ import { StudentAddForm } from '../student-add-form/student-add-form'; styleUrl: './student-options.scss', }) export class StudentOptions { - constructor(private dialog: MatDialog) {} + private dialog = inject(MatDialog); openAddForm() { this.dialog.open(StudentAddForm, { diff --git a/uniplanWeb/src/app/features/university/university-service.ts b/uniplanWeb/src/app/features/university/university-service.ts index 0ac1336..c649e7c 100644 --- a/uniplanWeb/src/app/features/university/university-service.ts +++ b/uniplanWeb/src/app/features/university/university-service.ts @@ -1,5 +1,5 @@ import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { Injectable, inject } from '@angular/core'; import { Observable } from 'rxjs'; import {API_ENDPOINTS} from '../../config/endpoints'; @@ -16,7 +16,9 @@ export interface UniversityElm { providedIn: 'root', }) export class UniversityService { - constructor(private http: HttpClient) {} +private apiUrl = 'http://localhost:8080/api/universities'; + + private http = inject(HttpClient); getAllUniversities(): Observable { return this.http.get(API_ENDPOINTS.universities);