Skip to content

Commit eded5d0

Browse files
committed
Merge branch 'angular' into angular_report
2 parents 66df164 + 9c19c2f commit eded5d0

File tree

13 files changed

+386
-46
lines changed

13 files changed

+386
-46
lines changed

angular/wallypop/.idea/workspace.xml

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

angular/wallypop/src/app/app.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ import { ReportsComponent } from './components/report/reports.component';
1818
import { ShowReportComponent } from './components/report/showReport.component';
1919
import { CategoryListComponent } from './components/category/categoryList.component';
2020
import {CommercialComponent} from './components/articles/commercial.component';
21+
import {PostComponent} from './components/articles/post.component';
2122

2223
@NgModule({
23-
declarations: [AppComponent, IndexComponent, LoginComponent, SearchComponent, NotFoundComponent, NewaccountComponent, ProfileComponent, CategoryComponent, CategoryListComponent, CommercialComponent, FormReportComponent, ReportsComponent, ShowReportComponent],
24+
// tslint:disable-next-line:max-line-length
25+
declarations: [AppComponent, IndexComponent, LoginComponent, SearchComponent, NotFoundComponent, NewaccountComponent, ProfileComponent, CategoryComponent, CategoryListComponent, CommercialComponent, PostComponent, FormReportComponent, ReportsComponent, ShowReportComponent],
2426
imports: [BrowserModule, FormsModule, HttpClientModule, routing],
2527
bootstrap: [AppComponent]
2628
})

angular/wallypop/src/app/app.routing.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { ReportsComponent } from './components/report/reports.component';
1111
import { ShowReportComponent } from './components/report/showReport.component';
1212
import { CategoryListComponent } from './components/category/categoryList.component';
1313
import {CommercialComponent} from './components/articles/commercial.component';
14+
import {PostComponent} from './components/articles/post.component';
1415

1516
const appRoutes = [
1617
{ path: '', component: IndexComponent },
@@ -24,6 +25,9 @@ const appRoutes = [
2425
{ path: 'categoryList', component: CategoryListComponent},
2526
{ path: 'commercial', component: CommercialComponent },
2627
{ path: 'showReport/:id', component: ShowReportComponent},
28+
{ path: 'commercial/:id', component: CommercialComponent },
29+
{ path: 'post', component: PostComponent },
30+
{ path: 'post/:id', component: PostComponent },
2731
{ path: '**', component: NotFoundComponent}
2832
];
2933

angular/wallypop/src/app/components/articles/commercial.component.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
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>
@@ -29,14 +29,14 @@ <h4 class="text-light">CATEGORÍA</h4>
2929
</div>
3030
<p class="text-center">
3131
<button class="btn btn-success btn-block">APLICAR</button>
32+
</p> -->
33+
<p>
34+
<small>Anuncios segunda mano. Las mejores ofertas en de segunda mano y de ocasión solo
35+
en Wallypop</small>
3236
</p>
3337
<p class="text-center">
34-
<a class="btn btn-info btn-block" href="/commercial" onclick="" type="reset">BORRAR
35-
FILTROS</a>
36-
</p>
37-
<p>
38-
<small>Anuncios segunda mano . Las mejores ofertas en de segunda mano y de ocasión solo
39-
en </small>
38+
<a class="btn btn-info btn-block" href="/commercial" onclick="" type="reset">BORRAR
39+
FILTROS</a>
4040
</p>
4141
</form>
4242
</div>
@@ -47,11 +47,11 @@ <h4 class="text-light">CATEGORÍA</h4>
4747
<li *ngFor="let category of categories"><a href="/commercial/{{category.id_CATEGORY}}">{{category.title}}</a></li>
4848
</ol>
4949
</div>
50-
<div class="full-widht">
50+
<!-- <div class="full-widht">
5151
<i class="fa fa-th-large btn btn-default hidden-xs btn-change-post"></i>
5252
<i class="fa fa-refresh btn btn-default"></i>
5353
<i class="fa fa-angle-right btn btn-default"></i>
54-
</div>
54+
</div> -->
5555
<!-- Article -->
5656
<div class="full-width container-post">
5757
<div class="full-width post" *ngFor="let article of articles">
@@ -64,7 +64,7 @@ <h4 class="text-light">CATEGORÍA</h4>
6464
<p class="full-width post-info-price">{{article.price}}€</p>
6565
<span class="post-info-zone">{{article.city}}</span>
6666
<span class="post-info-date">{{article.date}}</span>
67-
<a *ngIf="this.loginService.isLogged" href="/addFavorite/{{article.id_ARTICLE}}"><i class="fa fa-heart-o post-info-like"></i></a>
67+
<a *ngIf="this.loginService.isLogged()" href="/addFavorite/{{article.id_ARTICLE}}"><i class="fa fa-heart-o post-info-like"></i></a>
6868
</div>
6969
</ng-template>
7070
</div>

angular/wallypop/src/app/components/articles/commercial.component.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {Article} from '../../models/article.model';
55
import {Category} from '../../models/category.model';
66
import {CategoryService} from '../../services/category.service';
77
import {User} from '../../models/user.model';
8+
import {ActivatedRoute} from '@angular/router';
89

910
@Component({
1011
selector: 'commercial',
@@ -13,12 +14,21 @@ import {User} from '../../models/user.model';
1314
export class CommercialComponent implements OnInit {
1415
articles: Article[];
1516
categories: Category[];
16-
constructor(private articleService: ArticleService, private categoryService: CategoryService, private loginService: LoginService) {
17+
category: Category;
18+
idCategory: number;
19+
constructor(private articleService: ArticleService, private categoryService: CategoryService, private loginService: LoginService, private routing: ActivatedRoute) {
20+
this.idCategory = -1;
1721
}
1822

1923
ngOnInit(): void {
2024
this.getCategories();
21-
this.getArticles();
25+
26+
this.idCategory = this.routing.snapshot.params.id;
27+
if (this.idCategory !== undefined) {
28+
this.getArticlesFromCategory(this.idCategory);
29+
} else {
30+
this.getAllArticles();
31+
}
2232
}
2333

2434
getCategories(): void {
@@ -28,17 +38,17 @@ export class CommercialComponent implements OnInit {
2838
);
2939
}
3040

31-
getArticles(): void {
32-
this.articleService.getArticles().subscribe(
33-
article => this.articles = article,
41+
getArticlesFromCategory(id: number | string): void {
42+
this.categoryService.getCategory(id).subscribe(
43+
articles => this.articles = articles,
3444
error => console.log(error)
3545
);
36-
this.articles.forEach(value => {
37-
value.user = this.getUser(value.userID);
38-
});
3946
}
4047

41-
getUser(id: number): User {
42-
return this.loginService.getUser(id);
48+
getAllArticles(): void {
49+
this.articleService.getArticles().subscribe(
50+
article => this.articles = article,
51+
error => console.log(error)
52+
);
4353
}
4454
}

0 commit comments

Comments
 (0)