Commit d0a93cc6d1cf5b12fb3583acecb7aec3cd27ed16

Authored by Deepak
1 parent 9508f883a0
Exists in master

csv file

imports/client/views/org/admin/students/UploadCsv.js
... ... @@ -41,6 +41,14 @@ export class UploadCsv extends Component {
41 41 onUpdate(key, value) {
42 42 this.setState({[key]: value});
43 43 };
  44 + uploadStudentCsv(e){
  45 + e.preventDefault();
  46 + e.persist();
  47 + csvData = "";
  48 + Meteor.call('student.uploadCsv', csvData, function (error, result) {
  49 +
  50 + })
  51 + }
44 52  
45 53 render() {
46 54 console.log(this.props);
... ... @@ -59,13 +67,14 @@ export class UploadCsv extends Component {
59 67 <Modal.Title id="contained-modal-title-lg">New Student</Modal.Title>
60 68 </Modal.Header>
61 69 <Modal.Body>
62   - <form>
  70 + <form onSubmit={ (e) => this.uploadStudentCsv(e) } >
63 71 <FieldGroup
64 72 id="formControlsFile"
65 73 type="file"
66 74 label="File"
67 75 help="Upload you CSV here."
68 76 />
  77 + <Button type="submit" bsStyle="default">Upload File</Button>
69 78 </form>
70 79 </Modal.Body>
71 80 <Modal.Footer>
... ...
imports/collections/students/index.js
1   -// import {Students } from '/imports/collections/students/methods'
  1 +// import {Students } from '/imports/collections/students/index'
2 2  
3 3 import _ from 'lodash';
4 4 import { Meteor } from 'meteor/meteor';
... ...
imports/collections/students/serverCsvUpload.js
... ... @@ -0,0 +1,35 @@
  1 +// import { } from '/imports/collections/orgs/methods';
  2 +import _ from 'lodash';
  3 +import { Meteor } from 'meteor/meteor';
  4 +import { ValidatedMethod } from 'meteor/mdg:validated-method';
  5 +import { SimpleSchema } from 'meteor/aldeed:simple-schema';
  6 +import { DDPRateLimiter } from 'meteor/ddp-rate-limiter';
  7 +import { Bert } from 'meteor/themeteorchef:bert';
  8 +import { Users } from '/imports/collections/users/index';
  9 +import { Orgs } from '/imports/collections/orgs/index';
  10 +import {Students } from '/imports/collections/students/index'
  11 +export const orgMethod = new ValidatedMethod({
  12 + name: 'org.method',
  13 +
  14 + validate: new SimpleSchema({
  15 + itemId: { type: String },
  16 + }).validator(),
  17 +
  18 + run({itemId}) {
  19 + return {};
  20 + },
  21 +
  22 +});
  23 +
  24 +export const studentUploadCsv = new ValidatedMethod({
  25 + name: 'student.uploadCsv',
  26 +
  27 + validate: new SimpleSchema({
  28 + itemId: { type: String },
  29 + }).validator(),
  30 +
  31 + run({itemId}) {
  32 + return {};
  33 + },
  34 +
  35 +});
... ...