How can I have a dashboard that cannot be modifed by users?

I want a normal user not to be able to modify his dashboard, and i want to make sure he always sees the default dashboard.

2 votes

1 answers

3531 views

ANSWER



Dear me,

The user dashboard is a document that is automatically copied from the default dashboard defined by the Admin. So you can set any permission you want on this “document”. In your case, what you would do, is make sure everyone accesses the default dashboard (not theirs) and give read permission on the default dashboard that is by default restricted to the Administrator. So you need to follow several steps:

First Step : always display the default dashboard instead of the user dashboard to Studio

Add an xml contrib to studio so that the defaultdashboard is always displayed instead of the default. Here is the contrib to add in Studio :

<require>org.nuxeo.ecm.user.center.dashboard.opensocial.spaceprovider</require>
<extension target="org.nuxeo.ecm.spaces.core.spacemanager.service"
    point="spaceProviders">
    <spaceProvider name="userDashboardSpaceProvider">
      <class>
        org.nuxeo.ecm.user.center.dashboard.DefaultDashboardSpaceProvider
      </class>
    </spaceProvider>
  </extension>

Second step : add read permission to the defaultdashboard which is not the case by default

For an existing application

If the application is already deployed, the permission all already set on the default dashboard so we need to change them. We will need to access it, but this a not an easy access doc :) We will use Nuxeo Shell

Go to the adress :

yourServer/nuxeo/site/shell (in my case http://localhost:8080/nuxeo/site/shell), it should launch a java applet. Type the following commands :

connect -u Administrator (or whatever user is an Admin, it should prompt the pwd) 
cd management/dashboard-management/ (if you do a ls in there you'll see the defaultdashboardSpace) 
perms defaultDashboardSpace/ (it will show you the permissions) 
perms -grant "Everyone:Read" defaultDashboardSpace/ (it will update the property) 

And then when you access the dashboard from a standard user (after redeploying the Studio project of course), you'll always see the same dashboard, in read-only mode.

For a new application (or a reset of the database)

The pb with the solution above is that if you redeploy a new database, you will have to redo the permission granting, which is not something you want. So let's use Studio to make sure we add the read permission whenever the defaultDashBoardSpace is created.

  • Add the document type in the registries (AdvancedSettings >Registries> Doc Types :

    { doctypes: {

    Space: {
    

    parent:“Document”,} } }

  • Add an event handler on document created for type Space and with document path starts with : /management/dashboard-management/

  • Add an automation chain that grant read permission to everyone and bind it to the event handler.

Deploy your bundle before anyone accesses the home dashboard on a newly created database and you are (should be) good to go!

One more thing

The dashboard cannot be modified by a non admin anymore but you still see the top right buttons for modifying it, it will show errors if you try to :)

If you want to remove those buttons, you will have to overidde the xhtml template layout of the page. The file you want to override is :

/nuxeo/addons/nuxeo-user-center/nuxeo-user-dashboard/nuxeo-user-dashboard-opensocial/src/main/resources/web/nuxeo.war/incl/dashboard/user_opensocial_dashboard.xhtml (to be updated whith the github link when it's back…)

2 votes



Dear you, that's an interesting use case which Laurent could reuse for his blogs ;)
09/11/2012

Interesting article/question. I've tried the above Nuxeo shell procedure with a test system and it works, however if I use a development system started under Eclipse there is no defaultDashboeardSpace just an empty container. Any comments?
09/11/2012

The dashboard is created when accessed for the first time, so It might be the issue here. The other solution is that you only CAP deploy and not DM, if so you should only see a static dashboard, and I don't think the dynamic one is created in that case (did not checked though)
09/12/2012

Hi Fred, what part exactly I have to modify if I want to hidden the buttons: restore default, layout and Add gadget. I found the file user_opensocial_dashboard.xhtml and removed those lines:

  &lt;ui:define name=&quot;opensocial_container_actions&quot;&gt;
    &lt;c:if test=&quot;#{not currentUser.anonymous}&quot;&gt;
      &lt;div class=&quot;opensocial_buttons&quot;&gt;
        &lt;h:form id=&quot;openSocialActionsForm&quot;&gt;
          &lt;ul&gt;
            &lt;li&gt;
              &lt;a onclick=&quot;nuxeo.container.openContainerBuilder();&quot;
                id=&quot;openContainerBuilder&quot;
                title=&quot;#{messages[&apos;label.opensocial.container.change.layout&apos;]}&quot;&gt;#{messages[&apos;label.opensocial.container.change.layout&apos;]}&lt;/a&gt;
            &lt;/li&gt;
            &lt;li&gt;
              &lt;a id=&quot;addGadgetButton&quot; href=&quot;#{baseURL}site/gadgets?language=#{localeSelector.language}&quot;&gt;#{messages[&apos;label.opensocial.container.add.gadget&apos;]}&lt;/a&gt;
            &lt;/li&gt;
            &lt;li&gt;
              &lt;h:commandLink id=&quot;restoreToDefault&quot; action=&quot;#{userDashboardActions.removeUserDashboard()}&quot;
                immediate=&quot;true&quot; onclick=&quot;return confirmRestoreDashboard();&quot;&gt;
                &lt;h:outputText value=&quot;#{messages[&apos;label.opensocial.container.restore.default&apos;]}&quot; /&gt;
              &lt;/h:commandLink&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
        &lt;/h:form&gt;
      &lt;/div&gt;
    &lt;/c:if&gt;
  &lt;/ui:define&gt;

but when I check my dashboard, only the button restore default is hidden

04/25/2013

Hi, I created another myopensocial_container_template.xhtml file, deleted the lines from insert buttons so I could hide this buttons
04/25/2013