Skip to content

Commit 1e171b2

Browse files
committed
Correção do loader interceptor para requisições que são canceladas pelo angular.
1 parent 991eb3e commit 1e171b2

File tree

6 files changed

+65
-61
lines changed

6 files changed

+65
-61
lines changed

src/app/modules/core/http-loader.interceptor.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ export class HttpLoaderInterceptor implements HttpInterceptor {
1111
constructor(private loadingService: LoadingService) { }
1212

1313
intercept(request: HttpRequest<any>, next: HttpHandler) {
14-
console.log('foi ' + request.url )
15-
1614
this.loadingService.loading.next(true);
1715

1816
return next.handle(request)
@@ -31,7 +29,6 @@ export class HttpLoaderInterceptor implements HttpInterceptor {
3129
}
3230

3331
private finishing(request: HttpRequest<any>) {
34-
console.log('voltou ' + request.url )
3532
this.requests--;
3633

3734
if (this.requests == 0) {

src/app/modules/ui/pagination.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Component, ViewEncapsulation, Input, Output, EventEmitter } from '@angular/core';
22
import { faAngleRight, faAngleLeft, IconDefinition } from '@fortawesome/free-solid-svg-icons';
3-
import { Pagination } from 'src/app/domain/pagination';
43
import { FadeAnimation } from '../animations/fade.animation';
54
import { BehaviorSubject } from 'rxjs';
5+
import { Pagination } from '../../domain/pagination';
66

77
@Component({
88
selector: 'pagination',

src/app/routes/users/users-add/users-add.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ export class UsersAddComponent {
7676

7777
this.renderer.addClass(document.body, 'overflow');
7878
this.renderer.setProperty(this.panel.nativeElement, 'scrollTop', '0');
79-
this.location.go(this.router.url.split('/')[1] + '/new');
79+
this.location.go(this.router.url.split('?')[0] + '/new');
8080
} else {
8181
this.renderer.removeClass(document.body, 'overflow');
82-
this.location.go(this.router.url.split('/')[1]);
82+
this.location.go(this.router.url.split('?')[0]);
8383
}
8484
});
8585
}

src/app/routes/users/users-edit/users-edit.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Component, ViewEncapsulation, Renderer2, ViewChild, ElementRef, LOCALE_
22
import { faTimes, IconDefinition } from '@fortawesome/free-solid-svg-icons';
33
import { BehaviorSubject } from 'rxjs';
44
import { Location } from '@angular/common';
5-
import { Router } from '@angular/router';
5+
import { Router, ActivatedRoute } from '@angular/router';
66
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
77
import { UsersFormComponent } from '../users-form/users-form.component';
88
import { PanelAnimation } from '../../../modules/animations/panel.animation';
@@ -36,6 +36,7 @@ export class UsersEditComponent {
3636
private renderer: Renderer2,
3737
private location: Location,
3838
private router: Router,
39+
private route: ActivatedRoute,
3940
private userHttpService: HttpService<User>,
4041
private toastService: ToastService,
4142
@Inject(LOCALE_ID) private locale: string) {
@@ -75,10 +76,12 @@ export class UsersEditComponent {
7576

7677
this.renderer.addClass(document.body, 'overflow');
7778
this.renderer.setProperty(this.panel.nativeElement, 'scrollTop', '0');
78-
this.location.go(this.router.url.split('/')[1] + '/' + this.user.Id);
79+
console.log(route);
80+
console.log(router);
81+
this.location.go(this.router.url.split('?')[0] + '/' + this.user.Id);
7982
} else {
8083
this.renderer.removeClass(document.body, 'overflow');
81-
this.location.go(this.router.url.split('/')[1]);
84+
this.location.go(this.router.url.split('?')[0]);
8285
}
8386
});
8487
}
Lines changed: 55 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,72 @@
1-
<pagination-information
2-
#information
3-
[pagination]="pagination | async"
4-
[entity]="'users'">
5-
</pagination-information>
1+
<ng-container *ngTemplateOutlet="items; context:{ observable: pagination | async }"></ng-container>
62

7-
<ng-container *ngIf="pagination | async as pagination">
8-
<div [@list-transition]="pagination.Items.length"
9-
(@list-transition.start)="hide($event)"
10-
(@list-transition.done)="show($event)">
11-
12-
<ng-container *ngIf="pagination.Items.length > 0; else no_items">
13-
<div *ngFor="let user of pagination.Items">
14-
<div class="card mb-2" style="padding: 15px;">
15-
<div class="row justify-content-sm-between align-items-sm-center">
16-
<div class="col-md-2">
17-
<div class="form-group">
18-
<label class="small">Name</label>
19-
<label>{{ user.Name }}</label>
3+
<ng-template #items let-pagination="observable">
4+
<pagination-information
5+
#information
6+
[pagination]="pagination"
7+
[entity]="'users'">
8+
</pagination-information>
9+
10+
<ng-container *ngIf="pagination">
11+
<div [@list-transition]="pagination.Items.length"
12+
(@list-transition.start)="hide($event)"
13+
(@list-transition.done)="show($event)">
14+
15+
<ng-container *ngIf="pagination.Items.length > 0; else no_items">
16+
<div *ngFor="let user of pagination.Items">
17+
<div class="card mb-2" style="padding: 15px;">
18+
<div class="row justify-content-sm-between align-items-sm-center">
19+
<div class="col-md-2">
20+
<div class="form-group">
21+
<label class="small">Name</label>
22+
<label>{{ user.Name }}</label>
23+
</div>
2024
</div>
21-
</div>
22-
<div class="col-md-3">
23-
<div class="form-group">
24-
<label class="small">Email</label>
25-
<label>{{ user.Email }}</label>
25+
<div class="col-md-3">
26+
<div class="form-group">
27+
<label class="small">Email</label>
28+
<label>{{ user.Email }}</label>
29+
</div>
2630
</div>
27-
</div>
28-
<div class="col-md-3">
29-
<div class="form-group">
30-
<label class="small">Document</label>
31-
<label>{{ user.Document | mask: '000.000.000-00' }}</label>
31+
<div class="col-md-3">
32+
<div class="form-group">
33+
<label class="small">Document</label>
34+
<label>{{ user.Document | mask: '000.000.000-00' }}</label>
35+
</div>
3236
</div>
33-
</div>
34-
<div class="col-2 col-md-1">
35-
<div class="form-group">
36-
<label class="small">Birthday</label>
37-
<label>{{ user.Birthdate.toLocaleDateString(locale) }}</label>
37+
<div class="col-2 col-md-1">
38+
<div class="form-group">
39+
<label class="small">Birthday</label>
40+
<label>{{ user.Birthdate.toLocaleDateString(locale) }}</label>
41+
</div>
3842
</div>
39-
</div>
40-
<div class="col-1 col-md-1 text-center dropdown">
41-
<fa-icon [icon]="faEllipsisV"></fa-icon>
42-
43-
<div class="dropdown-content">
44-
<a (click)="edit(user)" href="javascript:void(0);" class="action-icon">Editar</a>
45-
<a (click)="delete(user)" href="javascript:void(0);" class="action-icon">Excluir</a>
43+
<div class="col-1 col-md-1 text-center dropdown">
44+
<fa-icon [icon]="faEllipsisV"></fa-icon>
45+
46+
<div class="dropdown-content">
47+
<a (click)="edit(user)" href="javascript:void(0);" class="action-icon">Editar</a>
48+
<a (click)="delete(user)" href="javascript:void(0);" class="action-icon">Excluir</a>
49+
</div>
4650
</div>
4751
</div>
4852
</div>
4953
</div>
50-
</div>
51-
</ng-container>
52-
<ng-template #no_items>
53-
<div class="card mb-2" style="padding: 15px;">
54-
<div class="row justify-content-sm-between align-items-sm-center">
55-
<div class="col-md-12 text-center">
56-
We've searched for some users, but we haven't found any.
54+
</ng-container>
55+
<ng-template #no_items>
56+
<div class="card mb-2" style="padding: 15px;">
57+
<div class="row justify-content-sm-between align-items-sm-center">
58+
<div class="col-md-12 text-center">
59+
We've searched for some users, but we haven't found any.
60+
</div>
5761
</div>
5862
</div>
59-
</div>
60-
</ng-template>
61-
</div>
63+
</ng-template>
64+
</div>
65+
</ng-container>
6266

6367
<pagination
6468
#pages
6569
[pagination]="pagination"
6670
(paginateEvent)="list($event, null)">
6771
</pagination>
68-
</ng-container>
72+
</ng-template>

src/app/routes/users/users-list/users-list.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,4 @@ export class UsersListComponent {
7878
return pagination;
7979
});
8080
}
81-
}
81+
}

0 commit comments

Comments
 (0)