Newer
Older
import {Component, OnDestroy, OnInit} from '@angular/core';
ywb16155
committed
import {takeWhile} from 'rxjs/operators';
import {LecturerInfoService} from 'src/app/services/lecturer-info.service';
import {ActivatedRoute, Router} from '@angular/router';
import {LecturerDataService} from 'src/app/services/lecturer-data.service';
import {LecturerViewService} from 'src/app/services/lecturer-view.service';
import {GridOptions} from 'ag-grid-community';
import {ViewClassesButtonComponent} from 'src/app/GridComponents/ViewClassesButton/view-classes-button.component';
ywb16155
committed
@Component({
selector: 'app-lecturer-dashboard',
templateUrl: './lecturer-dashboard.component.html',
styleUrls: ['./lecturer-dashboard.component.css']
})
export class LecturerDashboardComponent implements OnInit, OnDestroy {
private isAlive = true;
private lecturerId: String;
public rowData: any;
{headerName: 'Class Code', field: 'classCode', sortable: true, lockPosition: true},
{headerName: 'Class Name', field: 'classname', sortable: true, lockPosition: true},
{headerName: 'Year', field: 'year', sortable: true, lockPosition: true},
{headerName: 'View', field: '', cellRendererFramework: ViewClassesButtonComponent, lockPosition: true},
ywb16155
committed
constructor(private lecturerInfoService: LecturerInfoService,
private lecturerDataService: LecturerDataService,
ywb16155
committed
private lecturerViewService: LecturerViewService,
ywb16155
committed
private router: Router,
private route: ActivatedRoute) {
}
ngOnInit(): void {
this.route.params.subscribe(params => { this.lecturerId = params.id; }).add(takeWhile(() => this.isAlive));
this.lecturerDataService.lecturerId = this.lecturerId;
this.gridOptions = {
context: {componentParent: this}
};
this.rowData = this.lecturerInfoService.getLecturerClasses(this.lecturerId);
ywb16155
committed
}
ngOnDestroy(): void {
this.isAlive = false;
}
public goToPaperView(classCode: String) {
this.lecturerDataService.classCode = classCode;
ywb16155
committed
this.lecturerViewService.changeToDashboard(false);
this.router.navigate(['/paper-view']);
this.ngOnDestroy();
}
public goToTemplateView() {
this.lecturerViewService.changeToDashboard(false);
this.router.navigate(['/template-view']);
this.ngOnDestroy();
ywb16155
committed
}
public createPaperView() {
this.lecturerDataService.isTemplate = false;
this.lecturerViewService.changeToDashboard(false);
this.router.navigate(['/creation-view']);
this.ngOnDestroy();
}
public createTemplateView() {
this.lecturerDataService.isTemplate = true;
this.lecturerViewService.changeToDashboard(false);
this.router.navigate(['/creation-view']);
this.ngOnDestroy();