Angular LMS app
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 

75 line
2.2 KiB

  1. import { Component, OnInit } from '@angular/core';
  2. import { ActivatedRoute } from '@angular/router';
  3. import { Subscription } from 'rxjs';
  4. import { Location } from '@angular/common';
  5. import { DemoService } from '../../../services/demo.service';
  6. @Component({
  7. selector: 'app-course-details',
  8. templateUrl: './course-details.component.html',
  9. styleUrls: ['./course-details.component.scss']
  10. })
  11. export class CourseDetailsComponent implements OnInit {
  12. selectedSegment: string = 'home';
  13. heading: string;
  14. routeSubscription: Subscription;
  15. selectedChapter: number = 0;
  16. showDeletePopup: boolean = false;
  17. isSubSegment: boolean = true;
  18. selectedTopic: number;
  19. classLevel: string;
  20. demoType: string;
  21. chapterList = [];
  22. constructor(
  23. private route: ActivatedRoute,
  24. private location: Location,
  25. private demoService: DemoService
  26. ) { }
  27. ngOnInit(): void {
  28. let classLevel: string, courseId: string;
  29. this.routeSubscription = this.route.params.subscribe((params) => {
  30. classLevel = params['classLevel'];
  31. this.classLevel = classLevel;
  32. courseId = params['courseId'];
  33. });
  34. this.demoType = localStorage.demoType;
  35. let courseData = this.demoService.courseData;
  36. let course = courseData.find((courseClass) => courseClass.classLevel === classLevel).courses.find((course) => course.id === courseId);
  37. this.heading = course.name;
  38. this.chapterList = course.chapterList;
  39. }
  40. ngOnDestroy() {
  41. this.routeSubscription.unsubscribe();
  42. }
  43. back() {
  44. this.location.back();
  45. }
  46. getPopupDeleteDecision(e : string) {
  47. if (e === 'false') {
  48. this.showDeletePopup = false;
  49. }
  50. if (e === 'true') {
  51. this.chapterList[this.selectedChapter].topics[this.selectedTopic].mediaState = 'none';
  52. this.showDeletePopup = false;
  53. }
  54. }
  55. downloadMedia() {
  56. this.chapterList[this.selectedChapter].topics[this.selectedTopic].mediaState = 'downloading';
  57. setTimeout(() => {
  58. this.chapterList[this.selectedChapter].topics[this.selectedTopic].mediaState = 'downloaded';
  59. }, 1500);
  60. }
  61. }