Skip to content
This repository was archived by the owner on May 17, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ad775b6
refactor: Bundle createParser() into single export
imlucas Oct 28, 2019
dcde71f
disable terser on storybook and dev so it doesn't kill CPU for no reason
imlucas Oct 29, 2019
833c5a5
preview streams. broke need help
imlucas Oct 29, 2019
e3599d6
yay tests pass
imlucas Oct 29, 2019
e443559
load import preview docs after file detected
imlucas Oct 29, 2019
a0dc45c
rough wiring preview into <ImportModal />
imlucas Oct 29, 2019
9997f98
nit: remove console logs
imlucas Oct 31, 2019
dc85b1c
refactor: Break out `<SelectFieldType />`
imlucas Oct 31, 2019
5254469
getting wired. need more streams work for preview parsing
imlucas Oct 31, 2019
ae2eedf
fix: default csv delimiter is ,
imlucas Nov 1, 2019
ac41125
fix: preview fields not set because of typo
imlucas Nov 1, 2019
3832f4a
cleanup and warn on invariants
imlucas Nov 1, 2019
9644de1
fighting with PropTypes
imlucas Nov 1, 2019
4716e9d
styling and field checked toggle
imlucas Nov 14, 2019
3f0b3a0
type casting wiring
imlucas Nov 14, 2019
8686f28
type selection and strip unchecked fields
imlucas Nov 16, 2019
abc2b55
transformProjectedTypesStream
imlucas Nov 20, 2019
7615ce4
lots
imlucas Nov 21, 2019
4626bb8
fix: copy paste error was trying to set delimiter as a boolean
imlucas Nov 21, 2019
032b402
keep one pager w preview
imlucas Nov 21, 2019
31dd6b5
remove diagnostic logging that is real slow
imlucas Nov 21, 2019
b10af84
fixup connection debug on start
imlucas Nov 21, 2019
af49ed2
turn off strict csv for now bc of finding right shape for options case
imlucas Nov 21, 2019
3926478
Add JS type lookup for bson csv deserializer
imlucas Nov 21, 2019
2f1f548
Type detection and pass down all options to parser for preview
imlucas Nov 21, 2019
a2dd7d4
fix: forgot somer renames
imlucas Nov 21, 2019
6c0eb20
tests to come back to
imlucas Nov 25, 2019
99b05ac
renaming things, consolidating all the todos from jira's/slacks/postits
imlucas Dec 4, 2019
784e575
fix tests
imlucas Dec 4, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,25 @@ See files in the `./test` directory.

## TODO/Ideas

- [ ] Import: Preview Table: Use highlight.js, mongodb-ace-mode, or something so the text style of the value within a cell matches its destination type
- [ ] Export: Use electron add to destination file to [recent documents](https://electronjs.org/docs/tutorial/recent-documents)
- [ ] Import and Export: Show system notification when operation completes. like dropbox screenshot message. toast "XX/XX documents successfully"
- [ ] Import and Export: New Option: If you need to [specify extended-json legacy spec](https://github.com/mongodb/js-bson/pull/339)
- [ ] Refactor src/modules/ so import and export reuse a common base
- [ ] Import and Export: Show system notification when operation completes. like dropbox screenshot message.
- [ ] Import csv: dynamicTyping of values like papaparse
- [ ] Import csv: mapHeaders option to support existing .<bson_type>() caster like [mongoimport does today][mongoimport]
- [ ] Import: bson-csv: support existing .<bson_type>() caster like [mongoimport does today][mongoimport]
- [ ] Import: expose finer-grained bulk op results in progress
- [ ] Import: define import mode: insert, upsert, merge
- [ ] Import: option to specify a different path for `_id` such as `business_id` in the yelp dataset
- [ ] Import: Paste URL to fetch from
- [ ] Import: multi file import via archive (supports gzip/zip/bzip2/etc.)
- [ ] Import: option for path to pass to JSONStream for nested docs (e.g. `results` array when fetching JSON from a rest api)
- [ ] Import: Option to drop target collection before import
- [ ] Import: Drop file target in modal
- [ ] Export: use electron add to destination file to [recent documents](https://electronjs.org/docs/tutorial/recent-documents)
- [ ] Import: New Option: drop target collection before import
- [ ] Import: New Option: define import mode: insert, upsert, merge
- [ ] Import: New Option: specify a different path for `_id` such as `business_id` in the yelp dataset
- [ ] Import: Option for path to pass to JSONStream for nested docs (e.g. `results` array when fetching JSON from a rest api)
- [ ] Import: New Option: Paste URL to fetch from
- [ ] Import: Preview Table: use `react-table` and [`react-window`](https://www.npmjs.com/package/react-window-infinite-loader) for fixed headers and more # of documents to preview
- [ ] Import: Preview Table: Allow transpose on fields/values so all type selection and projection is in a single left aligned list
- [ ] Import: Multi file import via archive (supports gzip/zip/bzip2/etc.)
- [ ] Import: Use schema parser or something later to handle complete tabular renderings of sparse/polymorphic
- [ ] Import: Improve import-size-guesstimator
- [ ] Import: guess delimiter in `src/utils/detect-import-file.js`
- [ ] Import and Export: Extract anything from `./src/utils` that could live as standalone modules so other things like say a cli or a different platform could reuse compass' import/export business logic and perf.

## License

Expand Down
3 changes: 3 additions & 0 deletions config/webpack.dev.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const config = {
mode: 'development',
target: 'electron-renderer',
devtool: 'eval-source-map',
optimization: {
minimize: false
},
entry: {
index: [
// activate HMR for React
Expand Down
3 changes: 3 additions & 0 deletions config/webpack.storybook.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ const config = {
process: false,
Buffer: false
},
optimization: {
minimize: false
},
devtool: 'eval-source-map',
entry: {
index: path.resolve(project.path.src, 'index.js')
Expand Down
13 changes: 8 additions & 5 deletions electron/renderer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ import 'less/global.less';
/**
* Customize data service for your sandbox.
*/
const NS = 'test.people_imported';
const NS = 'lucas_apple_health_data.sleep';

import Connection from 'mongodb-connection-model';
const connection = new Connection({
hostname: '127.0.0.1',
port: 27017
port: 27017,
options: {
explicitlyIgnoreSession: true
}
});

/**
Expand All @@ -51,8 +54,8 @@ var QUERY_BAR = {

console.group('Compass Plugin Sandbox');
console.log('db.collection', NS);
console.log('connect', connection.driver_url, {
options: connection.driver_options
console.log('connect', connection.driverUrl, {
options: connection.driverOptions
});
console.groupEnd();

Expand Down Expand Up @@ -82,7 +85,7 @@ const store = configureStore({
});

// Create a HMR enabled render function
const render = Component => {
const render = (Component) => {
ReactDOM.render(
<AppContainer>
<Component store={store} appRegistry={localAppRegistry} />
Expand Down
49 changes: 49 additions & 0 deletions examples/import-options.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const DEFAULT_PROPS = {
delimiter: ',',
setDelimiter: () => console.log('setDelimiter:'),
fileType: '',
selectImportFileType: () => console.log('selectImportFileType:'),
fileName: '',
selectImportFileName: () => console.log('selectImportFileName:'),
stopOnErrors: false,
setStopOnErrors: () => console.log('setStopOnErrors:'),
ignoreBlanks: true,
setIgnoreBlanks: () => console.log('setIgnoreBlanks:'),
fileOpenDialog: () => console.log('fileOpenDialog:')
};

/* eslint-disable no-alert */
import React from 'react';
import { storiesOf } from '@storybook/react';
import ImportOptions from 'components/import-options';

storiesOf('Examples/ImportOptions', module)
.add('csv', () => {
const props = {
...DEFAULT_PROPS,
fileType: 'csv',
fileName: '~/my-csv-data.csv'
};
return <ImportOptions {...props} />;
})
.add('tsv', () => {
const props = {
...DEFAULT_PROPS,
fileType: 'csv',
fileName: '~/my-tsv-data.tsv',
delimiter: '\\t'
};
return <ImportOptions {...props} />;
})
.add('json', () => {
const props = {
...DEFAULT_PROPS,
fileType: 'json',
fileName: '~/compass-github-api-releases.json'
};

return <ImportOptions {...props} />;
})
.add('default', () => {
return <ImportOptions {...DEFAULT_PROPS} />;
});
71 changes: 71 additions & 0 deletions examples/import-preview.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/* eslint-disable no-alert */
import React from 'react';
import { storiesOf } from '@storybook/react';
import ImportPreview from 'components/import-preview';

// const docs = [
// {
// _id: 'arlo',
// name: 'Arlo',
// stats: {
// age: 5,
// fluffiness: ''
// }
// },
// {
// _id: 'basilbazel',
// name: 'Basil',
// stats: {
// age: 8,
// fluffiness: '100'
// }
// },
// {
// _id: 'hellbeast',
// name: 'Kochka',
// stats: {
// age: '14',
// fluffiness: 50
// }
// }
// ];

storiesOf('Examples/ImportPreview', module).add('simple', () => {
return (
<ImportPreview
onFieldCheckedChanged={(path, checked) => {
console.log('onFieldCheckedChanged: %s is now', path, checked);
}}
setFieldType={(path, bsonType) => {
console.log('setFieldType: %s to %s', path, bsonType);
}}
fields={[
{
path: '_id',
type: 'string',
checked: true
},
{
path: 'name',
type: 'string',
checked: true
},
{
path: 'stats.age',
type: 'string',
checked: true
},
{
path: 'stats.fluffiness',
type: 'string',
checked: false
}
]}
values={[
['arlo', 'Arlo', '5', ''],
['basilbazel', 'Basil', '8', '100'],
['hellbeast', 'Kochka', '14', '50']
]}
/>
);
});
21 changes: 21 additions & 0 deletions examples/select-field-type.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* eslint-disable no-alert */
import React from 'react';
import { storiesOf } from '@storybook/react';
import SelectFieldType from 'components/select-field-type';

storiesOf('Examples/SelectFieldType', module)
.add('default', () => {
return (
<SelectFieldType
onChange={t => window.alert(`Selected type changed ${t}`)}
/>
);
})
.add('number selected', () => {
return (
<SelectFieldType
selectedType="number"
onChange={t => window.alert(`Selected type changed ${t}`)}
/>
);
});
8 changes: 6 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@
"fast-csv": "^3.4.0",
"flat": "^4.1.0",
"javascript-stringify": "^1.6.0",
"lodash.isobjectlike": "^4.0.0",
"lodash.isplainobject": "^4.0.6",
"lodash.throttle": "^4.1.1",
"marky": "^1.2.1",
"mime-types": "^2.1.24",
Expand Down
5 changes: 4 additions & 1 deletion src/components/error-box/error-box.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import styles from './error-box.less';
import createStyler from 'utils/styler.js';
const style = createStyler(styles, 'error-box');

// TODO: lucas: Sync hex values against .less
/**
* TODO: lucas: Sync hex values against palatte
* once we start actually produce ansi.
*/
const ANSI_TO_HTML_OPTIONS = {
fg: '#FFF',
bg: '#000',
Expand Down
Loading