1 import {Component, Input, ViewChild, OnInit, TemplateRef} from '@angular/core';
2 import {ActivatedRoute} from '@angular/router';
3 import {PcrudService} from '@eg/core/pcrud.service';
4 import {IdlObject, IdlService} 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;
21 @ViewChild('courseMaterialDialog', {static: true})
22 private courseMaterialDialog: CourseAssociateMaterialComponent;
23 @ViewChild('courseUserDialog', {static: true})
24 private courseUserDialog: CourseAssociateUsersComponent;
27 @ViewChild('archiveFailedString', { static: true })
28 archiveFailedString: StringComponent;
29 @ViewChild('archiveSuccessString', { static: true })
30 archiveSuccessString: StringComponent;
35 private course: CourseService,
36 private pcrud: PcrudService,
37 private route: ActivatedRoute,
38 private toast: ToastService
43 this.courseId = +this.route.snapshot.paramMap.get('id');
44 this.course.getCourses([this.courseId]).then(course => {
45 this.currentCourse = course[0];
51 this.course.disassociateMaterials([this.currentCourse]).then(res => {
52 this.currentCourse.is_archived('t');
53 this.pcrud.update(this.currentCourse).subscribe(val => {
54 console.debug('archived: ' + val);
55 this.archiveSuccessString.current()
56 .then(str => this.toast.success(str));
58 this.archiveFailedString.current()
59 .then(str => this.toast.danger(str));