From c503829cad8f5982e61a8e1d5f86e1ff2b4e947c Mon Sep 17 00:00:00 2001 From: Marcelfrueh <78954450+Marcelfrueh@users.noreply.github.com> Date: Fri, 25 Oct 2024 16:18:21 +0200 Subject: [PATCH 1/8] Time range selector moved to shared-ui --- .../time-range-selector.component.html | 0 .../time-range-selector.component.scss | 2 -- .../time-range-selector.component.ts | 0 .../custom-time-range-selection.component.html | 0 .../custom-time-range-selection.component.scss | 0 .../custom-time-range-selection.component.ts | 0 .../time-selector-menu.component.html | 0 .../time-selector-menu.component.scss | 0 .../time-selector-menu.component.ts | 0 .../lib}/services/time-selection.service.ts | 0 .../shared-ui/src/lib/shared-ui.module.ts | 18 ++++++++++++++++++ .../streampipes/shared-ui/src/public-api.ts | 3 +++ .../data-explorer-dashboard-panel.component.ts | 2 +- .../data-explorer-data-view.component.ts | 2 +- ...data-explorer-dashboard-widget.component.ts | 2 +- .../base-data-explorer-widget.directive.ts | 2 +- .../app/data-explorer/data-explorer.module.ts | 13 ------------- 17 files changed, 25 insertions(+), 19 deletions(-) rename ui/{src/app/data-explorer => projects/streampipes/shared-ui/src/lib}/components/time-selector/time-range-selector.component.html (100%) rename ui/{src/app/data-explorer => projects/streampipes/shared-ui/src/lib}/components/time-selector/time-range-selector.component.scss (97%) rename ui/{src/app/data-explorer => projects/streampipes/shared-ui/src/lib}/components/time-selector/time-range-selector.component.ts (100%) rename ui/{src/app/data-explorer => projects/streampipes/shared-ui/src/lib}/components/time-selector/time-selector-menu/custom-time-range-selection/custom-time-range-selection.component.html (100%) rename ui/{src/app/data-explorer => projects/streampipes/shared-ui/src/lib}/components/time-selector/time-selector-menu/custom-time-range-selection/custom-time-range-selection.component.scss (100%) rename ui/{src/app/data-explorer => projects/streampipes/shared-ui/src/lib}/components/time-selector/time-selector-menu/custom-time-range-selection/custom-time-range-selection.component.ts (100%) rename ui/{src/app/data-explorer => projects/streampipes/shared-ui/src/lib}/components/time-selector/time-selector-menu/time-selector-menu.component.html (100%) rename ui/{src/app/data-explorer => projects/streampipes/shared-ui/src/lib}/components/time-selector/time-selector-menu/time-selector-menu.component.scss (100%) rename ui/{src/app/data-explorer => projects/streampipes/shared-ui/src/lib}/components/time-selector/time-selector-menu/time-selector-menu.component.ts (100%) rename ui/{src/app/data-explorer => projects/streampipes/shared-ui/src/lib}/services/time-selection.service.ts (100%) diff --git a/ui/src/app/data-explorer/components/time-selector/time-range-selector.component.html b/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-range-selector.component.html similarity index 100% rename from ui/src/app/data-explorer/components/time-selector/time-range-selector.component.html rename to ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-range-selector.component.html diff --git a/ui/src/app/data-explorer/components/time-selector/time-range-selector.component.scss b/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-range-selector.component.scss similarity index 97% rename from ui/src/app/data-explorer/components/time-selector/time-range-selector.component.scss rename to ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-range-selector.component.scss index aef8593a37..28deb3738b 100644 --- a/ui/src/app/data-explorer/components/time-selector/time-range-selector.component.scss +++ b/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-range-selector.component.scss @@ -16,8 +16,6 @@ * */ -@import '../../../../scss/variables'; - .start-date-margin { margin-right: 5px; } diff --git a/ui/src/app/data-explorer/components/time-selector/time-range-selector.component.ts b/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-range-selector.component.ts similarity index 100% rename from ui/src/app/data-explorer/components/time-selector/time-range-selector.component.ts rename to ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-range-selector.component.ts diff --git a/ui/src/app/data-explorer/components/time-selector/time-selector-menu/custom-time-range-selection/custom-time-range-selection.component.html b/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-selector-menu/custom-time-range-selection/custom-time-range-selection.component.html similarity index 100% rename from ui/src/app/data-explorer/components/time-selector/time-selector-menu/custom-time-range-selection/custom-time-range-selection.component.html rename to ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-selector-menu/custom-time-range-selection/custom-time-range-selection.component.html diff --git a/ui/src/app/data-explorer/components/time-selector/time-selector-menu/custom-time-range-selection/custom-time-range-selection.component.scss b/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-selector-menu/custom-time-range-selection/custom-time-range-selection.component.scss similarity index 100% rename from ui/src/app/data-explorer/components/time-selector/time-selector-menu/custom-time-range-selection/custom-time-range-selection.component.scss rename to ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-selector-menu/custom-time-range-selection/custom-time-range-selection.component.scss diff --git a/ui/src/app/data-explorer/components/time-selector/time-selector-menu/custom-time-range-selection/custom-time-range-selection.component.ts b/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-selector-menu/custom-time-range-selection/custom-time-range-selection.component.ts similarity index 100% rename from ui/src/app/data-explorer/components/time-selector/time-selector-menu/custom-time-range-selection/custom-time-range-selection.component.ts rename to ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-selector-menu/custom-time-range-selection/custom-time-range-selection.component.ts diff --git a/ui/src/app/data-explorer/components/time-selector/time-selector-menu/time-selector-menu.component.html b/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-selector-menu/time-selector-menu.component.html similarity index 100% rename from ui/src/app/data-explorer/components/time-selector/time-selector-menu/time-selector-menu.component.html rename to ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-selector-menu/time-selector-menu.component.html diff --git a/ui/src/app/data-explorer/components/time-selector/time-selector-menu/time-selector-menu.component.scss b/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-selector-menu/time-selector-menu.component.scss similarity index 100% rename from ui/src/app/data-explorer/components/time-selector/time-selector-menu/time-selector-menu.component.scss rename to ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-selector-menu/time-selector-menu.component.scss diff --git a/ui/src/app/data-explorer/components/time-selector/time-selector-menu/time-selector-menu.component.ts b/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-selector-menu/time-selector-menu.component.ts similarity index 100% rename from ui/src/app/data-explorer/components/time-selector/time-selector-menu/time-selector-menu.component.ts rename to ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-selector-menu/time-selector-menu.component.ts diff --git a/ui/src/app/data-explorer/services/time-selection.service.ts b/ui/projects/streampipes/shared-ui/src/lib/services/time-selection.service.ts similarity index 100% rename from ui/src/app/data-explorer/services/time-selection.service.ts rename to ui/projects/streampipes/shared-ui/src/lib/services/time-selection.service.ts diff --git a/ui/projects/streampipes/shared-ui/src/lib/shared-ui.module.ts b/ui/projects/streampipes/shared-ui/src/lib/shared-ui.module.ts index d5b90cf68d..5a1b150843 100644 --- a/ui/projects/streampipes/shared-ui/src/lib/shared-ui.module.ts +++ b/ui/projects/streampipes/shared-ui/src/lib/shared-ui.module.ts @@ -17,7 +17,13 @@ */ import { NgModule } from '@angular/core'; +import { + DefaultMatCalendarRangeStrategy, + MatDatepickerModule, + MatRangeDateSelectionModel, +} from '@angular/material/datepicker'; import { ConfirmDialogComponent } from './dialog/confirm-dialog/confirm-dialog.component'; +import { MatCardModule } from '@angular/material/card'; import { PanelDialogComponent } from './dialog/panel-dialog/panel-dialog.component'; import { StandardDialogComponent } from './dialog/standard-dialog/standard-dialog.component'; import { CommonModule } from '@angular/common'; @@ -55,6 +61,9 @@ import { AssetBrowserFilterTypeComponent } from './components/asset-browser/asse import { AssetBrowserHierarchyComponent } from './components/asset-browser/asset-browser-hierarchy/asset-browser-hierarchy.component'; import { AssetBrowserNodeComponent } from './components/asset-browser/asset-browser-hierarchy/asset-browser-node/asset-browser-node.component'; import { AssetBrowserNodeInfoComponent } from './components/asset-browser/asset-browser-hierarchy/asset-browser-node/asset-browser-node-info/asset-browser-node-info.component'; +import { TimeRangeSelectorComponent } from './components/time-selector/time-range-selector.component'; +import { TimeRangeSelectorMenuComponent } from './components/time-selector/time-selector-menu/time-selector-menu.component'; +import { CustomTimeRangeSelectionComponent } from './components/time-selector/time-selector-menu/custom-time-range-selection/custom-time-range-selection.component'; import { MatSelectModule } from '@angular/material/select'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatMenuModule } from '@angular/material/menu'; @@ -74,6 +83,7 @@ import { MatTreeModule } from '@angular/material/tree'; AssetBrowserNodeInfoComponent, AssetBrowserToolbarComponent, ConfirmDialogComponent, + CustomTimeRangeSelectionComponent, PanelDialogComponent, StandardDialogComponent, SpBasicFieldDescriptionComponent, @@ -88,6 +98,8 @@ import { MatTreeModule } from '@angular/material/tree'; SpTableComponent, SplitSectionComponent, SpWarningBoxComponent, + TimeRangeSelectorComponent, + TimeRangeSelectorMenuComponent, ], imports: [ CommonModule, @@ -102,6 +114,8 @@ import { MatTreeModule } from '@angular/material/tree'; MatTabsModule, MatTooltipModule, MatTreeModule, + MatDatepickerModule, + MatCardModule, PortalModule, OverlayModule, MatDialogModule, @@ -109,6 +123,7 @@ import { MatTreeModule } from '@angular/material/tree'; MatPaginator, MatSort, ], + providers: [DefaultMatCalendarRangeStrategy, MatRangeDateSelectionModel], exports: [ AssetBrowserComponent, ConfirmDialogComponent, @@ -126,6 +141,9 @@ import { MatTreeModule } from '@angular/material/tree'; SpTableComponent, SplitSectionComponent, SpWarningBoxComponent, + CustomTimeRangeSelectionComponent, + TimeRangeSelectorComponent, + TimeRangeSelectorMenuComponent, ], }) export class SharedUiModule {} diff --git a/ui/projects/streampipes/shared-ui/src/public-api.ts b/ui/projects/streampipes/shared-ui/src/public-api.ts index a923f5abbc..67892b5dba 100644 --- a/ui/projects/streampipes/shared-ui/src/public-api.ts +++ b/ui/projects/streampipes/shared-ui/src/public-api.ts @@ -39,6 +39,8 @@ 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-range-selector.component'; +export * from './lib/components/time-selector/time-selector-menu/time-selector-menu.component'; export * from './lib/models/sp-navigation.model'; @@ -47,4 +49,5 @@ export * from './lib/services/jwt-token-storage.service'; export * from './lib/services/current-user.service'; export * from './lib/services/echarts-toolbox.service'; export * from './lib/services/colorization.service'; +export * from './lib/services/time-selection.service'; export * from './lib/components/asset-browser/asset-browser.service'; diff --git a/ui/src/app/data-explorer/components/dashboard/data-explorer-dashboard-panel.component.ts b/ui/src/app/data-explorer/components/dashboard/data-explorer-dashboard-panel.component.ts index 7a28ff025d..016a22eb5d 100644 --- a/ui/src/app/data-explorer/components/dashboard/data-explorer-dashboard-panel.component.ts +++ b/ui/src/app/data-explorer/components/dashboard/data-explorer-dashboard-panel.component.ts @@ -28,7 +28,6 @@ import { TimeSelectionId, TimeSettings, } from '@streampipes/platform-services'; -import { TimeSelectionService } from '../../services/time-selection.service'; import { AuthService } from '../../../services/auth.service'; import { UserPrivilege } from '../../../_enums/user-privilege.enum'; import { @@ -48,6 +47,7 @@ import { SpDataExplorerRoutes } from '../../data-explorer.routes'; import { DataExplorerRoutingService } from '../../services/data-explorer-routing.service'; import { DataExplorerDetectChangesService } from '../../services/data-explorer-detect-changes.service'; import { SupportsUnsavedChangeDialog } from '../../models/dataview-dashboard.model'; +import { TimeSelectionService } from 'projects/streampipes/shared-ui/src/lib/services/time-selection.service'; @Component({ selector: 'sp-data-explorer-dashboard-panel', diff --git a/ui/src/app/data-explorer/components/data-view/data-explorer-data-view.component.ts b/ui/src/app/data-explorer/components/data-view/data-explorer-data-view.component.ts index 202946c582..4ff02c6095 100644 --- a/ui/src/app/data-explorer/components/data-view/data-explorer-data-view.component.ts +++ b/ui/src/app/data-explorer/components/data-view/data-explorer-data-view.component.ts @@ -30,7 +30,6 @@ import { RouterStateSnapshot, } from '@angular/router'; import { ConfirmDialogComponent } from '@streampipes/shared-ui'; -import { TimeSelectionService } from '../../services/time-selection.service'; import { DataExplorerRoutingService } from '../../services/data-explorer-routing.service'; import { DataExplorerDashboardService } from '../../services/data-explorer-dashboard.service'; import { DataExplorerDetectChangesService } from '../../services/data-explorer-detect-changes.service'; @@ -38,6 +37,7 @@ import { SupportsUnsavedChangeDialog } from '../../models/dataview-dashboard.mod import { Observable, of } from 'rxjs'; import { MatDialog } from '@angular/material/dialog'; import { map } from 'rxjs/operators'; +import { TimeSelectionService } from 'projects/streampipes/shared-ui/src/lib/services/time-selection.service'; @Component({ selector: 'sp-data-explorer-data-view', diff --git a/ui/src/app/data-explorer/components/widget/data-explorer-dashboard-widget.component.ts b/ui/src/app/data-explorer/components/widget/data-explorer-dashboard-widget.component.ts index 21e5170c0e..4293f1460d 100644 --- a/ui/src/app/data-explorer/components/widget/data-explorer-dashboard-widget.component.ts +++ b/ui/src/app/data-explorer/components/widget/data-explorer-dashboard-widget.component.ts @@ -47,8 +47,8 @@ import { UserPrivilege } from '../../../_enums/user-privilege.enum'; import { CurrentUserService } from '@streampipes/shared-ui'; import { BaseWidgetData } from '../../models/dataview-dashboard.model'; import { DataExplorerDashboardService } from '../../services/data-explorer-dashboard.service'; -import { TimeSelectionService } from '../../services/time-selection.service'; import { MatMenuTrigger } from '@angular/material/menu'; +import { TimeSelectionService } from 'projects/streampipes/shared-ui/src/lib/services/time-selection.service'; @Component({ selector: 'sp-data-explorer-dashboard-widget', diff --git a/ui/src/app/data-explorer/components/widgets/base/base-data-explorer-widget.directive.ts b/ui/src/app/data-explorer/components/widgets/base/base-data-explorer-widget.directive.ts index 5df627e9e7..adf7653af0 100644 --- a/ui/src/app/data-explorer/components/widgets/base/base-data-explorer-widget.directive.ts +++ b/ui/src/app/data-explorer/components/widgets/base/base-data-explorer-widget.directive.ts @@ -45,10 +45,10 @@ import { } from '../../../models/dataview-dashboard.model'; import { Observable, Subject, Subscription, zip } from 'rxjs'; import { DataExplorerFieldProviderService } from '../../../services/data-explorer-field-provider-service'; -import { TimeSelectionService } from '../../../services/time-selection.service'; import { catchError, switchMap } from 'rxjs/operators'; import { DataExplorerWidgetRegistry } from '../../../registry/data-explorer-widget-registry'; import { SpFieldUpdateService } from '../../../services/field-update.service'; +import { TimeSelectionService } from 'projects/streampipes/shared-ui/src/lib/services/time-selection.service'; @Directive() export abstract class BaseDataExplorerWidgetDirective< diff --git a/ui/src/app/data-explorer/data-explorer.module.ts b/ui/src/app/data-explorer/data-explorer.module.ts index c3070b45b5..5c5e6790b3 100644 --- a/ui/src/app/data-explorer/data-explorer.module.ts +++ b/ui/src/app/data-explorer/data-explorer.module.ts @@ -23,11 +23,6 @@ import { FlexLayoutModule } from '@ngbracket/ngx-layout'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { MatChipsModule } from '@angular/material/chips'; import { MatNativeDateModule } from '@angular/material/core'; -import { - DefaultMatCalendarRangeStrategy, - MatDatepickerModule, - MatRangeDateSelectionModel, -} from '@angular/material/datepicker'; import { MatGridListModule } from '@angular/material/grid-list'; import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; import { MatSliderModule } from '@angular/material/slider'; @@ -43,7 +38,6 @@ import { CoreUiModule } from '../core-ui/core-ui.module'; import { DataExplorerDashboardGridComponent } from './components/widget-view/grid-view/data-explorer-dashboard-grid.component'; import { DataExplorerOverviewComponent } from './components/overview/data-explorer-overview.component'; import { DataExplorerDashboardPanelComponent } from './components/dashboard/data-explorer-dashboard-panel.component'; -import { TimeRangeSelectorComponent } from './components/time-selector/time-range-selector.component'; import { DataExplorerDashboardWidgetComponent } from './components/widget/data-explorer-dashboard-widget.component'; import { ImageWidgetComponent } from './components/widgets/image/image-widget.component'; import { TrafficLightWidgetComponent } from './components/widgets/traffic-light/traffic-light-widget.component'; @@ -129,8 +123,6 @@ import { DataExplorerDataViewSelectionComponent } from './components/dashboard/d import { DataExplorerDashboardWidgetSelectionPanelComponent } from './components/dashboard/dashboard-widget-selection-panel/dashboard-widget-selection-panel.component'; import { DataExplorerDataViewPreviewComponent } from './components/dashboard/dashboard-widget-selection-panel/data-view-selection/data-view-preview/data-view-preview.component'; import { DataExplorerDashboardToolbarComponent } from './components/dashboard/dashboard-toolbar/dashboard-toolbar.component'; -import { TimeRangeSelectorMenuComponent } from './components/time-selector/time-selector-menu/time-selector-menu.component'; -import { CustomTimeRangeSelectionComponent } from './components/time-selector/time-selector-menu/custom-time-range-selection/custom-time-range-selection.component'; import { DataExplorerRefreshIntervalSettingsComponent } from './components/dashboard/dashboard-toolbar/refresh-interval-settings/refresh-interval-settings.component'; import { OrderSelectionPanelComponent } from './components/data-view/data-view-designer-panel/data-settings/order-selection-panel/order-selection-panel.component'; import { GaugeWidgetConfigComponent } from './components/widgets/gauge/config/gauge-widget-config.component'; @@ -174,7 +166,6 @@ import { GaugeWidgetConfigComponent } from './components/widgets/gauge/config/ga MatProgressSpinnerModule, ReactiveFormsModule, CoreUiModule, - MatDatepickerModule, MatNativeDateModule, MatSliderModule, MatSlideToggleModule, @@ -215,7 +206,6 @@ import { GaugeWidgetConfigComponent } from './components/widgets/gauge/config/ga ], declarations: [ AggregateConfigurationComponent, - CustomTimeRangeSelectionComponent, DataExplorerDashboardGridComponent, DataExplorerOverviewComponent, DataExplorerDashboardPanelComponent, @@ -259,8 +249,6 @@ import { GaugeWidgetConfigComponent } from './components/widgets/gauge/config/ga MapWidgetComponent, HeatmapWidgetConfigComponent, ImageViewerComponent, - TimeRangeSelectorComponent, - TimeRangeSelectorMenuComponent, DataExplorerVisualisationSettingsComponent, GroupSelectionPanelComponent, DataExplorerVisualisationSettingsComponent, @@ -283,7 +271,6 @@ import { GaugeWidgetConfigComponent } from './components/widgets/gauge/config/ga SpTimeSeriesAppearanceConfigComponent, SpDataZoomConfigComponent, ], - providers: [DefaultMatCalendarRangeStrategy, MatRangeDateSelectionModel], exports: [], }) export class DataExplorerModule { From 48058391c2b31fe632049fae29555aa63c7cd903 Mon Sep 17 00:00:00 2001 From: Marcelfrueh <78954450+Marcelfrueh@users.noreply.github.com> Date: Mon, 28 Oct 2024 09:27:06 +0100 Subject: [PATCH 2/8] Changed imports for time selection serivce --- .../dashboard/data-explorer-dashboard-panel.component.ts | 2 +- .../components/data-view/data-explorer-data-view.component.ts | 2 +- .../widget/data-explorer-dashboard-widget.component.ts | 2 +- .../widgets/base/base-data-explorer-widget.directive.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/src/app/data-explorer/components/dashboard/data-explorer-dashboard-panel.component.ts b/ui/src/app/data-explorer/components/dashboard/data-explorer-dashboard-panel.component.ts index 016a22eb5d..28bb0097bd 100644 --- a/ui/src/app/data-explorer/components/dashboard/data-explorer-dashboard-panel.component.ts +++ b/ui/src/app/data-explorer/components/dashboard/data-explorer-dashboard-panel.component.ts @@ -47,7 +47,7 @@ import { SpDataExplorerRoutes } from '../../data-explorer.routes'; import { DataExplorerRoutingService } from '../../services/data-explorer-routing.service'; import { DataExplorerDetectChangesService } from '../../services/data-explorer-detect-changes.service'; import { SupportsUnsavedChangeDialog } from '../../models/dataview-dashboard.model'; -import { TimeSelectionService } from 'projects/streampipes/shared-ui/src/lib/services/time-selection.service'; +import { TimeSelectionService } from '@streampipes/shared-ui'; @Component({ selector: 'sp-data-explorer-dashboard-panel', diff --git a/ui/src/app/data-explorer/components/data-view/data-explorer-data-view.component.ts b/ui/src/app/data-explorer/components/data-view/data-explorer-data-view.component.ts index 4ff02c6095..6ede8d66cb 100644 --- a/ui/src/app/data-explorer/components/data-view/data-explorer-data-view.component.ts +++ b/ui/src/app/data-explorer/components/data-view/data-explorer-data-view.component.ts @@ -37,7 +37,7 @@ import { SupportsUnsavedChangeDialog } from '../../models/dataview-dashboard.mod import { Observable, of } from 'rxjs'; import { MatDialog } from '@angular/material/dialog'; import { map } from 'rxjs/operators'; -import { TimeSelectionService } from 'projects/streampipes/shared-ui/src/lib/services/time-selection.service'; +import { TimeSelectionService } from '@streampipes/shared-ui'; @Component({ selector: 'sp-data-explorer-data-view', diff --git a/ui/src/app/data-explorer/components/widget/data-explorer-dashboard-widget.component.ts b/ui/src/app/data-explorer/components/widget/data-explorer-dashboard-widget.component.ts index 4293f1460d..51dee8acda 100644 --- a/ui/src/app/data-explorer/components/widget/data-explorer-dashboard-widget.component.ts +++ b/ui/src/app/data-explorer/components/widget/data-explorer-dashboard-widget.component.ts @@ -48,7 +48,7 @@ import { CurrentUserService } from '@streampipes/shared-ui'; import { BaseWidgetData } from '../../models/dataview-dashboard.model'; import { DataExplorerDashboardService } from '../../services/data-explorer-dashboard.service'; import { MatMenuTrigger } from '@angular/material/menu'; -import { TimeSelectionService } from 'projects/streampipes/shared-ui/src/lib/services/time-selection.service'; +import { TimeSelectionService } from '@streampipes/shared-ui'; @Component({ selector: 'sp-data-explorer-dashboard-widget', diff --git a/ui/src/app/data-explorer/components/widgets/base/base-data-explorer-widget.directive.ts b/ui/src/app/data-explorer/components/widgets/base/base-data-explorer-widget.directive.ts index adf7653af0..b28d5ac40a 100644 --- a/ui/src/app/data-explorer/components/widgets/base/base-data-explorer-widget.directive.ts +++ b/ui/src/app/data-explorer/components/widgets/base/base-data-explorer-widget.directive.ts @@ -48,7 +48,7 @@ import { DataExplorerFieldProviderService } from '../../../services/data-explore import { catchError, switchMap } from 'rxjs/operators'; import { DataExplorerWidgetRegistry } from '../../../registry/data-explorer-widget-registry'; import { SpFieldUpdateService } from '../../../services/field-update.service'; -import { TimeSelectionService } from 'projects/streampipes/shared-ui/src/lib/services/time-selection.service'; +import { TimeSelectionService } from '@streampipes/shared-ui'; @Directive() export abstract class BaseDataExplorerWidgetDirective< From 4f76a69c13c434917e823e4bb57b6688e3f7d51f Mon Sep 17 00:00:00 2001 From: Marcelfrueh <78954450+Marcelfrueh@users.noreply.github.com> Date: Mon, 28 Oct 2024 09:59:00 +0100 Subject: [PATCH 3/8] Modify imports --- ui/projects/streampipes/shared-ui/package.json | 3 ++- ui/projects/streampipes/shared-ui/src/public-api.ts | 1 + ui/projects/streampipes/shared-ui/tsconfig.lib.json | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/projects/streampipes/shared-ui/package.json b/ui/projects/streampipes/shared-ui/package.json index f2f8f4d9b5..6f8f27f9ef 100644 --- a/ui/projects/streampipes/shared-ui/package.json +++ b/ui/projects/streampipes/shared-ui/package.json @@ -10,7 +10,8 @@ "@angular/material": "^17.3.3", "@angular/router": "^17.3.3", "@streampipes/platform-services": "0.0.1", - "rxjs": "^7.5.7" + "rxjs": "^7.5.7", + "date-fns": "^3.6.0" }, "dependencies": { "tslib": "^2.6.2" diff --git a/ui/projects/streampipes/shared-ui/src/public-api.ts b/ui/projects/streampipes/shared-ui/src/public-api.ts index 67892b5dba..40fe20fa0a 100644 --- a/ui/projects/streampipes/shared-ui/src/public-api.ts +++ b/ui/projects/streampipes/shared-ui/src/public-api.ts @@ -41,6 +41,7 @@ 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-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/models/sp-navigation.model'; diff --git a/ui/projects/streampipes/shared-ui/tsconfig.lib.json b/ui/projects/streampipes/shared-ui/tsconfig.lib.json index e2c590dbbf..0b34959311 100644 --- a/ui/projects/streampipes/shared-ui/tsconfig.lib.json +++ b/ui/projects/streampipes/shared-ui/tsconfig.lib.json @@ -8,7 +8,7 @@ "declarationMap": true, "inlineSources": true, "types": [], - "lib": ["dom", "es2018"] + "lib": ["dom", "es2020"] }, "exclude": ["src/test.ts", "**/*.spec.ts"] } From 43e4eb7f6a1965fd0b30c546f5e33e22b07ef355 Mon Sep 17 00:00:00 2001 From: Marcelfrueh <78954450+Marcelfrueh@users.noreply.github.com> Date: Thu, 31 Oct 2024 15:34:39 +0100 Subject: [PATCH 4/8] Added option to customize date range quick selections --- .../src/lib/model/datalake/DateRange.ts | 47 ++++++- .../time-range-selector.component.html | 1 + .../time-range-selector.component.ts | 15 ++- ...custom-time-range-selection.component.html | 5 +- .../custom-time-range-selection.component.ts | 32 ++++- .../time-selector-menu.component.ts | 1 + .../lib/services/time-selection.service.ts | 127 +++++++++++++----- ...data-explorer-dashboard-panel.component.ts | 4 +- ...ata-explorer-dashboard-widget.component.ts | 2 +- .../data-explorer-detect-changes.service.ts | 2 +- 10 files changed, 187 insertions(+), 49 deletions(-) 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 9f3cff7d29..b3b417bb54 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 @@ -21,7 +21,50 @@ export interface TimeSettings { endTime: number; // deprecated dynamicSelection?: 15 | 60 | 1440 | 10080 | 43800 | 525600 | -1; - timeSelectionId?: TimeSelectionId; + timeSelectionId?: string; +} + +export class TimeSelectionConstants { + static CUSTOM = 'custom'; + static LAST_15_MINUTES = 'last-15-minutes'; + static LAST_HOUR = 'last-hour'; + static CURRENT_HOUR = 'current-hour'; + static LAST_DAY = 'last-day'; + static CURRENT_DAY = 'current-day'; + static LAST_WEEK = 'last-week'; + static CURRENT_WEEK = 'current-week'; + static LAST_MONTH = 'last-month'; + static CURRENT_MONTH = 'current-month'; + static LAST_YEAR = 'last-year'; + static CURRENT_YEAR = 'current-year'; + + static getLegacyTimeSelectionID(legacyID: number) { + if (legacyID === 0) { + return TimeSelectionConstants.CUSTOM; + } else if (legacyID === 1) { + return TimeSelectionConstants.LAST_15_MINUTES; + } else if (legacyID === 2) { + return TimeSelectionConstants.LAST_HOUR; + } else if (legacyID === 3) { + return TimeSelectionConstants.CURRENT_HOUR; + } else if (legacyID === 4) { + return TimeSelectionConstants.LAST_DAY; + } else if (legacyID === 5) { + return TimeSelectionConstants.CURRENT_DAY; + } else if (legacyID === 6) { + return TimeSelectionConstants.LAST_WEEK; + } else if (legacyID === 7) { + return TimeSelectionConstants.CURRENT_WEEK; + } else if (legacyID === 8) { + return TimeSelectionConstants.LAST_MONTH; + } else if (legacyID === 9) { + return TimeSelectionConstants.CURRENT_MONTH; + } else if (legacyID === 10) { + return TimeSelectionConstants.LAST_YEAR; + } else if (legacyID === 11) { + return TimeSelectionConstants.CURRENT_YEAR; + } + } } export interface WidgetTimeSettings { @@ -53,7 +96,7 @@ export enum TimeSelectionId { export interface QuickTimeSelection { label: string; - timeSelectionId: TimeSelectionId; + timeSelectionId: string; startTime: (now: Date) => Date; endTime: (now: Date) => Date; addDividerAfter?: boolean; 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 eb51825326..4e515e0694 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 @@ -64,6 +64,7 @@ #timeSelectorMenu [timeSettings]="timeSettings" (timeSettingsEmitter)="applyCurrentDateRange($event)" + [quickSelections]="quickSelections" class="w-100" > diff --git a/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-range-selector.component.ts b/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-range-selector.component.ts index a2b663d5b3..7f992c4803 100644 --- a/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-range-selector.component.ts +++ b/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-range-selector.component.ts @@ -28,7 +28,8 @@ import { ViewEncapsulation, } from '@angular/core'; import { - TimeSelectionId, + QuickTimeSelection, + TimeSelectionConstants, TimeSettings, TimeString, } from '@streampipes/platform-services'; @@ -55,6 +56,9 @@ export class TimeRangeSelectorComponent implements OnInit, OnChanges { @Input() showTimeSelector = true; + @Input() + quickSelections: QuickTimeSelection[] = []; + simpleTimeString: string = ''; timeString: TimeString; timeStringMode: 'simple' | 'advanced' = 'simple'; @@ -62,6 +66,9 @@ export class TimeRangeSelectorComponent implements OnInit, OnChanges { constructor(private timeSelectionService: TimeSelectionService) {} ngOnInit() { + this.timeSelectionService.initializeQuickTimeSelection( + this.quickSelections, + ); this.createDateString(); } @@ -112,7 +119,7 @@ export class TimeRangeSelectorComponent implements OnInit, OnChanges { this.timeSettings.startTime = newStartTime; this.timeSettings.endTime = newEndTime; - this.timeSettings.timeSelectionId = TimeSelectionId.CUSTOM; + this.timeSettings.timeSelectionId = TimeSelectionConstants.CUSTOM; this.timeSelectorMenu.triggerDisplayUpdate(); this.createDateString(); this.reloadData(); @@ -126,7 +133,9 @@ export class TimeRangeSelectorComponent implements OnInit, OnChanges { } createDateString(): void { - if (this.timeSettings.timeSelectionId !== TimeSelectionId.CUSTOM) { + if ( + this.timeSettings.timeSelectionId !== TimeSelectionConstants.CUSTOM + ) { this.simpleTimeString = this.timeSelectionService.getTimeSelection( this.timeSettings.timeSelectionId, ).label; diff --git a/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-selector-menu/custom-time-range-selection/custom-time-range-selection.component.html b/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-selector-menu/custom-time-range-selection/custom-time-range-selection.component.html index 1564d9b5dc..fb9d54b368 100644 --- a/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-selector-menu/custom-time-range-selection/custom-time-range-selection.component.html +++ b/ui/projects/streampipes/shared-ui/src/lib/components/time-selector/time-selector-menu/custom-time-range-selection/custom-time-range-selection.component.html @@ -26,7 +26,7 @@ -