mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
- Renamed 'doclist' dashlet to 'docsummary'
- Added docsummary data webscript to provide recently modified docs - Updated styles for lists in dashboard.css - Added 'error' style to base.css (just red text at the moment) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9320 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
<webscript>
|
||||||
|
<shortname>docsummary</shortname>
|
||||||
|
<description>Document Summary Component Data Webscript</description>
|
||||||
|
<url>/slingshot/docsummary?site={site}&filter={filter?}</url>
|
||||||
|
<format default="json"></format>
|
||||||
|
<authentication>user</authentication>
|
||||||
|
<transaction>required</transaction>
|
||||||
|
</webscript>
|
@@ -0,0 +1 @@
|
|||||||
|
<#include "docsummary.get.json.ftl">
|
@@ -0,0 +1,81 @@
|
|||||||
|
|
||||||
|
/**
|
||||||
|
* Document Summary Component: docsummary
|
||||||
|
*
|
||||||
|
* Inputs:
|
||||||
|
* mandatory: site = the site to get documents from
|
||||||
|
* optional: filter = the filter to apply
|
||||||
|
*
|
||||||
|
* Outputs:
|
||||||
|
* docs - object containing list of documents
|
||||||
|
*/
|
||||||
|
model.docs = getDocs(args["site"], args["filter"]);
|
||||||
|
|
||||||
|
/* Create collection of documents */
|
||||||
|
function getDocs(siteId, filter)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
/* siteId input */
|
||||||
|
var site = siteService.getSite(siteId);
|
||||||
|
if (site === null)
|
||||||
|
{
|
||||||
|
return jsonError("Site not found: " + siteId);
|
||||||
|
}
|
||||||
|
|
||||||
|
var parentNode = site.getContainer("documentLibrary");
|
||||||
|
if (parentNode === null)
|
||||||
|
{
|
||||||
|
return jsonError("Document Library container not found in: " + siteId + ". (No write permission?)");
|
||||||
|
}
|
||||||
|
|
||||||
|
// build up the query to get documents modified in the last 7 days
|
||||||
|
var path = parentNode.qnamePath + "//*";
|
||||||
|
|
||||||
|
var date = new Date();
|
||||||
|
var toQuery = date.getFullYear() + "\\-" + (date.getMonth()+1) + "\\-" + date.getDate();
|
||||||
|
date.setDate(date.getDate() - 7);
|
||||||
|
var fromQuery = date.getFullYear() + "\\-" + (date.getMonth()+1) + "\\-" + date.getDate();
|
||||||
|
|
||||||
|
search.setStoreUrl("workspace://SiteStore");
|
||||||
|
var docs = search.luceneSearch("+PATH:\"" + path + "\"" +
|
||||||
|
" +@cm\\:modified:[" + fromQuery + "T00\\:00\\:00 TO " + toQuery + "T23\\:59\\:59]",
|
||||||
|
"cm:modified", false);
|
||||||
|
|
||||||
|
var items = null;
|
||||||
|
|
||||||
|
// restrict results to 10 items if necessary
|
||||||
|
if (docs.length > 10)
|
||||||
|
{
|
||||||
|
items = new Array();
|
||||||
|
for (var x = 0; x < 10; x++)
|
||||||
|
{
|
||||||
|
items.push(docs[x]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
items = docs;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ({
|
||||||
|
"items": items
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch(e)
|
||||||
|
{
|
||||||
|
return jsonError(e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Format and return error object */
|
||||||
|
function jsonError(errorString)
|
||||||
|
{
|
||||||
|
var obj =
|
||||||
|
{
|
||||||
|
"error": errorString
|
||||||
|
};
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
<#if docs.error?exists>
|
||||||
|
"error": "${docs.error}"
|
||||||
|
<#else>
|
||||||
|
"items":
|
||||||
|
[
|
||||||
|
<#list docs.items as d>
|
||||||
|
{
|
||||||
|
"nodeRef": "${d.nodeRef}",
|
||||||
|
"icon16": "${d.icon16}",
|
||||||
|
"icon32": "${d.icon32}",
|
||||||
|
"name": "${d.name}",
|
||||||
|
"title": "${d.properties.title!""}",
|
||||||
|
"description": "${d.properties.description!""}",
|
||||||
|
"createdOn": "${d.properties.created?datetime}",
|
||||||
|
"createdBy": "${d.properties.creator}",
|
||||||
|
"modifiedOn": "${d.properties.modified?datetime}",
|
||||||
|
"modifiedBy": "${d.properties.modifier}"
|
||||||
|
}<#if d_has_next>,</#if>
|
||||||
|
</#list>
|
||||||
|
]
|
||||||
|
</#if>
|
||||||
|
}
|
Reference in New Issue
Block a user