Commit be60ace9 authored by dev0tion's avatar dev0tion

Edit load function, navigate with status message

parent 3cc77262
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { ApiService } from '../shared/api/api.service'; import { ApiService } from '../shared/api/api.service';
import { WalletLoad } from '../shared/wallet-load';
@Component({ @Component({
selector: 'app-login', selector: 'app-login',
...@@ -10,27 +11,34 @@ import { ApiService } from '../shared/api/api.service'; ...@@ -10,27 +11,34 @@ import { ApiService } from '../shared/api/api.service';
export class LoginComponent implements OnInit { export class LoginComponent implements OnInit {
constructor(private apiService: ApiService, private router: Router) { } constructor(private apiService: ApiService, private router: Router) { }
private response: any; private responseMessage: any;
private errorMessage: string; private errorMessage: any;
private walletLoad: WalletLoad;
ngOnInit() { ngOnInit() {
} }
private onSubmit() { private onSubmit() {
this.apiService.loadWallet("123") this.walletLoad = new WalletLoad();
this.walletLoad.password = "123";
this.walletLoad.name = "test"
this.walletLoad.folderPath = "folderPath"
this.apiService.loadWallet(this.walletLoad)
.subscribe( .subscribe(
response => this.response = response, response => {
error => this.errorMessage = error, if (response.status === 200) {
() => this.loadWallet() this.responseMessage = response;
this.router.navigate['/wallet']
}
},
error => {
this.errorMessage = <any>error;
if (error.status === 400) {
alert(this.errorMessage);
console.log(this.errorMessage);
}
}
); );
} }
}
private loadWallet() { \ No newline at end of file
if (this.response.success === "true") {
this.router.navigate(['/wallet/send']);
} else {
alert("Something went wrong.")
}
}
}
...@@ -6,6 +6,7 @@ import 'rxjs/add/operator/catch'; ...@@ -6,6 +6,7 @@ import 'rxjs/add/operator/catch';
import { WalletCreation } from '../wallet-creation'; import { WalletCreation } from '../wallet-creation';
import { WalletRecovery } from '../wallet-recovery'; import { WalletRecovery } from '../wallet-recovery';
import { WalletLoad } from '../wallet-load';
import { Mnemonic } from '../mnemonic'; import { Mnemonic } from '../mnemonic';
/** /**
...@@ -41,9 +42,9 @@ export class ApiService { ...@@ -41,9 +42,9 @@ export class ApiService {
/** /**
* Load a wallet * Load a wallet
*/ */
loadWallet(password: string): Observable<any> { loadWallet(data: WalletLoad): Observable<any> {
return this.http return this.http
.get(this.webApiUrl + '/wallet/load/', {headers: this.headers, body: JSON.stringify(password)}) .get(this.webApiUrl + '/wallet/load/', {headers: this.headers, body: JSON.stringify(data)})
.map(response => response.json()) .map(response => response.json())
.catch(this.handleError); .catch(this.handleError);
} }
......
export class WalletLoad {
password: string;
folderPath: string;
name: string;
}
\ No newline at end of file
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