Skip to content

Commit 57cbda5

Browse files
author
JLRR2019
committed
Pequeños fixeos
1 parent 3801a51 commit 57cbda5

8 files changed

+37
-208
lines changed

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

Lines changed: 0 additions & 6 deletions
This file was deleted.

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

Lines changed: 0 additions & 29 deletions
This file was deleted.

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

Lines changed: 0 additions & 86 deletions
This file was deleted.

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

Lines changed: 0 additions & 69 deletions
This file was deleted.

frontend/src/app/components/videogame/videogame-detail.component.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ <h1 style="padding-bottom: 10px;">Noticias destacadas sobre este Titulo.</h1>
9595
<div class="container px-5 my-5" style="margin-bottom: 0px !important ;">
9696
<div class="row gx-5 justify-content-center">
9797

98-
<!-- {{>newsTemplate}} FALTA AÑADIR -->
99-
<!--<newsTemplate [news]="news"></newsTemplate>-->
98+
<newsTemplate class="col-lg-4 mb-5" *ngFor="let ng of news" [news]="ng"></newsTemplate>
10099

101100
</div>
102101
</div>

frontend/src/app/components/videogame/videogame-detail.component.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { Router,ActivatedRoute } from '@angular/router';
33
import { Videogame } from 'src/app/models/videogame.model';
44
import { LoginService } from 'src/app/services/login.service';
55
import { VideogameService } from 'src/app/services/videogame.service';
6+
import { News } from 'src/app/models/news.model';
7+
import { NewsService } from 'src/app/services/news.service';
68

79
@Component({
810
selector: 'videogame-detail',
@@ -11,15 +13,24 @@ import { VideogameService } from 'src/app/services/videogame.service';
1113

1214
export class VideogameDetailComponent{
1315

16+
17+
news!: News[];
1418
videogame!: Videogame;
1519

16-
constructor(private router: Router,public loginService: LoginService, activatedRoute: ActivatedRoute, public videogameService: VideogameService){
17-
20+
constructor(private router: Router,public loginService: LoginService, activatedRoute: ActivatedRoute, public videogameService: VideogameService, newsService: NewsService){
21+
1822
const id = activatedRoute.snapshot.params['id'];
1923
videogameService.getVideogame(id).subscribe(
2024
videogame => this.videogame = videogame,
2125
error => console.error(error)
2226
)
27+
28+
29+
newsService.getNew(id).subscribe(
30+
news => {this.news = news as News[]},
31+
error => console.error(error)
32+
)
33+
2334
}
2435

2536
removeVideogame() {
@@ -30,13 +41,13 @@ export class VideogameDetailComponent{
3041
error => console.error(error)
3142
);
3243
}
33-
}
34-
44+
}
45+
3546
editVideogame() {
3647
this.router.navigate(['/videogame/edit/' + this.videogame.id]);
3748
}
3849

39-
purchasevideogame(){
50+
purchasevideogame(){
4051
var id = this.loginService.currentUser();
4152
this.router.navigate(['/videogame/' + this.videogame.id + '/purchase/' + id?.id]);
4253
}
@@ -45,7 +56,7 @@ export class VideogameDetailComponent{
4556
return this.videogame.imageVg? '/api/videogames/'+this.videogame.id+'/image' : '/assets/images/no_image.png';
4657
}
4758

48-
59+
4960
companyImage(){
5061
return this.videogame.imageCompany? '/api/videogames/'+this.videogame.id+'/companyImage' : '/assets/images/no_image.png';
5162
}

frontend/src/app/components/videogame/videogame-edit-form.component.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ <h2 style="text-align: center; padding-top: 2%;">Edit Videogame Form</h2>
177177
<div class="col-md-8">
178178
<p>Related News: </p>
179179
<select name="notices" multiple style="width: 100%;">
180-
<!-- {{#news}}
181-
<option value="{{ id }}">{{ title }}</option>
182-
{{/news}} -->
180+
181+
<option *ngFor="let ng of news" value="{{ ng.id }}">{{ ng.title }}</option>
182+
183183
</select>
184184
</div>
185185
</div>
@@ -209,4 +209,4 @@ <h2 style="text-align: center; padding-top: 2%;">Edit Videogame Form</h2>
209209
</div>
210210
</form>
211211
</section>
212-
</main>
212+
</main>

frontend/src/app/components/videogame/videogame-edit-form.component.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { Component, Input, ViewChild } from '@angular/core';
22
import { Router,ActivatedRoute } from '@angular/router';
33
import { Videogame } from 'src/app/models/videogame.model';
44
import { VideogameService } from 'src/app/services/videogame.service';
5+
import { News } from 'src/app/models/news.model';
6+
import { NewsService } from 'src/app/services/news.service';
57

68
@Component({
79
selector: 'videogame-edit-form',
@@ -13,26 +15,33 @@ export class VideogameEditFormComponent{
1315
videogame!: Videogame;
1416
ready:boolean = false;
1517

18+
news!: News[];
19+
1620
@ViewChild("file")
1721
file: any;
1822

1923
@ViewChild("file1")
2024
file1: any;
2125

22-
constructor(private router: Router, activatedroute:ActivatedRoute, public videogameService: VideogameService){
26+
constructor(private router: Router, activatedroute:ActivatedRoute, public videogameService: VideogameService, newsService: NewsService){
2327
const id = activatedroute.snapshot.params['id'];
24-
videogameService.getVideogame(id).subscribe(
28+
videogameService.getVideogame(id).subscribe(
2529
data => {this.videogame= data as Videogame},
2630
error => console.error(error)
2731
)
2832

33+
newsService.getNews().subscribe(
34+
data => {this.news = data as News[]},
35+
error => console.error(error)
36+
)
37+
2938
}
3039

3140

3241
ngOnInit(){
3342
this.ready = true;
3443
}
35-
44+
3645
cancel() {
3746
window.history.back();
3847
}
@@ -45,7 +54,7 @@ export class VideogameEditFormComponent{
4554
}
4655

4756
uploadImage(videogame: Videogame): void {
48-
57+
4958
const image = this.file.nativeElement.files[0];
5059
if (image) {
5160
let formData = new FormData();
@@ -58,9 +67,9 @@ export class VideogameEditFormComponent{
5867
this.afterUploadImage(videogame);
5968
}
6069
}
61-
70+
6271
private afterUploadImage(videogame: Videogame){
6372
this.router.navigate(['/videogame/', videogame.id]);
6473
}
6574

66-
}
75+
}

0 commit comments

Comments
 (0)