diff --git a/client/main.html b/client/main.html index 32dd10b..c441456 100644 --- a/client/main.html +++ b/client/main.html @@ -5,6 +5,9 @@ + + + ( + diff --git a/imports/client/views/etc/index.js b/imports/client/views/etc/index.js index 6579f02..f8fb0eb 100644 --- a/imports/client/views/etc/index.js +++ b/imports/client/views/etc/index.js @@ -13,14 +13,17 @@ import { Users } from '/imports/collections/users/index const meteorTick = (props, onData) => { const handles = [ - Meteor.subscribe('users.current') + Meteor.subscribe('users.current'), + Meteor.subscribe('orgs.current') ]; if(_.every(handles, (handle) => (handle.ready()) )) { const user = Users.current(); + const org = Orgs.current(); onData(null, { data: { user: user, + org: org }, }); } diff --git a/imports/client/views/etc/signup.js b/imports/client/views/etc/signup.js index a47fa6e..f78461d 100644 --- a/imports/client/views/etc/signup.js +++ b/imports/client/views/etc/signup.js @@ -22,6 +22,7 @@ export class InviteSignupView extends Component { }; render() { + const {user, org} = this.props.data; return (
diff --git a/imports/client/views/org/admin/students/StudentDataView.js b/imports/client/views/org/admin/students/StudentDataView.js new file mode 100644 index 0000000..03a3f53 --- /dev/null +++ b/imports/client/views/org/admin/students/StudentDataView.js @@ -0,0 +1,88 @@ +import _ from 'lodash'; +import { Meteor } from 'meteor/meteor'; + +import React, { Component } from 'react'; +import { Link,browserHistory } from 'react-router'; +import { FormGroup,Panel,Table, + ButtonToolbar,Modal, + FormControl,Glyphicon,Button } from 'react-bootstrap'; + import { AddStudentForm } from './addStudentForm'; + +export class StudentDataView extends Component { + + constructor(props) { + super(props); + this.state = { + show: false + }; + this.showModal = this.showModal.bind(this); + this.hideModal = this.hideModal.bind(this); + this.onUpdate = this.onUpdate.bind(this); + }; + + showModal() { + this.setState({show: true}); + } + + hideModal() { + this.setState({show: false}); + } + onUpdate(key, value) { + this.setState({[key]: value}); + }; + + render() { + return ( +
+ + + + + + + + + + + { + this.props.data.students.map(function(student, i) + { + return( + + + + + + ) + }) + } + + +
#First NameLast Name
{i+1}{student.firstName}{student.lastName}
+ + + + + New Student + + + + + + + + + +
+
+ ); + }; + +}; diff --git a/imports/client/views/org/admin/students/addStudentForm.js b/imports/client/views/org/admin/students/addStudentForm.js new file mode 100644 index 0000000..fa3c589 --- /dev/null +++ b/imports/client/views/org/admin/students/addStudentForm.js @@ -0,0 +1,90 @@ +import _ from 'lodash'; +import { Meteor } from 'meteor/meteor'; + +import React, { Component } from 'react'; +import { Link,browserHistory } from 'react-router'; +import { FormGroup,InputGroup, + DropdownButton,MenuItem,ControlLabel, + SplitButton, + FormControl,Glyphicon,Button } from 'react-bootstrap'; +import {DatePicker} from 'react-bootstrap-date-picker' +import {addStudentManually} from '/imports/collections/students/methods'; + +export class AddStudentForm extends Component { + + constructor(props) { + super(props); + this.state = { + firstName: "", + lastName: "", + middleName: "", + dob: "", + }; + this.onUpdate = this.onUpdate.bind(this); + this.aFunction = this.aFunction.bind(this); + }; + + onUpdate(key, value) { + this.setState({[key]: value}); + }; + aFunction(e){ + console.log(e); + console.log(e); + } + addStudent(e){ + e.preventDefault(); + e.persist(); + const firstName = this.state.firstName; + const middleName = this.state.middleName; + const lastName = this.state.lastName; + if(firstName==""){ + Bert.alert('Enter Fist Name', 'danger'); + } else if(middleName==""){ + Bert.alert('Enter Middle name!', 'danger'); + } else{ + addStudentManually.call({ + firstName: firstName, + middleName: middleName, + lastName: lastName + }, function (error, result) { + console.log(error); + console.log(result); + }); + } + } + render() { + return ( +
this.addStudent(e) }> + + First Name + this.onUpdate('firstName',e.target.value)} + /> + + + Middle Name + this.onUpdate('middleName',e.target.value)} + /> + + + Last Name + this.onUpdate('lastName',e.target.value)} + /> + + +
+ ); + }; + +}; diff --git a/imports/client/views/org/admin/students/index.js b/imports/client/views/org/admin/students/index.js new file mode 100644 index 0000000..20d1f09 --- /dev/null +++ b/imports/client/views/org/admin/students/index.js @@ -0,0 +1,54 @@ +// import { StudentDataController } from '/imports/client/views/org/admin/students/index' +import _ from 'lodash'; +import { + composeWithTracker, + compose, + composeAll + } from 'react-komposer'; +import { Loading } from '/imports/client/components/Loading'; + +import { Orgs } from '/imports/collections/orgs/index'; +import { Users } from '/imports/collections/users/index'; +import { StudentDataView } from './StudentDataView'; +import { Students } from '/imports/collections/students/methods' + + +const meteorTick = (props, onData) => { + + const handles = [ + Meteor.subscribe('users.current'), + Meteor.subscribe('orgs.current'), + Meteor.subscribe('users.forMyOrg') + ]; + + if(_.every(handles, (handle) => (handle.ready()) )) { + const user = Users.current(); + const org = Orgs.current(); + const students = Users.find({"role":"STUDENT"}).fetch(); + console.log(students); + onData(null, { + data: { + user: user, + org: org, + students:students + }, + }); + } + + return () => { + _.each(handles, (handle) => handle.stop() ); + }; +}; + + +const reduxTick = (props, onData) => { + onData(null, { + data: {} + }); +}; + + +export const StudentDataController = composeAll( + composeWithTracker(meteorTick, Loading), + compose(reduxTick, Loading), +)(StudentDataView); diff --git a/imports/client/views/org/app/module/navigation/AuthenticatedNavigation.js b/imports/client/views/org/app/module/navigation/AuthenticatedNavigation.js index bfe5a7e..9a2f16e 100644 --- a/imports/client/views/org/app/module/navigation/AuthenticatedNavigation.js +++ b/imports/client/views/org/app/module/navigation/AuthenticatedNavigation.js @@ -1,10 +1,11 @@ -import React, { Component } from 'react'; -import { browserHistory } from 'react-router'; -import { LinkContainer } from 'react-router-bootstrap'; +import React, { Component } from 'react'; +import { browserHistory } from 'react-router'; +import { LinkContainer } from 'react-router-bootstrap'; +import { logout } from '/imports/client/app/utils/loginMethods'; import { Navbar,Modal, Nav, NavItem, Glyphicon, - NavDropdown, MenuItem } from 'react-bootstrap'; -import { Meteor } from 'meteor/meteor'; + NavDropdown, MenuItem } from 'react-bootstrap'; +import { Meteor } from 'meteor/meteor'; const handleLogout = () => Meteor.logout(() => browserHistory.push('/login')); @@ -16,27 +17,32 @@ export class AuthenticatedNavigation extends Component { }; }; render(){ - const {user} = this.props.data; + const {user, org} = this.props.data; return( - + - - YOUNGDESK + {org.name} + -