File

datapoints-export-selector/datapoints-export-selector-modal/datapoints-export-selector-file-exporter/data-fetching.service.ts

Index

Methods

Constructor

constructor(alertService: AlertService, measurementService: MeasurementService, translateService: TranslateService, utilsService: UtilsService)
Parameters :
Name Type Optional
alertService AlertService No
measurementService MeasurementService No
translateService TranslateService No
utilsService UtilsService No

Methods

adjustDate
adjustDate(date: string | Date, minutes: number, roundSeconds)

Adjusts the given date by adding the specified number of minutes and setting seconds to 0.

Example :
                  If true, the seconds will be rounded to 0.
                  If false, the seconds will be displayed as they are.
Parameters :
Name Type Optional Default value Description
date string | Date No
  • The date to be adjusted in string format.
minutes number No
  • The number of minutes to add to the date.
roundSeconds No true
  • 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 : string

The adjusted date in ISO string format.

Async fetchAndPrepareDataToExport
fetchAndPrepareDataToExport(exportConfig: ExportConfig, isMeasurement: boolean)
Parameters :
Name Type Optional
exportConfig ExportConfig No
isMeasurement boolean No
Returns : Promise<DataToExport[]>
Async fetchAndProcessMeasurementFile
fetchAndProcessMeasurementFile(details: DatapointDetails, measurementFileConfig: MeasurementFileConfig, roundSeconds)
Parameters :
Name Type Optional Default value
details DatapointDetails No
measurementFileConfig MeasurementFileConfig No
roundSeconds No false
Returns : Promise<DataToExportWithBackendCreatedFile | undefined>
Async fetchMeasurementDataFilesAndPairWithSourceDetails
fetchMeasurementDataFilesAndPairWithSourceDetails(acceptFileType: string, exportConfig: ExportConfig)
Parameters :
Name Type Optional
acceptFileType string No
exportConfig ExportConfig No
Returns : Promise<DataToExportWithBackendCreatedFile[]>
Async fetchSeriesData
fetchSeriesData(rawFilter: ISeriesFilter, roundSeconds)

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.

Parameters :
Name Type Optional Default value Description
rawFilter ISeriesFilter No
  • The parameters for loading series data, including date range, source, series names, and aggregation type.
roundSeconds No false
  • Indicates whether to round the seconds in the date range to the nearest whole number.
Returns : Promise | undefined

A promise that resolves to series data wrapped in result object.

Async getDatapointsExceedingLimit
getDatapointsExceedingLimit(exportConfig: ExportConfig)

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).

Parameters :
Name Type Optional Description
exportConfig ExportConfig No
  • The export configuration.

A promise that returns an array of objects representing datapoints files that will be sent by email.

getLimitExceededMessage
getLimitExceededMessage(hasNoExportableData: boolean, emailDeliverableCount?: number, browserDownloadableCount?: number, nonRetrievableCount?: number, totalDatapointsSelectedForExportCount?: number)

Retrieves the message to be displayed when the limit of datapoints is exceeded during file export.

Parameters :
Name Type Optional Description
hasNoExportableData boolean No
  • Indicates if there is no exportable data because the date range of all selected datapoints exceeds 1,000,000 records.
emailDeliverableCount number Yes
  • The number of datapoint exports that exceed the limit, will be proceeded by the backend and sent by email.
browserDownloadableCount number Yes
  • The number of datapoint exports that can be downloaded directly.
nonRetrievableCount number Yes
totalDatapointsSelectedForExportCount number Yes
  • Total number of datapoint selected for exports.
Returns : string

The message that can be injected.

Async getSourcesWithPermissionsToRead
getSourcesWithPermissionsToRead(datapointDetails: DatapointDetails[])
Parameters :
Name Type Optional
datapointDetails DatapointDetails[] No
Returns : Promise<string[]>
groupSeriesByDeviceId
groupSeriesByDeviceId(datapointDetails: DatapointDetails[])

Returns a map of active data points device IDs with their corresponding series.

Example output:

Example :
new Map([
  ['844657202', ['c8y_Temperature.T']],
  ['32666427', ['c8y_Battery.Battery']]
]);
Parameters :
Name Type Optional Description
datapointDetails DatapointDetails[] No
  • An array of data points details.

A map where the key is the data point ID and the value is an array of data point series.

Async mergeMeasurementsWithItsSourceDetails
mergeMeasurementsWithItsSourceDetails(details: DatapointDetails, measurementFile: IFetchResponse)
Parameters :
Name Type Optional
details DatapointDetails No
measurementFile IFetchResponse No
Returns : Promise<DataToExportWithBackendCreatedFile>
prepareMeasurementsFilter
prepareMeasurementsFilter(details: DatapointDetails, exportConfig: ExportConfig, roundSeconds: boolean, pageSize?: number)
Parameters :
Name Type Optional
details DatapointDetails No
exportConfig ExportConfig No
roundSeconds boolean No
pageSize number Yes
Returns : IMeasurementFilter
processMeasurementDataForPreview
processMeasurementDataForPreview(details: DatapointDetails, data: IMeasurement[])
Parameters :
Name Type Optional
details DatapointDetails No
data IMeasurement[] No
Returns : DataToExport
processSeriesData
processSeriesData(datapointDetails: DatapointDetails[], fetchedDataMap: SourceItem[])

Processes the fetched series data and prepares it for export.

Parameters :
Name Type Optional Description
datapointDetails DatapointDetails[] No
  • An array of data point details.
fetchedDataMap SourceItem[] No
  • A map of fetched series data grouped by source.
Returns : DataToExport[]

An array of DataToExport objects.

removeZeroCountListItems
removeZeroCountListItems(message: string, counts: number[], countToTrim: number)

Trims the given HTML message by removing list items that correspond to zero counts.

Example:

Example :
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>'
Parameters :
Name Type Optional Default value Description
message string No
  • The HTML string containing the message with list items.
counts number[] No
  • An array of number values corresponding to each list item.
countToTrim number No 0
  • A count that will be trimmed with corresponding list item.
Returns : string

A trimmed HTML string with list items removed where the corresponding count is zero.

Example:

Example :
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>'
showSendViaEmailInfoAlert
showSendViaEmailInfoAlert(fileType: string, datapointsExceedingLimit: DatapointsExceedingLimit[])

Displays an information alert about sending data via email.

Only measurements API can send files via email.

Parameters :
Name Type Optional Description
fileType string No
  • The type of file to be sent.
datapointsExceedingLimit DatapointsExceedingLimit[] No
  • The array of datapoints exceeding the limit.
Returns : void

results matching ""

    No results matching ""