Commit ea4d73d090e35256855da348ed92d8be15fbfc13
Exists in
master
Merge branch 'master' of https://bitbucket.org/youngdesk/ydapp
Showing
16 changed files
Show diff stats
client/stylesheets/custom.css
1 | body | 1 | body |
2 | { | 2 | { |
3 | background: -webkit-linear-gradient(#00b395, #00cdaa); | 3 | background: -webkit-linear-gradient(#00b395, #00b395); |
4 | background: -o-linear-gradient(#00b395, #00cdaa); | 4 | background: -o-linear-gradient(#00b395, #00b395); |
5 | background: linear-gradient(#00b395, #00cdaa); | 5 | background: linear-gradient(#00b395, #00b395); |
6 | } | 6 | } |
7 | 7 | ||
8 | table .dropdown span{ | 8 | table .dropdown span{ |
9 | color: #000000; | 9 | color: #000000; |
10 | } | 10 | } |
11 | table .dropdown-toggle{ | 11 | table .dropdown-toggle{ |
12 | cursor: pointer; | 12 | cursor: pointer; |
13 | } | 13 | } |
14 | table .dropdown .fa{ | 14 | table .dropdown .fa{ |
15 | display: inline; | 15 | display: inline; |
16 | margin: 6px 6px; | 16 | margin: 6px 6px; |
17 | } | 17 | } |
18 | table .dropdown-menu { | 18 | table .dropdown-menu { |
19 | min-width: 134px; | 19 | min-width: 134px; |
20 | } | 20 | } |
21 | table .dropdown-menu > li { | 21 | table .dropdown-menu > li { |
22 | cursor: pointer; | 22 | cursor: pointer; |
23 | } | 23 | } |
24 | table .dropdown-menu > li:hover{ | 24 | table .dropdown-menu > li:hover{ |
25 | text-decoration: none; | 25 | text-decoration: none; |
26 | color: #333333; | 26 | color: #333333; |
27 | background-color: #f5f5f5; | 27 | background-color: #f5f5f5; |
28 | } | 28 | } |
29 | table .dropdown-menu > li > span{ | 29 | table .dropdown-menu > li > span{ |
30 | padding: 6px 16px; | 30 | padding: 6px 16px; |
31 | display: block; | 31 | display: block; |
32 | } | 32 | } |
33 | .panel-body{ | 33 | .panel-body{ |
34 | max-height: 550px; | 34 | max-height: 550px; |
35 | overflow-y: scroll; | 35 | overflow-y: scroll; |
36 | } | 36 | } |
37 | 37 |
imports/client/app/routes.js
1 | /* eslint-disable max-len */ | 1 | /* eslint-disable max-len */ |
2 | 2 | ||
3 | import React from 'react'; | 3 | import React from 'react'; |
4 | import { render } from 'react-dom'; | 4 | import { render } from 'react-dom'; |
5 | import { Router, Route, | 5 | import { Router, Route, |
6 | IndexRoute, browserHistory } from 'react-router'; | 6 | IndexRoute, browserHistory } from 'react-router'; |
7 | import { Meteor } from 'meteor/meteor'; | 7 | import { Meteor } from 'meteor/meteor'; |
8 | 8 | ||
9 | /** | 9 | /** |
10 | * General Components | 10 | * General Components |
11 | */ | 11 | */ |
12 | import Index from '/imports/client/views/app/module/Index'; | 12 | import Index from '/imports/client/views/app/module/Index'; |
13 | import NotFound from '/imports/client/views/org/NotFound'; | 13 | import NotFound from '/imports/client/views/org/NotFound'; |
14 | 14 | ||
15 | /** | 15 | /** |
16 | * Org Components | 16 | * Org Components |
17 | */ | 17 | */ |
18 | 18 | ||
19 | import { App } from '/imports/client/layouts/OrgApp'; | 19 | import { App } from '/imports/client/layouts/OrgApp'; |
20 | import { AppModule } from '/imports/client/views/org/app/module/Index'; | 20 | import { AppModule } from '/imports/client/views/org/app/module/Index'; |
21 | import { Orgs } from '/imports/collections/orgs/index'; | 21 | import { Orgs } from '/imports/collections/orgs/index'; |
22 | import { importCsvController } from '/imports/client/views/org/importCsv/index' | 22 | import { importCsvController } from '/imports/client/views/org/importCsv/index' |
23 | 23 | ||
24 | //admin | 24 | //admin |
25 | import { StudentDataController } from '/imports/client/views/org/admin/students/index' | 25 | import { StudentDataController } from '/imports/client/views/org/admin/students/index' |
26 | import { staffViewController } from '/imports/client/views/org/admin/staff/index' | 26 | import { staffViewController } from '/imports/client/views/org/admin/staff/index' |
27 | import { ParentViewController } from '/imports/client/views/org/admin/parents/index' | ||
27 | //students | 28 | //students |
28 | 29 | ||
29 | //teachers | 30 | //teachers |
30 | 31 | ||
31 | //parents | 32 | //parents |
32 | 33 | ||
33 | 34 | ||
34 | 35 | ||
35 | /** | 36 | /** |
36 | * NonOrg Components | 37 | * NonOrg Components |
37 | */ | 38 | */ |
38 | import Signup from '/imports/client/views/nonOrg/enter/SignupView'; | 39 | import Signup from '/imports/client/views/nonOrg/enter/SignupView'; |
39 | import { NonOrgApp } from '/imports/client/layouts/NonOrgApp'; | 40 | import { NonOrgApp } from '/imports/client/layouts/NonOrgApp'; |
40 | import {NonOrgAppModule} from '/imports/client/views/nonOrg/app/module/Index'; | 41 | import {NonOrgAppModule} from '/imports/client/views/nonOrg/app/module/Index'; |
41 | 42 | ||
42 | /** | 43 | /** |
43 | * Invalid Org Components | 44 | * Invalid Org Components |
44 | */ | 45 | */ |
45 | 46 | ||
46 | /** | 47 | /** |
47 | There are three types of routes | 48 | There are three types of routes |
48 | 1)getOrgRoutes: all the routes that should be present for a registered org | 49 | 1)getOrgRoutes: all the routes that should be present for a registered org |
49 | 2)getInvalidOrgRoute: all the routes where someone tries to enter a subdomain which hasn't been registered yet (404 mostly :D) | 50 | 2)getInvalidOrgRoute: all the routes where someone tries to enter a subdomain which hasn't been registered yet (404 mostly :D) |
50 | 3)getNonOrgRoutes: all routes linked to normal site, ie signing up a new org. CHeking out demo and everything internal | 51 | 3)getNonOrgRoutes: all routes linked to normal site, ie signing up a new org. CHeking out demo and everything internal |
51 | **/ | 52 | **/ |
52 | const getOrgRoutes = () => ( | 53 | const getOrgRoutes = () => ( |
53 | <Router history={ browserHistory }> | 54 | <Router history={ browserHistory }> |
54 | <Route path="/" component={ App }> | 55 | <Route path="/" component={ App }> |
55 | <IndexRoute name="index" component={ AppModule } /> | 56 | <IndexRoute name="index" component={ AppModule } /> |
56 | <Route name="import" path="/import" component={ importCsvController } /> | 57 | <Route name="import" path="/import" component={ importCsvController } /> |
57 | <Route name="student" path="/students" component={ StudentDataController } /> | 58 | <Route name="student" path="/students" component={ StudentDataController } /> |
58 | <Route name="staff" path="/staff" component={ staffViewController } /> | 59 | <Route name="staff" path="/staff" component={ staffViewController } /> |
60 | <Route name="parent" path="/parents" component={ ParentViewController } /> | ||
59 | <Route path="*" component={ NotFound } /> | 61 | <Route path="*" component={ NotFound } /> |
60 | </Route> | 62 | </Route> |
61 | </Router> | 63 | </Router> |
62 | ) | 64 | ) |
63 | 65 | ||
64 | 66 | ||
65 | const getInvalidOrgRoute = () => ( | 67 | const getInvalidOrgRoute = () => ( |
66 | <Router history={ browserHistory }> | 68 | <Router history={ browserHistory }> |
67 | <Route path="/" component={ App }> | 69 | <Route path="/" component={ App }> |
68 | <IndexRoute name="index" component={ NotFound } /> | 70 | <IndexRoute name="index" component={ NotFound } /> |
69 | <Route path="*" component={ NotFound } /> | 71 | <Route path="*" component={ NotFound } /> |
70 | </Route> | 72 | </Route> |
71 | </Router> | 73 | </Router> |
72 | ) | 74 | ) |
73 | 75 | ||
74 | const getNonOrgRoutes = () => ( | 76 | const getNonOrgRoutes = () => ( |
75 | <Router history={ browserHistory }> | 77 | <Router history={ browserHistory }> |
76 | <Route path="/" component={ NonOrgApp }> | 78 | <Route path="/" component={ NonOrgApp }> |
77 | <IndexRoute name="index" component={ NonOrgAppModule } /> | 79 | <IndexRoute name="index" component={ NonOrgAppModule } /> |
78 | <Route name="signup" path="/signup" component={ Signup } /> | 80 | <Route name="signup" path="/signup" component={ Signup } /> |
79 | <Route path="*" component={ NotFound } /> | 81 | <Route path="*" component={ NotFound } /> |
80 | </Route> | 82 | </Route> |
81 | </Router> | 83 | </Router> |
82 | ) | 84 | ) |
83 | 85 | ||
84 | //Authenticate function to give access to users only | 86 | //Authenticate function to give access to users only |
85 | const authenticate = (nextState, replace) => { | 87 | const authenticate = (nextState, replace) => { |
86 | if (!Meteor.loggingIn() && !Meteor.userId()) { | 88 | if (!Meteor.loggingIn() && !Meteor.userId()) { |
87 | replace({ | 89 | replace({ |
88 | pathname: '/login', | 90 | pathname: '/login', |
89 | state: { nextPathname: nextState.location.pathname }, | 91 | state: { nextPathname: nextState.location.pathname }, |
90 | }); | 92 | }); |
91 | } | 93 | } |
92 | }; | 94 | }; |
93 | 95 | ||
94 | 96 | ||
95 | /** | 97 | /** |
96 | 98 | ||
97 | **/ | 99 | **/ |
98 | const detectOrg = () => { | 100 | const detectOrg = () => { |
99 | orgSlug = ""; | 101 | orgSlug = ""; |
100 | var hostnameArray = document.location.hostname.split( "." ); | 102 | var hostnameArray = document.location.hostname.split( "." ); |
101 | if(hostnameArray[0] !== "www"){ | 103 | if(hostnameArray[0] !== "www"){ |
102 | if((hostnameArray[1]==='localhost'||hostnameArray[1]==='ydapp')){ | 104 | if((hostnameArray[1]==='localhost'||hostnameArray[1]==='ydapp')){ |
103 | orgSlug = hostnameArray[0]; | 105 | orgSlug = hostnameArray[0]; |
104 | } | 106 | } |
105 | }else{ | 107 | }else{ |
106 | if((hostnameArray[2]==='localhost'||hostnameArray[2]==='ydapp')){ | 108 | if((hostnameArray[2]==='localhost'||hostnameArray[2]==='ydapp')){ |
107 | orgSlug = hostnameArray[1]; | 109 | orgSlug = hostnameArray[1]; |
108 | } | 110 | } |
109 | } | 111 | } |
110 | 112 | ||
111 | if(orgSlug!==""){ | 113 | if(orgSlug!==""){ |
112 | console.log(orgSlug); | 114 | console.log(orgSlug); |
113 | Meteor.call('checkExistingOrg', {slug:orgSlug}, function(err, res) { | 115 | Meteor.call('checkExistingOrg', {slug:orgSlug}, function(err, res) { |
114 | if(res){ | 116 | if(res){ |
115 | Session.set('orgId', res._id); | 117 | Session.set('orgId', res._id); |
116 | Session.set('orgSlug', orgSlug); | 118 | Session.set('orgSlug', orgSlug); |
117 | render(getOrgRoutes(),document.getElementById('app')); | 119 | render(getOrgRoutes(),document.getElementById('app')); |
118 | }else{ | 120 | }else{ |
119 | render(getInvalidOrgRoute(),document.getElementById('app')); | 121 | render(getInvalidOrgRoute(),document.getElementById('app')); |
120 | } | 122 | } |
121 | }); | 123 | }); |
122 | }else{ | 124 | }else{ |
123 | render(getNonOrgRoutes(),document.getElementById('app')); | 125 | render(getNonOrgRoutes(),document.getElementById('app')); |
124 | } | 126 | } |
125 | } | 127 | } |
126 | const checkSlug = (nextState, replace) => { | 128 | const checkSlug = (nextState, replace) => { |
127 | orgId = Session.get('orgId'); | 129 | orgId = Session.get('orgId'); |
128 | } | 130 | } |
129 | 131 | ||
130 | 132 | ||
131 | Meteor.startup(() => { | 133 | Meteor.startup(() => { |
132 | detectOrg(); | 134 | detectOrg(); |
133 | }); | 135 | }); |
134 | 136 |
imports/client/views/nonOrg/enter/signup.css
1 | .Signup | 1 | .Signup |
2 | { | 2 | { |
3 | float: right; | 3 | float: right; |
4 | margin: 20px auto; | 4 | margin: 20px auto; |
5 | width: 400px; | 5 | width: 400px; |
6 | height: auto; | 6 | height: auto; |
7 | padding: 20px; | 7 | padding: 20px; |
8 | -webkit-border-radius: 8px/7px; | 8 | -webkit-border-radius: 8px/7px; |
9 | -moz-border-radius: 8px/7px; | 9 | -moz-border-radius: 8px/7px; |
10 | border-radius: 8px/7px; | 10 | border-radius: 8px/7px; |
11 | background-color: white; | 11 | background-color: white; |
12 | -webkit-box-shadow: 1px 2px 5px rgba(0,0,0,.31); | 12 | -webkit-box-shadow: 1px 2px 5px rgba(0,0,0,.31); |
13 | -moz-box-shadow: 1px 2px 5px rgba(0,0,0,.31); | 13 | -moz-box-shadow: 1px 2px 5px rgba(0,0,0,.31); |
14 | box-shadow: 1px 2px 5px rgba(0,0,0,.31); | 14 | box-shadow: 1px 2px 5px rgba(0,0,0,.31); |
15 | border: solid 1px #cbc9c9; | 15 | border: solid 1px #cbc9c9; |
16 | font-family: 'Ubuntu', sans-serif; | 16 | font-family: 'Ubuntu', sans-serif; |
17 | } | 17 | } |
18 | 18 | ||
19 | .Content | 19 | .Content |
20 | { | 20 | { |
21 | margin: 20px auto; | 21 | margin: 20px auto; |
22 | width: 750px; | 22 | width: 750px; |
23 | height: auto; | 23 | height: auto; |
24 | padding: 20px; | 24 | padding: 20px; |
25 | font-family: 'Ubuntu', sans-serif; | 25 | font-family: 'Ubuntu', sans-serif; |
26 | color: white; | 26 | color: white; |
27 | float:left; | 27 | float:left; |
28 | } | 28 | } |
29 | 29 | ||
30 | .section-heading | 30 | .section-heading |
31 | { | 31 | { |
32 | text-align: center; | 32 | text-align: center; |
33 | } | 33 | } |
34 | 34 | ||
35 | .signupView .contact | 35 | .signupView .contact |
36 | { | 36 | { |
37 | text-align: center; | 37 | text-align: center; |
38 | text-indent: 0px !important; | 38 | text-indent: 0px !important; |
39 | } | 39 | } |
40 | 40 | ||
41 | |||
42 | @media screen and (max-width:768px){ | ||
41 | .container | 43 | .container |
42 | { | 44 | { |
43 | /*width:1300px !important;*/ | 45 | /*width:1300px !important;*/ |
44 | } | 46 | } |
47 | .Signup | ||
48 | { | ||
49 | float:none; | ||
50 | clear:both; | ||
51 | } | ||
52 | } | ||
45 | 53 | ||
46 | .signupView h1 | 54 | .signupView h1 |
47 | { | 55 | { |
48 | font-size: 45px !important; | 56 | font-size: 45px !important; |
49 | } | 57 | } |
50 | 58 | ||
51 | .signupView p | 59 | .signupView p |
52 | { | 60 | { |
53 | text-indent: 50px; | 61 | text-indent: 50px; |
54 | text-align: justify; | 62 | text-align: justify; |
55 | font-size:15px; | 63 | font-size:15px; |
56 | } | 64 | } |
57 | 65 | ||
58 | .signupView h6 | 66 | .signupView h6 |
59 | { | 67 | { |
60 | text-align: center; | 68 | text-align: center; |
61 | } | 69 | } |
62 | 70 | ||
63 | .signupView i | 71 | .signupView i |
64 | { | 72 | { |
65 | display: inline-block; | 73 | display: inline-block; |
66 | width: 100%; | 74 | width: 100%; |
67 | text-align: center; | 75 | text-align: center; |
68 | } | 76 | } |
69 | 77 | ||
70 | 78 | ||
71 | 79 | ||
72 | .wrapper | 80 | .wrapper |
73 | { | 81 | { |
74 | overflow: hidden; | 82 | overflow: hidden; |
75 | } | 83 | } |
76 | 84 | ||
77 | .page-header | 85 | .page-header |
78 | { | 86 | { |
79 | text-align: center; | 87 | text-align: center; |
80 | color:#00b395; | 88 | color:#00b395; |
81 | font-weight: bolder; | 89 | font-weight: bolder; |
82 | } | 90 | } |
83 | 91 | ||
84 | .side-heading | 92 | .side-heading |
85 | { | 93 | { |
86 | /*padding: 10px;*/ | 94 | /*padding: 10px;*/ |
87 | text-align: left; | 95 | text-align: left; |
88 | font-weight: bold; | 96 | font-weight: bold; |
89 | color:#00b395; | 97 | color:#00b395; |
90 | font-size: 14px; | 98 | font-size: 14px; |
91 | } | 99 | } |
92 | 100 | ||
93 | .signupView hr { | 101 | .signupView hr { |
94 | display: block; | 102 | display: block; |
95 | height: 1px; | 103 | height: 1px; |
96 | border: 0; | 104 | border: 0; |
97 | border-top: 1px solid #00b395; | 105 | border-top: 1px solid #00b395; |
98 | padding: 0; | 106 | padding: 0; |
99 | } | 107 | } |
100 | 108 | ||
101 | .blue { | 109 | .blue { |
102 | background-color: #00b395; | 110 | background-color: #00b395; |
103 | background-image: -webkit-linear-gradient(top,#00b395,#00cdaa); | 111 | background-image: -webkit-linear-gradient(top,#00b395,#00cdaa); |
104 | background-image: -moz-linear-gradient(top,#00b395,#00cdaa); | 112 | background-image: -moz-linear-gradient(top,#00b395,#00cdaa); |
105 | background-image: -ms-linear-gradient(top,#00b395,#00cdaa); | 113 | background-image: -ms-linear-gradient(top,#00b395,#00cdaa); |
106 | background-image: -o-linear-gradient(top,#00b395,#00cdaa); | 114 | background-image: -o-linear-gradient(top,#00b395,#00cdaa); |
107 | background-image: linear-gradient(top,#00b395,#00cdaa); | 115 | background-image: linear-gradient(top,#00b395,#00cdaa); |
108 | 116 | ||
109 | border: 1px solid #00b395; | 117 | border: 1px solid #00b395; |
110 | color: white; | 118 | color: white; |
111 | 119 | ||
112 | font-size: 13px; | 120 | font-size: 13px; |
113 | font-weight: bold; | 121 | font-weight: bold; |
114 | text-align: center; | 122 | text-align: center; |
115 | height: 27px; | 123 | height: 27px; |
116 | line-height: 27px; | 124 | line-height: 27px; |
117 | min-width: 54px; | 125 | min-width: 54px; |
118 | padding: 0 10px; | 126 | padding: 0 10px; |
119 | text-decoration: none; | 127 | text-decoration: none; |
120 | } | 128 | } |
121 | 129 | ||
122 | .blue:hover { | 130 | .blue:hover { |
123 | border: 1px solid #00b395; | 131 | border: 1px solid #00b395; |
124 | 132 | ||
125 | color: white; | 133 | color: white; |
126 | background-color: #00b395; | 134 | background-color: #00b395; |
127 | background-image: -webkit-linear-gradient(top,#00b395,#009f85); | 135 | background-image: -webkit-linear-gradient(top,#00b395,#009f85); |
128 | background-image: -moz-linear-gradient(top,#00b395,#009f85); | 136 | background-image: -moz-linear-gradient(top,#00b395,#009f85); |
129 | background-image: -ms-linear-gradient(top,#00b395,#009f85); | 137 | background-image: -ms-linear-gradient(top,#00b395,#009f85); |
130 | background-image: -o-linear-gradient(top,#00b395,#009f85); | 138 | background-image: -o-linear-gradient(top,#00b395,#009f85); |
131 | background-image: linear-gradient(top,#00b395,#009f85); | 139 | background-image: linear-gradient(top,#00b395,#009f85); |
132 | 140 | ||
133 | -webkit-box-shadow: 0 1px 1px rgba(0,0,0,.1); | 141 | -webkit-box-shadow: 0 1px 1px rgba(0,0,0,.1); |
134 | -moz-box-shadow: 0 1px 1px rgba(0,0,0,.1); | 142 | -moz-box-shadow: 0 1px 1px rgba(0,0,0,.1); |
135 | box-shadow: 0 1px 1px rgba(0,0,0,.1); | 143 | box-shadow: 0 1px 1px rgba(0,0,0,.1); |
136 | width: auto; | 144 | width: auto; |
137 | height: 27px; | 145 | height: 27px; |
138 | } | 146 | } |
139 | 147 |
imports/client/views/org/admin/AdminLayout.js
1 | import _ from 'lodash'; | 1 | import _ from 'lodash'; |
2 | import { Meteor } from 'meteor/meteor'; | 2 | import { Meteor } from 'meteor/meteor'; |
3 | import React, { Component } from 'react'; | 3 | import React, { Component } from 'react'; |
4 | import { Link } from 'react-router'; | 4 | import { Link } from 'react-router'; |
5 | import { Avatar } from '/imports/client/components/Avatar'; | 5 | import { Avatar } from '/imports/client/components/Avatar'; |
6 | import { Icon } from '/imports/client/components/Icon'; | 6 | import { Icon } from '/imports/client/components/Icon'; |
7 | import classNames from 'classnames'; | 7 | import classNames from 'classnames'; |
8 | import { EnterModule } from '/imports/client/views/org/enter/module/index'; | 8 | import { EnterModule } from '/imports/client/views/org/enter/module/index'; |
9 | import { AdminSidebar } from './Sidebar' | 9 | import { AdminSidebar } from './Sidebar' |
10 | import { AdminBreadcrumb } from './Breadcrumb' | 10 | import { AdminBreadcrumb } from './Breadcrumb' |
11 | // import { VerifyModule } from '/imports/client/views/verify/module/index'; | 11 | // import { VerifyModule } from '/imports/client/views/verify/module/index'; |
12 | import { Navbar,Modal, Nav, NavItem, | 12 | import { Navbar,Modal, Nav, NavItem, |
13 | Glyphicon, Collapse, | 13 | Glyphicon, Collapse, |
14 | NavbarToggler, NavbarBrand, | 14 | NavbarToggler, NavbarBrand, |
15 | NavLink, DropdownItem, DropdownToggle, DropdownMenu, | 15 | NavLink, DropdownItem, DropdownToggle, DropdownMenu, |
16 | NavDropdown, MenuItem, Breadcrumb } from 'react-bootstrap'; | 16 | NavDropdown, MenuItem, Breadcrumb } from 'react-bootstrap'; |
17 | import { VerifyModule } from '/imports/client/views/verify/module/index' | 17 | import { VerifyModule } from '/imports/client/views/verify/module/index' |
18 | 18 | ||
19 | var Accordion = require('react-bootstrap').Accordion; | 19 | var Accordion = require('react-bootstrap').Accordion; |
20 | var Panel = require('react-bootstrap').Panel; | 20 | var Panel = require('react-bootstrap').Panel; |
21 | export class AdminAppLayout extends Component { | 21 | export class AdminAppLayout extends Component { |
22 | render() { | 22 | render() { |
23 | const {user, org} = this.props; | 23 | const {user, org} = this.props; |
24 | return ( | 24 | return ( |
25 | <div className = "appLayout-box"> | 25 | <div className = "appLayout-box"> |
26 | <div className="page-container"> | 26 | <div className="page-container"> |
27 | <div className="page-content"> | 27 | <div className="page-content"> |
28 | <AdminSidebar | 28 | <AdminSidebar |
29 | user = {user} | 29 | user = {user} |
30 | org = {org} | 30 | org = {org} |
31 | /> | 31 | /> |
32 | <div className="content-wrapper"> | 32 | <div className="content-wrapper"> |
33 | <AdminBreadcrumb /> | 33 | <AdminBreadcrumb /> |
34 | <div className="content"> | 34 | <div className="content"> |
35 | <div className="row"> | 35 | <div className="row"> |
36 | <div className="col-lg-3 col-md-6"> | 36 | <div className="col-lg-3 col-md-6"> |
37 | <div className="thumbnail"> | 37 | <div className="thumbnail"> |
38 | <Link to="/students" > | 38 | <Link to="/students" > |
39 | <div className="thumb thumb-rounded"> | 39 | <div className="thumb thumb-rounded"> |
40 | <img src="assets/images/download2.png" alt="" /> | 40 | <img src="assets/images/download2.png" alt="" /> |
41 | </div> | 41 | </div> |
42 | <div className="caption text-center"> | 42 | <div className="caption text-center"> |
43 | <h6 className="text-semibold no-margin">Students <small className="display-block">Click to view</small></h6> | 43 | <h6 className="text-semibold no-margin">Students <small className="display-block">Click to view</small></h6> |
44 | </div> | 44 | </div> |
45 | </Link> | 45 | </Link> |
46 | </div> | 46 | </div> |
47 | </div> | 47 | </div> |
48 | <div className="col-lg-3 col-md-6"> | 48 | <div className="col-lg-3 col-md-6"> |
49 | <div className="thumbnail"> | 49 | <div className="thumbnail"> |
50 | <Link to="/staff" > | 50 | <Link to="/staff" > |
51 | <div className="thumb thumb-rounded"> | 51 | <div className="thumb thumb-rounded"> |
52 | <img src="assets/images/download3.png" alt=""/> | 52 | <img src="assets/images/download3.png" alt=""/> |
53 | </div> | 53 | </div> |
54 | <div className="caption text-center"> | 54 | <div className="caption text-center"> |
55 | <h6 className="text-semibold no-margin">Teachers <small className="display-block">Click to view</small></h6> | 55 | <h6 className="text-semibold no-margin">Teachers <small className="display-block">Click to view</small></h6> |
56 | </div> | 56 | </div> |
57 | </Link> | 57 | </Link> |
58 | </div> | 58 | </div> |
59 | </div> | 59 | </div> |
60 | <div className="col-lg-3 col-md-6"> | ||
61 | <div className="thumbnail"> | ||
62 | <Link to="/parents" > | ||
63 | <div className="thumb thumb-rounded"> | ||
64 | <img src="assets/images/download3.png" alt=""/> | ||
65 | </div> | ||
66 | <div className="caption text-center"> | ||
67 | <h6 className="text-semibold no-margin">Parents <small className="display-block">Click to view</small></h6> | ||
68 | </div> | ||
69 | </Link> | ||
70 | </div> | ||
71 | </div> | ||
60 | </div> | 72 | </div> |
61 | </div> | 73 | </div> |
62 | </div> | 74 | </div> |
63 | </div> | 75 | </div> |
64 | </div> | 76 | </div> |
65 | </div> | 77 | </div> |
66 | ); | 78 | ); |
67 | }; | 79 | }; |
68 | 80 | ||
69 | }; | 81 | }; |
70 | 82 |
imports/client/views/org/admin/Header.js
1 | import _ from 'lodash'; | 1 | import _ from 'lodash'; |
2 | import { Meteor } from 'meteor/meteor'; | 2 | import { Meteor } from 'meteor/meteor'; |
3 | 3 | ||
4 | import React, { Component } from 'react'; | 4 | import React, { Component } from 'react'; |
5 | import { Link,browserHistory } from 'react-router'; | 5 | import { Link,browserHistory } from 'react-router'; |
6 | import { FormGroup, | 6 | import { FormGroup, |
7 | FormControl,Glyphicon,Button } from 'react-bootstrap'; | 7 | FormControl,Glyphicon,Button } from 'react-bootstrap'; |
8 | import './header.css'; | ||
8 | 9 | ||
9 | 10 | ||
10 | export class Header extends Component { | 11 | export class Header extends Component { |
11 | 12 | ||
12 | constructor(props) { | 13 | constructor(props) { |
13 | super(props); | 14 | super(props); |
14 | this.state = { | 15 | this.state = { |
15 | 16 | ||
16 | }; | 17 | }; |
17 | this.onUpdate = this.onUpdate.bind(this); | 18 | this.onUpdate = this.onUpdate.bind(this); |
18 | }; | 19 | }; |
19 | 20 | ||
20 | onUpdate(key, value) { | 21 | onUpdate(key, value) { |
21 | this.setState({[key]: value}); | 22 | this.setState({[key]: value}); |
22 | }; | 23 | }; |
23 | 24 | ||
24 | render() { | 25 | render() { |
25 | return ( | 26 | return ( |
26 | <div className = "enterPane-box"> | 27 | <div className = "enterPane-box"> |
27 | <div className="row"> | 28 | <div className="row"> |
29 | |||
28 | <div className="col-lg-3 col-md-6"> | 30 | <div className="col-lg-3 col-md-6"> |
29 | <div className="thumbnail"> | 31 | <Link to="/parents" > |
30 | <Link to="/students" > | 32 | <div className="panel panel-body"> |
31 | <div className="thumb thumb-rounded"> | 33 | <div className="media"> |
32 | <img src="assets/images/download2.png" alt="" /> | 34 | <div className="media-left"> |
35 | <img src="assets/images/download2.png" className="img-circle" alt=""/> | ||
33 | </div> | 36 | </div> |
34 | <div className="caption text-center"> | 37 | |
35 | <h6 className="text-semibold no-margin">Students <small className="display-block">Click to view</small></h6> | 38 | <div className="media-body"> |
39 | <h6 className="media-heading">Students</h6> | ||
40 | <p className="text-muted">Click to view</p> | ||
36 | </div> | 41 | </div> |
37 | </Link> | ||
38 | </div> | 42 | </div> |
43 | </div> | ||
44 | </Link> | ||
39 | </div> | 45 | </div> |
40 | <div className="col-lg-3 col-md-6"> | 46 | <div className="col-lg-3 col-md-6"> |
41 | <div className="thumbnail"> | 47 | <Link to="/parents" > |
42 | <Link to="/staff" > | 48 | <div className="panel panel-body"> |
43 | <div className="thumb thumb-rounded"> | 49 | <div className="media"> |
44 | <img src="assets/images/download3.png" alt=""/> | 50 | <div className="media-left"> |
51 | <img src="assets/images/download.png" className="img-circle" alt=""/> | ||
45 | </div> | 52 | </div> |
46 | <div className="caption text-center"> | 53 | |
47 | <h6 className="text-semibold no-margin">Teachers <small className="display-block">Click to view</small></h6> | 54 | <div className="media-body"> |
55 | <h6 className="media-heading">Teachers</h6> | ||
56 | <p className="text-muted">Click to view</p> | ||
48 | </div> | 57 | </div> |
49 | </Link> | 58 | </div> |
59 | </div> | ||
60 | </Link> | ||
61 | </div> | ||
62 | |||
63 | <div className="col-lg-3 col-md-6"> | ||
64 | <Link to="/parents" > | ||
65 | <div className="panel panel-body"> | ||
66 | <div className="media"> | ||
67 | <div className="media-left"> | ||
68 | <img src="assets/images/download3.png" className="img-circle" alt=""/> | ||
69 | </div> | ||
70 | |||
71 | <div className="media-body"> | ||
72 | <h6 className="media-heading">Parents</h6> | ||
73 | <p className="text-muted">Click to view</p> | ||
74 | </div> | ||
75 | </div> | ||
50 | </div> | 76 | </div> |
77 | </Link> | ||
51 | </div> | 78 | </div> |
52 | 79 | ||
53 | </div> | 80 | </div> |
54 | </div> | 81 | </div> |
55 | ); | 82 | ); |
56 | }; | 83 | }; |
57 | 84 | ||
58 | }; | 85 | }; |
imports/client/views/org/admin/header.css
File was created | 1 | .img-circle | |
2 | { | ||
3 | width: 70px; | ||
4 | height: 70px; | ||
5 | } | ||
6 |
imports/client/views/org/admin/parents/index.js
File was created | 1 | import _ from 'lodash'; | |
2 | import { | ||
3 | composeWithTracker, | ||
4 | compose, | ||
5 | composeAll | ||
6 | } from 'react-komposer'; | ||
7 | import { Loading } from '/imports/client/components/Loading'; | ||
8 | |||
9 | import { Orgs } from '/imports/collections/orgs/index'; | ||
10 | import { Users } from '/imports/collections/users/index'; | ||
11 | import { Parents } from '/imports/collections/parents/index'; | ||
12 | import { ParentsView } from './parentsview'; | ||
13 | |||
14 | |||
15 | |||
16 | const meteorTick = (props, onData) => { | ||
17 | |||
18 | const handles = [ | ||
19 | Meteor.subscribe('users.current'), | ||
20 | Meteor.subscribe('orgs.current'), | ||
21 | Meteor.subscribe('users.forMyOrg'), | ||
22 | Meteor.subscribe('parent.forMyOrg'), | ||
23 | ]; | ||
24 | |||
25 | if(_.every(handles, (handle) => (handle.ready()) )) { | ||
26 | const user = Users.current(); | ||
27 | const org = Orgs.current(); | ||
28 | console.log("parents"); | ||
29 | parent = Users.find({"role":"PARENT"}).fetch() ? Users.find({"role":"PARENT"}).fetch() : ""; | ||
30 | console.log(Users.find({"role":"PARENT"}).fetch()); | ||
31 | parentData = Parents.find().fetch() ? Parents.find().fetch() : ""; | ||
32 | console.log("parentData"); | ||
33 | console.log(parentData); | ||
34 | for(var i=0; i< parent.length; i++){ | ||
35 | for(var j=0; j< parentData.length; j++){ | ||
36 | if(parent[i]._id == parentData[j].userId){ | ||
37 | parent[i].relationship = parentData[j].relationship; | ||
38 | } | ||
39 | } | ||
40 | } | ||
41 | onData(null, { | ||
42 | data: { | ||
43 | user: user, | ||
44 | org: org, | ||
45 | parent: parent | ||
46 | }, | ||
47 | }); | ||
48 | } | ||
49 | |||
50 | return () => { | ||
51 | _.each(handles, (handle) => handle.stop() ); | ||
52 | }; | ||
53 | }; | ||
54 | |||
55 | |||
56 | const reduxTick = (props, onData) => { | ||
57 | onData(null, { | ||
58 | data: {} | ||
59 | }); | ||
60 | }; | ||
61 | |||
62 | |||
63 | export const ParentViewController = composeAll( | ||
64 | composeWithTracker(meteorTick, Loading), | ||
65 | compose(reduxTick, Loading), | ||
66 | )(ParentsView); | ||
67 |
imports/client/views/org/admin/parents/parentsview.js
File was created | 1 | import _ from 'lodash'; | |
2 | import { Meteor } from 'meteor/meteor'; | ||
3 | |||
4 | import React, { Component } from 'react'; | ||
5 | import { Link,browserHistory } from 'react-router'; | ||
6 | import { FormGroup, | ||
7 | FormControl,Glyphicon,Button } from 'react-bootstrap'; | ||
8 | import { Header } from '../Header'; | ||
9 | import { AdminSidebar } from '../Sidebar' | ||
10 | import { AdminBreadcrumb } from '../Breadcrumb' | ||
11 | import { ParentTable } from './view/ParentTable' | ||
12 | |||
13 | |||
14 | export class ParentsView extends Component { | ||
15 | |||
16 | constructor(props) { | ||
17 | super(props); | ||
18 | this.state = { | ||
19 | |||
20 | }; | ||
21 | this.onUpdate = this.onUpdate.bind(this); | ||
22 | }; | ||
23 | |||
24 | onUpdate(key, value) { | ||
25 | this.setState({[key]: value}); | ||
26 | }; | ||
27 | |||
28 | render() { | ||
29 | const {user, org, parent} = this.props.data; | ||
30 | return ( | ||
31 | <div className="appLayout-box"> | ||
32 | <div className="page-container"> | ||
33 | <div className="page-content"> | ||
34 | <AdminSidebar | ||
35 | user = {user} | ||
36 | org = {org} | ||
37 | /> | ||
38 | <div className="content-wrapper"> | ||
39 | <AdminBreadcrumb /> | ||
40 | |||
41 | <div className="content has-detached-left"> | ||
42 | <div className="container-detached"> | ||
43 | <div className="content-detached"> | ||
44 | <Header | ||
45 | user = {user} | ||
46 | org = {org} | ||
47 | /> | ||
48 | <ParentTable | ||
49 | data = {this.props.data} | ||
50 | parent = {parent} | ||
51 | /> | ||
52 | {/* <AddStaff/> | ||
53 | <UploadCsvStaff /> */} | ||
54 | </div> | ||
55 | </div> | ||
56 | <div className="sidebar-detached affix-top"> | ||
57 | <div className="sidebar sidebar-default"> | ||
58 | <div className="sidebar-content"> | ||
59 | |||
60 | <div className="sidebar-category"> | ||
61 | <div className="category-title"> | ||
62 | <span>Advanced Search</span> | ||
63 | <ul className="icons-list"> | ||
64 | <li><a href="#" data-action="collapse"></a></li> | ||
65 | </ul> | ||
66 | </div> | ||
67 | |||
68 | <div className="category-content"> | ||
69 | <form action="#"> | ||
70 | <div className="has-feedback has-feedback-left"> | ||
71 | <input type="search" className="form-control" | ||
72 | value={this.state.firstNameSearch} | ||
73 | onChange={e=>this.onUpdate('firstNameSearch',e.target.value)} | ||
74 | placeholder="First Name" | ||
75 | /> | ||
76 | <div className="form-control-feedback"> | ||
77 | <i className="icon-search4 text-size-base text-muted"></i> | ||
78 | </div> | ||
79 | </div> | ||
80 | </form> | ||
81 | </div> | ||
82 | <div className="category-content"> | ||
83 | <form action="#"> | ||
84 | <div className="has-feedback has-feedback-left"> | ||
85 | <input type="search" className="form-control" | ||
86 | value={this.state.lastNameSearch} | ||
87 | onChange={e=>this.onUpdate('lastNameSearch',e.target.value)} | ||
88 | placeholder="Last Name" /> | ||
89 | <div className="form-control-feedback"> | ||
90 | <i className="icon-search4 text-size-base text-muted"></i> | ||
91 | </div> | ||
92 | </div> | ||
93 | </form> | ||
94 | </div> | ||
95 | </div> | ||
96 | </div> | ||
97 | </div> | ||
98 | </div> | ||
99 | </div> | ||
100 | </div> | ||
101 | </div> | ||
102 | </div> | ||
103 | </div> | ||
104 | ); | ||
105 | }; | ||
106 | |||
107 | |||
108 | }; | ||
109 |
imports/client/views/org/admin/parents/view/ParentRow.js
File was created | 1 | import _ from 'lodash'; | |
2 | import { Meteor } from 'meteor/meteor'; | ||
3 | |||
4 | import React, { Component } from 'react'; | ||
5 | import { Link,browserHistory } from 'react-router'; | ||
6 | import { FormGroup, | ||
7 | FormControl,Glyphicon,Button } from 'react-bootstrap'; | ||
8 | |||
9 | |||
10 | export class ParentRow extends Component { | ||
11 | |||
12 | constructor(props) { | ||
13 | super(props); | ||
14 | this.state = { | ||
15 | |||
16 | }; | ||
17 | this.onUpdate = this.onUpdate.bind(this); | ||
18 | }; | ||
19 | |||
20 | onUpdate(key, value) { | ||
21 | this.setState({[key]: value}); | ||
22 | }; | ||
23 | |||
24 | render() { | ||
25 | const {parent} = this.props; | ||
26 | if(parent.firstName){ | ||
27 | return ( | ||
28 | <tr> | ||
29 | <td>{parent.firstName}</td> | ||
30 | <td>{parent.relationship}</td> {/* relationship doesnt reflect here */} | ||
31 | <td><span className="label label-success">Active</span></td> | ||
32 | <td className="text-center"> | ||
33 | <ul className="icons-list"> | ||
34 | <li className="dropdown"> | ||
35 | <a href="#" className="dropdown-toggle" data-toggle="dropdown"> | ||
36 | <i className="icon-menu9"></i> | ||
37 | </a> | ||
38 | <ul className="dropdown-menu dropdown-menu-right"> | ||
39 | <li><a href="#"><i className="icon-file-pdf"></i> Export to .pdf</a></li> | ||
40 | <li><a href="#"><i className="icon-file-excel"></i> Export to .csv</a></li> | ||
41 | <li><a href="#"><i className="icon-file-word"></i> Export to .doc</a></li> | ||
42 | </ul> | ||
43 | </li> | ||
44 | </ul> | ||
45 | </td> | ||
46 | </tr> | ||
47 | ); | ||
48 | }else { | ||
49 | return null; | ||
50 | } | ||
51 | |||
52 | }; | ||
53 | |||
54 | }; | ||
55 |
imports/client/views/org/admin/parents/view/ParentTable.js
File was created | 1 | import _ from 'lodash'; | |
2 | import { Meteor } from 'meteor/meteor'; | ||
3 | |||
4 | import React, { Component } from 'react'; | ||
5 | import { Link,browserHistory } from 'react-router'; | ||
6 | import { FormGroup,Panel,Table, | ||
7 | ButtonToolbar,Modal, | ||
8 | FormControl,Glyphicon,Button } from 'react-bootstrap'; | ||
9 | import {moment} from 'meteor/momentjs:moment' | ||
10 | import {ParentRow} from './ParentRow' | ||
11 | |||
12 | export class ParentTable extends Component { | ||
13 | |||
14 | constructor(props) { | ||
15 | super(props); | ||
16 | this.state = { | ||
17 | show: false | ||
18 | }; | ||
19 | this.onUpdate = this.onUpdate.bind(this); | ||
20 | }; | ||
21 | onUpdate(key, value) { | ||
22 | this.setState({[key]: value}); | ||
23 | }; | ||
24 | |||
25 | render() { | ||
26 | return ( | ||
27 | <div className="panel panel-flat"> | ||
28 | <div className="panel-heading"> | ||
29 | <h5 className="panel-title">Parent Details</h5> | ||
30 | <div className="heading-elements"> | ||
31 | <ul className="icons-list"> | ||
32 | <li><a data-action="collapse"></a></li> | ||
33 | <li><a data-action="reload"></a></li> | ||
34 | </ul> | ||
35 | </div> | ||
36 | </div> | ||
37 | <Table striped bordered condensed hover> | ||
38 | <thead> | ||
39 | <tr> | ||
40 | <th>First Name</th> | ||
41 | <th>Relationship</th> | ||
42 | <th>Status</th> | ||
43 | <th className="text-center">Actions</th> | ||
44 | </tr> | ||
45 | </thead> | ||
46 | <tbody> | ||
47 | { | ||
48 | this.props.parent.map(function(parent, i) | ||
49 | { | ||
50 | return( | ||
51 | <ParentRow | ||
52 | key = {i} | ||
53 | parent = {parent} | ||
54 | /> | ||
55 | ) | ||
56 | }) | ||
57 | } | ||
58 | </tbody> | ||
59 | </Table> | ||
60 | </div> | ||
61 | ); | ||
62 | }; | ||
63 | |||
64 | }; | ||
65 |
imports/client/views/org/admin/students/index.js
1 | // import { StudentDataController } from '/imports/client/views/org/admin/students/index' | 1 | // import { StudentDataController } from '/imports/client/views/org/admin/students/index' |
2 | import _ from 'lodash'; | 2 | import _ from 'lodash'; |
3 | import { | 3 | import { |
4 | composeWithTracker, | 4 | composeWithTracker, |
5 | compose, | 5 | compose, |
6 | composeAll | 6 | composeAll |
7 | } from 'react-komposer'; | 7 | } from 'react-komposer'; |
8 | import { Loading } from '/imports/client/components/Loading'; | 8 | import { Loading } from '/imports/client/components/Loading'; |
9 | 9 | ||
10 | import { Orgs } from '/imports/collections/orgs/index'; | 10 | import { Orgs } from '/imports/collections/orgs/index'; |
11 | import { Users } from '/imports/collections/users/index'; | 11 | import { Users } from '/imports/collections/users/index'; |
12 | import { StudentView } from './StudentView'; | 12 | import { StudentView } from './StudentView'; |
13 | import { Students } from '/imports/collections/students/index'; | 13 | import { Students } from '/imports/collections/students/index'; |
14 | 14 | ||
15 | 15 | ||
16 | const meteorTick = (props, onData) => { | 16 | const meteorTick = (props, onData) => { |
17 | 17 | ||
18 | const handles = [ | 18 | const handles = [ |
19 | Meteor.subscribe('users.current'), | 19 | Meteor.subscribe('users.current'), |
20 | Meteor.subscribe('orgs.current'), | 20 | Meteor.subscribe('orgs.current'), |
21 | Meteor.subscribe('users.forMyOrg'), | 21 | Meteor.subscribe('users.forMyOrg'), |
22 | Meteor.subscribe('student.forMyOrg'), | 22 | Meteor.subscribe('student.forMyOrg'), |
23 | ]; | 23 | ]; |
24 | 24 | ||
25 | if(_.every(handles, (handle) => (handle.ready()) )) { | 25 | if(_.every(handles, (handle) => (handle.ready()) )) { |
26 | const user = Users.current(); | 26 | const user = Users.current(); |
27 | const org = Orgs.current(); | 27 | const org = Orgs.current(); |
28 | students = Users.find({"role":"STUDENT"}).fetch() ? Users.find({"role":"STUDENT"}).fetch() : ""; | 28 | students = Users.find({"role":"STUDENT"}).fetch() ? Users.find({"role":"STUDENT"}).fetch() : ""; |
29 | console.log(students); | ||
29 | studentData = Students.find().fetch() ? Students.find().fetch() : ""; | 30 | studentData = Students.find().fetch() ? Students.find().fetch() : ""; |
30 | var mergedData; | 31 | var mergedData; |
31 | console.log(studentData); | 32 | console.log(studentData); |
32 | for(var i=0; i< students.length; i++){ | 33 | for(var i=0; i< students.length; i++){ |
33 | for(var j=0; j< studentData.length; j++){ | 34 | for(var j=0; j< studentData.length; j++){ |
34 | if(students[i]._id == studentData[j].userId && studentData[j].admissionId){ | 35 | if(students[i]._id == studentData[j].userId && studentData[j].admissionId){ |
35 | students[i].admissionId = studentData[j].admissionId; | 36 | students[i].admissionId = studentData[j].admissionId; |
36 | students[i].class = studentData[j].class; | 37 | students[i].class = studentData[j].class; |
37 | students[i].dob = studentData[j].dob; | 38 | students[i].dob = studentData[j].dob; |
38 | } | 39 | } |
39 | } | 40 | } |
40 | } | 41 | } |
41 | onData(null, { | 42 | onData(null, { |
42 | data: { | 43 | data: { |
43 | user: user, | 44 | user: user, |
44 | org: org, | 45 | org: org, |
45 | students: students, | 46 | students: students, |
46 | studentData: studentData | 47 | studentData: studentData |
47 | }, | 48 | }, |
48 | }); | 49 | }); |
49 | } | 50 | } |
50 | 51 | ||
51 | return () => { | 52 | return () => { |
52 | _.each(handles, (handle) => handle.stop() ); | 53 | _.each(handles, (handle) => handle.stop() ); |
53 | }; | 54 | }; |
54 | }; | 55 | }; |
55 | 56 | ||
56 | 57 | ||
57 | const reduxTick = (props, onData) => { | 58 | const reduxTick = (props, onData) => { |
58 | onData(null, { | 59 | onData(null, { |
59 | data: {} | 60 | data: {} |
60 | }); | 61 | }); |
61 | }; | 62 | }; |
62 | 63 | ||
63 | 64 | ||
64 | export const StudentDataController = composeAll( | 65 | export const StudentDataController = composeAll( |
65 | composeWithTracker(meteorTick, Loading), | 66 | composeWithTracker(meteorTick, Loading), |
66 | compose(reduxTick, Loading), | 67 | compose(reduxTick, Loading), |
67 | )(StudentView); | 68 | )(StudentView); |
68 | 69 |
imports/collections/parents/methods.js
1 | // import {Parents } from '/imports/collections/parents/methods' | 1 | // import {Parents } from '/imports/collections/parents/methods' |
2 | import _ from 'lodash'; | 2 | import _ from 'lodash'; |
3 | import { Meteor } from 'meteor/meteor'; | 3 | import { Meteor } from 'meteor/meteor'; |
4 | import { ValidatedMethod } from 'meteor/mdg:validated-method'; | 4 | import { ValidatedMethod } from 'meteor/mdg:validated-method'; |
5 | import { SimpleSchema } from 'meteor/aldeed:simple-schema'; | 5 | import { SimpleSchema } from 'meteor/aldeed:simple-schema'; |
6 | import { DDPRateLimiter } from 'meteor/ddp-rate-limiter'; | 6 | import { DDPRateLimiter } from 'meteor/ddp-rate-limiter'; |
7 | import { Bert } from 'meteor/themeteorchef:bert'; | 7 | import { Bert } from 'meteor/themeteorchef:bert'; |
8 | import { Users } from '/imports/collections/users/index'; | 8 | import { Users } from '/imports/collections/users/index'; |
9 | import { Students } from '/imports/collections/students/index'; | 9 | import { Students } from '/imports/collections/students/index'; |
10 | import { Orgs } from '/imports/collections/orgs/index'; | 10 | import { Orgs } from '/imports/collections/orgs/index'; |
11 | export const studentMethods = new ValidatedMethod({ | 11 | export const parentMethods = new ValidatedMethod({ |
12 | name: 'student.method', | 12 | name: 'parent.method', |
13 | 13 | ||
14 | validate: new SimpleSchema({ | 14 | validate: new SimpleSchema({ |
15 | itemId: { type: String }, | 15 | itemId: { type: String }, |
16 | }).validator(), | 16 | }).validator(), |
17 | 17 | ||
18 | run({itemId}) { | 18 | run({itemId}) { |
19 | return {}; | 19 | return {}; |
20 | }, | 20 | }, |
21 | 21 | ||
22 | }); | 22 | }); |
23 | |||
24 | export const addStudentManually = new ValidatedMethod({ | ||
25 | name: 'student.addManually', | ||
26 | |||
27 | validate: new SimpleSchema({ | ||
28 | admissionId: { type: String }, | ||
29 | firstName: { type: String }, | ||
30 | middleName: { type: String }, | ||
31 | lastName: { type: String }, | ||
32 | email: { type: String }, | ||
33 | dob: { type: String }, | ||
34 | formattedDob: { type: String }, | ||
35 | gender: { type: String }, | ||
36 | rollNo: { type: String }, | ||
37 | studentclass: { type: String }, | ||
38 | section: { type: String }, | ||
39 | community: { type: String }, | ||
40 | bloodGroup: { type: String }, | ||
41 | phone: { type: String }, | ||
42 | address: { type: String }, | ||
43 | city: { type: String }, | ||
44 | state: { type: String }, | ||
45 | parentName: { type: String }, | ||
46 | parentEmail: { type: String }, | ||
47 | relation: { type: String }, | ||
48 | profession: { type: String }, | ||
49 | parentGender: { type: String }, | ||
50 | parentPhone: { type: String }, | ||
51 | parentAddress: { type: String }, | ||
52 | parentCity: { type: String }, | ||
53 | parentState: { type: String }, | ||
54 | parentZipcode: { type: String }, | ||
55 | }).validator(), | ||
56 | |||
57 | run(data) { | ||
58 | console.log("data"); | ||
59 | console.log(data); | ||
60 | const user = Users.findOne({_id: this.userId}); | ||
61 | orgId = user.orgId; | ||
62 | newStudentId = Users.insert({ | ||
63 | emails: [data.email], | ||
64 | username: firstName, | ||
65 | firstName: firstName, | ||
66 | middleName: middleName, | ||
67 | lastName: lastName, | ||
68 | orgId: orgId, | ||
69 | role: 'STUDENT' | ||
70 | }); | ||
71 | newParentId = Users.insert({ | ||
72 | emails: [data.parentEmail], | ||
73 | username: parentName, | ||
74 | firstName: parentName, | ||
75 | orgId: orgId, | ||
76 | role: 'PARENT' | ||
77 | }); | ||
78 | console.log("newUserId"); | ||
79 | console.log(newUserId); | ||
80 | if(newUserId){ | ||
81 | Students.insert({ | ||
82 | userId: newUserId, | ||
83 | orgId: orgId, | ||
84 | admissionId: data.admissionId, | ||
85 | address: data.address, | ||
86 | gender: data.gender, | ||
87 | dob: data.dob, | ||
88 | rollNo: data.rollNo, | ||
89 | class: data.studentclass, | ||
90 | section: data.section, | ||
91 | bloodGroup: data.bloodGroup, | ||
92 | community: data.community, | ||
93 | |||
94 | }); | ||
95 | } | ||
96 | return {newUserId}; | ||
97 | }, | ||
98 | |||
99 | }); | ||
100 | 23 |
imports/collections/parents/publications.js
File was created | 1 | import { Meteor } from 'meteor/meteor'; | |
2 | import { check, Match } from 'meteor/check' | ||
3 | |||
4 | import { Orgs } from '/imports/collections/orgs/index'; | ||
5 | import { Users } from '/imports/collections/users/index'; | ||
6 | import { Parents } from '/imports/collections/parents/index'; | ||
7 | |||
8 | Meteor.publish('parent.forMyOrg', function () { | ||
9 | const user = Users.findOne({_id: this.userId}); | ||
10 | if(!user) return []; | ||
11 | return Parents.find({orgId: user.orgId}); | ||
12 | }); | ||
13 |
imports/collections/staff/serverCsvUpload.js
1 | // import { } from '/imports/collections/staff/methods'; | 1 | // import { } from '/imports/collections/staff/methods'; |
2 | import _ from 'lodash'; | 2 | import _ from 'lodash'; |
3 | import { Meteor } from 'meteor/meteor'; | 3 | import { Meteor } from 'meteor/meteor'; |
4 | import Papa from 'meteor/harrison:papa-parse' | 4 | import Papa from 'meteor/harrison:papa-parse' |
5 | import csv from 'csv2json-convertor' | 5 | import csv from 'csv2json-convertor' |
6 | import { ValidatedMethod } from 'meteor/mdg:validated-method'; | 6 | import { ValidatedMethod } from 'meteor/mdg:validated-method'; |
7 | import { SimpleSchema } from 'meteor/aldeed:simple-schema'; | 7 | import { SimpleSchema } from 'meteor/aldeed:simple-schema'; |
8 | import { DDPRateLimiter } from 'meteor/ddp-rate-limiter'; | 8 | import { DDPRateLimiter } from 'meteor/ddp-rate-limiter'; |
9 | import { Bert } from 'meteor/themeteorchef:bert'; | 9 | import { Bert } from 'meteor/themeteorchef:bert'; |
10 | import { Users } from '/imports/collections/users/index'; | 10 | import { Users } from '/imports/collections/users/index'; |
11 | import { Orgs } from '/imports/collections/orgs/index'; | 11 | import { Orgs } from '/imports/collections/orgs/index'; |
12 | import { Students } from '/imports/collections/students/index' | 12 | import { Students } from '/imports/collections/students/index' |
13 | import { Parents } from '/imports/collections/parents/index'; | 13 | import { Parents } from '/imports/collections/parents/index'; |
14 | import { Staffs } from '/imports/collections/staff/index'; | 14 | import { Staffs } from '/imports/collections/staff/index'; |
15 | import csv1 from 'csv2json-convertor' | 15 | import csv1 from 'csv2json-convertor' |
16 | import json2csv from 'json2csv' | 16 | import json2csv from 'json2csv' |
17 | import fs from 'fs' | 17 | import fs from 'fs' |
18 | import Validation from '/imports/validation/validationMethods'; | 18 | import Validation from '/imports/validation/validationMethods'; |
19 | import Constants from '/imports/constants/constants' | 19 | import Constants from '/imports/constants/constants' |
20 | 20 | ||
21 | export const staffCsvtMethod = new ValidatedMethod({ | 21 | export const staffCsvtMethod = new ValidatedMethod({ |
22 | name: 'staff.csvMethod', | 22 | name: 'staff.csvMethod', |
23 | 23 | ||
24 | validate: new SimpleSchema({ | 24 | validate: new SimpleSchema({ |
25 | itemId: { type: String }, | 25 | itemId: { type: String }, |
26 | }).validator(), | 26 | }).validator(), |
27 | 27 | ||
28 | run({itemId}) { | 28 | run({itemId}) { |
29 | return {}; | 29 | return {}; |
30 | }, | 30 | }, |
31 | 31 | ||
32 | }); | 32 | }); |
33 | 33 | ||
34 | export const staffSaveCsvData = new ValidatedMethod({ | 34 | export const staffSaveCsvData = new ValidatedMethod({ |
35 | name: 'staff.saveCsvData', | 35 | name: 'staff.saveCsvData', |
36 | 36 | ||
37 | validate: null, | 37 | validate: null, |
38 | 38 | ||
39 | run({item,filename,csv_fiels}) { | 39 | run({item,filename,csv_fiels}) { |
40 | var csv = json2csv({ | 40 | var csv = json2csv({ |
41 | data: item, | 41 | data: item, |
42 | fields: csv_fiels | 42 | fields: csv_fiels |
43 | }); | 43 | }); |
44 | fs.writeFile(filename, csv,function(err) { | 44 | fs.writeFile(filename, csv,function(err) { |
45 | if (err) throw err; | 45 | if (err) throw err; |
46 | }); | 46 | }); |
47 | }, | 47 | }, |
48 | }); | 48 | }); |
49 | 49 | ||
50 | export const addStaffCSV= new ValidatedMethod({ | 50 | export const addStaffCSV= new ValidatedMethod({ |
51 | name: 'staff.addCSV', | 51 | name: 'staff.addCSV', |
52 | 52 | ||
53 | validate: null, | 53 | validate: null, |
54 | 54 | ||
55 | run(item){ | 55 | run(item){ |
56 | data = item ; | 56 | data = item ; |
57 | console.log("data"); | 57 | console.log("data"); |
58 | console.log(data); | 58 | console.log(data); |
59 | // return true; | 59 | // return true; |
60 | const user = Users.findOne({_id: this.userId}); | 60 | const user = Users.findOne({_id: this.userId}); |
61 | orgId = user.orgId; | 61 | orgId = user.orgId; |
62 | newStaffId = Users.insert({ | 62 | newStaffId = Users.insert({ |
63 | // emails: [{address:data.email, verified: false}], | 63 | // emails: [{address:data.email, verified: false}], |
64 | //username: data["First Name*"], | 64 | //username: data["First Name*"], |
65 | firstName: data["First Name*"], | 65 | firstName: data["First Name*"], |
66 | lastName: data['Last Name*'], | 66 | lastName: data['Last Name*'], |
67 | emails: [{ address: data['Staff Email*'],verified: false }], | ||
68 | phones: [{ number: data['Staff Phone*'],verified: false }], | ||
67 | orgId: orgId, | 69 | orgId: orgId, |
68 | role: 'STAFF' | 70 | role: 'STAFF' |
69 | }); | 71 | }); |
70 | console.log("newStaffId"); | 72 | console.log("newStaffId"); |
71 | console.log(newStaffId); | 73 | console.log(newStaffId); |
72 | 74 | ||
73 | 75 | ||
74 | 76 | ||
75 | 77 | ||
76 | 78 | ||
77 | if(newStaffId){ | 79 | if(newStaffId){ |
78 | newStaff = Staffs.insert({ | 80 | newStaff = Staffs.insert({ |
79 | userId: newStaffId, | 81 | userId: newStaffId, |
80 | orgId: orgId, | 82 | orgId: orgId, |
81 | 83 | ||
82 | employeeId: data['Employee ID*'], | 84 | employeeId: data['Employee ID*'], |
83 | martialStatus: data['Marital Status(married/unmarried)*'], | 85 | martialStatus: data['Marital Status(married/unmarried)*'], |
84 | dob: data['Staff Birthday(YYYY-MM-DD)*'], | 86 | dob: data['Staff Birthday(YYYY-MM-DD)*'], |
85 | gender: data['Gender(male/female)*'], | 87 | gender: data['Gender(male/female)*'], |
86 | teaching: data['Teaching Staff(yes/no)*'], | 88 | teaching: data['Teaching Staff(yes/no)*'], |
87 | type: data['Job Type(permanent/contract)*'], | 89 | type: data['Job Type(permanent/contract)*'], |
88 | doj: data['Date of joining(YYYY-MM-DD)*'], | 90 | doj: data['Date of joining(YYYY-MM-DD)*'], |
89 | 91 | ||
90 | bloodGroup: data['Blood group*'], | 92 | bloodGroup: data['Blood group*'], |
91 | nationality: data['Nationality*'], | 93 | nationality: data['Nationality*'], |
92 | motherTongue: data['Mother Tongue*'], | 94 | motherTongue: data['Mother Tongue*'], |
93 | religion: data['Religion*'], | 95 | religion: data['Religion*'], |
94 | 96 | ||
95 | PANNumber: data['PAN Number'], | 97 | PANNumber: data['PAN Number'], |
96 | ESINumber: data['ESI Number'], | 98 | ESINumber: data['ESI Number'], |
97 | aadharNumber: data['Aadhar Number'], | 99 | aadharNumber: data['Aadhar Number'], |
98 | PFNumber: data['PF Number'], | 100 | PFNumber: data['PF Number'], |
99 | 101 | ||
100 | permanentAddress: { street: data['Staff Line Address*'], | 102 | permanentAddress: { street: data['Staff Line Address*'], |
101 | city: data['City*'], | 103 | city: data['City*'], |
102 | state: data['State*'], | 104 | state: data['State*'], |
103 | zip: data['Zip*'] | 105 | zip: data['Zip*'] |
104 | }, | 106 | }, |
105 | 107 | ||
106 | 108 | ||
107 | bankdetails: { bankAccountNo: data['Bank Account No'], | 109 | bankdetails: { bankAccountNo: data['Bank Account No'], |
108 | bankIFSC: data['Bank IFSC'], | 110 | bankIFSC: data['Bank IFSC'], |
109 | bankBranchDetails: data['Bank Branch Details'] | 111 | bankBranchDetails: data['Bank Branch Details'] |
110 | }, | 112 | }, |
111 | 113 | ||
112 | workingExperience: [{ previousJobRole: data['Previous job Role'], | 114 | workingExperience: [{ previousJobRole: data['Previous job Role'], |
113 | previousJobType: data['Previous Job Type'], | 115 | previousJobType: data['Previous Job Type'], |
114 | previousOrganization: data['Previous Organization'], | 116 | previousOrganization: data['Previous Organization'], |
115 | from: data['From'], | 117 | from: data['From'], |
116 | to: data['To'] | 118 | to: data['To'] |
117 | }], | 119 | }], |
118 | 120 | ||
119 | educationDetails: [{ qualifaication: data['Qualification*'], | 121 | educationDetails: [{ qualifaication: data['Qualification*'], |
120 | specialization: data['Specialization*'], | 122 | specialization: data['Specialization*'], |
121 | university: data['University*'], | 123 | university: data['University*'], |
122 | from: data['From*'], | 124 | from: data['From*'], |
123 | to: data['To*'] | 125 | to: data['To*'] |
124 | }] | 126 | }] |
125 | 127 | ||
126 | 128 | ||
127 | }); | 129 | }); |
128 | console.log("newStaff"); | 130 | console.log("newStaff"); |
129 | console.log(newStaff); | 131 | console.log(newStaff); |
130 | } | 132 | } |
131 | return {newStaffId}; | 133 | return {newStaffId}; |
132 | }, | 134 | }, |
133 | 135 | ||
134 | }); | 136 | }); |
135 | 137 | ||
136 | export const staffUploadCsv = new ValidatedMethod({ | 138 | export const staffUploadCsv = new ValidatedMethod({ |
137 | name: 'staff.uploadCsv', | 139 | name: 'staff.uploadCsv', |
138 | 140 | ||
139 | validate: null, | 141 | validate: null, |
140 | 142 | ||
141 | run({data}) { | 143 | run({data}) { |
142 | let validation = new Validation(); | 144 | let validation = new Validation(); |
143 | let constants = new Constants(); | 145 | let constants = new Constants(); |
144 | //console.log("++++++++++++++++++++++++"+constants.csv_students_data()); | ||
145 | temp = constants.csv_students_data(); | ||
146 | console.log(temp); | ||
147 | var CSV_valid_buffer = []; | 146 | var CSV_valid_buffer = []; |
148 | var CSV_invalid_buffer = []; | 147 | var CSV_invalid_buffer = []; |
149 | var filename = "Staff-" + new Date().getTime().toString(); | 148 | var filename = "Staff-" + new Date().getTime().toString(); |
150 | var csv_filepath = '/Users/satheeshnagaraj/Documents/Workspace/Meteor/Youngdesk/ydapp/CSV_Files/'; | 149 | var csv_filepath = '/Users/satheeshnagaraj/Documents/Workspace/Meteor/Youngdesk/ydapp/CSV_Files/'; |
151 | for (let i = 0; i < data.length; i++) | 150 | for (let i = 0; i < data.length; i++) |
152 | { | 151 | { |
153 | let item = data[i]; | 152 | let item = data[i]; |
154 | delete item['Errors']; | 153 | delete item['Errors']; |
155 | var formate_validation = 1; | 154 | var formate_validation = 1; |
156 | var is_not_null = 1; | 155 | var is_not_null = 1; |
157 | var errors = []; | 156 | var errors = []; |
158 | for (var key in item){ | 157 | for (var key in item){ |
159 | var value = item[key]; | 158 | var value = item[key]; |
160 | var n = key.indexOf("*"); | 159 | var n = key.indexOf("*"); |
161 | if(n!=-1) { | 160 | if(n!=-1) { |
162 | if(!(validation.notNull(value))) | 161 | if(!(validation.notNull(value))) |
163 | { | 162 | { |
164 | errors.push(key+"is Empty"); | 163 | errors.push(key+"is Empty"); |
165 | } | 164 | } |
166 | is_not_null = is_not_null && validation.notNull(value); | 165 | is_not_null = is_not_null && validation.notNull(value); |
167 | } | 166 | } |
168 | } | 167 | } |
169 | var formate_validation = validation.validateEmail(item["Staff Email*"]) && validation.mobileNumber(item["Staff Phone*"]) ; //&& validation.validateEmail(item["Parent Mobile"]) ); | 168 | var formate_validation = validation.validateEmail(item["Staff Email*"]) && validation.mobileNumber(item["Staff Phone*"]) ; //&& validation.validateEmail(item["Parent Mobile"]) ); |
170 | 169 | ||
171 | if (!(validation.validateEmail(item["Staff Email*"]))){ | 170 | if (!(validation.validateEmail(item["Staff Email*"]))){ |
172 | errors.push('Staff Email is invalid'); | 171 | errors.push('Staff Email is invalid'); |
173 | } | 172 | } |
174 | if (!(validation.mobileNumber(item["Staff Phone*"]))) | 173 | if (!(validation.mobileNumber(item["Staff Phone*"]))) |
175 | { | 174 | { |
176 | errors.push('Staffs Mobile is invalid'); | 175 | errors.push('Staffs Mobile is invalid'); |
177 | } | 176 | } |
178 | 177 | ||
179 | var is_valid = formate_validation && is_not_null ; | 178 | var is_valid = formate_validation && is_not_null ; |
179 | |||
180 | |||
181 | |||
180 | if (is_valid) | 182 | if (is_valid) |
181 | { | 183 | { |
182 | CSV_valid_buffer.push(item); | 184 | exists = Users.findOne({"firstName": item["First Name*"],"lastName": item["Last Name*"],'emails.$.address' : item['Staff Email*'],'phones.$.number' : item['Staff Phone*']}, {"_id": 1}); |
183 | console.log("----------------------------------------1"); | ||
184 | 185 | ||
185 | Meteor.call('staff.addCSV',item); | 186 | if (!exists) |
186 | console.log("----------------------------------------2"); | 187 | { |
187 | 188 | CSV_valid_buffer.push(item); | |
189 | Meteor.call('staff.addCSV',item); | ||
190 | console.warn('done'); | ||
191 | } | ||
192 | else | ||
193 | { | ||
194 | console.warn('This data already exists.'); | ||
195 | errors.push('This data already exists'); | ||
196 | var str = errors.toString(); | ||
197 | item.Errors = str; | ||
198 | CSV_invalid_buffer.push(item); | ||
199 | } | ||
200 | |||
188 | } | 201 | } |
189 | else | 202 | |
190 | { | ||
191 | var str = errors.toString(); | ||
192 | item.Errors = str; | ||
193 | CSV_invalid_buffer.push(item); | ||
194 | } | ||
195 | } | 203 | } |
204 |
imports/collections/students/serverCsvUpload.js
1 | // import { } from '/imports/collections/orgs/methods'; | 1 | // import { } from '/imports/collections/orgs/methods'; |
2 | import _ from 'lodash'; | 2 | import _ from 'lodash'; |
3 | import { Meteor } from 'meteor/meteor'; | 3 | import { Meteor } from 'meteor/meteor'; |
4 | import Papa from 'meteor/harrison:papa-parse' | 4 | import Papa from 'meteor/harrison:papa-parse' |
5 | import csv from 'csv2json-convertor' | 5 | import csv from 'csv2json-convertor' |
6 | import { ValidatedMethod } from 'meteor/mdg:validated-method'; | 6 | import { ValidatedMethod } from 'meteor/mdg:validated-method'; |
7 | import { SimpleSchema } from 'meteor/aldeed:simple-schema'; | 7 | import { SimpleSchema } from 'meteor/aldeed:simple-schema'; |
8 | import { DDPRateLimiter } from 'meteor/ddp-rate-limiter'; | 8 | import { DDPRateLimiter } from 'meteor/ddp-rate-limiter'; |
9 | import { Bert } from 'meteor/themeteorchef:bert'; | 9 | import { Bert } from 'meteor/themeteorchef:bert'; |
10 | import { Users } from '/imports/collections/users/index'; | 10 | import { Users } from '/imports/collections/users/index'; |
11 | import { Orgs } from '/imports/collections/orgs/index'; | 11 | import { Orgs } from '/imports/collections/orgs/index'; |
12 | import { Students } from '/imports/collections/students/index' | 12 | import { Students } from '/imports/collections/students/index' |
13 | import { Parents } from '/imports/collections/parents/index'; | 13 | import { Parents } from '/imports/collections/parents/index'; |
14 | import csv1 from 'csv2json-convertor' | 14 | import csv1 from 'csv2json-convertor' |
15 | import json2csv from 'json2csv' | 15 | import json2csv from 'json2csv' |
16 | import fs from 'fs' | 16 | import fs from 'fs' |
17 | import Validation from '/imports/validation/validationMethods'; | 17 | import Validation from '/imports/validation/validationMethods'; |
18 | import Constants from '/imports/constants/constants' | 18 | import Constants from '/imports/constants/constants' |
19 | 19 | ||
20 | export const studenCsvtMethod = new ValidatedMethod({ | 20 | export const studenCsvtMethod = new ValidatedMethod({ |
21 | name: 'student.csvMethod', | 21 | name: 'student.csvMethod', |
22 | 22 | ||
23 | validate: new SimpleSchema({ | 23 | validate: new SimpleSchema({ |
24 | itemId: { type: String }, | 24 | itemId: { type: String }, |
25 | }).validator(), | 25 | }).validator(), |
26 | 26 | ||
27 | run({itemId}) { | 27 | run({itemId}) { |
28 | return {}; | 28 | return {}; |
29 | }, | 29 | }, |
30 | 30 | ||
31 | }); | 31 | }); |
32 | 32 | ||
33 | export const save_csv_data = new ValidatedMethod({ | 33 | export const save_csv_data = new ValidatedMethod({ |
34 | name: 'save_csv_data', | 34 | name: 'save_csv_data', |
35 | 35 | ||
36 | validate: null, | 36 | validate: null, |
37 | 37 | ||
38 | run({item,filename,csv_fiels}) { | 38 | run({item,filename,csv_fiels}) { |
39 | 39 | ||
40 | if ((item.length)) | 40 | if ((item.length)) |
41 | { console.log("++++++++++++++++++"+item.length) | 41 | { console.log("++++++++++++++++++"+item.length) |
42 | var csv = json2csv({ | 42 | var csv = json2csv({ |
43 | data: item, | 43 | data: item, |
44 | fields: csv_fiels | 44 | fields: csv_fiels |
45 | }); | 45 | }); |
46 | fs.writeFile(filename, csv,function(err) { | 46 | fs.writeFile(filename, csv,function(err) { |
47 | if (err) throw err; | 47 | if (err) throw err; |
48 | }); | 48 | }); |
49 | 49 | ||
50 | } | 50 | } |
51 | }, | 51 | }, |
52 | }); | 52 | }); |
53 | 53 | ||
54 | export const addStudentCSV= new ValidatedMethod({ | 54 | export const addStudentCSV= new ValidatedMethod({ |
55 | name: 'student.addCSV', | 55 | name: 'student.addCSV', |
56 | 56 | ||
57 | validate: null, | 57 | validate: null, |
58 | 58 | ||
59 | run(item){ | 59 | run(item){ |
60 | data = item ; | 60 | data = item ; |
61 | console.log("data"); | ||
62 | console.log(data); | ||
63 | // return true; | ||
64 | const user = Users.findOne({_id: this.userId}); | 61 | const user = Users.findOne({_id: this.userId}); |
65 | orgId = user.orgId; | 62 | orgId = user.orgId; |
66 | newStudentId = Users.insert({ | 63 | newStudentId = Users.insert({ |
67 | // emails: [{address:data.email, verified: false}], | 64 | // emails: [{address:data.email, verified: false}], |
68 | //username: data["First Name*"], | 65 | //username: data["First Name*"], |
69 | firstName: data["First Name*"], | 66 | firstName: data["First Name*"], |
70 | lastName: data['Last Name*'], | 67 | lastName: data['Last Name*'], |
71 | orgId: orgId, | 68 | orgId: orgId, |
72 | role: 'STUDENT' | 69 | role: 'STUDENT' |
73 | }); | 70 | }); |
74 | newParentUserId = Users.insert({ | 71 | newParentUserId = Users.insert({ |
75 | //emails: [{address:data.parentEmail, verified: false}], | 72 | //emails: [{address:data.parentEmail, verified: false}], |
76 | //3: data['Parent Name*'], | 73 | //3: data['Parent Name*'], |
77 | firstName: data['Parent Name*'], | ||
78 | orgId: orgId, | 74 | orgId: orgId, |
75 | firstName: data['Parent Name*'], | ||
76 | emails: [{ address: data['Parent Email*'],verified: false }], | ||
77 | phones: [{ number: data['Parent Mobile*'],verified: false }], | ||
79 | role: 'PARENT' | 78 | role: 'PARENT' |
79 | |||
80 | }); | 80 | }); |
81 | if(newParentUserId){ | 81 | if(newParentUserId){ |
82 | newParentId = Parents.insert({ | 82 | newParentId = Parents.insert({ |
83 | userId: newParentUserId, | 83 | userId: newParentUserId, |
84 | orgId: orgId, | 84 | orgId: orgId, |
85 | profession: data['Parent Profession'] | 85 | profession: data['Parent Profession'] |
86 | 86 | ||
87 | }); | 87 | }); |
88 | console.log("newParentUserId"); | 88 | console.log("newParentUserId"); |
89 | console.log(newParentUserId); | 89 | console.log(newParentUserId); |
90 | } | 90 | } |
91 | console.log("newUserId"); | 91 | console.log("newUserId"); |
92 | console.log(newStudentId); | 92 | console.log(newStudentId); |
93 | if(newStudentId){ | 93 | if(newStudentId){ |
94 | Students.insert({ | 94 | Students.insert({ |
95 | userId: newStudentId, | 95 | userId: newStudentId, |
96 | orgId: orgId, | 96 | orgId: orgId, |
97 | admissionId: data['Student Admission ID*'], | 97 | admissionId: data['Student Admission ID*'], |
98 | enrollmentDate: data['Enrollment Date(YYYY-MM-DD)*'], | 98 | enrollmentDate: data['Enrollment Date(YYYY-MM-DD)*'], |
99 | gender: data['Gender(male/female)*'], | 99 | gender: data['Gender(male/female)*'], |
100 | dob: data['Birthday(YYYY-MM-DD)*'], | 100 | dob: data['Birthday(YYYY-MM-DD)*'], |
101 | bloodGroup: data['Blood Group*'], | 101 | bloodGroup: data['Blood Group*'], |
102 | nationality: data['Nationality*'], | 102 | nationality: data['Nationality*'], |
103 | motherTongue: data['Mother Tongue*'], | 103 | motherTongue: data['Mother Tongue*'], |
104 | religion: data['Religion*'], | 104 | religion: data['Religion*'], |
105 | community: data['Community'], | 105 | community: data['Community'], |
106 | 106 | ||
107 | rollNo: data['Student Roll*'], | 107 | rollNo: data['Student Roll*'], |
108 | class: data['Student Class Name*'], | 108 | class: data['Student Class Name*'], |
109 | section: data['Student Section Name*'], | 109 | section: data['Student Section Name*'], |
110 | 110 | ||
111 | prevInstitute: [{ name: data['Previous Institution Name'], | 111 | prevInstitute: [{ name: data['Previous Institution Name'], |
112 | fromYear: data['Class-From'], | 112 | fromYear: data['Class-From'], |
113 | toYear: data['Class-To'], | 113 | toYear: data['Class-To'], |
114 | fromClass: data['From-Year'], | 114 | fromClass: data['From-Year'], |
115 | toClass: data['To-Year'] | 115 | toClass: data['To-Year'] |
116 | }], | 116 | }], |
117 | permanentAddress: { street: data['Student Line Adress*'], | 117 | permanentAddress: { street: data['Student Line Adress*'], |
118 | city: data['Student City*'], | 118 | city: data['Student City*'], |
119 | state: data['Student State*'], | 119 | state: data['Student State*'], |
120 | zip: data['Student Zip Code*'] | 120 | zip: data['Student Zip Code*'] |
121 | }, | 121 | }, |
122 | parent: [{id: newParentUserId, relatinship: data['Parent Relation*']}] | 122 | parent: [{id: newParentUserId, relatinship: data['Parent Relation*']}] |
123 | }); | 123 | }); |
124 | } | 124 | } |
125 | return {newStudentId}; | 125 | return {newStudentId}; |
126 | }, | 126 | }, |
127 | 127 | ||
128 | }); | 128 | }); |
129 | 129 | ||
130 | export const studentUploadCsv = new ValidatedMethod({ | 130 | export const studentUploadCsv = new ValidatedMethod({ |
131 | name: 'student.uploadCsv', | 131 | name: 'student.uploadCsv', |
132 | 132 | ||
133 | validate: null, | 133 | validate: null, |
134 | 134 | ||
135 | run({data}) { | 135 | run({data}) { |
136 | let validation = new Validation(); | 136 | let validation = new Validation(); |
137 | let constants = new Constants(); | 137 | let constants = new Constants(); |
138 | //console.log("++++++++++++++++++++++++"+constants.csv_students_data()); | 138 | |
139 | temp = constants.csv_students_data(); | ||
140 | // | ||
141 | console.log(temp); | ||
142 | // var data_1=csv1.csvtojson(("/Users/satheeshnagaraj/Downloads/11.csv")); //csvtojson is function that accepts csv filenames and returns JSON object | 139 | // var data_1=csv1.csvtojson(("/Users/satheeshnagaraj/Downloads/11.csv")); //csvtojson is function that accepts csv filenames and returns JSON object |
143 | //console.log(data);'' | 140 | //console.log(data);'' |
144 | // Stores = new Mongo.Collection('stores'); | 141 | // Stores = new Mongo.Collection('stores'); |
145 | // data = data_1; | 142 | // data = data_1; |
146 | 143 | ||
147 | var CSV_valid_buffer = []; | 144 | var CSV_valid_buffer = []; |
148 | var CSV_invalid_buffer = []; | 145 | var CSV_invalid_buffer = []; |
149 | var filename = "Student" + new Date().getTime().toString(); | 146 | var filename = "Student" + new Date().getTime().toString(); |
150 | var csv_filepath = '/Users/deepak/dev/yd/csv'; | 147 | var csv_filepath ='/Users/satheeshnagaraj/Documents/Workspace/Meteor/production/ydapp/CSV_Files/'; |
148 | //var csv_filepath = '/Users/deepak/dev/yd/csv'; | ||
151 | 149 | ||
152 | 150 | ||
153 | 151 | ||
154 | for (let i = 0; i < data.length; i++) | 152 | for (let i = 0; i < data.length; i++) |
155 | { | 153 | { |
156 | 154 | ||
157 | //let item= {Errors:""}; | 155 | //let item= {Errors:""}; |
158 | let item = data[i]; | 156 | let item = data[i]; |
159 | delete item['Errors']; | 157 | delete item['Errors']; |
160 | var formate_validation = 1; | 158 | var formate_validation = 1; |
161 | var is_not_null = 1; | 159 | var is_not_null = 1; |
162 | var errors = []; | 160 | var errors = []; |
163 | for (var key in item) | 161 | for (var key in item) |
164 | { | 162 | { |
165 | var value = item[key]; | 163 | var value = item[key]; |
166 | var n = key.indexOf("*"); | 164 | var n = key.indexOf("*"); |
167 | if(n!=-1) { | 165 | if(n!=-1) { |
168 | if(!(validation.notNull(value))) | 166 | if(!(validation.notNull(value))) |
169 | { | 167 | { |
170 | errors.push(key+"is Empty"); | 168 | errors.push(key+"is Empty"); |
171 | } | 169 | } |
172 | is_not_null = is_not_null && validation.notNull(value); | 170 | is_not_null = is_not_null && validation.notNull(value); |
173 | } | 171 | } |
174 | } | 172 | } |
175 | //console.log(validation.mobileNumber(item["Parent Mobile*"])); | 173 | //console.log(validation.mobileNumber(item["Parent Mobile*"])); |
176 | 174 | ||
177 | 175 | ||
178 | 176 | ||
179 | 177 | ||
180 | var formate_validation = validation.validateEmail(item["Parent Email*"]) && validation.mobileNumber(item["Parent Mobile*"]) ; //&& validation.validateEmail(item["Parent Mobile"]) ); | 178 | var formate_validation = validation.validateEmail(item["Parent Email*"]) && validation.mobileNumber(item["Parent Mobile*"]) ; //&& validation.validateEmail(item["Parent Mobile"]) ); |
181 | 179 | ||
182 | if (!(validation.validateEmail(item["Parent Email*"]))) | 180 | if (!(validation.validateEmail(item["Parent Email*"]))) |
183 | { | 181 | { |
184 | errors.push('Parent Email is invalid'); | 182 | errors.push('Parent Email is invalid'); |
185 | } | 183 | } |
186 | if (!(validation.mobileNumber(item["Parent Mobile*"]))) | 184 | if (!(validation.mobileNumber(item["Parent Mobile*"]))) |
187 | { | 185 | { |
188 | errors.push('Parent Mobile is invalid'); | 186 | errors.push('Parent Mobile is invalid'); |
189 | } | 187 | } |
190 | 188 | ||
191 | var is_valid = formate_validation && is_not_null ; | 189 | var is_valid = formate_validation && is_not_null ; |
192 | 190 | ||
193 | // console.log(formate_validation); | 191 | // console.log(formate_validation); |
194 | if (is_valid) | 192 | if (is_valid) |
195 | { | 193 | { |
196 | CSV_valid_buffer.push(item); | 194 | |
197 | console.log("----------------------------------------1"); | 195 | exists = Users.findOne({"firstName": item["First Name*"],"lastName": item["Last Name*"]}, {"_id": 1}); |
198 | console.log("----------------------------------------item"); | 196 | |
199 | console.log(item); | 197 | if (!exists) |
200 | console.log (Users.findOne({"firstName": item["First Name*"],"lastName": item["Last Name*"]})); | 198 | { |
201 | 199 | CSV_valid_buffer.push(item); | |
202 | Meteor.call('student.addCSV',item); | 200 | Meteor.call('student.addCSV',item); |
203 | console.log("----------------------------------------2"); | 201 | console.warn('done'); |
204 | 202 | } | |
205 | // exists = Stores.findOne({ | 203 | else |
206 | // "Student 'Admission' ID*": item["Student Admission ID*"] | 204 | { |
207 | // }); | 205 | console.log(exists._id); |
208 | // if (!exists) | 206 | student_data = Students.findOne({"userId":exists._id}); |
209 | // { | 207 | console.log("--------------"+student_data); |
210 | // Stores.insert(item); | 208 | |
211 | // } | 209 | parent_data = Users.findOne({"_id":student_data.parent[0].id}); |
212 | // else | 210 | |
213 | // { | 211 | console.log(parent_data.emails[0].address); |
214 | // console.warn('Rejected. This item already exists.'); | 212 | if ( parent_data.emails[0].address != item["Parent Email*"]) |
215 | // } | 213 | { |
216 | } | 214 | CSV_valid_buffer.push(item); |
217 | else | 215 | Meteor.call('student.addCSV',item); |
218 | { | 216 | console.warn('done'); |
219 | var str = errors.toString(); | 217 | } |
220 | item.Errors = str; | 218 | else |
221 | CSV_invalid_buffer.push(item); | 219 | { |
222 | //console.log(str); | 220 | console.warn('This data already exists.'); |
223 | // console.log(CSV_invalid_buffer); | 221 | errors.push('This data already exists'); |
224 | } | 222 | var str = errors.toString(); |
223 | item.Errors = str; | ||
224 | CSV_invalid_buffer.push(item); | ||
225 | } | ||
226 | } | ||
227 | } | ||
225 | } | 228 | } |
imports/server/collections.js
1 | import '/imports/collections/orgs/publications' | 1 | import '/imports/collections/orgs/publications' |
2 | import '/imports/collections/orgs/methods'; | 2 | import '/imports/collections/orgs/methods'; |
3 | 3 | ||
4 | import '/imports/collections/users/publications'; | 4 | import '/imports/collections/users/publications'; |
5 | 5 | ||
6 | import '/imports/collections/students/methods'; | 6 | import '/imports/collections/students/methods'; |
7 | import '/imports/collections/students/publications'; | 7 | import '/imports/collections/students/publications'; |
8 | import '/imports/collections/students/serverCsvUpload'; | 8 | import '/imports/collections/students/serverCsvUpload'; |
9 | 9 | ||
10 | import '/imports/collections/staff/methods'; | 10 | import '/imports/collections/staff/methods'; |
11 | import '/imports/collections/staff/publications'; | 11 | import '/imports/collections/staff/publications'; |
12 | import '/imports/collections/staff/serverCsvUpload'; | 12 | import '/imports/collections/staff/serverCsvUpload'; |
13 | |||
14 | import '/imports/collections/parents/methods'; | ||
15 | import '/imports/collections/parents/publications'; | ||
13 | 16 |