How can I obtain information from dashboard?
Hi,
is it possible to obtain information from the dashboard in order to provide them to a custom viewlet?
For example in my custom viewlet I call a custom service with a parameter which is the project area name. Is it possible to obtain this information (or the project area UUID)?
Thanks,
Michele.
Accepted answer
As you suspected, there is a very simple way to do this. There is an API available to viewlets to get the "scope" of its container. When the viewlet is on a project or team dashboard, this API will give you the details of that parent artifact. The methods you want to call are Viewlet#getScope and Viewlet#getScopeItem. The former will give you what the type of scope is (Contributor, Project or Team). The result will be a constant from the "com.ibm.team.dashboard.web.ui.DashboardConstants" javascript module. You can simply require this module and compare to the DashboardConstants.SCOPE_CONTRIBUTOR, DashboardConstants.SCOPE_PROJECT_AREA and DashboardConstants.SCOPE_TEAM_AREA constants. The latter method, getScopeItem, will give you details about the actual associated item. This will come in the form of a json object with two properties: name and itemId.
Additionally, you can add a setting to the viewlet if you like that will allow the user to override the "scope" of the viewlet. By default the properties of the dashboard will be used, but this gives the consumer of the viewlet the ability to change which project/team's information is displayed. This can be useful for allowing users to use the viewlet on their personal dashboards with a bit of customization. To make your viewlet "scopable" and provide scope options in the settings area for the viewlet, you need to make some changes to the extension point declaration for your viewlet. The fields you care about in your viewlet definition are "scope-sensitive" and "applies-to". The "scope-sensitive" settings is a boolean that controls whether or not you want the scope settings to be surfaced and you should set it to true. The "applies-to" field controls what types of scope the viewlet will recognize. It sounds like for your purposes this should be "projects-and-teams", but you can see the other options available to you by using the plugin-manifest editor in the Eclipse client.
For more information on the API available to viewlets, see:
https://jazz.net/wiki/bin/view/Main/ViewletFunctions
Included in there are docs about the getScope and getScopeItem methods:
https://jazz.net/wiki/bin/view/Main/ViewletFunctions#GetScope
https://jazz.net/wiki/bin/view/Main/ViewletFunctions#GetScopeItem
3 other answers
Sam,
probably I was not very clear, but I think it is a very simple thing. I have created a new custom viewlet and added to my dashboard. In this viewlet I've a button which call a service I've created. This service need a parameter which is the project area (or team area) that owned the dashboard.
Currently I've created a string setting so I can obtain the project area name putting it there.
What I was asking to me is that probably there is a javascript method (something like the getAutenticatedContributor) that can give me the project/team area of the dashboard on which I've put the viewlet. In this way I don't have to configure the settings for the viewlet each time I create a new dashoboard. I've take a look to the WEB UI API (https://jazz.net/library/LearnItem.jsp?href=content/docs/web-ui-programming/web-ui-api.html) but I cannot find anything like this.
Is it possible?
Thanks,
Michele.