2019-03-19 00:13:01 +00:00
|
|
|
import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
|
|
|
|
import { Subject } from 'rxjs';
|
|
|
|
import { takeUntil } from 'rxjs/operators';
|
|
|
|
import { Store } from '@ngrx/store';
|
|
|
|
|
|
|
|
import { MatTableDataSource, MatSort } from '@angular/material';
|
2019-11-21 00:14:37 +00:00
|
|
|
import { Channel, GetInfo, PendingChannels } from '../../../../../shared/models/lndModels';
|
|
|
|
import { SelNodeChild } from '../../../../../shared/models/RTLconfig';
|
|
|
|
import { LoggerService } from '../../../../../shared/services/logger.service';
|
2019-03-19 00:13:01 +00:00
|
|
|
|
2019-11-21 00:14:37 +00:00
|
|
|
import { RTLEffects } from '../../../../../store/rtl.effects';
|
|
|
|
import * as RTLActions from '../../../../../store/rtl.actions';
|
|
|
|
import * as fromRTLReducer from '../../../../../store/rtl.reducers';
|
2019-03-19 00:13:01 +00:00
|
|
|
|
|
|
|
@Component({
|
2019-11-21 00:14:37 +00:00
|
|
|
selector: 'rtl-channel-pending-table',
|
|
|
|
templateUrl: './channel-pending-table.component.html',
|
|
|
|
styleUrls: ['./channel-pending-table.component.scss']
|
2019-03-19 00:13:01 +00:00
|
|
|
})
|
2019-11-21 00:14:37 +00:00
|
|
|
export class ChannelPendingTableComponent implements OnInit, OnDestroy {
|
2019-07-27 18:20:17 +00:00
|
|
|
@ViewChild(MatSort, { static: true }) sort: MatSort;
|
2019-09-01 19:55:52 +00:00
|
|
|
public selNode: SelNodeChild = {};
|
2019-03-19 00:13:01 +00:00
|
|
|
public selectedFilter = 0;
|
|
|
|
public information: GetInfo = {};
|
|
|
|
public pendingChannels: PendingChannels = {};
|
|
|
|
public displayedClosingColumns = [
|
|
|
|
'closing_txid',
|
2019-11-22 03:59:38 +00:00
|
|
|
'channel_point', 'remote_balance', 'local_balance', 'remote_node_pub', 'capacity', 'actions'
|
2019-03-19 00:13:01 +00:00
|
|
|
];
|
|
|
|
public pendingClosingChannelsLength = 0;
|
|
|
|
public pendingClosingChannels: any;
|
|
|
|
public displayedForceClosingColumns = [
|
|
|
|
'closing_txid', 'limbo_balance', 'maturity_height', 'blocks_til_maturity', 'recovered_balance',
|
2019-11-22 03:59:38 +00:00
|
|
|
'channel_point', 'remote_balance', 'local_balance', 'remote_node_pub', 'capacity', 'actions'
|
2019-03-19 00:13:01 +00:00
|
|
|
];
|
|
|
|
public pendingForceClosingChannelsLength = 0;
|
|
|
|
public pendingForceClosingChannels: any;
|
2019-11-22 03:59:38 +00:00
|
|
|
public displayedOpenColumns = ['channel_point', 'commit_fee', 'commit_weight', 'capacity', 'actions'];
|
2019-03-19 00:13:01 +00:00
|
|
|
public pendingOpenChannelsLength = 0;
|
|
|
|
public pendingOpenChannels: any;
|
|
|
|
public displayedWaitClosingColumns = [
|
|
|
|
'limbo_balance',
|
2019-11-22 03:59:38 +00:00
|
|
|
'channel_point', 'remote_balance', 'local_balance', 'remote_node_pub', 'capacity', 'actions'
|
2019-03-19 00:13:01 +00:00
|
|
|
];
|
|
|
|
public pendingWaitClosingChannelsLength = 0;
|
|
|
|
public pendingWaitClosingChannels: any;
|
|
|
|
public flgLoading: Array<Boolean | 'error'> = [true];
|
2019-08-24 20:35:31 +00:00
|
|
|
private unsub: Array<Subject<void>> = [new Subject(), new Subject()];
|
2019-03-19 00:13:01 +00:00
|
|
|
|
2019-08-31 02:05:27 +00:00
|
|
|
constructor(private logger: LoggerService, private store: Store<fromRTLReducer.RTLState>, private rtlEffects: RTLEffects) {
|
2019-03-19 00:13:01 +00:00
|
|
|
switch (true) {
|
|
|
|
case (window.innerWidth <= 415):
|
2019-11-22 03:59:38 +00:00
|
|
|
this.displayedClosingColumns = ['channel_point', 'capacity', 'actions'];
|
|
|
|
this.displayedForceClosingColumns = ['channel_point', 'limbo_balance', 'actions'];
|
|
|
|
this.displayedOpenColumns = ['channel_point', 'commit_fee', 'actions'];
|
|
|
|
this.displayedWaitClosingColumns = ['channel_point', 'limbo_balance', 'actions'];
|
2019-03-19 00:13:01 +00:00
|
|
|
break;
|
|
|
|
case (window.innerWidth > 415 && window.innerWidth <= 730):
|
2019-11-22 03:59:38 +00:00
|
|
|
this.displayedClosingColumns = ['channel_point', 'local_balance', 'remote_balance', 'actions'];
|
|
|
|
this.displayedForceClosingColumns = ['channel_point', 'recovered_balance', 'limbo_balance', 'actions'];
|
|
|
|
this.displayedOpenColumns = ['channel_point', 'commit_fee', 'commit_weight', 'actions'];
|
|
|
|
this.displayedWaitClosingColumns = ['channel_point', 'limbo_balance', 'capacity', 'actions'];
|
2019-03-19 00:13:01 +00:00
|
|
|
break;
|
|
|
|
case (window.innerWidth > 730 && window.innerWidth <= 1024):
|
2019-11-22 03:59:38 +00:00
|
|
|
this.displayedClosingColumns = ['channel_point', 'local_balance', 'remote_balance', 'capacity', 'actions'];
|
|
|
|
this.displayedForceClosingColumns = ['channel_point', 'recovered_balance', 'limbo_balance', 'capacity', 'actions'];
|
|
|
|
this.displayedOpenColumns = ['channel_point', 'commit_fee', 'commit_weight', 'capacity', 'actions'];
|
|
|
|
this.displayedWaitClosingColumns = ['channel_point', 'limbo_balance', 'local_balance', 'remote_balance', 'actions'];
|
2019-03-19 00:13:01 +00:00
|
|
|
break;
|
|
|
|
case (window.innerWidth > 1024 && window.innerWidth <= 1280):
|
2019-11-22 03:59:38 +00:00
|
|
|
this.displayedClosingColumns = ['channel_point', 'local_balance', 'remote_balance', 'capacity', 'actions'];
|
|
|
|
this.displayedForceClosingColumns = ['channel_point', 'recovered_balance', 'limbo_balance', 'capacity', 'actions'];
|
|
|
|
this.displayedOpenColumns = ['channel_point', 'commit_fee', 'commit_weight', 'capacity', 'actions'];
|
|
|
|
this.displayedWaitClosingColumns = ['channel_point', 'limbo_balance', 'local_balance', 'remote_balance', 'actions'];
|
2019-03-19 00:13:01 +00:00
|
|
|
break;
|
|
|
|
default:
|
2019-11-22 03:59:38 +00:00
|
|
|
this.displayedClosingColumns = ['channel_point', 'local_balance', 'remote_balance', 'capacity', 'actions'];
|
|
|
|
this.displayedForceClosingColumns = ['channel_point', 'recovered_balance', 'limbo_balance', 'capacity', 'actions'];
|
|
|
|
this.displayedOpenColumns = ['channel_point', 'commit_fee', 'commit_weight', 'capacity', 'actions'];
|
|
|
|
this.displayedWaitClosingColumns = ['channel_point', 'limbo_balance', 'local_balance', 'remote_balance', 'actions'];
|
2019-03-19 00:13:01 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
2019-09-01 19:55:52 +00:00
|
|
|
this.store.select('lnd')
|
2019-08-24 20:35:31 +00:00
|
|
|
.pipe(takeUntil(this.unsub[0]))
|
2019-08-31 02:05:27 +00:00
|
|
|
.subscribe((rtlStore) => {
|
2019-09-01 19:55:52 +00:00
|
|
|
rtlStore.effectErrorsLnd.forEach(effectsErr => {
|
2019-08-24 20:35:31 +00:00
|
|
|
if (effectsErr.action === 'FetchChannels/pending') {
|
|
|
|
this.flgLoading[0] = 'error';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-09-01 19:55:52 +00:00
|
|
|
this.selNode = rtlStore.nodeSettings;
|
2019-08-24 20:35:31 +00:00
|
|
|
this.information = rtlStore.information;
|
|
|
|
this.pendingChannels = rtlStore.pendingChannels;
|
2019-11-22 03:59:38 +00:00
|
|
|
if (this.pendingChannels.total_limbo_balance) {
|
2019-03-19 00:13:01 +00:00
|
|
|
this.flgLoading[1] = false;
|
2019-11-22 03:59:38 +00:00
|
|
|
if (this.pendingChannels.pending_closing_channels) {
|
2019-03-19 00:13:01 +00:00
|
|
|
this.loadClosingChannelsTable(this.pendingChannels.pending_closing_channels);
|
|
|
|
}
|
2019-11-22 03:59:38 +00:00
|
|
|
if (this.pendingChannels.pending_force_closing_channels) {
|
2019-03-19 00:13:01 +00:00
|
|
|
this.loadForceClosingChannelsTable(this.pendingChannels.pending_force_closing_channels);
|
|
|
|
}
|
2019-11-22 03:59:38 +00:00
|
|
|
if (this.pendingChannels.pending_open_channels) {
|
2019-03-19 00:13:01 +00:00
|
|
|
this.loadOpenChannelsTable(this.pendingChannels.pending_open_channels);
|
|
|
|
}
|
2019-11-22 03:59:38 +00:00
|
|
|
if (this.pendingChannels.waiting_close_channels) {
|
2019-03-19 00:13:01 +00:00
|
|
|
this.loadWaitClosingChannelsTable(this.pendingChannels.waiting_close_channels);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (this.flgLoading[0] !== 'error') {
|
2019-11-22 03:59:38 +00:00
|
|
|
this.flgLoading[0] = (this.information.identity_pubkey) ? false : true;
|
2019-03-19 00:13:01 +00:00
|
|
|
}
|
|
|
|
this.logger.info(rtlStore);
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
onOpenClick(selRow: any, event: any) {
|
|
|
|
const selChannel = this.pendingOpenChannels.data.filter(channel => {
|
|
|
|
return channel.channel.channel_point === selRow.channel.channel_point;
|
|
|
|
})[0];
|
|
|
|
const fcChannelObj1 = JSON.parse(JSON.stringify(selChannel, ['commit_weight', 'confirmation_height', 'fee_per_kw', 'commit_fee'], 2));
|
|
|
|
const fcChannelObj2 = JSON.parse(JSON.stringify(selChannel.channel, ['channel_point', 'remote_balance', 'local_balance', 'remote_node_pub', 'capacity'], 2));
|
|
|
|
const reorderedChannel = {};
|
|
|
|
Object.assign(reorderedChannel, fcChannelObj1, fcChannelObj2);
|
2019-11-16 03:34:05 +00:00
|
|
|
this.store.dispatch(new RTLActions.OpenAlert({config: { width: '75%', data: {
|
2019-03-19 00:13:01 +00:00
|
|
|
type: 'INFO',
|
|
|
|
message: JSON.stringify(reorderedChannel)
|
2019-11-16 03:34:05 +00:00
|
|
|
}}}));
|
2019-03-19 00:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onForceClosingClick(selRow: any, event: any) {
|
|
|
|
const selChannel = this.pendingForceClosingChannels.data.filter(channel => {
|
|
|
|
return channel.channel.channel_point === selRow.channel.channel_point;
|
|
|
|
})[0];
|
|
|
|
const fcChannelObj1 = JSON.parse(JSON.stringify(selChannel, ['closing_txid', 'limbo_balance', 'maturity_height', 'blocks_til_maturity', 'recovered_balance'], 2));
|
|
|
|
const fcChannelObj2 = JSON.parse(JSON.stringify(selChannel.channel, ['channel_point', 'remote_balance', 'local_balance', 'remote_node_pub', 'capacity'], 2));
|
|
|
|
const reorderedChannel = {};
|
|
|
|
Object.assign(reorderedChannel, fcChannelObj1, fcChannelObj2);
|
2019-11-16 03:34:05 +00:00
|
|
|
this.store.dispatch(new RTLActions.OpenAlert({config: { width: '75%', data: {
|
2019-03-19 00:13:01 +00:00
|
|
|
type: 'INFO',
|
|
|
|
message: JSON.stringify(reorderedChannel)
|
2019-11-16 03:34:05 +00:00
|
|
|
}}}));
|
2019-03-19 00:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onClosingClick(selRow: any, event: any) {
|
|
|
|
const selChannel = this.pendingClosingChannels.data.filter(channel => {
|
|
|
|
return channel.channel.channel_point === selRow.channel.channel_point;
|
|
|
|
})[0];
|
|
|
|
const fcChannelObj1 = JSON.parse(JSON.stringify(selChannel, ['closing_txid'], 2));
|
|
|
|
const fcChannelObj2 = JSON.parse(JSON.stringify(selChannel.channel, ['channel_point', 'remote_balance', 'local_balance', 'remote_node_pub', 'capacity'], 2));
|
|
|
|
const reorderedChannel = {};
|
|
|
|
Object.assign(reorderedChannel, fcChannelObj1, fcChannelObj2);
|
2019-11-16 03:34:05 +00:00
|
|
|
this.store.dispatch(new RTLActions.OpenAlert({config: { width: '75%', data: {
|
2019-03-19 00:13:01 +00:00
|
|
|
type: 'INFO',
|
|
|
|
message: JSON.stringify(reorderedChannel)
|
2019-11-16 03:34:05 +00:00
|
|
|
}}}));
|
2019-03-19 00:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onWaitClosingClick(selRow: any, event: any) {
|
|
|
|
const selChannel = this.pendingWaitClosingChannels.data.filter(channel => {
|
|
|
|
return channel.channel.channel_point === selRow.channel.channel_point;
|
|
|
|
})[0];
|
|
|
|
const fcChannelObj1 = JSON.parse(JSON.stringify(selChannel, ['limbo_balance'], 2));
|
|
|
|
const fcChannelObj2 = JSON.parse(JSON.stringify(selChannel.channel, ['channel_point', 'remote_balance', 'local_balance', 'remote_node_pub', 'capacity'], 2));
|
|
|
|
const reorderedChannel = {};
|
|
|
|
Object.assign(reorderedChannel, fcChannelObj1, fcChannelObj2);
|
2019-11-16 03:34:05 +00:00
|
|
|
this.store.dispatch(new RTLActions.OpenAlert({config: { width: '75%', data: {
|
2019-03-19 00:13:01 +00:00
|
|
|
type: 'INFO',
|
|
|
|
message: JSON.stringify(reorderedChannel)
|
2019-11-16 03:34:05 +00:00
|
|
|
}}}));
|
2019-03-19 00:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
loadOpenChannelsTable(channels) {
|
|
|
|
channels.sort(function(a, b) {
|
|
|
|
return (a.active === b.active) ? 0 : ((b.active) ? -1 : 1);
|
|
|
|
});
|
2019-11-22 03:59:38 +00:00
|
|
|
this.pendingOpenChannelsLength = (channels.length) ? channels.length : 0;
|
2019-03-19 00:13:01 +00:00
|
|
|
this.pendingOpenChannels = new MatTableDataSource<Channel>([...channels]);
|
|
|
|
this.pendingOpenChannels.sort = this.sort;
|
|
|
|
this.logger.info(this.pendingOpenChannels);
|
|
|
|
}
|
|
|
|
|
|
|
|
loadForceClosingChannelsTable(channels) {
|
|
|
|
channels.sort(function(a, b) {
|
|
|
|
return (a.active === b.active) ? 0 : ((b.active) ? -1 : 1);
|
|
|
|
});
|
2019-11-22 03:59:38 +00:00
|
|
|
this.pendingForceClosingChannelsLength = (channels.length) ? channels.length : 0;
|
2019-03-19 00:13:01 +00:00
|
|
|
this.pendingForceClosingChannels = new MatTableDataSource<Channel>([...channels]);
|
|
|
|
this.pendingForceClosingChannels.sort = this.sort;
|
|
|
|
this.logger.info(this.pendingForceClosingChannels);
|
|
|
|
}
|
|
|
|
|
|
|
|
loadClosingChannelsTable(channels) {
|
|
|
|
channels.sort(function(a, b) {
|
|
|
|
return (a.active === b.active) ? 0 : ((b.active) ? -1 : 1);
|
|
|
|
});
|
2019-11-22 03:59:38 +00:00
|
|
|
this.pendingClosingChannelsLength = (channels.length) ? channels.length : 0;
|
2019-03-19 00:13:01 +00:00
|
|
|
this.pendingClosingChannels = new MatTableDataSource<Channel>([...channels]);
|
|
|
|
this.pendingClosingChannels.sort = this.sort;
|
|
|
|
this.logger.info(this.pendingClosingChannels);
|
|
|
|
}
|
|
|
|
|
|
|
|
loadWaitClosingChannelsTable(channels) {
|
|
|
|
channels.sort(function(a, b) {
|
|
|
|
return (a.active === b.active) ? 0 : ((b.active) ? -1 : 1);
|
|
|
|
});
|
2019-11-22 03:59:38 +00:00
|
|
|
this.pendingWaitClosingChannelsLength = (channels.length) ? channels.length : 0;
|
2019-03-19 00:13:01 +00:00
|
|
|
this.pendingWaitClosingChannels = new MatTableDataSource<Channel>([...channels]);
|
|
|
|
this.pendingWaitClosingChannels.sort = this.sort;
|
|
|
|
this.logger.info(this.pendingWaitClosingChannels);
|
|
|
|
}
|
|
|
|
|
|
|
|
applyFilter(selFilter: number) {
|
|
|
|
this.selectedFilter = selFilter;
|
|
|
|
}
|
|
|
|
|
2019-11-22 03:59:38 +00:00
|
|
|
onPendingClick(selRow: any, event: any) {
|
|
|
|
// // const flgExpansionClicked = event.target.className.includes('mat-expansion-panel-header') || event.target.className.includes('mat-expansion-indicator');
|
|
|
|
// // if (flgExpansionClicked) { return; }
|
|
|
|
// const selPayment = this.payments.data.filter(payment => {
|
|
|
|
// return payment.payment_hash === selRow.payment_hash;
|
|
|
|
// })[0];
|
|
|
|
// const reorderedPayment = JSON.parse(JSON.stringify(selPayment, [
|
|
|
|
// 'creation_date_str', 'payment_hash', 'fee', 'value_msat', 'value_sat', 'value', 'payment_preimage', 'path'
|
|
|
|
// ] , 2));
|
|
|
|
// this.store.dispatch(new RTLActions.OpenAlert({config: { width: '75%', data: {
|
|
|
|
// type: 'INFO',
|
|
|
|
// message: JSON.stringify(reorderedPayment)
|
|
|
|
// }}}));
|
|
|
|
}
|
|
|
|
|
2019-03-19 00:13:01 +00:00
|
|
|
ngOnDestroy() {
|
2019-08-24 20:35:31 +00:00
|
|
|
this.unsub.forEach(completeSub => {
|
2019-03-19 00:13:01 +00:00
|
|
|
completeSub.next();
|
|
|
|
completeSub.complete();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|