Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

51 descricao #16

Merged
merged 25 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
937e78a
#51 - Service para descrição
castroricardo1 Nov 15, 2023
ad94aee
#51 - Componente viewer para descrição no video
castroricardo1 Nov 15, 2023
d7798c5
#51 - Adicionando mostrar para descrições longas
castroricardo1 Nov 15, 2023
5113417
#51 - Arrumando visualização da descrição
castroricardo1 Nov 15, 2023
6f1c7a7
Adiciona serviço para realizar requição de um vídeo pelo id
GabrielaTiago Nov 16, 2023
73544ed
Adiciona método para buscar informações do vídeo obtidas na requisição
GabrielaTiago Nov 16, 2023
a2cf905
Adiciona teste para método de buscar video pelo id
GabrielaTiago Nov 16, 2023
71cd86e
Adiciona teste para método de expandir descrição
DiegoCarlito Nov 16, 2023
76c0ef1
remoção do título pelo parâmetro
vicamatos Nov 17, 2023
c41dd5f
Merge branch 'develop' of https://github.com/fga-eps-mds/2023.2-UnB-T…
vicamatos Nov 17, 2023
d93af10
altera link de exibição do vídeo
vicamatos Nov 17, 2023
7bcc712
Remove métodos que não são mais utilizados
GabrielaTiago Nov 17, 2023
174318b
Merge branch 'develop' into 51-descricao
GabrielaTiago Nov 17, 2023
2921b85
Separa a url do vídeo proveniente da propriedade embed
GabrielaTiago Nov 18, 2023
e61413b
Alterações de responsividade
GabrielaTiago Nov 18, 2023
84f1efb
Adiciona teste para o método de extração de url
GabrielaTiago Nov 18, 2023
adc0a4a
corrige ativar conta tela de login
Marcosatc147 Nov 18, 2023
8868493
Merge 'fix-tests' into 51-descricao
GabrielaTiago Nov 18, 2023
be4be09
Merge branch 'develop' into 51-descricao
GabrielaTiago Nov 18, 2023
70e3c6c
Merge branch '51-descricao' of https://github.com/fga-eps-mds/2023.2-…
Marcosatc147 Nov 19, 2023
a55d352
padroniza variaveis e metodo
Marcosatc147 Nov 19, 2023
c5052dd
apaga safe pipe
Marcosatc147 Nov 19, 2023
959abaf
altera safehtml
Marcosatc147 Nov 19, 2023
8fd739e
Altera chamada da api para passar nos testes
joao15victor08 Nov 20, 2023
473f515
Remove import sem uso
joao15victor08 Nov 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { LoginComponent } from './pages/login/login.component';
import { RegisterComponent } from './pages/register/register.component';
import { VideoComponent } from './pages/video/video.component';
import { VideoViewerComponent } from './pages/video-viewer/video-viewer.component';
import { SafePipe } from './pipes/safe.pipe';
import { BackgroundComponent } from './components/background/background.component';
import { LoginSocialComponent } from './pages/login-social/login-social.component';
import { ActiveAccountComponent } from './pages/active-account/active-account.component';
Expand Down Expand Up @@ -58,7 +57,6 @@ import { MessageService } from 'primeng/api';
LoginSocialComponent,
VideoComponent,
VideoViewerComponent,
SafePipe,
BackgroundComponent,
ActiveAccountComponent,
ProfileComponent,
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/background/background.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</div>
</nav>
</div>
<div class="flex-grow m-3">
<div class="flex-grow">
<ng-content></ng-content>
</div>
<div class="flex flex-row items-center justify-center pb-10 mt-20">
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/profile/profile.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,4 @@ describe('ProfileComponent', () => {
});


});
});
7 changes: 7 additions & 0 deletions src/app/pages/video-viewer/video-viewer.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.clamped-description {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
overflow: hidden;
}

46 changes: 35 additions & 11 deletions src/app/pages/video-viewer/video-viewer.component.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,43 @@
<div class="max-w-full justify-center max-h-full flex">
<div class="max-w-full max-h-full flex justify-center flex-col gap-3">
<video
class="w-full h-2/3 max-w-6xl"
[src]="videoMP4.url | safe"
title="trusted video url"
<div class="justify-center flex flex-col">
<div class="relative w-full max-h-96 overflow-hidden aspect-video">
<iframe
id="embeddedVideo"
title="{{ video.title }}"
allowfullscreen
controls
></video>
class="top-0 left-0 bottom-0 right-0 w-full h-full absolute"
></iframe>
</div>
<div class="flex justify-center flex-col gap-6 p-3 m-3">
<div class="max-w-full justify-start max-h-full flex">
<h4 class="font-custom">
{{ videoTitle }}
<h4 class="font-custom font-bold">
{{ video.title }}
</h4>
</div>
<div class="max-w-full max-h-full flex text-[12px] font-custom">
<div>
<span
*ngIf="!showDescription && videoDescription.length > characterLimit"
class="clamped-description"
[innerHTML]="videoDescription"
></span>
<button
*ngIf="!showDescription && videoDescription.length > characterLimit"
class="font-bold"
(click)="expandDescription()"
>
Mostrar
</button>

<span *ngIf="showDescription" [innerHTML]="videoDescription"></span>
<div *ngIf="showDescription">
<button class="font-bold" (click)="expandDescription()">
Mostrar menos
</button>
</div>
</div>
</div>
<div>
<app-video-comment/>
<app-video-comment />
</div>
</div>
</div>
56 changes: 45 additions & 11 deletions src/app/pages/video-viewer/video-viewer.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,71 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { RouterTestingModule } from "@angular/router/testing";
import { RouterTestingModule } from '@angular/router/testing';
import { VideoViewerComponent } from './video-viewer.component';
import { SafePipe } from 'src/app/pipes/safe.pipe';
import { VideoCommentComponent } from 'src/app/components/video-comment/video-comment.component';
import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
import { VideoService } from 'src/app/services/video.service';
import { ActivatedRoute } from '@angular/router';
import { of } from 'rxjs';

class VideoServiceMock {
constructor() { }
findVideoById() {
return of({});
}
}

describe('VideoViewerComponent', () => {
let component: VideoViewerComponent;
let fixture: ComponentFixture<VideoViewerComponent>;
let videoService: VideoService;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [VideoViewerComponent, SafePipe, VideoCommentComponent],
imports: [HttpClientTestingModule, RouterTestingModule, ReactiveFormsModule],
declarations: [VideoViewerComponent, VideoCommentComponent],
imports: [
HttpClientTestingModule,
RouterTestingModule,
ReactiveFormsModule,
],
providers: [
{ provide: ActivatedRoute, useValue: { snapshot: { params: { 'id': 1 }, queryParams: { 'title': "titulo" } } } },
{ provide: VideoService },
{
provide: ActivatedRoute,
useValue: { snapshot: { params: { id: 190329 } } },
},
{ provide: VideoService, useValue: new VideoServiceMock() },
FormBuilder,
]

})
.compileComponents();
],
}).compileComponents();

fixture = TestBed.createComponent(VideoViewerComponent);
component = fixture.componentInstance;
localStorage.setItem('token', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZW1haWwiOiJqb2FvMTV2aWN0b3IwOEBnbWFpbC5jb20iLCJleHAiOjE2OTkzMTI5MzV9.1B9qBJt8rErwBKyD5JCdsPozsw86oQ38tdfDuMM2HFI');
fixture.detectChanges();
videoService = TestBed.inject(VideoService);
});

it('should create', () => {
expect(component).toBeTruthy();
});
});

it('should toggle showDescription when expandDescription is called', () => {

expect(component.showDescription).toBe(false);

component.expandDescription();

expect(component.showDescription).toBe(true);

component.expandDescription();

expect(component.showDescription).toBe(false);
});

it('should call findVideoById and return video', () => {
const mySpy = spyOn(videoService, 'findVideoById').and.callThrough();
component.findVideoById();
expect(mySpy).toHaveBeenCalled();
});

});
53 changes: 24 additions & 29 deletions src/app/pages/video-viewer/video-viewer.component.ts
Original file line number Diff line number Diff line change
@@ -1,51 +1,46 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, SecurityContext } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { HttpResponse } from '@angular/common/http';
import {
IVideoVersion,
} from 'src/shared/model/video-version.model';
import {
IVideoDetails,
VideoDetails,
} from 'src/shared/model/video-details.model';
import { VideoService } from '../../services/video.service';

import { IVideo, Video } from 'src/shared/model/video.model';

@Component({
selector: 'app-video-viewer',
templateUrl: './video-viewer.component.html',
styleUrls: ['./video-viewer.component.css'],
})

export class VideoViewerComponent implements OnInit {
videoVersion!: IVideoVersion;
videoMP4: IVideoDetails = new VideoDetails();
videoTitle: string = '';
videoDescription: string = '';
characterLimit = 100;
showDescription = false;
video: IVideo = new Video();
idVideo!: number;
eduplayVideoUrl = "https://eduplay.rnp.br/portal/video/embed/";

expandDescription() {
this.showDescription = !this.showDescription;
}

constructor(
private route: ActivatedRoute,
private videoService: VideoService,
) { }

ngOnInit(): void {
const iframe = document.getElementById('embeddedVideo') as HTMLIFrameElement;
this.idVideo = this.route.snapshot.params['idVideo'];
this.findVideo();
this.videoTitle = this.route.snapshot.queryParams['title'];

this.findVideoById();
iframe.src = this.eduplayVideoUrl + this.idVideo;
}

findVideo = () => {
this.videoService.findVideoVersionByVideoId(this.idVideo)
.subscribe({
next: (data: HttpResponse<IVideoVersion>) => {
this.videoVersion = data.body ? data.body : this.videoVersion;
const videoMP4Found = this.videoVersion.videoVersionList?.find(
(video) => video.fileFormat === 'MP4'
);

this.videoMP4 = !!videoMP4Found ? videoMP4Found : this.videoMP4;
}
});
}
findVideoById = () => {
this.videoService.findVideoById(this.idVideo).subscribe({
next: (data: HttpResponse<IVideo>) => {
this.video = data.body ? data.body : this.video;
this.videoDescription = this.video.description
? this.video.description
: '';
},
});
};
}
4 changes: 2 additions & 2 deletions src/app/pages/video/video.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<div
*ngFor="let image of video.images"
[routerLink]="['/video', video.id]"
[queryParams]="{ title: video.title }"
>
class="cursor-pointer"
>
<img
src="{{ image.href }}"
alt="{{ video.title }}"
Expand Down
8 changes: 0 additions & 8 deletions src/app/pipes/safe.pipe.spec.ts

This file was deleted.

14 changes: 0 additions & 14 deletions src/app/pipes/safe.pipe.ts

This file was deleted.

Loading
Loading