Commit ac484c0f by Natalia

Video details updates

parent 96f463fa
...@@ -10,7 +10,9 @@ const routes: Routes = [ ...@@ -10,7 +10,9 @@ const routes: Routes = [
]; ];
@NgModule({ @NgModule({
imports: [RouterModule.forRoot(routes)], imports: [
RouterModule.forRoot(routes, { onSameUrlNavigation: 'reload'})
],
exports: [RouterModule] exports: [RouterModule]
}) })
export class AppRoutingModule {} export class AppRoutingModule {}
...@@ -26,9 +26,7 @@ export class FindVideoIdComponent implements OnInit { ...@@ -26,9 +26,7 @@ export class FindVideoIdComponent implements OnInit {
onSubmitId() { onSubmitId() {
if (this.videoIdForm.valid) { if (this.videoIdForm.valid) {
this.store.dispatch(new FindTranscriptById(this.videoIdForm.value.videoid));
this.router.navigateByUrl('/?id=' + this.videoIdForm.value.videoid); this.router.navigateByUrl('/?id=' + this.videoIdForm.value.videoid);
// this.router.navigateByUrl(['/'], { queryParams: { id: this.videoIdForm.value.videoid } });
} }
} }
......
...@@ -41,7 +41,6 @@ export function videoReducer(state: IVideoState = initialState, action: any): IV ...@@ -41,7 +41,6 @@ export function videoReducer(state: IVideoState = initialState, action: any): IV
case VideoActionsTypes.LOAD_TRANSCRIPT_BY_ID_ERROR: { case VideoActionsTypes.LOAD_TRANSCRIPT_BY_ID_ERROR: {
return { return {
...state, ...state,
videoId: initialState.videoId,
transcript: initialState.transcript, transcript: initialState.transcript,
loading: false, loading: false,
error: true error: true
......
<div class="video-details-container" *ngIf="!errorLoading; else errorLoadingContainer"> <div class="video-details-container" *ngIf="!(error$ | async) || !errorLoading; else errorLoadingContainer">
<div class="video-details" *ngIf="(videoId$ | async) as videoId; else noIdContainer"> <div class="video-details" *ngIf="(videoId$ | async) as videoId; else noIdContainer">
<h1>Test title</h1> <h1 [class.display-none]="!videoLoaded">Moment from meeting with Two Pillars</h1>
<div class="video-container" #player> <div class="video-container" #player [class.display-none]="!videoLoaded">
<video #video class="video" [attr.src]="'https://static.chorus.ai/api/' + videoId + '.mp4'" preload="auto"> <video #video class="video" [attr.src]="'https://static.chorus.ai/api/' + videoId + '.mp4'" preload="auto">
This browser does not support HTML5 video. This browser does not support HTML5 video.
</video> </video>
...@@ -15,8 +15,14 @@ ...@@ -15,8 +15,14 @@
</div> </div>
</div> </div>
<div class="transcript-container" *ngIf="(transcript$ | async) as transcript"> <div *ngIf="(loading$ | async)">
<div class="speaker-container" *ngFor="let item of transcript | orderBy: 'time'; let i = index; trackBy: trackByFn" [ngClass]="item.speaker?.toLowerCase()"> <mat-progress-spinner></mat-progress-spinner>
</div>
<div class="transcript-container" *ngIf="!(loading$ | async) && (transcript$ | async) as transcript">
<div class="speaker-container"
*ngFor="let item of transcript | orderBy: 'time'; let i = index; trackBy: trackByFn"
[ngClass]="item.speaker?.toLowerCase()">
<div class="speaker-status" [class.hidden]="item.speaker === transcript[i+1]?.speaker"></div> <div class="speaker-status" [class.hidden]="item.speaker === transcript[i+1]?.speaker"></div>
<div> <div>
<div class="speaker-name" *ngIf="item.speaker !== transcript[i-1]?.speaker">{{ item.speaker }}</div> <div class="speaker-name" *ngIf="item.speaker !== transcript[i-1]?.speaker">{{ item.speaker }}</div>
......
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
@media screen and (min-width: 768px) { @media screen and (min-width: 768px) {
max-width: 60%; max-width: 60%;
} }
.display-none {
display: none;
}
.video-container { .video-container {
width: 300px; width: 300px;
margin: 0 auto 15px; margin: 0 auto 15px;
...@@ -39,7 +42,8 @@ ...@@ -39,7 +42,8 @@
border: none; border: none;
color: $color-white; color: $color-white;
border-radius: 3px; border-radius: 3px;
padding: 11px 11px 9px; width: 47px;
height: 47px;
cursor: pointer; cursor: pointer;
} }
&.visible { &.visible {
......
import { Component, OnInit, AfterViewInit, OnDestroy, ElementRef, ViewChild, Renderer2 } from '@angular/core'; import { Component, OnInit, OnDestroy, ElementRef, ViewChild, Renderer2 } from '@angular/core';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { EventService } from '../store/services/event.service'; import { EventService } from '../store/services/event.service';
import { Store, select } from '@ngrx/store'; import { Store, select } from '@ngrx/store';
import { IAppState } from '../store/reducers/video.reducer'; import { IAppState } from '../store/reducers/video.reducer';
import { FindTranscriptById } from '../store/actions/video.actions'; import { FindTranscriptById } from '../store/actions/video.actions';
import { Observable } from 'rxjs'; import { Observable, Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
@Component({ @Component({
selector: 'app-video-details', selector: 'app-video-details',
templateUrl: './video-details.component.html', templateUrl: './video-details.component.html',
styleUrls: ['./video-details.component.scss'] styleUrls: ['./video-details.component.scss']
}) })
export class VideoDetailsComponent implements OnInit, AfterViewInit, OnDestroy { export class VideoDetailsComponent implements OnInit, OnDestroy {
@ViewChild('player') private player: ElementRef; @ViewChild('player') private player: ElementRef;
@ViewChild('video') private video: ElementRef; @ViewChild('video') private video: ElementRef;
isDestroyed$ = new Subject<boolean>();
videoIdParam: string; videoIdParam: string;
playing = false; playing = false;
videoLoaded = false; videoLoaded = false;
...@@ -32,7 +34,6 @@ export class VideoDetailsComponent implements OnInit, AfterViewInit, OnDestroy { ...@@ -32,7 +34,6 @@ export class VideoDetailsComponent implements OnInit, AfterViewInit, OnDestroy {
private evt: EventService, private evt: EventService,
private store: Store<IAppState> private store: Store<IAppState>
) { ) {
// this.videoIdParam = this.route.snapshot.queryParams['id'];
this.transcript$ = store.pipe(select(state => state.videoState.transcript)); this.transcript$ = store.pipe(select(state => state.videoState.transcript));
this.videoId$ = store.pipe(select(state => state.videoState.videoId)); this.videoId$ = store.pipe(select(state => state.videoState.videoId));
...@@ -41,42 +42,25 @@ export class VideoDetailsComponent implements OnInit, AfterViewInit, OnDestroy { ...@@ -41,42 +42,25 @@ export class VideoDetailsComponent implements OnInit, AfterViewInit, OnDestroy {
} }
ngOnInit() { ngOnInit() {
this.route.queryParams.subscribe(queryParams => { this.route.queryParams.pipe(takeUntil(this.isDestroyed$))
if (queryParams.id) { .subscribe(queryParams => {
this.store.dispatch(new FindTranscriptById(queryParams.id)); if (queryParams.id) {
this.store.dispatch(new FindTranscriptById(queryParams.id));
if (this.video) {
this.events = [
{ element: this.video.nativeElement, name: 'loadstart', callback: event => this.videoLoaded = false, dispose: null },
{ element: this.video.nativeElement, name: 'loadedmetadata', callback: event => this.onLoadedMetadata(event), dispose: null },
{ element: this.video.nativeElement, name: 'error', callback: event => this.onLoadingError(event), dispose: null },
{ element: this.player.nativeElement, name: 'mouseenter', callback: event => this.onMouseEnter(event), dispose: null },
{ element: this.player.nativeElement, name: 'mouseleave', callback: event => this.onMouseLeave(event), dispose: null }
];
this.evt.addEvents(this.renderer, this.events);
} }
} });
this.loading$.pipe(takeUntil(this.isDestroyed$))
}); .subscribe(loading => {
} if (this.events) {
this.evt.removeEvents(this.events);
ngAfterViewInit() { }
// if (this.video) { this.load();
// this.events = [ })
// { element: this.video.nativeElement, name: 'loadstart', callback: event => this.videoLoaded = false, dispose: null },
// { element: this.video.nativeElement, name: 'loadedmetadata', callback: event => this.onLoadedMetadata(event), dispose: null },
// { element: this.video.nativeElement, name: 'error', callback: event => this.onLoadingError(event), dispose: null },
// { element: this.player.nativeElement, name: 'mouseenter', callback: event => this.onMouseEnter(event), dispose: null },
// { element: this.player.nativeElement, name: 'mouseleave', callback: event => this.onMouseLeave(event), dispose: null }
// ];
// // this.evt.addEvents(this.renderer, this.events);
// }
} }
ngOnDestroy() { ngOnDestroy() {
this.evt.removeEvents(this.events); this.evt.removeEvents(this.events);
this.isDestroyed$.next(true);
this.isDestroyed$.complete();
} }
trackByFn(index, item) { trackByFn(index, item) {
...@@ -86,6 +70,16 @@ export class VideoDetailsComponent implements OnInit, AfterViewInit, OnDestroy { ...@@ -86,6 +70,16 @@ export class VideoDetailsComponent implements OnInit, AfterViewInit, OnDestroy {
load() { load() {
if (this.video && this.video.nativeElement) { if (this.video && this.video.nativeElement) {
this.video.nativeElement.load(); this.video.nativeElement.load();
this.events = [
{ element: this.video.nativeElement, name: 'loadstart', callback: event => this.videoLoaded = false, dispose: null },
{ element: this.video.nativeElement, name: 'loadedmetadata', callback: event => this.onLoadedMetadata(event), dispose: null },
{ element: this.video.nativeElement, name: 'error', callback: event => this.onLoadingError(event), dispose: null },
{ element: this.player.nativeElement, name: 'mouseenter', callback: event => this.onMouseEnter(event), dispose: null },
{ element: this.player.nativeElement, name: 'mouseleave', callback: event => this.onMouseLeave(event), dispose: null }
];
this.evt.addEvents(this.renderer, this.events);
} }
} }
......
// Colors // Colors
$color-white: #FFFFFF; $color-white: #FFFFFF;
$color-black: #000000;
$color-light-grey: #F7F7F7; $color-light-grey: #F7F7F7;
$color-grey: #D7DADE; $color-grey: #D7DADE;
$color-grey-dark: #333333; $color-grey-dark: #333333;
$color-blue: #00A7D1; $color-blue: #00A7D1;
\ No newline at end of file $color-purple: #646791;
$color-pink: #EE6EFF;
\ No newline at end of file
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico"> <link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head> </head>
<body> <body>
<app-root></app-root> <app-root></app-root>
......
...@@ -35,4 +35,4 @@ h1 { ...@@ -35,4 +35,4 @@ h1 {
p { p {
font-size: 1rem; font-size: 1rem;
line-height: 1.34rem; line-height: 1.34rem;
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment