1
1
import { Component , OnDestroy , OnInit } from '@angular/core' ;
2
2
import { SwUpdate , UpdateAvailableEvent } from '@angular/service-worker' ;
3
3
4
+ import { Router } from '@angular/router' ;
4
5
import { Observable , Subscription } from 'rxjs' ;
5
6
import { Logger , LoggerManager } from './utils/logging/index' ;
6
7
import { CacheRefreshStatus } from './utils/services/cache/cache.model' ;
7
8
import { CachedHttpClientService } from './utils/services/cache/cachedhttpclient.service' ;
9
+ import { AppConfigService } from './utils/services/config.service' ;
8
10
import { InputDialogService } from './utils/services/input-dialog.service' ;
9
11
10
12
import {
@@ -42,7 +44,9 @@ export class AppComponent implements OnInit, OnDestroy {
42
44
private inputDialog : InputDialogService ,
43
45
private swUpdate : SwUpdate ,
44
46
private cachedHttpClient : CachedHttpClientService ,
45
- private ccService : NgcCookieConsentService
47
+ private ccService : NgcCookieConsentService ,
48
+ private config : AppConfigService ,
49
+ private router : Router
46
50
) {
47
51
this . refreshStatus$ = this . cachedHttpClient . refreshProgressStatus$ ;
48
52
}
@@ -51,7 +55,20 @@ export class AppComponent implements OnInit, OnDestroy {
51
55
return this . swUpdate . available ;
52
56
}
53
57
58
+ get maintenanceModeEnabled ( ) : boolean {
59
+ return this . config . maintenanceMode ;
60
+ }
61
+
54
62
ngOnInit ( ) {
63
+
64
+ if ( this . maintenanceModeEnabled ) {
65
+ console . log ( "Current route: " + this . router . url ) ;
66
+ if ( this . router . url !== '/maintenance'
67
+ && ! this . router . url . startsWith ( '/static' ) ) {
68
+ return this . router . navigateByUrl ( '/maintenance' ) ;
69
+ }
70
+ }
71
+
55
72
if ( this . swUpdate . isEnabled ) {
56
73
this . checkVersionSubscription = this . updateAvailable . subscribe ( ( ) => {
57
74
this . inputDialog . show ( {
@@ -73,30 +90,30 @@ export class AppComponent implements OnInit, OnDestroy {
73
90
}
74
91
75
92
// subscribe to cookieconsent observables to react to main events
76
- this . popupOpenSubscription = this . ccService . popupOpen$ . subscribe ( ( ) => { } ) ;
93
+ this . popupOpenSubscription = this . ccService . popupOpen$ . subscribe ( ( ) => { } ) ;
77
94
78
95
this . popupCloseSubscription = this . ccService . popupClose$ . subscribe (
79
- ( ) => { }
96
+ ( ) => { }
80
97
) ;
81
98
82
99
this . initializeSubscription = this . ccService . initializing$ . subscribe (
83
- ( event : NgcInitializingEvent ) => { }
100
+ ( event : NgcInitializingEvent ) => { }
84
101
) ;
85
102
86
103
this . statusChangeSubscription = this . ccService . statusChange$ . subscribe (
87
- ( event : NgcStatusChangeEvent ) => { }
104
+ ( event : NgcStatusChangeEvent ) => { }
88
105
) ;
89
106
90
107
this . revokeChoiceSubscription = this . ccService . revokeChoice$ . subscribe (
91
- ( ) => { }
108
+ ( ) => { }
92
109
) ;
93
110
94
111
this . noCookieLawSubscription = this . ccService . noCookieLaw$ . subscribe (
95
- ( event : NgcNoCookieLawEvent ) => { }
112
+ ( event : NgcNoCookieLawEvent ) => { }
96
113
) ;
97
114
}
98
115
99
- ngAfterViewInit ( ) { }
116
+ ngAfterViewInit ( ) { }
100
117
101
118
ngOnDestroy ( ) {
102
119
if ( this . checkVersionSubscription ) {
0 commit comments