Skip to content

Commit

Permalink
Move default refresh interval settings to time selection service
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcelfrueh committed Nov 25, 2024
1 parent 25ab4b6 commit cf46c32
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,52 +30,8 @@ export class DataExplorerRefreshIntervalSettingsComponent implements OnInit {
intervalSettingsChangedEmitter: EventEmitter<DashboardLiveSettings> =
new EventEmitter<DashboardLiveSettings>();

availableOptions: DashboardLiveSettings[] = [
{
label: 'Off',
refreshModeActive: false,
},
{
label: '1 sec',
refreshModeActive: true,
refreshIntervalInSeconds: 1,
},
{
label: '2 sec',
refreshModeActive: true,
refreshIntervalInSeconds: 2,
},
{
label: '5 sec',
refreshModeActive: true,
refreshIntervalInSeconds: 5,
},
{
label: '10 sec',
refreshModeActive: true,
refreshIntervalInSeconds: 10,
},
{
label: '30 sec',
refreshModeActive: true,
refreshIntervalInSeconds: 30,
},
{
label: '1 min',
refreshModeActive: true,
refreshIntervalInSeconds: 60,
},
{
label: '5 min',
refreshModeActive: true,
refreshIntervalInSeconds: 300,
},
{
label: '30 min',
refreshModeActive: true,
refreshIntervalInSeconds: 60 * 30,
},
];
@Input()
availableOptions: DashboardLiveSettings[];

ngOnInit() {
if (!this.liveSettings?.label) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
(intervalSettingsChangedEmitter)="
intervalSettingsChangedEmitter.emit($event)
"
[availableOptions]="availableOptions"
>
</sp-data-explorer-refresh-interval-settings-component>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ export class TimeRangeSelectorComponent implements OnInit, OnChanges {
@Input()
quickSelections: QuickTimeSelection[];

@Input()
availableOptions: DashboardLiveSettings[];

@Input()
labels: TimeSelectorLabel;

Expand All @@ -93,6 +96,8 @@ export class TimeRangeSelectorComponent implements OnInit, OnChanges {
this.quickSelections ??=
this.timeSelectionService.defaultQuickTimeSelections;
this.labels ??= this.timeSelectionService.defaultLabels;
this.availableOptions ??=
this.timeSelectionService.defaultAvailableLiveSettingsOptions;
this.createDateString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs';
import {
DashboardLiveSettings,
DateRange,
QuickTimeSelection,
TimeSelectionConstants,
Expand Down Expand Up @@ -128,6 +129,53 @@ export class TimeSelectionService {
},
];

defaultAvailableLiveSettingsOptions: DashboardLiveSettings[] = [
{
label: 'Off',
refreshModeActive: false,
},
{
label: '1 sec',
refreshModeActive: true,
refreshIntervalInSeconds: 1,
},
{
label: '2 sec',
refreshModeActive: true,
refreshIntervalInSeconds: 2,
},
{
label: '5 sec',
refreshModeActive: true,
refreshIntervalInSeconds: 5,
},
{
label: '10 sec',
refreshModeActive: true,
refreshIntervalInSeconds: 10,
},
{
label: '30 sec',
refreshModeActive: true,
refreshIntervalInSeconds: 30,
},
{
label: '1 min',
refreshModeActive: true,
refreshIntervalInSeconds: 60,
},
{
label: '5 min',
refreshModeActive: true,
refreshIntervalInSeconds: 300,
},
{
label: '30 min',
refreshModeActive: true,
refreshIntervalInSeconds: 60 * 30,
},
];

public getDateRange(quickSelection: QuickTimeSelection): DateRange {
const now = new Date();
return {
Expand Down

0 comments on commit cf46c32

Please sign in to comment.