Skip to content

Commit bee004c

Browse files
committed
Refactoring da estrutura do app.
1 parent 8d29257 commit bee004c

File tree

70 files changed

+1285
-519
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1285
-519
lines changed

.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}

src/app/app.module.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,32 @@ import { HttpClientModule } from '@angular/common/http';
55

66
import { AppComponent } from './app.component';
77

8-
import { CoreModule } from './core/core.module';
9-
import { UIModule } from './ui/ui.module';
8+
import { CoreModule } from './modules/core/.core.module';
9+
import { UIModule } from './modules/ui/.ui.module';
1010

1111
import { AuthenticationService } from './services/authentication.service';
1212
import { LoadingService } from './services/loading.service';
13+
import { NotFoundComponent } from './modules/ui/not-found.component';
14+
import { HomePageComponent } from './routes/home/home-page.component';
1315

1416
export const appRoutes: Routes = [
1517
{
16-
path: '',
17-
loadChildren: './routes/index/index.module#IndexModule'
18+
path: 'identity',
19+
loadChildren: './routes/identity/identity.module#IdentityModule'
1820
},
1921
{
20-
path: 'login',
21-
loadChildren: './routes/login/login.module#LoginModule'
22-
},
23-
{
24-
path: 'users',
25-
loadChildren: './routes/users/users.module#UsersModule'
26-
},
27-
{
28-
path: 'not-found',
29-
loadChildren: './routes/not-found/not-found.module#NotFoundModule'
22+
path: 'dot',
23+
loadChildren: './routes/dot/dot.module#DotModule'
3024
},
25+
{ path: '', component: HomePageComponent },
26+
{ path: 'not-found', component: NotFoundComponent },
3127
{ path: '**', redirectTo: 'not-found' }
3228
];
3329

3430
@NgModule({
3531
declarations: [
36-
AppComponent
32+
AppComponent,
33+
HomePageComponent
3734
],
3835
imports: [
3936
BrowserModule,

src/app/core/core.module.ts renamed to src/app/modules/core/.core.module.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { NgModule, LOCALE_ID, Optional, SkipSelf, ModuleWithProviders } from '@angular/core';
22
import { HTTP_INTERCEPTORS } from '@angular/common/http';
33

4-
import { AuthenticationGuardComponent } from './authentication-guard.component';
5-
import { HttpBackendInterceptorComponent } from './http-backend-interceptor.component';
6-
import { HttpBearerInterceptorComponent } from './http-bearer-interceptor.component';
7-
import { HttpLoaderInterceptorComponent } from './http-loader-interceptor.component';
4+
import { HttpBackendInterceptor } from './http-backend.interceptor';
5+
import { HttpBearerInterceptor } from './http-bearer.interceptor';
6+
import { HttpLoaderInterceptor } from './http-loader.interceptor';
7+
8+
import { AuthenticationGuard } from './authentication.guard';
89

910
@NgModule({})
1011
export class CoreModule {
@@ -21,10 +22,10 @@ export class CoreModule {
2122
// O SISTEMA VAI CARREGAR ISSO TUDO. EM TODOS OS MODULOS.
2223
providers: [
2324
{ provide: LOCALE_ID, useValue: 'pt-BR' },
24-
{ provide: HTTP_INTERCEPTORS, useClass: HttpLoaderInterceptorComponent, multi: true },
25-
{ provide: HTTP_INTERCEPTORS, useClass: HttpBearerInterceptorComponent, multi: true },
26-
{ provide: HTTP_INTERCEPTORS, useClass: HttpBackendInterceptorComponent, multi: true },
27-
AuthenticationGuardComponent,
25+
{ provide: HTTP_INTERCEPTORS, useClass: HttpLoaderInterceptor, multi: true },
26+
{ provide: HTTP_INTERCEPTORS, useClass: HttpBearerInterceptor, multi: true },
27+
{ provide: HTTP_INTERCEPTORS, useClass: HttpBackendInterceptor, multi: true },
28+
AuthenticationGuard
2829
]
2930
}
3031
}

src/app/core/authentication-guard.component.ts renamed to src/app/modules/core/authentication.guard.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Injectable } from '@angular/core';
22
import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
3-
import { AuthenticationService } from '../services/authentication.service';
3+
import { AuthenticationService } from '../../services/authentication.service';
44

55
@Injectable()
6-
export class AuthenticationGuardComponent implements CanActivate {
6+
export class AuthenticationGuard implements CanActivate {
77

88
constructor(
99
private router: Router,
@@ -21,7 +21,7 @@ export class AuthenticationGuardComponent implements CanActivate {
2121
}
2222
}
2323

24-
this.router.navigate(['/login'], {
24+
this.router.navigate(['/identity'], {
2525
queryParams: {
2626
returnUrl: state.url
2727
}

src/app/core/http-backend-interceptor.component.ts renamed to src/app/modules/core/http-backend.interceptor.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ import { Injectable } from '@angular/core';
22
import { HttpRequest, HttpResponse, HttpHandler, HttpEvent, HttpInterceptor } from '@angular/common/http';
33
import { Observable, of, throwError } from 'rxjs';
44
import { delay, mergeMap, materialize, dematerialize } from 'rxjs/operators';
5-
import { Jwt } from '../domain/Jwt';
5+
import { Jwt } from '../../domain/jwt';
66

77
@Injectable()
8-
export class HttpBackendInterceptorComponent implements HttpInterceptor {
8+
export class HttpBackendInterceptor implements HttpInterceptor {
99
constructor() { }
1010

1111
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
12-
if (req.url.endsWith('/login') ||
12+
if (req.url.endsWith('/identity') ||
1313
req.url.endsWith('/users') ||
1414
req.url.endsWith('/error')) {
1515

1616
return of(null).pipe(mergeMap(() => {
17-
if (req.url.endsWith('/login') && req.method === 'POST') {
17+
if (req.url.endsWith('/identity') && req.method === 'POST') {
1818
var data = new Date();
1919
data.setDate(data.getDate() + 1);
2020

@@ -68,7 +68,7 @@ export class HttpBackendInterceptorComponent implements HttpInterceptor {
6868
return next.handle(req);
6969
}))
7070
.pipe(materialize())
71-
.pipe(delay(5000))
71+
.pipe(delay(500))
7272
.pipe(dematerialize());
7373
}
7474
}

src/app/core/http-bearer-interceptor.component.ts renamed to src/app/modules/core/http-bearer.interceptor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest } from '@angular/c
33
import { Observable } from 'rxjs';
44

55
@Injectable()
6-
export class HttpBearerInterceptorComponent implements HttpInterceptor {
6+
export class HttpBearerInterceptor implements HttpInterceptor {
77
constructor() {}
88

99
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {

src/app/core/http-loader-interceptor.component.ts renamed to src/app/modules/core/http-loader.interceptor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { Injectable } from '@angular/core';
22
import { HttpRequest, HttpHandler, HttpInterceptor, HttpResponse } from '@angular/common/http';
33
import { tap, catchError } from 'rxjs/operators';
44

5-
import { LoadingService } from '../services/loading.service';
5+
import { LoadingService } from '../../services/loading.service';
66

77
@Injectable()
8-
export class HttpLoaderInterceptorComponent implements HttpInterceptor {
8+
export class HttpLoaderInterceptor implements HttpInterceptor {
99
private requests = 0;
1010

1111
constructor(private loadingService: LoadingService) { }

src/app/modules/ui/.ui.module.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { NgModule } from '@angular/core';
2+
import { CommonModule } from '@angular/common';
3+
import { RouterModule } from '@angular/router';
4+
5+
import { LayoutComponent } from './layout.component';
6+
import { HeaderComponent } from './header.component';
7+
import { FooterComponent } from './footer.component';
8+
import { BreadcrumbComponent } from './breadcrumb.component';
9+
import { NotFoundComponent } from './not-found.component';
10+
11+
@NgModule({
12+
imports: [
13+
CommonModule,
14+
RouterModule
15+
],
16+
declarations: [
17+
LayoutComponent,
18+
HeaderComponent,
19+
FooterComponent,
20+
BreadcrumbComponent,
21+
NotFoundComponent
22+
],
23+
exports: [
24+
LayoutComponent,
25+
HeaderComponent,
26+
FooterComponent,
27+
BreadcrumbComponent,
28+
NotFoundComponent
29+
]
30+
})
31+
export class UIModule { }
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-breadcrumb',
5+
template: `
6+
<div class="row">
7+
<div class="col-12">
8+
<div class="page-title-box">
9+
<div class="page-title-right">
10+
<ol class="breadcrumb m-0">
11+
<li class="breadcrumb-item"><a href="javascript: void(0);">Hyper</a></li>
12+
<li class="breadcrumb-item"><a href="javascript: void(0);">Forms</a></li>
13+
<li class="breadcrumb-item active">Form Elements</li>
14+
</ol>
15+
</div>
16+
<h4 class="page-title">Form Elements</h4>
17+
</div>
18+
</div>
19+
</div>
20+
`,
21+
styles: []
22+
})
23+
export class BreadcrumbComponent {
24+
25+
constructor() { }
26+
}

0 commit comments

Comments
 (0)