Configuration added for web-client to setup default dashlets shown in a user Dashboard on first login

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5979 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2007-06-15 15:07:36 +00:00
parent 3131468788
commit 1883c7b020
4 changed files with 63 additions and 11 deletions

View File

@@ -193,6 +193,7 @@
<config evaluator="string-compare" condition="Dashboards"> <config evaluator="string-compare" condition="Dashboards">
<!-- Dashboard layouts and available dashlets for the My Alfresco pages --> <!-- Dashboard layouts and available dashlets for the My Alfresco pages -->
<!-- see http://wiki.alfresco.com/wiki/User_Configurable_Dashboards -->
<dashboards> <dashboards>
<layouts> <layouts>
<!-- the mandatory "default" layout - will be used for all users initially --> <!-- the mandatory "default" layout - will be used for all users initially -->
@@ -209,17 +210,18 @@
label-id="layout_three_column_label" description-id="layout_three_column_desc" label-id="layout_three_column_label" description-id="layout_three_column_desc"
jsp="/jsp/dashboards/layouts/three-column.jsp" /> jsp="/jsp/dashboards/layouts/three-column.jsp" />
</layouts> </layouts>
<dashlets> <dashlets>
<!-- this is the default dashlet shown in the default layout initially --> <!-- this is the default dashlet shown in the default layout initially -->
<!-- the default dashlet must have the id of 'getting-started' --> <!-- the default dashlet must have the id of 'getting-started' -->
<dashlet id="getting-started" label-id="dashlet_gettingstarted_label" <dashlet id="getting-started" label-id="dashlet_gettingstarted_label"
description-id="dashlet_gettingstarted_desc" description-id="dashlet_gettingstarted_desc"
jsp="/jsp/dashboards/dashlets/getting-started.jsp" allow-narrow="false" /> jsp="/jsp/dashboards/dashlets/getting-started.jsp" allow-narrow="false" />
<dashlet id="tasks-active" label-id="tasks_active_title" description-id="tasks_active_desc"
jsp="/jsp/workflow/tasks-active-dashlet.jsp" allow-narrow="false" />
<!-- this dashlet 'tasks-todo' is also shown by default for all users --> <!-- this dashlet 'tasks-todo' is also shown by default for all users -->
<dashlet id="tasks-todo" label-id="my_tasks_todo_title" description-id="my_tasks_todo_desc" <dashlet id="tasks-todo" label-id="my_tasks_todo_title" description-id="my_tasks_todo_desc"
jsp="/jsp/workflow/tasks-todo-dashlet.jsp" allow-narrow="false" /> jsp="/jsp/workflow/tasks-todo-dashlet.jsp" allow-narrow="false" />
<dashlet id="tasks-active" label-id="tasks_active_title" description-id="tasks_active_desc"
jsp="/jsp/workflow/tasks-active-dashlet.jsp" allow-narrow="false" />
<dashlet id="pooled-tasks" label-id="pooled_tasks_title" description-id="pooled_tasks_desc" <dashlet id="pooled-tasks" label-id="pooled_tasks_title" description-id="pooled_tasks_desc"
jsp="/jsp/workflow/pooled-tasks-todo-dashlet.jsp" allow-narrow="false" /> jsp="/jsp/workflow/pooled-tasks-todo-dashlet.jsp" allow-narrow="false" />
<dashlet id="tasks-completed" label-id="my_tasks_completed_title" description-id="my_tasks_completed_desc" <dashlet id="tasks-completed" label-id="my_tasks_completed_title" description-id="my_tasks_completed_desc"
@@ -235,6 +237,15 @@
<dashlet id="mywebforms-webscript" label="My Web Forms" description="My Web Forms WebScript" <dashlet id="mywebforms-webscript" label="My Web Forms" description="My Web Forms WebScript"
jsp="/jsp/dashboards/dashlets/mywebforms-webscript.jsp" /> jsp="/jsp/dashboards/dashlets/mywebforms-webscript.jsp" />
</dashlets> </dashlets>
<!-- configuration of the default dashlets to display when users login for the first time -->
<!-- if this config is removed, then no dashlets will be shown by default -->
<!-- overides of this config should redefine the entire list, not assume additions to it -->
<default-dashlets>
<dashlet id="getting-started" />
<dashlet id="tasks-todo" />
</default-dashlets>
<!-- set true allow the Guest user to configure the dashboard view - false by default --> <!-- set true allow the Guest user to configure the dashboard view - false by default -->
<allow-guest-config>false</allow-guest-config> <allow-guest-config>false</allow-guest-config>
</dashboards> </dashboards>

View File

@@ -162,16 +162,17 @@ public class DashboardManager
Page page = new Page("default", layout); Page page = new Page("default", layout);
Column defaultColumn = new Column(); Column defaultColumn = new Column();
// add the default dashlet(s) to the column // add the default dashlet(s) to the column as specified in the config
DashletDefinition dashlet = config.getDashletDefinition(DASHLET_STARTEDDEFAULT); if (config.getDefaultDashlets() != null)
if (dashlet != null)
{ {
defaultColumn.addDashlet(dashlet); for (String id : config.getDefaultDashlets())
} {
dashlet = config.getDashletDefinition(DASHLET_TASKSDEFAULT); DashletDefinition dashlet = config.getDashletDefinition(id);
if (dashlet != null) if (dashlet != null)
{ {
defaultColumn.addDashlet(dashlet); defaultColumn.addDashlet(dashlet);
}
}
} }
// add the column to the page and we are done // add the column to the page and we are done

View File

@@ -24,6 +24,7 @@
*/ */
package org.alfresco.web.config; package org.alfresco.web.config;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@@ -45,6 +46,7 @@ public class DashboardsConfigElement extends ConfigElementAdapter
private Map<String, LayoutDefinition> layoutDefs = new LinkedHashMap<String, LayoutDefinition>(4, 1.0f); private Map<String, LayoutDefinition> layoutDefs = new LinkedHashMap<String, LayoutDefinition>(4, 1.0f);
private Map<String, DashletDefinition> dashletDefs = new LinkedHashMap<String, DashletDefinition>(8, 1.0f); private Map<String, DashletDefinition> dashletDefs = new LinkedHashMap<String, DashletDefinition>(8, 1.0f);
private List<String> defaultDashlets = null;
private boolean allowGuestConfig = false; private boolean allowGuestConfig = false;
/** /**
@@ -91,6 +93,18 @@ public class DashboardsConfigElement extends ConfigElementAdapter
combinedElement.allowGuestConfig = newElement.allowGuestConfig; combinedElement.allowGuestConfig = newElement.allowGuestConfig;
} }
// the default-dashlets list is completely replaced if config is overriden
if (newElement.defaultDashlets != null)
{
combinedElement.defaultDashlets =
(List<String>)((ArrayList<String>)newElement.defaultDashlets).clone();
}
else if (this.defaultDashlets != null)
{
combinedElement.defaultDashlets =
(List<String>)((ArrayList<String>)this.defaultDashlets).clone();
}
return combinedElement; return combinedElement;
} }
@@ -134,6 +148,20 @@ public class DashboardsConfigElement extends ConfigElementAdapter
return this.dashletDefs.values(); return this.dashletDefs.values();
} }
/*package*/ void addDefaultDashlet(String id)
{
if (this.defaultDashlets == null)
{
this.defaultDashlets = new ArrayList<String>(2);
}
this.defaultDashlets.add(id);
}
public Collection<String> getDefaultDashlets()
{
return this.defaultDashlets;
}
/** /**
* Structure class for the definition of a dashboard page layout * Structure class for the definition of a dashboard page layout
*/ */

View File

@@ -46,6 +46,7 @@ public class DashboardsElementReader implements ConfigElementReader
public static final String ELEMENT_DASHLETS = "dashlets"; public static final String ELEMENT_DASHLETS = "dashlets";
public static final String ELEMENT_DASHLET = "dashlet"; public static final String ELEMENT_DASHLET = "dashlet";
public static final String ELEMENT_GUESTCONFIG = "allow-guest-config"; public static final String ELEMENT_GUESTCONFIG = "allow-guest-config";
public static final String ELEMENT_DEFAULTDASHLETS = "default-dashlets";
public static final String ATTR_ID = "id"; public static final String ATTR_ID = "id";
public static final String ATTR_COLUMNS = "columns"; public static final String ATTR_COLUMNS = "columns";
public static final String ATTR_COLUMNLENGTH = "column-length"; public static final String ATTR_COLUMNLENGTH = "column-length";
@@ -95,6 +96,17 @@ public class DashboardsElementReader implements ConfigElementReader
} }
} }
Element defaultDashletsElement = element.element(ELEMENT_DEFAULTDASHLETS);
if (defaultDashletsElement != null)
{
Iterator<Element> dashletsItr = defaultDashletsElement.elementIterator(ELEMENT_DASHLET);
while (dashletsItr.hasNext())
{
String id = getMandatoryDashletAttributeValue(dashletsItr.next(), ATTR_ID);
configElement.addDefaultDashlet(id);
}
}
Element guestConfigElement = element.element(ELEMENT_GUESTCONFIG); Element guestConfigElement = element.element(ELEMENT_GUESTCONFIG);
if (guestConfigElement != null) if (guestConfigElement != null)
{ {