From a5098c9b9875e8515c5e5cdcb4712c866b8f2082 Mon Sep 17 00:00:00 2001 From: Rowan de Haas Date: Wed, 13 Mar 2019 16:56:21 +1100 Subject: [PATCH 01/17] Add coin unit selection component --- .../coin-unit/coin-unit.component.css | 0 .../coin-unit/coin-unit.component.html | 3 +++ .../coin-unit/coin-unit.component.spec.ts | 25 +++++++++++++++++++ .../coin-unit/coin-unit.component.ts | 15 +++++++++++ .../src/app/wallet/wallet.module.ts | 4 ++- 5 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.css create mode 100644 StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.html create mode 100644 StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.spec.ts create mode 100644 StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.ts diff --git a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.css b/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.css new file mode 100644 index 00000000..e69de29b diff --git a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.html b/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.html new file mode 100644 index 00000000..f6d3001a --- /dev/null +++ b/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.html @@ -0,0 +1,3 @@ +

+ coin-unit works! +

diff --git a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.spec.ts b/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.spec.ts new file mode 100644 index 00000000..215c4623 --- /dev/null +++ b/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CoinUnitComponent } from './coin-unit.component'; + +describe('CoinUnitComponent', () => { + let component: CoinUnitComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ CoinUnitComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CoinUnitComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.ts b/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.ts new file mode 100644 index 00000000..79a7fc2c --- /dev/null +++ b/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-coin-unit', + templateUrl: './coin-unit.component.html', + styleUrls: ['./coin-unit.component.css'] +}) +export class CoinUnitComponent implements OnInit { + + constructor() { } + + ngOnInit() { + } + +} diff --git a/StratisCore.UI/src/app/wallet/wallet.module.ts b/StratisCore.UI/src/app/wallet/wallet.module.ts index ed6f107e..7e8d8f26 100644 --- a/StratisCore.UI/src/app/wallet/wallet.module.ts +++ b/StratisCore.UI/src/app/wallet/wallet.module.ts @@ -22,6 +22,7 @@ import { SendConfirmationComponent } from './send/send-confirmation/send-confirm import { TransactionDetailsComponent } from './transaction-details/transaction-details.component'; import { LogoutConfirmationComponent } from './logout-confirmation/logout-confirmation.component'; import { BsDatepickerModule } from 'ngx-bootstrap'; +import { CoinUnitComponent } from './advanced/components/coin-unit/coin-unit.component'; @NgModule({ imports: [ @@ -48,7 +49,8 @@ import { BsDatepickerModule } from 'ngx-bootstrap'; ExtPubkeyComponent, AboutComponent, GenerateAddressesComponent, - ResyncComponent + ResyncComponent, + CoinUnitComponent ], entryComponents: [ SendComponent, From 1bfcdd3c70eeb9c0ba07d24267c8b1f403dab02a Mon Sep 17 00:00:00 2001 From: Rowan de Haas Date: Wed, 13 Mar 2019 16:57:44 +1100 Subject: [PATCH 02/17] Add route --- .../src/app/wallet/advanced/advanced.component.html | 3 +++ StratisCore.UI/src/app/wallet/wallet-routing.module.ts | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/StratisCore.UI/src/app/wallet/advanced/advanced.component.html b/StratisCore.UI/src/app/wallet/advanced/advanced.component.html index ae380467..1f96cb3c 100644 --- a/StratisCore.UI/src/app/wallet/advanced/advanced.component.html +++ b/StratisCore.UI/src/app/wallet/advanced/advanced.component.html @@ -22,6 +22,9 @@ + diff --git a/StratisCore.UI/src/app/wallet/wallet-routing.module.ts b/StratisCore.UI/src/app/wallet/wallet-routing.module.ts index 1e5d5c69..3d82b369 100644 --- a/StratisCore.UI/src/app/wallet/wallet-routing.module.ts +++ b/StratisCore.UI/src/app/wallet/wallet-routing.module.ts @@ -11,6 +11,7 @@ import { ExtPubkeyComponent } from './advanced/components/ext-pubkey/ext-pubkey. import { AboutComponent } from './advanced/components/about/about.component'; import { GenerateAddressesComponent } from './advanced/components/generate-addresses/generate-addresses.component'; import { ResyncComponent } from './advanced/components/resync/resync.component'; +import { CoinUnitComponent } from './advanced/components/coin-unit/coin-unit.component'; const routes: Routes = [ { path: 'wallet', component: WalletComponent, children: [ @@ -24,7 +25,8 @@ const routes: Routes = [ { path: 'about', component: AboutComponent}, { path: 'extpubkey', component: ExtPubkeyComponent}, { path: 'generate-addresses', component: GenerateAddressesComponent}, - { path: 'resync', component: ResyncComponent} + { path: 'resync', component: ResyncComponent}, + { path: 'coin-unit', component: CoinUnitComponent} ] }, { path: 'smart-contracts', component: SmartContractsComponent }, From a35f6c0ce5e67e3b4fb01db822519dc1b125df5a Mon Sep 17 00:00:00 2001 From: Rowan de Haas Date: Wed, 13 Mar 2019 17:21:31 +1100 Subject: [PATCH 03/17] Add basic UI --- .../coin-unit/coin-unit.component.html | 21 ++++++++++++++++--- .../coin-unit/coin-unit.component.ts | 11 ++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.html b/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.html index f6d3001a..c898e2e0 100644 --- a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.html +++ b/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.html @@ -1,3 +1,18 @@ -

- coin-unit works! -

+
+
Change Coin Unit
+
+
+
+ Change: +
+
+
+ +
+ 1 Strat = {{ 1 | coinNotation }} {{ unit }} +
+
+
+
diff --git a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.ts b/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.ts index 79a7fc2c..58888480 100644 --- a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.ts +++ b/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.ts @@ -1,4 +1,5 @@ import { Component, OnInit } from '@angular/core'; +import { FormGroup } from '@angular/forms'; @Component({ selector: 'app-coin-unit', @@ -9,6 +10,16 @@ export class CoinUnitComponent implements OnInit { constructor() { } + private selectCoinUnitForm: FormGroup; + + units = [ + 'STRAT', + 'mSTRAT', + 'uSTRAT', + ] + + unit: string; + ngOnInit() { } From 145b9c4ad8151a5df38d4d16a71001c04370a546 Mon Sep 17 00:00:00 2001 From: Rowan de Haas Date: Wed, 13 Mar 2019 18:56:50 +1100 Subject: [PATCH 04/17] Add basic base unit selection --- .../app/shared/pipes/coin-notation.pipe.ts | 4 +- .../src/app/shared/services/global.service.ts | 40 +++++++++++++++++++ .../coin-unit/coin-unit.component.html | 10 ++--- .../coin-unit/coin-unit.component.ts | 27 +++++++++---- .../send-confirmation.component.ts | 4 +- .../src/app/wallet/send/send.component.ts | 2 +- 6 files changed, 68 insertions(+), 19 deletions(-) diff --git a/StratisCore.UI/src/app/shared/pipes/coin-notation.pipe.ts b/StratisCore.UI/src/app/shared/pipes/coin-notation.pipe.ts index d8a93dde..c22aa37a 100644 --- a/StratisCore.UI/src/app/shared/pipes/coin-notation.pipe.ts +++ b/StratisCore.UI/src/app/shared/pipes/coin-notation.pipe.ts @@ -8,10 +8,10 @@ export class CoinNotationPipe implements PipeTransform { private decimalLimit = 8; - transform(value: number): number { + transform(value: number, multiple: number = 100000000): number { let temp; if (typeof value === 'number') { - temp = value / 100000000; + temp = value / multiple; return temp.toFixed(this.decimalLimit); } } diff --git a/StratisCore.UI/src/app/shared/services/global.service.ts b/StratisCore.UI/src/app/shared/services/global.service.ts index 19355556..a112a778 100644 --- a/StratisCore.UI/src/app/shared/services/global.service.ts +++ b/StratisCore.UI/src/app/shared/services/global.service.ts @@ -25,6 +25,15 @@ export class GlobalService { private coinUnit: string; private network: string; + // Base units relative to sats + private baseUnits = [ + new BaseUnit('', 100000000), // BTC = 100,000,000 sats + new BaseUnit('m', 100000), // mBTC = 100,000 sats + new BaseUnit('μ', 100), // μBTC = 100 sats + new BaseUnit('sats', 1) // Defaults are in sats + ]; + + private baseUnit: BaseUnit = this.baseUnits[0]; // Default to COIN getApplicationVersion() { return this.applicationVersion; @@ -105,4 +114,35 @@ export class GlobalService { setCoinUnit(coinUnit: string) { this.coinUnit = coinUnit; } + + getBaseUnit() { + return this.baseUnit; + } + + setBaseUnit(baseUnit: BaseUnit) { + console.log("Set baseunit"); + console.log(baseUnit); + //localStorage.setItem('baseUnit', JSON.stringify(baseUnit)); + this.baseUnit = baseUnit; + } + + getBaseUnits() { + return this.baseUnits; + } +} + +export class BaseUnit { + constructor(public name: string, public multiple: number) {} + + addCoinUnit(unit: string): BaseUnit { + + // Some base units look funny with a prefix + if (this.name === 'sats') { + return this; + } + + let newName = this.name + unit; + + return new BaseUnit(newName, this.multiple); + } } diff --git a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.html b/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.html index c898e2e0..31170d86 100644 --- a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.html +++ b/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.html @@ -6,12 +6,10 @@ Change:
-
- -
- 1 Strat = {{ 1 | coinNotation }} {{ unit }} + + 1 Strat = {{ 100000000 | coinNotation:selectedCoinUnit.multiple }} {{ selectedCoinUnit.name }}
diff --git a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.ts b/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.ts index 58888480..bff75368 100644 --- a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.ts +++ b/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { FormGroup } from '@angular/forms'; +import { GlobalService, BaseUnit } from '../../../../shared/services/global.service'; @Component({ selector: 'app-coin-unit', @@ -7,20 +8,30 @@ import { FormGroup } from '@angular/forms'; styleUrls: ['./coin-unit.component.css'] }) export class CoinUnitComponent implements OnInit { + coinUnit: string; + baseUnits: BaseUnit[]; + units: BaseUnit[]; - constructor() { } + constructor(private globalService: GlobalService) { + this.coinUnit = this.globalService.getCoinUnit(); + this.selectedCoinUnit = this.globalService.getBaseUnit(); + this.baseUnits = this.globalService.getBaseUnits(); - private selectCoinUnitForm: FormGroup; + // Map to our own baseunit + coinunit suffix eg. mSTRAT + this.units = this.baseUnits.map(b => b.addCoinUnit(this.coinUnit)); + console.log(this.units); + } - units = [ - 'STRAT', - 'mSTRAT', - 'uSTRAT', - ] + private selectCoinUnitForm: FormGroup; - unit: string; + selectedCoinUnit: BaseUnit; ngOnInit() { } + onBaseUnitChanged() + { + this.globalService.setBaseUnit(this.selectedCoinUnit); + } + } diff --git a/StratisCore.UI/src/app/wallet/send/send-confirmation/send-confirmation.component.ts b/StratisCore.UI/src/app/wallet/send/send-confirmation/send-confirmation.component.ts index 20addbf1..bdc57682 100644 --- a/StratisCore.UI/src/app/wallet/send/send-confirmation/send-confirmation.component.ts +++ b/StratisCore.UI/src/app/wallet/send/send-confirmation/send-confirmation.component.ts @@ -25,9 +25,9 @@ export class SendConfirmationComponent implements OnInit { ngOnInit() { this.coinUnit = this.globalService.getCoinUnit(); - this.transactionFee = new CoinNotationPipe().transform(this.transactionFee); + this.transactionFee = new CoinNotationPipe(this.globalService).transform(this.transactionFee); if (this.hasOpReturn) { - this.opReturnAmount = new CoinNotationPipe().transform(this.opReturnAmount); + this.opReturnAmount = new CoinNotationPipe(this.globalService).transform(this.opReturnAmount); this.transaction.amount = +this.transaction.recipients[0].amount + +this.transactionFee + +this.opReturnAmount; } else { this.transaction.amount = +this.transaction.recipients[0].amount + +this.transactionFee; diff --git a/StratisCore.UI/src/app/wallet/send/send.component.ts b/StratisCore.UI/src/app/wallet/send/send.component.ts index f0cdebb5..2a576a6a 100644 --- a/StratisCore.UI/src/app/wallet/send/send.component.ts +++ b/StratisCore.UI/src/app/wallet/send/send.component.ts @@ -212,7 +212,7 @@ export class SendComponent implements OnInit, OnDestroy { this.apiError = error.error.errors[0].message; }, () => { - this.sendForm.patchValue({amount: +new CoinNotationPipe().transform(balanceResponse.maxSpendableAmount)}); + this.sendForm.patchValue({amount: +new CoinNotationPipe(this.globalService).transform(balanceResponse.maxSpendableAmount)}); this.estimatedFee = balanceResponse.fee; } ) From e7251b490d73fbb1beabb7853c42199dcd337fb4 Mon Sep 17 00:00:00 2001 From: Rowan de Haas Date: Wed, 13 Mar 2019 19:01:05 +1100 Subject: [PATCH 05/17] Add coins component --- .../src/app/shared/coins/coins.component.css | 0 .../src/app/shared/coins/coins.component.html | 3 +++ .../app/shared/coins/coins.component.spec.ts | 25 +++++++++++++++++++ .../src/app/shared/coins/coins.component.ts | 15 +++++++++++ .../app/shared/pipes/coin-notation.pipe.ts | 7 +++--- .../src/app/shared/shared.module.ts | 3 ++- 6 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 StratisCore.UI/src/app/shared/coins/coins.component.css create mode 100644 StratisCore.UI/src/app/shared/coins/coins.component.html create mode 100644 StratisCore.UI/src/app/shared/coins/coins.component.spec.ts create mode 100644 StratisCore.UI/src/app/shared/coins/coins.component.ts diff --git a/StratisCore.UI/src/app/shared/coins/coins.component.css b/StratisCore.UI/src/app/shared/coins/coins.component.css new file mode 100644 index 00000000..e69de29b diff --git a/StratisCore.UI/src/app/shared/coins/coins.component.html b/StratisCore.UI/src/app/shared/coins/coins.component.html new file mode 100644 index 00000000..21b7b180 --- /dev/null +++ b/StratisCore.UI/src/app/shared/coins/coins.component.html @@ -0,0 +1,3 @@ +

+ coins works! +

diff --git a/StratisCore.UI/src/app/shared/coins/coins.component.spec.ts b/StratisCore.UI/src/app/shared/coins/coins.component.spec.ts new file mode 100644 index 00000000..3a4b3fed --- /dev/null +++ b/StratisCore.UI/src/app/shared/coins/coins.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CoinsComponent } from './coins.component'; + +describe('CoinsComponent', () => { + let component: CoinsComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ CoinsComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CoinsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/StratisCore.UI/src/app/shared/coins/coins.component.ts b/StratisCore.UI/src/app/shared/coins/coins.component.ts new file mode 100644 index 00000000..c4ea92f4 --- /dev/null +++ b/StratisCore.UI/src/app/shared/coins/coins.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-coins', + templateUrl: './coins.component.html', + styleUrls: ['./coins.component.css'] +}) +export class CoinsComponent implements OnInit { + + constructor() { } + + ngOnInit() { + } + +} diff --git a/StratisCore.UI/src/app/shared/pipes/coin-notation.pipe.ts b/StratisCore.UI/src/app/shared/pipes/coin-notation.pipe.ts index c22aa37a..553b1e24 100644 --- a/StratisCore.UI/src/app/shared/pipes/coin-notation.pipe.ts +++ b/StratisCore.UI/src/app/shared/pipes/coin-notation.pipe.ts @@ -1,17 +1,18 @@ import { Pipe, PipeTransform } from '@angular/core'; +import { GlobalService } from '../services/global.service'; @Pipe({ name: 'coinNotation' }) export class CoinNotationPipe implements PipeTransform { - constructor() { } + constructor(private globalService: GlobalService) { } private decimalLimit = 8; transform(value: number, multiple: number = 100000000): number { - let temp; + let temp; if (typeof value === 'number') { - temp = value / multiple; + temp = value / this.globalService.getBaseUnit().multiple; return temp.toFixed(this.decimalLimit); } } diff --git a/StratisCore.UI/src/app/shared/shared.module.ts b/StratisCore.UI/src/app/shared/shared.module.ts index a53cca50..3d2d237d 100644 --- a/StratisCore.UI/src/app/shared/shared.module.ts +++ b/StratisCore.UI/src/app/shared/shared.module.ts @@ -10,10 +10,11 @@ import { NgxPaginationModule } from 'ngx-pagination'; import { ClipboardModule } from 'ngx-clipboard'; import { ReactiveFormsModule, FormsModule } from '@angular/forms'; import { GenericModalComponent } from './components/generic-modal/generic-modal.component'; +import { CoinsComponent } from './coins/coins.component'; @NgModule({ imports: [ CommonModule ], - declarations: [ CoinNotationPipe, AutoFocusDirective, PasswordValidationDirective, GenericModalComponent ], + declarations: [ CoinNotationPipe, AutoFocusDirective, PasswordValidationDirective, GenericModalComponent, CoinsComponent ], exports: [ CommonModule, ReactiveFormsModule, FormsModule, NgbModule, NgxElectronModule, NgxQRCodeModule, NgxPaginationModule, ClipboardModule, GenericModalComponent, CoinNotationPipe, AutoFocusDirective, PasswordValidationDirective ], entryComponents: [ GenericModalComponent ] }) From bab1a41135c0262edccf87f524670e02130e11e9 Mon Sep 17 00:00:00 2001 From: Rowan de Haas Date: Wed, 13 Mar 2019 19:07:07 +1100 Subject: [PATCH 06/17] Use coinunit --- .../src/app/shared/coins/coins.component.ts | 19 ++++++++++++++----- .../src/app/shared/shared.module.ts | 2 +- .../coin-unit/coin-unit.component.html | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/StratisCore.UI/src/app/shared/coins/coins.component.ts b/StratisCore.UI/src/app/shared/coins/coins.component.ts index c4ea92f4..41cd8b49 100644 --- a/StratisCore.UI/src/app/shared/coins/coins.component.ts +++ b/StratisCore.UI/src/app/shared/coins/coins.component.ts @@ -1,13 +1,22 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, Input } from '@angular/core'; +import { GlobalService, BaseUnit } from '../services/global.service'; @Component({ - selector: 'app-coins', - templateUrl: './coins.component.html', - styleUrls: ['./coins.component.css'] + selector: 'coins', + template: ` + {{ (amount | coinNotation:baseUnit.multiplier) | number : '1.2' }} {{ baseUnit.name }} + ` }) export class CoinsComponent implements OnInit { - constructor() { } + @Input() + amount: number = 0; + baseUnit: BaseUnit; + + constructor(private globalService: GlobalService) { + this.baseUnit = globalService.getBaseUnit(); + console.log(this.baseUnit); + } ngOnInit() { } diff --git a/StratisCore.UI/src/app/shared/shared.module.ts b/StratisCore.UI/src/app/shared/shared.module.ts index 3d2d237d..f375f581 100644 --- a/StratisCore.UI/src/app/shared/shared.module.ts +++ b/StratisCore.UI/src/app/shared/shared.module.ts @@ -15,7 +15,7 @@ import { CoinsComponent } from './coins/coins.component'; @NgModule({ imports: [ CommonModule ], declarations: [ CoinNotationPipe, AutoFocusDirective, PasswordValidationDirective, GenericModalComponent, CoinsComponent ], - exports: [ CommonModule, ReactiveFormsModule, FormsModule, NgbModule, NgxElectronModule, NgxQRCodeModule, NgxPaginationModule, ClipboardModule, GenericModalComponent, CoinNotationPipe, AutoFocusDirective, PasswordValidationDirective ], + exports: [ CommonModule, ReactiveFormsModule, FormsModule, NgbModule, NgxElectronModule, NgxQRCodeModule, NgxPaginationModule, ClipboardModule, GenericModalComponent, CoinNotationPipe, AutoFocusDirective, PasswordValidationDirective, CoinsComponent ], entryComponents: [ GenericModalComponent ] }) diff --git a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.html b/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.html index 31170d86..8a814813 100644 --- a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.html +++ b/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.html @@ -9,7 +9,7 @@ - 1 Strat = {{ 100000000 | coinNotation:selectedCoinUnit.multiple }} {{ selectedCoinUnit.name }} + 1 Strat = From 040aef42d82538f2f0af6fb490ec6550aacae901 Mon Sep 17 00:00:00 2001 From: Rowan de Haas Date: Wed, 13 Mar 2019 19:34:28 +1100 Subject: [PATCH 07/17] Make observable --- StratisCore.UI/src/app/shared/BaseUnit.ts | 3 ++ .../src/app/shared/coins/coins.component.html | 3 -- .../src/app/shared/coins/coins.component.ts | 13 +++++---- .../app/shared/pipes/coin-notation.pipe.ts | 5 ++-- .../src/app/shared/services/global.service.ts | 29 ++++--------------- .../coin-unit/coin-unit.component.html | 2 +- .../coin-unit/coin-unit.component.ts | 21 +++++++------- .../send-confirmation.component.ts | 4 +-- .../src/app/wallet/send/send.component.ts | 2 +- 9 files changed, 32 insertions(+), 50 deletions(-) create mode 100644 StratisCore.UI/src/app/shared/BaseUnit.ts delete mode 100644 StratisCore.UI/src/app/shared/coins/coins.component.html diff --git a/StratisCore.UI/src/app/shared/BaseUnit.ts b/StratisCore.UI/src/app/shared/BaseUnit.ts new file mode 100644 index 00000000..53e69adf --- /dev/null +++ b/StratisCore.UI/src/app/shared/BaseUnit.ts @@ -0,0 +1,3 @@ +export class BaseUnit { + constructor(public name: string, public multiple: number) { } +} \ No newline at end of file diff --git a/StratisCore.UI/src/app/shared/coins/coins.component.html b/StratisCore.UI/src/app/shared/coins/coins.component.html deleted file mode 100644 index 21b7b180..00000000 --- a/StratisCore.UI/src/app/shared/coins/coins.component.html +++ /dev/null @@ -1,3 +0,0 @@ -

- coins works! -

diff --git a/StratisCore.UI/src/app/shared/coins/coins.component.ts b/StratisCore.UI/src/app/shared/coins/coins.component.ts index 41cd8b49..ef0da414 100644 --- a/StratisCore.UI/src/app/shared/coins/coins.component.ts +++ b/StratisCore.UI/src/app/shared/coins/coins.component.ts @@ -1,21 +1,24 @@ import { Component, OnInit, Input } from '@angular/core'; -import { GlobalService, BaseUnit } from '../services/global.service'; +import { GlobalService } from '../services/global.service'; +import { BaseUnit } from "../BaseUnit"; +import { Subject } from 'rxjs'; @Component({ selector: 'coins', template: ` - {{ (amount | coinNotation:baseUnit.multiplier) | number : '1.2' }} {{ baseUnit.name }} + {{ amount | coinNotation:(baseUnit | async)?.multiple }} {{ this.coinUnit }} ` }) export class CoinsComponent implements OnInit { @Input() amount: number = 0; - baseUnit: BaseUnit; + baseUnit: Subject; + coinUnit: string; constructor(private globalService: GlobalService) { - this.baseUnit = globalService.getBaseUnit(); - console.log(this.baseUnit); + this.baseUnit = this.globalService.baseUnit; + this.coinUnit = this.globalService.getCoinUnit(); } ngOnInit() { diff --git a/StratisCore.UI/src/app/shared/pipes/coin-notation.pipe.ts b/StratisCore.UI/src/app/shared/pipes/coin-notation.pipe.ts index 553b1e24..ca9fba2d 100644 --- a/StratisCore.UI/src/app/shared/pipes/coin-notation.pipe.ts +++ b/StratisCore.UI/src/app/shared/pipes/coin-notation.pipe.ts @@ -1,18 +1,17 @@ import { Pipe, PipeTransform } from '@angular/core'; -import { GlobalService } from '../services/global.service'; @Pipe({ name: 'coinNotation' }) export class CoinNotationPipe implements PipeTransform { - constructor(private globalService: GlobalService) { } + constructor() { } private decimalLimit = 8; transform(value: number, multiple: number = 100000000): number { let temp; if (typeof value === 'number') { - temp = value / this.globalService.getBaseUnit().multiple; + temp = value / multiple; return temp.toFixed(this.decimalLimit); } } diff --git a/StratisCore.UI/src/app/shared/services/global.service.ts b/StratisCore.UI/src/app/shared/services/global.service.ts index a112a778..54dbe4fe 100644 --- a/StratisCore.UI/src/app/shared/services/global.service.ts +++ b/StratisCore.UI/src/app/shared/services/global.service.ts @@ -1,5 +1,8 @@ import {Injectable} from "@angular/core"; import { ElectronService } from 'ngx-electron'; +import { BehaviorSubject } from "rxjs"; +import { take } from "rxjs/operators"; +import { BaseUnit } from "../BaseUnit"; @Injectable({ providedIn: 'root' @@ -33,7 +36,7 @@ export class GlobalService { new BaseUnit('sats', 1) // Defaults are in sats ]; - private baseUnit: BaseUnit = this.baseUnits[0]; // Default to COIN + public baseUnit: BehaviorSubject = new BehaviorSubject(this.baseUnits[0]); getApplicationVersion() { return this.applicationVersion; @@ -115,34 +118,12 @@ export class GlobalService { this.coinUnit = coinUnit; } - getBaseUnit() { - return this.baseUnit; - } - setBaseUnit(baseUnit: BaseUnit) { - console.log("Set baseunit"); - console.log(baseUnit); //localStorage.setItem('baseUnit', JSON.stringify(baseUnit)); - this.baseUnit = baseUnit; + this.baseUnit.next(baseUnit); } getBaseUnits() { return this.baseUnits; } } - -export class BaseUnit { - constructor(public name: string, public multiple: number) {} - - addCoinUnit(unit: string): BaseUnit { - - // Some base units look funny with a prefix - if (this.name === 'sats') { - return this; - } - - let newName = this.name + unit; - - return new BaseUnit(newName, this.multiple); - } -} diff --git a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.html b/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.html index 8a814813..2818a543 100644 --- a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.html +++ b/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.html @@ -7,7 +7,7 @@
1 Strat =
diff --git a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.ts b/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.ts index bff75368..bab825cb 100644 --- a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.ts +++ b/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit } from '@angular/core'; -import { FormGroup } from '@angular/forms'; -import { GlobalService, BaseUnit } from '../../../../shared/services/global.service'; +import { GlobalService } from '../../../../shared/services/global.service'; +import { BaseUnit } from '../../../../shared/BaseUnit'; +import { take } from 'rxjs/operators'; @Component({ selector: 'app-coin-unit', @@ -13,24 +14,22 @@ export class CoinUnitComponent implements OnInit { units: BaseUnit[]; constructor(private globalService: GlobalService) { + // Set the initial value + this.globalService.baseUnit.pipe(take(1)).subscribe(b => { + this.selectedCoinUnit = b; + }); + this.coinUnit = this.globalService.getCoinUnit(); - this.selectedCoinUnit = this.globalService.getBaseUnit(); this.baseUnits = this.globalService.getBaseUnits(); - - // Map to our own baseunit + coinunit suffix eg. mSTRAT - this.units = this.baseUnits.map(b => b.addCoinUnit(this.coinUnit)); - console.log(this.units); + this.units = this.baseUnits; } - private selectCoinUnitForm: FormGroup; - selectedCoinUnit: BaseUnit; ngOnInit() { } - onBaseUnitChanged() - { + onBaseUnitChanged() { this.globalService.setBaseUnit(this.selectedCoinUnit); } diff --git a/StratisCore.UI/src/app/wallet/send/send-confirmation/send-confirmation.component.ts b/StratisCore.UI/src/app/wallet/send/send-confirmation/send-confirmation.component.ts index bdc57682..20addbf1 100644 --- a/StratisCore.UI/src/app/wallet/send/send-confirmation/send-confirmation.component.ts +++ b/StratisCore.UI/src/app/wallet/send/send-confirmation/send-confirmation.component.ts @@ -25,9 +25,9 @@ export class SendConfirmationComponent implements OnInit { ngOnInit() { this.coinUnit = this.globalService.getCoinUnit(); - this.transactionFee = new CoinNotationPipe(this.globalService).transform(this.transactionFee); + this.transactionFee = new CoinNotationPipe().transform(this.transactionFee); if (this.hasOpReturn) { - this.opReturnAmount = new CoinNotationPipe(this.globalService).transform(this.opReturnAmount); + this.opReturnAmount = new CoinNotationPipe().transform(this.opReturnAmount); this.transaction.amount = +this.transaction.recipients[0].amount + +this.transactionFee + +this.opReturnAmount; } else { this.transaction.amount = +this.transaction.recipients[0].amount + +this.transactionFee; diff --git a/StratisCore.UI/src/app/wallet/send/send.component.ts b/StratisCore.UI/src/app/wallet/send/send.component.ts index 2a576a6a..f0cdebb5 100644 --- a/StratisCore.UI/src/app/wallet/send/send.component.ts +++ b/StratisCore.UI/src/app/wallet/send/send.component.ts @@ -212,7 +212,7 @@ export class SendComponent implements OnInit, OnDestroy { this.apiError = error.error.errors[0].message; }, () => { - this.sendForm.patchValue({amount: +new CoinNotationPipe(this.globalService).transform(balanceResponse.maxSpendableAmount)}); + this.sendForm.patchValue({amount: +new CoinNotationPipe().transform(balanceResponse.maxSpendableAmount)}); this.estimatedFee = balanceResponse.fee; } ) From 6c8d73d25d32d36c12d51731da9d3462172731f5 Mon Sep 17 00:00:00 2001 From: Rowan de Haas Date: Wed, 13 Mar 2019 19:45:11 +1100 Subject: [PATCH 08/17] Create prefixed coin unit pipe --- .../src/app/shared/coins/coins.component.ts | 2 +- .../shared/pipes/prefix-coin-unit.pipe.spec.ts | 8 ++++++++ .../src/app/shared/pipes/prefix-coin-unit.pipe.ts | 15 +++++++++++++++ StratisCore.UI/src/app/shared/shared.module.ts | 5 +++-- .../components/coin-unit/coin-unit.component.html | 2 +- .../components/coin-unit/coin-unit.component.ts | 2 -- 6 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 StratisCore.UI/src/app/shared/pipes/prefix-coin-unit.pipe.spec.ts create mode 100644 StratisCore.UI/src/app/shared/pipes/prefix-coin-unit.pipe.ts diff --git a/StratisCore.UI/src/app/shared/coins/coins.component.ts b/StratisCore.UI/src/app/shared/coins/coins.component.ts index ef0da414..141f0adf 100644 --- a/StratisCore.UI/src/app/shared/coins/coins.component.ts +++ b/StratisCore.UI/src/app/shared/coins/coins.component.ts @@ -6,7 +6,7 @@ import { Subject } from 'rxjs'; @Component({ selector: 'coins', template: ` - {{ amount | coinNotation:(baseUnit | async)?.multiple }} {{ this.coinUnit }} + {{ amount | coinNotation:(baseUnit | async)?.multiple }} {{ this.coinUnit|prefixCoinUnit:(baseUnit | async)?.name }} ` }) export class CoinsComponent implements OnInit { diff --git a/StratisCore.UI/src/app/shared/pipes/prefix-coin-unit.pipe.spec.ts b/StratisCore.UI/src/app/shared/pipes/prefix-coin-unit.pipe.spec.ts new file mode 100644 index 00000000..23bca749 --- /dev/null +++ b/StratisCore.UI/src/app/shared/pipes/prefix-coin-unit.pipe.spec.ts @@ -0,0 +1,8 @@ +import { PrefixCoinUnitPipe } from './prefix-coin-unit.pipe'; + +describe('PrefixCoinUnitPipe', () => { + it('create an instance', () => { + const pipe = new PrefixCoinUnitPipe(); + expect(pipe).toBeTruthy(); + }); +}); diff --git a/StratisCore.UI/src/app/shared/pipes/prefix-coin-unit.pipe.ts b/StratisCore.UI/src/app/shared/pipes/prefix-coin-unit.pipe.ts new file mode 100644 index 00000000..7af8c960 --- /dev/null +++ b/StratisCore.UI/src/app/shared/pipes/prefix-coin-unit.pipe.ts @@ -0,0 +1,15 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'prefixCoinUnit' +}) +export class PrefixCoinUnitPipe implements PipeTransform { + + transform(value: string, baseUnit: string): any { + if (baseUnit === 'sats') { + return baseUnit; + } + + return baseUnit + value; + } +} diff --git a/StratisCore.UI/src/app/shared/shared.module.ts b/StratisCore.UI/src/app/shared/shared.module.ts index f375f581..862a0ebc 100644 --- a/StratisCore.UI/src/app/shared/shared.module.ts +++ b/StratisCore.UI/src/app/shared/shared.module.ts @@ -11,11 +11,12 @@ import { ClipboardModule } from 'ngx-clipboard'; import { ReactiveFormsModule, FormsModule } from '@angular/forms'; import { GenericModalComponent } from './components/generic-modal/generic-modal.component'; import { CoinsComponent } from './coins/coins.component'; +import { PrefixCoinUnitPipe } from './pipes/prefix-coin-unit.pipe'; @NgModule({ imports: [ CommonModule ], - declarations: [ CoinNotationPipe, AutoFocusDirective, PasswordValidationDirective, GenericModalComponent, CoinsComponent ], - exports: [ CommonModule, ReactiveFormsModule, FormsModule, NgbModule, NgxElectronModule, NgxQRCodeModule, NgxPaginationModule, ClipboardModule, GenericModalComponent, CoinNotationPipe, AutoFocusDirective, PasswordValidationDirective, CoinsComponent ], + declarations: [ CoinNotationPipe, AutoFocusDirective, PasswordValidationDirective, GenericModalComponent, CoinsComponent, PrefixCoinUnitPipe ], + exports: [ CommonModule, ReactiveFormsModule, FormsModule, NgbModule, NgxElectronModule, NgxQRCodeModule, NgxPaginationModule, ClipboardModule, GenericModalComponent, CoinNotationPipe, AutoFocusDirective, PasswordValidationDirective, CoinsComponent, PrefixCoinUnitPipe ], entryComponents: [ GenericModalComponent ] }) diff --git a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.html b/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.html index 2818a543..c5f1c53a 100644 --- a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.html +++ b/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.html @@ -7,7 +7,7 @@
1 Strat =
diff --git a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.ts b/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.ts index bab825cb..dff7d56c 100644 --- a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.ts +++ b/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.ts @@ -11,7 +11,6 @@ import { take } from 'rxjs/operators'; export class CoinUnitComponent implements OnInit { coinUnit: string; baseUnits: BaseUnit[]; - units: BaseUnit[]; constructor(private globalService: GlobalService) { // Set the initial value @@ -21,7 +20,6 @@ export class CoinUnitComponent implements OnInit { this.coinUnit = this.globalService.getCoinUnit(); this.baseUnits = this.globalService.getBaseUnits(); - this.units = this.baseUnits; } selectedCoinUnit: BaseUnit; From ee9cec88eb1314acb179d7f8558403316e8da196 Mon Sep 17 00:00:00 2001 From: Rowan de Haas Date: Wed, 13 Mar 2019 20:26:24 +1100 Subject: [PATCH 09/17] Add showUnit --- StratisCore.UI/src/app/shared/coins/coins.component.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/StratisCore.UI/src/app/shared/coins/coins.component.ts b/StratisCore.UI/src/app/shared/coins/coins.component.ts index 141f0adf..c0c16a9f 100644 --- a/StratisCore.UI/src/app/shared/coins/coins.component.ts +++ b/StratisCore.UI/src/app/shared/coins/coins.component.ts @@ -6,13 +6,17 @@ import { Subject } from 'rxjs'; @Component({ selector: 'coins', template: ` - {{ amount | coinNotation:(baseUnit | async)?.multiple }} {{ this.coinUnit|prefixCoinUnit:(baseUnit | async)?.name }} + {{ amount | coinNotation:(baseUnit | async)?.multiple }} {{ this.coinUnit|prefixCoinUnit:(baseUnit | async)?.name }} ` }) export class CoinsComponent implements OnInit { @Input() amount: number = 0; + + @Input() + showUnit: boolean = true; + baseUnit: Subject; coinUnit: string; From 88889e8fb452141a69f4468d5629aae303a62a77 Mon Sep 17 00:00:00 2001 From: Rowan de Haas Date: Wed, 13 Mar 2019 20:26:55 +1100 Subject: [PATCH 10/17] Show formatted coins almost everywhere --- .../src/app/shared/services/global.service.ts | 12 ++++++++++-- .../app/wallet/dashboard/dashboard.component.html | 10 +++++----- .../src/app/wallet/dashboard/dashboard.component.ts | 6 +++++- .../src/app/wallet/history/history.component.html | 6 +++--- .../src/app/wallet/send/send.component.html | 10 +++++----- .../transaction-details.component.html | 10 +++++----- .../transaction-details.component.ts | 7 ++++++- 7 files changed, 39 insertions(+), 22 deletions(-) diff --git a/StratisCore.UI/src/app/shared/services/global.service.ts b/StratisCore.UI/src/app/shared/services/global.service.ts index 54dbe4fe..7917c5a3 100644 --- a/StratisCore.UI/src/app/shared/services/global.service.ts +++ b/StratisCore.UI/src/app/shared/services/global.service.ts @@ -1,7 +1,7 @@ import {Injectable} from "@angular/core"; import { ElectronService } from 'ngx-electron'; -import { BehaviorSubject } from "rxjs"; -import { take } from "rxjs/operators"; +import { BehaviorSubject, Observable } from "rxjs"; +import { take, map } from "rxjs/operators"; import { BaseUnit } from "../BaseUnit"; @Injectable({ @@ -38,6 +38,14 @@ export class GlobalService { public baseUnit: BehaviorSubject = new BehaviorSubject(this.baseUnits[0]); + public formattedBaseUnit: Observable = this.baseUnit.pipe(map(baseUnit => { + if (baseUnit.name === 'sats') { + return baseUnit.name; + } + + return baseUnit.name + this.coinUnit; + })); + getApplicationVersion() { return this.applicationVersion; } diff --git a/StratisCore.UI/src/app/wallet/dashboard/dashboard.component.html b/StratisCore.UI/src/app/wallet/dashboard/dashboard.component.html index c2579299..b0313f2a 100644 --- a/StratisCore.UI/src/app/wallet/dashboard/dashboard.component.html +++ b/StratisCore.UI/src/app/wallet/dashboard/dashboard.component.html @@ -8,12 +8,12 @@
Spendable balance

- {{ (confirmedBalance | coinNotation) || (0 | coinNotation) }} + {{ coinUnit }}

    -
  • {{ (unconfirmedBalance | coinNotation) || (0 | coinNotation) }} (unconfirmed)
  • +
  • (unconfirmed)
@@ -66,9 +66,9 @@
Spendable balance
{{ transaction.transactionType }} - - {{ transaction.transactionAmount + transaction.transactionFee | coinNotation }} {{ coinUnit }} - + {{ transaction.transactionAmount + transaction.transactionFee | coinNotation }} {{ coinUnit }} - + {{ transaction.transactionAmount + transaction.transactionFee | coinNotation }} {{ coinUnit }} + - + + + + {{ transaction.transactionTimestamp * 1000 | date:'medium' }} details diff --git a/StratisCore.UI/src/app/wallet/dashboard/dashboard.component.ts b/StratisCore.UI/src/app/wallet/dashboard/dashboard.component.ts index 34563c9a..9a922486 100644 --- a/StratisCore.UI/src/app/wallet/dashboard/dashboard.component.ts +++ b/StratisCore.UI/src/app/wallet/dashboard/dashboard.component.ts @@ -50,7 +50,11 @@ export class DashboardComponent implements OnInit, OnDestroy { ngOnInit() { this.sidechainEnabled = this.globalService.getSidechainEnabled(); this.walletName = this.globalService.getWalletName(); - this.coinUnit = this.globalService.getCoinUnit(); + + this.globalService.formattedBaseUnit + .pipe(takeUntil(this.destroyed$)) + .subscribe(baseUnit => this.coinUnit = baseUnit); + this.refreshData(); }; diff --git a/StratisCore.UI/src/app/wallet/history/history.component.html b/StratisCore.UI/src/app/wallet/history/history.component.html index 95ed1b1b..9e95c052 100644 --- a/StratisCore.UI/src/app/wallet/history/history.component.html +++ b/StratisCore.UI/src/app/wallet/history/history.component.html @@ -16,9 +16,9 @@ {{ transaction.transactionType }} - - {{ transaction.transactionAmount + transaction.transactionFee | coinNotation }} {{ coinUnit }} - + {{ transaction.transactionAmount + transaction.transactionFee | coinNotation }} {{ coinUnit }} - + {{ transaction.transactionAmount + transaction.transactionFee | coinNotation }} {{ coinUnit }} + - + + + + {{ transaction.transactionTimestamp * 1000 | date:'medium' }} details diff --git a/StratisCore.UI/src/app/wallet/send/send.component.html b/StratisCore.UI/src/app/wallet/send/send.component.html index 96397f5f..e37ee49b 100644 --- a/StratisCore.UI/src/app/wallet/send/send.component.html +++ b/StratisCore.UI/src/app/wallet/send/send.component.html @@ -18,7 +18,7 @@
- +
{{ sendFormErrors.amount }}
@@ -33,7 +33,7 @@
Please enter a valid amount and destination address to calculate the fee. - +
- +
{{ sendToSidechainFormErrors.amount }}
@@ -107,7 +107,7 @@
Please enter a valid amount, federation and destination address to calculate the fee. - +
From bfa1436ed3f09fb1e997c697252d43338912e271 Mon Sep 17 00:00:00 2001 From: Rowan de Haas Date: Wed, 13 Mar 2019 21:09:28 +1100 Subject: [PATCH 15/17] Store in localstorage --- .../src/app/shared/services/global.service.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/StratisCore.UI/src/app/shared/services/global.service.ts b/StratisCore.UI/src/app/shared/services/global.service.ts index 8909f329..82a3accd 100644 --- a/StratisCore.UI/src/app/shared/services/global.service.ts +++ b/StratisCore.UI/src/app/shared/services/global.service.ts @@ -13,6 +13,15 @@ export class GlobalService { this.setSidechainEnabled(); this.setTestnetEnabled(); this.setApiPort(); + + // Store by name so we can match the object and populate the settings list correctly. + let storedBaseUnitName = localStorage.getItem('baseUnit'); + + if (storedBaseUnitName) { + let baseUnit = this.baseUnits.find(b => b.name === storedBaseUnitName); + if (baseUnit) + this.baseUnit.next(baseUnit); + } } private applicationVersion: string = "1.0.0"; @@ -127,7 +136,7 @@ export class GlobalService { } setBaseUnit(baseUnit: BaseUnit) { - //localStorage.setItem('baseUnit', JSON.stringify(baseUnit)); + localStorage.setItem('baseUnit', baseUnit.name); this.baseUnit.next(baseUnit); } From b4de4348c646d262df90a329086475680eff8c32 Mon Sep 17 00:00:00 2001 From: Rowan de Haas Date: Thu, 14 Mar 2019 11:08:45 +1100 Subject: [PATCH 16/17] Rename to baseunit --- .../app/wallet/advanced/advanced.component.html | 2 +- .../base-unit.component.css} | 0 .../base-unit.component.html} | 4 ++-- .../base-unit.component.spec.ts} | 12 ++++++------ .../base-unit.component.ts} | 14 +++++++------- .../src/app/wallet/wallet-routing.module.ts | 4 ++-- StratisCore.UI/src/app/wallet/wallet.module.ts | 4 ++-- 7 files changed, 20 insertions(+), 20 deletions(-) rename StratisCore.UI/src/app/wallet/advanced/components/{coin-unit/coin-unit.component.css => base-unit/base-unit.component.css} (100%) rename StratisCore.UI/src/app/wallet/advanced/components/{coin-unit/coin-unit.component.html => base-unit/base-unit.component.html} (84%) rename StratisCore.UI/src/app/wallet/advanced/components/{coin-unit/coin-unit.component.spec.ts => base-unit/base-unit.component.spec.ts} (55%) rename StratisCore.UI/src/app/wallet/advanced/components/{coin-unit/coin-unit.component.ts => base-unit/base-unit.component.ts} (67%) diff --git a/StratisCore.UI/src/app/wallet/advanced/advanced.component.html b/StratisCore.UI/src/app/wallet/advanced/advanced.component.html index 1f96cb3c..6d95fafe 100644 --- a/StratisCore.UI/src/app/wallet/advanced/advanced.component.html +++ b/StratisCore.UI/src/app/wallet/advanced/advanced.component.html @@ -23,7 +23,7 @@ Rescan Wallet diff --git a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.css b/StratisCore.UI/src/app/wallet/advanced/components/base-unit/base-unit.component.css similarity index 100% rename from StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.css rename to StratisCore.UI/src/app/wallet/advanced/components/base-unit/base-unit.component.css diff --git a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.html b/StratisCore.UI/src/app/wallet/advanced/components/base-unit/base-unit.component.html similarity index 84% rename from StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.html rename to StratisCore.UI/src/app/wallet/advanced/components/base-unit/base-unit.component.html index c5f1c53a..ecdd9055 100644 --- a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.html +++ b/StratisCore.UI/src/app/wallet/advanced/components/base-unit/base-unit.component.html @@ -1,12 +1,12 @@
-
Change Coin Unit
+
Change Base Unit
Change:
- 1 Strat = diff --git a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.spec.ts b/StratisCore.UI/src/app/wallet/advanced/components/base-unit/base-unit.component.spec.ts similarity index 55% rename from StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.spec.ts rename to StratisCore.UI/src/app/wallet/advanced/components/base-unit/base-unit.component.spec.ts index 215c4623..cdc68d06 100644 --- a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.spec.ts +++ b/StratisCore.UI/src/app/wallet/advanced/components/base-unit/base-unit.component.spec.ts @@ -1,20 +1,20 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { CoinUnitComponent } from './coin-unit.component'; +import { BaseUnitComponent } from './base-unit.component'; -describe('CoinUnitComponent', () => { - let component: CoinUnitComponent; - let fixture: ComponentFixture; +describe('BaseUnitComponent', () => { + let component: BaseUnitComponent; + let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ CoinUnitComponent ] + declarations: [ BaseUnitComponent ] }) .compileComponents(); })); beforeEach(() => { - fixture = TestBed.createComponent(CoinUnitComponent); + fixture = TestBed.createComponent(BaseUnitComponent); component = fixture.componentInstance; fixture.detectChanges(); }); diff --git a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.ts b/StratisCore.UI/src/app/wallet/advanced/components/base-unit/base-unit.component.ts similarity index 67% rename from StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.ts rename to StratisCore.UI/src/app/wallet/advanced/components/base-unit/base-unit.component.ts index dff7d56c..c61578fc 100644 --- a/StratisCore.UI/src/app/wallet/advanced/components/coin-unit/coin-unit.component.ts +++ b/StratisCore.UI/src/app/wallet/advanced/components/base-unit/base-unit.component.ts @@ -4,31 +4,31 @@ import { BaseUnit } from '../../../../shared/BaseUnit'; import { take } from 'rxjs/operators'; @Component({ - selector: 'app-coin-unit', - templateUrl: './coin-unit.component.html', - styleUrls: ['./coin-unit.component.css'] + selector: 'app-base-unit', + templateUrl: './base-unit.component.html', + styleUrls: ['./base-unit.component.css'] }) -export class CoinUnitComponent implements OnInit { +export class BaseUnitComponent implements OnInit { coinUnit: string; baseUnits: BaseUnit[]; constructor(private globalService: GlobalService) { // Set the initial value this.globalService.baseUnit.pipe(take(1)).subscribe(b => { - this.selectedCoinUnit = b; + this.selectedBaseUnit = b; }); this.coinUnit = this.globalService.getCoinUnit(); this.baseUnits = this.globalService.getBaseUnits(); } - selectedCoinUnit: BaseUnit; + selectedBaseUnit: BaseUnit; ngOnInit() { } onBaseUnitChanged() { - this.globalService.setBaseUnit(this.selectedCoinUnit); + this.globalService.setBaseUnit(this.selectedBaseUnit); } } diff --git a/StratisCore.UI/src/app/wallet/wallet-routing.module.ts b/StratisCore.UI/src/app/wallet/wallet-routing.module.ts index 3d82b369..41fb1e50 100644 --- a/StratisCore.UI/src/app/wallet/wallet-routing.module.ts +++ b/StratisCore.UI/src/app/wallet/wallet-routing.module.ts @@ -11,7 +11,7 @@ import { ExtPubkeyComponent } from './advanced/components/ext-pubkey/ext-pubkey. import { AboutComponent } from './advanced/components/about/about.component'; import { GenerateAddressesComponent } from './advanced/components/generate-addresses/generate-addresses.component'; import { ResyncComponent } from './advanced/components/resync/resync.component'; -import { CoinUnitComponent } from './advanced/components/coin-unit/coin-unit.component'; +import { BaseUnitComponent } from './advanced/components/base-unit/base-unit.component'; const routes: Routes = [ { path: 'wallet', component: WalletComponent, children: [ @@ -26,7 +26,7 @@ const routes: Routes = [ { path: 'extpubkey', component: ExtPubkeyComponent}, { path: 'generate-addresses', component: GenerateAddressesComponent}, { path: 'resync', component: ResyncComponent}, - { path: 'coin-unit', component: CoinUnitComponent} + { path: 'base-unit', component: BaseUnitComponent} ] }, { path: 'smart-contracts', component: SmartContractsComponent }, diff --git a/StratisCore.UI/src/app/wallet/wallet.module.ts b/StratisCore.UI/src/app/wallet/wallet.module.ts index 7e8d8f26..94f4c306 100644 --- a/StratisCore.UI/src/app/wallet/wallet.module.ts +++ b/StratisCore.UI/src/app/wallet/wallet.module.ts @@ -22,7 +22,7 @@ import { SendConfirmationComponent } from './send/send-confirmation/send-confirm import { TransactionDetailsComponent } from './transaction-details/transaction-details.component'; import { LogoutConfirmationComponent } from './logout-confirmation/logout-confirmation.component'; import { BsDatepickerModule } from 'ngx-bootstrap'; -import { CoinUnitComponent } from './advanced/components/coin-unit/coin-unit.component'; +import { BaseUnitComponent } from './advanced/components/base-unit/base-unit.component'; @NgModule({ imports: [ @@ -50,7 +50,7 @@ import { CoinUnitComponent } from './advanced/components/coin-unit/coin-unit.com AboutComponent, GenerateAddressesComponent, ResyncComponent, - CoinUnitComponent + BaseUnitComponent ], entryComponents: [ SendComponent, From c00bf088533663b7f903eb32384e7db91ddc86b2 Mon Sep 17 00:00:00 2001 From: Rowan de Haas Date: Thu, 14 Mar 2019 11:10:33 +1100 Subject: [PATCH 17/17] Change text --- .../advanced/components/base-unit/base-unit.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StratisCore.UI/src/app/wallet/advanced/components/base-unit/base-unit.component.html b/StratisCore.UI/src/app/wallet/advanced/components/base-unit/base-unit.component.html index ecdd9055..da392393 100644 --- a/StratisCore.UI/src/app/wallet/advanced/components/base-unit/base-unit.component.html +++ b/StratisCore.UI/src/app/wallet/advanced/components/base-unit/base-unit.component.html @@ -3,7 +3,7 @@
- Change: + Base Unit: