Commit be60ace9 authored by dev0tion's avatar dev0tion

Edit load function, navigate with status message

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