Skip to content

Commit

Permalink
feat: migrate TEI and Event export to new tracker API
Browse files Browse the repository at this point in the history
  • Loading branch information
kabaros committed Feb 23, 2024
1 parent 021c83d commit 90a4073
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/pages/EventExport/EventExport.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
OrgUnitTree,
ProgramPicker,
Format,
formatOptions,
defaultFormatOption,
Compression,
defaultCompressionOption,
Expand All @@ -32,6 +31,7 @@ import {
defaultOrgUnitIdSchemeOption,
IdScheme,
defaultIdSchemeOption,
formatNoXmlOptions,
} from '../../components/Inputs/index.js'
import { jsDateToISO8601 } from '../../utils/helper.js'
import { onExport, validate } from './form-helper.js'
Expand Down Expand Up @@ -103,7 +103,7 @@ const EventExport = () => {
<StartDate />
<EndDate />
</Dates>
<Format availableFormats={formatOptions} />
<Format availableFormats={formatNoXmlOptions} />
<Compression />
</BasicOptions>
<MoreOptions>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/EventExport/form-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const onExport = (baseUrl, setExportEnabled) => (values) => {
} = values

// generate URL and redirect
const apiBaseUrl = `${baseUrl}/api/`
const apiBaseUrl = `${baseUrl}/api/tracker/`
const endpoint = `events`
const endpointExtension = compression ? `${format}.${compression}` : format
const filename = `${endpoint}.${endpointExtension}`
Expand Down
7 changes: 2 additions & 5 deletions src/pages/TEIExport/TEIExport.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
} from '../../components/index.js'
import {
Format,
formatOptions,
defaultFormatOption,
OrgUnitMode,
defaultOrgUnitSelectionModeOption,
Expand All @@ -36,7 +35,6 @@ import {
AssignedUserMode,
defaultAssignedUserModeOption,
IncludeDeleted,
IncludeAllAttributes,
DataElementIdScheme,
defaultDataElementIdSchemeOption,
EventIdScheme,
Expand All @@ -47,6 +45,7 @@ import {
defaultOrgUnitIdSchemeOption,
ExportButton,
FormAlerts,
formatNoXmlOptions,
} from '../../components/Inputs/index.js'
import { onExport, validate } from './form-helper.js'

Expand Down Expand Up @@ -80,7 +79,6 @@ const initialValues = {
assignedUserModeFilter: false,
assignedUserMode: defaultAssignedUserModeOption,
includeDeleted: false,
includeAllAttributes: false,
dataElementIdScheme: defaultDataElementIdSchemeOption,
eventIdScheme: defaultEventIdSchemeOption,
orgUnitIdScheme: defaultOrgUnitIdSchemeOption,
Expand Down Expand Up @@ -136,7 +134,7 @@ const TEIExport = () => {
<ProgramEndDate show={showProgramFilters} />
</Dates>
<TETypePicker show={showTEFilters} />
<Format availableFormats={formatOptions} />
<Format availableFormats={formatNoXmlOptions} />
</BasicOptions>
<MoreOptions>
<LastUpdatedFilter />
Expand All @@ -147,7 +145,6 @@ const TEIExport = () => {
<LastUpdatedDuration show={showLUDuration} />
<AssignedUserMode />
<IncludeDeleted />
<IncludeAllAttributes />
<SchemeContainer>
<DataElementIdScheme />
<EventIdScheme />
Expand Down
8 changes: 3 additions & 5 deletions src/pages/TEIExport/form-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const valuesToParams = (
inclusion,
format,
includeDeleted,
includeAllAttributes,
dataElementIdScheme,
eventIdScheme,
orgUnitIdScheme,
Expand All @@ -40,7 +39,6 @@ const valuesToParams = (
ouMode: ouMode,
format: format,
includeDeleted: includeDeleted.toString(),
includeAllAttributes: includeAllAttributes.toString(),
dataElementIdScheme: dataElementIdScheme,
eventIdScheme: eventIdScheme,
orgUnitIdScheme: orgUnitIdScheme,
Expand All @@ -51,7 +49,7 @@ const valuesToParams = (
// include selected org.units only when manual selection is selected
// ouMode is then stored in the `inclusion` field
if (ouMode === OU_MODE_MANUAL_VALUE) {
minParams.ou = selectedOrgUnits.map((o) => pathToId(o)).join(';')
minParams.orgUnit = selectedOrgUnits.map((o) => pathToId(o)).join(';')
minParams.ouMode = inclusion
}

Expand Down Expand Up @@ -111,8 +109,8 @@ const onExport = (baseUrl, setExportEnabled) => async (values) => {
const { format } = values

// generate URL and redirect
const apiBaseUrl = `${baseUrl}/api/`
const endpoint = `trackedEntityInstances`
const apiBaseUrl = `${baseUrl}/api/tracker/`
const endpoint = `trackedEntities`
const filename = `${endpoint}.${format}`
const downloadUrlParams = valuesToParams(values, filename)
const url = `${apiBaseUrl}${endpoint}.${format}?${downloadUrlParams}`
Expand Down

0 comments on commit 90a4073

Please sign in to comment.