-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21a1a6e
commit ed39a34
Showing
30 changed files
with
490 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
projects/design-angular-kit/src/lib/components/utils/error-page/error-page.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<div class="container text-center mt-5"> | ||
<h1 *ngIf="errorCode && isShowErrorCode">{{errorCode}}</h1> | ||
<h2> | ||
<ng-container *ngIf="!errorTitle && isDefaultErrorCode; else customTitle"> | ||
{{'it.utils.error-page.' + errorCode + '.title' | translate}} | ||
</ng-container> | ||
<ng-template #customTitle>{{(errorTitle || 'it.errors.generic') | translate}}</ng-template> | ||
</h2> | ||
|
||
<p class="mt-3 w-75 mx-auto"> | ||
<ng-container | ||
*ngIf="!errorDescription && isDefaultErrorCode; else customDescription"> | ||
{{'it.utils.error-page.' + errorCode + '.description' | translate}} | ||
</ng-container> | ||
<ng-template #customDescription> | ||
{{(errorDescription || 'it.errors.generic-support-message') | translate}} | ||
</ng-template> | ||
</p> | ||
|
||
<div class="mt-5" *ngIf="isShowBackButton || isShowHomeButton"> | ||
<it-back-button *ngIf="isShowBackButton"></it-back-button> | ||
<a *ngIf="isShowHomeButton" itButton="outline-primary" class="ms-3" routerLink="/" | ||
title="{{'it.utils.error-page.go-to-homepage' | translate}}"> | ||
{{'it.utils.error-page.go-to-homepage' | translate}} | ||
</a> | ||
</div> | ||
</div> |
24 changes: 24 additions & 0 deletions
24
projects/design-angular-kit/src/lib/components/utils/error-page/error-page.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ErrorPageComponent } from './error-page.component'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
|
||
describe('ErrorPageComponent', () => { | ||
let component: ErrorPageComponent; | ||
let fixture: ComponentFixture<ErrorPageComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ErrorPageComponent], imports: [TranslateModule.forRoot(), RouterTestingModule] | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(ErrorPageComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
90 changes: 90 additions & 0 deletions
90
projects/design-angular-kit/src/lib/components/utils/error-page/error-page.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { BooleanInput, isTrueBooleanInput } from '../../../utils/boolean-input'; | ||
|
||
@Component({ | ||
selector: 'it-error-page', | ||
templateUrl: './error-page.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class ErrorPageComponent { | ||
|
||
/** | ||
* The error code to show | ||
*/ | ||
@Input() errorCode?: number | 404 | 403 | 500; | ||
|
||
/** | ||
* Show/Hide error code | ||
* @default true - show | ||
*/ | ||
@Input() showErrorCode?: BooleanInput = true; | ||
|
||
/** | ||
* Custom error title | ||
* - If set it will be displayed instead of the default title. | ||
* - It is possible to use i18n keys | ||
*/ | ||
@Input() errorTitle?: string; | ||
|
||
/** | ||
* Custom error description | ||
* - If set it will be displayed instead of the default description. | ||
* - It is possible to use i18n keys | ||
*/ | ||
@Input() errorDescription?: string; | ||
|
||
/** | ||
* Show/Hide back button | ||
* @default true - show | ||
*/ | ||
@Input() showBackButton?: BooleanInput = true; | ||
|
||
/** | ||
* Show/Hide home button | ||
* @default true - show | ||
*/ | ||
@Input() showHomeButton?: BooleanInput = true; | ||
|
||
constructor( | ||
private readonly route: ActivatedRoute | ||
) { | ||
this.route.data.subscribe(data => { | ||
if (!this.errorCode && data['errorCode']) { | ||
this.errorCode = data['errorCode']; // Get errorCode from route data | ||
} | ||
if (data['showErrorCode'] !== undefined) { | ||
this.showBackButton = data['showErrorCode']; // Get showErrorCode from route data | ||
} | ||
if (!this.errorTitle && data['errorTitle']) { | ||
this.errorTitle = data['errorTitle']; // Get errorTitle from route data | ||
} | ||
if (!this.errorDescription && data['errorDescription']) { | ||
this.errorDescription = data['errorDescription']; // Get errorDescription from route data | ||
} | ||
if (data['showBackButton'] !== undefined) { | ||
this.showBackButton = data['showBackButton']; // Get showBackButton from route data | ||
} | ||
if (data['showHomeButton'] !== undefined) { | ||
this.showHomeButton = data['showHomeButton']; // Get showHomeButton from route data | ||
} | ||
}); | ||
} | ||
|
||
get isDefaultErrorCode(): boolean { | ||
return this.errorCode === 404 || this.errorCode === 403 || this.errorCode === 500; | ||
} | ||
|
||
get isShowErrorCode(): boolean { | ||
return isTrueBooleanInput(this.showErrorCode); | ||
} | ||
|
||
get isShowBackButton(): boolean { | ||
return isTrueBooleanInput(this.showBackButton); | ||
} | ||
|
||
get isShowHomeButton(): boolean { | ||
return isTrueBooleanInput(this.showHomeButton); | ||
} | ||
|
||
} |
13 changes: 0 additions & 13 deletions
13
.../design-angular-kit/src/lib/components/utils/not-found-page/not-found-page.component.html
This file was deleted.
Oops, something went wrong.
Empty file.
24 changes: 0 additions & 24 deletions
24
...sign-angular-kit/src/lib/components/utils/not-found-page/not-found-page.component.spec.ts
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
...ts/design-angular-kit/src/lib/components/utils/not-found-page/not-found-page.component.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/app/error-page/error-page-component-example/error-page-component-example.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<h3>Componente</h3> | ||
<p>Puoi utilizzare la pagina d'errore come un classico componente</p> | ||
|
||
<div class="bd-example"> | ||
|
||
<div class="row"> | ||
<div class="col-6"> | ||
<h4>404 - Not Found</h4> | ||
<hr> | ||
<it-error-page [errorCode]="404"></it-error-page> | ||
</div> | ||
|
||
<div class="col-6"> | ||
<h4>403 - Forbidden</h4> | ||
<hr> | ||
<it-error-page [errorCode]="403"></it-error-page> | ||
</div> | ||
</div> | ||
|
||
<div class="row mt-5"> | ||
<div class="col-6"> | ||
<h4>500 - Internal Server Error</h4> | ||
<hr> | ||
<it-error-page [errorCode]="500"></it-error-page> | ||
</div> | ||
|
||
<div class="col-6"> | ||
<h4>Personalizzato</h4> | ||
<hr> | ||
<it-error-page showBackButton="true" | ||
showHomeButton="false" | ||
[errorCode]="503" | ||
showErrorCode="true" | ||
errorTitle="Servizio non disponibile" | ||
errorDescription="Mi dispiace, momentaneamente questa risorsa non è disponibile"></it-error-page> | ||
</div> | ||
</div> | ||
|
||
</div> |
23 changes: 23 additions & 0 deletions
23
...pp/error-page/error-page-component-example/error-page-component-example.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ErrorPageComponentExampleComponent } from './error-page-component-example.component'; | ||
|
||
describe('ErrorPageComponentExampleComponent', () => { | ||
let component: ErrorPageComponentExampleComponent; | ||
let fixture: ComponentFixture<ErrorPageComponentExampleComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ ErrorPageComponentExampleComponent ] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(ErrorPageComponentExampleComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
9 changes: 9 additions & 0 deletions
9
src/app/error-page/error-page-component-example/error-page-component-example.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'it-error-page-component-example', | ||
templateUrl: './error-page-component-example.component.html' | ||
}) | ||
export class ErrorPageComponentExampleComponent { | ||
|
||
} |
Oops, something went wrong.
ed39a34
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
design-angular-kit – ./
design-angular-kit.vercel.app
design-angular-kit-git-main-dip-trasformazione-digitale.vercel.app
design-angular-kit-dip-trasformazione-digitale.vercel.app