refactor: bind components to api
This commit is contained in:
@ -43,9 +43,6 @@ export class TabsComponent {
|
||||
constructor(private scheduleApi: ScheduleService) {
|
||||
}
|
||||
|
||||
protected campuses: Observable<CampusBasicInfoResponse[]> = of([]);
|
||||
protected lectureHalls: Observable<LectureHallResponse[]> = of([]);
|
||||
private lectureHallsData: Observable<LectureHallResponse[]> = of([]);
|
||||
protected groupSelected(id: number) {
|
||||
this.eventResult.emit(
|
||||
[
|
||||
@ -153,68 +150,10 @@ export class TabsComponent {
|
||||
}
|
||||
}
|
||||
|
||||
protected async loadDisciplines() {
|
||||
if (!this.disciplinesLoaded) {
|
||||
this.disciplineApi.getDisciplines().pipe(
|
||||
catchError((error) => {
|
||||
this.disciplinesLoaded = null;
|
||||
throw error;
|
||||
})).subscribe(data => {
|
||||
this.disciplineEx.Data = data.map(x =>
|
||||
({
|
||||
id: x.id,
|
||||
name: x.name,
|
||||
selected: false
|
||||
}));
|
||||
this.disciplinesLoaded = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected async loadGroups() {
|
||||
if (!this.facultiesLoaded)
|
||||
await this.facultyLoad();
|
||||
|
||||
if (!this.groupLoaded) {
|
||||
this.groupsData = this.groupApi.getGroups();
|
||||
this.groupsData.pipe(
|
||||
switchMap(groups => this.faculties.pipe(
|
||||
map(campuses => {
|
||||
return groups.map(x => {
|
||||
const faculties = campuses.find(c => c.id === x.facultyId);
|
||||
const name = faculties ? faculties.name : '';
|
||||
return {
|
||||
id: x.id,
|
||||
name: `${x.name} (${name})`,
|
||||
selected: false
|
||||
};
|
||||
});
|
||||
})
|
||||
))
|
||||
).subscribe(data => {
|
||||
this.groupEx.Data = data;
|
||||
this.groupLoaded = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected async extensionLoad() {
|
||||
// Lecture Hall
|
||||
await this.loadLectureHalls();
|
||||
|
||||
// Disciplines
|
||||
await this.loadDisciplines();
|
||||
|
||||
// Groups
|
||||
await this.loadGroups();
|
||||
|
||||
// Professors
|
||||
if (this.professorsData.length === 0)
|
||||
this.professorsLoad();
|
||||
}
|
||||
|
||||
/*
|
||||
@ViewChild('discipline') disciplineEx!: OtherComponent;
|
||||
@ViewChild('lecture') lectureHallEx!: OtherComponent;
|
||||
@ViewChild('group') groupEx!: OtherComponent;
|
||||
@ViewChild('professor') professorEx!: OtherComponent;
|
||||
*/
|
||||
}
|
||||
|
Reference in New Issue
Block a user