Fineract backend settings with environment variables

This commit is contained in:
Jose Alberto Hernandez
2022-07-13 16:40:23 +02:00
committed by Arnold Gálovics
parent 1b72136411
commit 14ceb4f3fd
44 changed files with 815 additions and 291 deletions
+4 -2
View File
@@ -1,5 +1,7 @@
<div fxLayout="column" id="footer" class="m-b-20">
<mat-divider fxFlexAlign="center" class="divider"></mat-divider>
<p fxFlexAlign="center" class="footer-content">Version {{ version }}</p>
<p fxFlexAlign="center" class="footer-content">Mifos X is up to date</p>
<p fxFlexAlign="center" class="footer-content">Version <b>{{ version }}</b> - <b>{{ hash }}</b></p>
<p fxFlexAlign="center" class="footer-content" *ngIf="isBusinessDateDefined">Current Business Date: <b>{{ businessDate | date: 'EEEE, MMMM dd, y' }}</b></p>
<mat-divider fxFlexAlign="center" class="divider"></mat-divider>
<p fxFlexAlign="center" class="footer-content">Mifos X by Mifos</p>
</div>
+68 -3
View File
@@ -1,8 +1,14 @@
/** Angular Imports */
import { Component, OnInit } from '@angular/core';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Alert } from 'app/core/alert/alert.model';
import { AlertService } from 'app/core/alert/alert.service';
import { AuthenticationService } from 'app/core/authentication/authentication.service';
import { SettingsService } from 'app/settings/settings.service';
import { SystemService } from 'app/system/system.service';
/** Environment Configuration */
import { environment } from 'environments/environment';
import { Subscription } from 'rxjs';
/**
* Footer component.
@@ -12,14 +18,73 @@ import { environment } from 'environments/environment';
templateUrl: './footer.component.html',
styleUrls: ['./footer.component.scss']
})
export class FooterComponent implements OnInit {
export class FooterComponent implements OnInit, OnDestroy {
/** Mifos X version. */
version: string = environment.version;
/** Mifos X hash */
hash: string = environment.hash;
/** Business Date */
businessDate: Date = null;
constructor() { }
isBusinessDateEnabled = false;
isBusinessDateDefined = false;
/** Subscription to alerts. */
alert$: Subscription;
timer: any;
constructor(private systemService: SystemService,
private authenticationService: AuthenticationService,
private alertService: AlertService) { }
ngOnInit() {
this.alert$ = this.alertService.alertEvent.subscribe((alertEvent: Alert) => {
const alertType = alertEvent.type;
if (alertType === SettingsService.businessDateType + ' Set Config') {
this.isBusinessDateEnabled = (alertEvent.message === 'enabled') ? true : false;
this.isBusinessDateDefined = false;
if (this.isBusinessDateEnabled) {
this.setBusinessDate();
}
} else if (alertType === SettingsService.businessDateType + ' Set') {
if (this.isBusinessDateEnabled) {
this.setBusinessDate();
}
} else if (alertType === 'Authentication Start') {
this.timer = setTimeout(() => { this.getConfigurations(); }, 60000);
}
});
this.getConfigurations();
}
ngOnDestroy() {
clearTimeout(this.timer);
}
/**
* Get the Configuration for Business Date
*/
getConfigurations(): void {
if (this.authenticationService.isAuthenticated()) {
this.systemService.getConfigurationByName(SettingsService.businessDateConfigName)
.subscribe((configurationData: any) => {
this.isBusinessDateEnabled = configurationData.enabled;
if (this.isBusinessDateEnabled) {
this.setBusinessDate();
this.timer = setTimeout(() => { this.getConfigurations(); }, 60000);
}
});
}
}
/**
* Get the Business Date data
*/
setBusinessDate(): void {
this.systemService.getBusinessDate(SettingsService.businessDateType)
.subscribe((data: any) => {
this.businessDate = new Date(data.date);
this.isBusinessDateDefined = true;
});
}
}
@@ -1,5 +1,5 @@
<mat-form-field id="language-selector">
<mat-label>Language</mat-label>
<mat-label>{{ 'Language' | translate }}</mat-label>
<mat-select [formControl]="languageSelector" (selectionChange)="setLanguage()" class="languageselector">
<mat-option *ngFor="let language of languages" [value]="language">
{{ language }}
@@ -1,19 +1,19 @@
<mat-form-field id="server-selector">
<mat-label>Server</mat-label>
<mat-select [formControl]="serverSelector">
<mat-form-field id="server-selector" *ngIf="existMoreThanOneServer">
<mat-label>{{ 'Server' | translate }}</mat-label>
<mat-select [formControl]="serverSelector" (selectionChange)="setServer()">
<div class="sticky">
<form [formGroup]="form" (ngSubmit)="setNewServer()">
<form [formGroup]="form" (ngSubmit)="addNewServer()">
<div class="actions">
<mat-form-field class="ml" fxFlexAlign="start">
<span matPrefix><mat-icon>language</mat-icon></span>
<mat-label>Add new server</mat-label>
<mat-label>{{ 'Add new server' | translate }}</mat-label>
<input matInput type="text" autocomplete="off" formControlName="url">
<mat-error *ngIf="form.controls.url.hasError('required')">
Url <strong>is required</strong>
Url <strong>{{'is required' | translate }}</strong>
</mat-error>
</mat-form-field>
<button type="submit" [disabled]="form.invalid" class="ml" mat-raised-button color="primary">Add</button>
<button type="submit" [disabled]="form.invalid" class="ml" mat-raised-button color="primary">{{'Add' | translate }}</button>
</div>
</form>
</div>
@@ -21,4 +21,4 @@
{{ server }}
</mat-option>
</mat-select>
</mat-form-field>
</mat-form-field>
@@ -26,34 +26,42 @@ export class ServerSelectorComponent implements OnInit {
/** Server Setting */
serverSelector = new FormControl('');
/** Server list to show */
existMoreThanOneServer = false;
/**
* @param {SettingsService} settingsService Settings Service
*/
constructor(private settingsService: SettingsService, public dialog: MatDialog, private formBuilder: FormBuilder) { }
constructor(private settingsService: SettingsService,
public dialog: MatDialog,
private formBuilder: FormBuilder) { }
ngOnInit(): void {
this.servers = this.settingsService.servers;
this.serverSelector.patchValue(this.settingsService.server);
this.buildDependencies();
this.form = this.formBuilder.group({
'url': ['', [Validators.required]],
});
this.existMoreThanOneServer = (this.servers && this.servers.length > 1);
if (!this.existMoreThanOneServer) {
this.settingsService.setServer(this.servers[0]);
} else {
this.existMoreThanOneServer = true;
this.serverSelector.patchValue(this.settingsService.server);
this.form = this.formBuilder.group({
'url': ['', [Validators.required]],
});
}
}
/**
* Subscribe to value changes.
* Set backend server from the list
*/
buildDependencies() {
this.serverSelector.valueChanges.subscribe((url: string) => {
this.settingsService.setServer(url);
window.location.reload(); // refreshes the environment.ts.
});
setServer(): void {
this.settingsService.setServer(this.serverSelector.value);
}
/**
* Set new server.
* Add new server to the list.
*/
setNewServer() {
addNewServer(): void {
let servers;
this.settingsService.setServer(this.form.value.url);
servers = this.settingsService.servers;
+3 -1
View File
@@ -25,6 +25,7 @@ import { ServerSelectorComponent } from './server-selector/server-selector.compo
/** Custom Modules */
import { IconsModule } from './icons.module';
import { MaterialModule } from './material.module';
import { TranslateModule } from '@ngx-translate/core';
/**
* Shared Module
@@ -36,7 +37,8 @@ import { MaterialModule } from './material.module';
CommonModule,
IconsModule,
MaterialModule,
ReactiveFormsModule
ReactiveFormsModule,
TranslateModule.forRoot(),
],
declarations: [
FormfieldComponent,