|
- import { Component, OnInit } from '@angular/core';
- import { ActivatedRoute } from '@angular/router';
- import { Subscription } from 'rxjs';
- import { Location } from '@angular/common';
- import { DemoService } from '../../../services/demo.service';
-
- @Component({
- selector: 'app-course-details',
- templateUrl: './course-details.component.html',
- styleUrls: ['./course-details.component.scss']
- })
- export class CourseDetailsComponent implements OnInit {
- selectedSegment: string = 'home';
- heading: string;
- routeSubscription: Subscription;
- selectedChapter: number = 0;
- showDeletePopup: boolean = false;
- isSubSegment: boolean = true;
- selectedTopic: number;
- classLevel: string;
-
- demoType: string;
-
- chapterList = [];
-
- constructor(
- private route: ActivatedRoute,
- private location: Location,
- private demoService: DemoService
- ) { }
-
- ngOnInit(): void {
- let classLevel: string, courseId: string;
- this.routeSubscription = this.route.params.subscribe((params) => {
- classLevel = params['classLevel'];
- this.classLevel = classLevel;
- courseId = params['courseId'];
- });
-
- this.demoType = localStorage.demoType;
- let courseData = this.demoService.courseData;
- let course = courseData.find((courseClass) => courseClass.classLevel === classLevel).courses.find((course) => course.id === courseId);
- this.heading = course.name;
- this.chapterList = course.chapterList;
- }
-
- ngOnDestroy() {
- this.routeSubscription.unsubscribe();
- }
-
- back() {
- this.location.back();
- }
-
- getPopupDeleteDecision(e : string) {
- if (e === 'false') {
- this.showDeletePopup = false;
- }
-
- if (e === 'true') {
- this.chapterList[this.selectedChapter].topics[this.selectedTopic].mediaState = 'none';
- this.showDeletePopup = false;
- }
- }
-
- downloadMedia() {
- this.chapterList[this.selectedChapter].topics[this.selectedTopic].mediaState = 'downloading';
-
- setTimeout(() => {
- this.chapterList[this.selectedChapter].topics[this.selectedTopic].mediaState = 'downloaded';
- }, 1500);
- }
-
- }
|