File

datapoints-export-selector/datapoints-export-selector-modal/datapoints-export-selector-file-exporter/datapoints-export-selector-file-exporter.component.ts

Implements

OnInit OnDestroy

Metadata

Index

Properties
Methods
Inputs
Outputs

Constructor

constructor(datapointsExportModalService: DataProcessingService, datapointsExportSelectorService: DataFetchingService, datapointsExportSelectorFileExporterService: DatapointsExportSelectorFileExporterService, formBuilder: FormBuilder, generators: FileGenerator[], gainsightService: GainsightService)
Parameters :
Name Type Optional
datapointsExportModalService DataProcessingService No
datapointsExportSelectorService DataFetchingService No
datapointsExportSelectorFileExporterService DatapointsExportSelectorFileExporterService No
formBuilder FormBuilder No
generators FileGenerator[] No
gainsightService GainsightService No

Inputs

exportConfig
Type : ExportConfig

Outputs

onDownloadButtonStateChange
Type : EventEmitter<boolean>

Methods

Async downloadFile
downloadFile(blob: Blob | null, fileType: string, measurementsZipFileName: string)
Parameters :
Name Type Optional
blob Blob | null No
fileType string No
measurementsZipFileName string No
Returns : Promise<void>
excludeDatapointsThatExceedsApiLimit
excludeDatapointsThatExceedsApiLimit(exportConfig: ExportConfig)
Parameters :
Name Type Optional
exportConfig ExportConfig No
Returns : ExportConfig
Async exportAndDownload
exportAndDownload()
Returns : Promise<void>
Async exportFile
exportFile(fileType: string)
Parameters :
Name Type Optional
fileType string No
Returns : Promise<Blob | null>
Async exportMeasurementFile
exportMeasurementFile(fileType: string)

Exports a measurement file of the specified type.

Measurements API does provide a way to fetch a preprocessed CSV/Excel file.

At this point a backed file needs to be fetched. Measurement data used for a preview contains just 5 first records and it's not fetched with CSV/Excel headers.

Parameters :
Name Type Optional Description
fileType string No
  • The type of file to export.
Returns : Promise | null

A Promise that resolves to a Blob representing the exported file or null when no data to export or it's sent via email.

Async exportSeriesFile
exportSeriesFile(fileType: string)

Exports the series data to a file of the specified type.

Series API does not provide a way to fetch a preprocessed CSV/Excel file.

Series data used for exporting a file is already fetched for a preview and can be reused for exporting.

Parameters :
Name Type Optional Description
fileType string No
  • The type of file to export (e.g., CSV, Excel).
Returns : Promise<Blob>

A Promise that resolves to a Blob representing the exported file.

getOnlySelectedFileExports
getOnlySelectedFileExports(fileExports: FileExportConfig[])
Parameters :
Name Type Optional
fileExports FileExportConfig[] No
Returns : FileExportConfig[]
ngOnDestroy
ngOnDestroy()
Returns : void
Async ngOnInit
ngOnInit()
Returns : Promise<void>
Async onAggregationChange
onAggregationChange(aggregation: AggregationOption)
Parameters :
Name Type Optional
aggregation AggregationOption No
Returns : Promise<void>
onDateFromChange
onDateFromChange(updatedDate: string)
Parameters :
Name Type Optional
updatedDate string No
Returns : void
onDateToChange
onDateToChange(updatedDate: string)
Parameters :
Name Type Optional
updatedDate string No
Returns : void
Async onExportTypeChange
onExportTypeChange(exportType: string)
Parameters :
Name Type Optional
exportType string No
Returns : Promise<void>
setFilesType
setFilesType(generators: FileGenerator[])
Parameters :
Name Type Optional
generators FileGenerator[] No
Returns : void
Async updateDateAndFetchData
updateDateAndFetchData(dateType: "dateFrom" | "dateTo", updatedDate: string)
Parameters :
Name Type Optional
dateType "dateFrom" | "dateTo" No
updatedDate string No
Returns : Promise<void>

Properties

datapointsExceedingBrowserDownloadLimit
Type : DatapointsExceedingLimit[]
Default value : []

Contains all datapoints that number of records exceeds a threshold, where data for these datapoints will be processed by the backend. Applies only to measurement API which can return processed CSV, Excel or XML data.

disabledAggregationOptions
Type : AggregationOptionStatus
Default value : {}

Represents aggregation selector options that are disabled. This state is determined based on the current date range.

dynamicFilesTypeMetadata
Type : literal type
Default value : {}
formGroup
Type : ReturnType<>
hasFetchedDataAnyValuesToExport
Default value : false

Indicates whether any of DataToExport objects timeValueMap property is not undefined (series data) or dataPointToExport is not undefined at all (measurement data).

hasNoExportableData
Type : boolean

Indicates if there is no exportable data because the date range of all selected datapoints exceeds 1,000,000 records.

hasPermissionToReadAnyMeasurements
Default value : false
isFullTypeOfExport
Default value : false

Indicates whether the full or compact type of export is selected. Full type of export is based on measurement API data. Compact type of export is based on series API data.

isPreviewLoading
Default value : true
limitExceededMessage
Type : string
previewTableData
Type : ExportData[]
<div class="p-b-16">
  <ng-container *ngIf="hasPermissionToReadAnyMeasurements; else hasNoRoleToReadAnyMeasurements">
    <div class="p-16 text-center separator-bottom sticky-top bg-component">
      <p class="text-medium text-16">
        {{ 'Configure export' | translate }}
      </p>
    </div>
    <div
      class="p-t-24 p-r-16 p-l-16 gap-8 p-b-16 flex-wrap"
      [ngClass]="{ 'separator-bottom': isFullTypeOfExport }"
    >
      <div class="row">
        <div class="col-md-4">
          <c8y-datapoints-export-selector-time-range
            *ngIf="this.hasPermissionToReadAnyMeasurements"
            [formGroup]="formGroup"
            (onDateFromChange)="onDateFromChange($event)"
            (onDateToChange)="onDateToChange($event)"
          ></c8y-datapoints-export-selector-time-range>
        </div>
        <div class="col-md-4">
          <c8y-datapoints-export-selector-data-scope
            *ngIf="this.hasPermissionToReadAnyMeasurements"
            [disabledAggregationOptions]="disabledAggregationOptions"
            [formGroup]="formGroup"
            (onAggregationChange)="onAggregationChange($event)"
            (onExportTypeChange)="onExportTypeChange($event)"
          ></c8y-datapoints-export-selector-data-scope>
        </div>
        <div class="col-md-4">
          <c8y-datapoints-export-selector-file-types
            *ngIf="this.hasPermissionToReadAnyMeasurements"
            [dynamicFilesTypeMetadata]="dynamicFilesTypeMetadata"
            [formGroup]="formGroup"
          ></c8y-datapoints-export-selector-file-types>
        </div>
      </div>
    </div>
    <ng-container
      *ngIf="!isFullTypeOfExport && !hasFetchedDataAnyValuesToExport && !isPreviewLoading"
    >
      <div class="p-t-24 p-r-16 p-l-16 p-b-16 separator-bottom d-flex">
        <div
          class="alert alert-warning center-block"
          role="alert"
          data-cy="file-exporter--no-data-available"
          translate
        >
          No data available.
        </div>
      </div>
    </ng-container>
    <ng-container *ngIf="datapointsExceedingBrowserDownloadLimit.length > 0">
      <div class="p-t-24 p-r-16 p-l-16 p-b-16 separator-bottom d-flex">
        <div
          [class]="
            hasNoExportableData
              ? 'alert alert-warning center-block'
              : 'alert alert-info center-block'
          "
          role="alert"
          [innerHTML]="limitExceededMessage"
        ></div>
      </div>
    </ng-container>
    <ng-container *ngIf="isFullTypeOfExport">
      <c8y-datapoints-export-selector-preview
        *ngIf="this.hasPermissionToReadAnyMeasurements"
        [hasFetchedDataAnyValuesToExport]="hasFetchedDataAnyValuesToExport"
        [isPreviewLoading]="isPreviewLoading"
        [previewTableData]="previewTableData"
      ></c8y-datapoints-export-selector-preview>
    </ng-container>
  </ng-container>
  <ng-template #hasNoRoleToReadAnyMeasurements>
    <div class="p-t-24 p-r-16 p-l-16 p-b-16 d-flex">
      <div
        class="alert alert-info center-block"
        role="alert"
        translate
      >
        <p>To export data, you must meet at least one of these criteria:</p>
        <ul>
          <li>
            Have
            <b>READ permission for "Measurements" permission type</b>
            (either as a global role or for the specific source)
          </li>
          <li>
            Be the
            <b>owner of the source</b>
            you want to export data from
          </li>
        </ul>
        <p>Don't meet these requirements? Contact your system administrator for assistance.</p>
      </div>
    </div>
  </ng-template>
</div>

results matching ""

    No results matching ""