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
74 changes: 74 additions & 0 deletions uniplanWeb/src/app/core/shared/main-panel/main-panel.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<div class="mainPanel" [class.login-view]="currentView === 'login'"> <div class="components-wrapper">
@if (currentView === 'faculty') {
<div class="component-panel faculty">
<app-faculty-options></app-faculty-options>
<app-faculty-table></app-faculty-table>
</div>
}

@if (currentView === 'home') {
<div class="component-panel home">
<h1>Main!</h1>
</div>
}

@if (currentView === 'login') {
<div class="component-panel login">
<app-login-form></app-login-form>
</div>
}

@if (currentView === 'major') {
<div class="component-panel major">
<div class="controls-row">
<app-major-options class="options"></app-major-options>
<app-major-filters
[faculties]="faculties"
[types]="types"
[subtypes]="subtypes"
[selectedFaculty]="selectedFaculty"
[selectedType]="selectedType"
[selectedSubtype]="selectedSubtype"
[internalSearchText]="searchText"
(facultyChange)="selectedFaculty = $event"
(typeChange)="selectedType = $event"
(subtypeChange)="selectedSubtype = $event"
(searchTextChange)="searchText = $event">
</app-major-filters>
</div>
<app-major-table
[faculty]="selectedFaculty"
[type]="selectedType"
[subtype]="selectedSubtype"
[searchText]="searchText">
</app-major-table>
</div>
}

@if (currentView === 'student') {
<div class="component-panel student">
<div class="controls-row">
<app-student-options class="options"></app-student-options>
<app-student-filters
[internalSearchText]="searchText"
(searchTextChange)="searchText = $event"
[internalSearchFacNum]="searchFacNum"
(searchFacNumChange)="searchFacNum = $event"
[internalSearchMajor]="searchMajor"
(searchMajorChange)="searchMajor = $event"
[subtypes]="studentSubtypes"
[selectedSubtype]="selectedStudentSubtype"
(subtypeChange)="selectedStudentSubtype = $event">
</app-student-filters>
</div>
<app-student-table
[searchText]="searchText"
[searchFacNum]="searchFacNum"
[searchMajor]="searchMajor"
[subtype]="selectedStudentSubtype"
[subtypes]="studentSubtypes">
</app-student-table>
</div>
}
</div>
</div>
98 changes: 98 additions & 0 deletions uniplanWeb/src/app/core/shared/main-panel/main-panel.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
.mainPanel {
height: 100%;
width: 100%;
overflow: auto;
display: flex;
justify-content: center;
}

.component-panel.login {
width: 100%;
min-height: calc(100vh - 80px);
display: flex;
align-items: center;
justify-content: center;
padding: 32px;
box-sizing: border-box;
}

.components-wrapper {
position: relative;
margin-left: 8%;
margin-right: 13%;
max-width: 2000px;
width: 100%;

@media screen and (max-width: 1024px) {
margin-left: 5%;
padding-left: 1%;
margin-right: 5%;
}

@media screen and (max-width: 768px) {
margin-left: 2%;
padding-left: 1%;
margin-right: 2%;
}

@media screen and (max-width: 480px) {
margin-left: 1%;
padding-left: 1%;
margin-right: 1%;
}
}

.component-panel .major .component-panel .student {
display: grid;
grid-template-columns: 1fr;
grid-template-rows: auto 1fr;
gap: 16px;
height: 100%;
padding: 5px;
margin-top: 1%;
}

.component-panel {
margin-top: 4%;
}

.controls-row {
display: grid;
grid-template-columns: auto 1fr;
gap: 16px;
align-items: center;
}

.options {
padding-bottom: 20px;
}

.mainPanel.login-view {
align-items: center;
justify-content: center;
}

.mainPanel.login-view .components-wrapper {
margin-left: 0;
margin-right: 0;
padding-left: 0;
width: 100%;
max-width: none;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}

.component-panel.login {
width: 100%;
min-height: 100%;
margin-top: 0;
display: flex;
align-items: center;
justify-content: center;
padding: 32px;
box-sizing: border-box;
}


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 { LoginForm } from '../../../features/login/login-form/login-form';

@Component({
selector: 'app-main-panel',
imports: [
FacultyOptions,
MajorOptions,
FacultyTable,
MajorTable,
MajorFilters,
StudentOptions,
StudentTable,
StudentFilters,
LoginForm,
],
standalone: true,
templateUrl: './main-panel.html',
changeDetection: ChangeDetectionStrategy.Eager,
styleUrl: './main-panel.scss',
})
export class MainPanel {
currentView = 'home';

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

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

selectedFaculty = '';
selectedType = '';
selectedSubtype = '';

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

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

constructor(
private viewService: ViewService,
private majorService: MajorService,
private facultyService: FacultyService
) {
this.viewService.currentView$.subscribe((view) => {
this.currentView = view;
});
}

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

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

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

private loadMajorFilters(): void {
this.facultyService.getFaculties().subscribe((faculties) => {
this.facultyMap = new Map(faculties.map((f) => [f.id, f.facultyName]));

this.majorService.getMajors().subscribe((data) => {
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,30 +60,39 @@ <h2>Logo</h2>
</a>
</li>

@if (authService.isLoggedIn()) {
<li class="list dropdown profile">
<a href="#" class="nav-link">
<div class="profile-link">
<img src class="profile-img" alt="" />
<span class="profile-name">Иван Иванов</span>
</div>
</a>
<ul class="dropdown-menu">
<li><a href="#"><span class="link">{{ 'navmenu.open-profile' | translate }}</span></a></li>
<li class="logout">
<a href="#"><i class="bx bx-log-out icon"></i><span class="link">{{ 'navmenu.logout' | translate }}</span></a>
</li>
@if (authService.isLoggedIn()) {
<li class="list dropdown profile">
<a href="#" class="nav-link">
<div class="profile-link">
<img src class="profile-img" />
<span class="profile-name">{{ authService.getUsername() }}</span>
</div>
</a>
<ul class="dropdown-menu">
<li>
<a href="#" (click)="onProfileOpenClick()">
<span class="link">Отвори</span>
</a>
</li>

<li class="logout">
<a href="#" (click)="onLogoutClick()">
<i class="bx bx-log-out icon"></i>
<span class="link">Изход</span>
</a>
</li>
</ul>
</li>
}

@if (!authService.isLoggedIn()) {
<li class="list">
<a href="#" class="nav-link">
<i class="bx bx-log-in icon"></i><span class="link">{{ 'navmenu.login' | translate }}</span>
<a href="#" class="nav-link" (click)="onLoginClick()">
<i class="bx bx-log-in icon"></i>
<span class="link">Вход</span>
</a>
</li>
}
</ul>
</div>
</li>
}
</ul>
</div>
</div>
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 Down Expand Up @@ -41,4 +42,33 @@ export class NavmenuComponent implements OnInit {
toggleSidebar(): void {
this.isSidebarCollapsed = !this.isSidebarCollapsed;
}

onHomeClick(): void {
this.viewService.setView('home');
}

onFacultyClick(): void {
this.viewService.setView('faculty');
}

onMajorClick(): void {
this.viewService.setView('major');
}

onStudentClick(): void {
this.viewService.setView('student');
}

protected onLoginClick(): void {
this.viewService.setView('login');
}

protected onLogoutClick(): void {
this.authService.logout();
this.viewService.setView('home');
}

protected onProfileOpenClick(): void {
this.viewService.setView('home');
}
}
Loading