Add database connection check
This commit is contained in:
parent
94ee509b43
commit
bfb9f9b582
2 changed files with 19 additions and 1 deletions
|
@ -93,7 +93,18 @@ import { FilterPipeModule } from 'ngx-filter-pipe';
|
||||||
bootstrap: [ AppComponent ]
|
bootstrap: [ AppComponent ]
|
||||||
})
|
})
|
||||||
export class AppModule {
|
export class AppModule {
|
||||||
constructor () {
|
constructor (
|
||||||
|
private api: ApiService,
|
||||||
|
) {
|
||||||
|
this.api.checkDatabaseConnection().subscribe(
|
||||||
|
result => {
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
document.location = '#/500';
|
||||||
|
throw new Error('Server connection fail');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
if (environment.enableAnalytics) {
|
if (environment.enableAnalytics) {
|
||||||
(<any>window).ga('create', environment.analyticsKey, 'auto');
|
(<any>window).ga('create', environment.analyticsKey, 'auto');
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,13 @@ export class ApiService {
|
||||||
localStorage.removeItem('sessionKey');
|
localStorage.removeItem('sessionKey');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public checkDatabaseConnection() {
|
||||||
|
return this.http.post<any>(
|
||||||
|
this.apiUrl,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public register(data) {
|
public register(data) {
|
||||||
return this.http.post<any>(
|
return this.http.post<any>(
|
||||||
this.apiUrl + '/register',
|
this.apiUrl + '/register',
|
||||||
|
|
Reference in a new issue