UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

294 lines (287 loc) 12 kB
import { KPIDetails } from '@c8y/ngx-components/datapoint-selector'; import { GlobalContextState, GLOBAL_CONTEXT_DISPLAY_MODE, PresetName } from '@c8y/ngx-components/global-context'; import * as _angular_core from '@angular/core'; import { OnInit, AfterViewInit } from '@angular/core'; import { IManagedObject, IMeasurement } from '@c8y/client'; import { DynamicComponentAlertAggregator, DashboardChildComponent, ColorRangeBoundaries } from '@c8y/ngx-components'; import { ExportConfig } from '@c8y/ngx-components/datapoints-export-selector'; import * as _angular_forms from '@angular/forms'; import { FormGroup, FormArray } from '@angular/forms'; import { CdkDragDrop } from '@angular/cdk/drag-drop'; import { Observable } from 'rxjs'; /** * Datapoint with enriched measurement data */ interface DatapointWithMeasurement extends KPIDetails { id?: string; currentValue?: number | null; timestamp?: Date | null; diffValue?: number | null; diffPercentValue?: number | null; currentFractionSize?: string; diffFractionSize?: string; diffPercentFractionSize?: string; } /** * Individual column configuration with ordering support */ interface ColumnConfig { id: 'kpi' | 'target' | 'current' | 'diff' | 'diffPercentage' | 'asset'; label: string; visible: boolean; order: number; } /** * Column visibility options for the Datapoints List widget */ interface DatapointsListOptions { /** * Array of column configurations with visibility and ordering */ columns?: ColumnConfig[]; /** * Legacy boolean properties for backwards compatibility * These are automatically migrated to the columns array format */ kpi?: boolean; target?: boolean; current?: boolean; diff?: boolean; diffPercentage?: boolean; asset?: boolean; dataPoints?: KPIDetails[]; } /** * Configuration interface for the Datapoints List widget * Extends GlobalContextState to support global context integration */ interface DatapointsListConfig extends Partial<GlobalContextState> { /** * Array of selected datapoints to display in the list */ datapoints: KPIDetails[]; /** * Display settings inherited from the widget definition */ displaySettings: { globalTimeContext: boolean; globalRealtimeContext: boolean; globalAggregationContext: boolean; globalAutoRefreshContext: boolean; }; /** * Column visibility and widget options */ options?: DatapointsListOptions; /** * Number of decimal places to display for numeric values */ decimalPlaces?: number; } declare class DatapointsListViewComponent implements OnInit { config: _angular_core.InputSignal<DatapointsListConfig>; isInPreviewMode: _angular_core.InputSignal<boolean>; private readonly alertService; private readonly dashboardChild; private readonly defaultColumns; private readonly fetchService; private readonly groupService; private readonly inventoryService; private readonly router; private readonly widgetConfigMigrationService; readonly CONTEXT_FEATURE: { readonly LIVE_TIME: "liveTime"; readonly HISTORY_TIME: "historyTime"; readonly AGGREGATION: "aggregation"; readonly AUTO_REFRESH: "autoRefresh"; readonly REFRESH: "refresh"; readonly REFRESH_LIVE: "refreshLive"; readonly REFRESH_HISTORY: "refreshHistory"; }; readonly GLOBAL_CONTEXT_DISPLAY_MODE: typeof GLOBAL_CONTEXT_DISPLAY_MODE; missingAllPermissionsAlert: DynamicComponentAlertAggregator; targetManagedObjects: Map<string, IManagedObject>; configSignal: _angular_core.WritableSignal<DatapointsListConfig>; contextConfig: _angular_core.WritableSignal<GlobalContextState>; dataPoints: _angular_core.WritableSignal<DatapointWithMeasurement[]>; displayMode: _angular_core.WritableSignal<"dashboard" | "config" | "view_and_config">; hasLoadedOnce: _angular_core.WritableSignal<boolean>; hasNoPermissionsToReadAnyMeasurement: _angular_core.WritableSignal<boolean>; isLinkedToGlobal: _angular_core.WritableSignal<boolean>; isLoading: _angular_core.WritableSignal<boolean>; widgetControls: _angular_core.WritableSignal<PresetName>; fractionSize: _angular_core.Signal<string>; columns: _angular_core.Signal<ColumnConfig[]>; visibleColumns: _angular_core.Signal<ColumnConfig[]>; exportConfig: _angular_core.Signal<ExportConfig>; activeDataPoints: _angular_core.Signal<KPIDetails[]>; private loadRequestId; private readonly seriesWithoutPermissionToReadCount; constructor(); ngOnInit(): void; onContextChange(event: { context: GlobalContextState; diff: GlobalContextState; }): void; onRefresh(): void; onExportModalOpen(isOpened: boolean): void; redirectToAsset(assetId: string | number | undefined): Promise<void>; getTargetManagedObject(targetId: string | number): IManagedObject | undefined; getDashboardChild(): DashboardChildComponent | null; getRangeValues(dp: KPIDetails): ColorRangeBoundaries; onListScrolled(): void; onListScrolledToTop(): void; /** Runs once on init; subsequent input changes are already in the new format. */ private applyConfigMigration; private extractContextState; private setAutoRefreshPaused; private loadDatapoints; private fetchMeasurements; private checkAndDisplayPermissionErrors; private handleNoPermissionErrorMessage; private showMessageForMissingPermissionsForAllSeries; static ɵfac: _angular_core.ɵɵFactoryDeclaration<DatapointsListViewComponent, never>; static ɵcmp: _angular_core.ɵɵComponentDeclaration<DatapointsListViewComponent, "c8y-datapoints-list", never, { "config": { "alias": "config"; "required": true; "isSignal": true; }; "isInPreviewMode": { "alias": "isInPreviewMode"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>; } declare class DatapointsListService { /** * Calculate difference between current value and target * @param datapoint - Datapoint record * @returns Difference value or null if value/target is undefined */ diff(datapoint: DatapointWithMeasurement): number | null; /** * Calculate percentage difference between current value and target * @param datapoint - Datapoint record * @returns Percentage difference or null if target is undefined */ diffPercent(datapoint: DatapointWithMeasurement): number | null; /** * Get fraction size format based on whether the value is an integer * @param value - Number to check * @param defaultFractionSize - Default fraction size format to use for non-integers * @returns Fraction size format ('1.0-0' for integers, defaultFractionSize for decimals) */ getFractionSize(value: number | null | undefined, defaultFractionSize: string): string; /** * Extract current value and timestamp from a measurement * @param datapoint - Datapoint configuration (contains fragment and series) * @param measurement - Measurement to extract value from * @returns Object containing extracted value and timestamp (null if not found) */ extractMeasurementValue(datapoint: KPIDetails, measurement: IMeasurement | undefined): { value: number | null; timestamp: Date | null; }; static ɵfac: _angular_core.ɵɵFactoryDeclaration<DatapointsListService, never>; static ɵprov: _angular_core.ɵɵInjectableDeclaration<DatapointsListService>; } interface FetchConfig { fractionSize: string; dateFrom?: string; dateTo?: string; } interface FetchResult { dataPoints: DatapointWithMeasurement[]; seriesWithoutPermissionCount: number; targetManagedObjects: Map<string, IManagedObject>; } /** * Service that handles all data-fetching operations for the datapoints list widget. * Encapsulates measurement fetching, data enrichment, and error handling. */ declare class DatapointsListFetchService { private alertService; private measurementService; private inventoryService; private datapointsListService; /** * Fetch measurements for all active datapoints and enrich them with calculated values. */ fetchDatapointsWithMeasurements(datapoints: KPIDetails[], config: FetchConfig): Promise<FetchResult>; /** * Fetch and enrich all datapoints in parallel. * Each datapoint fetch is independent - one failure doesn't affect others. */ private fetchAllDatapoints; /** * Fetch measurement for a single datapoint and return enriched result. * Handles errors gracefully - returns empty datapoint on failure. */ private fetchSingleDatapoint; /** * Handle fetch error and return appropriate result. */ private handleFetchError; /** * Create an enriched datapoint with measurement value and all calculated fields. */ private createEnrichedDatapoint; /** * Calculate and set all derived fields on a datapoint. * Includes diff, diffPercent, and fraction sizes for display formatting. */ private calculateDerivedFields; /** * Fetch managed objects for device status display. */ private fetchTargetManagedObjects; /** * Get unique target IDs from datapoints. */ private getUniqueTargetIds; /** * Fetch a single managed object and add to the map. */ private fetchManagedObject; /** * Fetch the most recent measurement for a datapoint within the specified date range. */ private getMeasurementForDatapoint; /** * Get unique ID for a datapoint. * Uses target ID if available, otherwise generates fallback based on index. */ private getDatapointId; static ɵfac: _angular_core.ɵɵFactoryDeclaration<DatapointsListFetchService, never>; static ɵprov: _angular_core.ɵɵInjectableDeclaration<DatapointsListFetchService>; } declare class DatapointsListConfigComponent implements OnInit, AfterViewInit { config: _angular_core.InputSignal<DatapointsListConfig>; private readonly previewTemplate; private readonly defaultColumns; private readonly destroyRef; private readonly form; private readonly formBuilder; private readonly widgetConfigMigrationService; private readonly widgetConfigService; readonly controls: PresetName; readonly minDecimalPlaces = 0; readonly maxDecimalPlaces = 10; configForm: _angular_core.WritableSignal<FormGroup<{ decimalPlaces: _angular_forms.FormControl<number>; columns: FormArray<FormGroup<any>>; }>>; readonly columnsFormArray: _angular_core.Signal<FormArray<any>>; /** * Debounced config for preview to prevent multiple series requests on initial load. * Uses debounceTime to batch rapid emissions (e.g., from initConfig + GlobalContext processing). */ previewConfig$: Observable<DatapointsListConfig>; ngOnInit(): void; ngAfterViewInit(): void; onColumnDrop(event: CdkDragDrop<ColumnConfig[]>): void; private initForm; private pushFormToService; private createForm; private createColumnFormGroup; private migrateColumnsConfig; private minOneColumnVisible; /** Stamp epoch defaults so the editor opens matching the AngularJS predecessor. */ private applyLegacyEpochDefaults; static ɵfac: _angular_core.ɵɵFactoryDeclaration<DatapointsListConfigComponent, never>; static ɵcmp: _angular_core.ɵɵComponentDeclaration<DatapointsListConfigComponent, "c8y-datapoints-list-view-config", never, { "config": { "alias": "config"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>; } export { DatapointsListConfigComponent, DatapointsListFetchService, DatapointsListService, DatapointsListViewComponent }; export type { ColumnConfig, DatapointWithMeasurement, DatapointsListConfig, DatapointsListOptions }; //# sourceMappingURL=index.d.ts.map