1 import {Component, ViewChild, OnInit} from '@angular/core';
2 import {ActivatedRoute} from '@angular/router';
3 import {PcrudService} from '@eg/core/pcrud.service';
4 import {IdlObject} from '@eg/core/idl.service';
5 import {StringComponent} from '@eg/share/string/string.component';
6 import {ToastService} from '@eg/share/toast/toast.service';
7 import {CourseService} from '@eg/staff/share/course.service';
8 import {CourseAssociateUsersComponent} from './course-associate-users.component';
9 import {CourseAssociateMaterialComponent} from './course-associate-material.component';
12 selector: 'eg-course-page',
13 templateUrl: './course-page.component.html'
16 export class CoursePageComponent implements OnInit {
18 currentCourse: IdlObject;
22 @ViewChild('courseMaterialDialog', {static: true})
23 private courseMaterialDialog: CourseAssociateMaterialComponent;
24 @ViewChild('courseUserDialog', {static: true})
25 private courseUserDialog: CourseAssociateUsersComponent;
28 @ViewChild('archiveFailedString', { static: true })
29 archiveFailedString: StringComponent;
30 @ViewChild('archiveSuccessString', { static: true })
31 archiveSuccessString: StringComponent;
34 private course: CourseService,
35 private pcrud: PcrudService,
36 private route: ActivatedRoute,
37 private toast: ToastService
42 this.courseId = +this.route.snapshot.paramMap.get('id');
43 this.course.getCourses([this.courseId]).then(course => {
44 this.currentCourse = course[0];
50 this.course.disassociateMaterials([this.currentCourse]).then(res => {
51 this.currentCourse.is_archived('t');
52 this.pcrud.update(this.currentCourse).subscribe(val => {
53 console.debug('archived: ' + val);
54 this.archiveSuccessString.current()
55 .then(str => this.toast.success(str));
57 this.archiveFailedString.current()
58 .then(str => this.toast.danger(str));