Skip to content

Commit a62006f

Browse files
committed
0.4:
- datatable columns can now be configured to be shown or hidden - an extra field has been added to the config dialog to pass additional server side query parameters. See the wiki documentation (http://wiki.alfresco.com/wiki/Auditing_(from_V3.4)#Advanced_Query) and the web script description. - datatable css fix for google chrome, and various css tweaks - Added help link opposite the config link git-svn-id: https://share-extras.googlecode.com/svn/trunk/Sandbox/Audit Dashlet@728 a3f5c567-fd0f-3a89-9b71-a290c5a5f590
1 parent c9e68bc commit a62006f

16 files changed

+449
-136
lines changed

README.txt

Lines changed: 49 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,60 +3,73 @@ Audit Application dashlet for Alfresco Share
33

44
Author: Romain Guinot
55

6-
This project defines a custom dashlet to display events for a given audit application.
6+
This project defines a custom dashlet to display events for any given audit application.
77

8-
The dashlet will need to have auditing application(s) already configured, and to be useful some events captured.
8+
The dashlet will need to have auditing application(s) already configured, and, to be useful, some events captured.
99
See http://wiki.alfresco.com/wiki/Auditing_(from_V3.4) on how to define audit applications and some samples.
1010

11+
From 3.4.4, also see http://wiki.alfresco.com/wiki/Content_Auditing and http://wiki.alfresco.com/wiki/Audit_Filter.
12+
1113
Installation
1214
------------
1315

14-
The dashlet has been developed to install on top of an existing Alfresco
15-
3.4 installation.
16+
The dashlet has been developed to install on top of an existing Alfresco 3.4 installation.
17+
18+
* Users : Prebuilt jar
19+
20+
A prebuilt jar is provided. You only need to copy it to <tomcat-home>/shared/lib.
1621

17-
An Ant build script is provided to build a JAR file containing the
18-
custom files, which can then be installed into the 'tomcat/shared/lib' folder
19-
of your Alfresco installation.
22+
* Developers : Building the jar
2023

21-
To build the JAR file, run the following command from the base project
22-
directory.
24+
For developers, an Ant build script is provided to build a JAR file containing the
25+
custom files, which can then be installed into the 'tomcat/shared/lib' folder
26+
of your Alfresco installation.
2327

24-
ant clean dist-jar
28+
To build the JAR file, run the following command from the base project
29+
directory.
2530

26-
The command should build a JAR file named sample-audit-dashlet.jar
27-
in the 'dist' directory within your project.
31+
ant clean dist-jar
2832

29-
To deploy the dashlet files into a local Tomcat instance for testing, you can
30-
use the hotcopy-tomcat-jar task. You will need to set the tomcat.home
31-
property in Ant.
33+
The command should build a JAR file named sample-audit-dashlet.jar in the 'dist' directory within your project.
3234

33-
ant -Dtomcat.home=C:/Alfresco/tomcat clean hotcopy-tomcat-jar
35+
To deploy the dashlet files into a local Tomcat instance for testing, you can
36+
use the hotcopy-tomcat-jar task. You will need to set the tomcat.home
37+
property in Ant.
3438

35-
Once you have run this you will need to restart Tomcat so that the classpath
36-
resources in the JAR file are picked up.
39+
ant -Dtomcat.home=C:/Alfresco/tomcat clean hotcopy-tomcat-jar
3740

38-
As an alternative, you may also copy the exploded files in your classpath, but they must have the classpath tree than the one in the jar.
39-
If using development/debug mode for the web framework, you will not need to restart tomcat, but you may have to clear your
40-
browser's cache.
41+
Once you have run this you will need to restart Tomcat so that the classpath resources in the JAR file are picked up.
42+
43+
As an alternative, you may also copy the exploded files in your classpath, but they must have the classpath tree
44+
than the one in the jar. If using development/debug mode for the web framework, you will not need to restart tomcat,
45+
but you may have to clear your browser's cache.
4146

4247
Using the dashlet
4348
-----------------
4449

45-
Log in to Alfresco Share and navigate to a site or user dashboard. Click the
46-
Customize Dashboard button to edit the contents of the dashboard and drag
47-
the dashlet into one of the columns from the list of dashlets.
50+
Log in to Alfresco Share and navigate to a site or user dashboard. Click the 'Customize Dashboard' button to edit the contents
51+
of the dashboard and drag the dashlet into one of the columns from the list of dashlets.
4852

4953
* Configuration :
5054

5155
Click Configure to choose an existing audit application. Results will appear as you type and will be matched
5256
against the live list of audit applications as reported by /api/audit/control.
5357

54-
For convenience, application names are prepended with a space. So by typing a leading space in the search box,
55-
you will see the full list of applications in the suggestions. May be useful if you don't know what application name to search for.
58+
For convenience, the list will pop out when opening the configure dialog with no applications currently configured.
59+
Could be useful if you don't know what application name to search for.
60+
61+
The number of data rows (audit events) per page is configurable by the 'Entries per page' parameter.
5662

57-
If you want you can also select an additional value filter to limit the results.
58-
This server-side filter correspond to the "value" parameter optionally passed to the audit query.
59-
(See http://wiki.alfresco.com/wiki/Auditing_(from_V3.4)#Advanced_Query). This filtering is done server-side
63+
Additional server side filters are configurable :
64+
UI Name Description Audit API corresponding parameter
65+
-----------------------------------------------------------------------------------------------------------
66+
- value filter filter on the audit value (exact match,optional) 'value'
67+
- limit maximum number of audit entries retrieved (optional) 'limit'
68+
- Additional Query params other possible query parameters (optional) from/to time, from/to id, user
69+
70+
(See http://wiki.alfresco.com/wiki/Auditing_(from_V3.4)#Advanced_Query). This filtering is done server-side.
71+
72+
The columns to display are also configurable (show/hide).
6073

6174
* Search box
6275

@@ -93,6 +106,13 @@ the dashlet into one of the columns from the list of dashlets.
93106

94107
Changelog
95108
---------
109+
0.4:
110+
- datatable columns can now be configured to be shown or hidden
111+
- an extra field has been added to the config dialog to pass additional server side query parameters.
112+
See the wiki documentation (http://wiki.alfresco.com/wiki/Auditing_(from_V3.4)#Advanced_Query) and the web script description.
113+
- datatable css fix for google chrome, and various css tweaks
114+
- Added help link opposite the config link
115+
96116
0.31:
97117
- build.properties more consistent with other projects
98118
- distributed jar had a wrong french bundle filename
@@ -122,4 +142,3 @@ Changelog
122142
0.2 : search box / query filtering
123143

124144
0.1 : inital release
125-

build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
build.version=0.31
1+
build.version=0.4
22
project.name=sample-audit-dashlet
33
jar.name=${project.name}-${build.version}.jar

build.xml

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@
9292

9393
<!-- Create required prerequisite directory structure -->
9494
<target name="prepare" description="Create initial build structures">
95-
<mkdir dir="${build.dir}" />
95+
<mkdir dir="${build.dir}" />
9696
<mkdir dir="${dist.dir}" />
9797
</target>
9898

99-
<!--
99+
<!--
100100
Assemble the configuration and resource files in a JAR file structure. This mechanism
101101
was introduced in Alfresco 3.3 and allows Share extensions containing web scripts, Surf
102102
configuration and static assets to be added to the servlet container as shared libraries.
@@ -106,8 +106,8 @@
106106
107107
This target excludes the files custom-slingshot-application-context.xml, share-config-custom.xml
108108
and similar files as only one of these should be present on the classpath.
109-
-->
110-
<target name="build-jar" description="Assemble configuration and resource files in a JAR file structure">
109+
-->
110+
<target name="build-jar" description="Assemble configuration and resource files in a JAR file structure">
111111
<mkdir dir="${build.jar.dir}" />
112112
<copy todir="${build.jar.dir}" includeEmptyDirs="false">
113113
<fileset dir="${config.dir}" includes="${config.includes}" excludes="${config.excludes}" >
@@ -124,28 +124,48 @@
124124
<yuicompress fromdir="${res.dir}" todir="${build.jar.dir}/META-INF" excludes="**/*-min.js" warn="yuicompress.warn">
125125
<include name="**/*.js" />
126126
</yuicompress>
127-
</target>
128-
129-
<!-- Build the JAR file -->
130-
<target name="dist-jar" depends="clean, prepare, build-jar"
131-
description="Build a JAR file containing configuration and resource files">
132-
<jar destfile="${dist.dir}/${jar.name}">
133-
<fileset dir="${build.jar.dir}" />
134-
</jar>
127+
128+
<jar destfile="${dist.dir}/${jar.name}">
129+
<fileset dir="${build.jar.dir}" />
130+
</jar>
135131
</target>
136-
132+
133+
<!-- Distribute the JAR file -->
134+
<target name="dist-jar" depends="clean, prepare, copy-en-l10n-bundles, build-jar, write-sha1sums"
135+
description="Distribute the JAR file">
136+
</target>
137+
138+
<target name="copy-en-l10n-bundles" description="Copy the default l10n bundles to the _en locale suffix">
139+
<delete>
140+
<fileset dir="${config.dir}/alfresco/site-webscripts">
141+
<include name="**/*_en.properties" />
142+
</fileset>
143+
</delete>
144+
<copy todir="${config.dir}/alfresco/site-webscripts/org/alfresco/components/dashlets">
145+
<fileset dir="${config.dir}/alfresco/site-webscripts/org/alfresco/components/dashlets"/>
146+
<mapper type="regexp"
147+
from="^([^_]*).properties$"
148+
to="\1_en.properties"/>
149+
</copy>
150+
<copy todir="${config.dir}/alfresco/site-webscripts/org/alfresco/modules/dashlets">
151+
<fileset dir="${config.dir}/alfresco/site-webscripts/org/alfresco/modules/dashlets"/>
152+
<mapper type="regexp"
153+
from="^([^_]*).properties$"
154+
to="\1_en.properties"/>
155+
</copy>
156+
</target>
157+
137158
<target name="write-sha1sums">
138-
<delete file="${dist.dir}/SHA1SUM" quiet="true"/>
139-
<tstamp>
159+
<delete file="${dist.dir}/SHA1SUM" quiet="true"/>
160+
<tstamp>
140161
<format property="current.time" pattern="MM/dd/yyyy hh:mm aa"/>
141-
</tstamp>
142-
143-
<checksum file="${dist.dir}/${jar.name}" format="MD5SUM" algorithm="sha1" property="sha1.jar" readbuffersize="65536"/>
144-
<!--Note : we use a readbuffersize of 65536 to generate the same checksums as GNU coreutils (sha1sum, md5sum, ...) -->
162+
</tstamp>
145163

146-
<echo message="# Generated on ${current.time} ${line.separator}" file="${dist.dir}/SHA1SUM" append="true"/>
147-
<echo message="${sha1.jar} ${jar.name}${line.separator}" file="${dist.dir}/SHA1SUM" append="true"/>
164+
<checksum file="${dist.dir}/${jar.name}" format="MD5SUM" algorithm="sha1" property="sha1.jar" readbuffersize="65536"/>
165+
<!--Note : we use a readbuffersize of 65536 to generate the same checksums as GNU coreutils (sha1sum, md5sum, ...) -->
148166

167+
<echo message="# Generated on ${current.time} ${line.separator}" file="${dist.dir}/SHA1SUM" append="true"/>
168+
<echo message="${sha1.jar} ${jar.name}${line.separator}" file="${dist.dir}/SHA1SUM" append="true"/>
149169
</target>
150170

151171
<!--
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<webscript>
22
<shortname>Audit Application Data Component</shortname>
33
<description>Audit Application Data Component</description>
4-
<url>/components/dashlets/audit-application/entries?application={application}&amp;valueFilter={valueFilter}&amp;limit={limit}</url>
4+
<url>/components/dashlets/audit-application/entries?application={application}&amp;valueFilter={valueFilter}&amp;limit={limit}&amp;additionalQueryParams={additionalQueryParams}</url>
55
<format default="json">extension</format>
66
</webscript>

config/alfresco/site-webscripts/org/alfresco/components/dashlets/audit-application-data.get.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
11
function main()
22
{
3-
var application = args.application; // audit application name (as reported by /api/audit/control
4-
var valueFilter = args.valueFilter; // optional : "value" filter on the audit entries. match all
5-
var limit = args.limit; // optional : max entry count retrieved by the repo query
3+
var application = args.application; // audit application name (as reported by /api/audit/control
4+
var valueFilter = args.valueFilter; // optional : "value" filter on the audit entries. match all
5+
var limit = args.limit; // optional : max entry count retrieved by the repo query
6+
7+
// optional : free field to add in other server-side filters (e.g fromTime, ...)
8+
var additionalQueryParams = args.additionalQueryParams;
69

710
if (application != null)
811
{
9-
var additionalFilterQuery = valueFilter ? "&value=" + stringUtils.urlEncode(valueFilter) : "";
10-
if(logger.isLoggingEnabled())
12+
var valueFilterQuery = valueFilter ? "&value=" + stringUtils.urlEncode(valueFilter) : "";
13+
if(logger.isLoggingEnabled())
1114
logger.log(" application:" +application+ " - " + "valueFilter:" +valueFilter);
1215

1316
var maxEntryCount = limit ? "&limit=" + stringUtils.urlEncode(limit) : "";
17+
18+
// decode the '&' param separators from the optional additional params passed in by the dashlet.
19+
var optionalAdditionalQueryParams = additionalQueryParams ? ("&" + additionalQueryParams.replace(/\uFFFF/g,'&')) : "";
1420

15-
var sortOrder = "&forward=" + false;
21+
if(logger.isLoggingEnabled())
22+
logger.log(" optionalAdditionalQueryParams: '" +optionalAdditionalQueryParams+ "'");
23+
24+
var sortOrder = "&forward=" + false; // most recent first
1625

17-
var uri = "/api/audit/query/"+stringUtils.urlEncode(application)+"?verbose=true" + additionalFilterQuery + sortOrder + maxEntryCount;
26+
var uri = "/api/audit/query/"+stringUtils.urlEncode(application)+"?verbose=true"
27+
+ valueFilterQuery + sortOrder + maxEntryCount + optionalAdditionalQueryParams;
1828

1929
var connector = remote.connect("alfresco");
2030
var result = connector.get(uri);
@@ -23,7 +33,7 @@ function main()
2333

2434
if (result.status == status.STATUS_OK)
2535
{
26-
var rawresponse=result.response+""; // cast rawresponse back into a js string)
36+
var rawresponse = result.response+""; // cast rawresponse back into a js string
2737
//if(logger.isLoggingEnabled()) logger.log("rawresponse:\n"+rawresponse);
2838

2939
// the json outputted by the audit template does not quote user and application keys in the ouput

config/alfresco/site-webscripts/org/alfresco/components/dashlets/audit-application-data.get.json.ftl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
"values":
1212
{
1313
<#list e.values?keys as key>
14-
"${key?replace('.*/', '', 'r')}":"${e.values[key]}"
14+
<#-- keep only the audit key for readability -->
15+
<#-- and remove spurious/invalid linebreaks (see ALF-11190) -->
16+
"${key?replace('.*/', '', 'r')}":"${e.values[key]?replace('(\n|\r\n|\r)',' ','r')}"
1517
<#if key_has_next>,</#if>
1618
</#list>
1719
}

config/alfresco/site-webscripts/org/alfresco/components/dashlets/audit-application.get.html.ftl

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77
"application": "${args.application!''}",
88
"valueFilter": "${args.valueFilter!''}",
99
"limit": "${args.limit!''}",
10-
"rowsPerPage" : "${args.rowsPerPage!'10'}"
10+
"rowsPerPage" : "${args.rowsPerPage!'10'}",
11+
"additionalQueryParams" : "${args.additionalQueryParams!''}",
12+
"show_id_column" : "${args.show_id_column!'show'}",
13+
"show_user_column" : "${args.show_user_column!'show'}",
14+
"show_time_column" : "${args.show_time_column!'show'}",
15+
"show_values_column" : "${args.show_values_column!'show'}"
1116
}).setMessages(${messages});
1217
1318
<#-- dashlet resizer does not dynamically adjust the number of rows displayed on the page re: pagination -->
@@ -28,21 +33,30 @@
2833
<#-- audit only allows admin to query audit entries. therefore the dashlet is only usable by admin users. -->
2934
<#if userHasConfigPermission && userIsAdmin>
3035
<div class="toolbar" id="${el}-toolbar">
31-
<a class="theme-color-1" href="#" id="${el}-configure-link">${msg("audit.dashlet.link.configure")}</a>
36+
<span class="yui-button-align">
37+
<span class="first-child">
38+
<a class="theme-color-1" href="#" id="${el}-configure-link">${msg("audit.dashlet.link.configure")}</a>
39+
</span>
40+
</span>
41+
<span class="align-right yui-button-align">
42+
<span class="first-child spaced-more-left">
43+
<a class="theme-color-1" href="${msg("audit.dashlet.link.help.url")}" id="${el}-help-link" target="_blank">${msg("audit.dashlet.link.help")}</a>
44+
</span>
45+
</span>
3246
</div>
3347

3448
<#assign currentHeight=default_height>
3549
<#if args.height??><#assign currentHeight=args.height></#if>
3650
<div class="body" style="height: ${currentHeight}px;" id="${el}-body">
37-
<div class="message" id="${el}-message"></div>
51+
<div class="message spaced-left" id="${el}-message"></div>
3852

39-
<div class="markup" id="${el}-searchbox">
53+
<div class="markup spaced-left" id="${el}-searchbox">
4054
<#-- search box to filter audit values from YUI -->
4155
<label id="${el}-searchWithinResultsFilterLabel" for="${el}-searchWithinResultsFilter">${msg("audit.dashlet.searchWithinResults",0)} :</label>
4256
<input type="text" id="${el}-searchWithinResultsFilter">
4357
</div>
4458

45-
<div class="entries customScrollableList" id="${el}-entries"></div>
59+
<div class="entries custom-scrollable-list" id="${el}-entries"></div>
4660
</div>
4761

4862
<#else>

config/alfresco/site-webscripts/org/alfresco/components/dashlets/audit-application.get.properties

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
audit.dashlet.header.default=Audit Dashlet
22

33
audit.dashlet.link.configure=Configure
4+
audit.dashlet.link.help=Help
5+
audit.dashlet.link.help.url=http://code.google.com/p/share-extras/wiki/SampleAuditDashlet
46

57
audit.dashlet.notConfigured=No application is configured
68
audit.dashlet.notFound=The application could not be found
@@ -12,11 +14,11 @@ audit.dashlet.filteredResults={0} results ({1} filtered out)
1214
audit.dashlet.invalidSearch=Invalid search expression
1315
audit.dashlet.adminPrivilegesRequired=You need to be an admin user to query audit entries
1416

15-
audit.dashlet.th.id=ID
16-
audit.dashlet.th.application=Application
17-
audit.dashlet.th.user=User
18-
audit.dashlet.th.time=Timestamp
19-
audit.dashlet.th.values=Audited Values
17+
audit.dashlet.field.label.id=DB ID
18+
audit.dashlet.field.label.application=Application
19+
audit.dashlet.field.label.user=User
20+
audit.dashlet.field.label.time=Timestamp
21+
audit.dashlet.field.label.values=Audited Values
2022

2123
# Pagination
2224
audit.dashlet.firstPageLinkLabel=<< first
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
audit.dashlet.header.default=Audit Dashlet
2+
3+
audit.dashlet.link.configure=Configure
4+
audit.dashlet.link.help=Help
5+
audit.dashlet.link.help.url=http://code.google.com/p/share-extras/wiki/SampleAuditDashlet
6+
7+
audit.dashlet.notConfigured=No application is configured
8+
audit.dashlet.notFound=The application could not be found
9+
audit.dashlet.loading=Loading ...
10+
audit.dashlet.noEntries=No matching entries found
11+
audit.dashlet.searchWithinResults=Search within the {0} results
12+
audit.dashlet.valuefilteredOn=filtered on
13+
audit.dashlet.filteredResults={0} results ({1} filtered out)
14+
audit.dashlet.invalidSearch=Invalid search expression
15+
audit.dashlet.adminPrivilegesRequired=You need to be an admin user to query audit entries
16+
17+
audit.dashlet.field.label.id=DB ID
18+
audit.dashlet.field.label.application=Application
19+
audit.dashlet.field.label.user=User
20+
audit.dashlet.field.label.time=Timestamp
21+
audit.dashlet.field.label.values=Audited Values
22+
23+
# Pagination
24+
audit.dashlet.firstPageLinkLabel=<< first
25+
audit.dashlet.previousPageLinkLabel=< prev
26+
audit.dashlet.nextPageLinkLabel=next >
27+
audit.dashlet.lastPageLinkLabel=last >>
28+
audit.dashlet.pageReportTemplate={startRecord} - {endRecord} of {totalRecords}

0 commit comments

Comments
 (0)