Skip to content

Commit

Permalink
Add 'userType' field to Meteor.user Collection, add createAdmin view
Browse files Browse the repository at this point in the history
  • Loading branch information
malithjkmt committed May 3, 2016
1 parent 76ae7a0 commit 6f6d4c2
Show file tree
Hide file tree
Showing 14 changed files with 389 additions and 240 deletions.
2 changes: 1 addition & 1 deletion .idea/GTracker.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/libraries/meteor_packages_auto_import_browser.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

538 changes: 305 additions & 233 deletions .idea/workspace.xml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ aldeed:autoform
aldeed:collection2
yogiben:autoform-map
momentjs:moment
sergeyt:typeahead
1 change: 1 addition & 0 deletions .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ [email protected]
[email protected]
[email protected]
seba:[email protected]
sergeyt:[email protected]_8
[email protected]
[email protected]
[email protected]
Expand Down
1 change: 1 addition & 0 deletions client/head.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<head>
<title>GT2</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
2 changes: 1 addition & 1 deletion imports/startup/client/autoform.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
AutoForm.setDefaultTemplate('materialize');
AutoForm.setDefaultTemplate('materialize');
10 changes: 9 additions & 1 deletion imports/startup/client/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import '../../ui/pages/home/home.js';
import '../../ui/pages/feedback/feedback.js';
import '../../ui/pages/feedback/viewFeedback.js';
import '../../ui/pages/feedback/feedbackThreads.js';
import '../../ui/pages/admin/createAdmin.js';

import '../../ui/pages/footer.html';
import '../../ui/pages/master_layout.html';
Expand Down Expand Up @@ -47,7 +48,7 @@ Router.route('/', function () {


Router.route('/feedback/:townsmanID', function () {
var adminID = 'HxGqztWygWCxco4d5'; // admin ID should be accuired from DB ??? only one admin or multiple???????
var adminID = '6ekcRhqSWz6tijCKY'; // admin ID should be accuired from DB ??? only one admin or multiple???????
this.redirect('/feedback/' + this.params.townsmanID+ '/' + adminID);
});

Expand Down Expand Up @@ -75,6 +76,13 @@ Router.route('/feedbackThreads', function () {

});


Router.route('/createAdmin', function () {
this.layout('myLayout');
this.render('createAdmin');
this.render('nav', {to: 'nav'});
});

Router.route('/viewDrivers', function () {
this.layout('myLayout');
this.render('viewDrivers');
Expand Down
24 changes: 24 additions & 0 deletions imports/ui/pages/admin/createAdmin.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

<template name="createAdmin">

<div class="container">
<h3>Create Admin</h3>


<div class="row">
<div class="col s8">
<input class="form-control typeahead" name="userID" type="text"
placeholder="NIC"
autocomplete="off" spellcheck="off"
data-source="userIDs"/>
</div>
<div class="col s4">
<button id="makeAdmin" class="btn waves-effect waves-light" type="submit" name="action">Make Admin
<i class="material-icons right">send</i>
</button>
</div>
</div>


</div>
</template>
23 changes: 23 additions & 0 deletions imports/ui/pages/admin/createAdmin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import './createAdmin.html';


Template.createAdmin.helpers({
userIDs: function() {


return Meteor.users.find().fetch().map(function(it){ return it.username; });
}
});

Template.createAdmin.rendered = function() {
Meteor.typeahead.inject();
};


Template.createAdmin.events({
'click #makeAdmin'(event) {
// Prevent default browser form submit
console.log("clicked!!");
Meteor.call('test',"111111111");
}
});
1 change: 1 addition & 0 deletions imports/ui/pages/nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<li class="{{isActiveRoute regex='viewDrivers'}}"><a href="{{pathFor 'viewDrivers'}}">Drivers</a></li>
<li class="{{isActiveRoute regex='viewTrucks'}}"><a href="{{pathFor 'viewTrucks'}}">Trucks</a></li>
<li class="{{isActiveRoute regex='registerDriver'}}"><a href="{{pathFor 'registerDriver'}}">Register Driver</a></li>
<li class="{{isActiveRoute regex='createAdmin'}}"><a href="{{pathFor 'createAdmin'}}">Create Admin</a></li>
<li class="{{isActiveRoute regex='registerTruck'}}"><a href="{{pathFor 'registerTruck'}}">Register Truck</a></li>
<li class="{{isActiveRoute regex='registerTownsman'}}"><a href="{{pathFor 'registerTownsman'}}">Register Townsman</a></li>
<li>{{> atNavButton }}</li>
Expand Down
15 changes: 12 additions & 3 deletions lib/methods.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Meteor.methods({
/*"test":function(userID) {
"test":function(nic) {
//should print the user details if logged in, undefined otherwise.
console.log(userID);
}*/
console.log("test passed!!");
var townsman = Meteor.users.findOne({username:nic});
console.log(townsman);
console.log(townsman._id);



Meteor.users.update({_id:townsman._id},
{$set: { username: "999999999" }})
console.log(Meteor.users.findOne({_id:townsman._id}));
}
});
1 change: 0 additions & 1 deletion lib/useraccounts-configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,5 @@ AccountsTemplates.addFields([{
errStr: 'should be like: e.g: 0777203574',
}


]);
AccountsTemplates.addField(pwd);
6 changes: 6 additions & 0 deletions server/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import { Meteor } from 'meteor/meteor';

Meteor.startup(() => {
// code to run on server at startup
Accounts.onCreateUser(function(options, user) {
options.profile['userType'] = 'townsman';
console.log(options);
return user;
});



});

0 comments on commit 6f6d4c2

Please sign in to comment.