diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index 5c996af31f..43b4d1b199 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -87,6 +87,7 @@ id: 'user id', name: 'user name', group: 'group name' // for customization.reviewPermissions or permissions.reviewGroups or permissions.commentGroups. Can be multiple groups separated by commas (,) : 'Group1' or 'Group1,Group2' + image: 'image url' }, recent: [ { diff --git a/apps/common/Gateway.js b/apps/common/Gateway.js index 03bae36ebb..e2efd153d8 100644 --- a/apps/common/Gateway.js +++ b/apps/common/Gateway.js @@ -334,8 +334,8 @@ if (window.Common === undefined) { _postMessage({event:'onMakeActionLink', data: config}); }, - requestUsers: function (command) { - _postMessage({event:'onRequestUsers', data: {c: command}}); + requestUsers: function (command, id) { + _postMessage({event:'onRequestUsers', data: {c: command, id: id}}); }, requestSendNotify: function (emails) { diff --git a/apps/common/main/lib/collection/Users.js b/apps/common/main/lib/collection/Users.js index bc24e4e65b..d6651af831 100644 --- a/apps/common/main/lib/collection/Users.js +++ b/apps/common/main/lib/collection/Users.js @@ -87,6 +87,10 @@ define([ function(model){ return model.get('idOriginal') == id; }); + }, + + findOriginalUsers: function(id) { + return this.where({idOriginal: id}); } }); diff --git a/apps/common/main/lib/controller/Chat.js b/apps/common/main/lib/controller/Chat.js index 443bfdf286..2f717bcd19 100644 --- a/apps/common/main/lib/controller/Chat.js +++ b/apps/common/main/lib/controller/Chat.js @@ -103,6 +103,7 @@ define([ this.api.asc_registerCallback('asc_onCoAuthoringChatReceiveMessage', _.bind(this.onReceiveMessage, this)); if ( !this.mode.isEditDiagram && !this.mode.isEditMailMerge && !this.mode.isEditOle ) { + Common.NotificationCenter.on('mentions:setusers', _.bind(this.avatarsUpdate, this)); this.api.asc_registerCallback('asc_onAuthParticipantsChanged', _.bind(this.onUsersChanged, this)); this.api.asc_registerCallback('asc_onConnectionStateChanged', _.bind(this.onUserConnection, this)); this.api.asc_coAuthoringGetUsers(); @@ -138,27 +139,33 @@ define([ var usersStore = this.getApplication().getCollection('Common.Collections.Users'); if (usersStore) { - var arrUsers = [], name, user; + var arrUsers = [], name, user, arrIds = []; for (name in users) { if (undefined !== name) { user = users[name]; if (user) { + var avatar = Common.UI.ExternalUsers.getImage(user.asc_getIdOriginal()); var usermodel = new Common.Models.User({ id : user.asc_getId(), idOriginal : user.asc_getIdOriginal(), username : user.asc_getUserName(), + parsedName : AscCommon.UserInfoParser.getParsedName(user.asc_getUserName()), + initials : Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(user.asc_getUserName())), online : true, color : user.asc_getColor(), + avatar : avatar, view : user.asc_getView(), hidden : !(user.asc_getIdOriginal()===this.currentUserId || AscCommon.UserInfoParser.isUserVisible(user.asc_getUserName())) }); arrUsers[(user.asc_getId() == currentUserId ) ? 'unshift' : 'push'](usermodel); + (avatar===undefined) && arrIds.push(user.asc_getIdOriginal()); } } } usersStore[usersStore.size() > 0 ? 'add' : 'reset'](arrUsers); + arrIds.length && Common.UI.ExternalUsers.get('info', arrIds); } }, @@ -167,23 +174,53 @@ define([ if (usersStore){ var user = usersStore.findUser(change.asc_getId()); + var avatar = Common.UI.ExternalUsers.getImage(change.asc_getIdOriginal()); if (!user) { usersStore.add(new Common.Models.User({ id : change.asc_getId(), idOriginal : change.asc_getIdOriginal(), username : change.asc_getUserName(), + parsedName : AscCommon.UserInfoParser.getParsedName(change.asc_getUserName()), + initials : Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(change.asc_getUserName())), online : change.asc_getState(), color : change.asc_getColor(), + avatar : avatar, view : change.asc_getView(), hidden : !(change.asc_getIdOriginal()===this.currentUserId || AscCommon.UserInfoParser.isUserVisible(change.asc_getUserName())) })); } else { user.set({online: change.asc_getState()}); user.set({username: change.asc_getUserName()}); + user.set({parsedName: AscCommon.UserInfoParser.getParsedName(change.asc_getUserName())}); + user.set({initials: Common.Utils.getUserInitials(change.asc_getUserName())}); + user.set({avatar: avatar}); } + (avatar===undefined) && Common.UI.ExternalUsers.get('info', [change.asc_getIdOriginal()]); } }, + avatarsUpdate: function(type, users) { + if (type!=='info') return; + + var usersStore = this.getApplication().getCollection('Common.Collections.Users'), + msgStore = this.getApplication().getCollection('Common.Collections.ChatMessages'), + needrender = false; + if (users && users.length>0 ){ + _.each(users, function(item) { + usersStore && usersStore.findOriginalUsers(item.id).forEach(function(user){ + user.set({avatar: item.image}); + }); + msgStore && msgStore.where({userid: item.id}).forEach(function(msg){ + if (item.image!==undefined && item.image !== msg.get('avatar')) { + needrender = true; + msg.set('avatar', item.image, {silent: true}); + } + }); + }); + } + needrender && this.panelChat && this.panelChat.renderMessages(); + }, + onReceiveMessage: function(messages, clear){ var msgStore = this.getApplication().getCollection('Common.Collections.ChatMessages'); @@ -193,7 +230,8 @@ define([ array.push(new Common.Models.ChatMessage({ userid : msg.useridoriginal, message : msg.message, - username : msg.username + username : msg.username, + parsedName : AscCommon.UserInfoParser.getParsedName(msg.username), })); }); diff --git a/apps/common/main/lib/controller/Comments.js b/apps/common/main/lib/controller/Comments.js index d5b1b5c1f8..4d7f7f7f77 100644 --- a/apps/common/main/lib/controller/Comments.js +++ b/apps/common/main/lib/controller/Comments.js @@ -176,6 +176,7 @@ define([ this.userCollection = this.getApplication().getCollection('Common.Collections.Users'); this.userCollection.on('reset', _.bind(this.onUpdateUsers, this)); this.userCollection.on('add', _.bind(this.onUpdateUsers, this)); + Common.NotificationCenter.on('mentions:setusers', this.avatarsUpdate.bind(this)); this.bindViewEvents(this.view, this.events); }, @@ -743,7 +744,8 @@ define([ // SDK onApiAddComment: function (id, data) { - var comment = this.readSDKComment(id, data); + var requestObj = {}, + comment = this.readSDKComment(id, data, requestObj); if (comment) { if (comment.get('groupName')) { this.addCommentToGroupCollection(comment); @@ -763,15 +765,17 @@ define([ this.showPopover = undefined; this.editPopover = false; } + requestObj.arrIds && requestObj.arrIds.length && Common.UI.ExternalUsers.get('info', requestObj.arrIds); } }, onApiAddComments: function (data) { + var requestObj = {}; for (var i = 0; i < data.length; ++i) { - var comment = this.readSDKComment(data[i].asc_getId(), data[i]); + var comment = this.readSDKComment(data[i].asc_getId(), data[i], requestObj); comment.get('groupName') ? this.addCommentToGroupCollection(comment) : this.collection.push(comment); } - this.updateComments(true, this.getComparator() === 'position-asc' || this.getComparator() === 'position-desc'); + requestObj.arrIds && requestObj.arrIds.length && Common.UI.ExternalUsers.get('info', requestObj.arrIds); }, onApiRemoveComment: function (id, silentUpdate) { for (var name in this.groupCollection) { @@ -833,22 +837,30 @@ define([ date = (data.asc_getOnlyOfficeTime()) ? new Date(this.stringOOToLocalDate(data.asc_getOnlyOfficeTime())) : ((data.asc_getTime() == '') ? new Date() : new Date(this.stringUtcToLocalDate(data.asc_getTime()))); - var user = this.userCollection.findOriginalUser(data.asc_getUserId()); - var needSort = (this.getComparator() == 'author-asc' || this.getComparator() == 'author-desc') && (data.asc_getUserName() !== comment.get('username')); + var userid = data.asc_getUserId(), + user = this.userCollection.findOriginalUser(userid), + avatar = Common.UI.ExternalUsers.getImage(userid), + arrIds = []; + (avatar===undefined) && arrIds.push(userid); + var hideComment = !AscCommon.UserInfoParser.canViewComment(data.asc_getUserName()), + needSort = (this.getComparator() == 'author-asc' || this.getComparator() == 'author-desc') && (data.asc_getUserName() !== comment.get('username')) || + hideComment !== comment.get('hide'); comment.set('comment', data.asc_getText()); - comment.set('userid', data.asc_getUserId()); + comment.set('userid', userid); comment.set('username', data.asc_getUserName()); + comment.set('initials', Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(data.asc_getUserName()))); comment.set('parsedName', AscCommon.UserInfoParser.getParsedName(data.asc_getUserName())); comment.set('parsedGroups', AscCommon.UserInfoParser.getParsedGroups(data.asc_getUserName())); comment.set('usercolor', (user) ? user.get('color') : null); + comment.set('avatar', avatar); comment.set('resolved', data.asc_getSolved()); comment.set('quote', data.asc_getQuoteText()); comment.set('userdata', data.asc_getUserData()); comment.set('time', date.getTime()); comment.set('date', t.dateToLocaleTimeString(date)); - comment.set('editable', (t.mode.canEditComments || (data.asc_getUserId() == t.currentUserId)) && AscCommon.UserInfoParser.canEditComment(data.asc_getUserName())); - comment.set('removable', (t.mode.canDeleteComments || (data.asc_getUserId() == t.currentUserId)) && AscCommon.UserInfoParser.canDeleteComment(data.asc_getUserName())); - comment.set('hide', !AscCommon.UserInfoParser.canViewComment(data.asc_getUserName())); + comment.set('editable', (t.mode.canEditComments || (userid == t.currentUserId)) && AscCommon.UserInfoParser.canEditComment(data.asc_getUserName())); + comment.set('removable', (t.mode.canDeleteComments || (userid == t.currentUserId)) && AscCommon.UserInfoParser.canDeleteComment(data.asc_getUserName())); + comment.set('hide', hideComment); if (!comment.get('hide')) { var usergroups = comment.get('parsedGroups'); @@ -868,13 +880,18 @@ define([ dateReply = (data.asc_getReply(i).asc_getOnlyOfficeTime()) ? new Date(this.stringOOToLocalDate(data.asc_getReply(i).asc_getOnlyOfficeTime())) : ((data.asc_getReply(i).asc_getTime() == '') ? new Date() : new Date(this.stringUtcToLocalDate(data.asc_getReply(i).asc_getTime()))); - user = this.userCollection.findOriginalUser(data.asc_getReply(i).asc_getUserId()); + userid = data.asc_getReply(i).asc_getUserId(); + user = this.userCollection.findOriginalUser(userid); + avatar = Common.UI.ExternalUsers.getImage(userid); + (avatar===undefined) && arrIds.push(userid); replies.push(new Common.Models.Reply({ id : Common.UI.getId(), - userid : data.asc_getReply(i).asc_getUserId(), + userid : userid, username : data.asc_getReply(i).asc_getUserName(), + initials : Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(data.asc_getReply(i).asc_getUserName())), parsedName : AscCommon.UserInfoParser.getParsedName(data.asc_getReply(i).asc_getUserName()), usercolor : (user) ? user.get('color') : null, + avatar : avatar, date : t.dateToLocaleTimeString(dateReply), reply : data.asc_getReply(i).asc_getText(), userdata : data.asc_getReply(i).asc_getUserData(), @@ -883,8 +900,8 @@ define([ editTextInPopover : false, showReplyInPopover : false, scope : t.view, - editable : (t.mode.canEditComments || (data.asc_getReply(i).asc_getUserId() == t.currentUserId)) && AscCommon.UserInfoParser.canEditComment(data.asc_getReply(i).asc_getUserName()), - removable : (t.mode.canDeleteComments || (data.asc_getReply(i).asc_getUserId() == t.currentUserId)) && AscCommon.UserInfoParser.canDeleteComment(data.asc_getReply(i).asc_getUserName()) + editable : (t.mode.canEditComments || (userid == t.currentUserId)) && AscCommon.UserInfoParser.canEditComment(data.asc_getReply(i).asc_getUserName()), + removable : (t.mode.canDeleteComments || (userid == t.currentUserId)) && AscCommon.UserInfoParser.canDeleteComment(data.asc_getReply(i).asc_getUserName()) })); } @@ -902,6 +919,7 @@ define([ // this.api.asc_showComment(id, true); // } } + arrIds.length && Common.UI.ExternalUsers.get('info', arrIds); } }, onApiLockComment: function (id,userId) { @@ -1280,66 +1298,105 @@ define([ onUpdateUsers: function() { var users = this.userCollection, - hasGroup = false; - for (var name in this.groupCollection) { - hasGroup = true; - this.groupCollection[name].each(function (model) { - var user = users.findOriginalUser(model.get('userid')), - color = (user) ? user.get('color') : null, + hasGroup = false, + updateCommentData = function(comment, user, isNotReply) { + var color = (user) ? user.get('color') : null, needrender = false; - if (color !== model.get('usercolor')) { + if (color !== comment.get('usercolor')) { needrender = true; - model.set('usercolor', color, {silent: true}); + comment.set('usercolor', color, {silent: true}); } - - model.get('replys').forEach(function (reply) { - user = users.findOriginalUser(reply.get('userid')); - color = (user) ? user.get('color') : null; - if (color !== reply.get('usercolor')) { + if (user && (user.image!==undefined)) { + if (user.image !== comment.get('avatar')) { needrender = true; - reply.set('usercolor', color, {silent: true}); + comment.set('avatar', user.image, {silent: true}); } - }); + } - if (needrender) - model.trigger('change'); + //If a comment and not a reply + if(isNotReply){ + comment.get('replys').forEach(function (reply) { + var needrenderReply = updateCommentData(reply, users.findOriginalUser(reply.get('userid')), false); + needrender = needrenderReply || needrender; + }); + + if (needrender) + comment.trigger('change'); + } + + return needrender; + }; + + for (var name in this.groupCollection) { + hasGroup = true; + this.groupCollection[name].each(function (comment) { + updateCommentData(comment, users.findOriginalUser(comment.get('userid')), true); }); } - !hasGroup && this.collection.each(function (model) { - var user = users.findOriginalUser(model.get('userid')), - color = (user) ? user.get('color') : null, - needrender = false; - if (color !== model.get('usercolor')) { - needrender = true; - model.set('usercolor', color, {silent: true}); - } + !hasGroup && this.collection.each(function (comment) { + updateCommentData(comment, users.findOriginalUser(comment.get('userid')), true); + }); + }, - model.get('replys').forEach(function (reply) { - user = users.findOriginalUser(reply.get('userid')); - color = (user) ? user.get('color') : null; - if (color !== reply.get('usercolor')) { - needrender = true; - reply.set('usercolor', color, {silent: true}); + avatarsUpdate: function(type, users) { + if (type!=='info') return; + + var hasGroup = false, + updateCommentData = function(comment, isNotReply) { + var user = _.findWhere(users, {id: comment.get('userid')}), + needrender = false; + if (user && (user.image!==undefined)) { + var avatar = user.image; + if (avatar !== comment.get('avatar')) { + needrender = true; + comment.set('avatar', avatar, {silent: true}); + } + } + + //If a comment and not a reply + if(isNotReply){ + comment.get('replys').forEach(function (reply) { + var needrenderReply = updateCommentData(reply, false); + needrender = needrenderReply || needrender; + }); + + if (needrender) + comment.trigger('change'); } + + return needrender; + }; + + for (var name in this.groupCollection) { + hasGroup = true; + this.groupCollection[name].each(function (comment) { + updateCommentData(comment, true); }); - if (needrender) - model.trigger('change'); + } + !hasGroup && this.collection.each(function (comment) { + updateCommentData(comment, true); }); }, - readSDKComment: function (id, data) { + readSDKComment: function (id, data, requestObj) { + requestObj && !requestObj.arrIds && (requestObj.arrIds = []); var date = (data.asc_getOnlyOfficeTime()) ? new Date(this.stringOOToLocalDate(data.asc_getOnlyOfficeTime())) : ((data.asc_getTime() == '') ? new Date() : new Date(this.stringUtcToLocalDate(data.asc_getTime()))); - var user = this.userCollection.findOriginalUser(data.asc_getUserId()), - groupname = id.substr(0, id.lastIndexOf('_')+1).match(/^(doc|sheet[0-9_]+)_/); + var userid = data.asc_getUserId(), + user = this.userCollection.findOriginalUser(userid), + groupname = id.substr(0, id.lastIndexOf('_')+1).match(/^(doc|sheet[0-9_]+)_/), + avatar = Common.UI.ExternalUsers.getImage(userid); + (avatar===undefined) && requestObj.arrIds.push(userid); var comment = new Common.Models.Comment({ uid : id, guid : data.asc_getGuid(), - userid : data.asc_getUserId(), + userid : userid, username : data.asc_getUserName(), + initials : Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(data.asc_getUserName())), parsedName : AscCommon.UserInfoParser.getParsedName(data.asc_getUserName()), parsedGroups : AscCommon.UserInfoParser.getParsedGroups(data.asc_getUserName()), usercolor : (user) ? user.get('color') : null, + avatar : avatar, date : this.dateToLocaleTimeString(date), quote : data.asc_getQuoteText(), comment : data.asc_getText(), @@ -1355,8 +1412,8 @@ define([ showReplyInPopover : false, hideAddReply : !_.isUndefined(this.hidereply) ? this.hidereply : (this.showPopover ? true : false), scope : this.view, - editable : (this.mode.canEditComments || (data.asc_getUserId() == this.currentUserId)) && AscCommon.UserInfoParser.canEditComment(data.asc_getUserName()), - removable : (this.mode.canDeleteComments || (data.asc_getUserId() == this.currentUserId)) && AscCommon.UserInfoParser.canDeleteComment(data.asc_getUserName()), + editable : (this.mode.canEditComments || (userid == this.currentUserId)) && AscCommon.UserInfoParser.canEditComment(data.asc_getUserName()), + removable : (this.mode.canDeleteComments || (userid == this.currentUserId)) && AscCommon.UserInfoParser.canDeleteComment(data.asc_getUserName()), hide : !AscCommon.UserInfoParser.canViewComment(data.asc_getUserName()), hint : !this.mode.canComments, fullInfoInHint : this.fullInfoHintMode, @@ -1370,7 +1427,7 @@ define([ var filter = !!group && (group!==-1) && (!usergroups || usergroups.length<1 || usergroups.indexOf(group)<0); comment.set('filtered', filter); } - var replies = this.readSDKReplies(data); + var replies = this.readSDKReplies(data, requestObj); if (replies.length) { comment.set('replys', replies); } @@ -1378,7 +1435,8 @@ define([ return comment; }, - readSDKReplies: function (data) { + readSDKReplies: function (data, requestObj) { + requestObj && !requestObj.arrIds && (requestObj.arrIds = []); var i = 0, replies = [], date = null; @@ -1388,13 +1446,18 @@ define([ date = (data.asc_getReply(i).asc_getOnlyOfficeTime()) ? new Date(this.stringOOToLocalDate(data.asc_getReply(i).asc_getOnlyOfficeTime())) : ((data.asc_getReply(i).asc_getTime() == '') ? new Date() : new Date(this.stringUtcToLocalDate(data.asc_getReply(i).asc_getTime()))); - var user = this.userCollection.findOriginalUser(data.asc_getReply(i).asc_getUserId()); + var userid = data.asc_getReply(i).asc_getUserId(), + user = this.userCollection.findOriginalUser(userid), + avatar = Common.UI.ExternalUsers.getImage(userid); + (avatar===undefined) && requestObj && requestObj.arrIds.push(userid); replies.push(new Common.Models.Reply({ id : Common.UI.getId(), - userid : data.asc_getReply(i).asc_getUserId(), + userid : userid, username : data.asc_getReply(i).asc_getUserName(), + initials : Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(data.asc_getReply(i).asc_getUserName())), parsedName : AscCommon.UserInfoParser.getParsedName(data.asc_getReply(i).asc_getUserName()), usercolor : (user) ? user.get('color') : null, + avatar : avatar, date : this.dateToLocaleTimeString(date), reply : data.asc_getReply(i).asc_getText(), userdata : data.asc_getReply(i).asc_getUserData(), @@ -1403,8 +1466,8 @@ define([ editTextInPopover : false, showReplyInPopover : false, scope : this.view, - editable : (this.mode.canEditComments || (data.asc_getReply(i).asc_getUserId() == this.currentUserId)) && AscCommon.UserInfoParser.canEditComment(data.asc_getReply(i).asc_getUserName()), - removable : (this.mode.canDeleteComments || (data.asc_getReply(i).asc_getUserId() == this.currentUserId)) && AscCommon.UserInfoParser.canDeleteComment(data.asc_getReply(i).asc_getUserName()) + editable : (this.mode.canEditComments || (userid == this.currentUserId)) && AscCommon.UserInfoParser.canEditComment(data.asc_getReply(i).asc_getUserName()), + removable : (this.mode.canDeleteComments || (userid == this.currentUserId)) && AscCommon.UserInfoParser.canDeleteComment(data.asc_getReply(i).asc_getUserName()) })); } } @@ -1435,6 +1498,8 @@ define([ date: this.dateToLocaleTimeString(date), userid: this.currentUserId, username: AscCommon.UserInfoParser.getCurrentName(), + avatar: Common.UI.ExternalUsers.getImage(this.currentUserId), + initials: Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(AscCommon.UserInfoParser.getCurrentName())), parsedName: AscCommon.UserInfoParser.getParsedName(AscCommon.UserInfoParser.getCurrentName()), usercolor: (user) ? user.get('color') : null, editTextInPopover: true, diff --git a/apps/common/main/lib/controller/ExternalUsers.js b/apps/common/main/lib/controller/ExternalUsers.js index 48a1655cdd..317e77a99f 100644 --- a/apps/common/main/lib/controller/ExternalUsers.js +++ b/apps/common/main/lib/controller/ExternalUsers.js @@ -46,24 +46,81 @@ if (Common.UI === undefined) { Common.UI.ExternalUsers = new( function() { var externalUsers = [], - isUsersLoading = false; + isUsersLoading = false, + externalUsersInfo = [], + isUsersInfoLoading = false, + stackUsersInfoResponse = []; - var _get = function(type) { - if (isUsersLoading) return; - - type = type || 'mention'; - if (externalUsers[type]===undefined) { - isUsersLoading = true; - Common.Gateway.requestUsers(type || 'mention'); + var _get = function(type, ids) { + if (type==='info') { + (typeof ids !== 'object') && (ids = [ids]); + ids && (ids = _.uniq(ids)); + if (ids.length>100) { + while (ids.length>0) { + Common.Gateway.requestUsers('info', ids.splice(0, 100)); + } + } else + Common.Gateway.requestUsers('info', ids); } else { - Common.NotificationCenter.trigger('mentions:setusers', type, externalUsers[type]); + if (isUsersLoading) return; + + type = type || 'mention'; + if (externalUsers[type]===undefined) { + isUsersLoading = true; + Common.Gateway.requestUsers(type || 'mention'); + } else { + Common.NotificationCenter.trigger('mentions:setusers', type, externalUsers[type]); + } } }; + var _getImage = function(id, request) { + var image, + user = _.findWhere(externalUsersInfo, {id: id}) + user && (image = user.image); + request && (image===undefined) && _get('info', [id]); + return image; + }; + + var _setImage = function(id, image) { + var user = _.findWhere(externalUsersInfo, {id: id}) + user ? (user.image = image) : externalUsersInfo.push({id: id, image: image}); + }; + + var _onUsersInfo = function(data) { + if (data.c !== 'info') return; + + if (isUsersInfoLoading) { + stackUsersInfoResponse.push(data); + return; + } + + isUsersInfoLoading = true; + + var append = []; + data.users && _.each(data.users, function(item) { + var user = _.findWhere(externalUsersInfo, {id: item.id}); + if (user) { + user.image = item.image; + user.name = item.name; + user.email = item.email; + } else + append.push(item); + }); + externalUsersInfo = externalUsersInfo.concat(append); + Common.NotificationCenter.trigger('mentions:setusers', data.c, data.users); + isUsersInfoLoading = false; + if (stackUsersInfoResponse.length>0) + _onUsersInfo(stackUsersInfoResponse.shift()); + }; + var _init = function(canRequestUsers) { + Common.Gateway.on('setusers', _onUsersInfo); + if (!canRequestUsers) return; Common.Gateway.on('setusers', function(data) { + if (data.c === 'info') return; if (data.users===null) {// clear user lists externalUsers = []; return; @@ -73,13 +130,17 @@ Common.UI.ExternalUsers = new( function() { isUsersLoading = false; Common.NotificationCenter.trigger('mentions:setusers', type, externalUsers[type]); }); - Common.NotificationCenter.on('mentions:clearusers', function() { - externalUsers = []; + + Common.NotificationCenter.on('mentions:clearusers', function(type) { + if (type !== 'info') + externalUsers[type || 'mention'] = undefined; }); }; return { init: _init, - get: _get + get: _get, + getImage: _getImage, + setImage: _setImage } })(); diff --git a/apps/common/main/lib/controller/ReviewChanges.js b/apps/common/main/lib/controller/ReviewChanges.js index 6d77ff929c..03acbff802 100644 --- a/apps/common/main/lib/controller/ReviewChanges.js +++ b/apps/common/main/lib/controller/ReviewChanges.js @@ -122,9 +122,14 @@ define([ Common.NotificationCenter.on('collaboration:sharing', this.changeAccessRights.bind(this)); Common.NotificationCenter.on('collaboration:sharingdeny', this.onLostEditRights.bind(this)); Common.NotificationCenter.on('protect:wslock', _.bind(this.onChangeProtectSheet, this)); + Common.NotificationCenter.on('mentions:setusers', this.avatarsUpdate.bind(this)); + + this.userCollection.on({ + add : _.bind(this.onUpdateUsers, this), + change : _.bind(this.onUpdateUsers, this), + reset : _.bind(this.onUpdateUsers, this) + }); - this.userCollection.on('reset', _.bind(this.onUpdateUsers, this)); - this.userCollection.on('add', _.bind(this.onUpdateUsers, this)); }, setConfig: function (data, api) { this.setApi(api); @@ -322,7 +327,7 @@ define([ // helpers readSDKChange: function (data) { - var me = this, arr = []; + var me = this, arr = [], arrIds = []; _.each(data, function(item) { var changetext = '', proptext = '', value = item.get_Value(), @@ -508,11 +513,14 @@ define([ var date = (item.get_DateTime() == '') ? new Date() : new Date(item.get_DateTime()), user = me.userCollection.findOriginalUser(item.get_UserId()), isProtectedReview = me._state.docProtection.isReviewOnly, + avatar = Common.UI.ExternalUsers.getImage(item.get_UserId()), change = new Common.Models.ReviewChange({ uid : Common.UI.getId(), userid : item.get_UserId(), username : item.get_UserName(), usercolor : (user) ? user.get('color') : null, + initials : Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(item.get_UserName())), + avatar : avatar, date : me.dateToLocaleTimeString(date), changetext : changetext, id : Common.UI.getId(), @@ -528,7 +536,9 @@ define([ }); arr.push(change); + (avatar===undefined) && arrIds.push(item.get_UserId()); }); + arrIds.length && Common.UI.ExternalUsers.get('info', arrIds); return arr; }, @@ -1054,7 +1064,8 @@ define([ if (data) { this.document.info.sharingSettings = data.sharingSettings; Common.NotificationCenter.trigger('collaboration:sharingupdate', data.sharingSettings); - Common.NotificationCenter.trigger('mentions:clearusers', this); + Common.NotificationCenter.trigger('mentions:clearusers', 'mention'); + Common.NotificationCenter.trigger('mentions:clearusers', 'protect'); } }, @@ -1068,6 +1079,16 @@ define([ this.popoverChanges && this.popoverChanges.each(function (model) { var user = users.findOriginalUser(model.get('userid')); model.set('usercolor', (user) ? user.get('color') : null); + user && user.get('avatar') && model.set('avatar', user.get('avatar')); + }); + }, + + avatarsUpdate: function(type, users) { + if (type!=='info') return; + + this.popoverChanges && this.popoverChanges.each(function (model) { + var user = _.findWhere(users, {id: model.get('userid')}) + user && (user.image!==undefined) && model.set('avatar', user.image); }); }, diff --git a/apps/common/main/lib/template/Comments.template b/apps/common/main/lib/template/Comments.template index 36f249ac81..0c747184ec 100644 --- a/apps/common/main/lib/template/Comments.template +++ b/apps/common/main/lib/template/Comments.template @@ -3,10 +3,19 @@ -
-
<%= scope.getEncodedName(parsedName) %> +
+
+ style="background-image: url(<%=avatar%>); <% if (usercolor!==null) { %> border-color:<%=usercolor%>; border-style:solid;<% }%>" + <% } else { %> + style="background-color: <% if (usercolor!==null) { %> <%=usercolor%> <% } else { %> #cfcfcf <% }%>;" + <% } %> + ><% if (!avatar) { %><%=initials%><% } %>
+
-
<%=date%>
<% if (quote!==null && quote!=='') { %>
<%=scope.getFixedQuote(quote)%>
<% } %> @@ -30,10 +39,19 @@
<% } %>
style="padding-bottom: 0;" <% } %>;> -
-
<%=item.get("usercolor")%><% } else { %> #cfcfcf <% } %>; " >
<%= scope.getEncodedName(item.get("parsedName")) %> + -
<%=item.get("date")%>
<% if (!item.get("editText")) { %>
<%=scope.pickLink(item.get("reply"))%>
<% if (!scope.viewmode) { %> diff --git a/apps/common/main/lib/template/CommentsPopover.template b/apps/common/main/lib/template/CommentsPopover.template index 71b665002c..29bc93c28f 100644 --- a/apps/common/main/lib/template/CommentsPopover.template +++ b/apps/common/main/lib/template/CommentsPopover.template @@ -3,10 +3,19 @@ -
-
<%= scope.getEncodedName(parsedName) %> + -
<%=date%>
<% if (!editTextInPopover || (hint && !fullInfoInHint) || scope.viewmode) { %>
<%=scope.pickLink(comment)%>
<% } else { %> @@ -31,10 +40,19 @@
<% } %>
-
-
<%=item.get("usercolor")%><% } else { %> #cfcfcf <% } %>; " >
<%= scope.getEncodedName(item.get("parsedName")) %> + -
<%=item.get("date")%>
<% if (!item.get("editTextInPopover")) { %>
<%=scope.pickLink(item.get("reply"))%>
<% if ((fullInfoInHint || !hint) && !scope.viewmode) { %> diff --git a/apps/common/main/lib/template/ReviewChangesPopover.template b/apps/common/main/lib/template/ReviewChangesPopover.template index 409e4c0e5d..b89bced635 100644 --- a/apps/common/main/lib/template/ReviewChangesPopover.template +++ b/apps/common/main/lib/template/ReviewChangesPopover.template @@ -1,8 +1,18 @@
-
-
<%= scope.getUserName(username) %> + + -
<%=date%>
<%=changetext%>
<% if (goto) { %> diff --git a/apps/common/main/lib/util/utils.js b/apps/common/main/lib/util/utils.js index 732802e0dd..20f5fac76e 100644 --- a/apps/common/main/lib/util/utils.js +++ b/apps/common/main/lib/util/utils.js @@ -1176,6 +1176,18 @@ Common.Utils.UserInfoParser = new(function() { } })(); +Common.Utils.getUserInitials = function(username) { + var fio = username.split(' '); + var initials = fio[0].substring(0, 1).toUpperCase(); + for (var i = fio.length-1; i>0; i--) { + if (fio[i][0]!=='(' && fio[i][0]!==')') { + initials += fio[i].substring(0, 1).toUpperCase(); + break; + } + } + return initials; +}; + Common.Utils.getKeyByValue = function(obj, value) { for(var prop in obj) { if(obj.hasOwnProperty(prop)) { diff --git a/apps/common/main/lib/view/Chat.js b/apps/common/main/lib/view/Chat.js index 2fa4c213b5..033ab7567b 100644 --- a/apps/common/main/lib/view/Chat.js +++ b/apps/common/main/lib/view/Chat.js @@ -59,7 +59,7 @@ define([ storeMessages: undefined, tplUser: ['
  • "<% if (!user.get("online")) { %> class="offline"<% } %>>', - '
    ;" >
    <%= scope.getUserName(user.get("username")) %>', + '
    ;" >
    <%= user.get("parsedName") %>', '
    ', '
  • '].join(''), @@ -73,10 +73,19 @@ define([ '<% if (msg.get("type")==1) { %>', '
    <%= msg.get("message") %>
    ', '<% } else { %>', - '
    ', - '
    <%=msg.get("usercolor")%><% } else { %> #cfcfcf <% } %>; " >
    <%= scope.getUserName(msg.get("username")) %>', + '
    ', + 'style="background-image: url(<%=msg.get("avatar")%>); <% if (msg.get("usercolor")!==null) { %> border-color:<%=msg.get("usercolor")%>; border-style:solid;<% }%>"', + '<% } else { %>', + 'style="background-color: <% if (msg.get("usercolor")!==null) { %> <%=msg.get("usercolor")%> <% } else { %> #cfcfcf <% }%>;"', + '<% } %>', + '><% if (!msg.get("avatar")) { %><%=msg.get("initials")%><% } %>
    ', + '
    ', + '
    ', + '<%= msg.get("parsedName") %>', + '
    ', + '', '
    ', - '', '<% } %>', ''].join(''), @@ -196,6 +205,13 @@ define([ } }, + renderMessages: function() { + if (this.panelMessages && this.storeMessages) { + this.panelMessages.html(this.templateMsgList({messages: this.storeMessages.models, msgtpl: this.tplMsg, scope: this})); + this.panelMessages.scroller.update({minScrollbarLength : 40, alwaysVisibleY: true}); + } + }, + _onBtnAddMessage: function(e) { if (this.txtMessage) { this.fireEvent('message:add', [this, this.txtMessage.val().trim()]); @@ -205,11 +221,15 @@ define([ }, _prepareMessage: function(m) { - var user = this.storeUsers.findOriginalUser(m.get('userid')); + var user = this.storeUsers.findOriginalUser(m.get('userid')), + avatar = Common.UI.ExternalUsers.getImage(m.get('userid')); m.set({ usercolor : user ? user.get('color') : null, + avatar : avatar, + initials : user ? user.get('initials') : Common.Utils.getUserInitials(m.get('parsedName')), message : this._pickLink(m.get('message')) }, {silent:true}); + (avatar===undefined) && Common.UI.ExternalUsers.get('info', [m.get('userid')]); }, _pickLink: function(message) { @@ -266,10 +286,6 @@ define([ return str_res; }, - getUserName: function (username) { - return Common.Utils.String.htmlEncode(AscCommon.UserInfoParser.getParsedName(username)); - }, - hide: function () { Common.UI.BaseView.prototype.hide.call(this,arguments); this.fireEvent('hide', this ); diff --git a/apps/common/main/lib/view/Header.js b/apps/common/main/lib/view/Header.js index 524cfd4078..f74cc3adf7 100644 --- a/apps/common/main/lib/view/Header.js +++ b/apps/common/main/lib/view/Header.js @@ -58,7 +58,13 @@ define([ var templateUserItem = '
  • " class="<% if (!user.get("online")) { %> offline <% } if (user.get("view")) {%> viewmode <% } %>">' + '
    ' + - '
    ;">
    '+ + '
    ' + + 'style="background-image: url(<%=user.get("avatar")%>); <% if (user.get("color")!==null) { %> border-color:<%=user.get("color")%>; border-style: solid;<% }%>"' + + '<% } else { %>' + + 'style="background-color: <% if (user.get("color")!==null) { %> <%=user.get("color")%> <% } else { %> #cfcfcf <% }%>;"' + + '<% } %>' + + '><% if (!user.get("avatar")) { %><%=user.get("initials")%><% } %>
    ' + '' + '<% if (len>1) { %><% } %>' + '
    '+ @@ -564,6 +570,7 @@ define([ 'collaboration:sharingdeny': function(mode) {Common.Utils.asyncCall(onLostEditRights, me, mode);} }); Common.NotificationCenter.on('uitheme:changed', this.changeLogo.bind(this)); + Common.NotificationCenter.on('mentions:setusers', this.avatarsUpdate.bind(this)); }, render: function (el, role) { @@ -919,10 +926,34 @@ define([ html: true }); } - $btnUserName && $btnUserName.text(this.getInitials(name)); + $btnUserName && this.updateAvatarEl(); + return this; }, + setUserAvatar: function(avatar) { + this.options.userAvatar = avatar; + $btnUserName && this.updateAvatarEl(); + }, + + setUserId: function(id) { + this.options.currentUserId = id; + }, + + updateAvatarEl(){ + if(this.options.userAvatar){ + $btnUserName.css({'background-image': 'url('+ this.options.userAvatar +')'}); + $btnUserName.text(''); + } else { + $btnUserName.text(Common.Utils.getUserInitials(this.options.userName)); + } + }, + + avatarsUpdate: function(type, users) { + if (type!=='info') return; + this.setUserAvatar(Common.UI.ExternalUsers.getImage(this.options.currentUserId)); + }, + getButton: function(type) { if (type == 'save') return this.btnSave; @@ -970,18 +1001,6 @@ define([ } }, - getInitials: function(name) { - var fio = name.split(' '); - var initials = fio[0].substring(0, 1).toUpperCase(); - for (var i = fio.length-1; i>0; i--) { - if (fio[i][0]!=='(' && fio[i][0]!==')') { - initials += fio[i].substring(0, 1).toUpperCase(); - break; - } - } - return initials; - }, - setDocumentReadOnly: function (readonly) { this.readOnly = readonly; this.setDocumentCaption(this.documentCaption); diff --git a/apps/common/main/lib/view/History.js b/apps/common/main/lib/view/History.js index aa0172b25f..11292eef9b 100644 --- a/apps/common/main/lib/view/History.js +++ b/apps/common/main/lib/view/History.js @@ -91,8 +91,14 @@ define([ '
    ', '<% } %>', '
    ', - '
    ', - '
    <%= Common.Utils.String.htmlEncode(AscCommon.UserInfoParser.getParsedName(username)) %>', + '
    ', + 'style="background-image: url(<%=avatar%>); <% if (usercolor!==null) { %> border-color:<%=usercolor%>; border-style:solid;<% }%>"', + '<% } else { %>', + 'style="background-color: <% if (usercolor!==null) { %> <%=usercolor%> <% } else { %> #cfcfcf <% }%>;"', + '<% } %>', + '><% if (!avatar) { %><%=initials%><% } %>
    ', + '<%= Common.Utils.String.htmlEncode(AscCommon.UserInfoParser.getParsedName(username)) %>', '
    ', '<% if (canRestore && selected) { %>', '', diff --git a/apps/common/main/resources/less/chat.less b/apps/common/main/resources/less/chat.less index f175a33404..1a8cf629d1 100644 --- a/apps/common/main/resources/less/chat.less +++ b/apps/common/main/resources/less/chat.less @@ -63,14 +63,13 @@ .color { display: inline-block; vertical-align: middle; - margin: 0 5px 3px 0; - width: 12px; - height: 12px; - border: 1px solid @border-toolbar-ie; - border: 1px solid @border-toolbar; + margin: 0 10px 3px 0; + width: 6px; + height: 6px; + border-radius: 6px; .rtl & { - margin: 0 0 3px 5px; + margin: 0 0 3px 10px; } } @@ -102,6 +101,7 @@ padding: 0; li { + display: flex; list-style: none; padding: 5px 10px 8px 20px; @@ -132,18 +132,34 @@ } .color { - width: 12px; - height: 12px; - border: 1px solid @border-toolbar-ie; - border: 1px solid @border-toolbar; - margin: 0 5px 3px 0; + display: inline-block; + width: 26px; + height: 26px; + border-radius: 20px; + border-width: @scaled-two-px-value; + margin-right: 8px; vertical-align: middle; - + background-color: #ffffff; + background-size: cover; + background-position: center; + + text-align: center; + line-height: 26px; + color: #ffffff; + font-weight: 700; + .rtl & { - margin: 0 0 3px 5px; + margin-right: 0px; + margin-left: 8px; } } + .user-content { + flex: 1; + overflow: hidden; + line-height: 12.65px; + } + .message { word-wrap: break-word; width: 100%; diff --git a/apps/common/main/resources/less/comments.less b/apps/common/main/resources/less/comments.less index e05bc55215..b53134a2dc 100644 --- a/apps/common/main/resources/less/comments.less +++ b/apps/common/main/resources/less/comments.less @@ -169,6 +169,19 @@ padding: 0px 20px 10px 20px; } + .user-info { + display: flex; + padding-top: 10px; + .padding-right(65px); + } + + .user-info-text { + flex: 1; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + .user-name { color: @text-normal-ie; color: @text-normal; @@ -177,25 +190,29 @@ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; - padding: 10px 65px 0 0px; - height: 26px; cursor: default; - - .rtl & { - padding: 10px 0px 0 65px; - } } .color { - width: 12px; - height: 12px; - border: @scaled-one-px-value-ie solid @border-toolbar-ie; - border: @scaled-one-px-value solid @border-toolbar; - margin: 0 5px 3px 0; + display: inline-block; + width: 26px; + height: 26px; + border-radius: 20px; + border-width: @scaled-two-px-value; + margin-right: 8px; vertical-align: middle; + background-color: #ffffff; + background-size: cover; + background-position: center; + + text-align: center; + line-height: 26px; + color: #ffffff; + font-weight: 700; .rtl & { - margin: 0 0 3px 5px; + margin-right: 0px; + margin-left: 8px; } } @@ -438,7 +455,7 @@ } .inner-edit-ct { - padding: 7px 0px 0px 0px; + padding: 10px 0px 0px 0px; .btn-inner-close { .margin-left-7(); @@ -463,6 +480,10 @@ height: 16px; margin-top: 10px; position: absolute; + + .rtl & { + transform: scale(-1, 1); + } } .lock-area { diff --git a/apps/common/main/resources/less/header.less b/apps/common/main/resources/less/header.less index 0cc6b7bd58..4b4d6ccb11 100644 --- a/apps/common/main/resources/less/header.less +++ b/apps/common/main/resources/less/header.less @@ -400,6 +400,10 @@ background-color: @icon-toolbar-header; color: @toolbar-header-text-on-background-ie; color: @toolbar-header-text-on-background; + vertical-align: middle; + background-size: cover; + background-position: center; + font-size: 10px; line-height: 20px; overflow: hidden; @@ -445,24 +449,34 @@ li { list-style: none; - padding: 2px 0; + margin-top: 12px; overflow: hidden; &.offline, &.viewmode { display: none; } } + + li:first-child { + margin-top: 0px; + } } .color { - width: 12px; - height: 12px; + width: 26px; + height: 26px; + border-radius: 20px; + border-width: @scaled-two-px-value; display: inline-block; vertical-align: middle; - border: @scaled-one-px-value solid @border-toolbar; - .margin-right-5(); - margin-top: 0; - margin-bottom: 2px; + background-color: #ffffff; + background-size: cover; + background-position: center; + .margin-right-8(); + + line-height: 26px; + color: #ffffff; + text-align: center; } .user-name { diff --git a/apps/common/main/resources/less/history.less b/apps/common/main/resources/less/history.less index 1ae582bcb7..610722aa24 100644 --- a/apps/common/main/resources/less/history.less +++ b/apps/common/main/resources/less/history.less @@ -139,16 +139,20 @@ } .color { - width: 12px; - height: 12px; - border: @scaled-one-px-value-ie solid @border-toolbar-ie; - border: @scaled-one-px-value solid @border-toolbar; - margin: 0 5px 3px 0; + display: inline-block; + width: 26px; + height: 26px; + border-radius: 20px; + border-width: @scaled-two-px-value; + .margin-right-8(); vertical-align: middle; + background-color: #ffffff; + background-size: cover; + background-position: center; - .rtl & { - margin: 0 0 3px 5px; - } + color: #ffffff; + line-height: 26px; + text-align: center; } .revision-expand { diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 8b100b2295..6e6dc61ebf 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -696,7 +696,8 @@ define([ this._renameDialog && this._renameDialog.close(); var versions = opts.data.history, historyStore = this.getApplication().getCollection('Common.Collections.HistoryVersions'), - currentVersion = null; + currentVersion = null, + arrIds = []; if (historyStore) { var arrVersions = [], ver, version, group = -1, prev_ver = -1, arrColors = [], docIdPrev = '', usersStore = this.getApplication().getCollection('Common.Collections.HistoryUsers'), user = null, usersCnt = 0; @@ -718,13 +719,16 @@ define([ }); usersStore.add(user); } - + var avatar = Common.UI.ExternalUsers.getImage(version.user.id); + (avatar===undefined) && arrIds.push(version.user.id); arrVersions.push(new Common.Models.HistoryVersion({ version: version.versionGroup, revision: version.version, userid : version.user.id, username : version.user.name || this.textAnonymous, usercolor: user.get('color'), + initials : Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(version.user.name || this.textAnonymous)), + avatar : avatar, created: version.created, docId: version.key, markedAsVersion: (group!==version.versionGroup), @@ -767,7 +771,8 @@ define([ }); usersStore.add(user); } - + avatar = Common.UI.ExternalUsers.getImage(change.user.id); + (avatar===undefined) && arrIds.push(change.user.id); arrVersions.push(new Common.Models.HistoryVersion({ version: version.versionGroup, revision: version.version, @@ -775,6 +780,8 @@ define([ userid : change.user.id, username : change.user.name || this.textAnonymous, usercolor: user.get('color'), + initials : Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(change.user.name || this.textAnonymous)), + avatar : avatar, created: change.created, docId: version.key, docIdPrev: docIdPrev, @@ -807,6 +814,7 @@ define([ } if (currentVersion) this.getApplication().getController('Common.Controllers.History').onSelectRevision(null, null, currentVersion); + arrIds.length && Common.UI.ExternalUsers.get('info', arrIds); } } }, @@ -1635,6 +1643,8 @@ define([ this.appOptions.canUseCommentPermissions && AscCommon.UserInfoParser.setCommentPermissions(this.permissions.commentGroups); this.appOptions.canUseUserInfoPermissions && AscCommon.UserInfoParser.setUserInfoPermissions(this.permissions.userInfoGroups); appHeader.setUserName(AscCommon.UserInfoParser.getParsedName(AscCommon.UserInfoParser.getCurrentName())); + appHeader.setUserId(this.appOptions.user.id); + appHeader.setUserAvatar(this.appOptions.user.image); this.appOptions.canRename && appHeader.setCanRename(true); this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object' || this.editorConfig.plugins); @@ -1642,6 +1652,8 @@ define([ this.editorConfig.customization && Common.UI.LayoutManager.init(this.editorConfig.customization.layout, this.appOptions.canBrandingExt); this.editorConfig.customization && Common.UI.FeaturesManager.init(this.editorConfig.customization.features, this.appOptions.canBrandingExt); Common.UI.ExternalUsers.init(this.appOptions.canRequestUsers); + this.appOptions.user.image && Common.UI.ExternalUsers.setImage(this.appOptions.user.id, this.appOptions.user.image); + Common.UI.ExternalUsers.get('info', this.appOptions.user.id); if (this.appOptions.canComments) Common.NotificationCenter.on('comments:cleardummy', _.bind(this.onClearDummyComment, this)); diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 8db17de907..0d289441ec 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -1283,6 +1283,8 @@ define([ this.appOptions.canUseCommentPermissions && AscCommon.UserInfoParser.setCommentPermissions(this.permissions.commentGroups); this.appOptions.canUseUserInfoPermissions && AscCommon.UserInfoParser.setUserInfoPermissions(this.permissions.userInfoGroups); appHeader.setUserName(AscCommon.UserInfoParser.getParsedName(AscCommon.UserInfoParser.getCurrentName())); + appHeader.setUserId(this.appOptions.user.id); + appHeader.setUserAvatar(this.appOptions.user.image); this.appOptions.canRename && appHeader.setCanRename(true); this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object' || this.editorConfig.plugins); @@ -1290,6 +1292,8 @@ define([ this.editorConfig.customization && Common.UI.LayoutManager.init(this.editorConfig.customization.layout, this.appOptions.canBrandingExt); this.editorConfig.customization && Common.UI.FeaturesManager.init(this.editorConfig.customization.features, this.appOptions.canBrandingExt); Common.UI.ExternalUsers.init(this.appOptions.canRequestUsers); + this.appOptions.user.image && Common.UI.ExternalUsers.setImage(this.appOptions.user.id, this.appOptions.user.image); + Common.UI.ExternalUsers.get('info', this.appOptions.user.id); // change = true by default in editor this.appOptions.canLiveView = !!params.asc_getLiveViewerSupport() && (this.editorConfig.mode === 'view'); // viewer: change=false when no flag canLiveViewer (i.g. old license), change=true by default when canLiveViewer==true @@ -2616,7 +2620,8 @@ define([ this._renameDialog && this._renameDialog.close(); var versions = opts.data.history, historyStore = this.getApplication().getCollection('Common.Collections.HistoryVersions'), - currentVersion = null; + currentVersion = null, + arrIds = []; if (historyStore) { var arrVersions = [], ver, version, group = -1, prev_ver = -1, arrColors = [], docIdPrev = '', usersStore = this.getApplication().getCollection('Common.Collections.HistoryUsers'), user = null, usersCnt = 0; @@ -2638,13 +2643,16 @@ define([ }); usersStore.add(user); } - + var avatar = Common.UI.ExternalUsers.getImage(version.user.id); + (avatar===undefined) && arrIds.push(version.user.id); arrVersions.push(new Common.Models.HistoryVersion({ version: version.versionGroup, revision: version.version, userid : version.user.id, username : version.user.name, usercolor: user.get('color'), + initials : Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(version.user.name || this.textAnonymous)), + avatar : avatar, created: version.created, docId: version.key, markedAsVersion: (group!==version.versionGroup), @@ -2687,7 +2695,8 @@ define([ }); usersStore.add(user); } - + avatar = Common.UI.ExternalUsers.getImage(change.user.id); + (avatar===undefined) && arrIds.push(change.user.id); arrVersions.push(new Common.Models.HistoryVersion({ version: version.versionGroup, revision: version.version, @@ -2695,6 +2704,8 @@ define([ userid : change.user.id, username : change.user.name, usercolor: user.get('color'), + initials : Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(change.user.name || this.textAnonymous)), + avatar : avatar, created: change.created, docId: version.key, docIdPrev: docIdPrev, @@ -2727,6 +2738,7 @@ define([ } if (currentVersion) this.getApplication().getController('Common.Controllers.History').onSelectRevision(null, null, currentVersion); + arrIds.length && Common.UI.ExternalUsers.get('info', arrIds); } } }, diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index e13b5caa73..4bd6b32f91 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -1364,6 +1364,8 @@ define([ this.appOptions.canUseCommentPermissions && AscCommon.UserInfoParser.setCommentPermissions(this.permissions.commentGroups); this.appOptions.canUseUserInfoPermissions && AscCommon.UserInfoParser.setUserInfoPermissions(this.permissions.userInfoGroups); this.headerView.setUserName(AscCommon.UserInfoParser.getParsedName(AscCommon.UserInfoParser.getCurrentName())); + this.headerView.setUserId(this.appOptions.user.id); + this.headerView.setUserAvatar(this.appOptions.user.image); } else this.appOptions.canModifyFilter = true; @@ -1405,6 +1407,8 @@ define([ this.editorConfig.customization && Common.UI.LayoutManager.init(this.editorConfig.customization.layout, this.appOptions.canBrandingExt); this.editorConfig.customization && Common.UI.FeaturesManager.init(this.editorConfig.customization.features, this.appOptions.canBrandingExt); Common.UI.ExternalUsers.init(this.appOptions.canRequestUsers); + this.appOptions.user.image && Common.UI.ExternalUsers.setImage(this.appOptions.user.id, this.appOptions.user.image); + Common.UI.ExternalUsers.get('info', this.appOptions.user.id); } this.appOptions.canUseHistory = this.appOptions.canLicense && this.editorConfig.canUseHistory && this.appOptions.canCoAuthoring && !this.appOptions.isOffline; @@ -3258,7 +3262,8 @@ define([ this._renameDialog && this._renameDialog.close(); var versions = opts.data.history, historyStore = this.getApplication().getCollection('Common.Collections.HistoryVersions'), - currentVersion = null; + currentVersion = null, + arrIds = []; if (historyStore) { var arrVersions = [], ver, version, group = -1, prev_ver = -1, arrColors = [], docIdPrev = '', usersStore = this.getApplication().getCollection('Common.Collections.HistoryUsers'), user = null, usersCnt = 0; @@ -3280,13 +3285,16 @@ define([ }); usersStore.add(user); } - + var avatar = Common.UI.ExternalUsers.getImage(version.user.id); + (avatar===undefined) && arrIds.push(version.user.id); arrVersions.push(new Common.Models.HistoryVersion({ version: version.versionGroup, revision: version.version, userid : version.user.id, username : version.user.name, usercolor: user.get('color'), + initials : Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(version.user.name || this.textAnonymous)), + avatar : avatar, created: version.created, docId: version.key, markedAsVersion: (group!==version.versionGroup), @@ -3329,7 +3337,8 @@ define([ }); usersStore.add(user); } - + avatar = Common.UI.ExternalUsers.getImage(change.user.id); + (avatar===undefined) && arrIds.push(change.user.id); arrVersions.push(new Common.Models.HistoryVersion({ version: version.versionGroup, revision: version.version, @@ -3337,6 +3346,8 @@ define([ userid : change.user.id, username : change.user.name, usercolor: user.get('color'), + initials : Common.Utils.getUserInitials(AscCommon.UserInfoParser.getParsedName(change.user.name || this.textAnonymous)), + avatar : avatar, created: change.created, docId: version.key, docIdPrev: docIdPrev, @@ -3369,6 +3380,7 @@ define([ } // if (currentVersion) // this.getApplication().getController('Common.Controllers.History').onSelectRevision(null, null, currentVersion); + arrIds.length && Common.UI.ExternalUsers.get('info', arrIds); } } },