exportResultsFiltered
Exports all previously saved filtered result objects as a CSV file.
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:
- Stored filtered results are loaded.
- Results are converted to CSV.
- The CSV file is downloaded or shared.
- The configured
onSuccessevent target is executed.
pipelineConfig.executeStage(
pipelineConfig.stageConfig.eventTargets?.onSuccess,
'onSuccess',
pipelineConfig.stage
);
Error Behaviour
The configured onError event target is executed when:
- No stored results are found in IndexedDB.
- No stored results are found in localStorage or CSV storage.
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
- Exporting filtered measurement results
- Creating CSV result files
- Downloading result data in a web environment
- Sharing result exports from a mobile device
- Collecting all locally stored measurement exports into one file
Notes
- This function exports all currently stored filtered result objects.
- The export format is CSV.
- The output filename is currently fixed to
results.csv. - In web environments, the CSV file is downloaded directly.
- In Cordova environments, the CSV file is written and then shared via the social sharing plugin.
- If no results are available, the stage triggers
onError. - The actual data should previously have been saved using
saveResultsFilteredForExport().