Commit cb88292e authored by dev0tion's avatar dev0tion

Enable wallet loading

parent d6de1a0f
<h1>Welcome back</h1> <h1>Welcome to Breeze</h1>
<div *ngIf="hasWallet"> <div *ngIf="hasWallet">
<p>Choose the wallet you want to open:</p> <p>Choose the wallet you want to open:</p>
<div class="form-group"> <div class="form-group">
<label for="walletLabel">Wallet to open:</label> <label for="walletLabel">Wallet to open:</label>
<select name="wallet" #walletName> <select name="wallet" #walletName (change)="walletChanged(walletName.value)">
<option *ngFor="let wallet of wallets">{{wallet}}</option> <option *ngFor="let wallet of wallets" [value]="wallet">{{wallet}}</option>
</select> </select>
</div> </div>
<p>Please enter your password to decrypt your wallet</p> <p>Please enter your password to decrypt your wallet</p>
...@@ -17,5 +17,11 @@ ...@@ -17,5 +17,11 @@
</form> </form>
<p></p> <p></p>
</div> </div>
<p> If you like to create or restore a wallet please click the button below.</p> <div *ngIf="hasWallet;else no_wallet">
<p> If you like to create or restore a wallet please click the button below.</p>
</div>
<ng-template #no_wallet>
<p> Looks like you're new here. Please create or restore a wallet.</p>
</ng-template>
<button type="button" (click)="clickedCreate()" class="btn btn-success">Create or restore wallet</button> <button type="button" (click)="clickedCreate()" class="btn btn-success">Create or restore wallet</button>
\ No newline at end of file
...@@ -13,6 +13,7 @@ export class LoginComponent implements OnInit { ...@@ -13,6 +13,7 @@ export class LoginComponent implements OnInit {
private walletLoad: WalletLoad; private walletLoad: WalletLoad;
private hasWallet: boolean = false; private hasWallet: boolean = false;
private currentWalletName: string;
private wallets: [any]; private wallets: [any];
private walletPath: string; private walletPath: string;
...@@ -21,6 +22,7 @@ export class LoginComponent implements OnInit { ...@@ -21,6 +22,7 @@ export class LoginComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.currentWalletName = "";
this.apiService.getWalletFiles() this.apiService.getWalletFiles()
.subscribe( .subscribe(
response => { response => {
...@@ -28,9 +30,11 @@ export class LoginComponent implements OnInit { ...@@ -28,9 +30,11 @@ export class LoginComponent implements OnInit {
this.responseMessage=response; this.responseMessage=response;
this.wallets = response.json().walletsFiles; this.wallets = response.json().walletsFiles;
this.walletPath = response.json().walletsPath; this.walletPath = response.json().walletsPath;
console.log(this.wallets);
if (this.wallets.length > 0) { if (this.wallets.length > 0) {
this.hasWallet = true; this.hasWallet = true;
this.currentWalletName = this.wallets[0].slice(0, -5);
} else {
this.hasWallet = false;
} }
} }
}, },
...@@ -45,10 +49,13 @@ export class LoginComponent implements OnInit { ...@@ -45,10 +49,13 @@ export class LoginComponent implements OnInit {
} }
private onSubmit() { private onSubmit() {
this.walletLoad = new WalletLoad(); this.walletLoad = new WalletLoad();
this.walletLoad.password = "test"; this.walletLoad.password = "test";
this.walletLoad.name = "myFirstWallet" this.walletLoad.name = this.currentWalletName;
this.walletLoad.folderPath = "/home/dev0tion/Desktop/Wallets" this.walletLoad.folderPath = this.walletPath;
console.log(this.walletLoad);
this.apiService.loadWallet(this.walletLoad) this.apiService.loadWallet(this.walletLoad)
.subscribe( .subscribe(
...@@ -69,6 +76,11 @@ export class LoginComponent implements OnInit { ...@@ -69,6 +76,11 @@ export class LoginComponent implements OnInit {
); );
} }
private walletChanged(walletName: string) {
let walletNameNoJson: string = walletName.slice(0, -5);
this.currentWalletName = walletNameNoJson;
}
private clickedCreate() { private clickedCreate() {
this.router.navigate(['/setup']); this.router.navigate(['/setup']);
} }
......
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