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 bb4b843..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 = 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 d0eb4b4..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 = 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 6947946..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 = 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 53e9bb0..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 = ''; + @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 1f70c70..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 = ''; - @Output() searchTextChange = 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 d205b1b..a56abaa 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,55 +36,55 @@ import { FacultyService } from '../../../features/faculty/faculty-service'; styleUrl: './main-panel.scss', }) export class MainPanel { - currentView = 'home'; + protected currentView: string = 'home'; - majors: MajorElm[] = []; - students = ELEMENT_STUDENT_DATA; + protected majors: MajorElm[] = []; + protected students: StudentElm[] = ELEMENT_STUDENT_DATA; - searchText = ''; - searchFacNum = ''; - searchMajor = ''; - selectedStudentSubtype = ''; - studentSubtypes: string[] = []; + protected searchText: string = ''; + protected searchFacNum: string = ''; + protected searchMajor: string = ''; + protected selectedStudentSubtype: string = ''; + protected studentSubtypes: string[] = []; - selectedFaculty = ''; - selectedType = ''; - selectedSubtype = ''; + 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 = new Map(); + private facultyMap: Map = new Map(); - constructor( + public 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; }); } - ngOnInit(): void { + public ngOnInit(): void { 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..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,25 +13,25 @@ import { LoginAuthService } from '../../../services/login-auth-service'; styleUrls: ['./navmenu-component.scss'], }) export class NavmenuComponent implements OnInit { - isSidebarCollapsed = false; - isMobileView = 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(); } private checkViewport(): void { - const isNowMobile = window.innerWidth <= 768; + const isNowMobile: boolean = window.innerWidth <= 768; if (this.isMobileView !== isNowMobile) { this.isMobileView = isNowMobile; } @@ -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 81d040a..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 = ''; - location = ''; - universityId = ''; - universities: UniversityElm[] = []; + protected facultyName: string = ''; + protected location: string = ''; + protected universityId: string = ''; + protected universities: UniversityElm[] = []; constructor( private dialogRef: MatDialogRef, @@ -41,18 +41,18 @@ export class FacultyAddForm implements OnInit { private universityService: UniversityService ) {} - ngOnInit(): void { + public 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() { + protected 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..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,12 +22,12 @@ export class FacultyDeleteForm { public data: { id: string; facultyName: string } ) {} - deleteFaculty(): void { + protected 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..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 = ''; - location = ''; - universityId = ''; + 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() { + protected save(): void { if (!this.facultyName.trim()) { alert('Please enter faculty name.'); return; @@ -68,10 +67,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..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() { + 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 506fe3e..778f369 100644 --- a/uniplanWeb/src/app/features/faculty/faculty-service.ts +++ b/uniplanWeb/src/app/features/faculty/faculty-service.ts @@ -9,14 +9,14 @@ 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) => - faculties.map((faculty, index) => ({ + map((faculties: FacultyElm[]) => + faculties.map((faculty: FacultyElm, index: number) => ({ id: faculty.id, facultyName: faculty.facultyName, location: faculty.location, @@ -27,20 +27,20 @@ export class FacultyService { ); } - createFaculty(faculty: { + public createFaculty(faculty: { universityId: string; facultyName: string; location: string; }): Observable { return this.http.post(`${this.apiUrl}`, faculty).pipe( - map((res) => { + map((res: Object): Object => { this.refreshNeeded.next(); return res; }) ); } - 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 2daa689..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,13 +31,12 @@ import { FacultyService } from '../../faculty/faculty-service'; styleUrl: './major-add-form.scss', }) export class MajorAddForm implements OnInit { - //todo - majorName = ''; - faculty = ''; - type = ''; - subtype = ''; + protected majorName: string = ''; + protected faculty: string = ''; + protected type: string = ''; + protected subtype: string = ''; - faculties: FacultyElm[] = []; + protected faculties: FacultyElm[] = []; constructor( private dialogRef: MatDialogRef, @@ -45,16 +44,16 @@ export class MajorAddForm implements OnInit { private facultyService: FacultyService ) {} - ngOnInit(): void { + public 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() { + protected 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..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 @@ -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', @@ -23,15 +23,15 @@ export class MajorDeleteForm { public data: { id: string; courseId: string; name: string } ) {} - deleteMajor(): void { + protected 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..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,11 +32,10 @@ import { FacultyElm } from '../../../core/interfaces/faculty-elm'; styleUrl: './major-edit-form.scss', }) export class MajorEditForm implements OnInit { - //todo - majorName = ''; - facultyId = ''; + protected majorName: string = ''; + protected facultyId: string = ''; - faculties: FacultyElm[] = []; + protected faculties: FacultyElm[] = []; constructor( private dialogRef: MatDialogRef, @@ -53,14 +52,14 @@ export class MajorEditForm implements OnInit { this.facultyId = data.facultyId || ''; } - ngOnInit(): void { + public 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() { + protected 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..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,20 +21,19 @@ import { FacultyService } from '../../faculty/faculty-service'; styleUrl: './major-filters.scss', }) export class MajorFilters { - //todo - @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 = ''; - @Input() selectedType = ''; - @Input() selectedSubtype = ''; + @Input() public selectedFaculty: string = ''; + @Input() public selectedType: string = ''; + @Input() public selectedSubtype: string = ''; - @Output() facultyChange = new EventEmitter(); - @Output() typeChange = new EventEmitter(); - @Output() subtypeChange = new EventEmitter(); - @Output() searchTextChange = 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 e5a0660..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() { + 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 e89004f..819e73f 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(); + public readonly refreshNeeded: Subject = new Subject(); constructor(private http: HttpClient) {} - getMajors(): Observable { + public 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, @@ -31,32 +31,32 @@ export class MajorService { ); } - createMajor(createMajor: { + public createMajor(createMajor: { facultyId: string; majorName: string; }): Observable { return this.http.post(`${this.apiUrlMajor}`, createMajor).pipe( - map((res) => { + map((res: Object): Object => { this.refreshNeeded.next(); return res; }) ); } - createCourse(course: { + public createCourse(course: { majorId: string; courseYear: number; courseType: string; courseSubtype: string; }): Observable { return this.http.post(`${this.apiUrlCourse}`, course).pipe( - map((res) => { + map((res: Object): Object => { this.refreshNeeded.next(); return res; }) ); } - createMajorWithCourse(majorData: { + public createMajorWithCourse(majorData: { facultyId: string; majorName: string; type: string; @@ -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, @@ -77,31 +77,31 @@ export class MajorService { ); } - deleteMajor(id: string): Observable { + public deleteMajor(id: string): Observable { return this.http.delete(`${this.apiUrlMajor}/${id}`).pipe( - map((res) => { + map((res: Object): Object => { this.refreshNeeded.next(); return res; }) ); } - deleteCourse(courseId: string): Observable { + public deleteCourse(courseId: string): Observable { return this.http.delete(`${this.apiUrlCourse}/${courseId}`); } deleteMajorWithCourse(major: MajorElm): Observable { return this.deleteCourse(major.courseId).pipe( - switchMap(() => this.deleteMajor(major.majorId)) + switchMap((): Observable => this.deleteMajor(major.majorId)) ); } - editMajor( + public editMajor( id: string, 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..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,17 +23,16 @@ import { FormsModule } from '@angular/forms'; styleUrl: './student-add-form.scss', }) export class StudentAddForm { - //todo - studentName = ''; - facultyNumber = ''; - faculty = ''; - major = ''; - course = ''; - type = ''; + protected studentName: string = ''; + protected facultyNumber: string = ''; + protected faculty: string = ''; + protected major: string = ''; + protected course: string = ''; + protected type: string = ''; constructor(private dialogRef: MatDialogRef) {} - save() { + 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 7db2f2b..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,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() public internalSearchText: string = ''; + @Output() public readonly searchTextChange: EventEmitter = new EventEmitter(); - @Input() internalSearchFacNum = ''; - @Output() searchFacNumChange = new EventEmitter(); + @Input() public internalSearchFacNum: string = ''; + @Output() public readonly searchFacNumChange: EventEmitter = new EventEmitter(); - @Input() internalSearchMajor = ''; - @Output() searchMajorChange = new EventEmitter(); + @Input() public internalSearchMajor: string = ''; + @Output() public readonly searchMajorChange: EventEmitter = new EventEmitter(); - @Input() subtypes: string[] = []; - @Input() selectedSubtype = ''; - @Output() subtypeChange = 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 04b7c24..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() { + 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 acffefe..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,13 +113,12 @@ 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() 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', @@ -132,44 +131,44 @@ 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 { - const name = this.searchText.toLowerCase(); - const major = this.searchMajor.toLowerCase(); - const facNum = this.searchFacNum; + private applyFilters(): void { + 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; }); } - static getFilterOptions(data: StudentElm[]) { + public static getFilterOptions(data: StudentElm[]) { return { - subtypes: [...new Set(data.map((e) => e.subtype))], + 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 7516f0a..b611efd 100644 --- a/uniplanWeb/src/app/features/university/university-service.ts +++ b/uniplanWeb/src/app/features/university/university-service.ts @@ -15,11 +15,11 @@ 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) {} - 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 3ec49fe..8d68305 100644 --- a/uniplanWeb/src/app/services/login-auth-service.ts +++ b/uniplanWeb/src/app/services/login-auth-service.ts @@ -4,17 +4,17 @@ import { Injectable } from '@angular/core'; providedIn: 'root' }) export class LoginAuthService { - private loggedIn = false; + private loggedIn: boolean = false; constructor() { this.loggedIn = !!localStorage.getItem('user'); } - isLoggedIn(): boolean { + public isLoggedIn(): boolean { return this.loggedIn; } - logout(): void { + public logout(): void { localStorage.removeItem('user'); this.loggedIn = false; }