AnsweredAssumed Answered

Can't create custom  Dashlets Site Members with user details

Question asked by dga on Jan 4, 2013
Latest reply on Jan 7, 2013 by dga
Hello all,

I try to create a custom dashlets based on Site Members dashlets.
Original dashlet Site Members list all user in that site.

All i want is to add some user details like jobtitle, email, telephone…

in my *.get.html.ftl i have:

[…]
<#list memberships as m>
               <div class="detail-list-item">
                  <div class="avatar">
                     <#assign avatarNodeRef>${m.authority.avatarNode!"avatar"}</#assign>
                     <img src="${url.context}/proxy/alfresco/slingshot/profile/avatar/${avatarNodeRef?string?replace('://','/')}" alt="Avatar" />
               </div>      
                     <a href="${url.context}/page/user/${m.authority.userName?url}/profile" class="theme-color-1">${m.authority.firstName?html}
                     <#if m.authority.lastName??>${m.authority.lastName?html} </#if></a><br />
           ${jobtitle?html} <br />
      
                  <div class="clear"></div>
               </div>
</#list>
[…]

and in *.get.js

[…]

function getJobtitle(userName){
   var detaliiUtilizator = remote.call("/api/people/" + userName);
   
      var objDetalii = eval('(' + detaliiUtilizator + ')');      
      if(objDetalii){
         jobtitle = objDetalii.jobtitle;
      }      
         
      return jobtitle;
}

/**
* Site Colleagues component GET method
*/
function main()
{
// Call the repo for the site memberships
   var maxItems = getMaxItems(),
      size = maxItems + 1,
      json = remote.call("/api/sites/" + page.url.templateArgs.site + "/memberships?size=" + size + "&authorityType=USER");
 
var memberships = [],
      totalResults = 0;
  
   if (json.status == 200)
   {
      // Create javascript objects from the repo response
      var obj = eval('(' + json + ')');
      if (obj)
      {
         totalResults = obj.length;
         memberships = obj.slice(0, maxItems);

         var member, userStatus, userName, jobtitlem;
         for (var i = 0, j = memberships.length; i < j; i++)
         {
         
            member = memberships[i];
            userStatus = member.authority.userStatus;
            jobtitle = getJobtitle(member.authority.userName);
         }
         memberships.sort(sortByName);
      }
   }
  
   // Prepare the model
   model.memberships = memberships;
 
   model.jobtitle = jobtitle;
   model.totalResults = totalResults;
   model.maxResults = maxItems;
 
   model.userMembership = AlfrescoUtil.getSiteMembership(page.url.templateArgs.site);
[…]


the result list is:

Administrator
Manager

User Test
Manager

expected result

Administrator
Manager

User Test
Consummer

I don't know how to make in template or js to get correct result.
Thank you all for help.

Outcomes