mirror of
https://github.com/mempool/mempool.git
synced 2025-02-24 06:47:52 +01:00
Add fee rate unit preference & dropdown
This commit is contained in:
parent
408c86963b
commit
a45f1fde1c
6 changed files with 60 additions and 0 deletions
|
@ -0,0 +1,5 @@
|
|||
<div [formGroup]="rateUnitForm" class="text-small text-center">
|
||||
<select formControlName="rateUnits" class="custom-select custom-select-sm form-control-secondary form-control mx-auto" style="width: 200px;" (change)="changeUnits()">
|
||||
<option *ngFor="let unit of units" [value]="unit.name">{{ unit.label }}</option>
|
||||
</select>
|
||||
</div>
|
|
@ -0,0 +1,45 @@
|
|||
import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
|
||||
import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
|
||||
import { StorageService } from '../../services/storage.service';
|
||||
import { StateService } from '../../services/state.service';
|
||||
import { Subscription } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'app-rate-unit-selector',
|
||||
templateUrl: './rate-unit-selector.component.html',
|
||||
styleUrls: ['./rate-unit-selector.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class RateUnitSelectorComponent implements OnInit, OnDestroy {
|
||||
rateUnitForm: UntypedFormGroup;
|
||||
rateUnitSub: Subscription;
|
||||
units = [
|
||||
{ name: 'vb', label: 'sat/vB' },
|
||||
{ name: 'wu', label: 'sat/WU' },
|
||||
];
|
||||
|
||||
constructor(
|
||||
private formBuilder: UntypedFormBuilder,
|
||||
private stateService: StateService,
|
||||
private storageService: StorageService,
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.rateUnitForm = this.formBuilder.group({
|
||||
rateUnits: ['vb']
|
||||
});
|
||||
this.rateUnitSub = this.stateService.rateUnits$.subscribe((units) => {
|
||||
this.rateUnitForm.get('rateUnits')?.setValue(units);
|
||||
});
|
||||
}
|
||||
|
||||
changeUnits() {
|
||||
const newUnits = this.rateUnitForm.get('rateUnits')?.value;
|
||||
this.storageService.setValue('rate-unit-preference', newUnits);
|
||||
this.stateService.rateUnits$.next(newUnits);
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.rateUnitSub.unsubscribe();
|
||||
}
|
||||
}
|
|
@ -133,6 +133,7 @@ export class StateService {
|
|||
hideFlow: BehaviorSubject<boolean>;
|
||||
hideAudit: BehaviorSubject<boolean>;
|
||||
fiatCurrency$: BehaviorSubject<string>;
|
||||
rateUnits$: BehaviorSubject<string>;
|
||||
|
||||
constructor(
|
||||
@Inject(PLATFORM_ID) private platformId: any,
|
||||
|
@ -225,6 +226,9 @@ export class StateService {
|
|||
|
||||
const fiatPreference = this.storageService.getValue('fiat-preference');
|
||||
this.fiatCurrency$ = new BehaviorSubject<string>(fiatPreference || 'USD');
|
||||
|
||||
const rateUnitPreference = this.storageService.getValue('rate-unit-preference');
|
||||
this.rateUnits$ = new BehaviorSubject<string>(rateUnitPreference || 'vb');
|
||||
}
|
||||
|
||||
setNetworkBasedonUrl(url: string) {
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
<div class="selector">
|
||||
<app-fiat-selector></app-fiat-selector>
|
||||
</div>
|
||||
<div class="selector">
|
||||
<app-rate-unit-selector></app-rate-unit-selector>
|
||||
</div>
|
||||
<ng-template #temporaryHidden>
|
||||
<a *ngIf="officialMempoolSpace" class="cta btn btn-purple sponsor" [routerLink]="['/signup' | relativeUrl]">Support the Project</a>
|
||||
<p *ngIf="officialMempoolSpace && env.BASE_MODULE === 'mempool'" class="cta-secondary"><a [routerLink]="['/signin' | relativeUrl]" i18n="shared.broadcast-transaction|Broadcast Transaction">Sign In</a></p>
|
||||
|
|
|
@ -35,6 +35,7 @@ import { TxFeeRatingComponent } from '../components/tx-fee-rating/tx-fee-rating.
|
|||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { LanguageSelectorComponent } from '../components/language-selector/language-selector.component';
|
||||
import { FiatSelectorComponent } from '../components/fiat-selector/fiat-selector.component';
|
||||
import { RateUnitSelectorComponent } from '../components/rate-unit-selector/rate-unit-selector.component';
|
||||
import { ColoredPriceDirective } from './directives/colored-price.directive';
|
||||
import { NoSanitizePipe } from './pipes/no-sanitize.pipe';
|
||||
import { MempoolBlocksComponent } from '../components/mempool-blocks/mempool-blocks.component';
|
||||
|
@ -106,6 +107,7 @@ import { ClockComponent } from '../components/clock/clock.component';
|
|||
TxFeeRatingComponent,
|
||||
LanguageSelectorComponent,
|
||||
FiatSelectorComponent,
|
||||
RateUnitSelectorComponent,
|
||||
ScriptpubkeyTypePipe,
|
||||
RelativeUrlPipe,
|
||||
NoSanitizePipe,
|
||||
|
@ -225,6 +227,7 @@ import { ClockComponent } from '../components/clock/clock.component';
|
|||
TxFeeRatingComponent,
|
||||
LanguageSelectorComponent,
|
||||
FiatSelectorComponent,
|
||||
RateUnitSelectorComponent,
|
||||
ScriptpubkeyTypePipe,
|
||||
RelativeUrlPipe,
|
||||
Hex2asciiPipe,
|
||||
|
|
Loading…
Add table
Reference in a new issue