Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions uniplanWeb/src/app/core/interfaces/major-option-elm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface MajorOptionElm {
id: string;
facultyId: string;
majorName: string;
}
2 changes: 1 addition & 1 deletion uniplanWeb/src/app/core/shared/add-button/add-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { TranslatePipe } from '@ngx-translate/core';
export class AddButton {
@Output() addClicked = new EventEmitter<void>();

onClick(): void {
public onClick(): void {
this.addClicked.emit();
}
}
4 changes: 2 additions & 2 deletions uniplanWeb/src/app/core/shared/add-form/add-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { TranslatePipe } from '@ngx-translate/core';
imports: [MatDialogModule, FormsModule, MatInputModule, TranslatePipe],
})
export class AddForm {
@Input() title: string = '';
@Input() public title: string = '';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use newer syntax->input signal


@Output() saveClicked = new EventEmitter<void>();
@Output() public readonly saveClicked :EventEmitter<void> = new EventEmitter<void>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use newer syntax

}
4 changes: 2 additions & 2 deletions uniplanWeb/src/app/core/shared/delete-form/delete-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { TranslatePipe } from '@ngx-translate/core';
imports: [MatDialogModule, FormsModule, MatInputModule, TranslatePipe],
})
export class DeleteForm {
@Input() title: string = '';
@Input() public title: string = '';

@Output() deleteClicked = new EventEmitter<void>();
@Output() public readonly deleteClicked:EventEmitter<void> = new EventEmitter<void>();
}
4 changes: 2 additions & 2 deletions uniplanWeb/src/app/core/shared/edit-form/edit-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { TranslatePipe } from '@ngx-translate/core';

})
export class EditForm {
@Input() title: string = '';
@Input() public title: string = '';

@Output() saveClicked = new EventEmitter<void>();
@Output() public readonly saveClicked:EventEmitter<void> = new EventEmitter<void>();
}
14 changes: 7 additions & 7 deletions uniplanWeb/src/app/core/shared/filters-form/filters-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ import { TranslatePipe } from '@ngx-translate/core';
imports: [MatFormFieldModule, MatSelectModule, MatOptionModule, TranslatePipe],
})
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<string>();
@Input() public selected = '';
@Output() public readonly selectionChange = new EventEmitter<string>();

onChange(value: string) {
public onChange(value: string) {
this.selectionChange.emit(value);
}

isObjectMode(): boolean {
public isObjectMode(): boolean {
return this.objectOptions && this.objectOptions.length > 0;
}
}
6 changes: 3 additions & 3 deletions uniplanWeb/src/app/core/shared/input-filter/input-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>();
@Input() public label: string = '';
@Input() public searchText: string = '';
@Output() public readonly searchTextChange: EventEmitter<string> = new EventEmitter<string>();
}
106 changes: 106 additions & 0 deletions uniplanWeb/src/app/core/shared/main-panel/main-panel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { Component, ChangeDetectionStrategy } from '@angular/core';

import { FacultyOptions } from '../../../features/faculty/faculty-options/faculty-options';
import { ViewService } from './view.service';
import { MajorOptions } from '../../../features/major/major-options/major-options';
import { FacultyTable } from '../../../features/faculty/faculty-table/faculty-table';
import { MajorTable } from '../../../features/major/major-table/major-table';
import { MajorFilters } from '../../../features/major/major-filters/major-filters';
import { StudentOptions } from '../../../features/student/student-options/student-options';
import {
StudentTable,
ELEMENT_STUDENT_DATA,
} from '../../../features/student/student-table/student-table';
import { StudentFilters } from '../../../features/student/student-filters/student-filters';
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',
imports: [
FacultyOptions,
MajorOptions,
FacultyTable,
MajorTable,
MajorFilters,
StudentOptions,
StudentTable,
StudentFilters
],
standalone: true,
templateUrl: './main-panel.html',
changeDetection: ChangeDetectionStrategy.Eager,
styleUrl: './main-panel.scss',
})
export class MainPanel {
protected currentView: string = 'home';

protected majors: MajorElm[] = [];
protected students: StudentElm[] = ELEMENT_STUDENT_DATA;

protected searchText: string = '';
protected searchFacNum: string = '';
protected searchMajor: string = '';
protected selectedStudentSubtype: string = '';
protected studentSubtypes: string[] = [];

protected selectedFaculty: string = '';
protected selectedType: string = '';
protected selectedSubtype: string = '';

protected faculties: { id: string; name: string }[] = [];
protected types: string[] = [];
protected subtypes: string[] = [];

private facultyMap: Map<string, string> = new Map<string, string>();

public constructor(
private viewService: ViewService,
private majorService: MajorService,
private facultyService: FacultyService
) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main panel doesn't exist anymore

this.viewService.currentView$.subscribe((view: string): void => {
this.currentView = view;
});
}

public ngOnInit(): void {
this.loadMajorFilters();
this.loadStudentFilters();

this.majorService.refreshNeeded.subscribe((): void => {
this.loadMajorFilters();
});

this.viewService.currentView$.subscribe((view: string): void => {
this.currentView = view;
});
}

private loadMajorFilters(): void {
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: MajorElm[]): void => {
this.majors = data;

const filterOptionsMajor = MajorTable.getFilterOptions(
this.majors,
this.facultyMap
);

this.faculties = filterOptionsMajor.faculties;
this.types = filterOptionsMajor.types;
this.subtypes = filterOptionsMajor.subtypes;
});
});
}

private loadStudentFilters(): void {
const filterOptionsStudent = StudentTable.getFilterOptions(this.students);
this.studentSubtypes = filterOptionsStudent.subtypes;
}
}
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { CommonModule } from '@angular/common';
import { RouterLink, RouterLinkActive } from '@angular/router';
import { TranslatePipe } from '@ngx-translate/core';

import { ViewService } from '../main-panel/view.service';
import { LoginAuthService } from '../../../services/login-auth-service';

@Component({
Expand All @@ -14,22 +15,22 @@ 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) {}

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;
}
Expand All @@ -38,7 +39,7 @@ export class NavmenuComponent implements OnInit {
}
}

toggleSidebar(): void {
protected toggleSidebar(): void {
this.isSidebarCollapsed = !this.isSidebarCollapsed;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,29 @@ import { TranslatePipe } from '@ngx-translate/core';
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<AddForm>,
private facultyService: FacultyService,
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;
Expand All @@ -72,11 +72,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.');
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,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('Възникна грешка при изтриването на факултета.');
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ import { TranslatePipe } from '@ngx-translate/core';
],
})
export class FacultyEdit {
facultyName = '';
location = '';
universityId = '';
protected facultyName: string = '';
protected location: string = '';
protected universityId: string = '';

constructor(
private dialogRef: MatDialogRef<EditForm>,
Expand All @@ -51,8 +51,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;
Expand All @@ -70,10 +69,10 @@ export class FacultyEdit {
universityId: this.universityId,
})
.subscribe({
next: () => {
next: (): void => {
this.dialogRef.close(true);
},
error: () => {
error: (): void => {
alert('Failed to update faculty.');
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});
Expand Down
4 changes: 2 additions & 2 deletions uniplanWeb/src/app/features/faculty/faculty-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class FacultyService {
);
}

createFaculty(faculty: {
public createFaculty(faculty: {
universityId: string;
facultyName: string;
location: string;
Expand All @@ -39,7 +39,7 @@ export class FacultyService {
);
}

editFaculty(
public editFaculty(
id: string,
updatedFaculty: {
universityId: string;
Expand Down
Loading