diff --git a/ui/projects/streampipes/platform-services/src/lib/model/datalake/DateRange.ts b/ui/projects/streampipes/platform-services/src/lib/model/datalake/DateRange.ts index f061e5daff..c6e6a589c7 100644 --- a/ui/projects/streampipes/platform-services/src/lib/model/datalake/DateRange.ts +++ b/ui/projects/streampipes/platform-services/src/lib/model/datalake/DateRange.ts @@ -24,6 +24,11 @@ export interface TimeSettings { timeSelectionId?: string; } +export interface ExtendedTimeSettings { + timeSettings: TimeSettings; + supportsLiveRefresh: boolean; +} + export class TimeSelectionConstants { static CUSTOM = 'custom'; static LAST_15_MINUTES = 'last-15-minutes'; @@ -101,6 +106,7 @@ export interface QuickTimeSelection { startTime: (now: Date) => Date; endTime: (now: Date) => Date; addDividerAfter?: boolean; + supportsLiveRefresh?: boolean; } export class DateRange { diff --git a/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/refresh-interval-settings/refresh-interval-settings.component.html b/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/refresh-interval-settings/refresh-interval-settings.component.html index 36b2b76cfe..84f316bcda 100644 --- a/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/refresh-interval-settings/refresh-interval-settings.component.html +++ b/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/refresh-interval-settings/refresh-interval-settings.component.html @@ -23,6 +23,7 @@ [matMenuTriggerFor]="menu" aria-label="Refresh interval" matTooltip="Refresh interval" + [disabled]="!liveRefreshEnabled" > autorenew {{ liveSettings.label }} diff --git a/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/refresh-interval-settings/refresh-interval-settings.component.ts b/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/refresh-interval-settings/refresh-interval-settings.component.ts index 520dddbaa3..b60e4e1c78 100644 --- a/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/refresh-interval-settings/refresh-interval-settings.component.ts +++ b/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/refresh-interval-settings/refresh-interval-settings.component.ts @@ -33,6 +33,8 @@ export class DataExplorerRefreshIntervalSettingsComponent implements OnInit { @Input() availableOptions: DashboardLiveSettings[]; + liveRefreshEnabled: boolean; + ngOnInit() { if (!this.liveSettings?.label) { this.liveSettings = this.availableOptions[0]; @@ -43,4 +45,11 @@ export class DataExplorerRefreshIntervalSettingsComponent implements OnInit { this.liveSettings = option; this.intervalSettingsChangedEmitter.emit(option); } + + handleEnableLiveRefresh(liveRefreshEnabled: boolean) { + if (this.liveRefreshEnabled === true && liveRefreshEnabled === false) { + this.intervalSettingsChangedEmitter.emit(this.availableOptions[0]); + } + this.liveRefreshEnabled = liveRefreshEnabled; + } } diff --git a/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-range-selector.component.html b/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-range-selector.component.html index 58c976fd71..97aa766d30 100644 --- a/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-range-selector.component.html +++ b/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-range-selector.component.html @@ -88,7 +88,8 @@
= - new EventEmitter(); + timeSettingsEmitter: EventEmitter = + new EventEmitter(); @Input() quickSelections: QuickTimeSelection[]; @@ -72,7 +73,10 @@ export class TimeRangeSelectorMenuComponent implements OnInit { this.timeSettings.endTime = selectedDateRange.endDate.getTime(); this.timeRangeSelection.initializeDateRange(); this.triggerDisplayUpdate(); - this.timeSettingsEmitter.emit(this.timeSettings); + this.timeSettingsEmitter.emit({ + supportsLiveRefresh: quickSelection.supportsLiveRefresh, + timeSettings: this.timeSettings, + }); } triggerDisplayUpdate(): void { diff --git a/ui/projects/streampipes/shared-ui/src/lib/services/time-selection.service.ts b/ui/projects/streampipes/shared-ui/src/lib/services/time-selection.service.ts index be9d657fd4..cca6465323 100644 --- a/ui/projects/streampipes/shared-ui/src/lib/services/time-selection.service.ts +++ b/ui/projects/streampipes/shared-ui/src/lib/services/time-selection.service.ts @@ -66,66 +66,77 @@ export class TimeSelectionService { timeSelectionId: TimeSelectionConstants.LAST_15_MINUTES, startTime: now => subMinutes(now, 15), endTime: now => now, + supportsLiveRefresh: true, }, { label: 'Last 1 hour', timeSelectionId: TimeSelectionConstants.LAST_HOUR, startTime: now => subHours(now, 1), endTime: now => now, + supportsLiveRefresh: true, }, { label: 'Last 1 day', timeSelectionId: TimeSelectionConstants.LAST_DAY, startTime: now => subDays(now, 1), endTime: now => now, + supportsLiveRefresh: true, }, { label: 'Last 1 week', timeSelectionId: TimeSelectionConstants.LAST_WEEK, startTime: now => subWeeks(now, 1), endTime: now => now, + supportsLiveRefresh: true, }, { label: 'Last 1 month', timeSelectionId: TimeSelectionConstants.LAST_MONTH, startTime: now => subMonths(now, 1), endTime: now => now, + supportsLiveRefresh: true, }, { label: 'Last 1 year', timeSelectionId: TimeSelectionConstants.LAST_YEAR, startTime: now => subYears(now, 1), endTime: now => now, + supportsLiveRefresh: true, }, { label: 'Current day', timeSelectionId: TimeSelectionConstants.CURRENT_DAY, startTime: now => startOfDay(now), endTime: now => now, + supportsLiveRefresh: true, }, { label: 'Current hour', timeSelectionId: TimeSelectionConstants.CURRENT_HOUR, startTime: now => startOfHour(now), endTime: now => now, + supportsLiveRefresh: true, }, { label: 'Current week', timeSelectionId: TimeSelectionConstants.CURRENT_WEEK, startTime: now => startOfWeek(now), endTime: now => now, + supportsLiveRefresh: true, }, { label: 'Current month', timeSelectionId: TimeSelectionConstants.CURRENT_MONTH, startTime: now => startOfMonth(now), endTime: now => now, + supportsLiveRefresh: true, }, { label: 'Current year', timeSelectionId: TimeSelectionConstants.CURRENT_YEAR, startTime: now => startOfYear(now), endTime: now => now, + supportsLiveRefresh: true, }, ]; diff --git a/ui/projects/streampipes/shared-ui/src/public-api.ts b/ui/projects/streampipes/shared-ui/src/public-api.ts index 40fe20fa0a..ab70e0b106 100644 --- a/ui/projects/streampipes/shared-ui/src/public-api.ts +++ b/ui/projects/streampipes/shared-ui/src/public-api.ts @@ -39,6 +39,7 @@ export * from './lib/components/sp-exception-message/exception-details/exception export * from './lib/components/sp-label/sp-label.component'; export * from './lib/components/sp-table/sp-table.component'; export * from './lib/components/warning-box/warning-box.component'; +export * from './lib/components/time-selector/time-selector.model'; export * from './lib/components/time-selector/time-range-selector.component'; export * from './lib/components/time-selector/time-selector-menu/time-selector-menu.component'; export * from './lib/components/time-selector/time-selector-menu/custom-time-range-selection/custom-time-range-selection.component'; diff --git a/ui/src/app/data-explorer/components/widget/data-explorer-dashboard-widget.component.html b/ui/src/app/data-explorer/components/widget/data-explorer-dashboard-widget.component.html index 54e23fe4f9..5bdfed7df1 100644 --- a/ui/src/app/data-explorer/components/widget/data-explorer-dashboard-widget.component.html +++ b/ui/src/app/data-explorer/components/widget/data-explorer-dashboard-widget.component.html @@ -65,7 +65,7 @@ [matMenuTriggerFor]="menu" aria-label="More options" matTooltip="More options" - *ngIf="!editMode && !dataViewMode" + *ngIf="!dataViewMode" [attr.data-cy]=" 'more-options-' + configuredWidget.baseAppearanceConfig.widgetTitle.replaceAll( @@ -97,20 +97,6 @@ Edit Widget -