From d23e5d0e87b5727cf8ae6d296add7c3ec4c7ddf8 Mon Sep 17 00:00:00 2001 From: softsimon Date: Fri, 6 May 2022 00:52:25 +0400 Subject: [PATCH] Node qr code --- .../clipboard/clipboard.component.scss | 5 +++++ .../app/components/qrcode/qrcode.component.ts | 16 ++++++++++++++-- .../src/app/lightning/node/node.component.html | 18 +++++++++++------- .../src/app/lightning/node/node.component.scss | 15 +++++++++++++++ .../src/app/lightning/node/node.component.ts | 4 ++++ 5 files changed, 49 insertions(+), 9 deletions(-) diff --git a/frontend/src/app/components/clipboard/clipboard.component.scss b/frontend/src/app/components/clipboard/clipboard.component.scss index 9483fef52..be173d821 100644 --- a/frontend/src/app/components/clipboard/clipboard.component.scss +++ b/frontend/src/app/components/clipboard/clipboard.component.scss @@ -1,3 +1,8 @@ .btn-link { padding: 0.25rem 0 0.1rem 0.5rem; } + +img { + position: relative; + left: -3px; +} \ No newline at end of file diff --git a/frontend/src/app/components/qrcode/qrcode.component.ts b/frontend/src/app/components/qrcode/qrcode.component.ts index 30c8a8362..07f2703fc 100644 --- a/frontend/src/app/components/qrcode/qrcode.component.ts +++ b/frontend/src/app/components/qrcode/qrcode.component.ts @@ -1,11 +1,12 @@ -import { Component, Input, AfterViewInit, ViewChild, ElementRef } from '@angular/core'; +import { Component, Input, AfterViewInit, ViewChild, ElementRef, ChangeDetectionStrategy } from '@angular/core'; import * as QRCode from 'qrcode'; import { StateService } from 'src/app/services/state.service'; @Component({ selector: 'app-qrcode', templateUrl: './qrcode.component.html', - styleUrls: ['./qrcode.component.scss'] + styleUrls: ['./qrcode.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class QrcodeComponent implements AfterViewInit { @Input() data: string; @@ -19,7 +20,18 @@ export class QrcodeComponent implements AfterViewInit { private stateService: StateService, ) { } + ngOnChanges() { + if (!this.canvas.nativeElement) { + return; + } + this.render(); + } + ngAfterViewInit() { + this.render(); + } + + render() { if (!this.stateService.isBrowser) { return; } diff --git a/frontend/src/app/lightning/node/node.component.html b/frontend/src/app/lightning/node/node.component.html index b573346d9..713cb2709 100644 --- a/frontend/src/app/lightning/node/node.component.html +++ b/frontend/src/app/lightning/node/node.component.html @@ -38,9 +38,7 @@
-
- -
+
@@ -48,9 +46,9 @@
-
-
- +
+
+
@@ -59,7 +57,13 @@ {{ node.socketsObject[selectedSocketIndex].label }} - +
diff --git a/frontend/src/app/lightning/node/node.component.scss b/frontend/src/app/lightning/node/node.component.scss index 5ff5de482..c3831ded9 100644 --- a/frontend/src/app/lightning/node/node.component.scss +++ b/frontend/src/app/lightning/node/node.component.scss @@ -3,6 +3,21 @@ padding: 10px; padding-bottom: 5px; display: inline-block; + + + position: absolute; + bottom: 50px; + left: -175px; + z-index: 100; +} + +.dropdownLabel { + min-width: 50px; + display: inline-block; +} + +#inputGroupFileAddon04 { + position: relative; } .qrcode-col { diff --git a/frontend/src/app/lightning/node/node.component.ts b/frontend/src/app/lightning/node/node.component.ts index 503cc1471..f3c0d6153 100644 --- a/frontend/src/app/lightning/node/node.component.ts +++ b/frontend/src/app/lightning/node/node.component.ts @@ -15,6 +15,7 @@ export class NodeComponent implements OnInit { statistics$: Observable; publicKey$: Observable; selectedSocketIndex = 0; + qrCodeVisible = false; constructor( private lightningApiService: LightningApiService, @@ -30,6 +31,9 @@ export class NodeComponent implements OnInit { map((node) => { const socketsObject = []; for (const socket of node.sockets.split(',')) { + if (socket === '') { + continue; + } let label = ''; if (socket.match(/(?:[0-9]{1,3}\.){3}[0-9]{1,3}/)) { label = 'IPv4';