cancel
Showing results for 
Search instead for 
Did you mean: 

WebView Dashlet & modifiy JavaScript

sf_urzl
Champ in-the-making
Champ in-the-making
Hello,

i've placed a WebView Dashlet on a site. But all users have the possibility to access the configure link of the dashlet. Can i prohibit it so that only the the managers or admin can change the content of the dashlet?

Edit: I've tried to modify ../Alfresco/tomcat/webapps/share/components/dashlets/webview.js but there is no change in behavior when application is running. Do i anything wrong?

Regards
8 REPLIES 8

zoao
Champ in-the-making
Champ in-the-making
You have restart tomcat, or do a refresh on webscript services in url:
http://<share_server>/share/service/

sf_urzl
Champ in-the-making
Champ in-the-making
Hello zoao,

i have restartet the tomcat, but there is no change…

zoao
Champ in-the-making
Champ in-the-making
You already tried to make another kind of modification, to see if it works? Particularly in the template file (webview.get.html.ftl), which can be easier to see the change?

And no need to restart the tomcat is faster if you use the link that I suggested.

More info about webscript: http://wiki.alfresco.com/wiki/Web_Scripts

mikeh
Star Contributor
Star Contributor
You don't need to restart Tomcat, or reset webscripts if you're just updating the client-side assets. You may need to force-refresh your browser, or empty it's cache however.

Thanks,
Mike

zoao
Champ in-the-making
Champ in-the-making
Sorry for the mistake, when I read the post I thought he was change the server side.

Because I think in this case is more logical to change the template on the server side to only show the link when the user is Admin or has permissions to customize the Dashlet.

sf_urzl
Champ in-the-making
Champ in-the-making
No, zoao was right. I've cleared my cache, restart alfresco, doing anything but there is no change in behavior. Is there another way to modify the WebView Dashlet that only the admin can change the URL?

Edit: I will try it about modifying the webview.get.html.ftl like zoao said.

mikeh
Star Contributor
Star Contributor
You're going to have to modify more than just the Freemarker template I'm afraid.

You need something like this in the webview.get.js:
model.isManager = false;

// Check the role of the user - only SiteManagers are allowed to configure the dashlet
var obj = context.properties["memberships"];
if (!obj)
{
   var json = remote.call("/api/sites/" + page.url.templateArgs.site + "/memberships/" + stringUtils.urlEncode(user.name));
   if (json.status == 200)
   {
      obj = eval('(' + json + ')');
      // Store the memberships into the request context, so it can be used
      // downstream by other components - saves making same call many times
      context.setValue("memberships", obj);
   }
}
if (obj)
{
   model.isManager = (obj.role == "SiteManager");
}

However, that's not a complete solution because the WebView dashlet can also sit on a User's dashboard page as well as a Site's. This should get you started however.

Thanks,
Mike

sf_urzl
Champ in-the-making
Champ in-the-making
Thank you all. I have modified the webview.get.html.ftl. It is not the best solution but it works at the moment.