-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1154 from akvo/feature/1153-download-the-JSON-fil…
…e-with-queue [#1153] Add sync button to manage form
- Loading branch information
Showing
18 changed files
with
275 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { crudMonitoring } from '../database/crud'; | ||
import { DatapointSyncState } from '../store'; | ||
import api from './api'; | ||
|
||
export const fetchDatapoints = async (pageNumber = 1) => { | ||
try { | ||
const { data: apiData } = await api.get(`/datapoint-list?page=${pageNumber}`); | ||
const { data, total_page: totalPage, current: page } = apiData; | ||
DatapointSyncState.update((s) => { | ||
s.progress = (page / totalPage) * 100; | ||
}); | ||
if (page < totalPage) { | ||
return data.concat(await fetchDatapoints(page + 1)); | ||
} else { | ||
return data; | ||
} | ||
} catch (error) { | ||
return Promise.reject(error); | ||
} | ||
}; | ||
|
||
export const downloadDatapointsJson = async (formId, url) => { | ||
try { | ||
const response = await api.get(url); | ||
if (response.status === 200) { | ||
const jsonData = response.data; | ||
const res = await crudMonitoring.syncForm({ | ||
formId, | ||
formJSON: jsonData, | ||
}); | ||
console.info('[SYNCED MONITORING]', res); | ||
} | ||
} catch (error) { | ||
return Promise.reject(error); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.