瀏覽代碼

Demo data service + observable for demo type and data init for class list of both teacher and student + data integration for welcome & home page

master
kj1352 5 年之前
父節點
當前提交
f070326a93
共有 11 個檔案被更改,包括 276 行新增199 行删除
  1. +2
    -1
      src/app/app.component.ts
  2. +6
    -1
      src/app/app.module.ts
  3. +4
    -1
      src/app/reusable-components/class-card-list/class-card-list.component.html
  4. +16
    -0
      src/app/services/demo.service.spec.ts
  5. +177
    -0
      src/app/services/demo.service.ts
  6. +8
    -7
      src/app/tabs/home/home.component.html
  7. +13
    -0
      src/app/tabs/home/home.component.scss
  8. +21
    -98
      src/app/tabs/home/home.component.ts
  9. +2
    -2
      src/app/welcome/welcome.component.html
  10. +4
    -0
      src/app/welcome/welcome.component.scss
  11. +23
    -89
      src/app/welcome/welcome.component.ts

+ 2
- 1
src/app/app.component.ts 查看文件

@@ -1,10 +1,11 @@
import { Component } from '@angular/core'; import { Component } from '@angular/core';



@Component({ @Component({
selector: 'app-root', selector: 'app-root',
templateUrl: './app.component.html', templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'] styleUrls: ['./app.component.scss']
}) })
export class AppComponent { export class AppComponent {
title = 'lms-app-new';
} }

+ 6
- 1
src/app/app.module.ts 查看文件

@@ -34,6 +34,9 @@ import { ChatWindowComponent } from './chat-page/chat-window/chat-window.compone
import { SettingsComponent } from './settings/settings.component'; import { SettingsComponent } from './settings/settings.component';
import { ClassCardListComponent } from './reusable-components/class-card-list/class-card-list.component'; import { ClassCardListComponent } from './reusable-components/class-card-list/class-card-list.component';


// Import services
import { DemoService } from './services/demo.service';

@NgModule({ @NgModule({
declarations: [ declarations: [
AppComponent, AppComponent,
@@ -69,7 +72,9 @@ import { ClassCardListComponent } from './reusable-components/class-card-list/cl
AngularSvgIconModule.forRoot(), AngularSvgIconModule.forRoot(),
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }) ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production })
], ],
providers: [],
providers: [
DemoService
],
bootstrap: [AppComponent] bootstrap: [AppComponent]
}) })
export class AppModule { } export class AppModule { }

+ 4
- 1
src/app/reusable-components/class-card-list/class-card-list.component.html 查看文件

@@ -8,10 +8,13 @@
</div> </div>
<div class="subject"> <div class="subject">
<label> {{ class.subject }} </label> <label> {{ class.subject }} </label>
<p>
<p *ngIf="class.teacher.name !== 'You'">
<img [src]="class.teacher.profile_image"> <img [src]="class.teacher.profile_image">
<span> {{ class.teacher.name }} </span> <span> {{ class.teacher.name }} </span>
</p> </p>
<p *ngIf="class.classLevel">
{{ class.classLevel }}
</p>
</div> </div>
<span *ngIf="class.classUrl"> <span *ngIf="class.classUrl">
<button class="view-button" <button class="view-button"


+ 16
- 0
src/app/services/demo.service.spec.ts 查看文件

@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';

import { DemoService } from './demo.service';

describe('DemoService', () => {
let service: DemoService;

beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(DemoService);
});

it('should be created', () => {
expect(service).toBeTruthy();
});
});

+ 177
- 0
src/app/services/demo.service.ts 查看文件

@@ -0,0 +1,177 @@
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>;

studentClassList = [{
date: moment(new Date()).format('MMM, DD 2020'),
classes: [{
time: '10:00 AM',
duration: '45 Mins',
subject: 'Mathematics',
teacher: {
name: 'Mr Kashinath Kashyap',
profile_image: 'https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg'
},
classUrl: '/video-chapter',
classId: 'topic1',
attendanceStatus: 'LATE'
}, {
time: '11:00 AM',
duration: '45 Mins',
subject: 'Physics',
teacher: {
name: 'Dr Meghana',
profile_image: 'https://pbs.twimg.com/profile_images/416884752377843712/MW2qg7-f.jpeg'
},
classUrl: '/chapter-notes',
classId: 'topic1',
attendanceStatus: 'ABSENT'
}, {
time: '12:00 PM',
duration: '45 Mins',
subject: 'Chemistry',
teacher: {
name: 'Mr Kashinath Kashyap',
profile_image: 'https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg'
},
classUrl: '/chapter-notes',
classId: 'topic1',
attendanceStatus: 'PRESENT'
}, {
time: '2:00 PM',
duration: '45 Mins',
subject: 'EVS',
teacher: {
name: 'Mr Kashinath Kashyap',
profile_image: 'https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg'
}
}, {
time: '3:00 PM',
duration: '45 Mins',
subject: 'Biology',
teacher: {
name: 'Dr Meghana',
profile_image: 'https://pbs.twimg.com/profile_images/416884752377843712/MW2qg7-f.jpeg'
}
}]
}, {
date: moment(new Date()).subtract(1, 'day').format('MMM, DD 2020'),
classes: [{
time: '10:00 AM',
duration: '45 Mins',
subject: 'Mathematics',
teacher: {
name: 'Mr Kashinath Kashyap',
profile_image: 'https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg'
}
}, {
time: '11:00 AM',
duration: '45 Mins',
subject: 'Physics',
teacher: {
name: 'Dr Meghana',
profile_image: 'https://pbs.twimg.com/profile_images/416884752377843712/MW2qg7-f.jpeg'
}
}, {
time: '12:00 PM',
duration: '45 Mins',
subject: 'Chemistry',
teacher: {
name: 'Mr Kashinath Kashyap',
profile_image: 'https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg'
}
}, {
time: '2:00 PM',
duration: '45 Mins',
subject: 'EVS',
teacher: {
name: 'Mr Kashinath Kashyap',
profile_image: 'https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg'
}
}, {
time: '3:00 PM',
duration: '45 Mins',
subject: 'Biology',
teacher: {
name: 'Dr Meghana',
profile_image: 'https://pbs.twimg.com/profile_images/416884752377843712/MW2qg7-f.jpeg'
}
}]
}];

teacherClassList = [{
date: moment(new Date()).format('MMM, DD 2020'),
classes: [{
time: '10:00 AM',
duration: '45 Mins',
subject: 'Mathematics',
classLevel: 'Class 10',
teacher: {
name: 'You',
profile_image: 'https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg'
}
}, {
time: '11:00 AM',
duration: '45 Mins',
subject: 'EVS',
classLevel: 'Class 3',
teacher: {
name: 'You',
profile_image: 'https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg'
}
}, {
time: '2:00 PM',
duration: '45 Mins',
subject: 'Mathematics',
classLevel: 'Class 7',
teacher: {
name: 'You',
profile_image: 'https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg'
}
}]
}, {
date: moment(new Date()).subtract(1, 'day').format('MMM, DD 2020'),
classes: [{
time: '10:00 AM',
duration: '45 Mins',
subject: 'EVS',
classLevel: 'Class 4',
teacher: {
name: 'You',
profile_image: 'https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg'
}
}, {
time: '11:00 AM',
duration: '45 Mins',
subject: 'Mathematics',
classLevel: 'Class 10',
teacher: {
name: 'You',
profile_image: 'https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg'
}
}, {
time: '12:00 PM',
duration: '45 Mins',
subject: 'Mathematics',
classLevel: 'Class 6',
teacher: {
name: 'You',
profile_image: 'https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg'
}
}]
}];

constructor() {
this.demoType = Observable.create((observer: Observer<string>) => {
this.demoTypeObserver = observer;
this.demoTypeObserver.next('Teacher');
});
}
}

+ 8
- 7
src/app/tabs/home/home.component.html 查看文件

@@ -5,12 +5,12 @@
</header> </header>


<section class="video-section" [ngClass]="{'expand' : expandVideo }"> <section class="video-section" [ngClass]="{'expand' : expandVideo }">
<!-- <iframe src="https://player.vimeo.com/video/393975453?title=0&portrait=0&byline=0&autoplay=1" frameborder="0"></iframe> -->
<iframe *ngIf="showVideo" src="https://player.vimeo.com/video/393975453?title=0&portrait=0&byline=0&autoplay=1" frameborder="0"></iframe>


<div class="topic-name">
<h2> English Class </h2>
<p> Starts in </p>
<div class="counter"> 00:00:59 </div>
<div class="topic-name" *ngIf="classList.length > 0">
<h2> {{ classList[0].classes[0].subject }} </h2>
<p> Starts at </p>
<div class="counter"> {{ classList[0].classes[0].time }} </div>
</div> </div>


<span class="tutor"> <span class="tutor">
@@ -20,8 +20,9 @@
</p> </p>
<div class="profile-holder"> <div class="profile-holder">
<img src="https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg"> <img src="https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg">
<span> Dwayne the Rock </span>
<span> {{ classList[0].classes[0].teacher.name }} </span>
</div> </div>
<button (click)="showVideo = true" *ngIf="demoType === 'Teacher'" class="go-live-button"> Go Live </button>
</span> </span>
</section> </section>


@@ -100,7 +101,7 @@
</section> </section>


<div class="card-list-holder"> <div class="card-list-holder">
<div class="card-list" *ngFor="let class of studentClassList">
<div class="card-list" *ngFor="let class of classList">
<header> <header>
<h5> {{ class.date }} </h5> <h5> {{ class.date }} </h5>
</header> </header>


+ 13
- 0
src/app/tabs/home/home.component.scss 查看文件

@@ -102,6 +102,19 @@


.tutor { .tutor {
color: white; color: white;
width: 100%;

.go-live-button {
width: 100px;
display: block;
margin: 15px auto 0px;
background-color: var(--teal-green);
border-radius: 5px;
border: 0px;
color: white;
font-size: 14px;
height: 35px;
}


@media screen and (min-width: 1023px) { @media screen and (min-width: 1023px) {
position: relative; position: relative;


+ 21
- 98
src/app/tabs/home/home.component.ts 查看文件

@@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { ScrollEvent } from 'ngx-scroll-event'; import { ScrollEvent } from 'ngx-scroll-event';
import * as moment from 'moment';
import { DemoService } from '../../services/demo.service';
import { Subscription } from 'rxjs';


@Component({ @Component({
selector: 'app-home', selector: 'app-home',
@@ -11,105 +12,15 @@ export class HomeComponent implements OnInit {
expandVideo: boolean = false; expandVideo: boolean = false;
showClassDetails: boolean; showClassDetails: boolean;
selectedSegment: string = 'transcript'; selectedSegment: string = 'transcript';
showVideo: boolean = false;
demoTypeSubscriber: Subscription;
demoType: string;


studentClassList = [{
date: moment(new Date()).format('MMM, DD 2020'),
classes: [{
time: '10:00 AM',
duration: '45 Mins',
subject: 'Mathematics',
teacher: {
name: 'Mr Kashinath Kashyap',
profile_image: 'https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg'
},
classUrl: '/video-chapter',
classId: 'topic1',
attendanceStatus: 'LATE'
}, {
time: '11:00 AM',
duration: '45 Mins',
subject: 'Physics',
teacher: {
name: 'Dr Meghana',
profile_image: 'https://pbs.twimg.com/profile_images/416884752377843712/MW2qg7-f.jpeg'
},
classUrl: '/chapter-notes',
classId: 'topic1',
attendanceStatus: 'ABSENT'
}, {
time: '12:00 PM',
duration: '45 Mins',
subject: 'Chemistry',
teacher: {
name: 'Mr Kashinath Kashyap',
profile_image: 'https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg'
},
classUrl: '/chapter-notes',
classId: 'topic1',
attendanceStatus: 'PRESENT'
}, {
time: '2:00 PM',
duration: '45 Mins',
subject: 'EVS',
teacher: {
name: 'Mr Kashinath Kashyap',
profile_image: 'https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg'
}
}, {
time: '3:00 PM',
duration: '45 Mins',
subject: 'Biology',
teacher: {
name: 'Dr Meghana',
profile_image: 'https://pbs.twimg.com/profile_images/416884752377843712/MW2qg7-f.jpeg'
}
}]
}, {
date: moment(new Date()).subtract(1, 'day').format('MMM, DD 2020'),
classes: [{
time: '10:00 AM',
duration: '45 Mins',
subject: 'Mathematics',
teacher: {
name: 'Mr Kashinath Kashyap',
profile_image: 'https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg'
}
}, {
time: '11:00 AM',
duration: '45 Mins',
subject: 'Physics',
teacher: {
name: 'Dr Meghana',
profile_image: 'https://pbs.twimg.com/profile_images/416884752377843712/MW2qg7-f.jpeg'
}
}, {
time: '12:00 PM',
duration: '45 Mins',
subject: 'Chemistry',
teacher: {
name: 'Mr Kashinath Kashyap',
profile_image: 'https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg'
}
}, {
time: '2:00 PM',
duration: '45 Mins',
subject: 'EVS',
teacher: {
name: 'Mr Kashinath Kashyap',
profile_image: 'https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg'
}
}, {
time: '3:00 PM',
duration: '45 Mins',
subject: 'Biology',
teacher: {
name: 'Dr Meghana',
profile_image: 'https://pbs.twimg.com/profile_images/416884752377843712/MW2qg7-f.jpeg'
}
}]
}];
classList = [];


constructor() { }
constructor(
private demoService: DemoService
) { }


ngOnInit(): void { ngOnInit(): void {
if (window.innerWidth > 1023) { if (window.innerWidth > 1023) {
@@ -117,6 +28,18 @@ export class HomeComponent implements OnInit {
} else { } else {
this.showClassDetails = false; this.showClassDetails = false;
} }

this.demoTypeSubscriber = this.demoService.demoType.subscribe((type) => {
this.demoType = type;
if (type === 'Student') {
this.classList = this.demoService.studentClassList;
this.showVideo = true;
}

if (type === 'Teacher') {
this.classList = this.demoService.teacherClassList;
}
});
} }


public handleScroll(event: ScrollEvent) { public handleScroll(event: ScrollEvent) {


+ 2
- 2
src/app/welcome/welcome.component.html 查看文件

@@ -2,7 +2,7 @@
<section class="upfold"> <section class="upfold">
<h1> <h1>
Good Morning, <br> Good Morning, <br>
Shashank
{{ demoType }}
</h1> </h1>
<p> <p>
Your schedule for the day! Your schedule for the day!
@@ -10,7 +10,7 @@
</section> </section>


<div class="card-list-holder"> <div class="card-list-holder">
<div class="card-list" *ngFor="let class of studentClassList">
<div class="card-list" *ngFor="let class of classList">
<header> <header>
<h5> {{ class.date }} </h5> <h5> {{ class.date }} </h5>
</header> </header>


+ 4
- 0
src/app/welcome/welcome.component.scss 查看文件

@@ -1,3 +1,7 @@
.page-container {
padding-bottom: 100px;
}

.upfold { .upfold {
width: 100%; width: 100%;
color: white; color: white;


+ 23
- 89
src/app/welcome/welcome.component.ts 查看文件

@@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import * as moment from 'moment';
import { DemoService } from '../services/demo.service';
import { Subscription } from 'rxjs';


@Component({ @Component({
selector: 'app-welcome', selector: 'app-welcome',
@@ -7,97 +8,30 @@ import * as moment from 'moment';
styleUrls: ['./welcome.component.scss'] styleUrls: ['./welcome.component.scss']
}) })
export class WelcomeComponent implements OnInit { export class WelcomeComponent implements OnInit {
studentClassList = [{
date: moment(new Date()).format('MMM, DD 2020'),
classes: [{
time: '10:00 AM',
duration: '45 Mins',
subject: 'Mathematics',
teacher: {
name: 'Mr Kashinath Kashyap',
profile_image: 'https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg'
}
}, {
time: '11:00 AM',
duration: '45 Mins',
subject: 'Physics',
teacher: {
name: 'Dr Meghana',
profile_image: 'https://pbs.twimg.com/profile_images/416884752377843712/MW2qg7-f.jpeg'
}
}, {
time: '12:00 PM',
duration: '45 Mins',
subject: 'Chemistry',
teacher: {
name: 'Mr Kashinath Kashyap',
profile_image: 'https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg'
}
}, {
time: '2:00 PM',
duration: '45 Mins',
subject: 'EVS',
teacher: {
name: 'Mr Kashinath Kashyap',
profile_image: 'https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg'
}
}, {
time: '3:00 PM',
duration: '45 Mins',
subject: 'Biology',
teacher: {
name: 'Dr Meghana',
profile_image: 'https://pbs.twimg.com/profile_images/416884752377843712/MW2qg7-f.jpeg'
}
}]
}, {
date: moment(new Date()).subtract(1, 'day').format('MMM, DD 2020'),
classes: [{
time: '10:00 AM',
duration: '45 Mins',
subject: 'Mathematics',
teacher: {
name: 'Mr Kashinath Kashyap',
profile_image: 'https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg'
}
}, {
time: '11:00 AM',
duration: '45 Mins',
subject: 'Physics',
teacher: {
name: 'Dr Meghana',
profile_image: 'https://pbs.twimg.com/profile_images/416884752377843712/MW2qg7-f.jpeg'
}
}, {
time: '12:00 PM',
duration: '45 Mins',
subject: 'Chemistry',
teacher: {
name: 'Mr Kashinath Kashyap',
profile_image: 'https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg'
}
}, {
time: '2:00 PM',
duration: '45 Mins',
subject: 'EVS',
teacher: {
name: 'Mr Kashinath Kashyap',
profile_image: 'https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg'
}
}, {
time: '3:00 PM',
duration: '45 Mins',
subject: 'Biology',
teacher: {
name: 'Dr Meghana',
profile_image: 'https://pbs.twimg.com/profile_images/416884752377843712/MW2qg7-f.jpeg'
}
}]
}];
demoTypeSubscriber: Subscription;
demoType: string;


constructor() { }
classList = [];

constructor(
private demoService: DemoService
) { }


ngOnInit(): void { ngOnInit(): void {
this.demoTypeSubscriber = this.demoService.demoType.subscribe((type) => {
this.demoType = type;
if (type === 'Student') {
this.classList = this.demoService.studentClassList;
}

if (type === 'Teacher') {
this.classList = this.demoService.teacherClassList;
}
});
} }


ngOnDestroy() {
this.demoTypeSubscriber.unsubscribe();
}

} }