From 0dfda66578a4e43d25907f0668e4362bade15875 Mon Sep 17 00:00:00 2001 From: softsimon Date: Tue, 30 Aug 2022 11:46:37 +0200 Subject: [PATCH 1/7] Typeahead loading spinner and regex fixes --- .../search-form/search-form.component.html | 8 +++++++- .../search-form/search-form.component.scss | 8 +++++++- .../components/search-form/search-form.component.ts | 13 ++++++++----- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/frontend/src/app/components/search-form/search-form.component.html b/frontend/src/app/components/search-form/search-form.component.html index 378e38940..e96cd0a57 100644 --- a/frontend/src/app/components/search-form/search-form.component.html +++ b/frontend/src/app/components/search-form/search-form.component.html @@ -7,7 +7,13 @@
- +
+ + + + diff --git a/frontend/src/app/components/search-form/search-form.component.scss b/frontend/src/app/components/search-form/search-form.component.scss index 448cb28b3..7c8161196 100644 --- a/frontend/src/app/components/search-form/search-form.component.scss +++ b/frontend/src/app/components/search-form/search-form.component.scss @@ -49,4 +49,10 @@ form { .btn { width: 100px; } -} \ No newline at end of file +} + +.spinner-border { + vertical-align: text-top; + margin-top: 1px; + margin-right: 2px; +} diff --git a/frontend/src/app/components/search-form/search-form.component.ts b/frontend/src/app/components/search-form/search-form.component.ts index 9ed40700a..a9deccc6b 100644 --- a/frontend/src/app/components/search-form/search-form.component.ts +++ b/frontend/src/app/components/search-form/search-form.component.ts @@ -3,8 +3,8 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { Router } from '@angular/router'; import { AssetsService } from 'src/app/services/assets.service'; import { StateService } from 'src/app/services/state.service'; -import { Observable, of, Subject, merge, zip } from 'rxjs'; -import { debounceTime, distinctUntilChanged, switchMap, filter, catchError, map } from 'rxjs/operators'; +import { Observable, of, Subject, zip, BehaviorSubject } from 'rxjs'; +import { debounceTime, distinctUntilChanged, switchMap, catchError, map } from 'rxjs/operators'; import { ElectrsApiService } from 'src/app/services/electrs-api.service'; import { RelativeUrlPipe } from 'src/app/shared/pipes/relative-url/relative-url.pipe'; import { ApiService } from 'src/app/services/api.service'; @@ -20,13 +20,14 @@ export class SearchFormComponent implements OnInit { network = ''; assets: object = {}; isSearching = false; + isTypeaheading$ = new BehaviorSubject(false); typeAhead$: Observable; searchForm: FormGroup; regexAddress = /^([a-km-zA-HJ-NP-Z1-9]{26,35}|[a-km-zA-HJ-NP-Z1-9]{80}|[a-z]{2,5}1[ac-hj-np-z02-9]{8,100}|[A-Z]{2,5}1[AC-HJ-NP-Z02-9]{8,100})$/; regexBlockhash = /^[0]{8}[a-fA-F0-9]{56}$/; - regexTransaction = /^([a-fA-F0-9]{64}):?(\d+)?$/; - regexBlockheight = /^[0-9]+$/; + regexTransaction = /^([a-fA-F0-9]{64})(:\d+)?$/; + regexBlockheight = /^[0-9]{1,9}$/; focus$ = new Subject(); click$ = new Subject(); @@ -68,7 +69,7 @@ export class SearchFormComponent implements OnInit { } return text.trim(); }), - debounceTime(250), + debounceTime(200), distinctUntilChanged(), switchMap((text) => { if (!text.length) { @@ -80,6 +81,7 @@ export class SearchFormComponent implements OnInit { } ]); } + this.isTypeaheading$.next(true); if (!this.stateService.env.LIGHTNING) { return zip( this.electrsApiService.getAddressesByPrefix$(text).pipe(catchError(() => of([]))), @@ -95,6 +97,7 @@ export class SearchFormComponent implements OnInit { ); }), map((result: any[]) => { + this.isTypeaheading$.next(false); if (this.network === 'bisq') { return result[0].map((address: string) => 'B' + address); } From a2e6b265d35aaf92c7e71d0fa7c04ebca0537c19 Mon Sep 17 00:00:00 2001 From: softsimon Date: Tue, 30 Aug 2022 22:36:13 +0200 Subject: [PATCH 2/7] Search bar fixes. --- .../app/components/search-form/search-form.component.html | 2 +- .../app/components/search-form/search-form.component.ts | 1 + .../search-form/search-results/search-results.component.ts | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/components/search-form/search-form.component.html b/frontend/src/app/components/search-form/search-form.component.html index e96cd0a57..8badcc3cf 100644 --- a/frontend/src/app/components/search-form/search-form.component.html +++ b/frontend/src/app/components/search-form/search-form.component.html @@ -15,5 +15,5 @@ - + diff --git a/frontend/src/app/components/search-form/search-form.component.ts b/frontend/src/app/components/search-form/search-form.component.ts index a9deccc6b..712f7438c 100644 --- a/frontend/src/app/components/search-form/search-form.component.ts +++ b/frontend/src/app/components/search-form/search-form.component.ts @@ -156,6 +156,7 @@ export class SearchFormComponent implements OnInit { this.navigate('/tx/', matches[0]); } } else { + this.searchResults.searchButtonClick(); this.isSearching = false; } } diff --git a/frontend/src/app/components/search-form/search-results/search-results.component.ts b/frontend/src/app/components/search-form/search-results/search-results.component.ts index 84f6a7447..7bda62c02 100644 --- a/frontend/src/app/components/search-form/search-results/search-results.component.ts +++ b/frontend/src/app/components/search-form/search-results/search-results.component.ts @@ -25,6 +25,13 @@ export class SearchResultsComponent implements OnChanges { } } + searchButtonClick() { + if (this.resultsFlattened[this.activeIdx]) { + this.selectedResult.emit(this.resultsFlattened[this.activeIdx]); + this.results = null; + } + } + handleKeyDown(event: KeyboardEvent) { switch (event.key) { case 'ArrowDown': From 9dc45d9db334d636f74c2f0c0c0a23c2b9f5161f Mon Sep 17 00:00:00 2001 From: Mononaut Date: Tue, 30 Aug 2022 21:53:52 +0000 Subject: [PATCH 3/7] hotfix to rollback broken unfurler --- unfurler/src/index.ts | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/unfurler/src/index.ts b/unfurler/src/index.ts index 305a0a4c2..ff5e6963a 100644 --- a/unfurler/src/index.ts +++ b/unfurler/src/index.ts @@ -99,20 +99,15 @@ class Server { throw new Error('failed to access open graph service'); } } - // wait for navigation to complete - await page.waitForFunction( - (path) => window.location.pathname.includes(path), - {}, - path - ); - // wait for preview component to initialize - await page.waitForSelector('meta[property="og:preview:loading"]', { timeout: config.PUPPETEER.RENDER_TIMEOUT || 3000 }) + const waitForReady = await page.$('meta[property="og:preview:loading"]'); let success = true; - success = await Promise.race([ - page.waitForSelector('meta[property="og:preview:ready"]', { timeout: config.PUPPETEER.RENDER_TIMEOUT || 3000 }).then(() => true), - page.waitForSelector('meta[property="og:preview:fail"]', { timeout: config.PUPPETEER.RENDER_TIMEOUT || 3000 }).then(() => false) - ]) + if (waitForReady != null) { + success = await Promise.race([ + page.waitForSelector('meta[property="og:preview:ready"]', { timeout: config.PUPPETEER.RENDER_TIMEOUT || 3000 }).then(() => true), + page.waitForSelector('meta[property="og:preview:fail"]', { timeout: config.PUPPETEER.RENDER_TIMEOUT || 3000 }).then(() => false) + ]) + } if (success) { const screenshot = await page.screenshot(); return screenshot; From 48a7f8a3ee354a14a37d69628f292cd5eacf73ce Mon Sep 17 00:00:00 2001 From: softsimon Date: Wed, 31 Aug 2022 01:52:32 +0200 Subject: [PATCH 4/7] Channel txs details buttons --- .../lightning/channel/channel.component.html | 12 +++++++---- .../lightning/channel/channel.component.scss | 21 ++++++++++++++++--- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/frontend/src/app/lightning/channel/channel.component.html b/frontend/src/app/lightning/channel/channel.component.html index 195c35324..2824b8dba 100644 --- a/frontend/src/app/lightning/channel/channel.component.html +++ b/frontend/src/app/lightning/channel/channel.component.html @@ -65,14 +65,18 @@ -

Opening transaction

- +
+

Opening transaction

+ +
+
-
+

Closing transaction

   +
- + diff --git a/frontend/src/app/lightning/channel/channel.component.scss b/frontend/src/app/lightning/channel/channel.component.scss index c23d8e28c..333955212 100644 --- a/frontend/src/app/lightning/channel/channel.component.scss +++ b/frontend/src/app/lightning/channel/channel.component.scss @@ -45,19 +45,29 @@ app-fiat { } .closing-header { - display: flex; flex-direction: row; margin-bottom: 1rem; align-items: center; } +h3 { + margin-bottom: 0rem; +} + @media (max-width: 768px) { h3 { font-size: 1.4rem; + white-space: nowrap; + } + .closing-header { + flex-wrap: wrap; + } + app-closing-type { + flex-basis: 100%; + order: 1; } } - .loading-spinner { position: absolute; top: 400px; @@ -67,4 +77,9 @@ app-fiat { @media (max-width: 767.98px) { top: 450px; } -} \ No newline at end of file +} + +.details-button { + align-self: center; + margin-left: auto; +} From 434963e8a0c998578e51477b40f9feaea73599f5 Mon Sep 17 00:00:00 2001 From: nymkappa Date: Wed, 31 Aug 2022 07:44:18 +0200 Subject: [PATCH 5/7] Sort closed channels by closing_date, updated_at --- backend/src/api/explorer/channels.api.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/backend/src/api/explorer/channels.api.ts b/backend/src/api/explorer/channels.api.ts index b5eac7499..768d5d1e1 100644 --- a/backend/src/api/explorer/channels.api.ts +++ b/backend/src/api/explorer/channels.api.ts @@ -257,7 +257,8 @@ class ChannelsApi { let query = ` SELECT COALESCE(node2.alias, SUBSTRING(node2_public_key, 0, 20)) AS alias, COALESCE(node2.public_key, node2_public_key) AS public_key, channels.status, channels.node1_fee_rate, - channels.capacity, channels.short_id, channels.id, channels.closing_reason + channels.capacity, channels.short_id, channels.id, channels.closing_reason, + UNIX_TIMESTAMP(closing_date) as closing_date, UNIX_TIMESTAMP(channels.updated_at) as updated_at FROM channels LEFT JOIN nodes AS node2 ON node2.public_key = channels.node2_public_key WHERE node1_public_key = ? AND channels.status ${channelStatusFilter} @@ -268,7 +269,8 @@ class ChannelsApi { query = ` SELECT COALESCE(node1.alias, SUBSTRING(node1_public_key, 0, 20)) AS alias, COALESCE(node1.public_key, node1_public_key) AS public_key, channels.status, channels.node2_fee_rate, - channels.capacity, channels.short_id, channels.id, channels.closing_reason + channels.capacity, channels.short_id, channels.id, channels.closing_reason, + UNIX_TIMESTAMP(closing_date) as closing_date, UNIX_TIMESTAMP(channels.updated_at) as updated_at FROM channels LEFT JOIN nodes AS node1 ON node1.public_key = channels.node1_public_key WHERE node2_public_key = ? AND channels.status ${channelStatusFilter} @@ -277,7 +279,15 @@ class ChannelsApi { let allChannels = channelsFromNode.concat(channelsToNode); allChannels.sort((a, b) => { - return b.capacity - a.capacity; + if (status === 'closed') { + if (!b.closing_date && !a.closing_date) { + return (b.updated_at ?? 0) - (a.updated_at ?? 0); + } else { + return (b.closing_date ?? 0) - (a.closing_date ?? 0); + } + } else { + return b.capacity - a.capacity; + } }); if (index >= 0) { @@ -294,6 +304,7 @@ class ChannelsApi { channel = { status: row.status, closing_reason: row.closing_reason, + closing_date: row.closing_date, capacity: row.capacity ?? 0, short_id: row.short_id, id: row.id, From e8151e8393de6dd9f6349eb7162893630b5bf55b Mon Sep 17 00:00:00 2001 From: nymkappa Date: Wed, 31 Aug 2022 08:17:42 +0200 Subject: [PATCH 6/7] Fix node header layout --- .../app/lightning/node/node.component.html | 22 +++++++++---------- .../app/lightning/node/node.component.scss | 7 ++++++ .../geolocation/geolocation.component.html | 2 +- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/frontend/src/app/lightning/node/node.component.html b/frontend/src/app/lightning/node/node.component.html index a279d0fd7..778543772 100644 --- a/frontend/src/app/lightning/node/node.component.html +++ b/frontend/src/app/lightning/node/node.component.html @@ -22,30 +22,30 @@
- +
- + - + - + - + @@ -55,30 +55,30 @@
-
Active capacityActive capacity
Active channelsActive channels {{ node.active_channel_count }}
Average channel sizeAverage channel size
LocationLocation
+
- + - + - + - + diff --git a/frontend/src/app/lightning/node/node.component.scss b/frontend/src/app/lightning/node/node.component.scss index 481f2a8c4..7221e56bc 100644 --- a/frontend/src/app/lightning/node/node.component.scss +++ b/frontend/src/app/lightning/node/node.component.scss @@ -77,3 +77,10 @@ app-fiat { left: calc(50% - 15px); z-index: 100; } + +.label { + width: 50%; + @media (min-width: 576px) { + width: 40%; + } +} \ No newline at end of file diff --git a/frontend/src/app/shared/components/geolocation/geolocation.component.html b/frontend/src/app/shared/components/geolocation/geolocation.component.html index 2788cd4c1..c63af47be 100644 --- a/frontend/src/app/shared/components/geolocation/geolocation.component.html +++ b/frontend/src/app/shared/components/geolocation/geolocation.component.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file From ff1aae853eb54ea5941e9a21cf899eab98c8c693 Mon Sep 17 00:00:00 2001 From: nymkappa Date: Wed, 31 Aug 2022 09:37:19 +0200 Subject: [PATCH 7/7] Save latest node channel update in node.updated_at field in db --- backend/src/api/explorer/channels.api.ts | 17 +++++++++++++++++ .../src/tasks/lightning/network-sync.service.ts | 3 +++ 2 files changed, 20 insertions(+) diff --git a/backend/src/api/explorer/channels.api.ts b/backend/src/api/explorer/channels.api.ts index b5eac7499..7235d44b6 100644 --- a/backend/src/api/explorer/channels.api.ts +++ b/backend/src/api/explorer/channels.api.ts @@ -522,6 +522,23 @@ class ChannelsApi { logger.err('$setChannelsInactive() error: ' + (e instanceof Error ? e.message : e)); } } + + public async $getLatestChannelUpdateForNode(publicKey: string): Promise { + try { + const query = ` + SELECT MAX(UNIX_TIMESTAMP(updated_at)) as updated_at + FROM channels + WHERE node1_public_key = ? + `; + const [rows]: any[] = await DB.query(query, [publicKey]); + if (rows.length > 0) { + return rows[0].updated_at; + } + } catch (e) { + logger.err(`Can't getLatestChannelUpdateForNode for ${publicKey}. Reason ${e instanceof Error ? e.message : e}`); + } + return 0; + } } export default new ChannelsApi(); diff --git a/backend/src/tasks/lightning/network-sync.service.ts b/backend/src/tasks/lightning/network-sync.service.ts index 8d6d64d66..b9b7df92c 100644 --- a/backend/src/tasks/lightning/network-sync.service.ts +++ b/backend/src/tasks/lightning/network-sync.service.ts @@ -63,6 +63,9 @@ class NetworkSyncService { let deletedSockets = 0; const graphNodesPubkeys: string[] = []; for (const node of nodes) { + const latestUpdated = await channelsApi.$getLatestChannelUpdateForNode(node.pub_key); + node.last_update = Math.max(node.last_update, latestUpdated); + await nodesApi.$saveNode(node); graphNodesPubkeys.push(node.pub_key); ++progress;
First seenFirst seen
Last updateLast update
ColorColor
{{ node.color }}
ISPISP - + {{ node.as_organization }} [ASN {{node.as_number}}]