Skip to content
Snippets Groups Projects
Commit f6ca6e61 authored by Art Lowel's avatar Art Lowel
Browse files

Merge branch 'master' into switch-to-ngrx-platform

parents b66a70b5 4590575e
Branches
Tags
No related merge requests found
import { Component } from '@angular/core';
import { ServerResponseService } from '../shared/server-response.service';
import { Component, ChangeDetectionStrategy } from '@angular/core';
@Component({
selector: 'ds-pagenotfound',
styleUrls: ['./pagenotfound.component.scss'],
templateUrl: './pagenotfound.component.html'
templateUrl: './pagenotfound.component.html',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class PageNotFoundComponent {
data: any = {};
constructor(responseService: ServerResponseService) {
responseService.setNotFound();
}
}
import { RESPONSE } from '@nguniversal/express-engine/tokens';
import { Inject, Injectable, Optional } from '@angular/core';
import { Response } from 'express';
@Injectable()
export class ServerResponseService {
private response: Response;
constructor(@Optional() @Inject(RESPONSE) response: any) {
this.response = response;
}
setStatus(code: number, message?: string): this {
if (this.response) {
this.response.statusCode = code;
if (message) {
this.response.statusMessage = message;
}
}
return this;
}
setNotFound(message = 'Not found'): this {
return this.setStatus(404, message)
}
}
......@@ -24,6 +24,7 @@ import { ItemListElementComponent } from '../object-list/item-list-element/item-
import { CommunityListElementComponent } from '../object-list/community-list-element/community-list-element.component';
import { CollectionListElementComponent } from '../object-list/collection-list-element/collection-list-element.component';
import { TruncatePipe } from './utils/truncate.pipe';
import { ServerResponseService } from './server-response.service';
const MODULES = [
// Do NOT include UniversalModule, HttpModule, or JsonpModule here
......@@ -61,7 +62,8 @@ const COMPONENTS = [
const PROVIDERS = [
ApiService,
HostWindowService,
{ provide: NativeWindowService, useFactory: NativeWindowFactory }
{ provide: NativeWindowService, useFactory: NativeWindowFactory },
ServerResponseService
];
@NgModule({
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment