Added configurable warning message

This commit is contained in:
Dániel Gyenizse
2023-10-30 16:50:49 +01:00
committed by Adam Saghy
parent cee57c525e
commit 53bbe13603
9 changed files with 65 additions and 2 deletions
@@ -39,6 +39,7 @@ export class AuthenticationService {
/** User credentials. */ /** User credentials. */
private credentials: Credentials; private credentials: Credentials;
private dialogShown = false;
/** Key to store credentials in storage. */ /** Key to store credentials in storage. */
private credentialsStorageKey = 'mifosXCredentials'; private credentialsStorageKey = 'mifosXCredentials';
/** Key to store oauth token details in storage. */ /** Key to store oauth token details in storage. */
@@ -202,6 +203,7 @@ export class AuthenticationService {
} }
this.authenticationInterceptor.removeAuthorization(); this.authenticationInterceptor.removeAuthorization();
this.setCredentials(); this.setCredentials();
this.resetDialog();
return of(true); return of(true);
} }
@@ -266,6 +268,18 @@ export class AuthenticationService {
return this.http.get('/twofactor'); return this.http.get('/twofactor');
} }
showDialog() {
this.dialogShown = true;
}
resetDialog() {
this.dialogShown = false;
}
hasDialogBeenShown() {
return this.dialogShown;
}
/** /**
* Requests OTP to be sent via the given delivery method. * Requests OTP to be sent via the given delivery method.
* @param {any} deliveryMethod Delivery method for the OTP. * @param {any} deliveryMethod Delivery method for the OTP.
+6 -1
View File
@@ -10,6 +10,7 @@ import { startWith, map } from 'rxjs/operators';
/** Custom Imports. */ /** Custom Imports. */
import { activities } from './activities'; import { activities } from './activities';
import { WarningDialogComponent } from './warning-dialog/warning-dialog.component';
/** Custom Services */ /** Custom Services */
import { AuthenticationService } from '../core/authentication/authentication.service'; import { AuthenticationService } from '../core/authentication/authentication.service';
@@ -62,7 +63,7 @@ export class HomeComponent implements OnInit, AfterViewInit {
private router: Router, private router: Router,
private dialog: MatDialog, private dialog: MatDialog,
private configurationWizardService: ConfigurationWizardService, private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService) { } private popoverService: PopoverService,) { }
/** /**
* Sets the username of the authenticated user. * Sets the username of the authenticated user.
@@ -72,6 +73,10 @@ export class HomeComponent implements OnInit, AfterViewInit {
const credentials = this.authenticationService.getCredentials(); const credentials = this.authenticationService.getCredentials();
this.username = credentials.username; this.username = credentials.username;
this.setFilteredActivities(); this.setFilteredActivities();
if (!this.authenticationService.hasDialogBeenShown()) {
this.dialog.open(WarningDialogComponent);
this.authenticationService.showDialog();
}
} }
/** /**
+5 -1
View File
@@ -1,5 +1,6 @@
/** Angular Imports */ /** Angular Imports */
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { MatDialogModule } from '@angular/material/dialog';
/** Custom Modules */ /** Custom Modules */
import { SharedModule } from '../shared/shared.module'; import { SharedModule } from '../shared/shared.module';
@@ -13,6 +14,7 @@ import { AmountCollectedPieComponent } from './dashboard/amount-collected-pie/am
import { AmountDisbursedPieComponent } from './dashboard/amount-disbursed-pie/amount-disbursed-pie.component'; import { AmountDisbursedPieComponent } from './dashboard/amount-disbursed-pie/amount-disbursed-pie.component';
import { ClientTrendsBarComponent } from './dashboard/client-trends-bar/client-trends-bar.component'; import { ClientTrendsBarComponent } from './dashboard/client-trends-bar/client-trends-bar.component';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { WarningDialogComponent } from './warning-dialog/warning-dialog.component'
/** /**
* Home Component * Home Component
@@ -21,6 +23,7 @@ import { TranslateModule } from '@ngx-translate/core';
*/ */
@NgModule({ @NgModule({
imports: [ imports: [
MatDialogModule,
SharedModule, SharedModule,
PipesModule, PipesModule,
HomeRoutingModule, HomeRoutingModule,
@@ -31,7 +34,8 @@ import { TranslateModule } from '@ngx-translate/core';
DashboardComponent, DashboardComponent,
AmountCollectedPieComponent, AmountCollectedPieComponent,
AmountDisbursedPieComponent, AmountDisbursedPieComponent,
ClientTrendsBarComponent ClientTrendsBarComponent,
WarningDialogComponent
], ],
providers: [ ] providers: [ ]
}) })
@@ -0,0 +1,5 @@
<h1 mat-dialog-title>{{ title }}</h1>
<mat-dialog-content>{{ content }}</mat-dialog-content>
<mat-dialog-actions>
<button mat-raised-button color="primary" mat-dialog-close>{{ buttonText }}</button>
</mat-dialog-actions>
@@ -0,0 +1,25 @@
import { Component, OnInit } from '@angular/core';
import { MatDialogRef } from '@angular/material/dialog';
import { environment } from '../../../environments/environment';
@Component({
selector: 'mifos-warning-dialog',
templateUrl: './warning-dialog.component.html',
styleUrls: ['./warning-dialog.component.scss']
})
export class WarningDialogComponent implements OnInit {
title: string;
content: string;
buttonText: string;
constructor(public dialogRef: MatDialogRef<WarningDialogComponent>) {
this.title = environment.warningDialog.title;
this.content = environment.warningDialog.content;
this.buttonText = environment.warningDialog.buttonText;
}
ngOnInit() {
}
}
+5
View File
@@ -21,6 +21,11 @@ export const environment = {
enabled: false, // For connecting to Mifos X using OAuth2 Authentication change the value to true enabled: false, // For connecting to Mifos X using OAuth2 Authentication change the value to true
serverUrl: '' serverUrl: ''
}, },
warningDialog: {
title: 'Warning',
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut id efficitur tortor. Pellentesque vel augue dolor. Quisque bibendum, lacus quis iaculis interdum, mi quam hendrerit tortor, sed ornare erat mi quis sapien. Maecenas maximus placerat arcu, a faucibus metus venenatis a. Maecenas at nibh in enim posuere ullamcorper.',
buttonText: 'Close'
},
defaultLanguage: window['env']['defaultLanguage'] || 'en-US', defaultLanguage: window['env']['defaultLanguage'] || 'en-US',
supportedLanguages: window['env']['supportedLanguages'] || 'cs-CS,de-DE,en-US,es-MX,fr-FR,it-IT,ko-KO,lt-LT,lv-LV,ne-NE,pt-PT,sw-SW', supportedLanguages: window['env']['supportedLanguages'] || 'cs-CS,de-DE,en-US,es-MX,fr-FR,it-IT,ko-KO,lt-LT,lv-LV,ne-NE,pt-PT,sw-SW',
preloadClients: window['env']['preloadClients'] || true, preloadClients: window['env']['preloadClients'] || true,
+5
View File
@@ -26,6 +26,11 @@ export const environment = {
enabled: false, // For connecting to Mifos X using OAuth2 Authentication change the value to true enabled: false, // For connecting to Mifos X using OAuth2 Authentication change the value to true
serverUrl: '' serverUrl: ''
}, },
warningDialog: {
title: 'Warning',
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut id efficitur tortor. Pellentesque vel augue dolor. Quisque bibendum, lacus quis iaculis interdum, mi quam hendrerit tortor, sed ornare erat mi quis sapien. Maecenas maximus placerat arcu, a faucibus metus venenatis a. Maecenas at nibh in enim posuere ullamcorper.',
buttonText: 'Close'
},
defaultLanguage: window['env']['defaultLanguage'] || 'en-US', defaultLanguage: window['env']['defaultLanguage'] || 'en-US',
supportedLanguages: window['env']['supportedLanguages'] || 'cs-CS,de-DE,en-US,es-MX,fr-FR,it-IT,ko-KO,lt-LT,lv-LV,ne-NE,pt-PT,sw-SW', supportedLanguages: window['env']['supportedLanguages'] || 'cs-CS,de-DE,en-US,es-MX,fr-FR,it-IT,ko-KO,lt-LT,lv-LV,ne-NE,pt-PT,sw-SW',
preloadClients: window['env']['preloadClients'] || true, preloadClients: window['env']['preloadClients'] || true,