cancel
Showing results for 
Search instead for 
Did you mean: 

Custom dashlet: list documents contained in a Space

theorbix
Confirmed Champ
Confirmed Champ
Hello, I would like to develop a "parametric dashlet" that will display the list of documents contained in any valid Space, passing the Space unique name (or unique ID) as a parameter of the Dashlet.

Is such a thing possible?

So far I've developed a prototype Dashlet that uses a very simple freemarker script:

<#ftl strip_whitespace=true />
<#setting locale="it_IT"/>
<#setting datetime_format="short">

<!– Search a given space by its unique node ID –>
<!– This is a workaround since the childByNamePath method does not seem to work… –>
<#assign folderID = companyhome.childrenByLuceneSearch["ID:workspace\\:\\/\\/SpacesStore\\/2f93b4a6-f609-11dc-a589-999071556af1"] />
<#list folderID as child>
   <#assign folderContent = child.children />
</#list>

<!– Display all documents in the space –>

<script>var AlfNodeInfoMgr = new Alfresco.PanelManager("NodeInfoBean.sendNodeInfo", "noderef");</script>
<table class="recordSet" width=100%>
   
   <thead>
      <tr>
         <th style="padding:2px;text-align:left" class="recordSetHeader" colspan=2><b>Documento</b></th>
         <th style="padding:2px;text-align:left" class="recordSetHeader"><b>Data aggiorn.</b></th>
      </tr>
   </thead>
  
   <tbody>
      <#list folderContent as child>
         <#assign rowstyle="recordSetRow" />
         <#if (child_index % 2 = 1)>
            <#assign rowstyle="recordSetRowAlt" />
         <#else>
            <#assign rowstyle="recordSetRow" />
         </#if>
         <#if child.isDocument>
           <tr valign=top class="${rowstyle}">
             <td style="padding:2px;text-align:right;vertical-align:top;padding-right:10px;">
             <a href="/alfresco${child.url}" target="_blank">
             <img src="/alfresco${child.icon32}" border=0></a>
             </td>
             <td style="padding:2px;text-align:left;vertical-align:top;padding-right:10px;">
              <a href="/alfresco${child.url}" target="_blank">${child.properties.name}</a>
               <span onclick="AlfNodeInfoMgr.toggle('${child.nodeRef}',this);">
               <img id="browse:col1-img" src="/alfresco/images/icons/popup.gif" height="16" width="16" class="popupImage" />
               </span>
             </td>
             <td style="padding:2px;text-align:left"><nobr>${child.properties["cm:modified"]?datetime}</nobr>
             </td>
           </tr>
         </#if>
      </#list>
   </tbody>
   </table>

The code works well, but unfortunately the ID of the space to be "listed" in the Dashlet output is hardcoded at the beginning of the Freemarker script.

Unfortunately this code is not reusable. With the current approach, if I want to create a "My Alfresco" dashboard with (for instance) three Dashlets showing the content of three different spaces ("Whitepapers", "Brochures", "PowerPoint presentations"), I should define three different dashlets, each pointing to a different .jsp page and a different .ftl script, embedding the space ID.

Ideally, I would have a single Dashlet (maybe based on a WebScript instead than on a Freemarker script as in the current prototype) capable of receiving, as a parameter, the name or the ID of the space to be listed.

Has anyone already done something similar? I would not be surprised, because having a generic "List space content" Dashlet would  certainly be a nice add-on the the Web Client….
3 REPLIES 3

lnfalandino
Champ in-the-making
Champ in-the-making
While I haven't done such a thing, I wanted to give this idea another vote of support. I'd like to do something similar and if anyone has any thoughts I'd be happy to hear them.

This isn't a top priority for me, but I will be looking into it myself in the future.

theorbix
Confirmed Champ
Confirmed Champ
While I haven't done such a thing, I wanted to give this idea another vote of support. I'd like to do something similar and if anyone has any thoughts I'd be happy to hear them.
This isn't a top priority for me, but I will be looking into it myself in the future.

Yes I do believe that this would be a useful general purpose enhancement for the Alfresco Web Client. "Parametric dashlets" would be something pretty useful, in a way similar to the way parametric portlets can be used in most web portal frameworks.

I'm also pretty sure that someone with enough knowledge of the Web Client internals and JSF can implement this enhancement and contribute it back. Unfortunately I'm not a great Java developer, otherwise I would have tried by myself…

By the way, the only progress I've made so far is a slighly more elegant way of browsing the content a space in a Dashlet. You can see the details on this post http://forums.alfresco.com/viewtopic.php?f=12&t=12006. The code is simply a bit cleaner than the one shown above…

Another enhancement is that now the Freemarker script is stored in the Alfresco repository, and not in Tomcat. So it's much easier to edit the "path" of the space to display in case I want my Dashlet to display the content of a different space.

Unfortunately, to have 3 dashlet listing the content of three different spaces (e.g. "Marketing stuff", "Offers", "HR Documentation"), I will have to create three copies of the same dashlet config files, and three almost identical Freemarker scripts (one for each space): a bit cumbersome, but better than nothing…

rafaelscg
Champ on-the-rise
Champ on-the-rise
You can use <#macro> to make a recursive template and get all spaces what you want.