UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

129 lines 6.78 kB
import { OnDestroy, OnInit } from '@angular/core'; import { FormBuilder, NgForm, ValidatorFn } from '@angular/forms'; import { AggregationOptionStatus, AggregationService } from '@c8y/ngx-components'; import { WidgetConfigComponent } from '@c8y/ngx-components/context-dashboard'; import { DatapointAttributesFormConfig, DatapointSelectorModalOptions } from '@c8y/ngx-components/datapoint-selector'; import { DatapointsTableConfig } from '../datapoints-table-widget.model'; import { DatapointsTableService } from '../datapoints-table.service'; import * as i0 from "@angular/core"; export declare function minOneDatapointActive(): ValidatorFn; export declare class DatapointsTableWidgetConfigComponent implements OnInit, OnDestroy { private aggregationService; private datapointsTableService; private formBuilder; private form; private widgetConfig; /** * Data points table widget config. */ config: DatapointsTableConfig; readonly AGGREGATION_LABELS: { readonly NONE: string; readonly MINUTELY: string; readonly HOURLY: string; readonly DAILY: string; }; readonly DATE_SELECTION_LABELS: { readonly config: "Widget configuration"; readonly view_and_config: "Widget and widget configuration"; readonly dashboard_context: "Dashboard time range"; }; readonly DEFAULT_DATE_SELECTOR_VALUE: "dashboard_context"; readonly DEFAULT_INTERVAL_VALUE: "hours"; readonly TIME_RANGE_INTERVAL_LABELS: { readonly minutes: "Last minute"; readonly hours: "Last hour"; readonly days: "Last day"; readonly weeks: "Last week"; readonly months: "Last month"; readonly custom: "Custom"; }; readonly AGGREGATION_VALUES_ARR: readonly ["NONE", import("packages/client/lib").aggregationType.MINUTELY, import("packages/client/lib").aggregationType.HOURLY, import("packages/client/lib").aggregationType.DAILY]; readonly DATE_SELECTION_VALUES_ARR: readonly ["dashboard_context", "config", "view_and_config"]; readonly INTERVAL_VALUES_ARR: readonly ["minutes", "hours", "days", "weeks", "months", "custom"]; readonly REFRESH_INTERVAL_VALUES_ARR: number[]; datapointSelectionConfig: Partial<DatapointSelectorModalOptions>; disabledAggregationOptions: AggregationOptionStatus; defaultFormOptions: Partial<DatapointAttributesFormConfig>; formGroup: ReturnType<DatapointsTableWidgetConfigComponent['createForm']>; isWidgetLinkedToGlobalTimeContext: boolean; private decimalLimits; /** * Indicate when the time interval selector item has been changed programmatically. * * This property is used to track changes in the time interval selector * that are not triggered by direct user interaction, but by the application itself. * * In our case, the date selector and the interval selector are linked. * So, when one of them changes, it affects the other. * For example, selecting "Last hour" in the interval selector should automatically update the date range to the last hour. * But without this flag, changing the date range would also update the interval selector, resulting in "Custom date" being selected. * This happens because the system would interpret the behavior this way. */ private isIntervalSelectorChangedProgrammatically; private destroy$; constructor(aggregationService: AggregationService, datapointsTableService: DatapointsTableService, formBuilder: FormBuilder, form: NgForm, widgetConfig: WidgetConfigComponent); ngOnInit(): void; ngOnDestroy(): void; onBeforeSave(config?: DatapointsTableConfig): void; toggleRefreshIntervalControl(): void; private updateTimeContext; private initForm; private createForm; private determineGlobalDateSelectorValueForLegacyWidget; private isAutoRefershDisabled; /** * Handles changes to the auto-refresh toggle control and updates the aggregation control accordingly. * * This method subscribes to the value changes of the auto-refresh toggle form control. * When auto-refresh is enabled, the aggregation control's value is set to 'none' and the control is * visually disabled (but not programmatically disabled to ensure the value is saved). * When auto-refresh is disabled, the aggregation control is enabled. */ private handleAutoRefreshToggleChanges; /** * Handles changes in the interval selector form control. */ private handleIntervalSelectorChanges; private handleNonCustomInterval; private updateDateRange; private updateDisabledAggregationOptions; private updateAggregationIfAutoRefreshDisabled; private setAggregationValue; /** * Handles changes in the date selector form control. */ private handleDateSelectorChanges; private handleDateChange; private handleCustomIntervalDateChange; private setIntervalToCustom; /** * Handles changes in the global date selector form control. */ private handleGlobalDateSelectorChanges; private handleDashboardContext; private handleNonDashboardContext; private isConfigSavedWithoutDashboardTimeOption; private updateAggregationIfNecessary; /** * Sets the aggregation control to the first available (non-disabled) option if the current option is disabled. * * This method: * - Retrieves the current value of the aggregation control. * - Checks if the current aggregation option is disabled. * - If the current option is disabled, sets the control to the first available (non-disabled) option based on the following order: * - If the current value is `DAILY`, it switches to `HOURLY` if it's not disabled, otherwise to `MINUTELY` if `HOURLY` is also disabled. * - If the current value is `HOURLY`, it switches to `MINUTELY` if it's not disabled. * - If all options are disabled, it sets the value to `NONE`. * * The disabled state is stored in the `disabledAggregationOptions` object, * where the key is the aggregation value and the value is a boolean indicating whether the option is disabled. * * The `AGGREGATION_VALUES` object defines the possible aggregation values. */ private setToFirstAvailableAggregationOptionIfCurrentAggregationIsDisabled; private deleteAggregationProperty; static ɵfac: i0.ɵɵFactoryDeclaration<DatapointsTableWidgetConfigComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<DatapointsTableWidgetConfigComponent, "c8y-datapoints-table-view-config", never, { "config": { "alias": "config"; "required": false; }; }, {}, never, never, true, never>; } //# sourceMappingURL=datapoints-table-config.component.d.ts.map