From b574621cafdd3f2d240755e8f421e74aac52455c Mon Sep 17 00:00:00 2001 From: mjeannin2025 Date: Fri, 26 Sep 2025 16:28:24 +0200 Subject: [PATCH] =?UTF-8?q?Affichage=20des=20vid=C3=A9os=20fonctionnel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/app.routes.ts | 1 + src/app/pages/search/search.css | 7 +++- src/app/pages/search/search.html | 53 +++++++++++++++++++------------ src/app/pages/search/search.ts | 30 +++++++++++++++-- src/app/pages/video/video.css | 0 src/app/pages/video/video.html | 4 +++ src/app/pages/video/video.spec.ts | 23 ++++++++++++++ src/app/pages/video/video.ts | 31 ++++++++++++++++++ src/app/services/napod.ts | 6 ++-- 9 files changed, 128 insertions(+), 27 deletions(-) create mode 100644 src/app/pages/video/video.css create mode 100644 src/app/pages/video/video.html create mode 100644 src/app/pages/video/video.spec.ts create mode 100644 src/app/pages/video/video.ts diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index b0cf5c2..2304f83 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -9,6 +9,7 @@ export const routes: Routes = [ {path: 'login', loadComponent: ()=> import("./pages/login/login").then(m =>m.Login)}, {path: 'potd', loadComponent: ()=> import("./pages/potd/potd").then(m =>m.POTD)}, {path: 'search', loadComponent: ()=> import("./pages/search/search").then(m =>m.Search)}, + {path: 'video/:id', loadComponent: ()=> import("./pages/video/video").then(m =>m.Video)}, {path: 'admin',canActivate: [adminGuard], loadChildren: () => import('./pages/admin/admin').then(m => m.Admin), data: { role: 'ADMIN' } }, //version si besoin de multiplier les routes admin // {path: 'admin',canActivate: [adminGuard], loadChildren: () => import('./pages/admin/admin.routes').then(m => m.ADMIN_ROUTES), data: { role: 'ADMIN' } }, diff --git a/src/app/pages/search/search.css b/src/app/pages/search/search.css index 7682f99..416f8a7 100644 --- a/src/app/pages/search/search.css +++ b/src/app/pages/search/search.css @@ -3,5 +3,10 @@ display: flex; flex-direction: column; align-items: center; - justify-content: center; + justify-content: center; + +} + +.inputSearch { + margin-bottom: 1rem; } \ No newline at end of file diff --git a/src/app/pages/search/search.html b/src/app/pages/search/search.html index 8f1ce90..0e37296 100644 --- a/src/app/pages/search/search.html +++ b/src/app/pages/search/search.html @@ -1,5 +1,5 @@
-
+
-
+ + + + + +
  • Results
  • - -
  • -
    -
    -
    Dio Lupa
    -
    Remaining Reason
    -
    -

    - "Remaining Reason" became an instant hit, praised for its haunting sound and emotional depth. A viral performance brought it widespread recognition, making it one of Dio Lupa’s most iconic tracks. -

    - - -
  • + + @if(searchResults()!==null){ + @for(el of searchResults()!.collection.items; track el.data[0].nasa_id){ +
  • + +
    +
    +
    {{el.data[0].title}}
    +
    Photographer: {{el.data[0].photographer}}
    +
    +

    + {{el.data[0].description}} +

    + + +
  • + } + } +
diff --git a/src/app/pages/search/search.ts b/src/app/pages/search/search.ts index 8b2d329..0caf67f 100644 --- a/src/app/pages/search/search.ts +++ b/src/app/pages/search/search.ts @@ -1,14 +1,40 @@ import { Component, inject, signal } from '@angular/core'; import { NAPOD } from '../../services/napod'; import { NasaApi } from '../../interfaces/nasa-api'; +import { FormsModule, NgModel } from '@angular/forms'; +import { Router } from '@angular/router'; @Component({ selector: 'app-search', - imports: [], + imports: [FormsModule], templateUrl: './search.html', styleUrl: './search.css' }) export class Search { - private nasaApi = inject(NAPOD) + private nasaApi = inject(NAPOD); + private router = inject(Router) searchResults = signal(null) + searchString=signal(''); + + onSubmit() { + this.nasaApi.searchForVideos(this.searchString()).subscribe({ + next: (data)=>{this.searchResults.set(data); + console.log(data.collection); + }, + error: error =>{console.log(error); + } + }) + } + + onClick(nasaId: string){ + this.router.navigate(['/video/'+nasaId]) + } + + updateSearch(event: Event){ + console.log(this.searchString()); + const target = event.target as HTMLInputElement; + this.searchString.set(target.value) + } + + } diff --git a/src/app/pages/video/video.css b/src/app/pages/video/video.css new file mode 100644 index 0000000..e69de29 diff --git a/src/app/pages/video/video.html b/src/app/pages/video/video.html new file mode 100644 index 0000000..57304ff --- /dev/null +++ b/src/app/pages/video/video.html @@ -0,0 +1,4 @@ +

+ \ No newline at end of file diff --git a/src/app/pages/video/video.spec.ts b/src/app/pages/video/video.spec.ts new file mode 100644 index 0000000..a67a7dc --- /dev/null +++ b/src/app/pages/video/video.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { Video } from './video'; + +describe('Video', () => { + let component: Video; + let fixture: ComponentFixture