Commit ee131b80 authored by Paul Herbert's avatar Paul Herbert

2100 - Breeze Updates for ICO: latest

parent 0e0da38d
<div class="container" style="border:1px solid lightgray; border-radius: 4px; padding:10px; position: absolute; left:100px; width:65%"> <form [formGroup]='icoFormGroup'>
<h4>ICO</h4> <div class="container" style="border:1px solid lightgray; border-radius: 4px; padding:10px; position: absolute; left:100px; width:65%">
<div style="margin-top:15px"> <h4>ICO</h4>
<div style="margin-top:15px">
<div>
<label style="font-size:14px;margin-bottom:0px">Extended Public Key</label> <div>
<div class="myAddress" *ngIf="extPubKeyLoadingState.success; else elseFeedback"><code style="overflow-wrap: break-word">{{ extPubKey }}</code></div> <label style="font-size:14px;margin-bottom:0px">Extended Public Key</label>
<ng-template #elseFeedback> <div class="myAddress" *ngIf="extPubKeyLoadingState.success; else elseFeedback"><code style="overflow-wrap: break-word">{{ extPubKey }}</code></div>
<app-feedback [loading]="extPubKeyLoadingState.loading" <ng-template #elseFeedback>
[errored]="extPubKeyLoadingState.errored" <app-feedback [loading]="extPubKeyLoadingState.loading"
[erroredText]="extPubKeyLoadingState.erroredText"></app-feedback> [errored]="extPubKeyLoadingState.errored"
</ng-template> [erroredText]="'Failed to get Extended Public Key'"></app-feedback>
</div> </ng-template>
</div>
<div style="margin-top:20px"> <div style="margin-top:20px">
<label style="font-size:14px;margin-bottom:1px">Generate Addresses</label> <label style="font-size:14px;margin-bottom:1px">Generate Addresses</label>
<div class="input-group" style="width:55%; height:35px"> <div class="input-group" style="width:240px; height:35px">
<input pattern="^[1-9]+$" type="number" class="form-control" placeholder="Number to generate..." style="border-radius: 0px"> <input formControlName="addressCountControl" type="text" class="form-control" placeholder="Number to generate..." style="border-radius: 0px">
<span class="input-group-btn"> <span class="input-group-btn">
<button class="btn btn-default" type="button">Go</button> <div>
</span> <button *ngIf="!addressCountControl.invalid" style="outline: none" class="btn btn-default" type="button">Go</button>
<button *ngIf="addressCountControl.invalid" style="outline:none; color: gray" class="btn btn-default" type="button">Go</button>
</div>
</span>
</div>
</div> </div>
</div>
</div>
</div> </div>
</div> </form>
import { Component, OnDestroy } from '@angular/core'; import { Component, OnInit, OnDestroy, Input } from '@angular/core';
import { Subscription } from 'rxJs/Subscription'; import { Subscription } from 'rxJs/Subscription';
import { FormGroup, FormControl, Validators, FormBuilder } from '@angular/forms'; import { FormGroup, FormControl, Validators, FormBuilder } from '@angular/forms';
import 'rxjs/add/operator/filter';
import { AdvancedService } from './../advanced.service'; import { AdvancedService } from './../advanced.service';
import { LoadingState } from './loadingState'; import { LoadingState } from './loadingState';
...@@ -10,22 +12,24 @@ import { LoadingState } from './loadingState'; ...@@ -10,22 +12,24 @@ import { LoadingState } from './loadingState';
templateUrl: './advanced-ico.component.html', templateUrl: './advanced-ico.component.html',
styleUrls: ['./advanced-ico.component.css'] styleUrls: ['./advanced-ico.component.css']
}) })
export class AdvancedIcoComponent implements OnDestroy { export class AdvancedIcoComponent implements OnInit, OnDestroy {
public icoFormGroup: FormGroup;
private _extPubKey = ''; private _extPubKey = '';
private addressCount: string;
private extPubKeySubs: Subscription; private extPubKeySubs: Subscription;
private _extPubKeyLoadingState: LoadingState = new LoadingState("Failed to get ExtPubKey"); private _extPubKeyLoadingState: LoadingState = new LoadingState();
constructor(private advancedService: AdvancedService) { constructor(private advancedService: AdvancedService, private formBuilder: FormBuilder) {
this.loadExtPubKey(); this.loadExtPubKey();
} }
public get extPubKey(): string { ngOnInit() {
return this._extPubKey; this.registerFormControls();
} }
public get extPubKeyLoadingState(): LoadingState { public get extPubKey(): string { return this._extPubKey; }
return this._extPubKeyLoadingState; public get extPubKeyLoadingState(): LoadingState { return this._extPubKeyLoadingState; }
} public get addressCountControl() { return this.icoFormGroup.get('addressCountControl'); }
private loadExtPubKey() { private loadExtPubKey() {
this.extPubKeyLoadingState.loading = true; this.extPubKeyLoadingState.loading = true;
...@@ -38,6 +42,22 @@ export class AdvancedIcoComponent implements OnDestroy { ...@@ -38,6 +42,22 @@ export class AdvancedIcoComponent implements OnDestroy {
this.extPubKeyLoadingState.loading = false; this.extPubKeyLoadingState.loading = false;
} }
private registerFormControls() {
this.icoFormGroup = this.formBuilder.group({
addressCountControl: ["", [Validators.required, Validators.pattern('^[1-9][0-9]*$')]]
});
let ignore = false;
this.addressCountControl.valueChanges.filter(_ => !ignore).subscribe(_ => {
if (this.addressCountControl.invalid && this.addressCountControl.value) {
ignore = true;
this.addressCountControl.setValue(this.addressCount);
ignore = false;
} else {
this.addressCount = this.addressCountControl.value;
}
});
}
ngOnDestroy() { ngOnDestroy() {
this.extPubKeySubs.unsubscribe(); this.extPubKeySubs.unsubscribe();
} }
......
...@@ -3,10 +3,6 @@ export class LoadingState { ...@@ -3,10 +3,6 @@ export class LoadingState {
private _loading = false; private _loading = false;
private _errored = false; private _errored = false;
private _erroredText = ""; private _erroredText = "";
constructor(erroredText: string) {
this._erroredText = erroredText;
}
public get erroredText(): string { public get erroredText(): string {
return this._erroredText; return this._erroredText;
......
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