You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
RTL/src/app/clightning/lookups/node-lookup/node-lookup.component.ts

35 lines
1.5 KiB
TypeScript

import { Component, OnInit, Input, ViewChild } from '@angular/core';
import { MatSnackBar } from '@angular/material/snack-bar';
import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
import { LookupNode } from '../../../shared/models/clModels';
import { LoggerService } from '../../../shared/services/logger.service';
@Component({
selector: 'rtl-cl-node-lookup',
templateUrl: './node-lookup.component.html',
styleUrls: ['./node-lookup.component.scss']
})
export class CLNodeLookupComponent implements OnInit {
@ViewChild(MatSort, { static: false }) sort: MatSort|undefined;
@Input() lookupResult: LookupNode;
public addresses: any;
public displayedColumns = ['type', 'address', 'port', 'actions'];
constructor(private logger: LoggerService, private snackBar: MatSnackBar) { }
ngOnInit() {
this.addresses = this.lookupResult.addresses ? new MatTableDataSource<any>([...this.lookupResult.addresses]) : new MatTableDataSource([]);
this.addresses.data = this.lookupResult.addresses ? this.lookupResult.addresses : [];
this.addresses.sort = this.sort;
this.addresses.sortingDataAccessor = (data: any, sortHeaderId: string) => (data[sortHeaderId] && isNaN(data[sortHeaderId])) ? data[sortHeaderId].toLocaleLowerCase() : data[sortHeaderId] ? +data[sortHeaderId] : null;
}
onCopyNodeURI(payload: string) {
this.snackBar.open('Node URI copied.');
this.logger.info('Copied Text: ' + payload);
}
}