UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

176 lines 8.57 kB
import { ISeries } from '@c8y/client'; import { KPIDetails } from '@c8y/ngx-components/datapoint-selector'; import { DataFetchingService, DatapointsValuesDataMap, MinMaxValues, SourceId } from '@c8y/ngx-components/datapoints-export-selector'; import { Interval } from '@c8y/ngx-components/interval-picker'; import { DataPointsTableMap, DatapointTableItem, DatapointWithValues, DatapointsSeriesDataMap, DatapointsTableConfig, GroupedDatapointTableItem, TableColumnHeader, Value } from '../datapoints-table-widget.model'; import * as i0 from "@angular/core"; export declare class DatapointsTableViewService { private dataFetchingService; constructor(dataFetchingService: DataFetchingService); /** * Filters out inactive data points from the given array. * * @param datapoints - The array of data points to filter. * @returns An array of data points that are active. */ filterOutInactiveDatapoints(datapoints: KPIDetails[]): KPIDetails[]; hasMultipleDatapoints(datapoints: KPIDetails[]): boolean; /** * Returns a map of active data points device IDs with their corresponding series. * * Example output: * ```typescript * new Map([ * [ * "844657202", * [ * "c8y_Temperature.T" * ] * ], * [ * "32666427", * [ * "c8y_Battery.Battery" * ] * ] * ]); * ``` * @param datapoints - An array of data points. * @returns A map where the key is the data point ID and the value is an array of data point series. */ groupSeriesByDeviceId(activeDatapoints: KPIDetails[]): DatapointsValuesDataMap; /** * Retrieves the active data points series data and returns it as a map. * * @param datapointsValuesDataMap - A map of data point sources with their associated series. * @param config - The configuration of the data points table. * @param roundSeconds - Whether to round the seconds or not. * If true, the seconds will be rounded to 0. * If false, the seconds will be displayed as they are. * @returns A Promise that resolves to a Map object with data point IDs as keys and DataObject as values or undefined when all series has forbidden access. */ getAllActiveSeriesDataMap(datapointsValuesDataMap: DatapointsValuesDataMap, config: DatapointsTableConfig, roundSeconds: boolean): Promise<Map<string | number, ISeries>>; /** * Creates an array of DatapointsWithValues based on the provided datapoints and datapointsSeriesDataMap. * * Finds an index of a current data point within series object and based on that index filters values array. * * @param datapoints - An array of data points. * @param datapointsSeriesDataMap - A map containing series data for data points. * @returns An array of DatapointsWithValues. */ getDatapointsWithValues(datapoints: KPIDetails[], datapointsSeriesDataMap: DatapointsSeriesDataMap): DatapointWithValues[]; /** * Creates the column headers for the devices in the data points table. * * @param datapointsWithValues - An array of data points. * @returns An array of column headers for the devices. */ getColumnHeaders(datapointsWithValues: KPIDetails[]): TableColumnHeader[]; mapDatapointsWithValuesToList(datapointsWithValues: DatapointWithValues[]): DatapointTableItem[]; /** * Finds the overall minimum and maximum values from an array of objects containing 'min' and 'max' properties. * * If the array contains only one object, that object's 'min' and 'max' values will be returned. * * @param valuesArray - An array with objects, where each contains 'min' and 'max' properties. * @returns An object with the smallest 'min' and largest 'max' values found in the array. * * @example * const values = [ * { min: 1, max: 10 } * ]; * * const result = findMinMaxValues(values); * // result is { min: 1, max: 10 } */ findMinMaxValues(valuesArray: MinMaxValues[]): Value | null; /** * Groups a list of data points by date and device, based on given references. * * @param dataList - The list of data points to be grouped. * @param references - The column headers that serve as references for grouping. * @returns An array of grouped data points, where each group corresponds to a unique date and device. */ groupByDateAndDevice(dataList: DatapointTableItem[], references: TableColumnHeader[]): GroupedDatapointTableItem[]; /** * Generates and populates a map with data points. * * This function processes the provided data points and organizes them into a map structure * where each key is a unique combination of date and device identifiers, and the value is an * array of data points (or null values) associated with that key. This structured data is then * used in the data point table to render the data appropriately. * * @param dataList - The list of data point table items to be processed. * @param columnsHeadersReferences - The list of column headers used to determine the order and structure of the map values. * @returns A map where the key is a datapoint identifier containing the date and device name, and the value is an array of data point table items or null. */ generateDataPointMap(dataList: DatapointTableItem[], columnsHeadersReferences: TableColumnHeader[]): DataPointsTableMap; /** * Merges the data points from the given map into an array of grouped data point table items. * * @param map - The map containing the data points to be merged. * @returns An array of grouped data point table items. */ mergeDatapoints(map: DataPointsTableMap): GroupedDatapointTableItem[]; sortDataByDateDescending(data: GroupedDatapointTableItem[]): GroupedDatapointTableItem[]; /** * Prepares the updated time range based on the selected interval. * * In case of a 'custom' interval or no quantity, the original date range is returned. * * @param interval - The selected interval type. * @returns An object containing the `dateFrom` and `dateTo` in ISO string format. */ prepareTimeRange(interval: Interval['id'], dateFromInput: string, dateToInput: string): { dateFrom: string; dateTo: string; }; /** * Subtracts an amount of time from a given date. * * @param date - The original date. * @param amount - The amount of time units to subtract. * @param unit - The unit of time to subtract (e.g., minutes, hours, days, weeks, months). * @returns A new date with the specified time subtracted. */ subtractTime(date: Date, amount: number, unit: string): Date; getSeriesWithoutPermissionToRead(activeDatapointsSeriesData: Map<string | number, ISeries> | undefined, activeDatapointsIdsWithSeries: DatapointsValuesDataMap): { key: SourceId; value: string[]; }[]; hasSecondsAndMillisecondsEqualZero(timeString: string): boolean; /** * Converts a date string to ISO format. * * @param dateStr - The date string to convert. * @returns The ISO format of the given date string. */ private toISOFormat; private filterOutElementsWithForbiddenResponses; private subtractMonthsAndAdjustDay; /** * Calculates the target month number (0-11) after subtracting months from the current month. * Handles negative month numbers by normalizing them to the valid 0-11 range. * * Examples: * - January(0) - 1 month = December(11) * - March(2) - 4 months = November(10) * - December(11) - 1 month = November(10) * * @param currentMonth - Current month (0-11, where 0 is January) * @param monthsToSubtract - Number of months to subtract * @returns Normalized month number in range 0-11 */ private calculateTargetMonth; /** * Sets the date to the last day of the previous month. * Using 0 as dateValue makes JavaScript automatically calculate * last day of previous month, per JavaScript Date API behavior. * @param date - Date to modify */ private setToLastDayOfPreviousMonth; static ɵfac: i0.ɵɵFactoryDeclaration<DatapointsTableViewService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<DatapointsTableViewService>; } //# sourceMappingURL=datapoints-table-view.service.d.ts.map