From 02e56769a4af3e7da2b32eb840bd827f514f5dad Mon Sep 17 00:00:00 2001 From: Djesika Vacheva Date: Sun, 21 Jun 2026 23:01:52 +0300 Subject: [PATCH 1/2] add type annotations --- .../src/app/core/shared/add-form/add-form.ts | 2 +- .../core/shared/delete-form/delete-form.ts | 2 +- .../app/core/shared/edit-form/edit-form.ts | 2 +- .../core/shared/filters-form/filters-form.ts | 2 +- .../core/shared/input-filter/input-filter.ts | 4 +-- .../app/core/shared/main-panel/main-panel.ts | 34 ++++++++++--------- .../core/shared/main-panel/view.service.ts | 6 ++-- .../navmenu-component/navmenu-component.ts | 6 ++-- .../faculty-add-form/faculty-add-form.ts | 16 ++++----- .../faculty-delete-form.ts | 4 +-- .../faculty/faculty-edit/faculty-edit.ts | 12 +++---- .../faculty-options/faculty-options.ts | 2 +- .../app/features/faculty/faculty-service.ts | 6 ++-- .../major/major-add-form/major-add-form.ts | 19 +++++------ .../major-delete-form/major-delete-form.ts | 8 ++--- .../major/major-edit-form/major-edit-form.ts | 15 ++++---- .../major/major-filters/major-filters.ts | 15 ++++---- .../major/major-options/major-options.ts | 2 +- .../src/app/features/major/major-service.ts | 24 ++++++------- .../student-add-form/student-add-form.ts | 15 ++++---- .../student-filters/student-filters.ts | 17 +++++----- .../student-options/student-options.ts | 2 +- .../student/student-table/student-table.ts | 25 +++++++------- .../features/university/university-service.ts | 2 +- .../src/app/services/login-auth-service.ts | 2 +- 25 files changed, 120 insertions(+), 124 deletions(-) diff --git a/uniplanWeb/src/app/core/shared/add-form/add-form.ts b/uniplanWeb/src/app/core/shared/add-form/add-form.ts index bb4b843..47436c2 100644 --- a/uniplanWeb/src/app/core/shared/add-form/add-form.ts +++ b/uniplanWeb/src/app/core/shared/add-form/add-form.ts @@ -14,5 +14,5 @@ import { MatInputModule } from '@angular/material/input'; export class AddForm { @Input() title: string = ''; - @Output() saveClicked = new EventEmitter(); + @Output() saveClicked :EventEmitter = new EventEmitter(); } diff --git a/uniplanWeb/src/app/core/shared/delete-form/delete-form.ts b/uniplanWeb/src/app/core/shared/delete-form/delete-form.ts index d0eb4b4..ec69eec 100644 --- a/uniplanWeb/src/app/core/shared/delete-form/delete-form.ts +++ b/uniplanWeb/src/app/core/shared/delete-form/delete-form.ts @@ -13,5 +13,5 @@ import { MatInputModule } from '@angular/material/input'; export class DeleteForm { @Input() title: string = ''; - @Output() deleteClicked = new EventEmitter(); + @Output() deleteClicked:EventEmitter = new EventEmitter(); } diff --git a/uniplanWeb/src/app/core/shared/edit-form/edit-form.ts b/uniplanWeb/src/app/core/shared/edit-form/edit-form.ts index 6947946..3a46523 100644 --- a/uniplanWeb/src/app/core/shared/edit-form/edit-form.ts +++ b/uniplanWeb/src/app/core/shared/edit-form/edit-form.ts @@ -12,5 +12,5 @@ import { MatDialogModule } from '@angular/material/dialog'; export class EditForm { @Input() title: string = ''; - @Output() saveClicked = new EventEmitter(); + @Output() saveClicked:EventEmitter = new EventEmitter(); } diff --git a/uniplanWeb/src/app/core/shared/filters-form/filters-form.ts b/uniplanWeb/src/app/core/shared/filters-form/filters-form.ts index 53e9bb0..feaec7f 100644 --- a/uniplanWeb/src/app/core/shared/filters-form/filters-form.ts +++ b/uniplanWeb/src/app/core/shared/filters-form/filters-form.ts @@ -13,7 +13,7 @@ import { MatSelectModule } from '@angular/material/select'; styleUrl: './filters-form.scss', }) export class FiltersForm { - @Input() label = ''; + @Input() label: string = ''; @Input() options: string[] = []; diff --git a/uniplanWeb/src/app/core/shared/input-filter/input-filter.ts b/uniplanWeb/src/app/core/shared/input-filter/input-filter.ts index 1f70c70..e768f4e 100644 --- a/uniplanWeb/src/app/core/shared/input-filter/input-filter.ts +++ b/uniplanWeb/src/app/core/shared/input-filter/input-filter.ts @@ -13,6 +13,6 @@ import { MatFormField, MatInputModule } from '@angular/material/input'; }) export class InputFilter { @Input() label: string = ''; - @Input() searchText = ''; - @Output() searchTextChange = new EventEmitter(); + @Input() searchText: string = ''; + @Output() searchTextChange: EventEmitter = new EventEmitter(); } diff --git a/uniplanWeb/src/app/core/shared/main-panel/main-panel.ts b/uniplanWeb/src/app/core/shared/main-panel/main-panel.ts index d205b1b..e6cef50 100644 --- a/uniplanWeb/src/app/core/shared/main-panel/main-panel.ts +++ b/uniplanWeb/src/app/core/shared/main-panel/main-panel.ts @@ -15,6 +15,8 @@ import { StudentFilters } from '../../../features/student/student-filters/studen import { MajorElm } from '../../interfaces/major-elm'; import { MajorService } from '../../../features/major/major-service'; import { FacultyService } from '../../../features/faculty/faculty-service'; +import {StudentElm} from '../../interfaces/student-elm'; +import {FacultyElm} from '../../interfaces/faculty-elm'; @Component({ selector: 'app-main-panel', @@ -34,33 +36,33 @@ import { FacultyService } from '../../../features/faculty/faculty-service'; styleUrl: './main-panel.scss', }) export class MainPanel { - currentView = 'home'; + currentView: string = 'home'; majors: MajorElm[] = []; - students = ELEMENT_STUDENT_DATA; + students: StudentElm[] = ELEMENT_STUDENT_DATA; - searchText = ''; - searchFacNum = ''; - searchMajor = ''; - selectedStudentSubtype = ''; + searchText: string = ''; + searchFacNum: string = ''; + searchMajor: string = ''; + selectedStudentSubtype: string = ''; studentSubtypes: string[] = []; - selectedFaculty = ''; - selectedType = ''; - selectedSubtype = ''; + selectedFaculty: string = ''; + selectedType: string = ''; + selectedSubtype: string = ''; faculties: { id: string; name: string }[] = []; types: string[] = []; subtypes: string[] = []; - private facultyMap = new Map(); + private facultyMap: Map = new Map(); constructor( private viewService: ViewService, private majorService: MajorService, private facultyService: FacultyService ) { - this.viewService.currentView$.subscribe((view) => { + this.viewService.currentView$.subscribe((view: string): void => { this.currentView = view; }); } @@ -69,20 +71,20 @@ export class MainPanel { this.loadMajorFilters(); this.loadStudentFilters(); - this.majorService.refreshNeeded.subscribe(() => { + this.majorService.refreshNeeded.subscribe((): void => { this.loadMajorFilters(); }); - this.viewService.currentView$.subscribe((view) => { + this.viewService.currentView$.subscribe((view: string): void => { this.currentView = view; }); } private loadMajorFilters(): void { - this.facultyService.getFaculties().subscribe((faculties) => { - this.facultyMap = new Map(faculties.map((f) => [f.id, f.facultyName])); + this.facultyService.getFaculties().subscribe((faculties: FacultyElm[]): void => { + this.facultyMap = new Map(faculties.map((f: FacultyElm): [any, any] => [f.id, f.facultyName])); - this.majorService.getMajors().subscribe((data) => { + this.majorService.getMajors().subscribe((data: MajorElm[]): void => { this.majors = data; const filterOptionsMajor = MajorTable.getFilterOptions( diff --git a/uniplanWeb/src/app/core/shared/main-panel/view.service.ts b/uniplanWeb/src/app/core/shared/main-panel/view.service.ts index bbc6220..3455f8a 100644 --- a/uniplanWeb/src/app/core/shared/main-panel/view.service.ts +++ b/uniplanWeb/src/app/core/shared/main-panel/view.service.ts @@ -3,10 +3,10 @@ import { BehaviorSubject } from 'rxjs'; @Injectable({ providedIn: 'root' }) export class ViewService { - private viewSubject = new BehaviorSubject('home'); - currentView$ = this.viewSubject.asObservable(); + private viewSubject: BehaviorSubject = new BehaviorSubject('home'); + currentView$: any = this.viewSubject.asObservable(); - public setView(view: string) { + public setView(view: string): void { this.viewSubject.next(view); } } 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 d28b20a..3fb0a58 100644 --- a/uniplanWeb/src/app/core/shared/navmenu-component/navmenu-component.ts +++ b/uniplanWeb/src/app/core/shared/navmenu-component/navmenu-component.ts @@ -13,8 +13,8 @@ import { LoginAuthService } from '../../../services/login-auth-service'; styleUrls: ['./navmenu-component.scss'], }) export class NavmenuComponent implements OnInit { - isSidebarCollapsed = false; - isMobileView = window.innerWidth <= 768; + isSidebarCollapsed: boolean = false; + isMobileView: boolean = window.innerWidth <= 768; constructor( public authService: LoginAuthService, @@ -31,7 +31,7 @@ export class NavmenuComponent implements OnInit { } private checkViewport(): void { - const isNowMobile = window.innerWidth <= 768; + const isNowMobile: boolean = window.innerWidth <= 768; if (this.isMobileView !== isNowMobile) { this.isMobileView = isNowMobile; } 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 81d040a..9451901 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 @@ -30,9 +30,9 @@ import { styleUrl: './faculty-add-form.scss', }) export class FacultyAddForm implements OnInit { - facultyName = ''; - location = ''; - universityId = ''; + facultyName: string = ''; + location: string = ''; + universityId: string = ''; universities: UniversityElm[] = []; constructor( @@ -43,16 +43,16 @@ export class FacultyAddForm implements OnInit { ngOnInit(): void { this.universityService.getAllUniversities().subscribe({ - next: (data) => { + next: (data: UniversityElm[]): void => { this.universities = data; }, - error: (err) => { + error: (err: any): void => { console.error('Failed to load universities', err); }, }); } - save() { + save(): void { if (!this.facultyName.trim()) { alert('Please enter faculty name.'); return; @@ -70,11 +70,11 @@ export class FacultyAddForm implements OnInit { }; this.facultyService.createFaculty(newFaculty).subscribe({ - next: (response) => { + next: (response: any): void => { console.log('Faculty created:', response); this.dialogRef.close(response); }, - error: (err) => { + error: (err: any): void => { console.error('Failed to add faculty', err); alert('Failed to add faculty.'); }, 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 6a27b3f..684a92e 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 @@ -24,10 +24,10 @@ export class FacultyDeleteForm { deleteFaculty(): void { this.facultyService.deleteFaculty(this.data.id).subscribe({ - next: () => { + next: (): void => { this.dialogRef.close(true); }, - error: () => { + error: (): void => { alert('Възникна грешка при изтриването на факултета.'); }, }); 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 da277c9..6885f0e 100644 --- a/uniplanWeb/src/app/features/faculty/faculty-edit/faculty-edit.ts +++ b/uniplanWeb/src/app/features/faculty/faculty-edit/faculty-edit.ts @@ -30,9 +30,9 @@ import { EditForm } from '../../../core/shared/edit-form/edit-form'; ], }) export class FacultyEdit { - facultyName = ''; - location = ''; - universityId = ''; + facultyName: string = ''; + location: string = ''; + universityId: string = ''; constructor( private dialogRef: MatDialogRef, @@ -50,7 +50,7 @@ export class FacultyEdit { this.universityId = data.universityId; } - save() { + save(): void { if (!this.facultyName.trim()) { alert('Please enter faculty name.'); return; @@ -68,10 +68,10 @@ export class FacultyEdit { universityId: this.universityId, }) .subscribe({ - next: () => { + next: (): void => { this.dialogRef.close(true); }, - error: () => { + error: (): void => { alert('Failed to update faculty.'); }, }); 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 64ac111..34ee45d 100644 --- a/uniplanWeb/src/app/features/faculty/faculty-options/faculty-options.ts +++ b/uniplanWeb/src/app/features/faculty/faculty-options/faculty-options.ts @@ -22,7 +22,7 @@ import { AddButton } from '../../../core/shared/add-button/add-button'; export class FacultyOptions { constructor(private dialog: MatDialog) {} - openAddForm() { + openAddForm(): void { this.dialog.open(FacultyAddForm, { width: '400px', }); diff --git a/uniplanWeb/src/app/features/faculty/faculty-service.ts b/uniplanWeb/src/app/features/faculty/faculty-service.ts index 506fe3e..9eb8262 100644 --- a/uniplanWeb/src/app/features/faculty/faculty-service.ts +++ b/uniplanWeb/src/app/features/faculty/faculty-service.ts @@ -15,8 +15,8 @@ export class FacultyService { getFaculties(): Observable { return this.http.get(this.apiUrl).pipe( - map((faculties) => - faculties.map((faculty, index) => ({ + map((faculties: FacultyElm[]) => + faculties.map((faculty: FacultyElm, index: number) => ({ id: faculty.id, facultyName: faculty.facultyName, location: faculty.location, @@ -33,7 +33,7 @@ export class FacultyService { location: string; }): Observable { return this.http.post(`${this.apiUrl}`, faculty).pipe( - map((res) => { + map((res: Object): Object => { this.refreshNeeded.next(); return res; }) 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 2daa689..c9fbf52 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 @@ -31,11 +31,10 @@ import { FacultyService } from '../../faculty/faculty-service'; styleUrl: './major-add-form.scss', }) export class MajorAddForm implements OnInit { - //todo - majorName = ''; - faculty = ''; - type = ''; - subtype = ''; + majorName: string = ''; + faculty: string = ''; + type: string = ''; + subtype: string = ''; faculties: FacultyElm[] = []; @@ -47,14 +46,14 @@ export class MajorAddForm implements OnInit { ngOnInit(): void { this.facultyService.getFaculties().subscribe({ - next: (data) => { + next: (data: FacultyElm[]) => { this.faculties = data; }, - error: (err) => console.error('Failed to load faculties', err), + error: (err: any): void => console.error('Failed to load faculties', err), }); } - save() { + save(): void { if ( !this.majorName.trim() || !this.faculty || @@ -73,10 +72,10 @@ export class MajorAddForm implements OnInit { subtype: this.subtype, }) .subscribe({ - next: () => { + next: (): void => { this.dialogRef.close(true); }, - error: () => alert('Failed to create major or course.'), + error: (): void => alert('Failed to create major or course.'), }); } } 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 d75cd12..e29b7ec 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 @@ -6,7 +6,7 @@ import { MatDialogRef, } from '@angular/material/dialog'; import { MajorService } from '../major-service'; -import { switchMap } from 'rxjs'; +import {Observable, switchMap} from 'rxjs'; @Component({ selector: 'app-major-delete-form', @@ -26,12 +26,12 @@ export class MajorDeleteForm { deleteMajor(): void { this.majorService .deleteCourse(this.data.courseId) - .pipe(switchMap(() => this.majorService.deleteMajor(this.data.id))) + .pipe(switchMap((): Observable => this.majorService.deleteMajor(this.data.id))) .subscribe({ - next: () => { + next: (): void => { this.dialogRef.close(true); }, - error: () => { + error: (): void => { alert('Възникна грешка при изтриването на специалността или курса.'); }, }); 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 1c4b806..798cee6 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 @@ -32,9 +32,8 @@ import { FacultyElm } from '../../../core/interfaces/faculty-elm'; styleUrl: './major-edit-form.scss', }) export class MajorEditForm implements OnInit { - //todo - majorName = ''; - facultyId = ''; + majorName: string = ''; + facultyId: string = ''; faculties: FacultyElm[] = []; @@ -55,12 +54,12 @@ export class MajorEditForm implements OnInit { ngOnInit(): void { this.facultyService.getFaculties().subscribe({ - next: (data) => (this.faculties = data), - error: (err) => console.error('Failed to load faculties', err), + next: (data: FacultyElm[]): FacultyElm[] => (this.faculties = data), + error: (err: any): void => console.error('Failed to load faculties', err), }); } - save() { + save(): void { if (!this.majorName.trim()) { alert('Please enter the major name.'); return; @@ -72,8 +71,8 @@ export class MajorEditForm implements OnInit { facultyId: this.facultyId, }) .subscribe({ - next: () => this.dialogRef.close(true), - error: () => alert('Failed to update major.'), + next: (): void => this.dialogRef.close(true), + error: (): void => alert('Failed to update major.'), }); } } diff --git a/uniplanWeb/src/app/features/major/major-filters/major-filters.ts b/uniplanWeb/src/app/features/major/major-filters/major-filters.ts index 6af86ae..56347d0 100644 --- a/uniplanWeb/src/app/features/major/major-filters/major-filters.ts +++ b/uniplanWeb/src/app/features/major/major-filters/major-filters.ts @@ -21,7 +21,6 @@ import { FacultyService } from '../../faculty/faculty-service'; styleUrl: './major-filters.scss', }) export class MajorFilters { - //todo @Input() internalSearchText = ''; @Input() faculties: { id: string; name: string }[] = []; @@ -29,12 +28,12 @@ export class MajorFilters { @Input() types: string[] = []; @Input() subtypes: string[] = []; - @Input() selectedFaculty = ''; - @Input() selectedType = ''; - @Input() selectedSubtype = ''; + @Input() selectedFaculty: string = ''; + @Input() selectedType: string = ''; + @Input() selectedSubtype: string = ''; - @Output() facultyChange = new EventEmitter(); - @Output() typeChange = new EventEmitter(); - @Output() subtypeChange = new EventEmitter(); - @Output() searchTextChange = new EventEmitter(); + @Output() facultyChange: EventEmitter = new EventEmitter(); + @Output() typeChange: EventEmitter = new EventEmitter(); + @Output() subtypeChange: EventEmitter = new EventEmitter(); + @Output() searchTextChange: EventEmitter = new EventEmitter(); } 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..80bc7b9 100644 --- a/uniplanWeb/src/app/features/major/major-options/major-options.ts +++ b/uniplanWeb/src/app/features/major/major-options/major-options.ts @@ -22,7 +22,7 @@ import { AddButton } from '../../../core/shared/add-button/add-button'; export class MajorOptions { constructor(private dialog: MatDialog) {} - openAddForm() { + openAddForm(): void { this.dialog.open(MajorAddForm, { width: '400px', }); diff --git a/uniplanWeb/src/app/features/major/major-service.ts b/uniplanWeb/src/app/features/major/major-service.ts index e89004f..df57b9f 100644 --- a/uniplanWeb/src/app/features/major/major-service.ts +++ b/uniplanWeb/src/app/features/major/major-service.ts @@ -7,18 +7,18 @@ import { MajorElm } from '../../core/interfaces/major-elm'; providedIn: 'root', }) export class MajorService { - private apiUrl = 'http://localhost:8080/api/majors'; - private apiUrlMajor = 'http://localhost:8080/api/majors'; - private apiUrlCourse = 'http://localhost:8080/api/courses'; + private apiUrl: string = 'http://localhost:8080/api/majors'; + private apiUrlMajor: string = 'http://localhost:8080/api/majors'; + private apiUrlCourse: string = 'http://localhost:8080/api/courses'; - refreshNeeded = new Subject(); + refreshNeeded: Subject = new Subject(); constructor(private http: HttpClient) {} getMajors(): Observable { return this.http.get(this.apiUrl).pipe( - map((majors) => - majors.map((major, index) => ({ + map((majors: MajorElm[]): any => + majors.map((major: MajorElm, index: number) => ({ majorId: major.majorId, majorName: major.majorName, courseId: major.courseId, @@ -36,7 +36,7 @@ export class MajorService { majorName: string; }): Observable { return this.http.post(`${this.apiUrlMajor}`, createMajor).pipe( - map((res) => { + map((res: Object): Object => { this.refreshNeeded.next(); return res; }) @@ -50,7 +50,7 @@ export class MajorService { courseSubtype: string; }): Observable { return this.http.post(`${this.apiUrlCourse}`, course).pipe( - map((res) => { + map((res: Object): Object => { this.refreshNeeded.next(); return res; }) @@ -66,7 +66,7 @@ export class MajorService { facultyId: majorData.facultyId, majorName: majorData.majorName, }).pipe( - switchMap((createdMajor: any) => { + switchMap((createdMajor: any): Observable => { return this.createCourse({ majorId: createdMajor.id, courseType: majorData.type, @@ -79,7 +79,7 @@ export class MajorService { deleteMajor(id: string): Observable { return this.http.delete(`${this.apiUrlMajor}/${id}`).pipe( - map((res) => { + map((res: Object): Object => { this.refreshNeeded.next(); return res; }) @@ -92,7 +92,7 @@ export class MajorService { deleteMajorWithCourse(major: MajorElm): Observable { return this.deleteCourse(major.courseId).pipe( - switchMap(() => this.deleteMajor(major.majorId)) + switchMap((): Observable => this.deleteMajor(major.majorId)) ); } @@ -101,7 +101,7 @@ export class MajorService { updateMajor: { facultyId: string; majorName: string } ): Observable { return this.http.put(`${this.apiUrlMajor}/${id}`, updateMajor).pipe( - map((res) => { + map((res: Object): Object => { this.refreshNeeded.next(); return res; }) 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 157d98e..d933702 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 @@ -23,17 +23,16 @@ import { FormsModule } from '@angular/forms'; styleUrl: './student-add-form.scss', }) export class StudentAddForm { - //todo - studentName = ''; - facultyNumber = ''; - faculty = ''; - major = ''; - course = ''; - type = ''; + studentName: string = ''; + facultyNumber: string = ''; + faculty: string = ''; + major: string = ''; + course: string = ''; + type: string = ''; constructor(private dialogRef: MatDialogRef) {} - save() { + save(): void { if (!this.studentName.trim()) { alert('Please enter student name.'); return; diff --git a/uniplanWeb/src/app/features/student/student-filters/student-filters.ts b/uniplanWeb/src/app/features/student/student-filters/student-filters.ts index 7db2f2b..fe33166 100644 --- a/uniplanWeb/src/app/features/student/student-filters/student-filters.ts +++ b/uniplanWeb/src/app/features/student/student-filters/student-filters.ts @@ -10,17 +10,16 @@ import { FiltersForm } from '../../../core/shared/filters-form/filters-form'; styleUrl: './student-filters.scss', }) export class StudentFilters { - //todo - @Input() internalSearchText = ''; - @Output() searchTextChange = new EventEmitter(); + @Input() internalSearchText: string = ''; + @Output() searchTextChange: EventEmitter = new EventEmitter(); - @Input() internalSearchFacNum = ''; - @Output() searchFacNumChange = new EventEmitter(); + @Input() internalSearchFacNum: string = ''; + @Output() searchFacNumChange: EventEmitter = new EventEmitter(); - @Input() internalSearchMajor = ''; - @Output() searchMajorChange = new EventEmitter(); + @Input() internalSearchMajor: string = ''; + @Output() searchMajorChange: EventEmitter = new EventEmitter(); @Input() subtypes: string[] = []; - @Input() selectedSubtype = ''; - @Output() subtypeChange = new EventEmitter(); + @Input() selectedSubtype: string = ''; + @Output() subtypeChange: EventEmitter = new EventEmitter(); } 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..a51ad31 100644 --- a/uniplanWeb/src/app/features/student/student-options/student-options.ts +++ b/uniplanWeb/src/app/features/student/student-options/student-options.ts @@ -13,7 +13,7 @@ import { StudentAddForm } from '../student-add-form/student-add-form'; export class StudentOptions { constructor(private dialog: MatDialog) {} - openAddForm() { + openAddForm(): void { this.dialog.open(StudentAddForm, { width: '400px', }); diff --git a/uniplanWeb/src/app/features/student/student-table/student-table.ts b/uniplanWeb/src/app/features/student/student-table/student-table.ts index acffefe..58c4f03 100644 --- a/uniplanWeb/src/app/features/student/student-table/student-table.ts +++ b/uniplanWeb/src/app/features/student/student-table/student-table.ts @@ -113,11 +113,10 @@ export const ELEMENT_STUDENT_DATA: StudentElm[] = [ styleUrl: './student-table.scss', }) export class StudentTable implements OnInit, OnChanges { - //todo - @Input() searchText = ''; - @Input() searchFacNum = ''; - @Input() searchMajor = ''; - @Input() subtype = ''; + @Input() searchText: string = ''; + @Input() searchFacNum: string = ''; + @Input() searchMajor: string = ''; + @Input() subtype: string = ''; @Input() subtypes: string[] = []; @@ -145,15 +144,15 @@ export class StudentTable implements OnInit, OnChanges { } applyFilters(): void { - const name = this.searchText.toLowerCase(); - const major = this.searchMajor.toLowerCase(); - const facNum = this.searchFacNum; + const name: string = this.searchText.toLowerCase(); + const major: string = this.searchMajor.toLowerCase(); + const facNum: string = this.searchFacNum; this.dataSourceFilter = this.originalData.filter((student) => { - const matchName = !name || student.name.toLowerCase().includes(name); - const matchMajor = !major || student.major.toLowerCase().includes(major); - const matchFacNum = !facNum || student.facultyNumber.includes(facNum); - const matchSubtype = !this.subtype || student.subtype === this.subtype; + const matchName: boolean = !name || student.name.toLowerCase().includes(name); + const matchMajor: boolean = !major || student.major.toLowerCase().includes(major); + const matchFacNum: boolean = !facNum || student.facultyNumber.includes(facNum); + const matchSubtype: boolean = !this.subtype || student.subtype === this.subtype; return matchName && matchMajor && matchFacNum && matchSubtype; }); @@ -161,7 +160,7 @@ export class StudentTable implements OnInit, OnChanges { static getFilterOptions(data: StudentElm[]) { return { - subtypes: [...new Set(data.map((e) => e.subtype))], + subtypes: [...new Set(data.map((e: StudentElm) => e.subtype))], }; } diff --git a/uniplanWeb/src/app/features/university/university-service.ts b/uniplanWeb/src/app/features/university/university-service.ts index 7516f0a..82ecc85 100644 --- a/uniplanWeb/src/app/features/university/university-service.ts +++ b/uniplanWeb/src/app/features/university/university-service.ts @@ -15,7 +15,7 @@ export interface UniversityElm { providedIn: 'root', }) export class UniversityService { -private apiUrl = 'http://localhost:8080/api/universities'; +private apiUrl: string = 'http://localhost:8080/api/universities'; constructor(private http: HttpClient) {} diff --git a/uniplanWeb/src/app/services/login-auth-service.ts b/uniplanWeb/src/app/services/login-auth-service.ts index 3ec49fe..7d66059 100644 --- a/uniplanWeb/src/app/services/login-auth-service.ts +++ b/uniplanWeb/src/app/services/login-auth-service.ts @@ -4,7 +4,7 @@ import { Injectable } from '@angular/core'; providedIn: 'root' }) export class LoginAuthService { - private loggedIn = false; + private loggedIn: boolean = false; constructor() { this.loggedIn = !!localStorage.getItem('user'); From 5f2681326fcf78d741e938d8e1d07c022f468982 Mon Sep 17 00:00:00 2001 From: Djesika Vacheva Date: Mon, 22 Jun 2026 09:24:22 +0300 Subject: [PATCH 2/2] add access modifiers --- .../app/core/shared/add-button/add-button.ts | 2 +- .../src/app/core/shared/add-form/add-form.ts | 4 +-- .../core/shared/delete-form/delete-form.ts | 4 +-- .../app/core/shared/edit-form/edit-form.ts | 4 +-- .../core/shared/filters-form/filters-form.ts | 14 ++++---- .../core/shared/input-filter/input-filter.ts | 6 ++-- .../app/core/shared/main-panel/main-panel.ts | 32 +++++++++---------- .../navmenu-component/navmenu-component.ts | 22 ++++++------- .../faculty-add-form/faculty-add-form.ts | 12 +++---- .../faculty-delete-form.ts | 2 +- .../faculty/faculty-edit/faculty-edit.ts | 9 +++--- .../faculty-options/faculty-options.ts | 2 +- .../app/features/faculty/faculty-service.ts | 10 +++--- .../major/major-add-form/major-add-form.ts | 14 ++++---- .../major-delete-form/major-delete-form.ts | 2 +- .../major/major-edit-form/major-edit-form.ts | 10 +++--- .../major/major-filters/major-filters.ts | 22 ++++++------- .../major/major-options/major-options.ts | 2 +- .../src/app/features/major/major-service.ts | 16 +++++----- .../student-add-form/student-add-form.ts | 14 ++++---- .../student-filters/student-filters.ts | 18 +++++------ .../student-options/student-options.ts | 2 +- .../student/student-table/student-table.ts | 26 +++++++-------- .../features/university/university-service.ts | 2 +- .../src/app/services/login-auth-service.ts | 4 +-- 25 files changed, 127 insertions(+), 128 deletions(-) diff --git a/uniplanWeb/src/app/core/shared/add-button/add-button.ts b/uniplanWeb/src/app/core/shared/add-button/add-button.ts index 1c66b9f..315b488 100644 --- a/uniplanWeb/src/app/core/shared/add-button/add-button.ts +++ b/uniplanWeb/src/app/core/shared/add-button/add-button.ts @@ -12,7 +12,7 @@ import { MatIconModule } from '@angular/material/icon'; export class AddButton { @Output() addClicked = new EventEmitter(); - onClick(): void { + public onClick(): void { this.addClicked.emit(); } } diff --git a/uniplanWeb/src/app/core/shared/add-form/add-form.ts b/uniplanWeb/src/app/core/shared/add-form/add-form.ts index 47436c2..91eba22 100644 --- a/uniplanWeb/src/app/core/shared/add-form/add-form.ts +++ b/uniplanWeb/src/app/core/shared/add-form/add-form.ts @@ -12,7 +12,7 @@ import { MatInputModule } from '@angular/material/input'; styleUrl: './add-form.scss', }) export class AddForm { - @Input() title: string = ''; + @Input() public title: string = ''; - @Output() saveClicked :EventEmitter = new EventEmitter(); + @Output() public readonly saveClicked :EventEmitter = new EventEmitter(); } diff --git a/uniplanWeb/src/app/core/shared/delete-form/delete-form.ts b/uniplanWeb/src/app/core/shared/delete-form/delete-form.ts index ec69eec..d97f049 100644 --- a/uniplanWeb/src/app/core/shared/delete-form/delete-form.ts +++ b/uniplanWeb/src/app/core/shared/delete-form/delete-form.ts @@ -11,7 +11,7 @@ import { MatInputModule } from '@angular/material/input'; styleUrl: './delete-form.scss', }) export class DeleteForm { - @Input() title: string = ''; + @Input() public title: string = ''; - @Output() deleteClicked:EventEmitter = new EventEmitter(); + @Output() public readonly deleteClicked:EventEmitter = new EventEmitter(); } diff --git a/uniplanWeb/src/app/core/shared/edit-form/edit-form.ts b/uniplanWeb/src/app/core/shared/edit-form/edit-form.ts index 3a46523..42f33df 100644 --- a/uniplanWeb/src/app/core/shared/edit-form/edit-form.ts +++ b/uniplanWeb/src/app/core/shared/edit-form/edit-form.ts @@ -10,7 +10,7 @@ import { MatDialogModule } from '@angular/material/dialog'; styleUrl: './edit-form.scss', }) export class EditForm { - @Input() title: string = ''; + @Input() public title: string = ''; - @Output() saveClicked:EventEmitter = new EventEmitter(); + @Output() public readonly saveClicked:EventEmitter = new EventEmitter(); } diff --git a/uniplanWeb/src/app/core/shared/filters-form/filters-form.ts b/uniplanWeb/src/app/core/shared/filters-form/filters-form.ts index feaec7f..5c65f36 100644 --- a/uniplanWeb/src/app/core/shared/filters-form/filters-form.ts +++ b/uniplanWeb/src/app/core/shared/filters-form/filters-form.ts @@ -13,20 +13,20 @@ import { MatSelectModule } from '@angular/material/select'; styleUrl: './filters-form.scss', }) export class FiltersForm { - @Input() label: string = ''; + @Input() public label: string = ''; - @Input() options: string[] = []; + @Input() public options: string[] = []; - @Input() objectOptions: { id: string; name: string }[] = []; + @Input() public objectOptions: { id: string; name: string }[] = []; - @Input() selected = ''; - @Output() selectionChange = new EventEmitter(); + @Input() public selected = ''; + @Output() public readonly selectionChange = new EventEmitter(); - onChange(value: string) { + public onChange(value: string) { this.selectionChange.emit(value); } - isObjectMode(): boolean { + public isObjectMode(): boolean { return this.objectOptions && this.objectOptions.length > 0; } } diff --git a/uniplanWeb/src/app/core/shared/input-filter/input-filter.ts b/uniplanWeb/src/app/core/shared/input-filter/input-filter.ts index e768f4e..a0a821b 100644 --- a/uniplanWeb/src/app/core/shared/input-filter/input-filter.ts +++ b/uniplanWeb/src/app/core/shared/input-filter/input-filter.ts @@ -12,7 +12,7 @@ import { MatFormField, MatInputModule } from '@angular/material/input'; styleUrl: './input-filter.scss', }) export class InputFilter { - @Input() label: string = ''; - @Input() searchText: string = ''; - @Output() searchTextChange: EventEmitter = new EventEmitter(); + @Input() public label: string = ''; + @Input() public searchText: string = ''; + @Output() public readonly searchTextChange: EventEmitter = new EventEmitter(); } diff --git a/uniplanWeb/src/app/core/shared/main-panel/main-panel.ts b/uniplanWeb/src/app/core/shared/main-panel/main-panel.ts index e6cef50..a56abaa 100644 --- a/uniplanWeb/src/app/core/shared/main-panel/main-panel.ts +++ b/uniplanWeb/src/app/core/shared/main-panel/main-panel.ts @@ -36,28 +36,28 @@ import {FacultyElm} from '../../interfaces/faculty-elm'; styleUrl: './main-panel.scss', }) export class MainPanel { - currentView: string = 'home'; + protected currentView: string = 'home'; - majors: MajorElm[] = []; - students: StudentElm[] = ELEMENT_STUDENT_DATA; + protected majors: MajorElm[] = []; + protected students: StudentElm[] = ELEMENT_STUDENT_DATA; - searchText: string = ''; - searchFacNum: string = ''; - searchMajor: string = ''; - selectedStudentSubtype: string = ''; - studentSubtypes: string[] = []; + protected searchText: string = ''; + protected searchFacNum: string = ''; + protected searchMajor: string = ''; + protected selectedStudentSubtype: string = ''; + protected studentSubtypes: string[] = []; - selectedFaculty: string = ''; - selectedType: string = ''; - selectedSubtype: string = ''; + protected selectedFaculty: string = ''; + protected selectedType: string = ''; + protected selectedSubtype: string = ''; - faculties: { id: string; name: string }[] = []; - types: string[] = []; - subtypes: string[] = []; + protected faculties: { id: string; name: string }[] = []; + protected types: string[] = []; + protected subtypes: string[] = []; private facultyMap: Map = new Map(); - constructor( + public constructor( private viewService: ViewService, private majorService: MajorService, private facultyService: FacultyService @@ -67,7 +67,7 @@ export class MainPanel { }); } - ngOnInit(): void { + public ngOnInit(): void { this.loadMajorFilters(); this.loadStudentFilters(); 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 3fb0a58..7c6412f 100644 --- a/uniplanWeb/src/app/core/shared/navmenu-component/navmenu-component.ts +++ b/uniplanWeb/src/app/core/shared/navmenu-component/navmenu-component.ts @@ -13,20 +13,20 @@ import { LoginAuthService } from '../../../services/login-auth-service'; styleUrls: ['./navmenu-component.scss'], }) export class NavmenuComponent implements OnInit { - isSidebarCollapsed: boolean = false; - isMobileView: boolean = window.innerWidth <= 768; + protected isSidebarCollapsed: boolean = false; + protected isMobileView: boolean = window.innerWidth <= 768; constructor( - public authService: LoginAuthService, - public viewService: ViewService + protected authService: LoginAuthService, + private readonly viewService: ViewService ) {} - ngOnInit(): void { + public ngOnInit(): void { this.checkViewport(); } @HostListener('window:resize', ['$event']) - onResize(event: Event): void { + protected onResize(event: Event): void { this.checkViewport(); } @@ -40,23 +40,23 @@ export class NavmenuComponent implements OnInit { } } - toggleSidebar(): void { + protected toggleSidebar(): void { this.isSidebarCollapsed = !this.isSidebarCollapsed; } - onHomeClick(): void { + protected onHomeClick(): void { this.viewService.setView('home'); } - onFacultyClick(): void { + protected onFacultyClick(): void { this.viewService.setView('faculty'); } - onMajorClick(): void { + protected onMajorClick(): void { this.viewService.setView('major'); } - onStudentClick(): void { + protected onStudentClick(): void { this.viewService.setView('student'); } } 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 9451901..340320f 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 @@ -30,10 +30,10 @@ import { styleUrl: './faculty-add-form.scss', }) export class FacultyAddForm implements OnInit { - facultyName: string = ''; - location: string = ''; - universityId: string = ''; - universities: UniversityElm[] = []; + protected facultyName: string = ''; + protected location: string = ''; + protected universityId: string = ''; + protected universities: UniversityElm[] = []; constructor( private dialogRef: MatDialogRef, @@ -41,7 +41,7 @@ export class FacultyAddForm implements OnInit { private universityService: UniversityService ) {} - ngOnInit(): void { + public ngOnInit(): void { this.universityService.getAllUniversities().subscribe({ next: (data: UniversityElm[]): void => { this.universities = data; @@ -52,7 +52,7 @@ export class FacultyAddForm implements OnInit { }); } - save(): void { + protected save(): void { if (!this.facultyName.trim()) { alert('Please enter faculty name.'); return; 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 684a92e..00d2ed6 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 @@ -22,7 +22,7 @@ export class FacultyDeleteForm { public data: { id: string; facultyName: string } ) {} - deleteFaculty(): void { + protected deleteFaculty(): void { this.facultyService.deleteFaculty(this.data.id).subscribe({ next: (): void => { this.dialogRef.close(true); 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 6885f0e..ebb9c0f 100644 --- a/uniplanWeb/src/app/features/faculty/faculty-edit/faculty-edit.ts +++ b/uniplanWeb/src/app/features/faculty/faculty-edit/faculty-edit.ts @@ -30,9 +30,9 @@ import { EditForm } from '../../../core/shared/edit-form/edit-form'; ], }) export class FacultyEdit { - facultyName: string = ''; - location: string = ''; - universityId: string = ''; + protected facultyName: string = ''; + protected location: string = ''; + protected universityId: string = ''; constructor( private dialogRef: MatDialogRef, @@ -49,8 +49,7 @@ export class FacultyEdit { this.location = data.location; this.universityId = data.universityId; } - - save(): void { + protected save(): void { if (!this.facultyName.trim()) { alert('Please enter faculty name.'); return; 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 34ee45d..a8dace5 100644 --- a/uniplanWeb/src/app/features/faculty/faculty-options/faculty-options.ts +++ b/uniplanWeb/src/app/features/faculty/faculty-options/faculty-options.ts @@ -22,7 +22,7 @@ import { AddButton } from '../../../core/shared/add-button/add-button'; export class FacultyOptions { constructor(private dialog: MatDialog) {} - openAddForm(): void { + protected openAddForm(): void { this.dialog.open(FacultyAddForm, { width: '400px', }); diff --git a/uniplanWeb/src/app/features/faculty/faculty-service.ts b/uniplanWeb/src/app/features/faculty/faculty-service.ts index 9eb8262..778f369 100644 --- a/uniplanWeb/src/app/features/faculty/faculty-service.ts +++ b/uniplanWeb/src/app/features/faculty/faculty-service.ts @@ -9,11 +9,11 @@ import { FacultyElm } from '../../core/interfaces/faculty-elm'; export class FacultyService { private apiUrl = 'http://localhost:8080/api/faculties'; - refreshNeeded = new Subject(); + public readonly refreshNeeded = new Subject(); constructor(private http: HttpClient) {} - getFaculties(): Observable { + public getFaculties(): Observable { return this.http.get(this.apiUrl).pipe( map((faculties: FacultyElm[]) => faculties.map((faculty: FacultyElm, index: number) => ({ @@ -27,7 +27,7 @@ export class FacultyService { ); } - createFaculty(faculty: { + public createFaculty(faculty: { universityId: string; facultyName: string; location: string; @@ -40,7 +40,7 @@ export class FacultyService { ); } - editFaculty( + public editFaculty( id: string, updatedFaculty: { universityId: string; @@ -56,7 +56,7 @@ export class FacultyService { ); } - deleteFaculty(id: string): Observable { + public deleteFaculty(id: string): Observable { return this.http.delete(`${this.apiUrl}/${id}`).pipe( map((res) => { this.refreshNeeded.next(); 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 c9fbf52..2339556 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 @@ -31,12 +31,12 @@ import { FacultyService } from '../../faculty/faculty-service'; styleUrl: './major-add-form.scss', }) export class MajorAddForm implements OnInit { - majorName: string = ''; - faculty: string = ''; - type: string = ''; - subtype: string = ''; + protected majorName: string = ''; + protected faculty: string = ''; + protected type: string = ''; + protected subtype: string = ''; - faculties: FacultyElm[] = []; + protected faculties: FacultyElm[] = []; constructor( private dialogRef: MatDialogRef, @@ -44,7 +44,7 @@ export class MajorAddForm implements OnInit { private facultyService: FacultyService ) {} - ngOnInit(): void { + public ngOnInit(): void { this.facultyService.getFaculties().subscribe({ next: (data: FacultyElm[]) => { this.faculties = data; @@ -53,7 +53,7 @@ export class MajorAddForm implements OnInit { }); } - save(): void { + protected save(): void { if ( !this.majorName.trim() || !this.faculty || 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 e29b7ec..800027b 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 @@ -23,7 +23,7 @@ export class MajorDeleteForm { public data: { id: string; courseId: string; name: string } ) {} - deleteMajor(): void { + protected deleteMajor(): void { this.majorService .deleteCourse(this.data.courseId) .pipe(switchMap((): Observable => this.majorService.deleteMajor(this.data.id))) 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 798cee6..65dbe26 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 @@ -32,10 +32,10 @@ import { FacultyElm } from '../../../core/interfaces/faculty-elm'; styleUrl: './major-edit-form.scss', }) export class MajorEditForm implements OnInit { - majorName: string = ''; - facultyId: string = ''; + protected majorName: string = ''; + protected facultyId: string = ''; - faculties: FacultyElm[] = []; + protected faculties: FacultyElm[] = []; constructor( private dialogRef: MatDialogRef, @@ -52,14 +52,14 @@ export class MajorEditForm implements OnInit { this.facultyId = data.facultyId || ''; } - ngOnInit(): void { + public ngOnInit(): void { this.facultyService.getFaculties().subscribe({ next: (data: FacultyElm[]): FacultyElm[] => (this.faculties = data), error: (err: any): void => console.error('Failed to load faculties', err), }); } - save(): void { + protected save(): void { if (!this.majorName.trim()) { alert('Please enter the major name.'); return; diff --git a/uniplanWeb/src/app/features/major/major-filters/major-filters.ts b/uniplanWeb/src/app/features/major/major-filters/major-filters.ts index 56347d0..3b54a45 100644 --- a/uniplanWeb/src/app/features/major/major-filters/major-filters.ts +++ b/uniplanWeb/src/app/features/major/major-filters/major-filters.ts @@ -21,19 +21,19 @@ import { FacultyService } from '../../faculty/faculty-service'; styleUrl: './major-filters.scss', }) export class MajorFilters { - @Input() internalSearchText = ''; + @Input() public internalSearchText = ''; - @Input() faculties: { id: string; name: string }[] = []; + @Input() public faculties: { id: string; name: string }[] = []; - @Input() types: string[] = []; - @Input() subtypes: string[] = []; + @Input() public types: string[] = []; + @Input() public subtypes: string[] = []; - @Input() selectedFaculty: string = ''; - @Input() selectedType: string = ''; - @Input() selectedSubtype: string = ''; + @Input() public selectedFaculty: string = ''; + @Input() public selectedType: string = ''; + @Input() public selectedSubtype: string = ''; - @Output() facultyChange: EventEmitter = new EventEmitter(); - @Output() typeChange: EventEmitter = new EventEmitter(); - @Output() subtypeChange: EventEmitter = new EventEmitter(); - @Output() searchTextChange: EventEmitter = new EventEmitter(); + @Output() public readonly facultyChange: EventEmitter = new EventEmitter(); + @Output() public readonly typeChange: EventEmitter = new EventEmitter(); + @Output() public readonly subtypeChange: EventEmitter = new EventEmitter(); + @Output() public readonly searchTextChange: EventEmitter = new EventEmitter(); } 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 80bc7b9..e55b232 100644 --- a/uniplanWeb/src/app/features/major/major-options/major-options.ts +++ b/uniplanWeb/src/app/features/major/major-options/major-options.ts @@ -22,7 +22,7 @@ import { AddButton } from '../../../core/shared/add-button/add-button'; export class MajorOptions { constructor(private dialog: MatDialog) {} - openAddForm(): void { + protected openAddForm(): void { this.dialog.open(MajorAddForm, { width: '400px', }); diff --git a/uniplanWeb/src/app/features/major/major-service.ts b/uniplanWeb/src/app/features/major/major-service.ts index df57b9f..819e73f 100644 --- a/uniplanWeb/src/app/features/major/major-service.ts +++ b/uniplanWeb/src/app/features/major/major-service.ts @@ -11,11 +11,11 @@ export class MajorService { private apiUrlMajor: string = 'http://localhost:8080/api/majors'; private apiUrlCourse: string = 'http://localhost:8080/api/courses'; - refreshNeeded: Subject = new Subject(); + public readonly refreshNeeded: Subject = new Subject(); constructor(private http: HttpClient) {} - getMajors(): Observable { + public getMajors(): Observable { return this.http.get(this.apiUrl).pipe( map((majors: MajorElm[]): any => majors.map((major: MajorElm, index: number) => ({ @@ -31,7 +31,7 @@ export class MajorService { ); } - createMajor(createMajor: { + public createMajor(createMajor: { facultyId: string; majorName: string; }): Observable { @@ -43,7 +43,7 @@ export class MajorService { ); } - createCourse(course: { + public createCourse(course: { majorId: string; courseYear: number; courseType: string; @@ -56,7 +56,7 @@ export class MajorService { }) ); } - createMajorWithCourse(majorData: { + public createMajorWithCourse(majorData: { facultyId: string; majorName: string; type: string; @@ -77,7 +77,7 @@ export class MajorService { ); } - deleteMajor(id: string): Observable { + public deleteMajor(id: string): Observable { return this.http.delete(`${this.apiUrlMajor}/${id}`).pipe( map((res: Object): Object => { this.refreshNeeded.next(); @@ -86,7 +86,7 @@ export class MajorService { ); } - deleteCourse(courseId: string): Observable { + public deleteCourse(courseId: string): Observable { return this.http.delete(`${this.apiUrlCourse}/${courseId}`); } @@ -96,7 +96,7 @@ export class MajorService { ); } - editMajor( + public editMajor( id: string, updateMajor: { facultyId: string; majorName: string } ): Observable { 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 d933702..4f3cf00 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 @@ -23,16 +23,16 @@ import { FormsModule } from '@angular/forms'; styleUrl: './student-add-form.scss', }) export class StudentAddForm { - studentName: string = ''; - facultyNumber: string = ''; - faculty: string = ''; - major: string = ''; - course: string = ''; - type: string = ''; + protected studentName: string = ''; + protected facultyNumber: string = ''; + protected faculty: string = ''; + protected major: string = ''; + protected course: string = ''; + protected type: string = ''; constructor(private dialogRef: MatDialogRef) {} - save(): void { + protected save(): void { if (!this.studentName.trim()) { alert('Please enter student name.'); return; diff --git a/uniplanWeb/src/app/features/student/student-filters/student-filters.ts b/uniplanWeb/src/app/features/student/student-filters/student-filters.ts index fe33166..58c88c3 100644 --- a/uniplanWeb/src/app/features/student/student-filters/student-filters.ts +++ b/uniplanWeb/src/app/features/student/student-filters/student-filters.ts @@ -10,16 +10,16 @@ import { FiltersForm } from '../../../core/shared/filters-form/filters-form'; styleUrl: './student-filters.scss', }) export class StudentFilters { - @Input() internalSearchText: string = ''; - @Output() searchTextChange: EventEmitter = new EventEmitter(); + @Input() public internalSearchText: string = ''; + @Output() public readonly searchTextChange: EventEmitter = new EventEmitter(); - @Input() internalSearchFacNum: string = ''; - @Output() searchFacNumChange: EventEmitter = new EventEmitter(); + @Input() public internalSearchFacNum: string = ''; + @Output() public readonly searchFacNumChange: EventEmitter = new EventEmitter(); - @Input() internalSearchMajor: string = ''; - @Output() searchMajorChange: EventEmitter = new EventEmitter(); + @Input() public internalSearchMajor: string = ''; + @Output() public readonly searchMajorChange: EventEmitter = new EventEmitter(); - @Input() subtypes: string[] = []; - @Input() selectedSubtype: string = ''; - @Output() subtypeChange: EventEmitter = new EventEmitter(); + @Input() public subtypes: string[] = []; + @Input() public selectedSubtype: string = ''; + @Output() public readonly subtypeChange: EventEmitter = new EventEmitter(); } 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 a51ad31..5a60b48 100644 --- a/uniplanWeb/src/app/features/student/student-options/student-options.ts +++ b/uniplanWeb/src/app/features/student/student-options/student-options.ts @@ -13,7 +13,7 @@ import { StudentAddForm } from '../student-add-form/student-add-form'; export class StudentOptions { constructor(private dialog: MatDialog) {} - openAddForm(): void { + protected openAddForm(): void { this.dialog.open(StudentAddForm, { width: '400px', }); diff --git a/uniplanWeb/src/app/features/student/student-table/student-table.ts b/uniplanWeb/src/app/features/student/student-table/student-table.ts index 58c4f03..16679f2 100644 --- a/uniplanWeb/src/app/features/student/student-table/student-table.ts +++ b/uniplanWeb/src/app/features/student/student-table/student-table.ts @@ -113,12 +113,12 @@ export const ELEMENT_STUDENT_DATA: StudentElm[] = [ styleUrl: './student-table.scss', }) export class StudentTable implements OnInit, OnChanges { - @Input() searchText: string = ''; - @Input() searchFacNum: string = ''; - @Input() searchMajor: string = ''; - @Input() subtype: string = ''; + @Input() public searchText: string = ''; + @Input() public searchFacNum: string = ''; + @Input() public searchMajor: string = ''; + @Input() public subtype: string = ''; - @Input() subtypes: string[] = []; + @Input() public subtypes: string[] = []; displayedColumns: string[] = [ 'position', @@ -131,19 +131,19 @@ export class StudentTable implements OnInit, OnChanges { 'actions', ]; - originalData: StudentElm[] = ELEMENT_STUDENT_DATA; - dataSourceFilter: StudentElm[] = ELEMENT_STUDENT_DATA; + protected originalData: StudentElm[] = ELEMENT_STUDENT_DATA; + protected dataSourceFilter: StudentElm[] = ELEMENT_STUDENT_DATA; - ngOnInit(): void { + public ngOnInit(): void { this.subtypes = StudentTable.getFilterOptions(this.originalData).subtypes; this.applyFilters(); } - ngOnChanges(changes: SimpleChanges): void { + public ngOnChanges(changes: SimpleChanges): void { this.applyFilters(); } - applyFilters(): void { + private applyFilters(): void { const name: string = this.searchText.toLowerCase(); const major: string = this.searchMajor.toLowerCase(); const facNum: string = this.searchFacNum; @@ -158,17 +158,17 @@ export class StudentTable implements OnInit, OnChanges { }); } - static getFilterOptions(data: StudentElm[]) { + public static getFilterOptions(data: StudentElm[]) { return { subtypes: [...new Set(data.map((e: StudentElm) => e.subtype))], }; } - onEdit(element: StudentElm): void { + protected onEdit(element: StudentElm): void { console.log('Editing:', element); } - onDelete(element: StudentElm): void { + protected onDelete(element: StudentElm): void { console.log('Deleting:', element); } } diff --git a/uniplanWeb/src/app/features/university/university-service.ts b/uniplanWeb/src/app/features/university/university-service.ts index 82ecc85..b611efd 100644 --- a/uniplanWeb/src/app/features/university/university-service.ts +++ b/uniplanWeb/src/app/features/university/university-service.ts @@ -19,7 +19,7 @@ private apiUrl: string = 'http://localhost:8080/api/universities'; constructor(private http: HttpClient) {} - getAllUniversities(): Observable { + public getAllUniversities(): Observable { return this.http.get(this.apiUrl); } } diff --git a/uniplanWeb/src/app/services/login-auth-service.ts b/uniplanWeb/src/app/services/login-auth-service.ts index 7d66059..8d68305 100644 --- a/uniplanWeb/src/app/services/login-auth-service.ts +++ b/uniplanWeb/src/app/services/login-auth-service.ts @@ -10,11 +10,11 @@ export class LoginAuthService { this.loggedIn = !!localStorage.getItem('user'); } - isLoggedIn(): boolean { + public isLoggedIn(): boolean { return this.loggedIn; } - logout(): void { + public logout(): void { localStorage.removeItem('user'); this.loggedIn = false; }