bigbluebutton-Github/labs/meteor-client/client/views/users/user_item.coffee

122 lines
4.6 KiB
CoffeeScript
Raw Normal View History

2014-06-12 22:08:55 +08:00
Template.userItem.helpers
domain: ->
a = document.createElement("a")
a.href = @url
a.hostname
2014-06-13 03:12:09 +08:00
isUserModerator: =>
2014-06-14 00:22:30 +08:00
id = Session.get("userId") or "a1a1a1a1a1a1"
(Meteor.Users.findOne {"user.userId": id, "user.role": "MODERATOR"})?
2014-06-12 22:08:55 +08:00
# using handlebars' {{equals}} wasn't working for these some reason, so heres a simple JS function to do it
compareUserIds: (u1, u2) ->
u1 is u2
Template.userItem.events
2014-06-13 03:12:09 +08:00
"click .raiseHand": (event) ->
Meteor.Users.update {_id: @_id},{ $set:{ "user.handRaised": true}}
2014-06-12 22:08:55 +08:00
2014-06-13 03:12:09 +08:00
"click .disableCam": (event) ->
Meteor.Users.update {_id: @_id}, {$set:{ "user.sharingVideo": false}}
2014-06-12 22:08:55 +08:00
2014-06-13 03:12:09 +08:00
"click .disableMic": (event) ->
Meteor.Users.update { _id: @_id},{ $set:{"user.sharingAudio": false}}
2014-06-12 22:08:55 +08:00
2014-06-13 03:12:09 +08:00
"click .enableMic": (event) ->
Meteor.Users.update {_id: @_id}, {$set:{"user.sharingAudio": true}}
2014-06-12 22:08:55 +08:00
2014-06-13 03:12:09 +08:00
"click .enableCam": (event) ->
Meteor.Users.update {_id: @_id}, {$set:{ "user.sharingVideo": true}}
2014-06-12 22:08:55 +08:00
2014-06-13 03:12:09 +08:00
"click .lowerHand": (event) ->
Meteor.Users.update {_id: @_id}, {$set:{ "user.handRaised": false}}
2014-06-12 22:08:55 +08:00
2014-06-13 03:12:09 +08:00
"click .setPresenter": (event) ->
#
# Not the best way to go about doing this
# The meeting should probably know about the presenter instead of the individual user
#
2014-06-12 22:08:55 +08:00
# only perform operation if user is not already presenter, prevent extra DB work
2014-06-17 23:46:49 +08:00
unless @isPresenter
2014-06-12 22:08:55 +08:00
# from new user, find meeting
theUser = Meteor.Users.findOne(_id:@_id)
2014-06-17 23:46:49 +08:00
m = Meetings.findOne(meetingName: theUser.meetingId)
2014-06-12 22:08:55 +08:00
# unset old user as presenter
if m?
u = Meteor.Users.findOne(
2014-06-12 22:08:55 +08:00
meetingId: m.meetingName
"user.presenter": true
)
if u?
Meteor.Users.update {_id: u._id},{ $set:{ "user.presenter": false}}
2014-06-17 23:46:49 +08:00
# set newly selected user as presenter
Meteor.Users.update {_id: @_id},{$set:{"user.presenter": true}}
2014-06-12 22:08:55 +08:00
2014-06-13 03:12:09 +08:00
"click .kickUser": (event) ->
2014-06-12 22:08:55 +08:00
#
# Add:
# When user is blown away, if they were presenter remove that from meeting (if kicking the presenter is even possible?)
#
user = Meteor.Users.findOne(_id:@_id)
2014-06-17 23:08:07 +08:00
meeting = Meetings.findOne(meetingName:user.meetingId)
2014-06-12 22:08:55 +08:00
if user? and meeting?
# find users index. I couldn't get indexOf() working
2014-06-12 22:08:55 +08:00
index = -1
i = 0
while i < meeting.users.length
if meeting.users[i].userId is user.user.externUserId
index = i
break
i++
if index >= 0
meeting.users.splice index, 1 # remove user from meeting
Meetings.update # update meeting
_id: meeting._id
,
$set:
users: meeting.users
Meteor.Users.update # remove meeting from user
2014-06-12 22:08:55 +08:00
_id: @_id
,
$set:
meetingId: null
Template.displayOtherUsersControls.events
"click .disableMic": (event) ->
event.stopImmediatePropagation()
u = Meteor.Users.findOne {"user.externUserId": event.currentTarget.id}
Meteor.Users.update {_id: u._id}, {$set: {"user.sharingAudio": false}}
"click .enableMic": (event) ->
event.stopImmediatePropagation()
u = Meteor.Users.findOne {"user.externUserId": event.currentTarget.id}
Meteor.Users.update {_id: u._id}, {$set: {"user.sharingAudio": true}}
"click .disableCam": (event) ->
event.stopImmediatePropagation()
u = Meteor.Users.findOne {"user.externUserId": event.currentTarget.id}
Meteor.Users.update {_id: u._id}, {$set: {"user.sharingVideo": false}}
"click .enableCam": (event) ->
event.stopImmediatePropagation()
u = Meteor.Users.findOne {"user.externUserId": event.currentTarget.id}
Meteor.Users.update {_id: u._id}, {$set: {"user.sharingVideo": true}}
Template.displayOwnControls.events
"click .disableMic": (event) ->
event.stopImmediatePropagation()
u = Meteor.Users.findOne {"user.externUserId": event.currentTarget.id}
Meteor.Users.update {_id: u._id}, {$set: {"user.sharingAudio": false}}
"click .enableMic": (event) ->
event.stopImmediatePropagation()
u = Meteor.Users.findOne {"user.externUserId": event.currentTarget.id}
Meteor.Users.update {_id: u._id}, {$set: {"user.sharingAudio": true}}
"click .disableCam": (event) ->
event.stopImmediatePropagation()
u = Meteor.Users.findOne {"user.externUserId": event.currentTarget.id}
Meteor.Users.update {_id: u._id}, {$set: {"user.sharingVideo": false}}
"click .enableCam": (event) ->
event.stopImmediatePropagation()
u = Meteor.Users.findOne {"user.externUserId": event.currentTarget.id}
Meteor.Users.update {_id: u._id}, {$set: {"user.sharingVideo": true}}