UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

129 lines 7.96 kB
import { IFetchResponse, IMeasurement, IMeasurementFilter, IResult, ISeries, ISeriesFilter, MeasurementService } from '@c8y/client'; import { AlertService } from '@c8y/ngx-components'; import { TranslateService } from '@ngx-translate/core'; import { DatapointDetails, DatapointsExceedingLimit, DatapointsValuesDataMap, DataToExport, DataToExportWithBackendCreatedFile, ExportConfig, MeasurementFileConfig } from '../../datapoints-export-selector.model'; import { SourceItem, UtilsService } from './utils.service'; import * as i0 from "@angular/core"; export declare class DataFetchingService { private alertService; private measurementService; private translateService; private utilsService; constructor(alertService: AlertService, measurementService: MeasurementService, translateService: TranslateService, utilsService: UtilsService); /** * Checks if any of measurements requests may exceeded the limit, * after which the export data is processed by the backend and the generated CSV/Excel file is sent by email. * * The threshold is set to 50_000 records in application's core properties (export.data.synchronous.limit). * * @param exportConfig - The export configuration. * @returns A promise that returns an array of objects representing datapoints files that will be sent by email. */ getDatapointsExceedingLimit(exportConfig: ExportConfig): Promise<DatapointsExceedingLimit[]>; /** * Retrieves the message to be displayed when the limit of datapoints is exceeded during file export. * * @param hasNoExportableData - Indicates if there is no exportable data because the date range of all selected datapoints exceeds 1,000,000 records. * @param emailDeliverableCount - The number of datapoint exports that exceed the limit, will be proceeded by the backend and sent by email. * @param browserDownloadableCount - The number of datapoint exports that can be downloaded directly. * @param skippedDatapointCount - The number of datapoint exports skipped due to exceeding the measurements API limit of 1,000,000 records. * @param totalDatapointsSelectedForExportCount - Total number of datapoint selected for exports. * @returns The message that can be injected. */ getLimitExceededMessage(hasNoExportableData: boolean, emailDeliverableCount?: number, browserDownloadableCount?: number, nonRetrievableCount?: number, totalDatapointsSelectedForExportCount?: number): string; /** * Trims the given HTML message by removing list items that correspond to zero counts. * * @param message - The HTML string containing the message with list items. * @param counts - An array of number values corresponding to each list item. * @param countToTrim - A count that will be trimmed with corresponding list item. * @returns A trimmed HTML string with list items removed where the corresponding count is zero. * * Example: * ```typescript * const message = '<ul><li>Item 1</li><li>Item 2</li><li>Item 3</li></ul>'; * const counts = [1, 0, 2]; * const trimmedMessage = this.removeZeroCountListItems(message, counts); * // Result: '<ul><li>Item 1</li><li>Item 3</li></ul>' * ``` */ removeZeroCountListItems(message: string, counts: number[], countToTrim?: number): string; /** * Displays an information alert about sending data via email. * * Only measurements API can send files via email. * * @param fileType - The type of file to be sent. * @param datapointsExceedingLimit - The array of datapoints exceeding the limit. */ showSendViaEmailInfoAlert(fileType: string, datapointsExceedingLimit: DatapointsExceedingLimit[]): void; fetchMeasurementDataFilesAndPairWithSourceDetails(acceptFileType: string, exportConfig: ExportConfig): Promise<DataToExportWithBackendCreatedFile[]>; fetchAndProcessMeasurementFile(details: DatapointDetails, measurementFileConfig: MeasurementFileConfig, roundSeconds?: boolean): Promise<DataToExportWithBackendCreatedFile | undefined>; mergeMeasurementsWithItsSourceDetails(details: DatapointDetails, measurementFile: IFetchResponse): Promise<DataToExportWithBackendCreatedFile>; fetchAndPrepareDataToExport(exportConfig: ExportConfig, isMeasurement: boolean): Promise<DataToExport[]>; prepareMeasurementsFilter(details: DatapointDetails, exportConfig: ExportConfig, roundSeconds: boolean, pageSize?: number): IMeasurementFilter; processMeasurementDataForPreview(details: DatapointDetails, data: IMeasurement[]): DataToExport; /** * 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 datapointDetails - An array of data points details. * @returns A map where the key is the data point ID and the value is an array of data point series. */ groupSeriesByDeviceId(datapointDetails: DatapointDetails[]): DatapointsValuesDataMap; /** * Processes the fetched series data and prepares it for export. * * @param datapointDetails - An array of data point details. * @param fetchedDataMap - A map of fetched series data grouped by source. * @returns An array of DataToExport objects. */ processSeriesData(datapointDetails: DatapointDetails[], fetchedDataMap: SourceItem[]): DataToExport[]; getSourcesWithPermissionsToRead(datapointDetails: DatapointDetails[]): Promise<string[]>; /** * Adjusts the given date by adding the specified number of minutes and setting seconds to 0. * * @param date - The date to be adjusted in string format. * @param minutes - The number of minutes to add to the date. * @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 The adjusted date in ISO string format. */ adjustDate(date: string | Date, minutes: number, roundSeconds?: boolean): string; /** * Asynchronously loads series data based on the provided parameters. * * This method constructs a filter for retrieving series data within a specified date range, * from a specific source, and optionally applying an aggregation type. * * @param rawFilter - The parameters for loading series data, including date range, source, series names, and aggregation type. * @param roundSeconds - Indicates whether to round the seconds in the date range to the nearest whole number. * @returns A promise that resolves to series data wrapped in result object. */ fetchSeriesData(rawFilter: ISeriesFilter, roundSeconds?: boolean): Promise<IResult<ISeries>> | undefined; /** * Fetches and prepares measurement data for preview. * * Empty DataToExport object can be returned, because unlike series data, * measurement data is not further processed besides showing only in the preview. * CSV/Excel files are generated by the backend for measurements. * * @param exportConfig - The export configuration. * @param roundSeconds - Indicates whether to round the seconds in the date range to the nearest whole number. * @returns A promise that resolves to an array of DataToExport objects or null when no data is fetched. */ private fetchAndPrepareMeasurementDataToExportForPreview; private fetchMeasurementDataForPreview; private fetchAndPrepareSeriesDataToExport; private prepareSeriesFilter; static ɵfac: i0.ɵɵFactoryDeclaration<DataFetchingService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<DataFetchingService>; } //# sourceMappingURL=data-fetching.service.d.ts.map