From 5cb98b98137c8e8e2b91776bad24ef75ac3841da Mon Sep 17 00:00:00 2001 From: softsimon Date: Wed, 21 Apr 2021 22:12:35 +0400 Subject: [PATCH] Make unique URLs for graph timespans --- .../bisq/bisq-market/bisq-market.component.html | 16 ++++++++-------- .../bisq/bisq-market/bisq-market.component.ts | 17 +++++++++++++++-- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/frontend/src/app/bisq/bisq-market/bisq-market.component.html b/frontend/src/app/bisq/bisq-market/bisq-market.component.html index b00aba800..918704456 100644 --- a/frontend/src/app/bisq/bisq-market/bisq-market.component.html +++ b/frontend/src/app/bisq/bisq-market/bisq-market.component.html @@ -14,28 +14,28 @@
diff --git a/frontend/src/app/bisq/bisq-market/bisq-market.component.ts b/frontend/src/app/bisq/bisq-market/bisq-market.component.ts index de446f885..076208a00 100644 --- a/frontend/src/app/bisq/bisq-market/bisq-market.component.ts +++ b/frontend/src/app/bisq/bisq-market/bisq-market.component.ts @@ -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(); }