Make unique URLs for graph timespans
This commit is contained in:
		
							parent
							
								
									d4508bd876
								
							
						
					
					
						commit
						5cb98b9813
					
				| @ -14,28 +14,28 @@ | ||||
|       <form [formGroup]="radioGroupForm" class="mb-3 float-right"> | ||||
|         <div class="btn-group btn-group-toggle" ngbRadioGroup name="radioBasic" formControlName="interval"> | ||||
|           <label ngbButtonLabel class="btn-primary btn-sm"> | ||||
|             <input ngbButton type="radio" [value]="'half_hour'"> 30M | ||||
|             <input ngbButton type="radio" [value]="'half_hour'" (click)="setFragment('half_hour')"> 30M | ||||
|           </label> | ||||
|           <label ngbButtonLabel class="btn-primary btn-sm"> | ||||
|             <input ngbButton type="radio" [value]="'hour'"> 1H | ||||
|             <input ngbButton type="radio" [value]="'hour'" (click)="setFragment('hour')"> 1H | ||||
|           </label> | ||||
|           <label ngbButtonLabel class="btn-primary btn-sm"> | ||||
|             <input ngbButton type="radio" [value]="'half_day'"> 12H | ||||
|             <input ngbButton type="radio" [value]="'half_day'" (click)="setFragment('half_day')"> 12H | ||||
|           </label> | ||||
|           <label ngbButtonLabel class="btn-primary btn-sm"> | ||||
|             <input ngbButton type="radio" [value]="'day'"> 1D | ||||
|             <input ngbButton type="radio" [value]="'day'" (click)="setFragment('day')"> 1D | ||||
|           </label> | ||||
|           <label ngbButtonLabel class="btn-primary btn-sm"> | ||||
|             <input ngbButton type="radio" [value]="'week'"> 1W | ||||
|             <input ngbButton type="radio" [value]="'week'" (click)="setFragment('week')"> 1W | ||||
|           </label> | ||||
|           <label ngbButtonLabel class="btn-primary btn-sm"> | ||||
|             <input ngbButton type="radio" [value]="'month'"> 1M | ||||
|             <input ngbButton type="radio" [value]="'month'" (click)="setFragment('month')"> 1M | ||||
|           </label> | ||||
|           <label ngbButtonLabel class="btn-primary btn-sm"> | ||||
|             <input ngbButton type="radio" [value]="'year'"> 1Y | ||||
|             <input ngbButton type="radio" [value]="'year'" (click)="setFragment('year')"> 1Y | ||||
|           </label> | ||||
|           <label ngbButtonLabel class="btn-primary btn-sm"> | ||||
|             <input ngbButton type="radio" [value]="'auto'" fragment="auto"> Auto | ||||
|             <input ngbButton type="radio" [value]="'auto'" (click)="setFragment('auto')"> Auto | ||||
|           </label> | ||||
|         </div> | ||||
|       </form> | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core'; | ||||
| import { FormBuilder, FormGroup } from '@angular/forms'; | ||||
| import { ActivatedRoute } from '@angular/router'; | ||||
| import { ActivatedRoute, Router } from '@angular/router'; | ||||
| import { combineLatest, merge, Observable, of } from 'rxjs'; | ||||
| import { map, switchMap } from 'rxjs/operators'; | ||||
| import { SeoService } from 'src/app/services/seo.service'; | ||||
| @ -29,6 +29,7 @@ export class BisqMarketComponent implements OnInit, OnDestroy { | ||||
|     private bisqApiService: BisqApiService, | ||||
|     private formBuilder: FormBuilder, | ||||
|     private seoService: SeoService, | ||||
|     private router: Router, | ||||
|   ) { } | ||||
| 
 | ||||
|   ngOnInit(): void { | ||||
| @ -36,6 +37,10 @@ export class BisqMarketComponent implements OnInit, OnDestroy { | ||||
|       interval: [this.defaultInterval], | ||||
|     }); | ||||
| 
 | ||||
|     if (['half_hour', 'hour', 'half_day', 'day', 'week', 'month', 'year', 'auto'].indexOf(this.route.snapshot.fragment) > -1) { | ||||
|       this.radioGroupForm.controls.interval.setValue(this.route.snapshot.fragment, { emitEvent: false }); | ||||
|     } | ||||
| 
 | ||||
|     this.currency$ = this.bisqApiService.getMarkets$() | ||||
|       .pipe( | ||||
|         switchMap((markets) => combineLatest([of(markets), this.route.paramMap])), | ||||
| @ -66,7 +71,7 @@ export class BisqMarketComponent implements OnInit, OnDestroy { | ||||
| 
 | ||||
|     this.hlocData$ = combineLatest([ | ||||
|       this.route.paramMap, | ||||
|       merge(this.radioGroupForm.get('interval').valueChanges, of(this.defaultInterval)), | ||||
|       merge(this.radioGroupForm.get('interval').valueChanges, of(this.radioGroupForm.get('interval').value)), | ||||
|     ]) | ||||
|     .pipe( | ||||
|       switchMap(([routeParams, interval]) => { | ||||
| @ -95,6 +100,14 @@ export class BisqMarketComponent implements OnInit, OnDestroy { | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   setFragment(fragment: string) { | ||||
|     this.router.navigate([], { | ||||
|       relativeTo: this.route, | ||||
|       queryParamsHandling: 'merge', | ||||
|       fragment: fragment | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|   ngOnDestroy(): void { | ||||
|     this.websocketService.stopTrackingBisqMarket(); | ||||
|   } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user