Commit 380b60c0 authored by dev0tion's avatar dev0tion

Update login component to load Bitcoin and Stratis

parent 5403d689
......@@ -62,18 +62,43 @@ export class LoginComponent implements OnInit {
}
};
private updateWalletFileDisplay(walletName: string) {
this.openWalletForm.patchValue({selectWallet: walletName})
private getWalletFiles() {
this.apiService.getWalletFiles()
.subscribe(
response => {
if (response.status >= 200 && response.status < 400) {
let responseMessage = response.json();
this.wallets = responseMessage.walletsFiles;
this.globalService.setWalletPath(responseMessage.walletsPath);
if (this.wallets.length > 0) {
this.hasWallet = true;
for (let wallet in this.wallets) {
this.wallets[wallet] = this.wallets[wallet].slice(0, -12);
}
this.updateWalletFileDisplay(this.wallets[0]);
} else {
this.hasWallet = false;
}
}
},
error => {
if (error.status === 0) {
alert("Something went wrong while connecting to the API. Please restart the application.");
} else if (error.status >= 400) {
if (!error.json().errors[0]) {
console.log(error);
}
else {
alert(error.json().errors[0].message);
}
}
}
)
;
}
private onDecryptClicked() {
this.setGlobalWalletName(this.openWalletForm.get("selectWallet").value);
let walletLoad = new WalletLoad(
this.openWalletForm.get("password").value,
this.globalService.getWalletPath(),
this.openWalletForm.get("selectWallet").value
);
this.loadWallet(walletLoad);
private updateWalletFileDisplay(walletName: string) {
this.openWalletForm.patchValue({selectWallet: walletName})
}
private onCreateClicked() {
......@@ -86,27 +111,21 @@ export class LoginComponent implements OnInit {
}
}
private setGlobalWalletName(walletName: string) {
this.globalService.setWalletName(walletName);
private onDecryptClicked() {
this.globalService.setWalletName(this.openWalletForm.get("selectWallet").value);
let walletLoad = new WalletLoad(
this.openWalletForm.get("selectWallet").value,
this.openWalletForm.get("password").value
);
this.loadWallets(walletLoad);
}
private getWalletFiles() {
this.apiService.getWalletFiles()
private loadWallets(walletLoad: WalletLoad) {
this.apiService.loadBitcoinWallet(walletLoad)
.subscribe(
response => {
if (response.status >= 200 && response.status < 400) {
let responseMessage = response.json();
this.wallets = responseMessage.walletsFiles;
this.globalService.setWalletPath(responseMessage.walletsPath);
if (this.wallets.length > 0) {
this.hasWallet = true;
for (let wallet in this.wallets) {
this.wallets[wallet] = this.wallets[wallet].slice(0, -12);
}
this.updateWalletFileDisplay(this.wallets[0]);
} else {
this.hasWallet = false;
}
//Bitcoin wallet loaded
}
},
error => {
......@@ -123,14 +142,13 @@ export class LoginComponent implements OnInit {
}
)
;
}
private loadWallet(walletLoad: WalletLoad) {
this.apiService.loadWallet(walletLoad)
this.apiService.loadStratisWallet(walletLoad)
.subscribe(
response => {
if (response.status >= 200 && response.status < 400) {
this.globalService.setWalletName(walletLoad.name)
this.globalService.setCoinName("Bitcoin");
this.globalService.setWalletName(walletLoad.name);
this.globalService.setCoinType(1);
this.router.navigate(['/wallet']);
}
......
export class WalletLoad {
constructor(password: string, folderPath: string, name: string) {
constructor(name: string, password: string, folderPath: string = null ) {
this.name = name;
this.password = password;
this.folderPath = folderPath;
this.name = name;
}
public password: string;
public folderPath: string;
public name: string;
public password: string;
public folderPath?: string;
}
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