@@ -8,27 +8,53 @@ import {
88 MatExpansionPanelHeader ,
99 MatExpansionPanelTitle
1010} from '@angular/material/expansion' ;
11- import { NgComponentOutlet , NgForOf , NgIf } from "@angular/common" ;
11+ import { NgForOf , NgIf } from "@angular/common" ;
1212import { MatTab , MatTabContent , MatTabGroup , MatTabLabel } from "@angular/material/tabs" ;
1313import { icons } from "../../environment/styles" ;
1414import {
1515 IllnessNotificationModel
1616} from "../illness-notification/model/illness-notification-model" ;
17- import { SubjectListComponent } from "../user/courses/subject/subject-dialogs/subject-dialogs.component" ;
18- import { RoomListComponent } from "../user/courses/room/room-dialogs/room-list.component" ;
19- import { ClassRoomListComponent } from "../user/courses/classroom/class-room-dialogs/class-room-dialogs.component" ;
20- import { CourseListComponent } from "../user/courses/course-dialogs/course-dialogs.component" ;
2117import { FileService } from "../file/file.service" ;
2218import { MatButton } from "@angular/material/button" ;
2319import { MatIcon } from "@angular/material/icon" ;
2420import { ManagementService } from "./management.service" ;
2521import { IllnessNotificationStatus } from "../illness-notification/illness-notification-status" ;
22+ import { ListItemInfo } from "../common/abstract-list/abstract-list.component" ;
23+ import { CourseModel } from "../user/courses/course-model" ;
24+ import { ClassRoomModel } from "../user/courses/classroom/class-room-model" ;
25+ import { RoomModel } from "../user/courses/room/room-model" ;
26+ import { SubjectModel } from "../user/courses/subject/subject-model" ;
27+ import { EntityListComponent } from "../entity/entity-list/entity-list.component" ;
28+ import { SubjectService } from "../user/courses/subject/subject.service" ;
29+ import { RoomService } from "../user/courses/room/room.service" ;
30+ import { ClassRoomService } from "../user/courses/classroom/class-room.service" ;
31+ import { CourseService } from "../user/courses/course.service" ;
32+ import { EntityService } from "../entity/entity-service" ;
33+ import { ListItemContent } from "../common/abstract-list/list-item-content" ;
34+ import { CourseListItemComponent } from "../user/courses/course-dialogs/course-list-item/course-list-item.component" ;
35+ import { ComponentType } from "@angular/cdk/overlay" ;
36+ import { CreateCourseComponent } from "../user/courses/course-dialogs/course-dialogs.component" ;
37+ import { DeleteDialogComponent } from "../common/delete-dialog/delete-dialog.component" ;
38+ import {
39+ CreateSubjectComponent ,
40+ DeleteSubjectComponent
41+ } from "../user/courses/subject/subject-dialogs/subject-dialogs.component" ;
42+ import {
43+ CreateClassRoomComponent ,
44+ DeleteClassRoomComponent
45+ } from "../user/courses/classroom/class-room-dialogs/class-room-dialogs.component" ;
46+ import { CreateRoomComponent , DeleteRoomComponent } from "../user/courses/room/room-dialogs/room-list.component" ;
47+ import { MatDialog } from "@angular/material/dialog" ;
2648
2749export interface CourseTab
2850{
29- label : string ,
30- icon : string ,
31- component : Type < any >
51+ label : string ;
52+ icon : string ;
53+ service : EntityService < any , any , any , any > ;
54+ itemInfo : ListItemInfo < any > ;
55+ newDialog : ComponentType < any > ,
56+ deleteDialog : ComponentType < any > ,
57+ content ?: Type < ListItemContent < any > >
3258}
3359
3460
@@ -50,25 +76,72 @@ export interface CourseTab
5076 MatTabLabel ,
5177 MatIcon ,
5278 NgForOf ,
53- NgComponentOutlet ,
79+ EntityListComponent
5480 ] ,
5581 templateUrl : './management.component.html' ,
5682 styleUrl : './management.component.scss'
5783} )
5884export class ManagementComponent implements OnInit {
5985
60- private readonly _courseComponentsTabs : CourseTab [ ] = [
61- { label : 'Courses' , icon : icons . course , component : CourseListComponent } ,
62- { label : 'Class Rooms' , icon : icons . classroom , component : ClassRoomListComponent } ,
63- { label : 'Rooms' , icon : icons . room , component : RoomListComponent } ,
64- { label : 'Subjects' , icon : icons . subject , component : SubjectListComponent }
65- ] ;
86+ private readonly _courseComponentsTabs : CourseTab [ ] ;
6687
6788 userList : UserModel [ ] = [ ] ;
6889
6990 illnessNotifications : IllnessNotificationModel [ ] = [ ]
7091
71- public constructor ( protected managementService : ManagementService , protected userService : UserService , protected fileService : FileService ) {
92+ public constructor (
93+ private readonly _matDialog : MatDialog ,
94+ protected managementService : ManagementService ,
95+ protected userService : UserService ,
96+ protected fileService : FileService ,
97+ courseService : CourseService ,
98+ classRoomService : ClassRoomService ,
99+ roomService : RoomService ,
100+ subjectService : SubjectService )
101+ {
102+ const idTitle : ( obj : { id : string } ) => string = ( obj : { id : string } ) : string => obj . id
103+
104+ this . _courseComponentsTabs = [ {
105+ label : 'Courses' ,
106+ icon : icons . course ,
107+ service : courseService ,
108+ newDialog : CreateCourseComponent ,
109+ deleteDialog : DeleteDialogComponent ,
110+ itemInfo : {
111+ title : ( value : CourseModel ) : string => value . name ,
112+ chips : ( value : CourseModel ) : string [ ] => [
113+ `${ value . teacher ?. name } ` ,
114+ `${ value . students ?. length } Student(s)` , value . subject . id ,
115+ `${ value . appointmentEntries . length } Appointment(s)` ,
116+ `${ value . frequentAppointments . length } Frequent Appointment(s)`
117+ ]
118+ } ,
119+ content : CourseListItemComponent
120+ } , {
121+ label : 'Class Rooms' ,
122+ icon : icons . classroom ,
123+ service : classRoomService ,
124+ newDialog : CreateClassRoomComponent ,
125+ deleteDialog : DeleteClassRoomComponent ,
126+ itemInfo : {
127+ title : idTitle ,
128+ chips : ( value : ClassRoomModel ) : string [ ] => [ `Tutor: ${ value . tutor . name } ` , `${ value . students . length } Users` ]
129+ }
130+ } , {
131+ label : 'Rooms' ,
132+ icon : icons . room ,
133+ service : roomService ,
134+ newDialog : CreateRoomComponent ,
135+ deleteDialog : DeleteRoomComponent ,
136+ itemInfo : { title : idTitle }
137+ } , {
138+ label : 'Subjects' ,
139+ icon : icons . subject ,
140+ service : subjectService ,
141+ newDialog : CreateSubjectComponent ,
142+ deleteDialog : DeleteSubjectComponent ,
143+ itemInfo : { title : idTitle }
144+ } ] ;
72145 }
73146
74147 ngOnInit ( ) : void {
@@ -78,6 +151,11 @@ export class ManagementComponent implements OnInit {
78151 } ) ;
79152 }
80153
154+ protected openDialog ( dialog : ComponentType < any > )
155+ {
156+ return this . _matDialog . open ( dialog , { width : '600px' , disableClose : true } ) ;
157+ }
158+
81159 protected get courseComponentTabs ( ) : CourseTab [ ] {
82160 return this . _courseComponentsTabs ;
83161 }
@@ -99,5 +177,6 @@ export class ManagementComponent implements OnInit {
99177 }
100178
101179 protected readonly IllnessNotificationStatus = IllnessNotificationStatus ;
180+ protected readonly open = open ;
102181}
103182
0 commit comments