Commit 5d2e3ac1 authored by dev0tion's avatar dev0tion

Disable decrypt, create and recover button on api call

parent 58a60686
...@@ -20,6 +20,7 @@ export class LoginComponent implements OnInit { ...@@ -20,6 +20,7 @@ export class LoginComponent implements OnInit {
private openWalletForm: FormGroup; private openWalletForm: FormGroup;
private hasWallet: boolean = false; private hasWallet: boolean = false;
private wallets: [string]; private wallets: [string];
private isDecrypting = false;
ngOnInit() { ngOnInit() {
this.getWalletFiles(); this.getWalletFiles();
...@@ -112,6 +113,7 @@ export class LoginComponent implements OnInit { ...@@ -112,6 +113,7 @@ export class LoginComponent implements OnInit {
} }
private onDecryptClicked() { private onDecryptClicked() {
this.isDecrypting = true;
this.globalService.setWalletName(this.openWalletForm.get("selectWallet").value); this.globalService.setWalletName(this.openWalletForm.get("selectWallet").value);
let walletLoad = new WalletLoad( let walletLoad = new WalletLoad(
this.openWalletForm.get("selectWallet").value, this.openWalletForm.get("selectWallet").value,
...@@ -133,6 +135,7 @@ export class LoginComponent implements OnInit { ...@@ -133,6 +135,7 @@ export class LoginComponent implements OnInit {
} }
}, },
error => { error => {
this.isDecrypting = false;
if (error.status === 0) { if (error.status === 0) {
alert("Something went wrong while connecting to the API. Please restart the application."); alert("Something went wrong while connecting to the API. Please restart the application.");
} else if (error.status >= 400) { } else if (error.status >= 400) {
...@@ -159,6 +162,7 @@ export class LoginComponent implements OnInit { ...@@ -159,6 +162,7 @@ export class LoginComponent implements OnInit {
} }
}, },
error => { error => {
this.isDecrypting = false;
if (error.status === 0) { if (error.status === 0) {
alert("Something went wrong while connecting to the API. Please restart the application."); alert("Something went wrong while connecting to the API. Please restart the application.");
} else if (error.status >= 400) { } else if (error.status >= 400) {
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
</div> </div>
<!-- /row--> <!-- /row-->
<div class="row d-flex justify-content-center"> <div class="row d-flex justify-content-center">
<button type="button" class="btn btn-darkgray btn-lg" [disabled]="!createWalletForm.valid" (click)="onCreateClicked()">Create</button> <button type="button" class="btn btn-darkgray btn-lg" [disabled]="!createWalletForm.valid || isCreating" (click)="onCreateClicked()">Create</button>
</div> </div>
<!-- /row--> <!-- /row-->
</div> </div>
......
...@@ -24,6 +24,7 @@ export class CreateComponent implements OnInit { ...@@ -24,6 +24,7 @@ export class CreateComponent implements OnInit {
private createWalletForm: FormGroup; private createWalletForm: FormGroup;
private newWallet: WalletCreation; private newWallet: WalletCreation;
private mnemonic: string; private mnemonic: string;
private isCreating: Boolean = false;
ngOnInit() { ngOnInit() {
this.getNewMnemonic(); this.getNewMnemonic();
...@@ -99,6 +100,7 @@ export class CreateComponent implements OnInit { ...@@ -99,6 +100,7 @@ export class CreateComponent implements OnInit {
} }
private onCreateClicked() { private onCreateClicked() {
this.isCreating = true;
if (this.mnemonic) { if (this.mnemonic) {
this.newWallet = new WalletCreation( this.newWallet = new WalletCreation(
this.createWalletForm.get("walletName").value, this.createWalletForm.get("walletName").value,
...@@ -147,6 +149,7 @@ export class CreateComponent implements OnInit { ...@@ -147,6 +149,7 @@ export class CreateComponent implements OnInit {
}, },
error => { error => {
console.log(error); console.log(error);
this.isCreating = false;
if (error.status === 0) { if (error.status === 0) {
alert("Something went wrong while connecting to the API. Please restart the application."); alert("Something went wrong while connecting to the API. Please restart the application.");
} else if (error.status >= 400) { } else if (error.status >= 400) {
...@@ -174,6 +177,7 @@ export class CreateComponent implements OnInit { ...@@ -174,6 +177,7 @@ export class CreateComponent implements OnInit {
} }
}, },
error => { error => {
this.isCreating = false;
console.log(error); console.log(error);
if (error.status === 0) { if (error.status === 0) {
alert("Something went wrong while connecting to the API. Please restart the application."); alert("Something went wrong while connecting to the API. Please restart the application.");
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
</div> </div>
<!-- /row--> <!-- /row-->
<div class="row d-flex justify-content-center"> <div class="row d-flex justify-content-center">
<button type="button" class="btn btn-darkgray btn-lg" [disabled]="!recoverWalletForm.valid" (click)="onRecoverClicked()">Recover</button> <button type="button" class="btn btn-darkgray btn-lg" [disabled]="!recoverWalletForm.valid || isRecovering" (click)="onRecoverClicked()">Recover</button>
</div> </div>
<!-- /row--> <!-- /row-->
</div> </div>
......
...@@ -22,6 +22,7 @@ export class RecoverComponent implements OnInit { ...@@ -22,6 +22,7 @@ export class RecoverComponent implements OnInit {
private recoverWalletForm: FormGroup; private recoverWalletForm: FormGroup;
private creationDate: Date; private creationDate: Date;
private walletRecovery: WalletRecovery; private walletRecovery: WalletRecovery;
private isRecovering: Boolean = false;
private responseMessage: string; private responseMessage: string;
private errorMessage: string; private errorMessage: string;
...@@ -90,6 +91,7 @@ export class RecoverComponent implements OnInit { ...@@ -90,6 +91,7 @@ export class RecoverComponent implements OnInit {
} }
private onRecoverClicked(){ private onRecoverClicked(){
this.isRecovering = true;
this.walletRecovery = new WalletRecovery( this.walletRecovery = new WalletRecovery(
this.recoverWalletForm.get("walletName").value, this.recoverWalletForm.get("walletName").value,
this.recoverWalletForm.get("walletMnemonic").value, this.recoverWalletForm.get("walletMnemonic").value,
...@@ -110,6 +112,7 @@ export class RecoverComponent implements OnInit { ...@@ -110,6 +112,7 @@ export class RecoverComponent implements OnInit {
} }
}, },
error => { error => {
this.isRecovering = false;
console.log(error); console.log(error);
if (error.status === 0) { if (error.status === 0) {
alert("Something went wrong while connecting to the API. Please restart the application."); alert("Something went wrong while connecting to the API. Please restart the application.");
...@@ -139,6 +142,7 @@ export class RecoverComponent implements OnInit { ...@@ -139,6 +142,7 @@ export class RecoverComponent implements OnInit {
} }
}, },
error => { error => {
this.isRecovering = false;
console.log(error); console.log(error);
if (error.status === 0) { if (error.status === 0) {
alert("Something went wrong while connecting to the API. Please restart the application."); alert("Something went wrong while connecting to the API. Please restart the application.");
......
...@@ -108,10 +108,10 @@ export class SendComponent implements OnInit { ...@@ -108,10 +108,10 @@ export class SendComponent implements OnInit {
}, },
error => { error => {
console.log(error); console.log(error);
this.isSending = false;
if (error.status === 0) { if (error.status === 0) {
alert("Something went wrong while connecting to the API. Please restart the application."); alert("Something went wrong while connecting to the API. Please restart the application.");
} else if (error.status >= 400) { } else if (error.status >= 400) {
this.isSending = false;
if (!error.json().errors[0]) { if (!error.json().errors[0]) {
console.log(error); console.log(error);
} }
...@@ -150,10 +150,10 @@ export class SendComponent implements OnInit { ...@@ -150,10 +150,10 @@ export class SendComponent implements OnInit {
}, },
error => { error => {
console.log(error); console.log(error);
this.isSending = false;
if (error.status === 0) { if (error.status === 0) {
alert("Something went wrong while connecting to the API. Please restart the application."); alert("Something went wrong while connecting to the API. Please restart the application.");
} else if (error.status >= 400) { } else if (error.status >= 400) {
this.isSending = false;
if (!error.json().errors[0]) { if (!error.json().errors[0]) {
console.log(error); console.log(error);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment