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