Commit 8c4a3096b2db2d98a5b1bf612fe644ca432e0c33
1 parent
217abcceeb
Exists in
master
added settings and run file
Showing
9 changed files
with
194 additions
and
54 deletions
Show diff stats
imports/client/app/routes.js
... | ... | @@ -10,6 +10,7 @@ import { Meteor } from 'meteor/meteor'; |
10 | 10 | * General Components |
11 | 11 | */ |
12 | 12 | import Index from '/imports/client/views/app/module/Index'; |
13 | +import NotFound from '/imports/client/views/org/NotFound'; | |
13 | 14 | |
14 | 15 | /** |
15 | 16 | * Org Components |
... | ... | @@ -22,53 +23,24 @@ import { importCsvController } from '/imports/client/views/org/impo |
22 | 23 | |
23 | 24 | //admin |
24 | 25 | import { StudentDataController } from '/imports/client/views/org/admin/students/index' |
26 | +//students | |
27 | + | |
28 | +//teachers | |
29 | + | |
30 | +//parents | |
25 | 31 | |
26 | 32 | |
27 | -import NotFound from '/imports/client/views/org/NotFound'; | |
28 | 33 | |
29 | 34 | /** |
30 | 35 | * NonOrg Components |
31 | 36 | */ |
32 | 37 | import Signup from '/imports/client/views/nonOrg/enter/SignupView'; |
38 | +import { NonOrgApp } from '/imports/client/layouts/NonOrgApp'; | |
33 | 39 | |
34 | 40 | /** |
35 | 41 | * Invalid Org Components |
36 | 42 | */ |
37 | 43 | |
38 | -const authenticate = (nextState, replace) => { | |
39 | - if (!Meteor.loggingIn() && !Meteor.userId()) { | |
40 | - replace({ | |
41 | - pathname: '/login', | |
42 | - state: { nextPathname: nextState.location.pathname }, | |
43 | - }); | |
44 | - } | |
45 | -}; | |
46 | - | |
47 | - | |
48 | -const detectOrg = () => { | |
49 | - orgSlug = ""; | |
50 | - var hostnameArray = document.location.hostname.split( "." ); | |
51 | - if(hostnameArray[1]=='localhost'){ | |
52 | - orgSlug = hostnameArray[0]; | |
53 | - } | |
54 | - if(orgSlug!=""){ | |
55 | - Meteor.call('checkExistingOrg', {slug:orgSlug}, function(err, res) { | |
56 | - if(res){ | |
57 | - Session.set('orgId', res._id); | |
58 | - Session.set('orgSlug', orgSlug); | |
59 | - render(getOrgRoutes(),document.getElementById('app')); | |
60 | - }else{ | |
61 | - render(getInvalidOrgRoute(),document.getElementById('app')); | |
62 | - } | |
63 | - }); | |
64 | - }else{ | |
65 | - render(getNonOrgRoutes(),document.getElementById('app')); | |
66 | - } | |
67 | -} | |
68 | -const checkSlug = (nextState, replace) => { | |
69 | - orgId = Session.get('orgId'); | |
70 | -} | |
71 | - | |
72 | 44 | /** |
73 | 45 | There are three types of routes |
74 | 46 | 1)getOrgRoutes: all the routes that should be present for a registered org |
... | ... | @@ -98,7 +70,7 @@ const getInvalidOrgRoute = () => ( |
98 | 70 | |
99 | 71 | const getNonOrgRoutes = () => ( |
100 | 72 | <Router history={ browserHistory }> |
101 | - <Route path="/" component={ App }> | |
73 | + <Route path="/" component={ NonOrgApp }> | |
102 | 74 | <IndexRoute name="index" component={ Index } /> |
103 | 75 | <Route name="signup" path="/signup" component={ Signup } /> |
104 | 76 | <Route path="*" component={ NotFound } /> |
... | ... | @@ -106,6 +78,44 @@ const getNonOrgRoutes = () => ( |
106 | 78 | </Router> |
107 | 79 | ) |
108 | 80 | |
81 | +//Authenticate function to give access to users only | |
82 | +const authenticate = (nextState, replace) => { | |
83 | + if (!Meteor.loggingIn() && !Meteor.userId()) { | |
84 | + replace({ | |
85 | + pathname: '/login', | |
86 | + state: { nextPathname: nextState.location.pathname }, | |
87 | + }); | |
88 | + } | |
89 | +}; | |
90 | + | |
91 | + | |
92 | +/** | |
93 | + | |
94 | +**/ | |
95 | +const detectOrg = () => { | |
96 | + orgSlug = ""; | |
97 | + var hostnameArray = document.location.hostname.split( "." ); | |
98 | + if(hostnameArray[1]=='localhost'){ | |
99 | + orgSlug = hostnameArray[0]; | |
100 | + } | |
101 | + if(orgSlug!=""){ | |
102 | + Meteor.call('checkExistingOrg', {slug:orgSlug}, function(err, res) { | |
103 | + if(res){ | |
104 | + Session.set('orgId', res._id); | |
105 | + Session.set('orgSlug', orgSlug); | |
106 | + render(getOrgRoutes(),document.getElementById('app')); | |
107 | + }else{ | |
108 | + render(getInvalidOrgRoute(),document.getElementById('app')); | |
109 | + } | |
110 | + }); | |
111 | + }else{ | |
112 | + render(getNonOrgRoutes(),document.getElementById('app')); | |
113 | + } | |
114 | +} | |
115 | +const checkSlug = (nextState, replace) => { | |
116 | + orgId = Session.get('orgId'); | |
117 | +} | |
118 | + | |
109 | 119 | |
110 | 120 | Meteor.startup(() => { |
111 | 121 | detectOrg(); | ... | ... |
imports/client/layouts/NonOrgApp.js
1 | -import React from 'react'; | |
2 | -import { Grid } from 'react-bootstrap'; | |
3 | -import AppNavigation from '../containers/AppNavigation.js'; | |
1 | +import React, { Component } from 'react'; | |
2 | +import { Grid } from 'react-bootstrap'; | |
3 | +import {AppNavigationController} from '/imports/client/views/org/app/module/navigation/index'; | |
4 | +/** | |
5 | + * user based redirection will take place here | |
6 | + */ | |
7 | + export class App extends Component { | |
8 | + constructor(props) { | |
9 | + super(props); | |
10 | + this.state = { | |
4 | 11 | |
5 | -const App = ({ children }) => ( | |
6 | - <div> | |
7 | - <AppNavigation /> | |
8 | - <Grid> | |
9 | - { children } | |
10 | - </Grid> | |
11 | - </div> | |
12 | -); | |
13 | - | |
14 | -App.propTypes = { | |
15 | - children: React.PropTypes.node, | |
16 | -}; | |
17 | - | |
18 | -export default App; | |
12 | + }; | |
13 | + }; | |
14 | + render(){ | |
15 | + return ( | |
16 | + <div> | |
17 | + <AppNavigationController /> | |
18 | + <Grid> | |
19 | + { this.props.children } | |
20 | + </Grid> | |
21 | + </div> | |
22 | + ) | |
23 | + } | |
24 | + } | ... | ... |
imports/client/views/nonOrg/app/module/Index.js
... | ... | @@ -0,0 +1,15 @@ |
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/nonOrg/app/module/navigation/AppNavigation.js
... | ... | @@ -0,0 +1,27 @@ |
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 | + | |
7 | +const renderNavigation = hasUser => (hasUser ? <AuthenticatedNavigation /> : <PublicNavigation />); | |
8 | + | |
9 | +const AppNavigation = ({ hasUser }) => ( | |
10 | + <Navbar> | |
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 | + | |
23 | +AppNavigation.propTypes = { | |
24 | + hasUser: React.PropTypes.object, | |
25 | +}; | |
26 | + | |
27 | +export default AppNavigation; | ... | ... |
imports/client/views/nonOrg/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/nonOrg/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/nonOrg/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/nonOrg/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/server/emails/verifyEmail.js