dnet-applications/frontends/dnet-is-application/src/app/info/info.component.ts

46 lines
1.4 KiB
TypeScript
Raw Normal View History

2023-01-19 14:47:52 +01:00
import { Component } from '@angular/core';
2023-02-01 11:51:23 +01:00
import { ISService } from '../common/is.service';
2023-01-19 14:47:52 +01:00
import { MatTableDataSource } from '@angular/material/table';
2023-02-01 11:51:23 +01:00
import { Module } from '../common/is.model';
2023-01-19 14:47:52 +01:00
export interface KeyValueDatasource {
name: string;
2023-01-20 11:39:34 +01:00
datasource: MatTableDataSource<any>;
2023-01-19 14:47:52 +01:00
}
@Component({
selector: 'app-info',
templateUrl: './info.component.html',
styleUrls: ['./info.component.css']
})
export class InfoComponent {
kvDatasources:KeyValueDatasource[] = [];
2023-01-20 16:57:03 +01:00
moduleDatasource:MatTableDataSource<Module> = new MatTableDataSource<Module>([]);
2023-01-19 14:47:52 +01:00
displayedKVColumns: string[] = ['k', 'v'];
displayedModuleColumns: string[] = ['group', 'name', 'versions', 'files'];
2023-01-27 08:58:33 +01:00
constructor(public service:ISService) {
this.service.loadInfo((data:any[]) => {
2023-01-19 14:47:52 +01:00
data.forEach(section => {
if (section['name'] == 'Modules') {
this.moduleDatasource.data = section['data'];
} else {
this.kvDatasources.push({
name: section['name'],
datasource : new MatTableDataSource(section['data'])
});
}
})
2023-01-27 08:58:33 +01:00
});
2023-01-19 14:47:52 +01:00
}
applyFilter(event: Event) {
const filterValue = (event.target as HTMLInputElement).value.trim().toLowerCase();
this.kvDatasources.forEach(s => s.datasource.filter = filterValue)
this.moduleDatasource.filter = filterValue;
}
}