Skip to content

Commit fa3cdf7

Browse files
dizconnixaa
authored andcommitted
feat(notfound): add NotFound page (#1672)
1 parent 0ba99f2 commit fa3cdf7

File tree

9 files changed

+120
-0
lines changed

9 files changed

+120
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { NgModule } from '@angular/core';
2+
import { Routes, RouterModule } from '@angular/router';
3+
4+
import { MiscellaneousComponent } from './miscellaneous.component';
5+
import { NotFoundComponent } from './not-found/not-found.component';
6+
7+
const routes: Routes = [{
8+
path: '',
9+
component: MiscellaneousComponent,
10+
children: [{
11+
path: '404',
12+
component: NotFoundComponent,
13+
}],
14+
}];
15+
16+
@NgModule({
17+
imports: [RouterModule.forChild(routes)],
18+
exports: [RouterModule],
19+
})
20+
export class MiscellaneousRoutingModule { }
21+
22+
export const routedComponents = [
23+
MiscellaneousComponent,
24+
NotFoundComponent,
25+
];
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: 'ngx-miscellaneous',
5+
template: `
6+
<router-outlet></router-outlet>
7+
`,
8+
})
9+
export class MiscellaneousComponent {
10+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { NgModule } from '@angular/core';
2+
import { ThemeModule } from '../../@theme/theme.module';
3+
import { MiscellaneousRoutingModule, routedComponents } from './miscellaneous-routing.module';
4+
5+
@NgModule({
6+
imports: [
7+
ThemeModule,
8+
MiscellaneousRoutingModule,
9+
],
10+
declarations: [
11+
...routedComponents,
12+
],
13+
})
14+
export class MiscellaneousModule { }
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<div class="row">
2+
<div class="col-md-12">
3+
<nb-card>
4+
<nb-card-body>
5+
<div class="flex-centered col-xl-4 col-lg-6 col-md-8 col-sm-12">
6+
<h2 class="title">404 Page Not Found</h2>
7+
<small class="sub-title">The page you were looking for doesn't exist</small>
8+
<button (click)="goToHome()" type="button" class="btn btn-block btn-hero-primary">
9+
Take me home
10+
</button>
11+
</div>
12+
</nb-card-body>
13+
</nb-card>
14+
</div>
15+
</div>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.flex-centered {
2+
margin: auto;
3+
}
4+
nb-card-body {
5+
display: flex;
6+
}
7+
8+
.title {
9+
text-align: center;
10+
}
11+
12+
.sub-title {
13+
text-align: center;
14+
display: block;
15+
margin-bottom: 3rem;
16+
}
17+
18+
.btn {
19+
margin-bottom: 2rem;
20+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { NbMenuService } from '@nebular/theme';
2+
import { Component } from '@angular/core';
3+
4+
@Component({
5+
selector: 'ngx-not-found',
6+
styleUrls: ['./not-found.component.scss'],
7+
templateUrl: './not-found.component.html',
8+
})
9+
export class NotFoundComponent {
10+
11+
constructor(private menuService: NbMenuService) {
12+
}
13+
14+
goToHome() {
15+
this.menuService.navigateHome();
16+
}
17+
}

src/app/pages/pages-menu.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,16 @@ export const MENU_ITEMS: NbMenuItem[] = [
141141
},
142142
],
143143
},
144+
{
145+
title: 'Miscellaneous',
146+
icon: 'nb-shuffle',
147+
children: [
148+
{
149+
title: '404',
150+
link: '/pages/miscellaneous/404',
151+
},
152+
],
153+
},
144154
{
145155
title: 'Auth',
146156
icon: 'nb-locked',

src/app/pages/pages-routing.module.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { NgModule } from '@angular/core';
33

44
import { PagesComponent } from './pages.component';
55
import { DashboardComponent } from './dashboard/dashboard.component';
6+
import { NotFoundComponent } from './miscellaneous/not-found/not-found.component';
67

78
const routes: Routes = [{
89
path: '',
@@ -31,10 +32,16 @@ const routes: Routes = [{
3132
}, {
3233
path: 'tables',
3334
loadChildren: './tables/tables.module#TablesModule',
35+
}, {
36+
path: 'miscellaneous',
37+
loadChildren: './miscellaneous/miscellaneous.module#MiscellaneousModule',
3438
}, {
3539
path: '',
3640
redirectTo: 'dashboard',
3741
pathMatch: 'full',
42+
}, {
43+
path: '**',
44+
component: NotFoundComponent,
3845
}],
3946
}];
4047

src/app/pages/pages.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { PagesComponent } from './pages.component';
44
import { DashboardModule } from './dashboard/dashboard.module';
55
import { PagesRoutingModule } from './pages-routing.module';
66
import { ThemeModule } from '../@theme/theme.module';
7+
import { MiscellaneousModule } from './miscellaneous/miscellaneous.module';
78

89
const PAGES_COMPONENTS = [
910
PagesComponent,
@@ -14,6 +15,7 @@ const PAGES_COMPONENTS = [
1415
PagesRoutingModule,
1516
ThemeModule,
1617
DashboardModule,
18+
MiscellaneousModule,
1719
],
1820
declarations: [
1921
...PAGES_COMPONENTS,

0 commit comments

Comments
 (0)