From 62e2f7426c01a4aa9d030758731b0f7de0ab6ff9 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Mon, 6 Nov 2023 11:41:09 +0700 Subject: [PATCH] csharp: user avatar --- CHANGELOG.md | 1 + .../csharp/App_Themes/images/uid-1.png | Bin 0 -> 2226 bytes .../csharp/App_Themes/images/uid-2.png | Bin 0 -> 2199 bytes .../csharp/DocEditor.aspx | 26 ++++++++++++-- .../csharp/DocEditor.aspx.cs | 7 +++- web/documentserver-example/csharp/Users.cs | 34 +++++++++++++++--- 6 files changed, 60 insertions(+), 8 deletions(-) create mode 100644 web/documentserver-example/csharp/App_Themes/images/uid-1.png create mode 100644 web/documentserver-example/csharp/App_Themes/images/uid-2.png diff --git a/CHANGELOG.md b/CHANGELOG.md index 638bbc06..5bbe6450 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- csharp: user avatar - csharp-mvc: user avatar - java: user avatar - java-spring: user avatar diff --git a/web/documentserver-example/csharp/App_Themes/images/uid-1.png b/web/documentserver-example/csharp/App_Themes/images/uid-1.png new file mode 100644 index 0000000000000000000000000000000000000000..91cf9e02ce9c581fd3515f132a68945a8b1dea29 GIT binary patch literal 2226 zcmV;j2u=5iP)Px#32;bRa{vGf6951U69E94oEQKA0{~D=R7FQ{Ox)bu z)6>)9;o#oh-p$R;*45P8+1KFT-{0Tg-{0Th;Nafg-q+XH-QC^I&CSu#(bw14&CJWo z%gfW#)6&w?-rnBc-rmZ}%HQAL+S=OJ*VoO>&CSit%*@QPt*YAC*8BVS-rU;E%*@Eh z$jr>l+1c6I+1b(2(f9TB_xJbu`ueY@r=6RY`}+F(_x7csp0~2C`}_O6wz9movf

z*wfAW_Vf7j@#x~;=i=V$=;Ynq-QM2b(b3V^*x1(A*3{J0-{0TU)6><})yvDv+}zyP z*Vo(I+tSj~+1c69(9qi2+RV(%&(F`!&d$xv%@hm@BNY-K6cP~$2Mh-WI3pYy5f3I9 z7X17CG9nxu5f2y+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5zEzepA!NeENbeA03PIq#?(DQb`qx;W&1f_( zhI`PKjx)Gy8C=F;A?O7PKjFIUGXZNn`NX3EYkYy&-i{19T!{D@=O)NRB1|Evy4es7 zus1PWkU8eQG1HZBAfCasCV|LLs6KUOEH=@wiO=W3@fsIcnhY|RONFy<4E`orBN6&x zrl`8;F9W_<9T8EE68OdOX6JxYYQe!n;ccmsNN}m^VgnKZJ|Cny;0>_D#5M|aVerO; zZ;NG-NfKpucXjigejM)%^7Y+zfamadgLWti2?^PlkWeg-l=S4Nt4=kHfnjV43R0B^R>?56m!4E>GrAYYa0t=A_XDsL<+3JVEoFACcnHQ3bG zm!Frh>lUc0di%90&#QNrg@qNB?O3(y%Fmboe6VZhwrwiadn=xL62AWdpl7dNzcw(i zv%LJ)Cm*kP<{3+x{gLDH53db;_Nm?HlaAy60nijp^WHMgaR2}S07*qoM6N<$g1R-5 A9RL6T literal 0 HcmV?d00001 diff --git a/web/documentserver-example/csharp/App_Themes/images/uid-2.png b/web/documentserver-example/csharp/App_Themes/images/uid-2.png new file mode 100644 index 0000000000000000000000000000000000000000..651b40c6b91e59c94b2752ddcbe0dac2ffe38cab GIT binary patch literal 2199 zcmV;I2x#|-P)Px#32;bRa{vGf6951U69E94oEQKA0{~D=R7FQ{Oq!vx ze}+AOW?e_fc_WbMi|LXMpNJ~|EXlJ0OxrB?IpQgB&pRoY}0h*z+hK-+` zqqU2Yq?@9&eT0{ak)w!@p@4^(hmN3uh?M3@LM|yN zB`G;IIU5fQI4?1|$=*^xJCnge>*BVWkG+?Pjd*pF zYG5-mI6592q_)mqUS?BQW6s;{h?%%NN@a0_ret-KFefTMGc#o(Xj|XN zy`74L@A&?ZaALrrl%%ArfmTf)AS=hLq4L_!gmZ5|K}Ty?T1YA*oUO(v3<^RqD}aKI zkD$I;YK%}{e3`1pTUlXjaD0)Z!B|H_UsYM4l$Nf))!ypzrmwzge44SYwY0s&p_{x zuivlFzmS)l?Zf~81k_1HK~y-)ebskZ6G<2c;6*{;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entserver-example/csharp/DocEditor.aspx index 4d254058..e4c6cdb6 100644 --- a/web/documentserver-example/csharp/DocEditor.aspx +++ b/web/documentserver-example/csharp/DocEditor.aspx @@ -272,9 +272,29 @@ // add mentions for not anonymous users <% if (!string.IsNullOrEmpty(UsersForMentions)) { %> - config.events['onRequestUsers'] = function () { - docEditor.setUsers({ // set a list of users to mention in the comments - "users": <%= UsersForMentions %> + config.events['onRequestUsers'] = function (event) { + if (event && event.data){ + var c = event.data.c; + } + switch (c) { + case "info": + users = []; + var allUsers = <%= UsersInfo %>; + for (var i = 0; i < event.data.id.length; i++) { + for (var j = 0; j < allUsers.length; j++) { + if (allUsers[j].id == event.data.id[i]) { + users.push(allUsers[j]); + break; + } + } + } + break; + default: + users = <%= UsersForMentions %>; + } + docEditor.setUsers({ + "c": c, + "users": users, }); }; <% } %> diff --git a/web/documentserver-example/csharp/DocEditor.aspx.cs b/web/documentserver-example/csharp/DocEditor.aspx.cs index 334112a9..28a2a67d 100755 --- a/web/documentserver-example/csharp/DocEditor.aspx.cs +++ b/web/documentserver-example/csharp/DocEditor.aspx.cs @@ -64,6 +64,7 @@ namespace OnlineEditorsExample protected string DocumentData { get; private set; } protected string DataSpreadsheet { get; private set; } protected string UsersForMentions { get; private set; } + protected string UsersInfo { get; private set; } protected string DocumentType { get { return _Default.DocumentType(FileName); } } // get callback url @@ -256,7 +257,8 @@ namespace OnlineEditorsExample { { "id", !user.id.Equals("uid-0") ? user.id : null }, { "name", user.name }, - { "group", user.group } + { "group", user.group }, + { "image", user.avatar ? _Default.GetServerUrl(false) + "/App_Themes/images/"+ user.id + ".png" : null } } }, { @@ -317,6 +319,9 @@ namespace OnlineEditorsExample // get users for mentions List> usersData = Users.getUsersForMentions(user.id); UsersForMentions = !user.id.Equals("uid-0") ? jss.Serialize(usersData) : null; + + List> usersInfo = Users.getUsersInfo(user.id); + UsersInfo = jss.Serialize(usersData); } catch { } } diff --git a/web/documentserver-example/csharp/Users.cs b/web/documentserver-example/csharp/Users.cs index 1dea57de..40c250a0 100644 --- a/web/documentserver-example/csharp/Users.cs +++ b/web/documentserver-example/csharp/Users.cs @@ -30,7 +30,8 @@ namespace OnlineEditorsExample "Can perform all actions with comments", "The file favorite state is undefined", "Can create files from templates using data from the editor", - "Can see the information about all users" + "Can see the information about all users", + "Has an avatar" }; static List descr_user_2 = new List() @@ -40,7 +41,8 @@ namespace OnlineEditorsExample "Can view comments, edit his own comments and comments left by users with no group. Can remove his own comments only", "This file is marked as favorite", "Can create new files from the editor", - "Can see the information about users from Group2 and users who don’t belong to any group" + "Can see the information about users from Group2 and users who don’t belong to any group", + "Has an avatar" }; static List descr_user_3 = new List() @@ -84,6 +86,7 @@ namespace OnlineEditorsExample null, new List(), descr_user_1, + true, true ), new User( @@ -102,7 +105,8 @@ namespace OnlineEditorsExample true, new List(), descr_user_2, - false + false, + true ), new User( "uid-3", @@ -120,6 +124,7 @@ namespace OnlineEditorsExample false, new List() { "copy", "download", "print" }, descr_user_3, + false, false ), new User( @@ -133,6 +138,7 @@ namespace OnlineEditorsExample null, new List() { "protect" }, descr_user_0, + false, false ) }; @@ -171,6 +177,24 @@ namespace OnlineEditorsExample } return usersData; } + + public static List> getUsersInfo(string id) + { + List> usersData = new List>(); + if(id != "uid-0"){ + foreach (User user in users) + { + usersData.Add(new Dictionary() + { + {"id", user.id}, + {"name", user.name }, + {"email", user.email }, + {"image", user.avatar ? _Default.GetServerUrl(false) + "/App_Themes/images/"+ user.id + ".png" : null } + }); + } + } + return usersData; + } } public class User @@ -186,8 +210,9 @@ namespace OnlineEditorsExample public List descriptions; public bool templates; public List userInfoGroups; + public bool avatar; - public User(string id, string name, string email, string group, List reviewGroups, Dictionary commentGroups, List userInfoGroups, bool? favorite, List deniedPermissions, List descriptions, bool templates) + public User(string id, string name, string email, string group, List reviewGroups, Dictionary commentGroups, List userInfoGroups, bool? favorite, List deniedPermissions, List descriptions, bool templates, bool avatar) { this.id = id; this.name = name; @@ -200,6 +225,7 @@ namespace OnlineEditorsExample this.descriptions = descriptions; this.templates = templates; this.userInfoGroups = userInfoGroups; + this.avatar = avatar; } } }