|
| 1 | +/** |
| 2 | + * Copyright since 2025 Mifos Initiative |
| 3 | + * |
| 4 | + * This Source Code Form is subject to the terms of the Mozilla Public |
| 5 | + * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 6 | + * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 7 | + */ |
| 8 | + |
| 9 | +/** Angular Imports */ |
| 10 | +import { ChangeDetectionStrategy, Component, OnInit, inject } from '@angular/core'; |
| 11 | +import { |
| 12 | + MatDialogRef, |
| 13 | + MatDialogTitle, |
| 14 | + MatDialogContent, |
| 15 | + MatDialogActions, |
| 16 | + MatDialogClose |
| 17 | +} from '@angular/material/dialog'; |
| 18 | +import { MatButton } from '@angular/material/button'; |
| 19 | +import { AuthenticationService } from 'app/core/authentication/authentication.service'; |
| 20 | +import { SettingsService } from 'app/settings/settings.service'; |
| 21 | +import { VersionService } from 'app/system/version.service'; |
| 22 | +import { environment } from '../../../environments/environment'; |
| 23 | +import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module'; |
| 24 | + |
| 25 | +/** |
| 26 | + * About Dialog Component. |
| 27 | + * Displays version information accessible from the profile dropdown menu. |
| 28 | + */ |
| 29 | +@Component({ |
| 30 | + selector: 'mifosx-about-dialog', |
| 31 | + templateUrl: './about-dialog.component.html', |
| 32 | + styleUrls: ['./about-dialog.component.scss'], |
| 33 | + imports: [ |
| 34 | + ...STANDALONE_SHARED_IMPORTS, |
| 35 | + MatDialogTitle, |
| 36 | + MatDialogContent, |
| 37 | + MatDialogActions, |
| 38 | + MatDialogClose, |
| 39 | + MatButton |
| 40 | + ], |
| 41 | + changeDetection: ChangeDetectionStrategy.OnPush |
| 42 | +}) |
| 43 | +export class AboutDialogComponent implements OnInit { |
| 44 | + private dialogRef = inject<MatDialogRef<AboutDialogComponent>>(MatDialogRef); |
| 45 | + private authenticationService = inject(AuthenticationService); |
| 46 | + private settingsService = inject(SettingsService); |
| 47 | + private versionService = inject(VersionService); |
| 48 | + |
| 49 | + /** Mifos X version from environment */ |
| 50 | + mifosVersion = environment.version; |
| 51 | + /** Mifos X hash from environment */ |
| 52 | + mifosHash = environment.hash; |
| 53 | + /** Apache Fineract version */ |
| 54 | + fineractVersion = ''; |
| 55 | + /** Server URL */ |
| 56 | + server = ''; |
| 57 | + /** Tenant identifier */ |
| 58 | + tenant = ''; |
| 59 | + /** Username */ |
| 60 | + username = ''; |
| 61 | + /** Name */ |
| 62 | + name = ''; |
| 63 | + /** Render time */ |
| 64 | + renderTime = new Date(); |
| 65 | + |
| 66 | + ngOnInit(): void { |
| 67 | + this.server = this.settingsService.server; |
| 68 | + this.tenant = this.settingsService.tenantIdentifier || 'default'; |
| 69 | + this.setUserInfo(); |
| 70 | + this.fetchBackendInfo(); |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * Sets user info from authentication credentials. |
| 75 | + */ |
| 76 | + private setUserInfo(): void { |
| 77 | + const credentials = this.authenticationService.getCredentials(); |
| 78 | + if (credentials) { |
| 79 | + this.username = credentials.username || ''; |
| 80 | + this.name = credentials.staffDisplayName || credentials.username || ''; |
| 81 | + } |
| 82 | + } |
| 83 | + |
| 84 | + /** |
| 85 | + * Fetches backend version info from the server. |
| 86 | + */ |
| 87 | + private fetchBackendInfo(): void { |
| 88 | + this.versionService.getBackendInfo().subscribe({ |
| 89 | + next: (data: any) => { |
| 90 | + if (data.git && data.git.build && data.git.build.version) { |
| 91 | + const buildVersion: string = data.git.build.version.split('-'); |
| 92 | + this.fineractVersion = buildVersion[0]; |
| 93 | + } |
| 94 | + }, |
| 95 | + error: () => { |
| 96 | + this.fineractVersion = 'N/A'; |
| 97 | + } |
| 98 | + }); |
| 99 | + } |
| 100 | +} |
0 commit comments