add default 404 page

This commit is contained in:
Peter Maquiran
2023-12-06 13:14:41 +01:00
17 changed files with 411 additions and 476 deletions
+6 -4
View File
@@ -265,7 +265,8 @@ const routes = [
{ {
path: 'chat-options-popover', path: 'chat-options-popover',
loadChildren:() => import('./shared/popover/chat-options-popover/chat-options-popover.module').then( m => m.ChatOptionsPopoverPageModule) loadChildren:() => import('./shared/popover/chat-options-popover/chat-options-popover.module').then( m => m.ChatOptionsPopoverPageModule)
}, },
{
path: 'task-listt-header', path: 'task-listt-header',
loadChildren: () => import('./shared/gabinete-digital/generic/task-listt-header/task-listt-header.module').then( m => m.TaskListtHeaderPageModule) loadChildren: () => import('./shared/gabinete-digital/generic/task-listt-header/task-listt-header.module').then( m => m.TaskListtHeaderPageModule)
}, },
@@ -296,10 +297,11 @@ const routes = [
{ {
path: 'swiper', path: 'swiper',
loadChildren: () => import('./shared/swiper/swiper.module').then( m => m.SwiperPageModule) loadChildren: () => import('./shared/swiper/swiper.module').then( m => m.SwiperPageModule)
},
{
path: 'not-found',
loadChildren: () => import('./pages/not-found/not-found.module').then( m => m.NotFoundPageModule)
} }
}
/* /*
path: 'chat', path: 'chat',
component: ChatPage component: ChatPage
@@ -1,16 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { MiddlewareRemoteDatasourcecService } from './middleware-remote-datasourcec.service';
describe('MiddlewareRemoteDatasourcecService', () => {
let service: MiddlewareRemoteDatasourcecService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(MiddlewareRemoteDatasourcecService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -1,17 +0,0 @@
import { Injectable } from '@angular/core';
import { SessionStore } from "src/app/store/session.service"
import { MiddlewareServiceService } from "src/app/shared/API/middleware/middleware-service.service"
@Injectable({
providedIn: 'root'
})
export class MiddlewareRemoteDatasourcecService {
constructor(
private MiddlewareServiceService: MiddlewareServiceService,
) {}
refreshToken() {
const refreshToken = SessionStore.user.Authorization
return this.MiddlewareServiceService.refreshToken(refreshToken)
}
}
+4 -1
View File
@@ -414,7 +414,10 @@ const routes: Routes = [
}, },
{ path: '**', redirectTo: '/', pathMatch: 'full' }, {
path: '**',
loadChildren: ()=> import('../pages/not-found/not-found.module').then(m => m.NotFoundPageModule),
},
]; ];
@NgModule({ @NgModule({
@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { NotFoundPage } from './not-found.page';
const routes: Routes = [
{
path: '',
component: NotFoundPage
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class NotFoundPageRoutingModule {}
@@ -0,0 +1,20 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { NotFoundPageRoutingModule } from './not-found-routing.module';
import { NotFoundPage } from './not-found.page';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
NotFoundPageRoutingModule
],
declarations: [NotFoundPage]
})
export class NotFoundPageModule {}
@@ -0,0 +1,9 @@
<ion-content class="d-flex justity-center align-center">
<div class="ion-justify-content-center justify-content-center align-center d-flex height-100 width-100">
<h4>
A Reencaminhar a página
</h4>
</div>
</ion-content>
@@ -0,0 +1,24 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { NotFoundPage } from './not-found.page';
describe('NotFoundPage', () => {
let component: NotFoundPage;
let fixture: ComponentFixture<NotFoundPage>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ NotFoundPage ],
imports: [IonicModule.forRoot()]
}).compileComponents();
fixture = TestBed.createComponent(NotFoundPage);
component = fixture.componentInstance;
fixture.detectChanges();
}));
it('should create', () => {
expect(component).toBeTruthy();
});
});
+22
View File
@@ -0,0 +1,22 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { ToastService } from 'src/app/services/toast.service';
@Component({
selector: 'app-not-found',
templateUrl: './not-found.page.html',
styleUrls: ['./not-found.page.scss'],
})
export class NotFoundPage implements OnInit {
constructor(
private router: Router,
private toastService: ToastService,
) { }
ngOnInit() {
this.router.navigate(['/home/events']);
this.toastService._badRequest("Página não encontrada. Contacte o suporte técnico")
}
}
@@ -1,16 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { MiddlewareRepositoryService } from './middleware-repository.service';
describe('MiddlewareRepositoryService', () => {
let service: MiddlewareRepositoryService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(MiddlewareRepositoryService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -1,16 +0,0 @@
import { Injectable } from '@angular/core';
import { MiddlewareRemoteDatasourcecService } from "src/app/datasource/middleware/remote/middleware-remote-datasourcec.service";
@Injectable({
providedIn: 'root'
})
export class MiddlewareRepositoryService {
constructor(
private MiddlewareRemoteDatasourcecService: MiddlewareRemoteDatasourcecService,
) {}
refreshToken() {
return this.MiddlewareRemoteDatasourcecService.refreshToken()
}
}
@@ -1,16 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { TokenInterceptorService } from './token-interceptor.service';
describe('TokenInterceptorService', () => {
let service: TokenInterceptorService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(TokenInterceptorService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -1,81 +0,0 @@
import { Injectable } from "@angular/core";
import {
HttpRequest,
HttpHandler,
HttpEvent,
HttpInterceptor,
HttpErrorResponse,
HTTP_INTERCEPTORS,
} from "@angular/common/http";
import { Observable, throwError, BehaviorSubject } from "rxjs";
import { catchError, filter, take, switchMap } from "rxjs/operators";
import { SessionStore } from "src/app/store/session.service";
import { MiddlewareRepositoryService } from "src/app/repository/middleWare/middleware-repository.service"
@Injectable({
providedIn: 'root'
})
export class TokenInterceptorService {
private isRefreshing = false;
private refreshTokenSubject: BehaviorSubject<any> = new BehaviorSubject<any>(
null
);
constructor(private middlewareRepositoryService: MiddlewareRepositoryService) {
this.middlewareRepositoryService = middlewareRepositoryService
}
intercept(
request: HttpRequest<any>,
next: HttpHandler
): Observable<HttpEvent<any>> {
if (SessionStore.user.Authorization) {
request = this.addToken(request, SessionStore.user.Authorization);
}
return next.handle(request).pipe(
catchError((error) => {
if (error instanceof HttpErrorResponse && error.status === 401) {
return this.handle401Error(request, next);
} else {
return throwError(error);
}
})
) as any
}
private addToken(request: HttpRequest<any>, token: string) {
return request.clone({
setHeaders: {
Authorization: `Bearer ${token}`,
},
});
}
private handle401Error(request: HttpRequest<any>, next: HttpHandler) {
if (!this.isRefreshing) {
this.isRefreshing = true;
this.refreshTokenSubject.next(null);
return this.middlewareRepositoryService.refreshToken().pipe(
switchMap((token: any) => {
this.isRefreshing = false;
this.refreshTokenSubject.next(token['result'].accessToken);
return next.handle(this.addToken(request, token['result'].accessToken));
})
);
} else {
return this.refreshTokenSubject.pipe(
filter((token) => token != null),
take(1),
switchMap((jwt) => {
return next.handle(this.addToken(request, jwt));
})
);
}
}
}
@@ -56,7 +56,7 @@
</div> </div>
</swiper-slide> </swiper-slide>
<!--
<div class="swiper-button-next" <div class="swiper-button-next"
style=" style="
position: absolute; position: absolute;
@@ -73,7 +73,7 @@
right: 0px; right: 0px;
"> ">
<div>arrow-rights</div> <div>arrow-rights</div>
</div>s </div>s -->
</swiper-container> </swiper-container>
<div class="post-content"> <div class="post-content">
+1 -1
View File
@@ -27,7 +27,7 @@
<!-- same origin only --> <!-- same origin only -->
<add name="Cross-Origin-Embedder-Policy" value="require-corp" /> <add name="Cross-Origin-Embedder-Policy" value="require-corp" />
<!-- same origin only --> <!-- same origin only -->
<add name="Cross-Origin-Opener-Policy" value="same-origin" /> <!-- <add name="Cross-Origin-Opener-Policy" value="same-origin" /> -->
</customHeaders> </customHeaders>
</httpProtocol> </httpProtocol>