Wiki.js

exportResultsFiltered

Exports all previously saved filtered result objects as a CSV file.

AI Generated

exportResultsFiltered()

Purpose

Exports all previously saved filtered result objects as a CSV file.

Depending on the current environment, the function gathers stored result data from IndexedDB, localStorage, or CSV-based storage. The collected results are then converted into CSV format and either downloaded directly or shared via the Cordova social sharing plugin.


Location

src/app/services/fileManager/file-manager.service.ts

Signature

exportResultsFiltered(
  pipelineConfig: PipelineStageConfig
): OperatorFunction<StatusObject, Observable<any>>

Parameters

Parameter Type Description
pipelineConfig PipelineStageConfig Current pipeline stage configuration containing event targets and stage context.

Returns

OperatorFunction<StatusObject, Observable<any>>

RxJS operator which collects saved result data, converts it to CSV, and exports it.


Workflow

Check environment capabilities
        ↓
Load stored results
        ↓
Are results available?
        ↓
Convert results to CSV
        ↓
Download or share CSV file
        ↓
Execute onSuccess

Export Sources

Web / IndexedDB Environment

Used when:

this.environmentCapabilities.hasIndexedDB()
&& !this.environmentCapabilities.canUseCordova()

Data is loaded from:

this.indexedMeasurementDB.getAll()

Each stored entry is mapped to:

item.data

The resulting CSV is downloaded as:

results.csv

Cordova / File-Based Environment

Used when IndexedDB export is not selected.

The function collects result data from:

localStorage

and from stored CSV entries:

this.listCSV()
this.getCSV(key)

The resulting CSV is written to:

results.csv

and shared using:

window.plugins.socialsharing.share(...)

CSV Conversion

All collected result objects are converted using:

const resultsCSV = this.resultsToCSV(results);

This converts the stored JSON result objects into a CSV-compatible export format.


Output File

results.csv

The file contains all collected filtered result objects.


Success Behaviour

On successful execution:

  1. Stored filtered results are loaded.
  2. Results are converted to CSV.
  3. The CSV file is downloaded or shared.
  4. The configured onSuccess event target is executed.
pipelineConfig.executeStage(
  pipelineConfig.stageConfig.eventTargets?.onSuccess,
  'onSuccess',
  pipelineConfig.stage
);

Error Behaviour

The configured onError event target is executed when:

pipelineConfig.executeStage(
  pipelineConfig.stageConfig.eventTargets?.onError,
  'onError',
  pipelineConfig.stage
);

Example Export Flow: Web

IndexedDB
   ↓
getAll()
   ↓
resultsToCSV()
   ↓
downloadCSVFromIndexedDB()
   ↓
results.csv

Example Export Flow: Cordova

localStorage / CSV files
   ↓
listCSV() / getCSV()
   ↓
resultsToCSV()
   ↓
writeCSV()
   ↓
socialsharing.share()

Typical Use Cases


Notes