Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: refresh interval settings for widgets in dashboard #3421

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class DataExplorerRefreshIntervalSettingsComponent implements OnInit {
@Input()
availableOptions: DashboardLiveSettings[];

liveRefreshEnabled: boolean;
liveRefreshEnabled: boolean = true;

ngOnInit() {
if (!this.liveSettings?.label) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@
class="formatted-datetime"
>
<span class="formatted-date">{{ timeString.startDate }}</span>
<span *ngIf="enableTimeChange">
<span *ngIf="enableTimePicker">
&nbsp;<span class="formatted-time">{{
timeString.startTime
}}</span>
</span>
<div *ngIf="enableTimeChange || !timeString.sameDay">
<div *ngIf="enableTimePicker || !timeString.sameDay">
<span class="formatted-date">&nbsp;-&nbsp;</span>
<span class="formatted-date">{{ timeString.endDate }}</span>
<span *ngIf="enableTimeChange">
<span *ngIf="enableTimePicker">
&nbsp;<span class="formatted-time">{{
timeString.endTime
}}</span>
Expand All @@ -69,7 +69,7 @@
[labels]="labels"
(timeSettingsEmitter)="applyCurrentDateRange($event)"
[quickSelections]="quickSelections"
[enableTimeChange]="enableTimeChange"
[enableTimePicker]="enableTimePicker"
[maxDayRange]="maxDayRange"
class="w-100"
>
Expand All @@ -89,7 +89,7 @@
<div fxLayoutAlign="end center">
<sp-data-explorer-refresh-interval-settings-component
#refreshIntervalSettings
*ngIf="liveSettings && showTimeSelector && showIntervalSettings"
*ngIf="liveSettings && showIntervalSettings"
[liveSettings]="liveSettings"
(intervalSettingsChangedEmitter)="
intervalSettingsChangedEmitter.emit($event)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class TimeRangeSelectorComponent
showTimeSelector = true;

@Input()
enableTimeChange = true;
enableTimePicker = true;

@Input()
showIntervalSettings = true;
Expand Down Expand Up @@ -225,8 +225,16 @@ export class TimeRangeSelectorComponent
const startDate = new Date(this.timeSettings.startTime);
const endDate = new Date(this.timeSettings.endTime);
this.timeString = {
startDate: this.formatDate(startDate),
endDate: this.formatDate(endDate),
startDate: this.timeSelectionService.formatDate(
startDate,
this.enableTimePicker,
this.dateFormat,
),
endDate: this.timeSelectionService.formatDate(
endDate,
this.enableTimePicker,
this.dateFormat,
),
startTime: startDate.toLocaleTimeString(),
endTime: endDate.toLocaleTimeString(),
sameDay: isSameDay(startDate, endDate),
Expand All @@ -235,10 +243,4 @@ export class TimeRangeSelectorComponent
this.timeStringMode = 'advanced';
}
}

private formatDate(date: Date): string {
return this.enableTimeChange
? date.toLocaleDateString()
: date.toLocaleDateString(navigator.language, this.dateFormat);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</mat-calendar>
</mat-card>

<div *ngIf="enableTimeChange" fxLayout="column" class="mt-10 mr-5">
<div *ngIf="enableTimePicker" fxLayout="column" class="mt-10 mr-5">
<div fxLayout="row" fxLayoutGap="10px">
<div fxFlex="30">
<span
Expand Down Expand Up @@ -73,7 +73,7 @@
</div>
</div>
</div>
<div *ngIf="!enableTimeChange" fxLayout="row" class="mt-10 date-preview">
<div *ngIf="!enableTimePicker" fxLayout="row" class="mt-10 date-preview">
{{ dateRangeString }}
</div>
<div
Expand All @@ -96,7 +96,7 @@
data-cy="apply-custom-time"
(click)="saveSelection()"
[disabled]="!dateSelectionComplete"
*ngIf="enableTimeChange"
*ngIf="enableTimePicker"
>
Apply
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class CustomTimeRangeSelectionComponent implements OnInit {
@Input() labels: TimeSelectorLabel;

@Input()
enableTimeChange: boolean;
enableTimePicker: boolean;

@Input()
maxDayRange: number;
Expand Down Expand Up @@ -96,7 +96,7 @@ export class CustomTimeRangeSelectionComponent implements OnInit {
}

formatDate(date: Date): string {
if (this.enableTimeChange === true) {
if (this.enableTimePicker === true) {
return date?.toLocaleDateString() || '-';
} else {
return date?.toLocaleDateString() || ' ';
Expand All @@ -119,7 +119,7 @@ export class CustomTimeRangeSelectionComponent implements OnInit {
if (this.selectionModel.isComplete()) {
if (this.maxDayRange === 0 || daysDiff + 1 <= this.maxDayRange) {
this.dateSelectionComplete = true;
if (!this.enableTimeChange) {
if (!this.enableTimePicker) {
this.saveSelection();
}
} else {
Expand All @@ -130,7 +130,7 @@ export class CustomTimeRangeSelectionComponent implements OnInit {
}

saveSelection(): void {
if (this.enableTimeChange === true) {
if (this.enableTimePicker === true) {
this.updateDateTime(
this.currentDateRange.start,
this.currentStartTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
<div *ngFor="let quickSelection of quickSelections">
<span
class="quick-link"
[ngClass]="{
selected:
quickSelection.timeSelectionId ===
timeSettings?.timeSelectionId &&
timeSettings?.timeSelectionId !== 'custom'
}"
[attr.data-cy]="
'time-selector-quick-' +
quickSelection.timeSelectionId
Expand All @@ -52,7 +58,7 @@
timeSettings: $event
})
"
[enableTimeChange]="enableTimeChange"
[enableTimePicker]="enableTimePicker"
[maxDayRange]="maxDayRange"
class="w-100"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@
.quick-link:hover {
font-weight: bold;
}

.quick-link.selected {
font-weight: bold;
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class TimeRangeSelectorMenuComponent implements OnInit {
labels: TimeSelectorLabel;

@Input()
enableTimeChange: boolean;
enableTimePicker: boolean;

@Input()
maxDayRange: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,4 +280,14 @@ export class TimeSelectionService {
const widgetTimeSettings = { timeSettings, widgetIndex };
this.timeSelectionChangeSubject.next(widgetTimeSettings);
}

public formatDate(
date: Date,
enableTimePicker: boolean,
dateFormat: Intl.DateTimeFormatOptions,
): string {
return enableTimePicker
? date.toLocaleDateString()
: date.toLocaleDateString(navigator.language, dateFormat);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ import { MatTreeModule } from '@angular/material/tree';
CustomTimeRangeSelectionComponent,
TimeRangeSelectorComponent,
TimeRangeSelectorMenuComponent,
DataExplorerRefreshIntervalSettingsComponent,
],
})
export class SharedUiModule {}
1 change: 1 addition & 0 deletions ui/projects/streampipes/shared-ui/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ 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';
export * from './lib/components/time-selector/refresh-interval-settings/refresh-interval-settings.component';

export * from './lib/models/sp-navigation.model';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@
aria-label="Options"
data-cy="options-data-explorer"
#menuTrigger="matMenuTrigger"
[matTooltip]="tooltipText"
matTooltipClass="no-wrap-tooltip"
>
<mat-icon
[color]="timeSettingsModified ? 'primary' : 'default'"
Expand All @@ -112,9 +114,12 @@
</button>
<mat-menu #optMenu="matMenu" class="large-menu">
<sp-time-selector-menu
#timeSelectorMenu
*ngIf="quickSelections"
[timeSettings]="clonedTimeSettings"
[quickSelections]="quickSelections"
[enableTimePicker]="enableTimePicker"
[maxDayRange]="maxDayRange"
[labels]="labels"
(timeSettingsEmitter)="modifyWidgetTimeSettings($event)"
class="w-100"
Expand Down
Loading
Loading