Enable front end setting for zats

This commit is contained in:
Rene Vergara 2022-03-07 13:46:00 -06:00
parent 29a90b8614
commit 42dbd88e28
5 changed files with 22 additions and 6 deletions

View file

@ -1,3 +1,7 @@
.text { * {
font-family: 'Spartan', monospace; font-family: 'Spartan', sans-serif;
}
.mat-dialog-content {
max-width: 300px;
} }

View file

@ -13,6 +13,9 @@
</mat-option> </mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
<mat-slide-toggle formControlName="useZats" (change)="onChange($event)">
Display Zcash amount in zatoshis?
</mat-slide-toggle>
</mat-dialog-content> </mat-dialog-content>
<mat-dialog-actions> <mat-dialog-actions>

View file

@ -1,5 +1,6 @@
import { Inject, Component, OnInit, OnDestroy, ViewEncapsulation } from '@angular/core'; import { Inject, Component, OnInit, OnDestroy, ViewEncapsulation } from '@angular/core';
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { MatSlideToggleChange } from '@angular/material/slide-toggle';
import { FormBuilder, Validators, FormGroup, FormControl } from '@angular/forms'; import { FormBuilder, Validators, FormGroup, FormControl } from '@angular/forms';
import {User} from '../user.model'; import {User} from '../user.model';
import {Owner} from '../owner.model'; import {Owner} from '../owner.model';
@ -14,6 +15,7 @@ export class SettingsComponent implements OnInit {
settingsForm: FormGroup; settingsForm: FormGroup;
owner: Owner; owner: Owner;
useZats: boolean;
coins = [ coins = [
{ {
label: 'US Dollar', label: 'US Dollar',
@ -38,9 +40,11 @@ export class SettingsComponent implements OnInit {
private dialogRef: MatDialogRef<SettingsComponent>, private dialogRef: MatDialogRef<SettingsComponent>,
@Inject(MAT_DIALOG_DATA) public data: Owner @Inject(MAT_DIALOG_DATA) public data: Owner
) { ) {
this.useZats = data.zats;
this.settingsForm = fb.group({ this.settingsForm = fb.group({
name: [data.name, Validators.required], name: [data.name, Validators.required],
currency: [data.currency, Validators.required] currency: [data.currency, Validators.required],
useZats: [data.zats, Validators.required]
}); });
this.owner = data; this.owner = data;
} }
@ -55,6 +59,11 @@ export class SettingsComponent implements OnInit {
save() { save() {
this.owner.name = this.settingsForm.value.name; this.owner.name = this.settingsForm.value.name;
this.owner.currency = this.settingsForm.value.currency; this.owner.currency = this.settingsForm.value.currency;
this.owner.zats = this.useZats;
this.dialogRef.close(this.owner); this.dialogRef.close(this.owner);
} }
onChange(ob: MatSlideToggleChange) {
this.useZats = ob.checked;
}
} }

View file

@ -171,8 +171,8 @@ export class UserService{
this.http.post<{message: string, owner: Owner}>(this.beUrl+'api/updateowner', {owner: owner}, {headers: this.reqHeaders}). this.http.post<{message: string, owner: Owner}>(this.beUrl+'api/updateowner', {owner: owner}, {headers: this.reqHeaders}).
subscribe((responseData) => { subscribe((responseData) => {
console.log(responseData.message); console.log(responseData.message);
//this.dataStore.owner = responseData.owner; this.dataStore.owner = responseData.owner;
//this._ownerUpdated.next(Object.assign({},this.dataStore).owner); this._ownerUpdated.next(Object.assign({},this.dataStore).owner);
}); });
} }

View file

@ -121,7 +121,7 @@ export class ViewerComponent implements OnInit {
this.owner = owner; this.owner = owner;
this.userUpdate.subscribe((user) => { this.userUpdate.subscribe((user) => {
this.user = user; this.user = user;
console.log('Viewer loginCheck', this.user); //console.log('Viewer loginCheck', this.user);
if (!this.owner.paid || !this.user.validated || this.user.expired) { if (!this.owner.paid || !this.user.validated || this.user.expired) {
console.log('Log in expired!'); console.log('Log in expired!');
this.router.navigate(['/login']); this.router.navigate(['/login']);