AnsweredAssumed Answered

Javascript API - variable 'site' for dashlet

Question asked by nancygaillard on Oct 21, 2014
Latest reply on Oct 28, 2014 by nancygaillard
Hi,

I am working on a Windows 7 64bits with Alfresco 4.2.e

I have created a dashlet. I would like it shows a list of datalists of a particular site, but the dashlet has to be in the main dashboard.

I can obtain a result but not that i would like to have. I dont know how to access directories.
-> I have tested the remote.call function but i dont know what i can write for the uri…
-> I have trying use siteservice too with siteService.getSite("administratif")…

I have in tomcat\webapps\share\WEB-INF\classes\alfresco\site-webscripts\org\alfresco\components\dashlets :

- datalists-list.get.desc.xml
- datalists-list.get.html.ftl
- datalists-list.get.js


datalists-list.get.desc.xml :

<webscript>
    <shortname>Appels et Courriers</shortname>
    <description>Liste des listes d'appels et de courriers</description>
    <family>user-dashlet</family>
      <url>/components/dashlets/datalists-list</url>
</webscript>


datalists-list.get.html.ftl

<@markup id="js">
   <#– Your JavaScript file. You actually only need the my-dashlet-min.js file (unless in development mode), but we usually keep the original source in my-dashlet.js there so we can change it later.–>
   <@script type="text/javascript" src="${url.context}/res/components/dashlets/datalists-list.js" group="dashlets"/>
</@>
<@markup id="html">
  <@uniqueIdDiv>
      <div class="dashlet">
         <div class="title">Lites d'appels et de courriers</div>
         <div class="body">
            ${msg[0]} - ${msg[1]} - ${msg[2]} - ${msg[3]}<br/>
            <#if listes?exists>
               <#if listes?is_boolean>
                  Aucune liste d'appels ou de courrier
               <#else>
                  <#list listes as liste>
                     <a href="${url.serviceContext}/repo/node/${liste.id}">${liste.title}</a><br/>
                  </#list>
               </#if>
            <#else>
               liste non défini
            </#if>
         </div>
      </div>
   </@>
</@>


datalists-list.get.js :

<import resource="classpath:/alfresco/templates/org/alfresco/import/alfresco-util.js">
var listes = false;
var msg = [];

var dossier = sites.childByNamePath("Sites").childByNamePath("administratif");
if(dossier && dossier.childByNamePath("dataLists")){
   dossier = dossier.childByNamePath("dataLists");
   listes = dossier.children;
   msg[0] = "dossier Site et administratif trouvé";
}else msg[0] = "dossier sites et administratif non trouvé";

model.listes = listes;
model.msg = msg;

Outcomes