@@ -7,5 +7,9 @@ import { Component } from '@angular/core'; | |||
styleUrls: ['./app.component.scss'] | |||
}) | |||
export class AppComponent { | |||
constructor() { | |||
if (!localStorage.demoType) { | |||
localStorage.demoType = 'Teacher'; | |||
} | |||
} | |||
} |
@@ -1,14 +1,10 @@ | |||
import { Injectable } from '@angular/core'; | |||
import { Observable, Observer } from 'rxjs'; | |||
import * as moment from 'moment'; | |||
@Injectable({ | |||
providedIn: 'root' | |||
}) | |||
export class DemoService { | |||
demoType: Observable<string>; | |||
demoTypeObserver: Observer<string>; | |||
courseData = [{ | |||
classLevel: '10', | |||
courses: [{ | |||
@@ -328,9 +324,5 @@ export class DemoService { | |||
}]; | |||
constructor() { | |||
this.demoType = Observable.create((observer: Observer<string>) => { | |||
this.demoTypeObserver = observer; | |||
this.demoTypeObserver.next('Teacher'); | |||
}); | |||
} | |||
} |
@@ -19,7 +19,6 @@ export class CourseDetailsComponent implements OnInit { | |||
selectedTopic: number; | |||
classLevel: string; | |||
demoTypeSubscriber: Subscription; | |||
demoType: string; | |||
chapterList = []; | |||
@@ -38,19 +37,11 @@ export class CourseDetailsComponent implements OnInit { | |||
courseId = params['courseId']; | |||
}); | |||
this.demoTypeSubscriber = this.demoService.demoType.subscribe((type) => { | |||
this.demoType = type; | |||
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; | |||
console.log(this.chapterList); | |||
}); | |||
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() { | |||
@@ -1,6 +1,5 @@ | |||
import { Component, OnInit } from '@angular/core'; | |||
import { DemoService } from '../../services/demo.service'; | |||
import { Subscription } from 'rxjs'; | |||
import { Router } from '@angular/router'; | |||
@Component({ | |||
@@ -9,7 +8,6 @@ import { Router } from '@angular/router'; | |||
styleUrls: ['./courses.component.scss'] | |||
}) | |||
export class CoursesComponent implements OnInit { | |||
demoTypeSubscriber: Subscription; | |||
demoType: string; | |||
classCourseList = []; | |||
@@ -19,17 +17,15 @@ export class CoursesComponent implements OnInit { | |||
) { } | |||
ngOnInit(): void { | |||
this.demoTypeSubscriber = this.demoService.demoType.subscribe((type) => { | |||
this.demoType = type; | |||
if (type === 'Student') { | |||
this.classCourseList = this.demoService.courseData; | |||
this.classCourseList = this.classCourseList.filter((courseClass) => { | |||
return courseClass.level === '10'; | |||
}) | |||
} else { | |||
this.classCourseList = this.demoService.courseData; | |||
} | |||
}); | |||
this.demoType = localStorage.demoType; | |||
if (this.demoType === 'Student') { | |||
this.classCourseList = this.demoService.courseData; | |||
this.classCourseList = this.classCourseList.filter((courseClass) => { | |||
return courseClass.classLevel === '10'; | |||
}); | |||
} else { | |||
this.classCourseList = this.demoService.courseData; | |||
} | |||
} | |||
goToCourse(classLevel: string, courseId: string) { | |||
@@ -1,7 +1,6 @@ | |||
import { Component, OnInit } from '@angular/core'; | |||
import { ScrollEvent } from 'ngx-scroll-event'; | |||
import { DemoService } from '../../services/demo.service'; | |||
import { Subscription } from 'rxjs'; | |||
@Component({ | |||
selector: 'app-home', | |||
@@ -13,7 +12,6 @@ export class HomeComponent implements OnInit { | |||
showClassDetails: boolean; | |||
selectedSegment: string = 'transcript'; | |||
showVideo: boolean = false; | |||
demoTypeSubscriber: Subscription; | |||
demoType: string; | |||
classList = []; | |||
@@ -29,17 +27,15 @@ export class HomeComponent implements OnInit { | |||
this.showClassDetails = false; | |||
} | |||
this.demoTypeSubscriber = this.demoService.demoType.subscribe((type) => { | |||
this.demoType = type; | |||
if (type === 'Student') { | |||
this.classList = this.demoService.studentClassList; | |||
this.showVideo = true; | |||
} | |||
this.demoType = localStorage.demoType; | |||
if (this.demoType === 'Student') { | |||
this.classList = this.demoService.studentClassList; | |||
this.showVideo = true; | |||
} | |||
if (type === 'Teacher') { | |||
this.classList = this.demoService.teacherClassList; | |||
} | |||
}); | |||
if (this.demoType === 'Teacher') { | |||
this.classList = this.demoService.teacherClassList; | |||
} | |||
} | |||
public handleScroll(event: ScrollEvent) { | |||
@@ -58,8 +54,4 @@ export class HomeComponent implements OnInit { | |||
} | |||
} | |||
ngOnDestroy() { | |||
this.demoTypeSubscriber.unsubscribe(); | |||
} | |||
} |
@@ -12,8 +12,8 @@ | |||
<figure> | |||
<img src="https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg"> | |||
</figure> | |||
<h5> Dwayne The Rock </h5> | |||
<p> 3000 XP </p> | |||
<h5> {{ demoType }} </h5> | |||
<p *ngIf="demoType === 'Student'"> 3000 XP </p> | |||
</div> | |||
</section> | |||
@@ -139,7 +139,10 @@ | |||
<button class="logout-button"> Logout </button> | |||
<button class="logout-button teacher-mode"> Login as Teacher </button> | |||
<button class="logout-button teacher-mode" *ngIf="demoType === 'Student'" | |||
(click)="changeLogin('Teacher')"> Login as Teacher </button> | |||
<button class="logout-button teacher-mode" *ngIf="demoType === 'Teacher'" | |||
(click)="changeLogin('Student')"> Login as Student </button> | |||
</section> | |||
</div> |
@@ -1,4 +1,5 @@ | |||
import { Component, OnInit } from '@angular/core'; | |||
import { Router } from '@angular/router'; | |||
@Component({ | |||
selector: 'app-more', | |||
@@ -6,12 +7,25 @@ import { Component, OnInit } from '@angular/core'; | |||
styleUrls: ['./more.component.scss'] | |||
}) | |||
export class MoreComponent implements OnInit { | |||
selectedSegment: string = 'badges'; | |||
profileDetails: boolean = false; | |||
selectedSegment: string = 'badges'; | |||
profileDetails: boolean = false; | |||
demoType: string; | |||
constructor() { } | |||
constructor( | |||
private router: Router | |||
) { } | |||
ngOnInit(): void { | |||
ngOnInit(): void { | |||
this.demoType = localStorage.demoType; | |||
} | |||
ngOnDestroy() { | |||
} | |||
changeLogin(type: string) { | |||
localStorage.demoType = type; | |||
this.router.navigate(['welcome']); | |||
} | |||
} |
@@ -1,6 +1,5 @@ | |||
import { Component, OnInit } from '@angular/core'; | |||
import { DemoService } from '../services/demo.service'; | |||
import { Subscription } from 'rxjs'; | |||
@Component({ | |||
selector: 'app-welcome', | |||
@@ -8,30 +7,26 @@ import { Subscription } from 'rxjs'; | |||
styleUrls: ['./welcome.component.scss'] | |||
}) | |||
export class WelcomeComponent implements OnInit { | |||
demoTypeSubscriber: Subscription; | |||
demoType: string; | |||
classList = []; | |||
demoType: string; | |||
constructor( | |||
private demoService: DemoService | |||
) { } | |||
ngOnInit(): void { | |||
this.demoTypeSubscriber = this.demoService.demoType.subscribe((type) => { | |||
this.demoType = type; | |||
if (type === 'Student') { | |||
this.classList = this.demoService.studentClassList; | |||
} | |||
this.demoType = localStorage.demoType; | |||
if (this.demoType === 'Student') { | |||
this.classList = this.demoService.studentClassList; | |||
} | |||
if (type === 'Teacher') { | |||
this.classList = this.demoService.teacherClassList; | |||
} | |||
}); | |||
if (this.demoType === 'Teacher') { | |||
this.classList = this.demoService.teacherClassList; | |||
} | |||
} | |||
ngOnDestroy() { | |||
this.demoTypeSubscriber.unsubscribe(); | |||
} | |||
} |