From ab98f80740883a0cfbc12616c407f70aa1dbde91 Mon Sep 17 00:00:00 2001 From: maxime Date: Thu, 9 Apr 2026 18:35:30 +0200 Subject: [PATCH] prise en compte des video dans potd --- src/app/pages/potd/potd.html | 45 +++++++++++++------ src/app/pages/potd/potd.ts | 11 +++-- .../search/searchresults/searchresults.html | 4 +- 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/src/app/pages/potd/potd.html b/src/app/pages/potd/potd.html index c349967..05c7077 100644 --- a/src/app/pages/potd/potd.html +++ b/src/app/pages/potd/potd.html @@ -1,16 +1,33 @@ -
-
- {{nasaPOTD()?.explanation}} -
-

{{nasaPOTD()?.title}}

-

{{nasaPOTD()?.copyright}}

-

- {{nasaPOTD()?.explanation}} -

+@if(isLoading()){ +
+ +

Chargement ...

+
+} +@if(!isLoading() && nasaPOTD()){ + @if(nasaPOTD()?.media_type=="image"){ +
+
+ {{nasaPOTD()?.explanation}} +
+

{{nasaPOTD()?.title}}

+

{{nasaPOTD()?.copyright}}

+

+ {{nasaPOTD()?.explanation}} +

+
-
+ } + @if(nasaPOTD()?.media_type==="video"){ +
+ +
+ } + +} +@if(!isLoading() && !nasaPOTD()){ +

Impossible de charger la vidéo.

+} \ No newline at end of file diff --git a/src/app/pages/potd/potd.ts b/src/app/pages/potd/potd.ts index 9b79ba1..6b95aa3 100644 --- a/src/app/pages/potd/potd.ts +++ b/src/app/pages/potd/potd.ts @@ -1,4 +1,4 @@ -import { Component, inject, signal } from '@angular/core'; +import { Component, OnInit, inject, signal } from '@angular/core'; import { NAPOD } from '../../services/napod'; import { Picture } from '../../interfaces/picture'; @@ -8,19 +8,22 @@ import { Picture } from '../../interfaces/picture'; templateUrl: './potd.html', styleUrl: './potd.css' }) -export class POTD { +export class POTD implements OnInit{ private readonly nasaApi = inject(NAPOD) nasaPOTD = signal< Picture | null >(null) + isLoading = signal(true); - constructor(){ + ngOnInit(){ this.nasaApi.getPicOfToday().subscribe({ next: (data)=>{ console.log(data) this.nasaPOTD.set(data) + this.isLoading.set(false); }, error: error =>{ - console.log(error); + console.log(error); + this.isLoading.set(false); } } ) diff --git a/src/app/pages/search/searchresults/searchresults.html b/src/app/pages/search/searchresults/searchresults.html index 1aa81cb..88e2dfa 100644 --- a/src/app/pages/search/searchresults/searchresults.html +++ b/src/app/pages/search/searchresults/searchresults.html @@ -5,8 +5,8 @@ } @if(searchResults()!==null && searchResults()!.collection.items.length!==0){ -
-
    +
    +
    • Results
    • @for(el of searchResults()!.collection.items; track el.data[0].nasa_id){