|
|
|
@ -1,26 +1,26 @@
|
|
|
|
|
import {Component, EventEmitter, Output, ViewChild} from '@angular/core';
|
|
|
|
|
import {HttpClientModule} from "@angular/common/http";
|
|
|
|
|
import {ApiService} from '@service/api.service';
|
|
|
|
|
import {OtherComponent} from "@component/schedule/tabs/other/other.component";
|
|
|
|
|
import {MatTab, MatTabChangeEvent, MatTabGroup} from "@angular/material/tabs";
|
|
|
|
|
import {
|
|
|
|
|
ProfessorComponent
|
|
|
|
|
} from "@component/schedule/tabs/professor/professor.component";
|
|
|
|
|
import {GroupComponent} from "@component/schedule/tabs/group/group.component";
|
|
|
|
|
import {
|
|
|
|
|
LectureHallComponent
|
|
|
|
|
} from "@component/schedule/tabs/lecture-hall/lecture-hall.component";
|
|
|
|
|
import {ProfessorResponse} from "@model/professorResponse";
|
|
|
|
|
import {catchError, map, Observable, of, switchMap, tap} from "rxjs";
|
|
|
|
|
import {GroupResponse} from "@model/groupResponse";
|
|
|
|
|
import {FacultyResponse} from "@model/facultyResponse";
|
|
|
|
|
import {CampusBasicInfoResponse} from "@model/campusBasicInfoResponse";
|
|
|
|
|
import {LectureHallResponse} from "@model/lectureHallResponse";
|
|
|
|
|
import {ReactiveFormsModule} from "@angular/forms";
|
|
|
|
|
import {AsyncPipe, NgIf} from "@angular/common";
|
|
|
|
|
import {DisciplineResponse} from "@model/disciplineResponse";
|
|
|
|
|
import {MatButton} from "@angular/material/button";
|
|
|
|
|
import {DataSpinnerComponent} from "@component/common/data-spinner/data-spinner.component";
|
|
|
|
|
import {ProfessorResponse} from "@api/v1/professorResponse";
|
|
|
|
|
import {FacultyResponse} from "@api/v1/facultyResponse";
|
|
|
|
|
import {GroupResponse} from "@api/v1/groupResponse";
|
|
|
|
|
import {CampusBasicInfoResponse} from "@api/v1/campusBasicInfoResponse";
|
|
|
|
|
import {LectureHallResponse} from "@api/v1/lectureHallResponse";
|
|
|
|
|
import {DisciplineService} from "@api/v1/discipline.service";
|
|
|
|
|
import {GroupComponent} from "@component/schedule/tabs/group/group.component";
|
|
|
|
|
import {ProfessorComponent} from "@component/schedule/tabs/professor/professor.component";
|
|
|
|
|
import {LectureHallComponent} from "@component/schedule/tabs/lecture-hall/lecture-hall.component";
|
|
|
|
|
import {FacultyService} from "@api/v1/faculty.service";
|
|
|
|
|
import {GroupService} from "@api/v1/group.service";
|
|
|
|
|
import {ProfessorService} from "@api/v1/professor.service";
|
|
|
|
|
import {CampusService} from "@api/v1/campus.service";
|
|
|
|
|
import {LectureHallService} from "@api/v1/lectureHall.service";
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-tabs',
|
|
|
|
@ -30,17 +30,18 @@ import {DataSpinnerComponent} from "@component/common/data-spinner/data-spinner.
|
|
|
|
|
OtherComponent,
|
|
|
|
|
MatTabGroup,
|
|
|
|
|
MatTab,
|
|
|
|
|
ProfessorComponent,
|
|
|
|
|
GroupComponent,
|
|
|
|
|
LectureHallComponent,
|
|
|
|
|
ReactiveFormsModule,
|
|
|
|
|
AsyncPipe,
|
|
|
|
|
NgIf,
|
|
|
|
|
MatButton,
|
|
|
|
|
DataSpinnerComponent
|
|
|
|
|
DataSpinnerComponent,
|
|
|
|
|
GroupComponent,
|
|
|
|
|
ProfessorComponent,
|
|
|
|
|
LectureHallComponent
|
|
|
|
|
],
|
|
|
|
|
templateUrl: './tabs.component.html',
|
|
|
|
|
styleUrl: './tabs.component.css'
|
|
|
|
|
styleUrl: './tabs.component.css',
|
|
|
|
|
providers: [FacultyService, GroupService, ProfessorService, CampusService, LectureHallService, DisciplineService ]
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export class TabsComponent {
|
|
|
|
@ -66,12 +67,17 @@ export class TabsComponent {
|
|
|
|
|
@Output() lectureHallSelected: EventEmitter<number> = new EventEmitter<number>();
|
|
|
|
|
@Output() professorSelected: EventEmitter<number> = new EventEmitter<number>();
|
|
|
|
|
|
|
|
|
|
constructor(private api: ApiService) {
|
|
|
|
|
constructor(
|
|
|
|
|
private facultyApi: FacultyService,
|
|
|
|
|
private groupApi: GroupService,
|
|
|
|
|
private professorApi: ProfessorService,
|
|
|
|
|
private campusApi: CampusService,
|
|
|
|
|
private lectureHallApi: LectureHallService,
|
|
|
|
|
private disciplineApi: DisciplineService) {
|
|
|
|
|
this.facultyLoad().then();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected async chooseTabs(event: MatTabChangeEvent) {
|
|
|
|
|
console.log(event);
|
|
|
|
|
switch (event.index) {
|
|
|
|
|
case 0:
|
|
|
|
|
await this.facultyLoad();
|
|
|
|
@ -92,7 +98,7 @@ export class TabsComponent {
|
|
|
|
|
if (this.facultiesLoaded === null) this.facultiesLoaded = false;
|
|
|
|
|
if (this.facultiesLoaded) return;
|
|
|
|
|
|
|
|
|
|
this.faculties = this.api.get<FacultyResponse[]>("Faculty/Get").pipe(
|
|
|
|
|
this.faculties = this.facultyApi.getFaculties().pipe(
|
|
|
|
|
tap(() => {
|
|
|
|
|
this.facultiesLoaded = true;
|
|
|
|
|
}),
|
|
|
|
@ -109,7 +115,7 @@ export class TabsComponent {
|
|
|
|
|
if (this.groupLoaded)
|
|
|
|
|
this.groups = this.groupsData.pipe(map(data => data.filter(x => x.facultyId === id)));
|
|
|
|
|
else
|
|
|
|
|
this.groups = this.api.get<GroupResponse[]>("Group/GetByFaculty/" + id).pipe(
|
|
|
|
|
this.groups = this.groupApi.getByFaculty(id).pipe(
|
|
|
|
|
tap(() => {
|
|
|
|
|
this.groupLoaded = false;
|
|
|
|
|
}),
|
|
|
|
@ -125,7 +131,7 @@ export class TabsComponent {
|
|
|
|
|
|
|
|
|
|
if (this.professorsLoaded) return;
|
|
|
|
|
|
|
|
|
|
this.api.get<ProfessorResponse[]>("Professor/Get").pipe(
|
|
|
|
|
this.professorApi.getProfessors().pipe(
|
|
|
|
|
catchError((error) => {
|
|
|
|
|
this.professorsLoaded = null;
|
|
|
|
|
throw error;
|
|
|
|
@ -147,7 +153,7 @@ export class TabsComponent {
|
|
|
|
|
|
|
|
|
|
if (this.campusesLoaded) return;
|
|
|
|
|
|
|
|
|
|
this.campuses = this.api.get<CampusBasicInfoResponse[]>("Campus/Get").pipe(
|
|
|
|
|
this.campuses = this.campusApi.getCampus().pipe(
|
|
|
|
|
tap(() => {
|
|
|
|
|
this.campusesLoaded = true;
|
|
|
|
|
}),
|
|
|
|
@ -164,7 +170,7 @@ export class TabsComponent {
|
|
|
|
|
if (this.lectureHallsLoaded)
|
|
|
|
|
this.lectureHalls = this.lectureHallsData.pipe(map(data => data.filter(x => x.campusId === id)));
|
|
|
|
|
else
|
|
|
|
|
this.lectureHalls = this.api.get<LectureHallResponse[]>("LectureHall/GetByCampus/" + id).pipe(
|
|
|
|
|
this.lectureHalls = this.lectureHallApi.getByCampus(id).pipe(
|
|
|
|
|
tap(() => {
|
|
|
|
|
this.lectureHallsLoaded = false;
|
|
|
|
|
}),
|
|
|
|
@ -180,7 +186,7 @@ export class TabsComponent {
|
|
|
|
|
await this.campusLoad();
|
|
|
|
|
|
|
|
|
|
if (!this.lectureHallsLoaded) {
|
|
|
|
|
this.lectureHallsData = this.api.get<LectureHallResponse[]>("LectureHall/Get");
|
|
|
|
|
this.lectureHallsData = this.lectureHallApi.getLectureHalls();
|
|
|
|
|
this.lectureHallsData.pipe(
|
|
|
|
|
switchMap(lectureHalls => this.campuses.pipe(
|
|
|
|
|
map(campuses => {
|
|
|
|
@ -205,7 +211,7 @@ export class TabsComponent {
|
|
|
|
|
|
|
|
|
|
protected async loadDisciplines() {
|
|
|
|
|
if (!this.disciplinesLoaded) {
|
|
|
|
|
this.api.get<DisciplineResponse[]>("Discipline/Get").pipe(
|
|
|
|
|
this.disciplineApi.getDisciplines().pipe(
|
|
|
|
|
catchError((error) => {
|
|
|
|
|
this.disciplinesLoaded = null;
|
|
|
|
|
throw error;
|
|
|
|
@ -226,7 +232,7 @@ export class TabsComponent {
|
|
|
|
|
await this.facultyLoad();
|
|
|
|
|
|
|
|
|
|
if (!this.groupLoaded) {
|
|
|
|
|
this.groupsData = this.api.get<GroupResponse[]>("Group/Get");
|
|
|
|
|
this.groupsData = this.groupApi.getGroups();
|
|
|
|
|
this.groupsData.pipe(
|
|
|
|
|
switchMap(groups => this.faculties.pipe(
|
|
|
|
|
map(campuses => {
|
|
|
|
@ -267,11 +273,4 @@ export class TabsComponent {
|
|
|
|
|
@ViewChild('lecture') lectureHallEx!: OtherComponent;
|
|
|
|
|
@ViewChild('group') groupEx!: OtherComponent;
|
|
|
|
|
@ViewChild('professor') professorEx!: OtherComponent;
|
|
|
|
|
|
|
|
|
|
onClickNagmi() {
|
|
|
|
|
console.log('huy = ' + this.disciplineEx.selectedIds);
|
|
|
|
|
console.log('huy2 = ' + this.lectureHallEx.selectedIds);
|
|
|
|
|
console.log('huy3 = ' + this.groupEx.selectedIds);
|
|
|
|
|
console.log('huy3 = ' + this.professorEx.selectedIds);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|