Commit f3432726ef92306417c061c262b1a0c46f673ba0
1 parent
d0a93cc6d1
Exists in
master
added csv method
Showing
6 changed files
with
61 additions
and
45 deletions
Show diff stats
.meteor/packages
... | ... | @@ -6,19 +6,19 @@ |
6 | 6 | |
7 | 7 | meteor-base@1.0.4 # Packages every Meteor app needs to have |
8 | 8 | mobile-experience@1.0.4 # Packages for a great mobile UX |
9 | -mongo@1.1.15 # The database Meteor supports right now | |
9 | +mongo@1.1.16 # The database Meteor supports right now | |
10 | 10 | reactive-var@1.0.11 # Reactive variable for tracker |
11 | -session | |
11 | +session@1.1.7 | |
12 | 12 | tracker@1.1.2 # Meteor's client-side reactive programming library |
13 | 13 | |
14 | -standard-minifier-css@1.3.3 # CSS minifier run for production mode | |
15 | -standard-minifier-js@1.2.2 # JS minifier run for production mode | |
14 | +standard-minifier-css@1.3.4 # CSS minifier run for production mode | |
15 | +standard-minifier-js@1.2.3 # JS minifier run for production mode | |
16 | 16 | es5-shim@4.6.15 # ECMAScript 5 compatibility for older browsers. |
17 | 17 | ecmascript@0.6.3 # Enable ECMAScript2015+ syntax in app code |
18 | 18 | |
19 | -accounts-password | |
20 | -accounts-base@1.2.14 | |
21 | -check | |
19 | +accounts-password@1.3.4 | |
20 | +accounts-base@1.2.15 | |
21 | +check@1.2.5 | |
22 | 22 | audit-argument-checks@1.0.7 |
23 | 23 | browser-policy@1.1.0 |
24 | 24 | |
... | ... | @@ -32,8 +32,10 @@ practicalmeteor:mocha |
32 | 32 | xolvio:backdoor |
33 | 33 | mdg:validated-method |
34 | 34 | dburles:factory@1.0.0 |
35 | -ddp-rate-limiter@1.0.6 | |
36 | -shell-server@0.2.2 | |
35 | +ddp-rate-limiter@1.0.7 | |
36 | +shell-server@0.2.3 | |
37 | 37 | aldeed:simple-schema |
38 | 38 | momentjs:moment |
39 | 39 | meteorhacks:picker |
40 | +harrison:papa-parse | |
41 | +ostrio:files | ... | ... |
.meteor/release
.meteor/versions
1 | -accounts-base@1.2.14 | |
1 | +accounts-base@1.2.15 | |
2 | 2 | accounts-password@1.3.4 |
3 | 3 | alanning:roles@1.2.16 |
4 | 4 | aldeed:collection2@2.10.0 |
... | ... | @@ -13,7 +13,7 @@ babel-compiler@6.14.1 |
13 | 13 | babel-runtime@1.0.1 |
14 | 14 | base64@1.0.10 |
15 | 15 | binary-heap@1.0.10 |
16 | -blaze@2.3.0 | |
16 | +blaze@2.3.2 | |
17 | 17 | blaze-tools@1.0.10 |
18 | 18 | boilerplate-generator@1.0.11 |
19 | 19 | browser-policy@1.1.0 |
... | ... | @@ -21,7 +21,7 @@ browser-policy-common@1.0.11 |
21 | 21 | browser-policy-content@1.1.0 |
22 | 22 | browser-policy-framing@1.1.0 |
23 | 23 | caching-compiler@1.1.9 |
24 | -caching-html-compiler@1.1.0 | |
24 | +caching-html-compiler@1.1.2 | |
25 | 25 | callback-hook@1.0.10 |
26 | 26 | check@1.2.5 |
27 | 27 | coffeescript@1.12.3_1 |
... | ... | @@ -29,7 +29,7 @@ dburles:factory@1.1.0 |
29 | 29 | ddp@1.2.5 |
30 | 30 | ddp-client@1.3.3 |
31 | 31 | ddp-common@1.2.8 |
32 | -ddp-rate-limiter@1.0.6 | |
32 | +ddp-rate-limiter@1.0.7 | |
33 | 33 | ddp-server@1.3.13 |
34 | 34 | deps@1.0.12 |
35 | 35 | diff-sequence@1.0.7 |
... | ... | @@ -42,10 +42,11 @@ fastclick@1.0.13 |
42 | 42 | fortawesome:fontawesome@4.7.0 |
43 | 43 | fourseven:scss@3.13.0 |
44 | 44 | geojson-utils@1.0.10 |
45 | +harrison:papa-parse@1.1.7 | |
45 | 46 | hot-code-push@1.0.4 |
46 | 47 | html-tools@1.0.11 |
47 | 48 | htmljs@1.0.11 |
48 | -http@1.2.11 | |
49 | +http@1.2.12 | |
49 | 50 | id-map@1.0.9 |
50 | 51 | jquery@1.11.10 |
51 | 52 | launch-screen@1.1.1 |
... | ... | @@ -59,18 +60,20 @@ meteor-base@1.0.4 |
59 | 60 | meteorhacks:picker@1.0.3 |
60 | 61 | minifier-css@1.2.16 |
61 | 62 | minifier-js@1.2.18 |
62 | -minimongo@1.0.20 | |
63 | +minimongo@1.0.21 | |
63 | 64 | mobile-experience@1.0.4 |
64 | 65 | mobile-status-bar@1.0.14 |
65 | 66 | modules@0.7.9 |
66 | 67 | modules-runtime@0.7.9 |
67 | -momentjs:moment@2.17.1 | |
68 | -mongo@1.1.15 | |
68 | +momentjs:moment@2.18.1 | |
69 | +mongo@1.1.16 | |
69 | 70 | mongo-id@1.0.6 |
70 | 71 | npm-bcrypt@0.9.2 |
71 | -npm-mongo@2.2.16_1 | |
72 | -observe-sequence@1.0.15 | |
72 | +npm-mongo@2.2.24 | |
73 | +observe-sequence@1.0.16 | |
73 | 74 | ordered-dict@1.0.9 |
75 | +ostrio:cookies@2.2.0 | |
76 | +ostrio:files@1.7.13 | |
74 | 77 | practicalmeteor:chai@2.1.0_1 |
75 | 78 | practicalmeteor:loglevel@1.2.0_2 |
76 | 79 | practicalmeteor:mocha@2.4.5_6 |
... | ... | @@ -79,7 +82,7 @@ practicalmeteor:sinon@1.14.1_2 |
79 | 82 | promise@0.8.8 |
80 | 83 | raix:eventemitter@0.1.3 |
81 | 84 | random@1.0.10 |
82 | -rate-limit@1.0.6 | |
85 | +rate-limit@1.0.7 | |
83 | 86 | reactive-dict@1.1.8 |
84 | 87 | reactive-var@1.0.11 |
85 | 88 | reload@1.1.11 |
... | ... | @@ -89,23 +92,23 @@ service-configuration@1.0.11 |
89 | 92 | session@1.1.7 |
90 | 93 | sha@1.0.9 |
91 | 94 | shell-server@0.2.3 |
92 | -spacebars@1.0.13 | |
93 | -spacebars-compiler@1.1.0 | |
95 | +spacebars@1.0.15 | |
96 | +spacebars-compiler@1.1.2 | |
94 | 97 | srp@1.0.10 |
95 | 98 | standard-minifier-css@1.3.4 |
96 | 99 | standard-minifier-js@1.2.3 |
97 | -static-html@1.2.0 | |
98 | -templating@1.3.0 | |
99 | -templating-compiler@1.3.0 | |
100 | -templating-runtime@1.3.0 | |
101 | -templating-tools@1.1.0 | |
100 | +static-html@1.2.2 | |
101 | +templating@1.3.2 | |
102 | +templating-compiler@1.3.2 | |
103 | +templating-runtime@1.3.2 | |
104 | +templating-tools@1.1.2 | |
102 | 105 | themeteorchef:bert@2.1.1 |
103 | 106 | tmeasday:test-reporter-helpers@0.2.1 |
104 | 107 | tracker@1.1.2 |
105 | -ui@1.0.12 | |
108 | +ui@1.0.13 | |
106 | 109 | underscore@1.0.10 |
107 | 110 | url@1.1.0 |
108 | -webapp@1.3.13 | |
111 | +webapp@1.3.14 | |
109 | 112 | webapp-hashing@1.0.9 |
110 | 113 | xolvio:backdoor@0.2.1 |
111 | 114 | xolvio:cleaner@0.3.1 | ... | ... |
imports/client/views/org/admin/students/UploadCsv.js
... | ... | @@ -7,7 +7,9 @@ import { FormGroup,Panel,Table, |
7 | 7 | ButtonToolbar,Modal,ControlLabel,HelpBlock, |
8 | 8 | FormControl,Glyphicon,Button } from 'react-bootstrap'; |
9 | 9 | // import { AddStudentForm } from './addStudentForm'; |
10 | - | |
10 | +import { FilesCollection } from 'meteor/ostrio:files'; | |
11 | +const Papa = this.Papa; | |
12 | +// console.log(this); | |
11 | 13 | const style = { |
12 | 14 | margin: 12, |
13 | 15 | }; |
... | ... | @@ -44,10 +46,16 @@ export class UploadCsv extends Component { |
44 | 46 | uploadStudentCsv(e){ |
45 | 47 | e.preventDefault(); |
46 | 48 | e.persist(); |
47 | - csvData = ""; | |
48 | - Meteor.call('student.uploadCsv', csvData, function (error, result) { | |
49 | + var file = $('input[type="file"]').prop("files")[0]; | |
50 | + Papa.parse(file, { | |
51 | + complete: function(results) { | |
52 | + if(results){ | |
53 | + Meteor.call('student.uploadCsv', csvData, function (error, result) { | |
49 | 54 | |
50 | - }) | |
55 | + }) | |
56 | + } | |
57 | + } | |
58 | + }); | |
51 | 59 | } |
52 | 60 | |
53 | 61 | render() { | ... | ... |
imports/collections/orgs/methods.js
... | ... | @@ -52,18 +52,18 @@ export const checkEmailInOrg = new ValidatedMethod({ |
52 | 52 | }, |
53 | 53 | }); |
54 | 54 | |
55 | -export const studentCsvParse = new ValidatedMethod({ | |
56 | - name: 'org.studentCsvParse', | |
55 | +export const save_csv_data = new ValidatedMethod({ | |
56 | + name: 'save_csv_data', | |
57 | 57 | |
58 | - validate: new SimpleSchema({ | |
59 | - data: { type: [Object] }, | |
60 | - }).validator(), | |
58 | + validate: null, | |
61 | 59 | |
62 | - run(data) { | |
63 | - console.log(data); | |
64 | - return { | |
65 | - | |
66 | - }; | |
60 | + run(item,filename) { | |
61 | + var csv = json2csv({ | |
62 | + data: item, | |
63 | + fields: csv_students_fields | |
64 | + }); | |
65 | + fs.writeFile(filename, csv,function(err) { | |
66 | + if (err) throw err; | |
67 | + }); | |
67 | 68 | }, |
68 | - | |
69 | 69 | }); | ... | ... |
package.json
... | ... | @@ -66,10 +66,13 @@ |
66 | 66 | "babyparse": "^0.4.6", |
67 | 67 | "bcrypt": "^0.8.7", |
68 | 68 | "bootstrap": "^4.0.0-alpha.6", |
69 | + "csvtojson": "^1.1.4", | |
70 | + "fs": "0.0.1-security", | |
69 | 71 | "jquery": "^2.2.4", |
70 | 72 | "jquery-validation": "^1.15.1", |
71 | 73 | "material-fabmenu": "0.0.1", |
72 | 74 | "material-ui": "^0.17.1", |
75 | + "meteor-node-stubs": "^0.2.6", | |
73 | 76 | "moment": "^2.18.0", |
74 | 77 | "react": "^15.4.2", |
75 | 78 | "react-addons-css-transition-group": "^15.4.2", | ... | ... |