Skip to content

Commit 58ff5ac

Browse files
author
JLRR2019
committed
showNews a la espera del tempalte de mani. Head component, no header (fallo mio)
1 parent 8dc87b5 commit 58ff5ac

File tree

11 files changed

+11843
-103
lines changed

11 files changed

+11843
-103
lines changed

backend/gamelink/src/main/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ spring.mustache.suffix=.html
1010

1111
spring.datasource.url=jdbc:postgresql://localhost:5432/gamelink
1212
spring.datasource.username=postgres
13-
spring.datasource.password=123456
13+
spring.datasource.password=Juanluis-123
1414
spring.jpa.hibernate.ddl-auto=create-drop
1515

1616
logging.level.org.springframework.security=DEBUG

frontend/src/app/app.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { HttpClientModule } from '@angular/common/http';
66
import { AppComponent } from './app.component';
77
import { routing } from './app.routing';
88
import { LoginComponent } from './components/login/login.component';
9-
import { HeaderComponent } from './components/header/header.component';
9+
import { HeadComponent } from './components/head/head.component';
1010
import { NewsComponent } from './components/news/news.component';
1111
import { NavBarComponent } from './components/navBar/navBar.component';
1212
import { FooterComponent } from './components/footer/footer.component';
@@ -15,7 +15,7 @@ import { ShowNewsComponent } from './components/news/showNews.component';
1515

1616

1717
@NgModule({
18-
declarations: [AppComponent, LoginComponent, HeaderComponent, NewsComponent, NavBarComponent, FooterComponent, NewsTemplateComponent, ShowNewsComponent],
18+
declarations: [AppComponent, LoginComponent, HeadComponent, NewsComponent, NavBarComponent, FooterComponent, NewsTemplateComponent, ShowNewsComponent],
1919
imports: [BrowserModule, FormsModule, HttpClientModule, routing],
2020
bootstrap: [AppComponent]
2121
})
File renamed without changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: 'head',
5+
templateUrl: './head.component.html'
6+
})
7+
8+
9+
export class HeadComponent{
10+
11+
12+
}

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

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class NewsComponent{
3030
}
3131

3232
getNewsImage(){
33-
if(this.news){ //We have to put this always. If exist any new...
33+
if(this.news){ //Wwe have to put this always. If exist any new...
3434
return this.news?.image+ '/api/news/' +this.news.id
3535
} else {
3636
return undefined;
Lines changed: 57 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,68 @@
1-
<!DOCTYPE html>
2-
<html lang="en">
1+
<p *ngIf="news"></p>
32

4-
<p *ngIf="news"></p>
5-
<body class="d-flex flex-column h-100" style="background-color:#f5f5f5;">
6-
<main class="flex-shrink-0">
7-
<!-- Navigation-->
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>
14+
</div>
15+
</div>
16+
</div>
817

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

2319

20+
</header>
2421

25-
</header>
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>
34+
</div>
35+
</div>
36+
</div>
37+
</section>
2638

27-
{{#isAdmin}}
28-
<section class="pt-0 MoreInfo">
29-
<div class="container-fluid my-5">
30-
<div class="row justify-content-center" style=" background-color: rgb(27, 31, 31); margin-bottom: 2%;">
31-
<div class="col-5 text-center" >
32-
<p class="lead fw-normal text-white-50 mb-4"
33-
style="color: aliceblue !important; font-size: 2em !important; margin-top: 5%;"> Admin Actions :
34-
<a class="btn btn-primary btn-lg px-4 me-sm-3" href="/deleteNew/{{id}}" style="margin-top: auto;">Eliminar
35-
<a class="btn btn-outline-light btn-lg px-4" href="/editNew/{{id}}" style="margin-top: auto;">Editar</a>
36-
</p>
3739

38-
</div>
39-
</div>
40-
</div>
41-
</section>
42-
{{/isAdmin}}
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>
49+
</div>
4350

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

55-
</div>
53+
</div>
54+
</section>
5655

57-
</div>
58-
</section>
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}}
60+
</div>
61+
</div>
62+
</section>
63+
<!-- Footer-->
5964

60-
<section class="pt-0 MoreInfo" style="margin-left: 10%; margin-right: 10%; background-color: inherit !important;">
61-
<div class="container px-5 my-5">
62-
<div class="row gx-5 justify-content-center">
63-
{{>videogameTemplate}}
64-
</div>
65-
</div>
66-
</section>
67-
</main>
68-
{{/new}}
69-
<!-- Footer-->
70-
71-
<!-- Bootstrap core JS-->
72-
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
73-
<!-- Core theme JS-->
74-
<script src="js/scripts.js"></script>
75-
</body>
76-
</html>
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>

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class ShowNewsComponent{
1313

1414
news: News | undefined;
1515

16-
constructor(public newsService: NewsService, loginService: LoginService, activatedRoute: ActivatedRoute){
16+
constructor(public newsService: NewsService, public loginService: LoginService, activatedRoute: ActivatedRoute){
1717

1818
const id = activatedRoute.snapshot.params['id'];
1919
this.newsService.getNew(id).subscribe(
@@ -24,4 +24,8 @@ export class ShowNewsComponent{
2424

2525
}
2626

27+
isAdmin(){
28+
return this.loginService.isAdmin();
29+
}
30+
2731
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ export interface News {
1515

1616
title:string;
1717

18+
1819
}

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

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,56 +12,72 @@ export class NewsService {
1212

1313
constructor(private httpClient: HttpClient) { }
1414

15-
getNews(): Observable<News> {
15+
getsNews() {
1616
return this.httpClient.get(URL).pipe(
17-
//catchError((error: any) => this.handleError(error))
18-
) as Observable<News>
17+
catchError((error: any) => this.handleError(error))
18+
)
1919
}
2020

2121
findNewsPage() {
22-
return this.httpClient.get(URL + "pages")
22+
return this.httpClient.get(URL + "pages").pipe(
23+
catchError((error: any) => this.handleError(error))
24+
)
2325
}
2426

25-
getNew(id: number): Observable<News> {
26-
return this.httpClient.get(URL + id) as Observable<News>
27+
getNew(id: number) {
28+
return this.httpClient.get(URL + id).pipe(
29+
catchError((error: any) => this.handleError(error))
30+
)
2731
}
2832

2933
createNew(news: News) {
3034
if (!news.id) {
31-
return this.httpClient.post(URL, news)
35+
return this.httpClient.post(URL, news).pipe(
36+
catchError((error: any) => this.handleError(error))
37+
)
3238
} else {
33-
return this.httpClient.put(URL + news.id, news)
39+
return this.httpClient.put(URL + news.id, news).pipe(
40+
catchError((error: any) => this.handleError(error))
41+
)
3442
}
3543
}
3644

3745
uptadeNew(news: News) {
38-
return this.httpClient.put(URL + news.id, news)
46+
return this.httpClient.put(URL + news.id, news).pipe(
47+
catchError((error: any) => this.handleError(error))
48+
)
3949
}
4050

4151
deleteNew(news: News) {
42-
return this.httpClient.delete(URL + news.id)
52+
return this.httpClient.delete(URL + news.id).pipe(
53+
catchError((error: any) => this.handleError(error))
54+
)
4355
}
4456

4557
uploadNewImage(news: News, formData: FormData) {
46-
return this.httpClient.post(URL + news.id + '/image', formData)
58+
return this.httpClient.post(URL + news.id + '/image', formData).pipe(
59+
catchError((error: any) => this.handleError(error))
60+
)
4761
}
4862

4963
downloadNewImage(news: News) {
50-
return this.httpClient.get(URL + news.id + '/image')
64+
return this.httpClient.get(URL + news.id + '/image').pipe(
65+
catchError((error: any) => this.handleError(error))
66+
)
5167
}
5268

5369
deleteNewImage(news: News) {
54-
return this.httpClient.delete(URL + news.id + '/image')
70+
return this.httpClient.delete(URL + news.id + '/image').pipe(
71+
)
5572
}
5673
/*readNew(news: News, user: Usero) {
5774
return this.httpClient.put()
58-
}*/
59-
75+
}
76+
*/
6077

6178
private handleError(error: any) {
62-
console.log("ERROR:");
63-
console.error(error);
64-
return throwError("Server error (" + error.status + "): " + error.text())
65-
}
66-
79+
console.log("ERROR:");
80+
console.error(error);
81+
return throwError("Server error (" + error.status + "): " + error.text())
82+
}
6783
}

0 commit comments

Comments
 (0)