Skip to content

Commit c196dec

Browse files
committed
Fix show reports
1 parent 2535b92 commit c196dec

File tree

5 files changed

+36
-37
lines changed

5 files changed

+36
-37
lines changed

angular/wallypop/.idea/workspace.xml

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

angular/wallypop/src/app/components/report/reports.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- ====== Page content ======-->
22
<!-- {{>nav_side}} -->
3-
<section class="full-width section">
3+
<section class="full-width section" *ngIf="loginService.isAdmin()">
44
<div class="container">
55
<div class="row">
66
<div class="col-xs-12 col-sm-4 col-md-3">
@@ -98,4 +98,4 @@
9898
</div>
9999
</div>
100100
</div>
101-
</section>
101+
</section>

angular/wallypop/src/app/components/report/showReport.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ <h2 class="text-center text-light">INCIDENCIA</h2>
99
<a class="btn btn-info" href="/reports">&lt;</a>
1010
<br>
1111
<!-- {{#report}} -->
12-
<h3 class="text-info">{{report.id_REPORT}}</h3>
12+
<h3 class="text-info">ID Report: {{report.id_REPORT}}</h3>
1313
<div class="form-group">
1414
<label class="col-sm-3 control-label">Email</label>
1515
<label class="col-sm-7">
@@ -19,7 +19,7 @@ <h3 class="text-info">{{report.id_REPORT}}</h3>
1919
<div class="form-group">
2020
<label class="col-sm-3 control-label">Articlo Denunciado</label>
2121
<label class="col-sm-7">
22-
<a class="form-control" >Pulsa para acceder
22+
<a href="/post/{{report.article.id_ARTICLE}}" class="form-control" >Pulsa para acceder
2323
al articulo denunciado</a> <!--onclick="location.href='/showPost/{{ID_REPORT}}'"-->
2424
</label>
2525
</div>

angular/wallypop/src/app/components/report/showReport.component.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,32 @@ import { Report } from 'src/app/models/report.model';
1010
export class ShowReportComponent implements OnInit{
1111
report:Report;
1212

13-
constructor(private reportService: ReportService,private activatedRoute: ActivatedRoute,private router: Router) {
13+
constructor(private reportService: ReportService, private activatedRoute: ActivatedRoute, private router: Router) {
1414
}
1515

1616
ngOnInit(): void {
17-
const id = this.activatedRoute.snapshot.params['id'];
17+
const id = this.activatedRoute.snapshot.params.id;
1818
this.reportService.getReport(id).subscribe(
1919
report => this.report = report,
2020
error => console.error(error)
21-
);
22-
console.log(this.report);
21+
);
22+
console.log(this.report);
2323
}
2424

25-
rejectReport() {
25+
rejectReport(): void {
2626
this.reportService.deleteReport(this.report).subscribe(
2727
_ => this.router.navigate(['/reports']),
2828
error => console.error(error)
2929
);
30+
this.router.navigate(['reports']);
3031
}
3132

32-
aceptReport() {
33-
this.reportService.aceptReport(this.report).subscribe(
33+
aceptReport(): void {
34+
this.reportService.aceptReport(this.report).subscribe(
3435
_ => this.router.navigate(['/reports']),
3536
error => console.error(error)
36-
);
37+
);
38+
this.router.navigate(['reports']);
3739
}
3840

3941
downloadProof() {
@@ -42,4 +44,4 @@ export class ShowReportComponent implements OnInit{
4244
);
4345
}
4446

45-
}
47+
}

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

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const BASE_URL = '/api/';
1313
export class ReportService {
1414
constructor(private httpClient: HttpClient, private router: Router) {}
1515

16-
1716
getReports(): Observable<Report[]> {
1817
return this.httpClient.get(BASE_URL+"admin/reports").pipe(
1918
catchError(error => this.handleError(error))
@@ -27,17 +26,15 @@ export class ReportService {
2726
}
2827

2928
deleteReport(report: Report) {
30-
this.httpClient.delete(BASE_URL +"admin/reports/"+report.id_REPORT+"/rejectReport").pipe(
29+
return this.httpClient.delete(BASE_URL +"admin/reports/"+report.id_REPORT+"/rejectReport").pipe(
3130
catchError(error => this.handleError(error))
3231
);
33-
this.router.navigate(['reports']);
3432
}
3533

3634
aceptReport(report: Report) {
37-
this.httpClient.delete(BASE_URL +"admin/reports/"+report.id_REPORT+"/aceptReport").pipe(
35+
return this.httpClient.delete(BASE_URL +"admin/reports/"+report.id_REPORT+"/aceptReport").pipe(
3836
catchError(error => this.handleError(error))
3937
);
40-
this.router.navigate(['reports']);
4138
}
4239

4340
proof(report: Report) {
@@ -47,30 +44,30 @@ export class ReportService {
4744
}
4845

4946

50-
addReport(email:string,description:string,id:number) {
51-
this.httpClient.post(BASE_URL + "reports/"+id, {email,description})
52-
.subscribe(
53-
(response) => this.router.navigate(['post/'+id]),
54-
(error) => alert('Ha ocurrido un error en el reporte')
55-
);
56-
47+
addReport(email:string,description:string,id:number) {
48+
this.httpClient.post(BASE_URL + "reports/"+id, {email,description})
49+
.subscribe(
50+
(response) => this.router.navigate(['post/'+id]),
51+
(error) => alert('Ha ocurrido un error en el reporte')
52+
);
53+
5754
}
58-
55+
5956
createForm(article:Article){
60-
return this.httpClient.post(BASE_URL + "reports/" +article.id_ARTICLE,article);
57+
return this.httpClient.post(BASE_URL + "reports/" +article.id_ARTICLE,article);
6158
}
62-
59+
6360
setReportProof(report: Report, formData: FormData) {
6461
return this.httpClient.post(BASE_URL +'reports/'+ report.id_REPORT + '/proof', formData)
6562
.pipe(
6663
catchError(error => this.handleError(error))
6764
);
68-
}
65+
}
6966

7067
private handleError(error: any): Observable<never> {
71-
console.log('ERROR:');
72-
console.error(error);
73-
return throwError('Server error (' + error.status + '): ' + error.text());
74-
}
68+
console.log('ERROR:');
69+
console.error(error);
70+
return throwError('Server error (' + error.status + '): ' + error.text());
71+
}
7572
}
7673

0 commit comments

Comments
 (0)