source: Sources/frontend/src/app/student-course/student-course.component.ts

Last change on this file was 8423429, checked in by AngelNasev <angel.nasev@…>, 17 months ago

Add backend and frontend projects

  • Property mode set to 100644
File size: 1.6 KB
Line 
1import {Component, OnInit} from '@angular/core';
2import {StudentCourseService} from "../student-course.service";
3import {StudentCourseInterface} from "../StudentCourseInterface";
4import {LoginService} from "../login.service";
5import {ProfessorCourseInterface} from "../ProfessorCourseInterface";
6import {ActiveUserInterface} from "../ActiveUserInterface";
7import {Router} from "@angular/router";
8
9@Component({
10 selector: 'app-student-course',
11 templateUrl: './student-course.component.html',
12 styleUrls: ['./student-course.component.css']
13})
14export class StudentCourseComponent implements OnInit {
15
16 studentCourses: StudentCourseInterface[] = []
17 professorCourses: ProfessorCourseInterface[] = []
18 activeUser: ActiveUserInterface | undefined;
19
20 constructor(private service: StudentCourseService,
21 private loginService: LoginService,
22 private router: Router) {
23 }
24
25 ngOnInit(): void {
26 this.activeUser = this.loginService.activeUser!!;
27 if (!this.activeUser) {
28 this.router.navigate(['/'])
29 }
30 // console.log("username", this.activeUser.username)
31 if (this.loginService.activeUser!!.userType == 'STUDENT')
32 this.service.getAllCoursesForActiveUserStudent(this.activeUser.username)
33 .subscribe(studentCourses => this.studentCourses = studentCourses);
34 if (this.activeUser.userType == 'PROFESSOR')
35 this.service.getAllCoursesForActiveUserProfessor(this.activeUser.username)
36 .subscribe(professorCourses => this.professorCourses = professorCourses);
37 }
38
39 saveCourseAsCurrent(id: number): void {
40 console.log("course id", id)
41 this.loginService.setCurrentCourse(id);
42 }
43
44
45}
Note: See TracBrowser for help on using the repository browser.