Skip to content

Commit

Permalink
CADENZA-33493 [Embedding FA] Export Table and Indicator as JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian.nistor committed Oct 4, 2023
1 parent 9917231 commit d740b99
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ That's why the events use the `editGeometry` prefix.
<small>API: [CadenzaClient#fetchData](./classes/CadenzaClient.html#fetchData)</small>
Fetch data from a workbook view in CSV format.
Fetch data from a workbook view in CSV or JSON format.
```javascript
const response = await cadenzaClient.fetchData('{embeddingTargetId}', 'text/csv');
Expand All @@ -215,7 +215,7 @@ const text = await response.text();
<small>API: [CadenzaClient#downloadData](./classes/CadenzaClient.html#downloadData)</small>
Download data from a workbook view in Excel, CSV or PDF format. This triggers the browser's download dialog.
Download data from a workbook view in Excel, CSV, JSON or PDF format. This triggers the browser's download dialog.
```javascript
const button = document.createElement('button');
Expand Down
30 changes: 29 additions & 1 deletion sandbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@
locationFinder
});
},
fetchData ({ embeddingTargetId, mediaType }) {
cadenzaClient.fetchData(embeddingTargetId, mediaType)
.then(response => response.text())
.then(text => alert(text))
.catch(exception => alert(exception));
},
downloadData ({ embeddingTargetId, mediaType, fileName }) {
cadenzaClient.downloadData(embeddingTargetId, mediaType, {
fileName
Expand Down Expand Up @@ -147,6 +153,7 @@
<option value="createGeometry">Create Geometry</option>
<option value="editGeometry">Edit Geometry</option>
<option value="downloadData">Download data</option>
<option value="fetchData">Fetch data</option>
</select>
</div>

Expand Down Expand Up @@ -291,13 +298,34 @@
</div>
<div>
<label for="mediaType">Media type *</label>
<input name="mediaType" id="mediaType" value="text/csv" required>
<select name="mediaType" id="mediaType" required>
<option>text/csv</option>
<option>application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</option>
<option>application/json</option>
<option>application/pdf</option>
</select>
</div>
<div>
<label for="fileName">Filename</label>
<input name="fileName" id="fileName">
</div>
</template>

<template data-action="fetchData">
<div>
<label for="embeddingTargetId">Embedding target ID *</label>
<input name="embeddingTargetId" id="embeddingTargetId" required>
</div>
<div>
<label for="mediaType">Media type *</label>
<select name="mediaType" id="mediaType" required>
<option>text/csv</option>
<option>application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</option>
<option>application/json</option>
<option>application/pdf</option>
</select>
</div>
</template>

</body>
</html>
3 changes: 3 additions & 0 deletions src/cadenza.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ export class CadenzaClient {
assertSupportedMediaType(mediaType, [
MediaType.CSV,
MediaType.EXCEL,
MediaType.JSON,
MediaType.PDF,
]);
const params = createParams({ mediaType });
Expand Down Expand Up @@ -501,6 +502,7 @@ export class CadenzaClient {
assertSupportedMediaType(mediaType, [
MediaType.CSV,
MediaType.EXCEL,
MediaType.JSON,
MediaType.PDF,
]);
const params = createParams({ fileName, mediaType });
Expand Down Expand Up @@ -655,6 +657,7 @@ function validGeometryType(value) {
const MediaType = /** @type {Record<string, MediaType>} */ {
CSV: 'text/csv',
EXCEL: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
JSON: 'application/json',
PDF: 'application/pdf',
};

Expand Down

0 comments on commit d740b99

Please sign in to comment.