Commit a8c5a7fb6d807c52c4d119ddb806d2c99e347edb
1 parent
0d80eac236
Exists in
master
added teachers view
Showing
8 changed files
with
184 additions
and
31 deletions
Show diff stats
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 { teachersViewController } from '/imports/client/views/org/admin/teachers/index' | ||
26 | //students | 27 | //students |
27 | 28 | ||
28 | //teachers | 29 | //teachers |
29 | 30 | ||
30 | //parents | 31 | //parents |
31 | 32 | ||
32 | 33 | ||
33 | 34 | ||
34 | /** | 35 | /** |
35 | * NonOrg Components | 36 | * NonOrg Components |
36 | */ | 37 | */ |
37 | import Signup from '/imports/client/views/nonOrg/enter/SignupView'; | 38 | import Signup from '/imports/client/views/nonOrg/enter/SignupView'; |
38 | import { NonOrgApp } from '/imports/client/layouts/NonOrgApp'; | 39 | import { NonOrgApp } from '/imports/client/layouts/NonOrgApp'; |
39 | 40 | ||
40 | /** | 41 | /** |
41 | * Invalid Org Components | 42 | * Invalid Org Components |
42 | */ | 43 | */ |
43 | 44 | ||
44 | /** | 45 | /** |
45 | There are three types of routes | 46 | There are three types of routes |
46 | 1)getOrgRoutes: all the routes that should be present for a registered org | 47 | 1)getOrgRoutes: all the routes that should be present for a registered org |
47 | 2)getInvalidOrgRoute: all the routes where someone tries to enter a subdomain which hasn't been registered yet (404 mostly :D) | 48 | 2)getInvalidOrgRoute: all the routes where someone tries to enter a subdomain which hasn't been registered yet (404 mostly :D) |
48 | 3)getNonOrgRoutes: all routes linked to normal site, ie signing up a new org. CHeking out demo and everything internal | 49 | 3)getNonOrgRoutes: all routes linked to normal site, ie signing up a new org. CHeking out demo and everything internal |
49 | **/ | 50 | **/ |
50 | const getOrgRoutes = () => ( | 51 | const getOrgRoutes = () => ( |
51 | <Router history={ browserHistory }> | 52 | <Router history={ browserHistory }> |
52 | <Route path="/" component={ App }> | 53 | <Route path="/" component={ App }> |
53 | <IndexRoute name="index" component={ AppModule } /> | 54 | <IndexRoute name="index" component={ AppModule } /> |
54 | <Route name="import" path="/import" component={ importCsvController } /> | 55 | <Route name="import" path="/import" component={ importCsvController } /> |
55 | <Route name="student" path="/students" component={ StudentDataController } /> | 56 | <Route name="student" path="/students" component={ StudentDataController } /> |
57 | <Route name="teachers" path="/teachers" component={ teachersViewController } /> | ||
56 | <Route path="*" component={ NotFound } /> | 58 | <Route path="*" component={ NotFound } /> |
57 | </Route> | 59 | </Route> |
58 | </Router> | 60 | </Router> |
59 | ) | 61 | ) |
60 | 62 | ||
61 | 63 | ||
62 | const getInvalidOrgRoute = () => ( | 64 | const getInvalidOrgRoute = () => ( |
63 | <Router history={ browserHistory }> | 65 | <Router history={ browserHistory }> |
64 | <Route path="/" component={ App }> | 66 | <Route path="/" component={ App }> |
65 | <IndexRoute name="index" component={ NotFound } /> | 67 | <IndexRoute name="index" component={ NotFound } /> |
66 | <Route path="*" component={ NotFound } /> | 68 | <Route path="*" component={ NotFound } /> |
67 | </Route> | 69 | </Route> |
68 | </Router> | 70 | </Router> |
69 | ) | 71 | ) |
70 | 72 | ||
71 | const getNonOrgRoutes = () => ( | 73 | const getNonOrgRoutes = () => ( |
72 | <Router history={ browserHistory }> | 74 | <Router history={ browserHistory }> |
73 | <Route path="/" component={ NonOrgApp }> | 75 | <Route path="/" component={ NonOrgApp }> |
74 | <IndexRoute name="index" component={ Index } /> | 76 | <IndexRoute name="index" component={ Index } /> |
75 | <Route name="signup" path="/signup" component={ Signup } /> | 77 | <Route name="signup" path="/signup" component={ Signup } /> |
76 | <Route path="*" component={ NotFound } /> | 78 | <Route path="*" component={ NotFound } /> |
77 | </Route> | 79 | </Route> |
78 | </Router> | 80 | </Router> |
79 | ) | 81 | ) |
80 | 82 | ||
81 | //Authenticate function to give access to users only | 83 | //Authenticate function to give access to users only |
82 | const authenticate = (nextState, replace) => { | 84 | const authenticate = (nextState, replace) => { |
83 | if (!Meteor.loggingIn() && !Meteor.userId()) { | 85 | if (!Meteor.loggingIn() && !Meteor.userId()) { |
84 | replace({ | 86 | replace({ |
85 | pathname: '/login', | 87 | pathname: '/login', |
86 | state: { nextPathname: nextState.location.pathname }, | 88 | state: { nextPathname: nextState.location.pathname }, |
87 | }); | 89 | }); |
88 | } | 90 | } |
89 | }; | 91 | }; |
90 | 92 | ||
91 | 93 | ||
92 | /** | 94 | /** |
93 | 95 | ||
94 | **/ | 96 | **/ |
95 | const detectOrg = () => { | 97 | const detectOrg = () => { |
96 | orgSlug = ""; | 98 | orgSlug = ""; |
97 | var hostnameArray = document.location.hostname.split( "." ); | 99 | var hostnameArray = document.location.hostname.split( "." ); |
98 | if(hostnameArray[1]=='localhost'){ | 100 | if(hostnameArray[1]=='localhost'){ |
99 | orgSlug = hostnameArray[0]; | 101 | orgSlug = hostnameArray[0]; |
100 | } | 102 | } |
101 | if(orgSlug!=""){ | 103 | if(orgSlug!=""){ |
102 | Meteor.call('checkExistingOrg', {slug:orgSlug}, function(err, res) { | 104 | Meteor.call('checkExistingOrg', {slug:orgSlug}, function(err, res) { |
103 | if(res){ | 105 | if(res){ |
104 | Session.set('orgId', res._id); | 106 | Session.set('orgId', res._id); |
105 | Session.set('orgSlug', orgSlug); | 107 | Session.set('orgSlug', orgSlug); |
106 | render(getOrgRoutes(),document.getElementById('app')); | 108 | render(getOrgRoutes(),document.getElementById('app')); |
107 | }else{ | 109 | }else{ |
108 | render(getInvalidOrgRoute(),document.getElementById('app')); | 110 | render(getInvalidOrgRoute(),document.getElementById('app')); |
109 | } | 111 | } |
110 | }); | 112 | }); |
111 | }else{ | 113 | }else{ |
112 | render(getNonOrgRoutes(),document.getElementById('app')); | 114 | render(getNonOrgRoutes(),document.getElementById('app')); |
113 | } | 115 | } |
114 | } | 116 | } |
115 | const checkSlug = (nextState, replace) => { | 117 | const checkSlug = (nextState, replace) => { |
116 | orgId = Session.get('orgId'); | 118 | orgId = Session.get('orgId'); |
117 | } | 119 | } |
118 | 120 | ||
119 | 121 | ||
120 | Meteor.startup(() => { | 122 | Meteor.startup(() => { |
121 | detectOrg(); | 123 | detectOrg(); |
122 | }); | 124 | }); |
123 | 125 |
imports/client/layouts/NonOrgApp.js
1 | import React, { Component } from 'react'; | 1 | import React, { Component } from 'react'; |
2 | import { Grid } from 'react-bootstrap'; | 2 | import { Grid } from 'react-bootstrap'; |
3 | import {AppNavigationController} from '/imports/client/views/org/app/module/navigation/index'; | 3 | import {AppNavigationController} from '/imports/client/views/nonOrg/app/module/navigation/index'; |
4 | /** | 4 | /** |
5 | * user based redirection will take place here | 5 | * user based redirection will take place here |
6 | */ | 6 | */ |
7 | export class App extends Component { | 7 | export class App extends Component { |
8 | constructor(props) { | 8 | constructor(props) { |
9 | super(props); | 9 | super(props); |
10 | this.state = { | 10 | this.state = { |
11 | 11 | ||
12 | }; | 12 | }; |
13 | }; | 13 | }; |
14 | render(){ | 14 | render(){ |
15 | return ( | 15 | return ( |
16 | <div> | 16 | <div> |
17 | <AppNavigationController /> | 17 | <AppNavigationController /> |
18 | <Grid> | 18 | <Grid> |
19 | { this.props.children } | 19 | { this.props.children } |
20 | </Grid> | 20 | </Grid> |
21 | </div> | 21 | </div> |
22 | ) | 22 | ) |
23 | } | 23 | } |
24 | } | 24 | } |
25 | 25 |
imports/client/views/etc/index.js
1 | // import { InviteSignupController } from '/imports/client/views/invite/signup/index' | 1 | // import { InviteSignupController } from '/imports/client/views/invite/signup/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 { teachersView } from './teachersView'; | ||
12 | 13 | ||
13 | const meteorTick = (props, onData) => { | 14 | const meteorTick = (props, onData) => { |
14 | 15 | ||
15 | const handles = [ | 16 | const handles = [ |
16 | Meteor.subscribe('users.current'), | 17 | Meteor.subscribe('users.current'), |
17 | Meteor.subscribe('orgs.current') | 18 | Meteor.subscribe('orgs.current') |
18 | ]; | 19 | ]; |
19 | 20 | ||
20 | if(_.every(handles, (handle) => (handle.ready()) )) { | 21 | if(_.every(handles, (handle) => (handle.ready()) )) { |
21 | const user = Users.current(); | 22 | const user = Users.current(); |
22 | const org = Orgs.current(); | 23 | const org = Orgs.current(); |
23 | onData(null, { | 24 | onData(null, { |
24 | data: { | 25 | data: { |
25 | user: user, | 26 | user: user, |
26 | org: org | 27 | org: org |
27 | }, | 28 | }, |
28 | }); | 29 | }); |
29 | } | 30 | } |
30 | 31 | ||
31 | return () => { | 32 | return () => { |
32 | _.each(handles, (handle) => handle.stop() ); | 33 | _.each(handles, (handle) => handle.stop() ); |
33 | }; | 34 | }; |
34 | }; | 35 | }; |
35 | 36 | ||
36 | 37 | ||
37 | const reduxTick = (props, onData) => { | 38 | const reduxTick = (props, onData) => { |
38 | onData(null, { | 39 | onData(null, { |
39 | data: {} | 40 | data: {} |
40 | }); | 41 | }); |
41 | }; | 42 | }; |
42 | 43 | ||
43 | 44 | ||
44 | export const InviteSignupController = composeAll( | 45 | export const InviteSignupController = composeAll( |
45 | composeWithTracker(meteorTick, Loading), | 46 | composeWithTracker(meteorTick, Loading), |
46 | compose(reduxTick, Loading), | 47 | compose(reduxTick, Loading), |
47 | )(InviteSignupView); | 48 | )(InviteSignupView); |
48 | 49 |
imports/client/views/etc/signup.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 | 8 | ||
9 | 9 | ||
10 | export class InviteSignupView extends Component { | 10 | export class InviteSignupView extends Component { |
11 | 11 | ||
12 | constructor(props) { | 12 | constructor(props) { |
13 | super(props); | 13 | super(props); |
14 | this.state = { | 14 | this.state = { |
15 | 15 | ||
16 | }; | 16 | }; |
17 | this.onUpdate = this.onUpdate.bind(this); | 17 | this.onUpdate = this.onUpdate.bind(this); |
18 | }; | 18 | }; |
19 | 19 | ||
20 | onUpdate(key, value) { | 20 | onUpdate(key, value) { |
21 | this.setState({[key]: value}); | 21 | this.setState({[key]: value}); |
22 | }; | 22 | }; |
23 | 23 | ||
24 | render() { | 24 | render() { |
25 | const {user, org} = this.props.data; | 25 | const {user, org} = this.props.data; |
26 | return ( | 26 | return ( |
27 | <div className = "enterPane-box"> | 27 | <div className = "enterPane-box"> |
28 | 28 | ||
29 | </div> | 29 | </div> |
30 | ); | 30 | ); |
31 | }; | 31 | }; |
32 | 32 | ||
33 | }; | 33 | }; |
34 | 34 |
imports/client/views/nonOrg/app/module/navigation/AppNavigation.js
1 | import React from 'react'; | 1 | import React, { Component } from 'react'; |
2 | import { Navbar } from 'react-bootstrap'; | 2 | import { Navbar } from 'react-bootstrap'; |
3 | import { Link } from 'react-router'; | 3 | import { Link } from 'react-router'; |
4 | import PublicNavigation from './PublicNavigation.js'; | 4 | import {PublicNavigation} from './PublicNavigation.js'; |
5 | import AuthenticatedNavigation from './AuthenticatedNavigation.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 | // import '/imports/client/assets/css/colors.css'; | ||
12 | export class AppNavigation extends Component { | ||
6 | 13 | ||
7 | const renderNavigation = hasUser => (hasUser ? <AuthenticatedNavigation /> : <PublicNavigation />); | 14 | constructor(props) { |
15 | super(props); | ||
16 | this.state = { | ||
8 | 17 | ||
9 | const AppNavigation = ({ hasUser }) => ( | 18 | }; |
10 | <Navbar> | 19 | }; |
11 | <Navbar.Header> | ||
12 | <Navbar.Brand> | ||
13 | <Link to="/">Application Name</Link> | ||
14 | </Navbar.Brand> | ||
15 | <Navbar.Toggle /> | ||
16 | </Navbar.Header> | ||
17 | <Navbar.Collapse> | ||
18 | { renderNavigation(hasUser) } | ||
19 | </Navbar.Collapse> | ||
20 | </Navbar> | ||
21 | ); | ||
22 | 20 | ||
23 | AppNavigation.propTypes = { | 21 | onUpdate(key, value) { |
24 | hasUser: React.PropTypes.object, | 22 | this.setState({[key]: value}); |
25 | }; | 23 | }; |
24 | render() { | ||
25 | const {user} = this.props.data; | ||
26 | if(user){ | ||
27 | return( | ||
28 | <AuthenticatedNavigation | ||
29 | data = {this.props.data} | ||
30 | /> | ||
31 | ) | ||
32 | }else{ | ||
33 | return( | ||
34 | <Navbar> | ||
35 | <Navbar.Header> | ||
36 | <Navbar.Brand> | ||
37 | <Link to="/">Application Name</Link> | ||
38 | </Navbar.Brand> | ||
39 | <Navbar.Toggle /> | ||
40 | </Navbar.Header> | ||
41 | <Navbar.Collapse> | ||
42 | <PublicNavigation /> | ||
43 | </Navbar.Collapse> | ||
44 | </Navbar> |
imports/client/views/nonOrg/app/module/navigation/index.js
1 | import { composeWithTracker } from 'react-komposer'; | 1 | // import { AppNavigation } from '/imports/client/views/nonOrg/app/module/navigation/index' |
2 | import { Meteor } from 'meteor/meteor'; | 2 | import _ from 'lodash'; |
3 | import AppNavigation from '../components/AppNavigation.js'; | 3 | import { |
4 | composeWithTracker, | ||
5 | compose, | ||
6 | composeAll | ||
7 | } from 'react-komposer'; | ||
8 | import { Loading } from '/imports/client/components/Loading'; | ||
4 | 9 | ||
5 | const composer = (props, onData) => onData(null, { hasUser: Meteor.user() }); | 10 | import { Orgs } from '/imports/collections/orgs/index'; |
11 | import { Users } from '/imports/collections/users/index'; | ||
6 | 12 | ||
7 | export default composeWithTracker(composer, {}, {}, { pure: false })(AppNavigation); | 13 | import { AppNavigation } from './AppNavigation'; |
14 | |||
15 | const meteorTick = (props, onData) => { | ||
16 | |||
17 | const handles = [ | ||
18 | Meteor.subscribe('users.current'), | ||
19 | Meteor.subscribe('orgs.current') | ||
20 | ]; | ||
21 | |||
22 | if(_.every(handles, (handle) => (handle.ready()) )) { | ||
23 | const user = Users.current(); | ||
24 | const org = Orgs.current(); | ||
25 | onData(null, { | ||
26 | data: { | ||
27 | user: user, | ||
28 | org: org | ||
29 | }, | ||
30 | }); | ||
31 | } | ||
32 | |||
33 | return () => { | ||
34 | _.each(handles, (handle) => handle.stop() ); | ||
35 | }; | ||
36 | }; | ||
37 | |||
38 | |||
39 | const reduxTick = (props, onData) => { | ||
40 | onData(null, { | ||
41 | data: {} | ||
42 | }); | ||
43 | }; | ||
44 | |||
45 | |||
46 | export const AppNavigationController = composeAll( | ||
47 | composeWithTracker(meteorTick, Loading), | ||
48 | compose(reduxTick, Loading), | ||
49 | )(AppNavigation); | ||
8 | 50 |
imports/client/views/org/admin/teachers/index.js
File was created | 1 | // import { InviteSignupController } from '/imports/client/views/invite/signup/index' | |
2 | import _ from 'lodash'; | ||
3 | import { | ||
4 | composeWithTracker, | ||
5 | compose, | ||
6 | composeAll | ||
7 | } from 'react-komposer'; | ||
8 | import { Loading } from '/imports/client/components/Loading'; | ||
9 | |||
10 | import { Orgs } from '/imports/collections/orgs/index'; | ||
11 | import { Users } from '/imports/collections/users/index'; | ||
12 | import { teachersView } from './teachersView'; | ||
13 | |||
14 | const meteorTick = (props, onData) => { | ||
15 | |||
16 | const handles = [ | ||
17 | Meteor.subscribe('users.current'), | ||
18 | Meteor.subscribe('orgs.current') | ||
19 | ]; | ||
20 | |||
21 | if(_.every(handles, (handle) => (handle.ready()) )) { | ||
22 | const user = Users.current(); | ||
23 | const org = Orgs.current(); | ||
24 | onData(null, { | ||
25 | data: { | ||
26 | user: user, | ||
27 | org: org | ||
28 | }, | ||
29 | }); | ||
30 | } | ||
31 | |||
32 | return () => { | ||
33 | _.each(handles, (handle) => handle.stop() ); | ||
34 | }; | ||
35 | }; | ||
36 | |||
37 | |||
38 | const reduxTick = (props, onData) => { | ||
39 | onData(null, { | ||
40 | data: {} | ||
41 | }); | ||
42 | }; | ||
43 | |||
44 | |||
45 | export const teachersViewController = composeAll( | ||
46 | composeWithTracker(meteorTick, Loading), | ||
47 | compose(reduxTick, Loading), | ||
48 | )(teachersView); | ||
49 |
imports/client/views/org/admin/teachers/teachersView.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 teachersView 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 {user, org} = this.props.data; | ||
26 | return ( | ||
27 | <div className = "enterPane-box"> | ||
28 | |||
29 | </div> | ||
30 | ); | ||
31 | }; | ||
32 | |||
33 | }; | ||
34 |