Skip to content

Commit 1108a14

Browse files
Connect view with logic in component 4:
Component 4 (List all article's) commercial.html (old view) --> AllArticlesWebPagination.component.html (new view) --> + --> AllArticlesWebPagination.component.ts (logic)
1 parent 5cdab28 commit 1108a14

File tree

3 files changed

+26
-47
lines changed

3 files changed

+26
-47
lines changed

angular/wallypop/src/app/components/article/AllArticlesWebPagination.component.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
{{>header}}
1+
<!-- {>header}} -->{
22
<!-- ====== Page content ======-->
33
<section class="section">
4-
{{>search}}
5-
{{#ERROR}}
4+
<!--{{>search}}-->
5+
<!--{{#ERROR}}-->
66
<br>
77
<div class="container">
88
<div class="alert alert-danger" role="alert">
99
<center>El artículo que buscas no existe o ya no está disponible</center>
1010
</div>
1111
</div>
12-
{{/ERROR}}
12+
<!--{{/ERROR}}-->
1313
<hr>
1414
<div class="container-fluid">
1515
<div class="row">
@@ -20,13 +20,13 @@
2020
FILTROS <i aria-hidden="true" class="fa fa-sort pull-right"></i>
2121
</button>
2222
<form action="/search/commercial" class="full-width menu-commercial" method="GET">
23-
<h4 class="text-light">CATEGORÍA</h4>
23+
<h4 class="text-light">CATEGORÃA</h4>
2424
<div class="form-group">
2525
<select class="form-control" name="id_category">
2626
<option disabled selected>Selecciona una categoría</option>
27-
{{#lcategory}}
27+
<!--{{#lcategory}}-->
2828
<option name="CATEGORY" value="{{ID_CATEGORY}}">{{TITLE}}</option>
29-
{{/lcategory}}
29+
<!-- {{/lcategory}-->
3030
</select>
3131
</div>
3232
<p class="text-center">
@@ -46,17 +46,17 @@ <h4 class="text-light">CATEGORÍA</h4>
4646
<div class="col-xs-12 col-sm-9 col-md-10">
4747
<div class="full-width">
4848
<ol class="breadcrumb">
49-
{{#lcategory}}
49+
<!-- {{#lcategory}}-->
5050
<li><a href="/commercial/{{ID_CATEGORY}}">{{TITLE}}</a></li>
51-
{{/lcategory}}
51+
<!--{{/lcategory}}-->
5252
</ol>
5353
</div>
5454
<div class="full-widht">
5555
<i class="fa fa-th-large btn btn-default hidden-xs btn-change-post"></i>
5656
<i class="fa fa-refresh btn btn-default"></i>
5757
<i class="fa fa-angle-right btn btn-default"></i>
5858
</div>
59-
{{>article}}
59+
<!--{{>article}}-->
6060
<div class="clearfix"></div>
6161
<nav class="text-center">
6262
<ul class="pagination">
Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
2-
31
import {Component} from '@angular/core';
4-
import { Article } from 'src/app/models/article.model';
2+
import {Observable, throwError} from 'rxjs';
3+
//ESTA LINEA HAY QUE DESCOMENTARLA CUANDO SE HAGA EL MERGE CON LA RAMA CATEGORY
4+
//import {Category } from 'src/app/models/category.model';
5+
import {Article } from 'src/app/models/article.model';
56
import {ArticleService} from '../../services/article.service';
67
import {LoginService} from '../../services/login.service';
78

@@ -13,9 +14,17 @@ export class AllArticlesWebPagination {
1314
constructor(public articleService: ArticleService, public loginService: LoginService) {
1415
}
1516

16-
listAllArticlesWebPagination(event: any,): void {
17+
listAllArticlesWebPagination(event: any,): Observable<Object> {
18+
event.preventDefault();
19+
return this.articleService.listAllArticlesWebPagination();
20+
}
21+
22+
/*
23+
* ESTE METODO HAY QUE DESCOMENTARLO CUANDO SE HAGA EL MERGE CON LA RAMA CATEGORY
24+
showCategories(event: any): Observable<Category[]> {
1725
event.preventDefault();
18-
this.articleService.listAllArticlesWebPagination();
26+
this.articleService.addArticle(title,description,city, price, postal_code);
1927
}
28+
*/
2029
}
2130

angular/wallypop/src/app/services/article.service.ts

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export class ArticleService {
109109
}
110110

111111
listArticlesUserPagination (user: User){
112+
// MIRAR TRANSPARENCIAS 14 APIS REST Y SERVICIOS
112113
return this.httpClient.get(BASE_URL + user.articles).pipe(
113114
catchError(error => this.handleError(error))
114115
) as Observable<string>;
@@ -121,38 +122,7 @@ export class ArticleService {
121122

122123
}
123124

124-
/*
125-
* AQUÍ LA PAGINACIÓN QUE HICIMOS PARA LA API REST. HAY QUE TRADUCIR ESTE MÉTODO DE JAVA A TYPESCRIPT
126-
@GetMapping(params = {"page"})
127-
public ResponseEntity<List<Article>> articlesPagination(HttpServletRequest request, @RequestParam("page") int page) {
128-
if (page != -1) { // with pagination
129-
130-
int pageSize = 4;
131-
try {
132-
List<Article> lArticlesPageable = new LinkedList<>();
133-
Pageable paging = PageRequest.of(0, pageSize);
134-
Page<Article> articlePage;
135-
articlePage = articleService.findAllPageable(paging.withPage(page));
136-
if (articlePage.getNumberOfElements() == 0) {
137-
// Empty
138-
} else {
139-
for (Article a : articlePage) {
140-
lArticlesPageable.add(a);
141-
}
142-
}
143-
return new ResponseEntity<>(lArticlesPageable, HttpStatus.OK);
144-
} catch (Exception e) {
145-
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
146-
}
147-
} else { // without pagination
148-
try {
149-
return new ResponseEntity<>(articleService.findAll(), HttpStatus.OK);
150-
} catch (Exception e) {
151-
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
152-
}
153-
}
154-
}
155-
*/
125+
156126

157127

158128
}

0 commit comments

Comments
 (0)