Commit 9c83482d authored by Paul Herbert's avatar Paul Herbert

2100 - ICO updates: tweaks

parent 5348e6f7
import { Component, OnInit, OnDestroy, Input } from '@angular/core';
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Subscription } from 'rxJs/Subscription';
import { FormGroup, Validators, FormBuilder } from '@angular/forms';
import { FormGroup, Validators, FormBuilder, AbstractControl } from '@angular/forms';
import { NgbDateStruct } from '@ng-bootstrap/ng-bootstrap';
import { AdvancedService } from './advanced.service';
......@@ -12,14 +12,16 @@ import { LoadingState } from './loadingState';
styleUrls: ['./advanced.component.css']
})
export class AdvancedComponent implements OnInit, OnDestroy {
private addressCount: string;
private addressCount = "";
private extPubKeySubs: Subscription;
private generateAddressesSubs: Subscription;
private resyncSubs: Subscription;
private addresses = new Array<string>();
private resyncActioned = false;
constructor(private advancedService: AdvancedService, private formBuilder: FormBuilder) { }
constructor(private advancedService: AdvancedService, private formBuilder: FormBuilder) {
this.setResyncDates();
}
public icoFormGroup: FormGroup;
public extPubKey = "";
......@@ -29,17 +31,15 @@ export class AdvancedComponent implements OnInit, OnDestroy {
public resyncLoadingState = new LoadingState();
public maxResyncDate: NgbDateStruct;
public minResyncDate: NgbDateStruct;
public get datePickerControl() { return this.icoFormGroup.get('datePickerControl'); }
public get addressCountControl() { return this.icoFormGroup.get('addressCountControl'); }
public get showAddressesTick() { return this.generateAddressesLoadingState.success &&
public get datePickerControl(): AbstractControl { return this.icoFormGroup.get('datePickerControl'); }
public get addressCountControl(): AbstractControl { return this.icoFormGroup.get('addressCountControl'); }
public get showAddressesTick(): boolean { return this.generateAddressesLoadingState.success &&
this.addresses.length && (Number(this.addressCount)===this.addresses.length); }
public get showResyncTick(): boolean { return this.resyncLoadingState.success && this.resyncActioned; }
ngOnInit() {
this.registerFormControls();
this.loadExtPubKey();
this.setResyncDates();
}
public generateAddresses() {
......@@ -64,12 +64,6 @@ export class AdvancedComponent implements OnInit, OnDestroy {
_ => this.resyncLoadingState.errored = true);
}
private setResyncDates() {
const now = new Date();
this.maxResyncDate = {year: now.getFullYear(), month: now.getMonth()+1, day: now.getDate()}
this.minResyncDate = {year: now.getFullYear(), month: 1, day: 1}
}
private loadExtPubKey() {
this.extPubKeyLoadingState.loading = true;
this.extPubKeySubs = this.advancedService.getExtPubKey()
......@@ -106,6 +100,12 @@ export class AdvancedComponent implements OnInit, OnDestroy {
});
}
private setResyncDates() {
const now = new Date();
this.maxResyncDate = {year: now.getFullYear(), month: now.getMonth()+1, day: now.getDate()}
this.minResyncDate = {year: now.getFullYear(), month: 1, day: 1}
}
ngOnDestroy() {
if (this.extPubKeySubs) {
this.extPubKeySubs.unsubscribe();
......
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