Files
cbsnexora/src/app/system/external-services/amazon-s3/amazon-s3.component.ts
T

104 lines
2.7 KiB
TypeScript

/**
* Copyright since 2025 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/** Angular Imports */
import { Component, OnInit, ViewChild, inject } from '@angular/core';
import { MatSort, MatSortHeader } from '@angular/material/sort';
import {
MatTableDataSource,
MatTable,
MatColumnDef,
MatHeaderCellDef,
MatHeaderCell,
MatCellDef,
MatCell,
MatHeaderRowDef,
MatHeaderRow,
MatRowDef,
MatRow
} from '@angular/material/table';
import { ActivatedRoute, RouterLink } from '@angular/router';
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
/**
* Amazon S3 Component.
*/
@Component({
selector: 'mifosx-amazon-s3',
templateUrl: './amazon-s3.component.html',
styleUrls: ['./amazon-s3.component.scss'],
imports: [
...STANDALONE_SHARED_IMPORTS,
FaIconComponent,
MatTable,
MatSort,
MatColumnDef,
MatHeaderCellDef,
MatHeaderCell,
MatSortHeader,
MatCellDef,
MatCell,
MatHeaderRowDef,
MatHeaderRow,
MatRowDef,
MatRow
]
})
export class AmazonS3Component implements OnInit {
private route = inject(ActivatedRoute);
/** Amazon S3 configuration data. */
amazonS3ConfigurationData: any;
/** Columns to be displayed in Amazon S3 configuration table. */
displayedColumns: string[] = [
'name',
'value'
];
/** Data source for Amazon S3 configuration table. */
dataSource: MatTableDataSource<any>;
/** Sorter for Amazon S3 configuration table. */
@ViewChild(MatSort, { static: true }) sort: MatSort;
/**
* Retrieves the Amazon S3 configuration data from `resolve`.
* @param {ActivatedRoute} route Activated Route.
*/
constructor() {
this.route.data.subscribe((data: { amazonS3Configuration: any }) => {
this.amazonS3ConfigurationData = data.amazonS3Configuration;
});
}
/**
* Sets the Amazon S3 Configuration table.
*/
ngOnInit() {
this.setAmazonS3Configuration();
}
/**
* Initializes the data source and sorter for Amazon S3 configuration table.
*/
setAmazonS3Configuration() {
this.dataSource = new MatTableDataSource(this.amazonS3ConfigurationData);
this.dataSource.sort = this.sort;
}
getConfigurationValue(configuration: any): string {
const value = configuration.value;
if (configuration.name === 's3_access_key' || configuration.name === 's3_secret_key') {
return value
? value.replace(value.substring(1, value.length - 2), value.substring(1, value.length - 2).replace(/./g, '*'))
: '';
}
return value;
}
}