diff --git a/backend/src/api/explorer/channels.api.ts b/backend/src/api/explorer/channels.api.ts index f0d7dc56b..79aeebb97 100644 --- a/backend/src/api/explorer/channels.api.ts +++ b/backend/src/api/explorer/channels.api.ts @@ -13,9 +13,10 @@ class ChannelsApi { } } - public async $getAllChannelsGeo(): Promise { + public async $getAllChannelsGeo(publicKey?: string): Promise { try { - const query = `SELECT nodes_1.public_key as node1_public_key, nodes_1.alias AS node1_alias, + const params: string[] = []; + let query = `SELECT nodes_1.public_key as node1_public_key, nodes_1.alias AS node1_alias, nodes_1.latitude AS node1_latitude, nodes_1.longitude AS node1_longitude, nodes_2.public_key as node2_public_key, nodes_2.alias AS node2_alias, nodes_2.latitude AS node2_latitude, nodes_2.longitude AS node2_longitude, @@ -26,7 +27,14 @@ class ChannelsApi { WHERE nodes_1.latitude IS NOT NULL AND nodes_1.longitude IS NOT NULL AND nodes_2.latitude IS NOT NULL AND nodes_2.longitude IS NOT NULL `; - const [rows]: any = await DB.query(query); + + if (publicKey !== undefined) { + query += ' AND (nodes_1.public_key = ? OR nodes_2.public_key = ?)'; + params.push(publicKey); + params.push(publicKey); + } + + const [rows]: any = await DB.query(query, params); return rows.map((row) => [ row.node1_public_key, row.node1_alias, row.node1_longitude, row.node1_latitude, row.node2_public_key, row.node2_alias, row.node2_longitude, row.node2_latitude, diff --git a/backend/src/api/explorer/channels.routes.ts b/backend/src/api/explorer/channels.routes.ts index c6df30802..495eec789 100644 --- a/backend/src/api/explorer/channels.routes.ts +++ b/backend/src/api/explorer/channels.routes.ts @@ -11,7 +11,8 @@ class ChannelsRoutes { .get(config.MEMPOOL.API_URL_PREFIX + 'lightning/channels/search/:search', this.$searchChannelsById) .get(config.MEMPOOL.API_URL_PREFIX + 'lightning/channels/:short_id', this.$getChannel) .get(config.MEMPOOL.API_URL_PREFIX + 'lightning/channels', this.$getChannelsForNode) - .get(config.MEMPOOL.API_URL_PREFIX + 'lightning/channels-geo', this.$getChannelsGeo) + .get(config.MEMPOOL.API_URL_PREFIX + 'lightning/channels-geo', this.$getAllChannelsGeo) + .get(config.MEMPOOL.API_URL_PREFIX + 'lightning/channels-geo/:publicKey', this.$getAllChannelsGeo) ; } @@ -94,9 +95,9 @@ class ChannelsRoutes { } } - private async $getChannelsGeo(req: Request, res: Response) { + private async $getAllChannelsGeo(req: Request, res: Response) { try { - const channels = await channelsApi.$getAllChannelsGeo(); + const channels = await channelsApi.$getAllChannelsGeo(req.params?.publicKey); res.json(channels); } catch (e) { res.status(500).send(e instanceof Error ? e.message : e); diff --git a/frontend/src/app/lightning/channels-list/channels-list.component.html b/frontend/src/app/lightning/channels-list/channels-list.component.html index a6d553ef1..ff67788e1 100644 --- a/frontend/src/app/lightning/channels-list/channels-list.component.html +++ b/frontend/src/app/lightning/channels-list/channels-list.component.html @@ -1,6 +1,4 @@
-

Channels ({{ response.totalItems }})

-
diff --git a/frontend/src/app/lightning/node/node.component.scss b/frontend/src/app/lightning/node/node.component.scss index db4adc7b6..0bdb263a8 100644 --- a/frontend/src/app/lightning/node/node.component.scss +++ b/frontend/src/app/lightning/node/node.component.scss @@ -58,3 +58,65 @@ app-fiat { } } + /* The switch - the box around the slider */ + .switch { + position: relative; + display: inline-block; + width: 30px; + height: 17px; +} + +/* Hide default HTML checkbox */ +.switch input { + opacity: 0; + width: 0; + height: 0; +} + +/* The slider */ +.slider { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: #ccc; + -webkit-transition: .4s; + transition: .4s; +} + +.slider:before { + position: absolute; + content: ""; + height: 13px; + width: 13px; + left: 2px; + bottom: 2px; + background-color: white; + -webkit-transition: .4s; + transition: .4s; +} + +input:checked + .slider { + background-color: #2196F3; +} + +input:focus + .slider { + box-shadow: 0 0 1px #2196F3; +} + +input:checked + .slider:before { + -webkit-transform: translateX(13px); + -ms-transform: translateX(13px); + transform: translateX(13px); +} + +/* Rounded sliders */ +.slider.round { + border-radius: 17px; +} + +.slider.round:before { + border-radius: 50%; +} \ No newline at end of file diff --git a/frontend/src/app/lightning/node/node.component.ts b/frontend/src/app/lightning/node/node.component.ts index 1c6c5ee23..a286aa987 100644 --- a/frontend/src/app/lightning/node/node.component.ts +++ b/frontend/src/app/lightning/node/node.component.ts @@ -17,6 +17,7 @@ export class NodeComponent implements OnInit { publicKey$: Observable; selectedSocketIndex = 0; qrCodeVisible = false; + channelsListMode = 'list'; constructor( private lightningApiService: LightningApiService, @@ -61,4 +62,11 @@ export class NodeComponent implements OnInit { this.selectedSocketIndex = index; } + channelsListModeChange(e) { + if (e.target.checked === true) { + this.channelsListMode = 'map'; + } else { + this.channelsListMode = 'list'; + } + } } diff --git a/frontend/src/app/lightning/nodes-channels-map/nodes-channels-map.component.html b/frontend/src/app/lightning/nodes-channels-map/nodes-channels-map.component.html index e41bbd4bb..abc754bad 100644 --- a/frontend/src/app/lightning/nodes-channels-map/nodes-channels-map.component.html +++ b/frontend/src/app/lightning/nodes-channels-map/nodes-channels-map.component.html @@ -1,6 +1,6 @@ -
+
-
+
Lightning nodes channels world map