Skip to content

Commit

Permalink
feat: custom 404 page (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnurosePrakash authored Aug 11, 2023
1 parent c358d6c commit 2d8d88e
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 17 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ the detailed section referring to by linking pull requests or issues.

#### Added

- Added custom 404 pages to connector and broker ui

#### Changed

#### Removed
Expand Down
35 changes: 20 additions & 15 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {NgModule} from '@angular/core';
import {
LoadChildrenCallback,
ROUTES,
RouterModule,
Routes,
} from '@angular/router';
import {APP_CONFIG, AppConfig} from './core/config/app-config';
import {PageNotFoundComponent} from "./component-library/error-404-component/page-not-found.component";


@NgModule({
imports: [RouterModule.forRoot([], {paramsInheritanceStrategy: 'always'})],
Expand All @@ -15,27 +16,31 @@ import {APP_CONFIG, AppConfig} from './core/config/app-config';
provide: ROUTES,
deps: [APP_CONFIG],
multi: true,
useFactory: (config: AppConfig): Routes => {
const loadChildRoutes = (
loadChildren: LoadChildrenCallback,
): Routes => [{path: '', loadChildren}];

useFactory: (config: AppConfig): Routes => {
const routes: Routes = [];
switch (config.routes) {
case 'broker-ui':
return loadChildRoutes(() =>
import('./routes/broker-ui/broker-ui.module').then(
(m) => m.BrokerUiModule,
),
);
routes.push({
path: '', loadChildren: () =>
import('./routes/broker-ui/broker-ui.module').then(
(m) => m.BrokerUiModule,
)
});
break;
case 'connector-ui':
return loadChildRoutes(() =>
import('./routes/connector-ui/connector-ui.module').then(
(m) => m.ConnectorUiModule,
),
);
routes.push({
path: '', loadChildren: () =>
import('./routes/connector-ui/connector-ui.module').then(
(m) => m.ConnectorUiModule,
)
});
break;
default:
throw new Error(`Unhandled PageSet: ${config.routes}`);
}
routes.push({path: '**', component: PageNotFoundComponent})
return routes;
},
},
],
Expand Down
3 changes: 2 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {NgxsModule} from '@ngxs/store';
import {NgChartsModule} from 'ng2-charts';
import {AppRoutingModule} from './app-routing.module';
import {AppComponent} from './app.component';
import {PageNotFoundComponent} from './component-library/error-404-component/page-not-found.component';
import {provideAppConfig} from './core/config/app-config-initializer';
import {provideAppConfigProperty} from './core/config/app-config-injection-utils';
import {ApiKeyInterceptor} from './core/services/api/api-key.interceptor';
Expand Down Expand Up @@ -54,7 +55,7 @@ import {
// Routing
AppRoutingModule,
],
declarations: [AppComponent],
declarations: [AppComponent, PageNotFoundComponent],
providers: [
provideAppConfig(),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export class AssetPropertyGridGroupBuilder {
labelTitle: AssetProperties.language,
...this.propertyGridUtils.guessValue(asset.language?.label),
},

{
icon: 'apartment',
label: 'Publisher',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="flex flex-col items-center max-w-sm mx-auto text-center">
<h1 class="mt-3 text-2xl font-semibold text-gray-800 md:text-3xl">
Page not found
</h1>
<p class="mt-4 text-gray-500">The page you are looking for doesn't exist.</p>
<div class="flex items-center w-full mt-6 gap-x-3 shrink-0 sm:w-auto">
<a routerLink="/" mat-raised-button color="primary"> Go Back </a>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {Component, HostBinding} from '@angular/core';

@Component({
selector: 'app-page-not-found',
templateUrl: './page-not-found.component.html',
})
export class PageNotFoundComponent {
@HostBinding('class.container')
@HostBinding('class.flex')
@HostBinding('class.items-center')
@HostBinding('class.min-h-screen')
@HostBinding('class.px-6')
@HostBinding('class.py-12')
@HostBinding('class.box-border')
cls = true;
}

0 comments on commit 2d8d88e

Please sign in to comment.