From 691a06c2fb64fe63bc2a888a4fbb976301c16de4 Mon Sep 17 00:00:00 2001 From: ajaiprakash Date: Thu, 6 Apr 2017 18:31:47 +0530 Subject: [PATCH] Staff profile --- client/stylesheets/custom.css | 6 +- imports/client/app/routes.js | 4 +- imports/client/views/nonOrg/enter/signup.css | 8 ++ imports/client/views/org/admin/AdminLayout.js | 12 +++ imports/client/views/org/admin/Header.js | 55 ++++++++--- imports/client/views/org/admin/header.css | 5 + imports/client/views/org/admin/parents/index.js | 66 +++++++++++++ .../client/views/org/admin/parents/parentsview.js | 108 +++++++++++++++++++++ .../views/org/admin/parents/view/ParentRow.js | 54 +++++++++++ .../views/org/admin/parents/view/ParentTable.js | 64 ++++++++++++ imports/client/views/org/admin/students/index.js | 1 + imports/collections/parents/methods.js | 81 +--------------- imports/collections/parents/publications.js | 12 +++ imports/server/collections.js | 3 + 14 files changed, 382 insertions(+), 97 deletions(-) create mode 100644 imports/client/views/org/admin/header.css create mode 100644 imports/client/views/org/admin/parents/index.js create mode 100644 imports/client/views/org/admin/parents/parentsview.js create mode 100644 imports/client/views/org/admin/parents/view/ParentRow.js create mode 100644 imports/client/views/org/admin/parents/view/ParentTable.js create mode 100644 imports/collections/parents/publications.js diff --git a/client/stylesheets/custom.css b/client/stylesheets/custom.css index 5ac24d9..de74dd4 100644 --- a/client/stylesheets/custom.css +++ b/client/stylesheets/custom.css @@ -1,6 +1,6 @@ body { - background: -webkit-linear-gradient(#00b395, #00cdaa); - background: -o-linear-gradient(#00b395, #00cdaa); - background: linear-gradient(#00b395, #00cdaa); + background: -webkit-linear-gradient(#00b395, #00b395); + background: -o-linear-gradient(#00b395, #00b395); + background: linear-gradient(#00b395, #00b395); } diff --git a/imports/client/app/routes.js b/imports/client/app/routes.js index cb6e497..79a04f0 100644 --- a/imports/client/app/routes.js +++ b/imports/client/app/routes.js @@ -23,7 +23,8 @@ import { importCsvController } from '/imports/client/views/org/impo //admin import { StudentDataController } from '/imports/client/views/org/admin/students/index' -import { staffViewController } from '/imports/client/views/org/admin/staff/index' +import { staffViewController } from '/imports/client/views/org/admin/staff/index' +import { ParentViewController } from '/imports/client/views/org/admin/parents/index' //students //teachers @@ -56,6 +57,7 @@ const getOrgRoutes = () => ( + diff --git a/imports/client/views/nonOrg/enter/signup.css b/imports/client/views/nonOrg/enter/signup.css index 67c98ee..ad08ad1 100644 --- a/imports/client/views/nonOrg/enter/signup.css +++ b/imports/client/views/nonOrg/enter/signup.css @@ -38,10 +38,18 @@ text-indent: 0px !important; } + +@media screen and (max-width:768px){ .container { /*width:1300px !important;*/ } +.Signup +{ + float:none; + clear:both; +} +} .signupView h1 { diff --git a/imports/client/views/org/admin/AdminLayout.js b/imports/client/views/org/admin/AdminLayout.js index 09b594c..0297a7d 100644 --- a/imports/client/views/org/admin/AdminLayout.js +++ b/imports/client/views/org/admin/AdminLayout.js @@ -57,6 +57,18 @@ export class AdminAppLayout extends Component { +
+
+ +
+ +
+
+
Parents Click to view
+
+ +
+
diff --git a/imports/client/views/org/admin/Header.js b/imports/client/views/org/admin/Header.js index df66b46..e2d24fc 100644 --- a/imports/client/views/org/admin/Header.js +++ b/imports/client/views/org/admin/Header.js @@ -5,6 +5,7 @@ import React, { Component } from 'react'; import { Link,browserHistory } from 'react-router'; import { FormGroup, FormControl,Glyphicon,Button } from 'react-bootstrap'; +import './header.css'; export class Header extends Component { @@ -25,29 +26,55 @@ export class Header extends Component { return (
+
-
- -
- + +
+
+
+
-
-
Students Click to view
+ +
+
Students
+

Click to view

-
+
+
-
- -
- + +
+
+
+
-
-
Teachers Click to view
+ +
+
Teachers
+

Click to view

- +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
Parents
+

Click to view

+
+
+
diff --git a/imports/client/views/org/admin/header.css b/imports/client/views/org/admin/header.css new file mode 100644 index 0000000..07c32cf --- /dev/null +++ b/imports/client/views/org/admin/header.css @@ -0,0 +1,5 @@ +.img-circle +{ + width: 70px; + height: 70px; +} diff --git a/imports/client/views/org/admin/parents/index.js b/imports/client/views/org/admin/parents/index.js new file mode 100644 index 0000000..91ae565 --- /dev/null +++ b/imports/client/views/org/admin/parents/index.js @@ -0,0 +1,66 @@ +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 { Parents } from '/imports/collections/parents/index'; +import { ParentsView } from './parentsview'; + + + +const meteorTick = (props, onData) => { + + const handles = [ + Meteor.subscribe('users.current'), + Meteor.subscribe('orgs.current'), + Meteor.subscribe('users.forMyOrg'), + Meteor.subscribe('parent.forMyOrg'), + ]; + + if(_.every(handles, (handle) => (handle.ready()) )) { + const user = Users.current(); + const org = Orgs.current(); + console.log("parents"); + parent = Users.find({"role":"PARENT"}).fetch() ? Users.find({"role":"PARENT"}).fetch() : ""; + console.log(Users.find({"role":"PARENT"}).fetch()); + parentData = Parents.find().fetch() ? Parents.find().fetch() : ""; + console.log("parentData"); + console.log(parentData); + for(var i=0; i< parent.length; i++){ + for(var j=0; j< parentData.length; j++){ + if(parent[i]._id == parentData[j].userId){ + parent[i].relationship = parentData[j].relationship; + } + } + } + onData(null, { + data: { + user: user, + org: org, + parent: parent + }, + }); + } + + return () => { + _.each(handles, (handle) => handle.stop() ); + }; +}; + + +const reduxTick = (props, onData) => { + onData(null, { + data: {} + }); +}; + + +export const ParentViewController = composeAll( + composeWithTracker(meteorTick, Loading), + compose(reduxTick, Loading), +)(ParentsView); diff --git a/imports/client/views/org/admin/parents/parentsview.js b/imports/client/views/org/admin/parents/parentsview.js new file mode 100644 index 0000000..b7a7f38 --- /dev/null +++ b/imports/client/views/org/admin/parents/parentsview.js @@ -0,0 +1,108 @@ +import _ from 'lodash'; +import { Meteor } from 'meteor/meteor'; + +import React, { Component } from 'react'; +import { Link,browserHistory } from 'react-router'; +import { FormGroup, + FormControl,Glyphicon,Button } from 'react-bootstrap'; +import { Header } from '../Header'; +import { AdminSidebar } from '../Sidebar' +import { AdminBreadcrumb } from '../Breadcrumb' +import { ParentTable } from './view/ParentTable' + + +export class ParentsView extends Component { + + constructor(props) { + super(props); + this.state = { + + }; + this.onUpdate = this.onUpdate.bind(this); + }; + + onUpdate(key, value) { + this.setState({[key]: value}); + }; + + render() { + const {user, org, parent} = this.props.data; + return ( +
+
+
+ +
+ + +
+
+
+
+ + {/* + */} +
+
+
+
+
+ +
+
+ Advanced Search +
    +
  • +
+
+ +
+
+
+ this.onUpdate('firstNameSearch',e.target.value)} + placeholder="First Name" + /> +
+ +
+
+
+
+
+
+
+ this.onUpdate('lastNameSearch',e.target.value)} + placeholder="Last Name" /> +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+ ); + }; + + +}; diff --git a/imports/client/views/org/admin/parents/view/ParentRow.js b/imports/client/views/org/admin/parents/view/ParentRow.js new file mode 100644 index 0000000..130b080 --- /dev/null +++ b/imports/client/views/org/admin/parents/view/ParentRow.js @@ -0,0 +1,54 @@ +import _ from 'lodash'; +import { Meteor } from 'meteor/meteor'; + +import React, { Component } from 'react'; +import { Link,browserHistory } from 'react-router'; +import { FormGroup, + FormControl,Glyphicon,Button } from 'react-bootstrap'; + + + export class ParentRow extends Component { + + constructor(props) { + super(props); + this.state = { + + }; + this.onUpdate = this.onUpdate.bind(this); + }; + + onUpdate(key, value) { + this.setState({[key]: value}); + }; + + render() { + const {parent} = this.props; + if(parent.firstName){ + return ( + + {parent.firstName} + {parent.relationship} {/* relationship doesnt reflect here */} + Active + + + + + ); + }else { + return null; + } + + }; + + }; diff --git a/imports/client/views/org/admin/parents/view/ParentTable.js b/imports/client/views/org/admin/parents/view/ParentTable.js new file mode 100644 index 0000000..0b7a34d --- /dev/null +++ b/imports/client/views/org/admin/parents/view/ParentTable.js @@ -0,0 +1,64 @@ +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 {moment} from 'meteor/momentjs:moment' +import {ParentRow} from './ParentRow' + +export class ParentTable extends Component { + + constructor(props) { + super(props); + this.state = { + show: false + }; + this.onUpdate = this.onUpdate.bind(this); + }; + onUpdate(key, value) { + this.setState({[key]: value}); + }; + + render() { + return ( +
+
+
Parent Details
+
+
    +
  • +
  • +
+
+
+ + + + + + + + + + + { + this.props.parent.map(function(parent, i) + { + return( + + ) + }) + } + +
First NameRelationshipStatusActions
+
+ ); + }; + +}; diff --git a/imports/client/views/org/admin/students/index.js b/imports/client/views/org/admin/students/index.js index f0d6b76..6a007fb 100644 --- a/imports/client/views/org/admin/students/index.js +++ b/imports/client/views/org/admin/students/index.js @@ -26,6 +26,7 @@ const meteorTick = (props, onData) => { const user = Users.current(); const org = Orgs.current(); students = Users.find({"role":"STUDENT"}).fetch() ? Users.find({"role":"STUDENT"}).fetch() : ""; + console.log(students); studentData = Students.find().fetch() ? Students.find().fetch() : ""; for(var i=0; i< students.length; i++){ for(var j=0; j< studentData.length; j++){ diff --git a/imports/collections/parents/methods.js b/imports/collections/parents/methods.js index 9f0728c..d9ac05c 100644 --- a/imports/collections/parents/methods.js +++ b/imports/collections/parents/methods.js @@ -8,8 +8,8 @@ import { Bert } from 'meteor/themeteorchef:bert'; import { Users } from '/imports/collections/users/index'; import { Students } from '/imports/collections/students/index'; import { Orgs } from '/imports/collections/orgs/index'; -export const studentMethods = new ValidatedMethod({ - name: 'student.method', +export const parentMethods = new ValidatedMethod({ + name: 'parent.method', validate: new SimpleSchema({ itemId: { type: String }, @@ -20,80 +20,3 @@ export const studentMethods = new ValidatedMethod({ }, }); - -export const addStudentManually = new ValidatedMethod({ - name: 'student.addManually', - - validate: new SimpleSchema({ - admissionId: { type: String }, - firstName: { type: String }, - middleName: { type: String }, - lastName: { type: String }, - email: { type: String }, - dob: { type: String }, - formattedDob: { type: String }, - gender: { type: String }, - rollNo: { type: String }, - studentclass: { type: String }, - section: { type: String }, - community: { type: String }, - bloodGroup: { type: String }, - phone: { type: String }, - address: { type: String }, - city: { type: String }, - state: { type: String }, - parentName: { type: String }, - parentEmail: { type: String }, - relation: { type: String }, - profession: { type: String }, - parentGender: { type: String }, - parentPhone: { type: String }, - parentAddress: { type: String }, - parentCity: { type: String }, - parentState: { type: String }, - parentZipcode: { type: String }, - }).validator(), - - run(data) { - console.log("data"); - console.log(data); - const user = Users.findOne({_id: this.userId}); - orgId = user.orgId; - newStudentId = Users.insert({ - emails: [data.email], - username: firstName, - firstName: firstName, - middleName: middleName, - lastName: lastName, - orgId: orgId, - role: 'STUDENT' - }); - newParentId = Users.insert({ - emails: [data.parentEmail], - username: parentName, - firstName: parentName, - orgId: orgId, - role: 'PARENT' - }); - console.log("newUserId"); - console.log(newUserId); - if(newUserId){ - Students.insert({ - userId: newUserId, - orgId: orgId, - admissionId: data.admissionId, - address: data.address, - gender: data.gender, - dob: data.dob, - rollNo: data.rollNo, - class: data.studentclass, - section: data.section, - bloodGroup: data.bloodGroup, - community: data.community, - - }); - } - return {newUserId}; - }, - -}); diff --git a/imports/collections/parents/publications.js b/imports/collections/parents/publications.js new file mode 100644 index 0000000..bba437b --- /dev/null +++ b/imports/collections/parents/publications.js @@ -0,0 +1,12 @@ +import { Meteor } from 'meteor/meteor'; +import { check, Match } from 'meteor/check' + +import { Orgs } from '/imports/collections/orgs/index'; +import { Users } from '/imports/collections/users/index'; +import { Parents } from '/imports/collections/parents/index'; + +Meteor.publish('parent.forMyOrg', function () { + const user = Users.findOne({_id: this.userId}); + if(!user) return []; + return Parents.find({orgId: user.orgId}); +}); diff --git a/imports/server/collections.js b/imports/server/collections.js index e4c0235..62dc553 100644 --- a/imports/server/collections.js +++ b/imports/server/collections.js @@ -10,3 +10,6 @@ import '/imports/collections/students/serverCsvUpload'; import '/imports/collections/staff/methods'; import '/imports/collections/staff/publications'; import '/imports/collections/staff/serverCsvUpload'; + +import '/imports/collections/parents/methods'; +import '/imports/collections/parents/publications'; -- 2.0.0