Bug fix #159: filter active/inactive channels

Bug fix #159: filter active/inactive channels
pull/163/head
ShahanaFarooqui 5 years ago
parent efaac83db9
commit d8ea5974b4

@ -8,5 +8,5 @@
<link rel="stylesheet" href="styles.83644e00292bcd08f710.css"></head>
<body>
<rtl-app></rtl-app>
<script type="text/javascript" src="runtime.26209474bfa8dc87a77c.js"></script><script type="text/javascript" src="polyfills.d68e8f4f73dfaef206f1.js"></script><script type="text/javascript" src="main.e0a09a6455cf3f888aa6.js"></script></body>
<script type="text/javascript" src="runtime.26209474bfa8dc87a77c.js"></script><script type="text/javascript" src="polyfills.d68e8f4f73dfaef206f1.js"></script><script type="text/javascript" src="main.6c3ca97d1340edf66106.js"></script></body>
</html>

File diff suppressed because one or more lines are too long

@ -429,6 +429,37 @@ connect.logEnvVariables = () => {
}
}
connect.getAllNodeAllChannelBackup = (node) => {
let channel_backup_file = node.channel_backup_path + '/channel-all.bak';
let options = {
url: node.lnd_server_url + '/channels/backup',
rejectUnauthorized: false,
json: true,
headers: {'Grpc-Metadata-macaroon': fs.readFileSync(node.macaroon_path + '/admin.macaroon').toString('hex')}
};
request(options, function (err, res, body) {
if (err) {
logger.error('\r\nConnect: ' + new Date().toJSON().slice(0,19) + ': ERROR: Channel Backup Response Failed: ' + JSON.stringify(err));
} else {
fs.writeFile(channel_backup_file, JSON.stringify(body), function(err) {
if (err) {
if (node.ln_node) {
logger.error('\r\nConnect: ' + new Date().toJSON().slice(0,19) + ': ERROR: Channel Backup Failed for Node ' + node.ln_node + ' with error response: ' + JSON.stringify(err));
} else {
logger.error('\r\nConnect: ' + new Date().toJSON().slice(0,19) + ': ERROR: Channel Backup Failed: ' + JSON.stringify(err));
}
} else {
if (node.ln_node) {
logger.info('\r\nConnect: ' + new Date().toJSON().slice(0,19) + ': INFO: Channel Backup Successful for Node: ' + node.ln_node);
} else {
logger.info('\r\nConnect: ' + new Date().toJSON().slice(0,19) + ': INFO: Channel Backup Successful');
}
}
});
}
})
};
connect.setSingleNodeConfiguration = (singleNodeFilePath) => {
const exists = fs.existsSync(singleNodeFilePath);
if (exists) {
@ -476,40 +507,9 @@ connect.setServerConfiguration = () => {
} else if ((multiNodeExists && singleNodeExists) || (multiNodeExists && !singleNodeExists)) {
common.multi_node_setup = true;
connect.setMultiNodeConfiguration(multiNodeConfFile);
common.selectedNode = common.findNode(common.nodes[0].index);
common.selectedNode = common.findNode(common.nodes[1].index);
}
common.nodes.map(node => { connect.getAllNodeAllChannelBackup(node); });
}
connect.getAllNodeAllChannelBackup = (node) => {
let channel_backup_file = node.channel_backup_path + '/channel-all.bak';
let options = {
url: node.lnd_server_url + '/channels/backup',
rejectUnauthorized: false,
json: true,
headers: {'Grpc-Metadata-macaroon': fs.readFileSync(node.macaroon_path + '/admin.macaroon').toString('hex')}
};
request(options, function (err, res, body) {
if (err) {
logger.error('\r\nConnect: 496: ' + new Date().toJSON().slice(0,19) + ': ERROR: Channel Backup Response Failed: ' + JSON.stringify(err));
} else {
fs.writeFile(channel_backup_file, JSON.stringify(body), function(err) {
if (err) {
if (node.ln_node) {
logger.error('\r\nConnect: 501: ' + new Date().toJSON().slice(0,19) + ': ERROR: Channel Backup Failed for Node ' + node.ln_node + ' with error response: ' + JSON.stringify(err));
} else {
logger.error('\r\nConnect: 503: ' + new Date().toJSON().slice(0,19) + ': ERROR: Channel Backup Failed: ' + JSON.stringify(err));
}
} else {
if (node.ln_node) {
logger.info('\r\nConnect: 507: ' + new Date().toJSON().slice(0,19) + ': INFO: Channel Backup Successful for Node: ' + node.ln_node);
} else {
logger.info('\r\nConnect: 509: ' + new Date().toJSON().slice(0,19) + ': INFO: Channel Backup Successful');
}
}
});
}
})
};
module.exports = connect;

@ -38,7 +38,6 @@ exports.getChannels = (req, res, next) => {
channels = (undefined === body.channels) ? [] : body.channels;
Promise.all(
channels.map(channel => {
channel.private = (channel.private) ? 'True' : 'False';
return getAliasForChannel(channel, req.params.channelType);
})
)

@ -46,6 +46,15 @@ export class ChannelBackupComponent implements OnInit, OnDestroy {
this.channels.data = rtlStore.allChannels;
}
this.channels.sort = this.sort;
this.channels.filterPredicate = (channel: Channel, fltr: string) => {
const newChannel = ((channel.active) ? 'active' : 'inactive') + (channel.chan_id ? channel.chan_id : '') +
(channel.remote_pubkey ? channel.remote_pubkey : '') + (channel.remote_alias ? channel.remote_alias : '') +
(channel.capacity ? channel.capacity : '') + (channel.local_balance ? channel.local_balance : '') +
(channel.remote_balance ? channel.remote_balance : '') + (channel.total_satoshis_sent ? channel.total_satoshis_sent : '') +
(channel.total_satoshis_received ? channel.total_satoshis_received : '') + (channel.commit_fee ? channel.commit_fee : '') +
(channel.private ? 'private' : 'public');
return newChannel.includes(fltr);
};
if (this.flgLoading[0] !== 'error') {
this.flgLoading[0] = false;
}

@ -117,7 +117,7 @@
</ng-container>
<ng-container matColumnDef="private">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Private </th>
<td mat-cell *matCellDef="let channel"> {{channel.private}} </td>
<td mat-cell *matCellDef="let channel"> {{(channel.private ? 'Private' : 'Public')}} </td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: flgSticky;"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;" (click)="onChannelClick(row, $event)"></tr>

@ -222,6 +222,15 @@ export class ChannelManageComponent implements OnInit, OnDestroy {
});
this.channels = new MatTableDataSource<Channel>([...channels]);
this.channels.sort = this.sort;
this.channels.filterPredicate = (channel: Channel, fltr: string) => {
const newChannel = ((channel.active) ? 'active' : 'inactive') + (channel.chan_id ? channel.chan_id : '') +
(channel.remote_pubkey ? channel.remote_pubkey : '') + (channel.remote_alias ? channel.remote_alias : '') +
(channel.capacity ? channel.capacity : '') + (channel.local_balance ? channel.local_balance : '') +
(channel.remote_balance ? channel.remote_balance : '') + (channel.total_satoshis_sent ? channel.total_satoshis_sent : '') +
(channel.total_satoshis_received ? channel.total_satoshis_received : '') + (channel.commit_fee ? channel.commit_fee : '') +
(channel.private ? 'private' : 'public');
return newChannel.includes(fltr);
};
this.logger.info(this.channels);
}

Loading…
Cancel
Save