1 import {Component, Input, ViewChild, OnInit, TemplateRef} from '@angular/core';
2 import {Router, ActivatedRoute} from '@angular/router';
3 import {Observable, Observer, of} from 'rxjs';
4 import {DialogComponent} from '@eg/share/dialog/dialog.component';
5 import {AuthService} from '@eg/core/auth.service';
6 import {NetService} from '@eg/core/net.service';
7 import {EventService} from '@eg/core/event.service';
8 import {OrgService} from '@eg/core/org.service';
9 import {PcrudService} from '@eg/core/pcrud.service';
10 import {Pager} from '@eg/share/util/pager';
11 import {NgbModal, NgbModalOptions} from '@ng-bootstrap/ng-bootstrap';
12 import {GridDataSource} from '@eg/share/grid/grid';
13 import {GridComponent} from '@eg/share/grid/grid.component';
14 import {IdlObject, IdlService} from '@eg/core/idl.service';
15 import {StringComponent} from '@eg/share/string/string.component';
16 import {StaffBannerComponent} from '@eg/staff/share/staff-banner.component';
17 import {ToastService} from '@eg/share/toast/toast.service';
18 import {CourseService} from '@eg/staff/share/course.service';
19 import {CourseAssociateUsersComponent} from './course-associate-users.component';
20 import {CourseAssociateMaterialComponent} from './course-associate-material.component';
23 selector: 'eg-course-page',
24 templateUrl: './course-page.component.html'
27 export class CoursePageComponent implements OnInit {
29 currentCourse: IdlObject;
32 @ViewChild('courseMaterialDialog', {static: true})
33 private courseMaterialDialog: CourseAssociateMaterialComponent;
34 @ViewChild('courseUserDialog', {static: true})
35 private courseUserDialog: CourseAssociateUsersComponent;
38 @ViewChild('archiveFailedString', { static: true })
39 archiveFailedString: StringComponent;
40 @ViewChild('archiveSuccessString', { static: true })
41 archiveSuccessString: StringComponent;
46 private auth: AuthService,
47 private course: CourseService,
48 private event: EventService,
49 private idl: IdlService,
50 private net: NetService,
51 private org: OrgService,
52 private pcrud: PcrudService,
53 private route: ActivatedRoute,
54 private toast: ToastService
59 this.courseId = parseInt(this.route.snapshot.paramMap.get('id'));
60 this.course.getCourses([this.courseId]).then(course => {
61 this.currentCourse = course[0];
67 this.course.disassociateMaterials([this.currentCourse]).then(res => {
68 this.currentCourse.is_archived('t');
69 this.pcrud.update(this.currentCourse).subscribe(val => {
70 console.debug('archived: ' + val);
71 this.archiveSuccessString.current()
72 .then(str => this.toast.success(str));
74 this.archiveFailedString.current()
75 .then(str => this.toast.danger(str));