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