From ac10aafc07db942a350abf88a840f4bc5236cdc8 Mon Sep 17 00:00:00 2001 From: softsimon Date: Sun, 15 May 2022 16:48:38 +0400 Subject: [PATCH] More node info --- .../app/lightning/node/node.component.html | 28 ++++++++++++++++--- .../components/sats/sats.component.html | 2 +- .../src/api/explorer/nodes.api.ts | 4 +-- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/frontend/src/app/lightning/node/node.component.html b/frontend/src/app/lightning/node/node.component.html index 713cb2709..5309e10f2 100644 --- a/frontend/src/app/lightning/node/node.component.html +++ b/frontend/src/app/lightning/node/node.component.html @@ -14,6 +14,30 @@
+
+ + + + + + + + + + + + + + + +
Total capacity +   +
Total channels + {{ node.channel_count }} +
Average channel size +   +
+
@@ -36,10 +60,6 @@
-
-
- -
diff --git a/frontend/src/app/shared/components/sats/sats.component.html b/frontend/src/app/shared/components/sats/sats.component.html index 8358812a9..d8b52b956 100644 --- a/frontend/src/app/shared/components/sats/sats.component.html +++ b/frontend/src/app/shared/components/sats/sats.component.html @@ -1,4 +1,4 @@ -‎{{ addPlus && satoshis >= 0 ? '+' : '' }}{{ satoshis | number }} +‎{{ addPlus && satoshis >= 0 ? '+' : '' }}{{ satoshis | number : '1.0-0' }} L- tL- t- diff --git a/lightning-backend/src/api/explorer/nodes.api.ts b/lightning-backend/src/api/explorer/nodes.api.ts index e8e18b082..28aa6d925 100644 --- a/lightning-backend/src/api/explorer/nodes.api.ts +++ b/lightning-backend/src/api/explorer/nodes.api.ts @@ -4,8 +4,8 @@ import DB from '../../database'; class NodesApi { public async $getNode(public_key: string): Promise { try { - const query = `SELECT nodes.*, (SELECT COUNT(*) FROM channels WHERE channels.status < 2 AND (channels.node1_public_key = ? OR channels.node2_public_key = ?)) AS channel_count, (SELECT SUM(capacity) FROM channels WHERE channels.status < 2 AND (channels.node1_public_key = ? OR channels.node2_public_key = ?)) AS capacity FROM nodes WHERE public_key = ?`; - const [rows]: any = await DB.query(query, [public_key, public_key, public_key, public_key, public_key]); + const query = `SELECT nodes.*, (SELECT COUNT(*) FROM channels WHERE channels.status < 2 AND (channels.node1_public_key = ? OR channels.node2_public_key = ?)) AS channel_count, (SELECT SUM(capacity) FROM channels WHERE channels.status < 2 AND (channels.node1_public_key = ? OR channels.node2_public_key = ?)) AS capacity, (SELECT AVG(capacity) FROM channels WHERE status < 2 AND (node1_public_key = ? OR node2_public_key = ?)) AS channels_capacity_avg FROM nodes WHERE public_key = ?`; + const [rows]: any = await DB.query(query, [public_key, public_key, public_key, public_key, public_key, public_key, public_key]); return rows[0]; } catch (e) { logger.err('$getNode error: ' + (e instanceof Error ? e.message : e));