Skip to content

Commit 1ea4947

Browse files
author
JLRR2019
committed
Subidas todas las fotos. Corregidos los bucles if y for, aun así no he conseguido que se vean las imagenes. Corregido el constructor en newsTemplate para coger una new por id y corregido news para coger todas por array.
1 parent e350030 commit 1ea4947

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+107
-94
lines changed

frontend/src/app/components/home/home.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ <h3>Leyendas Pokemon Arceus</h3>
5050
</div>
5151
</ng-template>
5252
</a>
53-
53+
5454
</div>
5555
</div>
5656
</div>
@@ -80,6 +80,6 @@ <h3>Leyendas Pokemon Arceus</h3>
8080
<div id="moreImages" class="row gx-5 justify-content-center">
8181
<newsTemplate></newsTemplate>
8282
</div>
83-
83+
8484
</div>
8585
</section>

frontend/src/app/components/home/home.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ import { Component } from '@angular/core';
77

88

99
export class HomeComponent{
10-
images = ["assets/images/ lostark.jpg", "assets/images/archeAge.jpg", "assets/images/pokemonArceus.jpg"]
11-
}
10+
images = ["assets/images/ lostark.jpg", "assets/images/ archeAge.jpg", "assets/images/ pokemonArceus.jpg"]
11+
}

frontend/src/app/components/navBar/navBar.component.html

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,24 @@
88
<li class="nav-item dropdown">
99
<a class="nav-link dropdown-toggle" id="navbarDropdownBlog" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">Videojuegos</a>
1010
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdownBlog">
11-
<li><a class="dropdown-item" href="/videogame">Descubrir</a></li>
12-
<li><a class="dropdown-item" href="/videogameStatistics/0">Top Juegos</a></li>
11+
<li><a class="dropdown-item" [routerLink]="['/videogame']">Descubrir</a></li>
12+
<li><a class="dropdown-item" [routerLink]="['/videogameStatistics/0']">Top Juegos</a></li>
1313
</ul>
1414
</li>
15-
<li class="nav-item"><a class="nav-link" href="/news">Noticias</a></li>
16-
<li class="nav-item"><a class="nav-link" href="/about">About</a></li>
15+
<li class="nav-item"><a class="nav-link" [routerLink]="['/news']">Noticias</a></li>
16+
<li class="nav-item"><a class="nav-link" [routerLink]="['/about']">About</a></li>
17+
1718

1819
<p *ngIf="!loginService.isLogged()"><!--/p-->
1920
<li class="nav-item dropdown">
2021
<a class="nav-link dropdown-toggle" id="navbarDropdownBlog" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">Sesión</a>
2122
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdownBlog">
22-
<li><a class="dropdown-item" href="/login">Iniciar sesión</a></li>
23-
<li><a class="dropdown-item" href="/signin">Registrarse</a></li>
23+
<li><a class="dropdown-item" [routerLink]="['/login']">Iniciar sesión</a></li>
24+
<li><a class="dropdown-item" [routerLink]="['/signin']">Registrarse</a></li>
2425
</ul>
2526
</li>
2627

28+
2729
<a ngIf="loginService.isLogged()">
2830
<p ngIf="loginService.isAdmin()"><!--/p-->
2931
<li class="nav-item"><a class="nav-link" [routerLink]="['/admin']">Administrador</a></li>

frontend/src/app/components/news/news.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ <h1 class="fw-bolder fs-5 mb-4">Noticias destacadas</h1>
2626
<section class="py-5">
2727
<div class="container px-5">
2828
<h2 class="fw-bolder fs-5 mb-4">Noticias que te pueden interesar.</h2>
29-
<div id="moreImages" class="row gx-5">
29+
<div id="moreImages" class="row gx-5" *ngFor="let ns of news">
3030
<newsTemplate></newsTemplate>
3131
</div>
3232
<div class="text-end mb-5 mb-xl-0">

frontend/src/app/components/news/news.component.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@ export class NewsComponent{
1414

1515
//25: int;
1616
//25: int;
17-
news!: News;
18-
imagesCarousel = ['diabloIV.jgp', 'overwatch2.jpg', 'marioKart9.jgp'].map((n) => `./backend/src/main/resources/static/Photos/${n}`); //esto no se si está bien
17+
news!: News[];
18+
imagesCarousel = ['assets/images/ diabloIV.jgp', 'assets/images/ overwatch2.jpg', 'assets/images/ marioKart9.jgp']s
1919

2020
constructor(private router: Router, public newsService: NewsService, activatedRoute: ActivatedRoute){
2121

2222
const id = activatedRoute.snapshot.params['id'];
23-
this.newsService.getNew(id).subscribe(
24-
(news) => this.news = news as News, //casting in ts, es mejor hacerlo en el servicio (as Observable<News>), pero al dar error, hacemos el cast en el component
23+
this.newsService.getNews().subscribe(
24+
(news) => this.news = news as News[], //casting in ts, es mejor hacerlo en el servicio (as Observable<News>), pero al dar error, hacemos el cast en el component
2525
(error: any) => console.error(error)
2626

2727

2828
);
2929

3030
}
3131

32-
getNewsImage(){
32+
getNewsImage(news: News){
3333
if(this.news){ //We have to put this always. If exist any new...
34-
return this.news?.image+ '/api/news/' +this.news.id
34+
return news.image? '/api/news/' + news.id + '/image' : '/assets/images/not_foung.png';
3535
} else {
3636
return undefined;
3737
}
Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
1-
<p *ngIf="news"></p> <!--llamamos a news de tipo News, cargamos el constructor-->
2-
<div class="col-lg-4 mb-5">
1+
<div *ngIf="news">
2+
<!--llamamos a news de tipo News, cargamos el constructor-->
3+
<div class="col-lg-4 mb-5">
34
<div class="card h-100 shadow border-0">
4-
<p *ngIf="getNewsImage()"></p> <!--la imagen-->
5-
<img class="card-img-top" src="/news/{{news?.id}}/image" alt="..." />
6-
7-
<p *ngIf="!getNewsImage()"></p> <!--no imagen-->
8-
<img class="card-img-top" src="/Photos/not_foung.png" alt="..." />
9-
10-
<div class="card-body p-4">
11-
<div class="badge bg-primary bg-gradient rounded-pill mb-2">{{news?.badge}}</div>
12-
<a class="text-decoration-none link-dark stretched-link" href="/showNews/{{news?.id}}"><h5 class="card-title mb-3" style="color: black;">{{news?.title}}</h5></a>
13-
<p class="card-text mb-0">{{news?.description}}</p>
14-
</div>
15-
<div class="card-footer p-4 pt-0 bg-transparent border-top-0">
16-
<div class="d-flex align-items-end justify-content-between">
17-
<div class="d-flex align-items-center">
18-
<div class="small">
19-
<div class="text-muted">{{news?.date}} &middot; <p>{{news?.readTime}}</p></div>
20-
</div>
21-
</div>
5+
<!--la imagen-->
6+
<img class="card-img-top" [src]="newsImage()" alt="..." />
7+
<div class="card-body p-4">
8+
<div class="badge bg-primary bg-gradient rounded-pill mb-2">{{news?.badge}}</div>
9+
<a class="text-decoration-none link-dark stretched-link" [routerLink]="['/showNews/{{news?.id}}']">
10+
<h5 class="card-title mb-3" style="color: black;">{{news?.title}}</h5>
11+
</a>
12+
<p class="card-text mb-0">{{news?.description}}</p>
13+
</div>
14+
<div class="card-footer p-4 pt-0 bg-transparent border-top-0">
15+
<div class="d-flex align-items-end justify-content-between">
16+
<div class="d-flex align-items-center">
17+
<div class="small">
18+
<div class="text-muted">{{news?.date}} &middot; <p>{{news?.readTime}}</p>
19+
</div>
2220
</div>
21+
</div>
2322
</div>
23+
</div>
2424
</div>
25+
</div>
2526
</div>

frontend/src/app/components/news/newsTemplate.component.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Component } from '@angular/core';
22
import { Router, ActivatedRoute } from '@angular/router';
3+
34
import { News } from 'src/app/models/news.model';
45
import { NewsService } from 'src/app/services/news.service';
56

@@ -24,9 +25,12 @@ export class NewsTemplateComponent{
2425
);
2526
}
2627

27-
getNewsImage(){
28+
29+
30+
31+
newsImage(){
2832
if(this.news){ //We have to put this always. If exist any new...
29-
return this.news?.image+ '/api/news/' +this.news.id
33+
return this.news.image? '/api/news/' + this.news.id + '/image' : '/assets/images/not_foung.png';
3034
} else {
3135
return undefined;
3236
}
Lines changed: 55 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,73 @@
1-
<p *ngIf="news"></p>
1+
<div *ngIf="news">
22

3-
<!-- Header-->
4-
<header class="bg-dark py-5" style="background-color: #454546 !important;">
5-
<div class="container px-5">
6-
<div class="row gx-5 align-items-center justify-content-center">
7-
<div class="col-xl-5 col-xxl-6 d-none d-xl-block text-center"><img class="img-fluid rounded-3 my-5"
8-
src="/news/{{news?.id}}/image" alt="..." /></div>
9-
<div class="col-lg-8 col-xl-7 col-xxl-6">
10-
<div class="my-5 text-center text-xl-start">
11-
<h1 class="display-5 fw-bolder text-white mb-2" style="font-size: 40px;">{{news?.title}}</h1>
12-
<p class="lead fw-normal text-white-50 mb-4" style="color: aliceblue !important;">{{news?.argument}}</p>
3+
<!-- Header-->
4+
<header class="bg-dark py-5" style="background-color: #454546 !important;">
5+
<div class="container px-5">
6+
<div class="row gx-5 align-items-center justify-content-center">
7+
<div class="col-xl-5 col-xxl-6 d-none d-xl-block text-center"><img class="img-fluid rounded-3 my-5"
8+
src="/news/{{news?.id}}/image" alt="..." /></div>
9+
<div class="col-lg-8 col-xl-7 col-xxl-6">
10+
<div class="my-5 text-center text-xl-start">
11+
<h1 class="display-5 fw-bolder text-white mb-2" style="font-size: 40px;">{{news?.title}}</h1>
12+
<p class="lead fw-normal text-white-50 mb-4" style="color: aliceblue !important;">{{news?.argument}}</p>
13+
</div>
1314
</div>
1415
</div>
1516
</div>
16-
</div>
1717

1818

1919

20-
</header>
20+
</header>
2121

22-
<p *ngIf="isAdmin()"></p>
23-
<section class="pt-0 MoreInfo">
24-
<div class="container-fluid my-5">
25-
<div class="row justify-content-center" style=" background-color: rgb(27, 31, 31); margin-bottom: 2%;">
26-
<div class="col-5 text-center">
27-
<p class="lead fw-normal text-white-50 mb-4"
28-
style="color: aliceblue !important; font-size: 2em !important; margin-top: 5%;"> Admin Actions :
29-
<a class="btn btn-primary btn-lg px-4 me-sm-3" [routerLink]="['/deleteNew/{{news?.id}}']"
30-
style="margin-top: auto;">Eliminar</a>
31-
<a class="btn btn-outline-light btn-lg px-4" [routerLink]="['/editNew/{{news?.id}}']"
32-
style="margin-top: auto;">Editar</a>
33-
</p>
22+
<div *ngIf="isAdmin()">
23+
<section class="pt-0 MoreInfo">
24+
<div class="container-fluid my-5">
25+
<div class="row justify-content-center" style=" background-color: rgb(27, 31, 31); margin-bottom: 2%;">
26+
<div class="col-5 text-center">
27+
<p class="lead fw-normal text-white-50 mb-4"
28+
style="color: aliceblue !important; font-size: 2em !important; margin-top: 5%;"> Admin Actions :
29+
<a class="btn btn-primary btn-lg px-4 me-sm-3" [routerLink]="['/deleteNew/{{news?.id}}']"
30+
style="margin-top: auto;">Eliminar</a>
31+
<a class="btn btn-outline-light btn-lg px-4" [routerLink]="['/editNew/{{news?.id}}']"
32+
style="margin-top: auto;">Editar</a>
33+
</p>
34+
</div>
35+
</div>
3436
</div>
35-
</div>
37+
</section>
3638
</div>
37-
</section>
3839

3940

40-
<!-- MoreInfo-->
41-
<section class="pt-0 MoreInfo" style="margin-left: 10%; margin-right: 10%; background-color: #FFFFFF !important;">
42-
<div class="container px-5 my-5">
43-
<div class="row gx-5 justify-content-center">
44-
<div class="col-md-12">
45-
<h1 style="padding-bottom: 10px;">Leer más:</h1>
46-
<p class="">
47-
{{news?.description}}
48-
</p>
41+
<!-- MoreInfo-->
42+
<section class="pt-0 MoreInfo" style="margin-left: 10%; margin-right: 10%; background-color: #FFFFFF !important;">
43+
<div class="container px-5 my-5">
44+
<div class="row gx-5 justify-content-center">
45+
<div class="col-md-12">
46+
<h1 style="padding-bottom: 10px;">Leer más:</h1>
47+
<p class="">
48+
{{news?.description}}
49+
</p>
50+
</div>
51+
4952
</div>
5053

5154
</div>
55+
</section>
5256

53-
</div>
54-
</section>
55-
56-
<section class="pt-0 MoreInfo" style="margin-left: 10%; margin-right: 10%; background-color: inherit !important;">
57-
<div class="container px-5 my-5">
58-
<div class="row gx-5 justify-content-center">
59-
<!--{{>videogameTemplate}}-->
57+
<section class="pt-0 MoreInfo" style="margin-left: 10%; margin-right: 10%; background-color: inherit !important;">
58+
<div class="container px-5 my-5">
59+
<div class="row gx-5 justify-content-center">
60+
<!--{{>videogameTemplate}}-->
61+
</div>
6062
</div>
61-
</div>
62-
</section>
63-
<!-- Footer-->
63+
</section>
64+
65+
66+
67+
<!-- Bootstrap core JS-->
68+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
69+
<!-- Core theme JS-->
70+
<script src="js/scripts.js"></script>
71+
6472

65-
<!-- Bootstrap core JS-->
66-
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
67-
<!-- Core theme JS-->
68-
<script src="js/scripts.js"></script>
73+
</div>

frontend/src/app/models/videogame.model.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export interface Videogame {
22
id?: number;
33
imageVg: boolean;
44
imageCompany: boolean;
5-
title: string;
5+
title: string;
66
price:number;
77
rating:number;
88
genre:string;
@@ -11,16 +11,16 @@ export interface Videogame {
1111
description:string;
1212
shortDescription:string;
1313
history:string;
14-
14+
1515
cpuR:string;
1616
ramR:string;
1717
ssooR:string;
1818
gpuR:string;
1919
storageR:string;
20-
20+
2121
cpuM:string;
2222
ramM:string;
2323
ssooM:string;
2424
gpuM:string;
2525
storageM:string;
26-
}
26+
}

frontend/src/app/services/news.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class NewsService {
1212

1313
constructor(private httpClient: HttpClient) { }
1414

15-
getsNews() {
15+
getNews() {
1616
return this.httpClient.get(URL).pipe(
1717
catchError((error: any) => this.handleError(error))
1818
) //as Observable<News> es el tipo de objeto que devuelve, un objeto del tipo News

0 commit comments

Comments
 (0)