diff --git a/src/app/IntervalTimer/interval-timer.component.scss b/src/app/IntervalTimer/interval-timer.component.scss index e36cf083..134d47c1 100644 --- a/src/app/IntervalTimer/interval-timer.component.scss +++ b/src/app/IntervalTimer/interval-timer.component.scss @@ -12,7 +12,7 @@ } .countdown-number { - color: black; + color: var(--clr-forms-label-color); display: inline-block; line-height: 40px; } diff --git a/src/app/IntervalTimer/interval-timer.component.ts b/src/app/IntervalTimer/interval-timer.component.ts index 5f4a9220..fc6e90bd 100644 --- a/src/app/IntervalTimer/interval-timer.component.ts +++ b/src/app/IntervalTimer/interval-timer.component.ts @@ -6,6 +6,8 @@ import { Output, EventEmitter, } from '@angular/core'; +import { Settings, SettingsService } from '../data/settings.service'; +import { Subscription } from 'rxjs'; @Component({ selector: 'interval-timer', @@ -29,24 +31,36 @@ export class IntervalTimerComponent implements OnInit, OnDestroy { public currentCallDelay: number; public circleVisible: boolean = true; public delayOptions: Generator; + private settingsSubscription: Subscription; + + constructor(private settingsService: SettingsService) {} ngOnInit(): void { function* cycle(array: T[]) { while (true) yield* array; } this.delayOptions = cycle(this.delayOptionsArray); - this.changeDelay(); + this.settingsSubscription = this.settingsService.settings$.subscribe( + (settings: Settings) => { + this.currentCallDelay = settings.refresh_timer_interval; + this.changeDelay(false); + }, + ); } onTimerClick() { this.changeDelay(); this.intervalElapsed.emit(); + this.settingsService + .update({ refresh_timer_interval: this.currentCallDelay }) + .subscribe(); } - changeDelay() { + changeDelay(incrementInterval: boolean = true) { //Set next value of the interval array as call delay - this.currentCallDelay = this.delayOptions.next().value; - + if (incrementInterval) { + this.currentCallDelay = this.delayOptions.next().value; + } if (this.callInterval !== null) { clearInterval(this.callInterval); this.callInterval = null; @@ -63,6 +77,7 @@ export class IntervalTimerComponent implements OnInit, OnDestroy { } ngOnDestroy(): void { + this.settingsSubscription.unsubscribe(); if (this.callInterval !== null) { clearInterval(this.callInterval); this.callInterval = null; diff --git a/src/app/data/forms.ts b/src/app/data/forms.ts index 9fe4e104..50b8309b 100644 --- a/src/app/data/forms.ts +++ b/src/app/data/forms.ts @@ -78,6 +78,7 @@ export type SettingFormGroup = FormGroup<{ theme: FormControl<'dark' | 'light' | 'system'>; progress_view_mode: FormControl; currency_symbol: FormControl; + refresh_timer_interval: FormControl; }>; // This object type maps VMTemplate names to the number of requested VMs diff --git a/src/app/data/settings.service.ts b/src/app/data/settings.service.ts index 2abe1ce6..29d3ea90 100644 --- a/src/app/data/settings.service.ts +++ b/src/app/data/settings.service.ts @@ -24,6 +24,7 @@ export interface Settings { theme: 'dark' | 'light' | 'system'; progress_view_mode: ProgressViewMode; currency_symbol: string; + refresh_timer_interval: number; } /** @@ -55,6 +56,9 @@ export class SettingsService { currency_symbol: new FormControl('$', { nonNullable: true, }), + refresh_timer_interval: new FormControl(10, { + nonNullable: true, + }), }); fetch() { @@ -69,6 +73,7 @@ export class SettingsService { theme: 'system', progress_view_mode: 'cardView', currency_symbol: '$', + refresh_timer_interval: 10, } as Settings), ), tap((s: Settings) => { diff --git a/src/app/header/header.component.html b/src/app/header/header.component.html index 31575908..c12b86a0 100644 --- a/src/app/header/header.component.html +++ b/src/app/header/header.component.html @@ -133,6 +133,19 @@ /> + + + + + diff --git a/src/app/header/header.component.ts b/src/app/header/header.component.ts index 589d1c76..77b9c694 100644 --- a/src/app/header/header.component.ts +++ b/src/app/header/header.component.ts @@ -104,6 +104,7 @@ export class HeaderComponent implements OnInit { theme = 'system', progress_view_mode = 'cardView', currency_symbol = '$', + refresh_timer_interval = 10, }) => { this.settingsForm.setValue({ terminal_theme, @@ -111,6 +112,7 @@ export class HeaderComponent implements OnInit { theme, progress_view_mode, currency_symbol, + refresh_timer_interval, }); this.fetchingSettings = false;