-
Notifications
You must be signed in to change notification settings - Fork 19
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 #887 from codaco/feature/better-external-data
Feature/better external data
- Loading branch information
Showing
14 changed files
with
577 additions
and
69 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Submodule ui
updated
from 67fb1e to c5f620
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,32 @@ | ||
import { omit } from 'lodash'; | ||
import { entityAttributesProperty } from '../ducks/modules/network'; | ||
|
||
/** | ||
* Converts a CSV file into a Network Canvas node list JSON | ||
* | ||
* @param {string} data - the contents of a CSV file | ||
* | ||
* See: https://github.com/Keyang/node-csvtojson We may want to introduce buffering | ||
* to this function to increase performance particularly on cordova. | ||
* | ||
*/ | ||
|
||
const csv = require('../../node_modules/csvtojson/browser/browser.js'); | ||
|
||
const CSVToJSONNetworkFormat = (data) => { | ||
const withTypeAndAttributes = node => ({ | ||
type: node.type, | ||
[entityAttributesProperty]: { | ||
...omit(node, 'type'), | ||
}, | ||
}); | ||
|
||
csv().fromString(data) | ||
.then((json) => { | ||
const nodeList = json.map(entry => withTypeAndAttributes(entry)); | ||
self.postMessage({ nodes: nodeList }); | ||
}); | ||
}; | ||
|
||
// Respond to message from parent thread | ||
self.addEventListener('message', event => CSVToJSONNetworkFormat(event.data)); |
Oops, something went wrong.