. Changing default view after Login to the MyAlfresco dashboard for all users

- so new users see the helpful Getting Started page when logging in
 - this client config value can be changed if the sys admin does not want the MyAlfresco to be the default page
. Add User Preference to change the default view after login
 - so users familiar with the system can change their default view back to Home Space or similar
. Added client config to allow Guest user access to Configure Dashboard action (set to 'false' by default)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3652 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-09-01 15:42:35 +00:00
parent ac3ef0585a
commit 445fb40e86
15 changed files with 244 additions and 48 deletions

View File

@@ -932,6 +932,7 @@ old_password=Old Password
new_password=New Password
edit_user_details=Edit User Details
edit_user_details_description=Use this view to change your user details and email address
start_location=Start Location
# Delete Space Dialog messages
select_delete_operation=What do you want to delete?

View File

@@ -53,8 +53,8 @@
<home-space-permission>Consumer</home-space-permission>
<!-- The default location to display when the browse screen is first shown -->
<!-- This value should be one of 'companyhome', 'userhome', 'guesthome' or 'myalfresco' -->
<initial-location>userhome</initial-location>
<!-- This value should be one of 'myalfresco', 'userhome', 'companyhome' or 'guesthome' -->
<initial-location>myalfresco</initial-location>
<!-- the URL to the client Help file -->
<help-url>http://www.alfresco.org/help/webclient</help-url>
@@ -170,7 +170,7 @@
<!-- Dashboard layouts and available dashlets for the My Alfresco pages -->
<dashboards>
<layouts>
<!-- the "default" layout - will be used for all users initially -->
<!-- the mandatory "default" layout - will be used for all users initially -->
<layout id="default" columns="1" column-length="5" image="/images/icons/layout_single_column.gif"
label-id="layout_single_label" description-id="layout_single_desc"
jsp="/jsp/dashboards/layouts/single-column.jsp" />
@@ -186,6 +186,7 @@
</layouts>
<dashlets>
<!-- this is the default dashlet shown in the default layout initially -->
<!-- the default dashlet must have the id of 'getting-started' -->
<dashlet id="getting-started" label-id="dashlet_gettingstarted_label"
description-id="dashlet_gettingstarted_desc"
jsp="/jsp/dashboards/dashlets/getting-started.jsp" allow-narrow="false" />
@@ -203,6 +204,8 @@
<dashlet id="tasks-completed" label-id="my_tasks_completed_title" description-id="my_tasks_completed_desc"
jsp="/jsp/workflow/tasks-completed-dashlet.jsp" allow-narrow="false" />
</dashlets>
<!-- set true allow the Guest user to configure the dashboard view - false by default -->
<allow-guest-config>false</allow-guest-config>
</dashboards>
</config>

View File

@@ -77,7 +77,6 @@ public abstract class BaseServlet extends HttpServlet
validRedirectJSPs.add("/jsp/forums/forums.jsp");
validRedirectJSPs.add("/jsp/users/users.jsp");
validRedirectJSPs.add("/jsp/trashcan/trash-list.jsp");
validRedirectJSPs.add("/jsp/dashboards/container.jsp");
}
private static Log logger = LogFactory.getLog(BaseServlet.class);
@@ -156,10 +155,15 @@ public abstract class BaseServlet extends HttpServlet
throws IOException
{
// authentication failed - so end servlet execution and redirect to login page
// also save the full requested URL so the login page knows where to redirect too later
res.sendRedirect(req.getContextPath() + FACES_SERVLET + Application.getLoginPage(sc));
// save the full requested URL so the login page knows where to redirect too later
String uri = req.getRequestURI();
String url = uri + (req.getQueryString() != null ? ("?" + req.getQueryString()) : "");
String url = uri;
if (req.getQueryString() != null && req.getQueryString().length() != 0)
{
url += "?" + req.getQueryString();
}
if (uri.indexOf(req.getContextPath() + FACES_SERVLET) != -1)
{
// if we find a JSF servlet reference in the URI then we need to check if the rest of the

View File

@@ -91,13 +91,21 @@ public class LoginBean
}
/**
* @param navigator The NavigationBean to set.
* @param navigator The NavigationBean to set.
*/
public void setNavigator(NavigationBean navigator)
{
this.navigator = navigator;
}
/**
* @param preferences The UserPreferencesBean to set
*/
public void setUserPreferencesBean(UserPreferencesBean preferences)
{
this.preferences = preferences;
}
/**
* @return true if the default Alfresco authentication process is being used, else false
* if an external authorisation mechanism is present.
@@ -329,7 +337,7 @@ public class LoginBean
else
{
// special case to handle jump to My Alfresco page initially
String location = Application.getClientConfig(FacesContext.getCurrentInstance()).getInitialLocation();
String location = this.preferences.getStartLocation();
if (NavigationBean.LOCATION_MYALFRESCO.equals(location))
{
return "myalfresco";
@@ -451,4 +459,7 @@ public class LoginBean
/** The NavigationBean bean reference */
protected NavigationBean navigator;
/** The user preferences bean reference */
protected UserPreferencesBean preferences;
}

View File

@@ -126,6 +126,14 @@ public class NavigationBean
this.contentDiskDriver = contentDiskDriver;
}
/**
* @param preferences The UserPreferencesBean to set
*/
public void setUserPreferencesBean(UserPreferencesBean preferences)
{
this.preferences = preferences;
}
/**
* @return the User object representing the current instance for this user
*/
@@ -507,13 +515,8 @@ public class NavigationBean
{
if (this.location == null)
{
// get the initial location from the client config
String initialLocation = clientConfig.getInitialLocation();
if (initialLocation == null || initialLocation.length() == 0)
{
initialLocation = LOCATION_HOME;
}
processToolbarLocation(initialLocation, false);
// get the initial location from the user preferences
processToolbarLocation(this.preferences.getStartLocation(), false);
}
return this.location;
@@ -798,10 +801,10 @@ public class NavigationBean
private static Logger s_logger = Logger.getLogger(NavigationBean.class);
/** constant values used by the toolbar location modelist control */
static final String LOCATION_COMPANY = "companyhome";
static final String LOCATION_HOME = "userhome";
static final String LOCATION_GUEST = "guesthome";
static final String LOCATION_MYALFRESCO = "myalfresco";
public static final String LOCATION_COMPANY = "companyhome";
public static final String LOCATION_HOME = "userhome";
public static final String LOCATION_GUEST = "guesthome";
public static final String LOCATION_MYALFRESCO = "myalfresco";
private static final String MSG_MYALFRESCO = "my_alfresco";
@@ -828,6 +831,9 @@ public class NavigationBean
/** Client configuration object */
protected ClientConfigElement clientConfig = null;
/** The user preferences bean reference */
protected UserPreferencesBean preferences;
/** Cached path to our CIFS server and top level node DIR */
private String cifsServerPath;

View File

@@ -0,0 +1,66 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.web.bean;
import java.util.ResourceBundle;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.PreferencesService;
/**
* Simple bean backing the user preferences settings.
*
* @author Kevin Roast
*/
public class UserPreferencesBean
{
private static final String PREF_STARTLOCATION = "start-location";
private static final String MSG_MYALFRESCO = "my_alfresco";
private static final String MSG_MYHOME = "my_home";
private static final String MSG_COMPANYHOME = "company_home";
private static final String MSG_GUESTHOME = "guest_home";
public String getStartLocation()
{
String location = (String)PreferencesService.getPreferences().getValue(PREF_STARTLOCATION);
if (location == null)
{
// default to value from client config
location = Application.getClientConfig(FacesContext.getCurrentInstance()).getInitialLocation();
}
return location;
}
public void setStartLocation(String location)
{
PreferencesService.getPreferences().setValue(PREF_STARTLOCATION, location);
}
public SelectItem[] getStartLocations()
{
ResourceBundle msg = Application.getBundle(FacesContext.getCurrentInstance());
return new SelectItem[] {
new SelectItem(NavigationBean.LOCATION_MYALFRESCO, msg.getString(MSG_MYALFRESCO)),
new SelectItem(NavigationBean.LOCATION_HOME, msg.getString(MSG_MYHOME)),
new SelectItem(NavigationBean.LOCATION_COMPANY, msg.getString(MSG_COMPANYHOME)),
new SelectItem(NavigationBean.LOCATION_GUEST, msg.getString(MSG_GUESTHOME))};
}
}

View File

@@ -125,6 +125,14 @@ public class DashboardWizard extends BaseWizardBean
// ------------------------------------------------------------------------------
// Dashboard Wizard bean getters
/**
* @return true to allow the Guest user to configure the dashboard, false otherwise
*/
public boolean getAllowGuestConfig()
{
return DashboardManager.getDashboardConfig().getAllowGuestConfig();
}
/**
* @return The currently selected layout ID - used by the Dynamic Description component
*/

View File

@@ -40,7 +40,7 @@ public class ClientConfigElement extends ConfigElementAdapter
private String editLinkType = "http";
private String homeSpacePermission = null;
private boolean ajaxEnabled = false;
private String initialLocation = null;
private String initialLocation = "myalfresco";
/**
* Default Constructor

View File

@@ -37,6 +37,7 @@ public class DashboardsConfigElement extends ConfigElementAdapter
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 boolean allowGuestConfig = false;
/**
* Default constructor
@@ -77,9 +78,24 @@ public class DashboardsConfigElement extends ConfigElementAdapter
combinedElement.layoutDefs.putAll(this.layoutDefs);
combinedElement.layoutDefs.putAll(newElement.layoutDefs);
if (newElement.allowGuestConfig != combinedElement.allowGuestConfig)
{
combinedElement.allowGuestConfig = newElement.allowGuestConfig;
}
return combinedElement;
}
/*package*/ void setAllowGuestConfig(boolean allow)
{
this.allowGuestConfig = allow;
}
public boolean getAllowGuestConfig()
{
return this.allowGuestConfig;
}
/*package*/ void addLayoutDefinition(LayoutDefinition def)
{
this.layoutDefs.put(def.Id, def);

View File

@@ -37,6 +37,7 @@ public class DashboardsElementReader implements ConfigElementReader
public static final String ELEMENT_LAYOUT = "layout";
public static final String ELEMENT_DASHLETS = "dashlets";
public static final String ELEMENT_DASHLET = "dashlet";
public static final String ELEMENT_GUESTCONFIG = "allow-guest-config";
public static final String ATTR_ID = "id";
public static final String ATTR_COLUMNS = "columns";
public static final String ATTR_COLUMNLENGTH = "column-length";
@@ -85,6 +86,13 @@ public class DashboardsElementReader implements ConfigElementReader
configElement.addDashletDefinition(dashletDef);
}
}
Element guestConfigElement = element.element(ELEMENT_GUESTCONFIG);
if (guestConfigElement != null)
{
boolean allow = Boolean.parseBoolean(guestConfigElement.getTextTrim());
configElement.setAllowGuestConfig(allow);
}
}
return configElement;

View File

@@ -31,6 +31,10 @@
<property-name>browseBean</property-name>
<value>#{BrowseBean}</value>
</managed-property>
<managed-property>
<property-name>userPreferencesBean</property-name>
<value>#{UserPreferencesBean}</value>
</managed-property>
</managed-bean>
<managed-bean>
@@ -60,6 +64,10 @@
<property-name>ruleService</property-name>
<value>#{RuleService}</value>
</managed-property>
<managed-property>
<property-name>userPreferencesBean</property-name>
<value>#{UserPreferencesBean}</value>
</managed-property>
</managed-bean>
<managed-bean>
@@ -1993,6 +2001,15 @@
</managed-property>
</managed-bean>
<managed-bean>
<description>
The bean that backs up the User Preferences page
</description>
<managed-bean-name>UserPreferencesBean</managed-bean-name>
<managed-bean-class>org.alfresco.web.bean.UserPreferencesBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<!-- ==================== COMPONENT GENERATOR BEANS ==================== -->
<managed-bean>

View File

@@ -1,21 +1,51 @@
<%--
Copyright (C) 2005 Alfresco, Inc.
Copyright (C) 2005 Alfresco, Inc.
Licensed under the Mozilla Public License version 1.1
with a permitted attribution clause. You may obtain a
copy of the License at
Licensed under the Mozilla Public License version 1.1
with a permitted attribution clause. You may obtain a
copy of the License at
http://www.alfresco.org/legal/license.txt
http://www.alfresco.org/legal/license.txt
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the License for the specific
language governing permissions and limitations under the
License.
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the License for the specific
language governing permissions and limitations under the
License.
--%>
<%-- redirect to the web application's start page --%>
<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils" %>
<%@ page import="org.alfresco.config.ConfigService" %>
<%@ page import="org.alfresco.web.app.servlet.AuthenticationHelper" %>
<%@ page import="org.alfresco.web.bean.NavigationBean" %>
<%@ page import="org.alfresco.web.bean.repository.User" %>
<%@ page import="org.alfresco.web.bean.repository.PreferencesService" %>
<%@ page import="org.alfresco.web.config.ClientConfigElement" %>
<%-- redirect to the web application's appropriate start page --%>
<%
response.sendRedirect(request.getContextPath() + "/faces/jsp/browse/browse.jsp");
// get the start location as configured by the web-client config
ConfigService configService = (ConfigService)WebApplicationContextUtils.getRequiredWebApplicationContext(session.getServletContext()).getBean("webClientConfigService");
ClientConfigElement configElement = (ClientConfigElement)configService.getGlobalConfig().getConfigElement("client");
String location = configElement.getInitialLocation();
// override with the users preference if they have one
User user = (User)session.getAttribute(AuthenticationHelper.AUTHENTICATION_USER);
if (user != null)
{
String preference = (String)PreferencesService.getPreferences(user).getValue("start-location");
if (preference != null)
{
location = preference;
}
}
if (NavigationBean.LOCATION_MYALFRESCO.equals(location))
{
response.sendRedirect(request.getContextPath() + "/faces/jsp/dashboards/container.jsp");
}
else
{
response.sendRedirect(request.getContextPath() + "/faces/jsp/browse/browse.jsp");
}
%>

View File

@@ -74,7 +74,7 @@
<div class="mainSubText"><h:outputText value="#{msg.dashboard_description}" /></div>
</td>
<td align="right">
<a:actionLink value="#{msg.configure}" image="/images/icons/configure_dashboard.gif" padding="2" action="wizard:configureDashboard" />
<a:actionLink value="#{msg.configure}" image="/images/icons/configure_dashboard.gif" padding="2" action="wizard:configureDashboard" rendered="#{NavigationBean.isGuest == false || DashboardWizard.allowGuestConfig}" />
</td>
</tr>
</table>

View File

@@ -71,7 +71,12 @@
<h:panelGrid columns="2" cellpadding="2" cellspacing="2" border="0">
<h:graphicImage value="/images/icons/create_space_large.gif" width="32" height="32" />
<h:panelGroup>
<a:actionLink style="font-weight:bold" value="#{msg.gettingstarted_createspace}" action="#{GettingStartedBean.createSpace}" />
<a:booleanEvaluator value="#{NavigationBean.isGuest == false}">
<a:actionLink style="font-weight:bold" value="#{msg.gettingstarted_createspace}" action="#{GettingStartedBean.createSpace}" />
</a:booleanEvaluator>
<a:booleanEvaluator value="#{NavigationBean.isGuest == true}">
<h:outputText style="font-weight:bold" value="#{msg.gettingstarted_createspace}" />
</a:booleanEvaluator>
<f:verbatim><br></f:verbatim>
<h:outputText value="#{msg.gettingstarted_createspace_desc}" />
</h:panelGroup>
@@ -80,7 +85,12 @@
<h:panelGrid columns="2" cellpadding="2" cellspacing="2" border="0">
<h:graphicImage value="/images/icons/add_content_large.gif" width="32" height="32" />
<h:panelGroup>
<a:actionLink style="font-weight:bold" value="#{msg.gettingstarted_addcontent}" action="#{GettingStartedBean.addContent}" actionListener="#{AddContentDialog.start}" />
<a:booleanEvaluator value="#{NavigationBean.isGuest == false}">
<a:actionLink style="font-weight:bold" value="#{msg.gettingstarted_addcontent}" action="#{GettingStartedBean.addContent}" actionListener="#{AddContentDialog.start}" />
</a:booleanEvaluator>
<a:booleanEvaluator value="#{NavigationBean.isGuest == true}">
<h:outputText style="font-weight:bold" value="#{msg.gettingstarted_addcontent}" />
</a:booleanEvaluator>
<f:verbatim><br></f:verbatim>
<h:outputText value="#{msg.gettingstarted_addcontent_desc}" />
</h:panelGroup>
@@ -89,7 +99,12 @@
<h:panelGrid columns="2" cellpadding="2" cellspacing="2" border="0">
<h:graphicImage value="/images/icons/new_content_large.gif" width="32" height="32" />
<h:panelGroup>
<a:actionLink style="font-weight:bold" value="#{msg.gettingstarted_createcontent}" action="#{GettingStartedBean.createContent}" />
<a:booleanEvaluator value="#{NavigationBean.isGuest == false}">
<a:actionLink style="font-weight:bold" value="#{msg.gettingstarted_createcontent}" action="#{GettingStartedBean.createContent}" />
</a:booleanEvaluator>
<a:booleanEvaluator value="#{NavigationBean.isGuest == true}">
<h:outputText style="font-weight:bold" value="#{msg.gettingstarted_createcontent}" />
</a:booleanEvaluator>
<f:verbatim><br></f:verbatim>
<h:outputText value="#{msg.gettingstarted_createcontent_desc}" />
</h:panelGroup>

View File

@@ -134,14 +134,25 @@
</a:panel>
<div style="padding:4px"></div>
<h:panelGroup id="pref-panel-facets">
<%--<h:panelGroup id="pref-panel-facets">
<f:facet name="title">
<a:actionLink value="#{msg.modify}" action="" showLink="false" image="/images/icons/Change_details.gif" rendered="#{NavigationBean.isGuest == false}" />
</f:facet>
</h:panelGroup>
<a:panel label="#{msg.general_pref}" id="pref-panel" facetsId="pref-panel-facets"
</h:panelGroup>--%>
<a:panel label="#{msg.general_pref}" id="pref-panel" rendered="#{NavigationBean.isGuest == false}"
border="white" bgcolor="white" titleBorder="blue" titleBgcolor="#D3E6FE">
<table width=100% cellspacing=2 cellpadding=2 border=0>
<table cellspacing=2 cellpadding=2 border=0>
<tr>
<td>
<h:outputText value="#{msg.start_location}" />:&nbsp;
</td>
<td>
<%-- Start Location drop-down selector --%>
<h:selectOneMenu id="start-location" value="#{UserPreferencesBean.startLocation}" onchange="document.forms['user-console'].submit(); return true;">
<f:selectItems value="#{UserPreferencesBean.startLocations}" />
</h:selectOneMenu>
</td>
</tr>
</table>
</a:panel>
</td>