basic functionality for users
This commit is contained in:
parent
4e19f83006
commit
cb8b0d0e11
7
labs/meteor-client/client/stylesheets/style.css
Normal file → Executable file
7
labs/meteor-client/client/stylesheets/style.css
Normal file → Executable file
@ -91,4 +91,11 @@ margin-bottom: 10px;
|
||||
.load-more:hover {
|
||||
text-decoration: none;
|
||||
background: rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.raiseHand {
|
||||
}
|
||||
.lowerHand{
|
||||
}
|
||||
.kickUser{
|
||||
}
|
19
labs/meteor-client/client/views/users/user_item.html
Normal file → Executable file
19
labs/meteor-client/client/views/users/user_item.html
Normal file → Executable file
@ -2,6 +2,25 @@
|
||||
<div class="post">
|
||||
<div class="post-content">
|
||||
<h3><a href="{{url}}">{{title}}</a><span>{{domain}}</span></h3>
|
||||
<p>Username: {{user.name}}</p>
|
||||
<p>{{user.externUserId}}</p>
|
||||
<hr/>
|
||||
<input type="button" class="raiseHand" id="{{user.externUserId}}" value="Raise hand" />
|
||||
|
||||
{{#if user.handRaised}}
|
||||
<p>Hand is raised</p>
|
||||
{{/if}}
|
||||
|
||||
<p>Teacher controls:
|
||||
{{#if user.handRaised}}
|
||||
<input type="button" class="lowerHand" id="{{user.externUserId}}" value="Answer Question"/>
|
||||
{{else}}
|
||||
<input type="button" class="lowerHand" id="{{user.externUserId}}" value="Answer Question" disabled/>
|
||||
{{/if}}
|
||||
</p>
|
||||
|
||||
<input type="button" class="kickUser" id="{{user.externUserId}}" value="Kick from Call" />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
55
labs/meteor-client/client/views/users/user_item.js
Normal file → Executable file
55
labs/meteor-client/client/views/users/user_item.js
Normal file → Executable file
@ -3,5 +3,58 @@ Template.userItem.helpers({
|
||||
var a = document.createElement('a');
|
||||
a.href = this.url;
|
||||
return a.hostname;
|
||||
}
|
||||
},
|
||||
});
|
||||
Template.userItem.events({
|
||||
'click input.raiseHand': function(event){
|
||||
Users.update({_id:this._id},
|
||||
{
|
||||
$set: {"user.handRaised": true}
|
||||
}
|
||||
);
|
||||
console.log (Users);
|
||||
},
|
||||
'click input.lowerHand': function(event){
|
||||
Users.update({_id:this._id},
|
||||
{
|
||||
$set: {"user.handRaised": false}
|
||||
}
|
||||
);
|
||||
console.log (Users);
|
||||
},
|
||||
'click input.kickUser': function(event){
|
||||
var user = this;
|
||||
var meeting = Meetings.findOne({meetingName:this.meetingId});
|
||||
|
||||
if(user !== null && meeting !== null) {
|
||||
// find users index. I couldn't get indexOf() working because the array is of objects
|
||||
var index = -1;
|
||||
for(var i = 0; i < meeting.users.length; i++){
|
||||
if(meeting.users[i].userId == user.user.externUserId){
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(index >= 0) {
|
||||
// remove user from meeting
|
||||
meeting.users.splice(index, 1);
|
||||
// update meeting
|
||||
Meetings.update({_id:meeting._id},
|
||||
{
|
||||
$set:
|
||||
{
|
||||
users: meeting.users
|
||||
}
|
||||
}
|
||||
);
|
||||
// remove meeting from user
|
||||
Users.update({_id:this._id},
|
||||
{
|
||||
$set: {"meetingId": null}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
10
labs/meteor-client/client/views/users/users_list.html
Normal file → Executable file
10
labs/meteor-client/client/views/users/users_list.html
Normal file → Executable file
@ -1,7 +1,11 @@
|
||||
<template name="usersList">
|
||||
<div class="posts">
|
||||
{{#each users}}
|
||||
{{> userItem}}
|
||||
{{/each}}
|
||||
{{#each getMeetings}}
|
||||
<p>Meeting Name: {{meetingName}}</p>
|
||||
<p>Users in meeting:</p>
|
||||
{{#each getUsersInMeeting meetingName}}
|
||||
{{> userItem}}
|
||||
{{/each}}
|
||||
{{/each}}
|
||||
</div>
|
||||
</template>
|
17
labs/meteor-client/client/views/users/users_list.js
Normal file → Executable file
17
labs/meteor-client/client/views/users/users_list.js
Normal file → Executable file
@ -17,5 +17,20 @@ var postsData = [
|
||||
];
|
||||
|
||||
Template.usersList.helpers({
|
||||
users: postsData
|
||||
users: function() {
|
||||
console.log (Users);
|
||||
//console.log
|
||||
return Users.find();
|
||||
},
|
||||
|
||||
getMeetings: function(){
|
||||
console.log("meetings--------------");
|
||||
console.log(Meetings);
|
||||
return Meetings.find();
|
||||
},
|
||||
|
||||
getUsersInMeeting: function(meetingName){
|
||||
return Users.find({meetingId: meetingName});
|
||||
}
|
||||
|
||||
});
|
||||
|
1
labs/meteor-client/collections/users.js
Normal file → Executable file
1
labs/meteor-client/collections/users.js
Normal file → Executable file
@ -1,4 +1,5 @@
|
||||
Users = new Meteor.Collection('bbb_users');
|
||||
Meetings = new Meteor.Collection('meetings');
|
||||
|
||||
Meteor.methods({
|
||||
authenticate: function(auth) {
|
||||
|
25
labs/meteor-client/server/collection-permissions.js
Executable file
25
labs/meteor-client/server/collection-permissions.js
Executable file
@ -0,0 +1,25 @@
|
||||
SetCollectionPermissions = function() {
|
||||
|
||||
/*Users.allow({
|
||||
'insert': function(userId, doc){
|
||||
return userId;
|
||||
},
|
||||
'update': function(userId, doc, fields, modifier){
|
||||
return userId;
|
||||
},
|
||||
|
||||
});*/
|
||||
|
||||
/*Meetings.users.allow({
|
||||
'insert': function(userId, doc){
|
||||
return Roles.userIsInRole(Meteor.user(), ["admin"]);
|
||||
},
|
||||
'update': function (userId, doc, fields, modifier) {
|
||||
return Roles.userIsInRole(Meteor.user(), ["admin"]) && doc.username !== "Admin";
|
||||
},
|
||||
remove: function(userId, doc) {
|
||||
return Roles.userIsInRole(userId, ["admin"]) && doc.username !== "Admin";
|
||||
}
|
||||
});*/
|
||||
return 0;
|
||||
}
|
120
labs/meteor-client/server/insert-startup-data.js
Executable file
120
labs/meteor-client/server/insert-startup-data.js
Executable file
@ -0,0 +1,120 @@
|
||||
CreateSeedData = function() {
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Create Seed Data
|
||||
//
|
||||
|
||||
if(Meetings.find().count() === 0) {
|
||||
console.log("recreating meeting");
|
||||
Meetings.insert({
|
||||
meetingName: "Classroom1",
|
||||
users: [
|
||||
{userId: "24d1tjpraogv"},
|
||||
{userId: "24d16kfdmbd4"},
|
||||
{userId: "1111k54k67s4"}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
if (Users.find().count() === 0) {
|
||||
Users.insert({
|
||||
meetingId: "Classroom1",
|
||||
user: {
|
||||
handRaised: false,
|
||||
phoneUser: false,
|
||||
presenter: false,
|
||||
externUserId: "24d1tjpraogv",
|
||||
webcamStream: "",
|
||||
userId: "24d1tjpraogv",
|
||||
name: "RED",
|
||||
permissions: {
|
||||
disablePrivChat: false,
|
||||
disableCam: false,
|
||||
disableMic: false,
|
||||
lockedLayout: false,
|
||||
disablePubChat: false
|
||||
},
|
||||
hasStream: false,
|
||||
role: "MODERATOR",
|
||||
locked: false,
|
||||
voiceUser: {
|
||||
talking: false,
|
||||
webUserId: "24d1tjpraogv",
|
||||
joined: false,
|
||||
muted: false,
|
||||
userId: "24d1tjpraogv",
|
||||
callerNum: "RED",
|
||||
callerName: "RED",
|
||||
locked: false
|
||||
},
|
||||
listenOnly: false
|
||||
}
|
||||
});
|
||||
Users.insert({
|
||||
meetingId: "Classroom1",
|
||||
user: {
|
||||
handRaised: false,
|
||||
phoneUser: false,
|
||||
presenter: false,
|
||||
externUserId: "24d16kfdmbd4",
|
||||
webcamStream: "",
|
||||
userId: "24d16kfdmbd4",
|
||||
name: "BLUE",
|
||||
permissions: {
|
||||
disablePrivChat: false,
|
||||
disableCam: false,
|
||||
disableMic: false,
|
||||
lockedLayout: false,
|
||||
disablePubChat: false
|
||||
},
|
||||
hasStream: false,
|
||||
role: "USER",
|
||||
locked: false,
|
||||
voiceUser: {
|
||||
talking: false,
|
||||
webUserId: "24d16kfdmbd4",
|
||||
joined: false,
|
||||
muted: false,
|
||||
userId: "24d16kfdmbd4",
|
||||
callerNum: "BLUE",
|
||||
callerName: "BLUE",
|
||||
locked: false
|
||||
},
|
||||
listenOnly: false
|
||||
}
|
||||
});
|
||||
Users.insert({
|
||||
meetingId: "Classroom1",
|
||||
user: {
|
||||
handRaised: false,
|
||||
phoneUser: false,
|
||||
presenter: false,
|
||||
externUserId: "1111k54k67s4",
|
||||
webcamStream: "",
|
||||
userId: "1111k54k67s4",
|
||||
name: "Joe",
|
||||
permissions: {
|
||||
disablePrivChat: false,
|
||||
disableCam: false,
|
||||
disableMic: false,
|
||||
lockedLayout: false,
|
||||
disablePubChat: false
|
||||
},
|
||||
hasStream: false,
|
||||
role: "USER",
|
||||
locked: false,
|
||||
voiceUser: {
|
||||
talking: false,
|
||||
webUserId: "1111k54k67s4",
|
||||
joined: false,
|
||||
muted: false,
|
||||
userId: "1111k54k67s4",
|
||||
callerNum: "Joe",
|
||||
callerName: "Joe",
|
||||
locked: false
|
||||
},
|
||||
listenOnly: false
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
16
labs/meteor-client/server/publish.js
Executable file
16
labs/meteor-client/server/publish.js
Executable file
@ -0,0 +1,16 @@
|
||||
PublishCollections = function() {
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Publish
|
||||
//
|
||||
/*
|
||||
// publish Users
|
||||
Meteor.publish("Users", function () {
|
||||
return Orders.find();
|
||||
});
|
||||
|
||||
// publish Meetings
|
||||
Meteor.publish("Meetings", function () {
|
||||
return Orders.find();
|
||||
});*/
|
||||
}
|
25
labs/meteor-client/server/server.js
Executable file
25
labs/meteor-client/server/server.js
Executable file
@ -0,0 +1,25 @@
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Startup
|
||||
//
|
||||
|
||||
Meteor.startup(function () {
|
||||
console.log('server start');
|
||||
// cleanup collections
|
||||
remove_all_data = false;
|
||||
|
||||
if(remove_all_data){
|
||||
Meteor.users.remove({});
|
||||
Users.remove({});
|
||||
Meetings.remove({});
|
||||
}
|
||||
|
||||
// Add seed data if first time server starting
|
||||
CreateSeedData();
|
||||
|
||||
// Publish data collections
|
||||
PublishCollections();
|
||||
|
||||
// Set collection permissions
|
||||
SetCollectionPermissions();
|
||||
|
||||
});
|
Loading…
Reference in New Issue
Block a user