From f9d67947d7835e5cdd6ae3d1677ea97be99fb4e4 Mon Sep 17 00:00:00 2001 From: Marcelo Schmidt <marcelo.schmidt@konecty.com> Date: Thu, 27 Aug 2015 18:18:32 -0300 Subject: [PATCH] Multiple small changes; --- client/lib/RoomManager.coffee | 2 +- client/stylesheets/base.less | 40 ++++++- client/stylesheets/global/_variables.less | 2 +- client/views/admin/users/adminUsers.coffee | 12 +- client/views/app/room.coffee | 19 +-- client/views/app/userInfo.html | 128 +++++++++++---------- server/publications/fullUserData.coffee | 44 +++++++ server/publications/fullUsers.coffee | 38 ------ 8 files changed, 161 insertions(+), 124 deletions(-) create mode 100644 server/publications/fullUserData.coffee delete mode 100644 server/publications/fullUsers.coffee diff --git a/client/lib/RoomManager.coffee b/client/lib/RoomManager.coffee index 9c0d6348ae7..1edc98059b9 100644 --- a/client/lib/RoomManager.coffee +++ b/client/lib/RoomManager.coffee @@ -84,7 +84,7 @@ Meteor.startup -> if type in ['c', 'p'] query.name = name else if type is 'd' - query.usernames = $all: [Meteor.user().username, name] + query.usernames = $all: [Meteor.user()?.username, name] room = ChatRoom.findOne query, { reactive: false } diff --git a/client/stylesheets/base.less b/client/stylesheets/base.less index 253c49e1030..bf867eebf5f 100644 --- a/client/stylesheets/base.less +++ b/client/stylesheets/base.less @@ -2838,7 +2838,45 @@ a.github-fork { h3 { font-size: 24px; margin-bottom: 8px; - line-height: 22px; + line-height: 27px; + text-overflow: ellipsis; + width: 100%; + overflow: hidden; + white-space: nowrap; + + i:after { + content: " "; + display: inline-block; + width: 8px; + height: 8px; + border-radius: 4px; + vertical-align: middle; + } + + i.status-offline { + &:after { + border-color: darken(@status-offline, 5%); + background-color: @status-offline; + } + } + i.status-online { + &:after { + border-color: darken(@status-online, 5%); + background-color: @status-online; + } + } + i.status-away { + &:after { + border-color: darken(@status-away, 5%); + background-color: @status-away; + } + } + i.status-busy { + &:after { + border-color: darken(@status-busy, 5%); + background-color: @status-busy; + } + } } p { line-height: 18px; diff --git a/client/stylesheets/global/_variables.less b/client/stylesheets/global/_variables.less index 06715e4cefd..c8bf1d2587a 100644 --- a/client/stylesheets/global/_variables.less +++ b/client/stylesheets/global/_variables.less @@ -25,6 +25,6 @@ @info-font-color: #AAAAAA; @status-online: #35AC19; -@status-offline: rgba(255, 255, 255, 0.35); +@status-offline: rgba(150, 150, 150, 0.50); @status-busy: #D30230; @status-away: #fcb316; diff --git a/client/views/admin/users/adminUsers.coffee b/client/views/admin/users/adminUsers.coffee index bb9828828e3..b336d33aebf 100644 --- a/client/views/admin/users/adminUsers.coffee +++ b/client/views/admin/users/adminUsers.coffee @@ -10,9 +10,9 @@ Template.adminUsers.helpers arrowPosition: -> return 'left' unless Session.equals('flexOpened', true) userData: -> - return Meteor.users.findOne Session.get 'adminUsersSelected' + return Meteor.users.findOne Session.get 'adminSelectedUser' userChannels: -> - return ChatSubscription.find({ "u._id": Session.get 'adminUsersSelected' }, { fields: { rid: 1, name: 1, t: 1 }, sort: { t: 1, name: 1 } }).fetch() + return ChatSubscription.find({ "u._id": Session.get 'adminSelectedUser' }, { fields: { rid: 1, name: 1, t: 1 }, sort: { t: 1, name: 1 } }).fetch() isLoading: -> return 'btn-loading' unless Template.instance().ready?.get() hasMore: -> @@ -42,12 +42,12 @@ Template.adminUsers.onCreated -> @autorun -> filter = instance.filter.get() limit = instance.limit.get() - subscription = instance.subscribe 'fullUsers', filter, limit + subscription = instance.subscribe 'fullUserData', filter, limit instance.ready.set subscription.ready() @autorun -> - if Session.get 'adminUsersSelected' - channelSubscription = instance.subscribe 'userChannels', Session.get 'adminUsersSelected' + if Session.get 'adminSelectedUser' + channelSubscription = instance.subscribe 'userChannels', Session.get 'adminSelectedUser' @users = -> filter = _.trim instance.filter?.get() @@ -83,7 +83,7 @@ Template.adminUsers.events 'click .user-info': (e) -> e.preventDefault() - Session.set 'adminUsersSelected', $(e.currentTarget).data('id') + Session.set 'adminSelectedUser', $(e.currentTarget).data('id') Session.set 'flexOpened', true 'click .info-tabs a': (e) -> diff --git a/client/views/app/room.coffee b/client/views/app/room.coffee index 262c137014e..e027c67fb0f 100644 --- a/client/views/app/room.coffee +++ b/client/views/app/room.coffee @@ -74,15 +74,7 @@ Template.room.helpers flexUserInfo: -> username = Session.get('showUserInfo') - - if Meteor.user()?.admin is true - userData = _.extend { username: String(username) }, Meteor.users.findOne { username: String(username) } - else - userData = { - username: String(username) - } - - return userData + return Meteor.users.findOne({ username: String(username) }) or { username: String(username) } userStatus: -> roomData = Session.get('roomData' + this._id) @@ -639,11 +631,10 @@ Template.room.onCreated -> this.showUsersOffline = new ReactiveVar false this.atBottom = true - # If current user is admin, subscribe to full user data - if Meteor.user()?.admin is true - Tracker.autorun -> - if Session.get('showUserInfo') and not Meteor.users.findOne Session.get 'showUserInfo' - Meteor.subscribe 'fullUsers', Session.get('showUserInfo'), 1 + self = @ + + @autorun -> + self.subscribe 'fullUserData', Session.get('showUserInfo'), 1 Template.room.onRendered -> FlexTab.check() diff --git a/client/views/app/userInfo.html b/client/views/app/userInfo.html index 45b6f9b5b94..ea43c816b0e 100644 --- a/client/views/app/userInfo.html +++ b/client/views/app/userInfo.html @@ -1,73 +1,75 @@ <template name="userInfo"> - {{#with user}} - <div class="about clearfix"> - {{#if ../video}} - {{#if videoActive}} - {{#if rtcLayout3}} - <div id='fullscreendiv' style="width: 100%"> - <video id='videoremote' class="video-remote" src="{{remoteVideoUrl}}" style="width: 100%; align-items: center; margin-bottom: 10px; background-color: #000; transition: width 2s, height 2s, top 2s, left 2s, transform 2s;" autoplay></video> - <video id='videoself' class="video-self" src="{{selfVideoUrl}}" style="width: 250px; position: absolute; top: 21px; right: 31px; border: 1px solid #FFF; background-color: #000; transition: width 2s, height 2s, top 2s, left 2s, transform 2s;" autoplay muted></video> - </div> - {{/if}} - {{#if rtcLayout2}} - <div style="display: flex; flex-direction: row; align-items: center; width: 800px; height: 350px"> - <video id="videoremote" class="video-remote" src="{{remoteVideoUrl}}" style="flex: 1 0; min-width: 380px; height: 285px; margin: 10px; background-color: #000;" autoplay></video> - <video id="videoself" class="video-self" src="{{selfVideoUrl}}" style="flex: 1 0; min-width: 380px; height: 285px; margin: 10px; background-color: #000;" autoplay muted></video> - </div> - {{/if}} - {{#if rtcLayout1}} - <div style="display: flex; flex-direction: column; align-items: center; width: 360px; height: 500px"> - <video class="video-remote" src="{{remoteVideoUrl}}" style="flex: 1 1; width: 320px; margin: 10px; background-color: #000;" autoplay></video> - <video class="video-self" src="{{selfVideoUrl}}" style="flex: 1 1; width: 320px; margin: 10px; background-color: #000;" autoplay muted></video> - </div> - {{/if}} - {{#if noRtcLayout}} - <div> - <video class="video-remote" src="{{remoteVideoUrl}}" style="width: 100%; margin-bottom: 10px; background-color: #000; transition: width 2s, height 2s, top 2s, left 2s, transform 2s;" autoplay></video> - <video class="video-self" src="{{selfVideoUrl}}" style="width: 100px; position: absolute; top: 21px; right: 21px; border: 1px solid #FFF; background-color: #000; transition: width 2s, height 2s, top 2s, left 2s, transform 2s;" autoplay muted></video> + {{#if $.Session.get 'showUserInfo'}} + {{#with user}} + <div class="about clearfix"> + {{#if ../video}} + {{#if videoActive}} + {{#if rtcLayout3}} + <div id='fullscreendiv' style="width: 100%"> + <video id='videoremote' class="video-remote" src="{{remoteVideoUrl}}" style="width: 100%; align-items: center; margin-bottom: 10px; background-color: #000; transition: width 2s, height 2s, top 2s, left 2s, transform 2s;" autoplay></video> + <video id='videoself' class="video-self" src="{{selfVideoUrl}}" style="width: 250px; position: absolute; top: 21px; right: 31px; border: 1px solid #FFF; background-color: #000; transition: width 2s, height 2s, top 2s, left 2s, transform 2s;" autoplay muted></video> + </div> + {{/if}} + {{#if rtcLayout2}} + <div style="display: flex; flex-direction: row; align-items: center; width: 800px; height: 350px"> + <video id="videoremote" class="video-remote" src="{{remoteVideoUrl}}" style="flex: 1 0; min-width: 380px; height: 285px; margin: 10px; background-color: #000;" autoplay></video> + <video id="videoself" class="video-self" src="{{selfVideoUrl}}" style="flex: 1 0; min-width: 380px; height: 285px; margin: 10px; background-color: #000;" autoplay muted></video> </div> + {{/if}} + {{#if rtcLayout1}} + <div style="display: flex; flex-direction: column; align-items: center; width: 360px; height: 500px"> + <video class="video-remote" src="{{remoteVideoUrl}}" style="flex: 1 1; width: 320px; margin: 10px; background-color: #000;" autoplay></video> + <video class="video-self" src="{{selfVideoUrl}}" style="flex: 1 1; width: 320px; margin: 10px; background-color: #000;" autoplay muted></video> + </div> + {{/if}} + {{#if noRtcLayout}} + <div> + <video class="video-remote" src="{{remoteVideoUrl}}" style="width: 100%; margin-bottom: 10px; background-color: #000; transition: width 2s, height 2s, top 2s, left 2s, transform 2s;" autoplay></video> + <video class="video-self" src="{{selfVideoUrl}}" style="width: 100px; position: absolute; top: 21px; right: 21px; border: 1px solid #FFF; background-color: #000; transition: width 2s, height 2s, top 2s, left 2s, transform 2s;" autoplay muted></video> + </div> + {{/if}} {{/if}} {{/if}} - {{/if}} - <div class="thumb"> - {{> avatar username=username}} - </div> - <div class="info"> - <h3>{{username}}</h3> - {{#if isAdmin}} + <div class="thumb"> + {{> avatar username=username}} + </div> + <div class="info"> + <h3 title="{{username}}"><i class="status-{{status}}"></i> {{username}}</h3> <p>{{name}}</p> {{#if utc}}<p><i class="icon-clock"></i>{{userTime}} (UTC {{utc}})</p>{{/if}} - {{#each emails}} <p><i class="icon-mail"></i> {{address}}{{#if verified}} <i class="icon-ok"></i>{{/if}}</p> {{/each}} - {{#each phone}} <p><i class="icon-phone"></i> {{phoneNumber}}</p> {{/each}} - {{#if lastLogin}} <p><i class="icon-calendar"></i> {{_ "Last_login"}}: {{lastLogin}}</p> {{/if}} - {{#if services.facebook.id}} <p><i class="icon-facebook"></i><a href="{{services.facebook.link}}" target="_blank">{{services.facebook.name}}</a></p> {{/if}} - {{#if services.github.id}} <p><i class="icon-github-circled"></i><a href="https://www.github.com/{{services.github.username}}" target="_blank">{{services.github.username}}</a></p> {{/if}} - {{#if services.gitlab.id}} <p><i class="icon-gitlab"></i>{{services.gitlab.username}}</p> {{/if}} - {{#if services.google.id}} <p><i class="icon-gplus"></i><a href="https://plus.google.com/{{services.google.id}}" target="_blank">{{services.google.name}}</a></p> {{/if}} - {{#if services.linkedin.id}} <p><i class="icon-linkedin"></i><a href="{{services.linkedin.publicProfileUrl}}" target="_blank">{{linkedinUsername}}</a></p> {{/if}} - {{#if servicesMeteor.id}} <p><i class="icon-meteor"></i>{{servicesMeteor.username}}</p> {{/if}} - {{#if services.twitter.id}} <p><i class="icon-twitter"></i><a href="https://twitter.com/{{services.twitter.screenName}}" target="_blank">{{services.twitter.screenName}}</a></p> {{/if}} - {{/if}} + {{#if isAdmin}} + {{#each emails}} <p><i class="icon-mail"></i> {{address}}{{#if verified}} <i class="icon-ok"></i>{{/if}}</p> {{/each}} + {{#each phone}} <p><i class="icon-phone"></i> {{phoneNumber}}</p> {{/each}} + {{#if lastLogin}} <p><i class="icon-calendar"></i> {{_ "Last_login"}}: {{lastLogin}}</p> {{/if}} + {{#if services.facebook.id}} <p><i class="icon-facebook"></i><a href="{{services.facebook.link}}" target="_blank">{{services.facebook.name}}</a></p> {{/if}} + {{#if services.github.id}} <p><i class="icon-github-circled"></i><a href="https://www.github.com/{{services.github.username}}" target="_blank">{{services.github.username}}</a></p> {{/if}} + {{#if services.gitlab.id}} <p><i class="icon-gitlab"></i>{{services.gitlab.username}}</p> {{/if}} + {{#if services.google.id}} <p><i class="icon-gplus"></i><a href="https://plus.google.com/{{services.google.id}}" target="_blank">{{services.google.name}}</a></p> {{/if}} + {{#if services.linkedin.id}} <p><i class="icon-linkedin"></i><a href="{{services.linkedin.publicProfileUrl}}" target="_blank">{{linkedinUsername}}</a></p> {{/if}} + {{#if servicesMeteor.id}} <p><i class="icon-meteor"></i>{{servicesMeteor.username}}</p> {{/if}} + {{#if services.twitter.id}} <p><i class="icon-twitter"></i><a href="https://twitter.com/{{services.twitter.screenName}}" target="_blank">{{services.twitter.screenName}}</a></p> {{/if}} + {{/if}} + </div> </div> - </div> - {{/with}} - <nav> - {{#if video}} - {{#unless videoActive}} - <button class='button start-video'><span><i class='icon-videocam'></i> {{_ "Video_Chat"}}</span></button> - {{#if remoteMonitoring}} - <button class='button short monitor-video'><span><i class='icon-videocam'></i> {{_ "Remote"}}</span></button> - <button class='button lightblue setup-video'><span><i class='icon-videocam'></i> {{_ "Setup"}}</span></button> + {{/with}} + <nav> + {{#if video}} + {{#unless videoActive}} + <button class='button start-video'><span><i class='icon-videocam'></i> {{_ "Video_Chat"}}</span></button> + {{#if remoteMonitoring}} + <button class='button short monitor-video'><span><i class='icon-videocam'></i> {{_ "Remote"}}</span></button> + <button class='button lightblue setup-video'><span><i class='icon-videocam'></i> {{_ "Setup"}}</span></button> + {{/if}} + {{else}} + <button class='button red stop-video'><span><i class='icon-videocam'></i> {{_ "Stop_Video"}}</span></button> + {{/unless}} + {{/if}} + {{#if showAll}} + <button class='button secondary back'><span>{{_ "View_All"}} <i class='icon-angle-right'></i></span></button> + {{#if canDirectMessage}} + <button class='button pvt-msg'><span><i class='icon-chat'></i> {{_ "Conversation"}}</span></button> {{/if}} - {{else}} - <button class='button red stop-video'><span><i class='icon-videocam'></i> {{_ "Stop_Video"}}</span></button> - {{/unless}} - {{/if}} - {{#if showAll}} - <button class='button secondary back'><span>{{_ "View_All"}} <i class='icon-angle-right'></i></span></button> - {{#if canDirectMessage}} - <button class='button pvt-msg'><span><i class='icon-chat'></i> {{_ "Conversation"}}</span></button> {{/if}} - {{/if}} - </nav> + </nav> + {{/if}} </template> \ No newline at end of file diff --git a/server/publications/fullUserData.coffee b/server/publications/fullUserData.coffee new file mode 100644 index 00000000000..4a3616b92a7 --- /dev/null +++ b/server/publications/fullUserData.coffee @@ -0,0 +1,44 @@ +Meteor.publish 'fullUserData', (filter, limit) -> + unless @userId + return @ready() + + user = Meteor.users.findOne @userId + + fields = + name: 1 + username: 1 + status: 1 + utcOffset: 1 + + if user.admin is true + fields = _.extend fields, + emails: 1 + phone: 1 + statusConnection: 1 + admin: 1 + lastLogin: 1 + active: 1 + services: 1 + else + limit = 1 + + filter = s.trim filter + + if not filter and limit is 1 + return @ready() + + if filter + if limit is 1 + query = { username: filter } + else + filterReg = new RegExp filter, "i" + query = { $or: [ { username: filterReg }, { name: filterReg }, { "emails.address": filterReg } ] } + else + query = {} + + console.log '[publish] fullUserData'.green, filter, limit + + Meteor.users.find query, + fields: fields + limit: limit + sort: { username: 1 } diff --git a/server/publications/fullUsers.coffee b/server/publications/fullUsers.coffee deleted file mode 100644 index 1ce094c0a1e..00000000000 --- a/server/publications/fullUsers.coffee +++ /dev/null @@ -1,38 +0,0 @@ -Meteor.publish 'fullUsers', (filter, limit) -> - unless this.userId - return this.ready() - - user = Meteor.users.findOne this.userId - if user.admin isnt true - return this.ready() - - filter = _.trim filter - if filter - if limit is 1 - query = { username: filter } - else - filterReg = new RegExp filter, "i" - query = { $or: [ { username: filterReg }, { name: filterReg }, { "emails.address": filterReg } ] } - else - query = {} - - console.log '[publish] fullUsers'.green, filter, limit - - Meteor.users.find query, - fields: - name: 1 - username: 1 - emails: 1 - phone: 1 - status: 1 - statusDefault: 1 - statusConnection: 1 - avatarOrigin: 1 - admin: 1 - utcOffset: 1 - language: 1 - lastLogin: 1 - active: 1 - services: 1 - limit: limit - sort: { username: 1 } \ No newline at end of file -- GitLab