Commit e71cfa7e authored by dev0tion's avatar dev0tion

Add functionality to login component

parent ebd028f3
<h1>Welcome back</h1> <h1>Welcome back</h1>
<p>Please enter your password to decrypt your wallet</p> <div *ngIf="hasWallet">
<form (ngSubmit)="onSubmit()" #passwordForm="ngForm"> <p>Choose the wallet you want to open:</p>
<div class="form-group">
<label for="walletLabel">Wallet to open:</label>
<select name="wallet" #walletName>
<option *ngFor="let wallet of wallets">{{wallet}}</option>
</select>
</div>
<p>Please enter your password to decrypt your wallet</p>
<form (ngSubmit)="onSubmit()" #passwordForm="ngForm">
<div class="form-group"> <div class="form-group">
<label for="password">Your password: </label> <label for="password">Your password: </label>
<input type="password" class="form-control" id="password" required name="password"> <input type="password" class="form-control" id="password" required name="password">
</div> </div>
<button type="submit" class="btn btn-success">Decrypt</button> <button type="submit" class="btn btn-success">Decrypt</button>
</form> </form>
\ No newline at end of file <p></p>
</div>
<p> If you like to create or restore a wallet please click the button below.</p>
<button type="button" (click)="clickedCreate()" class="btn btn-success">Create or restore wallet</button>
\ No newline at end of file
...@@ -11,25 +11,52 @@ import { WalletLoad } from '../shared/wallet-load'; ...@@ -11,25 +11,52 @@ import { WalletLoad } from '../shared/wallet-load';
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 walletLoad: WalletLoad;
private hasWallet: boolean = false;
private wallets: [any];
private walletPath: string;
private responseMessage: any; private responseMessage: any;
private errorMessage: any; private errorMessage: any;
private walletLoad: WalletLoad;
ngOnInit() { ngOnInit() {
this.apiService.getWalletFiles()
.subscribe(
response => {
if (response.status >= 200 && response.status < 400) {
this.responseMessage=response;
this.wallets = response.json().walletsFiles;
this.walletPath = response.json().walletsPath;
console.log(this.wallets);
if (this.wallets.length > 0) {
this.hasWallet = true;
}
}
},
error => {
this.errorMessage = <any>error;
if (error.status >= 400) {
alert(this.errorMessage);
console.log(this.errorMessage);
}
}
);
} }
private onSubmit() { private onSubmit() {
this.walletLoad = new WalletLoad(); this.walletLoad = new WalletLoad();
this.walletLoad.password = "123"; this.walletLoad.password = "test";
this.walletLoad.name = "test" this.walletLoad.name = "myFirstWallet"
this.walletLoad.folderPath = "folderPath" this.walletLoad.folderPath = "/home/dev0tion/Desktop/Wallets"
this.apiService.loadWallet(this.walletLoad) this.apiService.loadWallet(this.walletLoad)
.subscribe( .subscribe(
response => { response => {
console.log(response);
if (response.status >= 200 && response.status < 400) { if (response.status >= 200 && response.status < 400) {
this.responseMessage = response; this.responseMessage = response;
this.router.navigate['/wallet'] this.router.navigate(['/wallet']);
} }
}, },
error => { error => {
...@@ -41,4 +68,8 @@ export class LoginComponent implements OnInit { ...@@ -41,4 +68,8 @@ export class LoginComponent implements OnInit {
} }
); );
} }
private clickedCreate() {
this.router.navigate(['/setup']);
}
} }
\ No newline at end of file
<h1>Welcome to Breeze. Looks like you're new here.</h1> <h1>Welcome to Breeze.</h1>
<p> <p>
If you haven't used Breeze before, please create a new wallet. If you haven't used Breeze before, please create a new wallet.
</p> </p>
......
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