Commit 39d8f536dc5551e3902d03d21d74903cfa54243b
1 parent
b48d5cb1c8
Exists in
master
some more cleamup
Showing
27 changed files
with
474 additions
and
185 deletions
Show diff stats
imports/client/components/validationMethods.js
imports/client/layouts/OrgApp.js
1 | 1 | import React from 'react'; |
2 | 2 | import { Grid } from 'react-bootstrap'; |
3 | -import AppNavigation from '/imports/client/views/org/module/navigation/AppNavigation'; | |
3 | +import AppNavigation from '/imports/client/views/org/app/module/navigation/AppNavigation'; | |
4 | 4 | |
5 | 5 | const App = ({ children }) => ( |
6 | 6 | <div> | ... | ... |
imports/client/views/nonOrg/enter/SignupView.js
... | ... | @@ -27,7 +27,6 @@ export default class Signup extends React.Component { |
27 | 27 | event.preventDefault(); |
28 | 28 | } |
29 | 29 | checkExistingOrgSlug() { |
30 | - console.log(this.state.orgSlug); | |
31 | 30 | if(this.state.orgSlug==""){return null} |
32 | 31 | searchOrg = Orgs.find({slug:this.state.orgSlug}).fetch(); |
33 | 32 | if(searchOrg.length>0){ |
... | ... | @@ -55,7 +54,7 @@ export default class Signup extends React.Component { |
55 | 54 | type ="text" |
56 | 55 | ref ="orgSlug" |
57 | 56 | name ="orgSlug" |
58 | - placeholder ="School Name" | |
57 | + placeholder ="School URL" | |
59 | 58 | onChange = {(e) => this.handleChange(e)} |
60 | 59 | /> |
61 | 60 | <InputGroup.Addon>@yd.com</InputGroup.Addon> |
... | ... | @@ -63,6 +62,19 @@ export default class Signup extends React.Component { |
63 | 62 | </FormGroup> |
64 | 63 | </Col> |
65 | 64 | </Row> |
65 | + <Row> | |
66 | + <Col xs={ 6 } sm={ 6 }> | |
67 | + <FormGroup> | |
68 | + <ControlLabel>First Name</ControlLabel> | |
69 | + <FormControl | |
70 | + type="text" | |
71 | + ref="orgName" | |
72 | + name="orgName" | |
73 | + placeholder="School Name" | |
74 | + /> | |
75 | + </FormGroup> | |
76 | + </Col> | |
77 | + </Row> | |
66 | 78 | <Row> |
67 | 79 | <Col xs={ 6 } sm={ 6 }> |
68 | 80 | <FormGroup> | ... | ... |
imports/client/views/nonOrg/enter/signup.js
... | ... | @@ -12,6 +12,8 @@ let component; |
12 | 12 | const getUserData = () => ({ |
13 | 13 | email: document.querySelector('[name="emailAddress"]').value, |
14 | 14 | password: document.querySelector('[name="password"]').value, |
15 | + orgSlug: document.querySelector('[name="orgSlug"]').value, | |
16 | + orgName: document.querySelector('[name="orgName"]').value, | |
15 | 17 | profile: { |
16 | 18 | name: { |
17 | 19 | first: document.querySelector('[name="firstName"]').value, |
... | ... | @@ -36,7 +38,6 @@ $.validator.addMethod( |
36 | 38 | "uniqueSlug", |
37 | 39 | function(value, element) { |
38 | 40 | slug = Orgs.find({slug:value}).fetch(); |
39 | - console.log(slug); | |
40 | 41 | if(slug.length>0){ |
41 | 42 | return false; |
42 | 43 | }else{ | ... | ... |
imports/client/views/org/app/module/AppLayout.js
... | ... | @@ -0,0 +1,44 @@ |
1 | +import _ from 'lodash'; | |
2 | +import { Meteor } from 'meteor/meteor'; | |
3 | +import React, { Component } from 'react'; | |
4 | +import { Link } from 'react-router'; | |
5 | +import { Avatar } from '/imports/client/components/Avatar'; | |
6 | +import { Icon } from '/imports/client/components/Icon'; | |
7 | +import classNames from 'classnames'; | |
8 | + | |
9 | + | |
10 | +export class AppLayout extends Component { | |
11 | + | |
12 | + | |
13 | + | |
14 | + | |
15 | + | |
16 | + | |
17 | + render() { | |
18 | + const {user} = this.props.data; | |
19 | + | |
20 | + if(!user) { | |
21 | + return ( | |
22 | + <div className="NotLoggedIn"></div> | |
23 | + ); | |
24 | + } | |
25 | + return ( | |
26 | + <div className = "appLayout-box"> | |
27 | + | |
28 | + <div className = "appLayout-wrapOuter"> | |
29 | + <div className = "appLayout-wrapInner"> | |
30 | + <div className = "appLayout-menuWrap"> | |
31 | + | |
32 | + </div> | |
33 | + <div className = "appLayout-contentWrap"> | |
34 | + <div className = "appLayout-content"> | |
35 | + { this.props.children } | |
36 | + </div> | |
37 | + </div> | |
38 | + </div> | |
39 | + </div> | |
40 | + </div> | |
41 | + ); | |
42 | + }; | |
43 | + | |
44 | +}; | ... | ... |
imports/client/views/org/app/module/Index.js
... | ... | @@ -0,0 +1,46 @@ |
1 | +// import { AppModule } from '/imports/client/views/app/module/index' | |
2 | +import { | |
3 | + composeWithTracker, | |
4 | + compose, | |
5 | + composeAll | |
6 | + } from 'react-komposer'; | |
7 | +import { AppLayout } from './AppLayout'; | |
8 | +import { Loading } from '/imports/client/components/Loading'; | |
9 | + | |
10 | +import { Users } from '/imports/collections/users/index'; | |
11 | +import { Orgs } from '/imports/collections/orgs/index'; | |
12 | + | |
13 | + | |
14 | +const meteorTick = (props, onData) => { | |
15 | + | |
16 | + const handles = [ | |
17 | + Meteor.subscribe('users.current'), | |
18 | + ]; | |
19 | + | |
20 | + if(_.every(handles, (handle) => (handle.ready()) )) { | |
21 | + const user = Users.current(); | |
22 | + onData(null, { | |
23 | + data: { | |
24 | + user: user, | |
25 | + }, | |
26 | + }); | |
27 | + } | |
28 | + | |
29 | + return () => { | |
30 | + _.each(handles, (handle) => handle.stop() ); | |
31 | + }; | |
32 | +}; | |
33 | + | |
34 | + | |
35 | +const reduxTick = (props, onData) => { | |
36 | + onData(null, { | |
37 | + location: props.location, | |
38 | + data: {} | |
39 | + }); | |
40 | +}; | |
41 | + | |
42 | + | |
43 | +export const AppModule = composeAll( | |
44 | + composeWithTracker(meteorTick, Loading), | |
45 | + compose(reduxTick, Loading), | |
46 | +)(AppLayout); | ... | ... |
imports/client/views/org/app/module/navigation/AppNavigation.js
... | ... | @@ -0,0 +1,30 @@ |
1 | +import React from 'react'; | |
2 | +import { Navbar } from 'react-bootstrap'; | |
3 | +import { Link } from 'react-router'; | |
4 | +import PublicNavigation from './PublicNavigation.js'; | |
5 | +import AuthenticatedNavigation from './AuthenticatedNavigation.js'; | |
6 | +import '/imports/client/assets/css/icons/icomoon/styles.css'; | |
7 | +import '/imports/client/assets/css/bootstrap.css'; | |
8 | +import '/imports/client/assets/css/core.css'; | |
9 | +import '/imports/client/assets/css/components.css'; | |
10 | +import '/imports/client/assets/css/colors.css'; | |
11 | +const renderNavigation = hasUser => (hasUser ? <AuthenticatedNavigation /> : <PublicNavigation />); | |
12 | +const AppNavigation = ({ hasUser }) => ( | |
13 | + <Navbar className="navbar-inverse bg-crimson"> | |
14 | + <Navbar.Header> | |
15 | + <Navbar.Brand> | |
16 | + <Link to="/">Home</Link> | |
17 | + </Navbar.Brand> | |
18 | + <Navbar.Toggle /> | |
19 | + </Navbar.Header> | |
20 | + <Navbar.Collapse> | |
21 | + { renderNavigation(hasUser) } | |
22 | + </Navbar.Collapse> | |
23 | + </Navbar> | |
24 | +); | |
25 | + | |
26 | +AppNavigation.propTypes = { | |
27 | + hasUser: React.PropTypes.object, | |
28 | +}; | |
29 | + | |
30 | +export default AppNavigation; | ... | ... |
imports/client/views/org/app/module/navigation/AuthenticatedNavigation.js
... | ... | @@ -0,0 +1,30 @@ |
1 | +import React from 'react'; | |
2 | +import { browserHistory } from 'react-router'; | |
3 | +import { LinkContainer } from 'react-router-bootstrap'; | |
4 | +import { Nav, NavItem, NavDropdown, MenuItem } from 'react-bootstrap'; | |
5 | +import { Meteor } from 'meteor/meteor'; | |
6 | + | |
7 | +const handleLogout = () => Meteor.logout(() => browserHistory.push('/login')); | |
8 | + | |
9 | +const userName = () => { | |
10 | + const user = Meteor.user(); | |
11 | + const name = user && user.profile ? user.profile.name : ''; | |
12 | + return user ? `${name.first} ${name.last}` : ''; | |
13 | +}; | |
14 | + | |
15 | +const AuthenticatedNavigation = () => ( | |
16 | + <div> | |
17 | + <Nav> | |
18 | + <LinkContainer to="/documents"> | |
19 | + <NavItem eventKey={ 2 } href="/documents">Documents</NavItem> | |
20 | + </LinkContainer> | |
21 | + </Nav> | |
22 | + <Nav pullRight> | |
23 | + <NavDropdown eventKey={ 3 } title={ userName() } id="basic-nav-dropdown"> | |
24 | + <MenuItem eventKey={ 3.1 } onClick={ handleLogout }>Logout</MenuItem> | |
25 | + </NavDropdown> | |
26 | + </Nav> | |
27 | + </div> | |
28 | +); | |
29 | + | |
30 | +export default AuthenticatedNavigation; | ... | ... |
imports/client/views/org/app/module/navigation/Loading.js
... | ... | @@ -0,0 +1,30 @@ |
1 | +import React from 'react'; | |
2 | + | |
3 | +const Loading = () => ( | |
4 | + <svg | |
5 | + version="1.1" | |
6 | + className="Loading" | |
7 | + xmlns="http://www.w3.org/2000/svg" | |
8 | + x="0px" | |
9 | + y="0px" | |
10 | + width="40px" | |
11 | + height="40px" | |
12 | + viewBox="0 0 40 40" | |
13 | + enableBackground="new 0 0 40 40"> | |
14 | + <path | |
15 | + opacity="1.0" | |
16 | + fill="#eee" | |
17 | + d="M20.201,5.169c-8.254,0-14.946,6.692-14.946,14.946c0,8.255,6.692,14.946, | |
18 | + 14.946,14.946s14.946-6.691,14.946-14.946C35.146,11.861,28.455,5.169,20.201, | |
19 | + 5.169z M20.201,31.749c-6.425,0-11.634-5.208-11.634-11.634c0-6.425, | |
20 | + 5.209-11.634,11.634-11.634c6.425,0,11.633,5.209,11.633,11.634C31.834, | |
21 | + 26.541,26.626,31.749,20.201,31.749z"/> | |
22 | + <path | |
23 | + fill="#da5347" | |
24 | + d="M26.013,10.047l1.654-2.866c-2.198-1.272-4.743-2.012-7.466-2.012h0v3.312h0 | |
25 | + C22.32,8.481,24.301,9.057,26.013,10.047z"> | |
26 | + </path> | |
27 | + </svg> | |
28 | +); | |
29 | + | |
30 | +export default Loading; | ... | ... |
imports/client/views/org/app/module/navigation/PublicNavigation.js
... | ... | @@ -0,0 +1,16 @@ |
1 | +import React from 'react'; | |
2 | +import { LinkContainer } from 'react-router-bootstrap'; | |
3 | +import { Nav, NavItem } from 'react-bootstrap'; | |
4 | + | |
5 | +const PublicNavigation = () => ( | |
6 | + <Nav pullRight> | |
7 | + <LinkContainer to="signup"> | |
8 | + <NavItem eventKey={ 1 } href="/signup">Sign Up</NavItem> | |
9 | + </LinkContainer> | |
10 | + <LinkContainer to="login"> | |
11 | + <NavItem eventKey={ 2 } href="/login">Log In</NavItem> | |
12 | + </LinkContainer> | |
13 | + </Nav> | |
14 | +); | |
15 | + | |
16 | +export default PublicNavigation; | ... | ... |
imports/client/views/org/app/module/navigation/index.js
... | ... | @@ -0,0 +1,7 @@ |
1 | +import { composeWithTracker } from 'react-komposer'; | |
2 | +import { Meteor } from 'meteor/meteor'; | |
3 | +import AppNavigation from '../components/AppNavigation.js'; | |
4 | + | |
5 | +const composer = (props, onData) => onData(null, { hasUser: Meteor.user() }); | |
6 | + | |
7 | +export default composeWithTracker(composer, {}, {}, { pure: false })(AppNavigation); | ... | ... |
imports/client/views/org/enter/login/LoginView.js
imports/client/views/org/module/Index.js
... | ... | @@ -1,15 +0,0 @@ |
1 | -import React from 'react'; | |
2 | -import { Jumbotron } from 'react-bootstrap'; | |
3 | - | |
4 | -const Index = () => ( | |
5 | - <div className="Index"> | |
6 | - <Jumbotron className="text-center"> | |
7 | - <h2>Base</h2> | |
8 | - <p>A starting point for Meteor applications.</p> | |
9 | - <p><a className="btn btn-success" href="https://themeteorchef.com/base" role="button">Read the Documentation</a></p> | |
10 | - <p style={ { fontSize: '16px', color: '#aaa' } }>Currently at v4.11.1</p> | |
11 | - </Jumbotron> | |
12 | - </div> | |
13 | -); | |
14 | - | |
15 | -export default Index; |
imports/client/views/org/module/navigation/AppNavigation.js
... | ... | @@ -1,31 +0,0 @@ |
1 | -import React from 'react'; | |
2 | -import { Navbar } from 'react-bootstrap'; | |
3 | -import { Link } from 'react-router'; | |
4 | -import PublicNavigation from './PublicNavigation.js'; | |
5 | -import AuthenticatedNavigation from './AuthenticatedNavigation.js'; | |
6 | -import '/imports/client/assets/css/icons/icomoon/styles.css'; | |
7 | -import '/imports/client/assets/css/bootstrap.css'; | |
8 | -import '/imports/client/assets/css/core.css'; | |
9 | -import '/imports/client/assets/css/components.css'; | |
10 | -import '/imports/client/assets/css/colors.css'; | |
11 | -const renderNavigation = hasUser => (hasUser ? <AuthenticatedNavigation /> : <PublicNavigation />); | |
12 | -console.log(React.PropTypes); | |
13 | -const AppNavigation = ({ hasUser }) => ( | |
14 | - <Navbar className="navbar-inverse bg-crimson"> | |
15 | - <Navbar.Header> | |
16 | - <Navbar.Brand> | |
17 | - <Link to="/">Home</Link> | |
18 | - </Navbar.Brand> | |
19 | - <Navbar.Toggle /> | |
20 | - </Navbar.Header> | |
21 | - <Navbar.Collapse> | |
22 | - { renderNavigation(hasUser) } | |
23 | - </Navbar.Collapse> | |
24 | - </Navbar> | |
25 | -); | |
26 | - | |
27 | -AppNavigation.propTypes = { | |
28 | - hasUser: React.PropTypes.object, | |
29 | -}; | |
30 | - | |
31 | -export default AppNavigation; |
imports/client/views/org/module/navigation/AuthenticatedNavigation.js
... | ... | @@ -1,30 +0,0 @@ |
1 | -import React from 'react'; | |
2 | -import { browserHistory } from 'react-router'; | |
3 | -import { LinkContainer } from 'react-router-bootstrap'; | |
4 | -import { Nav, NavItem, NavDropdown, MenuItem } from 'react-bootstrap'; | |
5 | -import { Meteor } from 'meteor/meteor'; | |
6 | - | |
7 | -const handleLogout = () => Meteor.logout(() => browserHistory.push('/login')); | |
8 | - | |
9 | -const userName = () => { | |
10 | - const user = Meteor.user(); | |
11 | - const name = user && user.profile ? user.profile.name : ''; | |
12 | - return user ? `${name.first} ${name.last}` : ''; | |
13 | -}; | |
14 | - | |
15 | -const AuthenticatedNavigation = () => ( | |
16 | - <div> | |
17 | - <Nav> | |
18 | - <LinkContainer to="/documents"> | |
19 | - <NavItem eventKey={ 2 } href="/documents">Documents</NavItem> | |
20 | - </LinkContainer> | |
21 | - </Nav> | |
22 | - <Nav pullRight> | |
23 | - <NavDropdown eventKey={ 3 } title={ userName() } id="basic-nav-dropdown"> | |
24 | - <MenuItem eventKey={ 3.1 } onClick={ handleLogout }>Logout</MenuItem> | |
25 | - </NavDropdown> | |
26 | - </Nav> | |
27 | - </div> | |
28 | -); | |
29 | - | |
30 | -export default AuthenticatedNavigation; |
imports/client/views/org/module/navigation/Loading.js
... | ... | @@ -1,30 +0,0 @@ |
1 | -import React from 'react'; | |
2 | - | |
3 | -const Loading = () => ( | |
4 | - <svg | |
5 | - version="1.1" | |
6 | - className="Loading" | |
7 | - xmlns="http://www.w3.org/2000/svg" | |
8 | - x="0px" | |
9 | - y="0px" | |
10 | - width="40px" | |
11 | - height="40px" | |
12 | - viewBox="0 0 40 40" | |
13 | - enableBackground="new 0 0 40 40"> | |
14 | - <path | |
15 | - opacity="1.0" | |
16 | - fill="#eee" | |
17 | - d="M20.201,5.169c-8.254,0-14.946,6.692-14.946,14.946c0,8.255,6.692,14.946, | |
18 | - 14.946,14.946s14.946-6.691,14.946-14.946C35.146,11.861,28.455,5.169,20.201, | |
19 | - 5.169z M20.201,31.749c-6.425,0-11.634-5.208-11.634-11.634c0-6.425, | |
20 | - 5.209-11.634,11.634-11.634c6.425,0,11.633,5.209,11.633,11.634C31.834, | |
21 | - 26.541,26.626,31.749,20.201,31.749z"/> | |
22 | - <path | |
23 | - fill="#da5347" | |
24 | - d="M26.013,10.047l1.654-2.866c-2.198-1.272-4.743-2.012-7.466-2.012h0v3.312h0 | |
25 | - C22.32,8.481,24.301,9.057,26.013,10.047z"> | |
26 | - </path> | |
27 | - </svg> | |
28 | -); | |
29 | - | |
30 | -export default Loading; |
imports/client/views/org/module/navigation/PublicNavigation.js
... | ... | @@ -1,16 +0,0 @@ |
1 | -import React from 'react'; | |
2 | -import { LinkContainer } from 'react-router-bootstrap'; | |
3 | -import { Nav, NavItem } from 'react-bootstrap'; | |
4 | - | |
5 | -const PublicNavigation = () => ( | |
6 | - <Nav pullRight> | |
7 | - <LinkContainer to="signup"> | |
8 | - <NavItem eventKey={ 1 } href="/signup">Sign Up</NavItem> | |
9 | - </LinkContainer> | |
10 | - <LinkContainer to="login"> | |
11 | - <NavItem eventKey={ 2 } href="/login">Log In</NavItem> | |
12 | - </LinkContainer> | |
13 | - </Nav> | |
14 | -); | |
15 | - | |
16 | -export default PublicNavigation; |
imports/client/views/org/module/navigation/index.js
... | ... | @@ -1,7 +0,0 @@ |
1 | -import { composeWithTracker } from 'react-komposer'; | |
2 | -import { Meteor } from 'meteor/meteor'; | |
3 | -import AppNavigation from '../components/AppNavigation.js'; | |
4 | - | |
5 | -const composer = (props, onData) => onData(null, { hasUser: Meteor.user() }); | |
6 | - | |
7 | -export default composeWithTracker(composer, {}, {}, { pure: false })(AppNavigation); |
imports/collections/orgs/index.js
... | ... | @@ -87,8 +87,8 @@ Orgs.deny({ |
87 | 87 | |
88 | 88 | Orgs.schema = new SimpleSchema({ |
89 | 89 | |
90 | - name: { type: String, }, | |
91 | - slug: { type: String, optional: true}, | |
90 | + name: { type: String }, | |
91 | + slug: { type: String }, | |
92 | 92 | address: { type: String, optional: true}, |
93 | 93 | users: { |
94 | 94 | type: [new SimpleSchema({ | ... | ... |
imports/collections/students/index.js
... | ... | @@ -0,0 +1,207 @@ |
1 | +// import { Users } from '/imports/collections/users/index'; | |
2 | +// import { Users } from '/imports/collections/users/index'; | |
3 | + | |
4 | +import _ from 'lodash'; | |
5 | +import { Meteor } from 'meteor/meteor'; | |
6 | +import { Mongo } from 'meteor/mongo'; | |
7 | +import { SimpleSchema } from 'meteor/aldeed:simple-schema'; | |
8 | + | |
9 | +import { Orgs } from '/imports/collections/orgs/index'; | |
10 | + | |
11 | +class User { | |
12 | + | |
13 | + constructor(doc) { | |
14 | + _.assign(this, doc); | |
15 | + }; | |
16 | + | |
17 | + isEmailVerified() { | |
18 | + return !! _.find(this.emails, x => x.verified); | |
19 | + }; | |
20 | + | |
21 | + isPhoneVerified() { | |
22 | + return !! _.find(this.phones, x => x.verified); | |
23 | + }; | |
24 | + | |
25 | + isIdentityVerified() { | |
26 | + return !! _.find(this.identities, x => x.verified); | |
27 | + }; | |
28 | + | |
29 | + getRole() { | |
30 | + const org = Orgs.findOne({_id: this.orgId}); | |
31 | + if(!org) return null; | |
32 | + const connection = _.find(org.users, {userId: this._id}); | |
33 | + if(!connection) return null; | |
34 | + return connection.role; | |
35 | + }; | |
36 | + | |
37 | + getFullName() { | |
38 | + return `${this.firstName} ${this.lastName}`; | |
39 | + }; | |
40 | + getFirstName() { | |
41 | + return `${this.firstName}`; | |
42 | + }; | |
43 | + getLastName() { | |
44 | + return `${this.lastName}`; | |
45 | + }; | |
46 | + getEmail() { | |
47 | + return `${this.emails[0].address}`; | |
48 | + }; | |
49 | + getOrganization(){ | |
50 | + return `${this.orgId}`; | |
51 | + }; | |
52 | + | |
53 | + getNameByUserId(userId){ | |
54 | + var user = Users.findOne({"_id":userId}); | |
55 | + return user.firstName + " " + user.lastName; | |
56 | + } | |
57 | + getAvatarUrl() { | |
58 | + let random = parseInt(this._id.substr(0, 4), 36); | |
59 | + random = '' + (random % 32); | |
60 | + while(random.length < 3) random = '0' + random; | |
61 | + return `/files/random/random${ random }.png`; | |
62 | + }; | |
63 | +}; | |
64 | + | |
65 | +export { User }; | |
66 | + | |
67 | + | |
68 | +const transform = function(doc) { | |
69 | + return new User(doc); | |
70 | +}; | |
71 | + | |
72 | +export const Users = { | |
73 | + | |
74 | + current: function() { | |
75 | + return Meteor.users.findOne({_id: Meteor.userId()}, _.extend({transform: transform})); | |
76 | + }, | |
77 | + | |
78 | + find: function(selector, options) { | |
79 | + return Meteor.users.find(selector || {}, _.extend({transform: transform}, options)); | |
80 | + }, | |
81 | + | |
82 | + findOne: function(selector, options) { | |
83 | + return Meteor.users.findOne(selector || {}, _.extend({transform: transform}, options)); | |
84 | + }, | |
85 | + | |
86 | + insert: _.bind(Meteor.users.insert, Meteor.users), | |
87 | + update: _.bind(Meteor.users.update, Meteor.users), | |
88 | + remove: _.bind(Meteor.users.remove, Meteor.users), | |
89 | + allow: _.bind(Meteor.users.allow, Meteor.users), | |
90 | + deny: _.bind(Meteor.users.deny, Meteor.users), | |
91 | + attachSchema: _.bind(Meteor.users.attachSchema, Meteor.users), | |
92 | + | |
93 | +}; | |
94 | + | |
95 | + | |
96 | +Users.deny({ | |
97 | + insert() { return true; }, | |
98 | + update() { return true; }, | |
99 | + remove() { return true; }, | |
100 | +}); | |
101 | + | |
102 | +Users.roles = { | |
103 | + 'STUDENT': 'STUDENT', | |
104 | + 'TEACHER': 'TEACHER', | |
105 | + 'ADMIN': 'ADMIN', | |
106 | + 'PARENT': 'PARENT' | |
107 | +}; | |
108 | + | |
109 | + | |
110 | +Users.schema = new SimpleSchema({ | |
111 | + roles: { type: String }, | |
112 | + orgId: { type: String }, | |
113 | + admissionId: { type: String, optional: true }, | |
114 | + enrollmentDate: { type: String, optional: true }, | |
115 | + address: { type: String, optional: true }, | |
116 | + prefix: { type: String, optional: true }, | |
117 | + firstName: { type: String, optional: true }, | |
118 | + middlename: { type: String, optional: true }, | |
119 | + lastName: { type: String, optional: true }, | |
120 | + gender: { type: String, optional: true }, | |
121 | + dob: { type: String, optional: true }, | |
122 | + rollNo: { type: String, optional: true }, | |
123 | + class: { type: String, optional: true }, | |
124 | + section: { type: String, optional: true }, | |
125 | + bloodGroup: { type: String, optional: true }, | |
126 | + community: { type: String, optional: true }, | |
127 | + nationality: { type: String, optional: true }, | |
128 | + motherTongue: { type: String, optional: true }, | |
129 | + motherTongue: { type: String, optional: true }, | |
130 | + religion: { type: String, optional: true }, | |
131 | + permanentAddress: { | |
132 | + type: new SimpleSchema({ | |
133 | + home: { type: String, optional: true }, | |
134 | + street: { type: String, optional: true }, | |
135 | + town: { type: String, optional: true }, | |
136 | + city: { type: String, optional: true }, | |
137 | + state: { type: String, optional: true }, | |
138 | + zip: { type: String, optional: true }, | |
139 | + }), | |
140 | + }, | |
141 | + parent: { | |
142 | + type: [new SimpleSchema({ | |
143 | + id: { type: String, }, | |
144 | + relatinship: { type: Boolean, }, | |
145 | + })], | |
146 | + minCount: 1, | |
147 | + }, | |
148 | + emails: { | |
149 | + type: [new SimpleSchema({ | |
150 | + address: { type: String, }, | |
151 | + verified: { type: Boolean, }, | |
152 | + })], | |
153 | + }, | |
154 | + prevInstitute: { | |
155 | + type: [new SimpleSchema({ | |
156 | + name: { type: String, }, | |
157 | + fromYear: { type: Boolean, }, | |
158 | + toYear: { type: Boolean, }, | |
159 | + ydId: { type: Boolean, }, | |
160 | + })], | |
161 | + optional: true | |
162 | + }, | |
163 | + | |
164 | + phones: { | |
165 | + type: [new SimpleSchema({ | |
166 | + country: { type: String, }, | |
167 | + prefix: { type: String, }, | |
168 | + number: { type: String, }, | |
169 | + verified: { type: Boolean, }, | |
170 | + })], | |
171 | + optional: true | |
172 | + }, | |
173 | + | |
174 | + services: { | |
175 | + type: Object, | |
176 | + optional: true, | |
177 | + blackbox: true, | |
178 | + }, | |
179 | + | |
180 | + isMetaUser: { type: Boolean, optional: true }, | |
181 | + | |
182 | + createdAt: { type: Date, autoValue: function(){return new Date();}} | |
183 | + | |
184 | +}); | |
185 | + | |
186 | +Users.attachSchema(Users.schema); | |
187 | + | |
188 | +Users.privateFields = { | |
189 | + orgId: 1, | |
190 | + address: 1, | |
191 | + | |
192 | + firstName: 1, | |
193 | + lastName: 1, | |
194 | + emails: 1, | |
195 | + phones: 1, | |
196 | + | |
197 | + isMetaUser: 1, | |
198 | + createdAt: 1, | |
199 | +}; | |
200 | + | |
201 | +Users.publicFields = { | |
202 | + firstName: 1, | |
203 | + lastName: 1, | |
204 | + emails: 1, | |
205 | + | |
206 | + createdAt: 1, | |
207 | +}; | ... | ... |
imports/collections/users/index.js
... | ... | @@ -108,59 +108,20 @@ Users.roles = { |
108 | 108 | |
109 | 109 | |
110 | 110 | Users.schema = new SimpleSchema({ |
111 | - roles: { type: String }, | |
111 | + role: { type: String }, | |
112 | 112 | orgId: { type: String }, |
113 | - admissionId: { type: String }, | |
114 | - enrollmentDate: { type: String, optional: true }, | |
115 | - address: { type: String, optional: true }, | |
116 | 113 | prefix: { type: String, optional: true }, |
117 | 114 | firstName: { type: String, optional: true }, |
118 | 115 | middlename: { type: String, optional: true }, |
119 | 116 | lastName: { type: String, optional: true }, |
120 | 117 | gender: { type: String, optional: true }, |
121 | 118 | dob: { type: String, optional: true }, |
122 | - rollNo: { type: String, optional: true }, | |
123 | - class: { type: String, optional: true }, | |
124 | - section: { type: String, optional: true }, | |
125 | - bloodGroup: { type: String, optional: true }, | |
126 | - community: { type: String, optional: true }, | |
127 | - nationality: { type: String, optional: true }, | |
128 | - motherTongue: { type: String, optional: true }, | |
129 | - motherTongue: { type: String, optional: true }, | |
130 | - religion: { type: String, optional: true }, | |
131 | - permanentAddress: { | |
132 | - type: new SimpleSchema({ | |
133 | - home: { type: String, optional: true }, | |
134 | - street: { type: String, optional: true }, | |
135 | - town: { type: String, optional: true }, | |
136 | - city: { type: String, optional: true }, | |
137 | - state: { type: String, optional: true }, | |
138 | - zip: { type: String, optional: true }, | |
139 | - }), | |
140 | - }, | |
141 | - parent: { | |
142 | - type: [new SimpleSchema({ | |
143 | - id: { type: String, }, | |
144 | - relatinship: { type: Boolean, }, | |
145 | - })], | |
146 | - minCount: 1, | |
147 | - }, | |
148 | 119 | emails: { |
149 | 120 | type: [new SimpleSchema({ |
150 | 121 | address: { type: String, }, |
151 | 122 | verified: { type: Boolean, }, |
152 | 123 | })], |
153 | 124 | }, |
154 | - prevInstitute: { | |
155 | - type: [new SimpleSchema({ | |
156 | - name: { type: String, }, | |
157 | - fromYear: { type: Boolean, }, | |
158 | - toYear: { type: Boolean, }, | |
159 | - ydId: { type: Boolean, }, | |
160 | - })], | |
161 | - optional: true | |
162 | - }, | |
163 | - | |
164 | 125 | phones: { |
165 | 126 | type: [new SimpleSchema({ |
166 | 127 | country: { type: String, }, | ... | ... |
imports/collections/users/publications.js
... | ... | @@ -0,0 +1,14 @@ |
1 | +import { Meteor } from 'meteor/meteor'; | |
2 | +import { check, Match } from 'meteor/check' | |
3 | +import { Users } from '/imports/collections/users/index'; | |
4 | +import { Orgs } from '/imports/collections/orgs/index'; | |
5 | + | |
6 | + | |
7 | + | |
8 | +Meteor.publish('users.current', function() { | |
9 | + return Users.find({ | |
10 | + _id: this.userId, | |
11 | + }, { | |
12 | + fields: Users.privateFields, | |
13 | + }); | |
14 | +}); | ... | ... |
imports/server/accounts/creation.js
imports/startup/client/routes.js
... | ... | @@ -16,12 +16,12 @@ import Index from '/imports/client/views/app/modu |
16 | 16 | */ |
17 | 17 | |
18 | 18 | import App from '/imports/client/layouts/OrgApp'; |
19 | -import OrgIndex from '/imports/client/views/org/module/Index'; | |
19 | +import { AppModule } from '/imports/client/views/org/app/module/Index'; | |
20 | 20 | import { orgLoginController } from '/imports/client/views/org/enter/login/index'; |
21 | -import NotFound from '/imports/client/views/org/NotFound'; | |
22 | 21 | import RecoverPassword from '/imports/client/views/org/enter/RecoverPassword'; |
23 | 22 | import ResetPassword from '/imports/client/views/org/enter/ResetPassword'; |
24 | 23 | import { Orgs } from '/imports/collections/orgs/index'; |
24 | +import NotFound from '/imports/client/views/org/NotFound'; | |
25 | 25 | |
26 | 26 | /** |
27 | 27 | * NonOrg Components |
... | ... | @@ -50,7 +50,6 @@ const detectOrg = () => { |
50 | 50 | } |
51 | 51 | if(orgSlug!=""){ |
52 | 52 | Meteor.call('checkExistingOrg', {slug:orgSlug}, function(err, res) { |
53 | - console.log(res); | |
54 | 53 | if(res){ |
55 | 54 | Session.set('orgId', res._id._str); |
56 | 55 | render(getOrgRoutes(),document.getElementById('app')); |
... | ... | @@ -75,7 +74,7 @@ There are three types of routes |
75 | 74 | const getOrgRoutes = () => ( |
76 | 75 | <Router history={ browserHistory }> |
77 | 76 | <Route path="/" component={ App }> |
78 | - <IndexRoute name="index" component={ OrgIndex } /> | |
77 | + <IndexRoute name="index" component={ AppModule } /> | |
79 | 78 | <Route name="login" path="/login" component={ orgLoginController } /> |
80 | 79 | <Route name="recover-password" path="/recover-password" component={ RecoverPassword } /> |
81 | 80 | <Route name="reset-password" path="/reset-password/:token" component={ ResetPassword } /> |
... | ... | @@ -97,7 +96,7 @@ const getInvalidOrgRoute = () => ( |
97 | 96 | const getNonOrgRoutes = () => ( |
98 | 97 | <Router history={ browserHistory }> |
99 | 98 | <Route path="/" component={ App }> |
100 | - <IndexRoute name="index" component={ Index } onEnter={ checkSlug } /> | |
99 | + <IndexRoute name="index" component={ Index } /> | |
101 | 100 | <Route name="signup" path="/signup" component={ Signup } /> |
102 | 101 | <Route path="*" component={ NotFound } /> |
103 | 102 | </Route> | ... | ... |
imports/startup/server/accounts/creation.js
... | ... | @@ -3,6 +3,8 @@ import { Accounts } from 'meteor/accounts-base'; |
3 | 3 | import { SimpleSchema } from 'meteor/aldeed:simple-schema'; |
4 | 4 | import { ValidatedMethod } from 'meteor/mdg:validated-method'; |
5 | 5 | |
6 | +import { Orgs } from '/imports/collections/orgs/index'; | |
7 | +import { Users } from '/imports/collections/users/index'; | |
6 | 8 | |
7 | 9 | |
8 | 10 | Accounts.validateNewUser((user) => { |
... | ... | @@ -11,4 +13,23 @@ Accounts.validateNewUser((user) => { |
11 | 13 | |
12 | 14 | Accounts.onCreateUser((options, user) => { |
13 | 15 | console.log(options); |
16 | + if(options.orgSlug){ | |
17 | + orgId = Orgs.insert({ | |
18 | + slug: options.orgSlug, | |
19 | + name: options.orgName, | |
20 | + setup: 1, | |
21 | + users: [{ | |
22 | + userId: user._id, | |
23 | + role: Users.roles.ADMIN, | |
24 | + }], | |
25 | + }); | |
26 | + } | |
27 | + console.log(user); | |
28 | + _.assign(user, { | |
29 | + role: Users.roles.ADMIN, | |
30 | + orgId: orgId, | |
31 | + firstName: options.profile.firstName, | |
32 | + lastName: options.profile.lastName, | |
33 | + }); | |
34 | + return user; | |
14 | 35 | }); | ... | ... |
imports/startup/server/api.js
package.json
... | ... | @@ -72,7 +72,8 @@ |
72 | 72 | "react-bootstrap": "^0.30.5", |
73 | 73 | "react-dom": "^15.3.2", |
74 | 74 | "react-komposer": "^1.13.1", |
75 | - "react-router": "^3.0.0", | |
76 | - "react-router-bootstrap": "^0.23.1" | |
75 | + "react-router": "^2.6.1", | |
76 | + "react-router-bootstrap": "^0.23.1", | |
77 | + "react-svg": "^2.1.19" | |
77 | 78 | } |
78 | 79 | } | ... | ... |