From 8e09842f8316c7370ca1e3c951808cdcaad84ddd Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Thu, 14 Jul 2022 14:04:04 -0500 Subject: [PATCH 1/3] Refactor item list to reduce server calls --- src/app/items/item-list/item-list.component.html | 4 ++-- src/app/items/item-list/item-list.component.ts | 13 +++++-------- src/app/viewer/viewer.component.html | 2 +- src/app/viewer/viewer.component.ts | 6 ++++++ 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/app/items/item-list/item-list.component.html b/src/app/items/item-list/item-list.component.html index cb1cd22..5e8f976 100644 --- a/src/app/items/item-list/item-list.component.html +++ b/src/app/items/item-list/item-list.component.html @@ -6,8 +6,8 @@ {{item.name}}

{{item.cost | currency: getCurrency() }}

-

{{(item.cost/price) | number: '1.0-6'}}

-

ⓩ {{(item.cost/price)*100000000 | number: '1.0-0'}}

+

{{(item.cost/zecPrice) | number: '1.0-6'}}

+

ⓩ {{(item.cost/zecPrice)*100000000 | number: '1.0-0'}}

diff --git a/src/app/items/item-list/item-list.component.ts b/src/app/items/item-list/item-list.component.ts index 71343c9..edc7136 100644 --- a/src/app/items/item-list/item-list.component.ts +++ b/src/app/items/item-list/item-list.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, Input } from '@angular/core'; import { MatDialog, MatDialogConfig} from '@angular/material/dialog'; import { Observable } from 'rxjs'; import { Item } from '../item.model'; @@ -19,6 +19,10 @@ import { ItemAddComponent } from '../item-add/item-add.component'; }) export class ItemListComponent implements OnInit{ + + @Input() + zecPrice: number = 1; + public items: Item[] = []; owner: Owner = { _id: '', @@ -45,10 +49,8 @@ export class ItemListComponent implements OnInit{ expiration: new Date(Date.now()).toISOString(), viewkey: '' }; - public price: number = 1; public ownerUpdate: Observable; public itemsUpdate: Observable; - public priceUpdate: Observable; constructor( public itemService: ItemService, @@ -59,18 +61,13 @@ export class ItemListComponent implements OnInit{ ) { this.ownerUpdate = userService.ownerUpdate; this.itemsUpdate = itemService.itemsUpdated; - this.priceUpdate = fullnodeService.priceUpdate; this.ownerUpdate.subscribe((owner) => { this.owner = owner; - fullnodeService.getPrice(this.owner.currency); itemService.getItems(this.owner.address); this.itemsUpdate.subscribe((items) => { this.items = items; }); }); - this.priceUpdate.subscribe((price) => { - this.price = price; - }); } ngOnInit(){ diff --git a/src/app/viewer/viewer.component.html b/src/app/viewer/viewer.component.html index aa272e5..6172894 100644 --- a/src/app/viewer/viewer.component.html +++ b/src/app/viewer/viewer.component.html @@ -14,7 +14,7 @@
- +
diff --git a/src/app/viewer/viewer.component.ts b/src/app/viewer/viewer.component.ts index 5056177..420dfb0 100644 --- a/src/app/viewer/viewer.component.ts +++ b/src/app/viewer/viewer.component.ts @@ -52,9 +52,11 @@ export class ViewerComponent implements OnInit { expiration: new Date(Date.now()).toISOString(), viewkey: '' }; + public price: number = 1; public addrUpdate: Observable; public ownerUpdate: Observable; public userUpdate: Observable; + public priceUpdate: Observable; orientation: boolean = false; constructor( @@ -65,6 +67,7 @@ export class ViewerComponent implements OnInit { ){ this.addrUpdate = fullnodeService.addrUpdate; this.ownerUpdate = userService.ownerUpdate; + this.priceUpdate = fullnodeService.priceUpdate; this.ownerUpdate.subscribe((owner) => { this.owner = owner; }); @@ -72,6 +75,9 @@ export class ViewerComponent implements OnInit { this.userUpdate.subscribe((user) => { this.user = user; }); + this.priceUpdate.subscribe((price) => { + this.price = price; + }); } ngOnInit(){ From 4aa7cbf7c28e9bc9b4aa752f1ad08a685f9def63 Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Thu, 14 Jul 2022 15:37:56 -0500 Subject: [PATCH 2/3] Use new price variable --- src/app/items/item-list/item-list.component.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/items/item-list/item-list.component.html b/src/app/items/item-list/item-list.component.html index 993d0e6..f88eb92 100644 --- a/src/app/items/item-list/item-list.component.html +++ b/src/app/items/item-list/item-list.component.html @@ -23,10 +23,10 @@
{{(item.cost/price) | number: '1.06'}} + height="16px">{{(item.cost/zecPrice) | number: '1.06'}} [{{item.cost | number: '1.02' | currency: getCurrency() }}]
-

ⓩ(item.cost/price)*100000000 | number: '1.0-0'}}

+

ⓩ(item.cost/zecPrice)*100000000 | number: '1.0-0'}}

From 51993a21a821f360bca54f2e2ffd989fedd4d782 Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Thu, 14 Jul 2022 15:44:53 -0500 Subject: [PATCH 3/3] Remove unused file --- server.js | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 server.js diff --git a/server.js b/server.js deleted file mode 100644 index ab46055..0000000 --- a/server.js +++ /dev/null @@ -1,19 +0,0 @@ -var fs = require('fs'); -var http = require('http'); -//var https = require('https'); - -//var certificate = fs.readFileSync('/etc/letsencrypt/live/zgo.cash/fullchain.pem'); -//var privateKey = fs.readFileSync('/etc/letsencrypt/live/zgo.cash/privkey.pem'); - -//var credentials = {key: privateKey, cert: certificate}; - -const app = require('./backend/app'); -const port = 3000; - -app.set('port', port); - -const httpServer = http.createServer(app); -//const httpsServer = https.createServer(credentials, app); - -httpServer.listen(port); -//httpsServer.listen(port);