Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="d-flex align-content-center flex-wrap">
<form class="mx-auto d-flex align-content-center flex-wrap" [formGroup]="mnemonicForm">
<form class="mx-auto d-flex align-content-center flex-wrap" [formGroup]="mnemonicForm" (ngSubmit)="onConfirmClicked()">
<div class="form-group col-12">
<label for="word1">{{secretWordIndexGenerator.text1}}</label>
<input type="text" class="form-control" formControlName="word1" id="word1" #words appFocusable (keydown.tab)="focusNext($event)" [class.is-invalid]="formErrors.word1" [class.is-valid]="!formErrors.word1 && mnemonicForm.get('word1').valid" pInputText>
Expand All @@ -20,7 +20,7 @@
<!-- /form-group -->
<div *ngIf="matchError" class="text-danger">{{ matchError }}</div>
<div class="modal-footer col-12">
<button *ngIf="!isCreating" type="button" pButton [disabled]="!mnemonicForm.valid || isCreating" (click)="onConfirmClicked()" label="Confirm" class="btn-block"></button>
<button *ngIf="!isCreating" type="submit" pButton [disabled]="!mnemonicForm.valid || isCreating" label="Confirm" class="btn-block"></button>
<!-- SVG -->
<div *ngIf="isCreating" [className]="isDarkTheme ? 'LoadingWhite' : 'Loading'" class="col-2 mx-auto unset-left" style="padding: 30px;">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="30px" height="30px" viewBox="0 0 300 300" enable-background="new 0 0 300 300" xml:space="preserve">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ export class ConfirmMnemonicComponent implements OnInit {
}

public onConfirmClicked() {
this.checkMnemonic();
if (this.mnemonicForm.invalid || this.isCreating) {
return;
}

if (this.checkMnemonic()) {
this.isCreating = true;
this.createWallet(this.newWallet);
Expand Down
4 changes: 2 additions & 2 deletions xCore.UI/src/app/setup/create/create.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</div>

<div class="formrow">
<form class="mx-auto d-flex align-content-center flex-wrap" [formGroup]="createWalletForm" *ngIf="!walletCreated">
<form class="mx-auto d-flex align-content-center flex-wrap" [formGroup]="createWalletForm" (ngSubmit)="onContinueClicked()" *ngIf="!walletCreated">
<div class="form-group col-12">
<label for="walletName">Name</label>
<input type="text" class="form-control" [class.is-invalid]="formErrors.walletName" [class.is-valid]="!formErrors.walletName && createWalletForm.get('walletName').valid" formControlName="walletName" id="walletName" placeholder="Enter a wallet name." pInputText>
Expand Down Expand Up @@ -40,7 +40,7 @@
</div>
</div>
<div class="modal-footer col-12">
<button pButton type="button" class="btn-block" label="Create {{createWalletForm.get('walletName').value}} wallet" [disabled]="!createWalletForm.valid" (click)="onContinueClicked()"></button>
<button pButton type="submit" class="btn-block" label="Create {{createWalletForm.get('walletName').value}} wallet" [disabled]="!createWalletForm.valid"></button>
</div>
</form>
<div class="modal-footer col-12">
Expand Down
15 changes: 13 additions & 2 deletions xCore.UI/src/app/setup/create/create.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { Component, OnInit, Input, Output, EventEmitter, HostListener } from '@angular/core';
import { FormGroup, Validators, FormBuilder } from '@angular/forms';
import { Router } from '@angular/router';
import { ApiService } from '../../shared/services/api.service';
Expand Down Expand Up @@ -120,8 +120,19 @@ export class CreateComponent implements OnInit {
this.ref.close();
}

@HostListener('document:keydown.enter', ['$event'])
public onEnterPressed(event: KeyboardEvent) {
if (this.displayMnemonic) {
event.preventDefault();
this.continueMnemonic();
} else if (this.walletCreated) {
event.preventDefault();
this.onClose();
}
}

public onContinueClicked() {
if (this.mnemonic) {
if (this.mnemonic && this.createWalletForm.valid) {
this.newWallet = new WalletCreation(
this.createWalletForm.get('walletName').value,
this.mnemonic,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, AfterViewInit, ElementRef, ViewChild } from '@angular/core';
import { Component, OnInit, AfterViewInit, ElementRef, ViewChild, HostListener } from '@angular/core';
import { DynamicDialogRef, DynamicDialogConfig } from 'primeng/dynamicdialog';

@Component({
Expand Down Expand Up @@ -26,4 +26,10 @@ export class GenericModalComponent implements OnInit, AfterViewInit {
this.focusElement.nativeElement.focus();
}, 0);
}

@HostListener('document:keydown.enter', ['$event'])
public onEnterPressed(event: KeyboardEvent) {
event.preventDefault();
this.ref.close('Close click');
}
}
2 changes: 1 addition & 1 deletion xCore.UI/src/app/wallet/receive/receive.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,6 @@
</div>
</div>
<div class="modal-footer">
<button *ngIf="!isPriceLock" type="button" class="btn-block" (click)="ref.close('Close click')" label="OK" pButton></button>
<button *ngIf="!isPriceLock" type="button" class="btn-block" (click)="ref.close('Close click')" label="OK" #closeButton pButton></button>
</div>
<!-- /MODAL RECEIVE -->
14 changes: 12 additions & 2 deletions xCore.UI/src/app/wallet/receive/receive.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { ElectronService } from 'ngx-electron';
import { ApiService } from '../../shared/services/api.service';
import { GlobalService } from '../../shared/services/global.service';
Expand All @@ -17,7 +17,7 @@ import { PriceLockUtil } from '../../shared/models/pricelockutil';
templateUrl: './receive.component.html',
styleUrls: ['./receive.component.css'],
})
export class ReceiveComponent implements OnInit {
export class ReceiveComponent implements OnInit, AfterViewInit {
constructor(
private apiService: ApiService,
private globalService: GlobalService,
Expand Down Expand Up @@ -63,6 +63,8 @@ export class ReceiveComponent implements OnInit {
public showAbout: boolean;
public errorMessage: string;

@ViewChild('closeButton') focusElement: ElementRef;

ngOnInit() {
this.getPairs();
this.getUnusedReceiveAddresses();
Expand All @@ -80,6 +82,14 @@ export class ReceiveComponent implements OnInit {
this.priceLockForm.patchValue({ blockExpire: 45 });
}

ngAfterViewInit() {
setTimeout(() => {
if (this.focusElement) {
this.focusElement.nativeElement.focus();
}
}, 0);
}

private buildCreatePLForm(): void {
this.priceLockForm = this.fb.group({
pair: [],
Expand Down