11import { AfterViewInit , Component , ElementRef , EventEmitter , OnDestroy , Output , ViewChild } from '@angular/core' ;
22import { FinancialData } from '../shared/financialData' ;
3- import { LocalService } from '../shared/local.service' ;
43import { ControllerComponent } from './controllers.component' ;
54import { GridFinJSComponent } from './grid-finjs.component' ;
65
76@Component ( {
8- providers : [ LocalService ] ,
97 selector : 'app-finjs-main' ,
108 styleUrls : [ './main.component.scss' ] ,
119 templateUrl : './main.component.html'
@@ -19,47 +17,19 @@ export class MainComponent implements AfterViewInit, OnDestroy {
1917 @Output ( ) public frequencyTimer = new EventEmitter < any > ( ) ;
2018 @Output ( ) public player = new EventEmitter < any > ( ) ;
2119
22- public data = [ ] ;
2320 private subscription$ ;
24-
25- constructor ( private localService : LocalService , private elRef : ElementRef ) {
26- this . localService . getFinancialData ( 1000 ) ;
27- }
28-
29- public selectionMode = 'multiple' ;
3021 public theme = false ;
3122 public volume = 1000 ;
3223 public frequency = 500 ;
33- public controls = [
34- {
35- disabled : false ,
36- icon : 'update' ,
37- label : 'LIVE PRICES' ,
38- selected : false
39- } ,
40- {
41- disabled : false ,
42- icon : 'update' ,
43- label : 'LIVE ALL PRICES' ,
44- selected : false
45- } ,
46- {
47- disabled : true ,
48- icon : 'stop' ,
49- label : 'Stop' ,
50- selected : false
51- }
52- ] ;
53-
54- private subscription ;
55- private selectedButton ;
5624 private _timer ;
5725
26+ constructor ( private elRef : ElementRef ) {
27+ }
28+
5829 public ngAfterViewInit ( ) {
59- this . subscription$ = this . localService . records . subscribe ( x => {
60- this . finGrid . data = x ;
61- this . finGrid . cdr . detectChanges ( ) ;
62- } ) ;
30+ // this.subscription$ = this.localService.records.subscribe(x => {
31+ // this.finGrid.data = x;
32+ // });
6333 }
6434 public onSwitchChanged ( event : any ) {
6535 switch ( event . action ) {
@@ -82,43 +52,18 @@ export class MainComponent implements AfterViewInit, OnDestroy {
8252 }
8353 }
8454
85- public onVolumeChanged ( event : any ) {
86- this . localService . getFinancialData ( this . volume ) ;
87- }
88-
89- public onFrequencyChanged ( event : any ) {
90- switch ( event . switch ) {
91- case 'theme' : {
92- this . changeTheme ( event . checked ) ;
93- break ;
94- }
95- case 'grouped' : {
96- this . disableOtherButtons ( event . index , true ) ;
97- const currData = this . finGrid . data ;
98- this . _timer = setInterval ( ( ) => this . tickerAllPrices ( currData ) , this . frequency ) ;
99- break ;
100- }
101- case 'showToolbar' : {
102- this . stopFeed ( ) ;
103- break ;
104- }
105- default :
106- {
107- break ;
108- }
109- }
55+ public onVolumeChanged ( volume : any ) {
56+ this . finGrid . finService . getFinancialData ( volume ) ;
11057 }
11158
11259 public onPlayAction ( event : any ) {
11360 switch ( event . action ) {
11461 case 'playAll' : {
115- this . disableOtherButtons ( event . index , true ) ;
11662 const currData = this . finGrid . data ;
11763 this . _timer = setInterval ( ( ) => this . tickerAllPrices ( currData ) , this . controller . frequency ) ;
11864 break ;
11965 }
12066 case 'playRandom' : {
121- this . disableOtherButtons ( event . index , true ) ;
12267 const currData = this . finGrid . data ;
12368 this . _timer = setInterval ( ( ) => this . ticker ( currData ) , this . controller . frequency ) ;
12469 break ;
@@ -151,8 +96,8 @@ export class MainComponent implements AfterViewInit, OnDestroy {
15196 if ( this . _timer ) {
15297 clearInterval ( this . _timer ) ;
15398 }
154- if ( this . subscription ) {
155- this . subscription . unsubscribe ( ) ;
99+ if ( this . subscription$ ) {
100+ this . subscription$ . unsubscribe ( ) ;
156101 }
157102 }
158103
@@ -164,21 +109,6 @@ export class MainComponent implements AfterViewInit, OnDestroy {
164109 this . finGrid . data = FinancialData . updateAllPrices ( data ) ;
165110 }
166111
167- private disableOtherButtons ( ind : number , disableButtons : boolean ) {
168- if ( this . subscription ) {
169- this . subscription . unsubscribe ( ) ;
170- }
171- this . controller . volumeSlider . disabled = disableButtons ;
172- this . controller . intervalSlider . disabled = disableButtons ;
173- this . selectedButton = ind ;
174- this . controller . buttonGroup1 . buttons . forEach ( ( button , index ) => {
175- if ( index === 2 ) { button . disabled = ! disableButtons ; } else {
176- this . controller . buttonGroup1 . buttons [ 0 ] . disabled = disableButtons ;
177- this . controller . buttonGroup1 . buttons [ 1 ] . disabled = disableButtons ;
178- }
179- } ) ;
180- }
181-
182112 /**
183113 * returns the main div container of the Index Component,
184114 * if path is /samples/sample-url, or the appRoot, if path is /sample-url
@@ -187,12 +117,7 @@ export class MainComponent implements AfterViewInit, OnDestroy {
187117 return this . elRef . nativeElement . parentElement . parentElement ;
188118 }
189119
190- get buttonSelected ( ) : number {
191- return this . selectedButton || this . selectedButton === 0 ? this . selectedButton : - 1 ;
192- }
193-
194120 public ngOnDestroy ( ) {
195121 this . stopFeed ( ) ;
196- this . subscription$ . unsubscribe ( ) ;
197122 }
198123}
0 commit comments