Skip to content

Commit 57c7247

Browse files
authored
Merge pull request #69 from kikkomep/feat/maintenance-mode
feat: maintenance mode
2 parents c6a08e6 + dd447c7 commit 57c7247

17 files changed

+157
-22
lines changed

k8s/lifemonitor-web/templates/configmap.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ data:
1212
{
1313
"apiBaseUrl": "https://{{ .Values.externalServerName }}/api",
1414
"appDomain": "{{ .Values.externalServerName }}",
15-
"socketBaseUrl": "https://{{ .Values.externalServerName }}"{{ if .Values.backend.clientId }},{{ end }}
16-
{{ if .Values.backend.clientId }}"clientId": "{{ .Values.backend.clientId }}"{{ end }}
15+
"socketBaseUrl": "https://{{ .Values.externalServerName }}"
16+
{{- if .Values.backend.clientId }}, "clientId": "{{ .Values.backend.clientId }}"{{ end }}
17+
{{- if .Values.maintenanceMode.enabled }}, "maintenanceMode": "true"{{ end }}
18+
{{- if .Values.maintenanceMode.message }}, "maintenanceMessage":"{{.Values.maintenanceMode.message}}"{{ end }}
1719
}

k8s/lifemonitor-web/values.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ fullnameOverride: ""
1414

1515
externalServerName: "localhost"
1616

17+
# Manage maintenance mode
18+
maintenanceMode:
19+
enabled: false
20+
# message: "The service is currently under maintenance. Please try again later."
21+
1722
# Setting for the LifeMonitor Backend API
1823
backend:
1924
apiUrl: ""

k8s/values.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ fullnameOverride: ''
1414

1515
externalServerName: 'localhost'
1616

17+
# Manage maintenance mode
18+
maintenanceMode:
19+
enabled: false
20+
# message: "The service is currently under maintenance. Please try again later."
21+
1722
# Setting for the LifeMonitor Backend API
1823
backend:
1924
apiUrl: 'https://api.lifemonitor.eu'

ngsw-config.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@
4040
"/socket.io/**",
4141
"/github/**",
4242
"/integrations/**",
43-
"/openapi.*",
44-
"/metrics"
43+
"/openapi.*"
4544
],
4645
"cacheConfig": {
4746
"strategy": "freshness",

src/app/app-routing.module.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { InputDialogService } from './utils/services/input-dialog.service';
1616
import { DashboardComponent } from './views/dashboard/dashboard.component';
1717
import { SuiteComponent } from './views/suite/suite.component';
1818
import { WorkflowComponent } from './views/workflow/workflow.component';
19+
import { MaintenanceComponent } from './pages/maintenance/maintenance.component';
1920

2021
const routes: Routes = [
2122
{
@@ -28,6 +29,11 @@ const routes: Routes = [
2829
// canActivate: [AuthGuard],
2930
// canActivateChild: [AuthGuard],
3031
children: [
32+
{
33+
path: 'maintenance',
34+
component: MaintenanceComponent,
35+
pathMatch: 'full',
36+
},
3137
{
3238
path: 'dashboard',
3339
component: DashboardComponent,
@@ -51,7 +57,7 @@ const routes: Routes = [
5157
{
5258
path: 'logout',
5359
component: LogoutComponent,
54-
},
60+
},
5561
// {
5662
// path: 'register',
5763
// component: RegisterComponent,
@@ -83,7 +89,7 @@ export class AppRoutingModule implements OnInit {
8389
private router: Router,
8490
private inputDialogService: InputDialogService,
8591
private toastr: ToastrService
86-
) {}
92+
) { }
8793

8894
ngOnInit() {
8995
this.logger.debug('Initializing app routing module');
@@ -133,7 +139,7 @@ export class AppRoutingModule implements OnInit {
133139
cancelText: 'Close',
134140
iconClass: 'fas fa-exclamation-triangle',
135141
enableCancel: false,
136-
onCancel: () => {},
142+
onCancel: () => { },
137143
});
138144
}
139145
}

src/app/app.component.ts

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { Component, OnDestroy, OnInit } from '@angular/core';
22
import { SwUpdate, UpdateAvailableEvent } from '@angular/service-worker';
33

4+
import { Router } from '@angular/router';
45
import { Observable, Subscription } from 'rxjs';
56
import { Logger, LoggerManager } from './utils/logging/index';
67
import { CacheRefreshStatus } from './utils/services/cache/cache.model';
78
import { CachedHttpClientService } from './utils/services/cache/cachedhttpclient.service';
9+
import { AppConfigService } from './utils/services/config.service';
810
import { InputDialogService } from './utils/services/input-dialog.service';
911

1012
import {
@@ -42,7 +44,9 @@ export class AppComponent implements OnInit, OnDestroy {
4244
private inputDialog: InputDialogService,
4345
private swUpdate: SwUpdate,
4446
private cachedHttpClient: CachedHttpClientService,
45-
private ccService: NgcCookieConsentService
47+
private ccService: NgcCookieConsentService,
48+
private config: AppConfigService,
49+
private router: Router
4650
) {
4751
this.refreshStatus$ = this.cachedHttpClient.refreshProgressStatus$;
4852
}
@@ -51,7 +55,20 @@ export class AppComponent implements OnInit, OnDestroy {
5155
return this.swUpdate.available;
5256
}
5357

58+
get maintenanceModeEnabled(): boolean {
59+
return this.config.maintenanceMode;
60+
}
61+
5462
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+
5572
if (this.swUpdate.isEnabled) {
5673
this.checkVersionSubscription = this.updateAvailable.subscribe(() => {
5774
this.inputDialog.show({
@@ -73,30 +90,30 @@ export class AppComponent implements OnInit, OnDestroy {
7390
}
7491

7592
// subscribe to cookieconsent observables to react to main events
76-
this.popupOpenSubscription = this.ccService.popupOpen$.subscribe(() => {});
93+
this.popupOpenSubscription = this.ccService.popupOpen$.subscribe(() => { });
7794

7895
this.popupCloseSubscription = this.ccService.popupClose$.subscribe(
79-
() => {}
96+
() => { }
8097
);
8198

8299
this.initializeSubscription = this.ccService.initializing$.subscribe(
83-
(event: NgcInitializingEvent) => {}
100+
(event: NgcInitializingEvent) => { }
84101
);
85102

86103
this.statusChangeSubscription = this.ccService.statusChange$.subscribe(
87-
(event: NgcStatusChangeEvent) => {}
104+
(event: NgcStatusChangeEvent) => { }
88105
);
89106

90107
this.revokeChoiceSubscription = this.ccService.revokeChoice$.subscribe(
91-
() => {}
108+
() => { }
92109
);
93110

94111
this.noCookieLawSubscription = this.ccService.noCookieLaw$.subscribe(
95-
(event: NgcNoCookieLawEvent) => {}
112+
(event: NgcNoCookieLawEvent) => { }
96113
);
97114
}
98115

99-
ngAfterViewInit() {}
116+
ngAfterViewInit() { }
100117

101118
ngOnDestroy() {
102119
if (this.checkVersionSubscription) {

src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import { BlankComponent } from './views/blank/blank.component';
5555
import { DashboardComponent } from './views/dashboard/dashboard.component';
5656
import { SuiteComponent } from './views/suite/suite.component';
5757
import { WorkflowComponent } from './views/workflow/workflow.component';
58+
import { MaintenanceComponent } from './pages/maintenance/maintenance.component';
5859

5960
// PrimeNG Modules
6061
// import { ChartModule } from 'primeng/chart';
@@ -156,6 +157,7 @@ export function initConfigService(
156157
LogoutComponent,
157158
ScrollComponent,
158159
BaseDataViewComponent,
160+
MaintenanceComponent,
159161
],
160162
imports: [
161163
// PrimeNg Modules

src/app/pages/main/header/header.component.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
/> -->
3636
</a>
3737

38-
<a *ngIf="!isUserLogged" [routerLink]="['/login']" class="btn btn-primary btn-lg mr-4" role="button">
38+
<a *ngIf="!isUserLogged && !maintenanceMode" [routerLink]="['/login']" class="btn btn-primary btn-lg mr-4"
39+
role="button">
3940
<i class="fas fa-sign-in-alt mr-2"></i>Sign In
4041
</a>
4142

@@ -58,4 +59,4 @@
5859
<app-user-dropdown-menu #userDropdownMenu></app-user-dropdown-menu>
5960
</ul>
6061
</nav>
61-
</nav>
62+
</nav>

src/app/pages/main/header/header.component.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { AppService } from 'src/app/utils/services/app.service';
1010

1111
import { UserDropdownMenuComponent } from './user-dropdown-menu/user-dropdown-menu.component';
1212
import { Router } from '@angular/router';
13+
import { AppConfigService } from 'src/app/utils/services/config.service';
1314

1415
@Component({
1516
selector: 'app-header',
@@ -22,14 +23,20 @@ export class HeaderComponent implements OnInit {
2223

2324
public searchForm: FormGroup;
2425

25-
constructor(private router: Router, private appService: AppService) {}
26+
constructor(private router: Router,
27+
private appService: AppService,
28+
private appConfig: AppConfigService) { }
2629

2730
ngOnInit() {
2831
this.searchForm = new FormGroup({
2932
search: new FormControl(null),
3033
});
3134
}
3235

36+
public get maintenanceMode(): boolean {
37+
return this.appConfig.maintenanceMode;
38+
}
39+
3340
public get isUserLogged(): boolean {
3441
return this.appService.isUserLogged();
3542
}

src/app/pages/main/main.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
(mainSidebarHeight)="mainSidebarHeight($event)"
1111
></app-menu-sidebar>-->
1212

13-
<div #contentWrapper class="content-wrapper" >
13+
<div #contentWrapper [ngClass]="{'content-wrapper': !maintenanceMode}">
1414
<router-outlet></router-outlet>
1515
</div>
1616

0 commit comments

Comments
 (0)