It's all about the answers!

Ask a question

How can I obtain information from dashboard?


Michele Pegoraro (1.8k12114101) | asked Nov 26 '12, 11:08 a.m.

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


permanent link
Adam Archer (83639) | answered Nov 28 '12, 9:50 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
Michele,

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
Michele Pegoraro selected this answer as the correct answer

Comments
Michele Pegoraro commented Nov 30 '12, 5:16 a.m.

Adam, thank you very much for these information. I'm going to learn more on this as it seems to be very useful.

Best regards, Michele.

3 other answers



permanent link
sam detweiler (12.5k6185201) | answered Nov 26 '12, 11:43 a.m.
sorry, I do not understand your question..

permanent link
Michele Pegoraro (1.8k12114101) | answered Nov 26 '12, 11:55 a.m.

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.


permanent link
sam detweiler (12.5k6185201) | answered Nov 26 '12, 12:04 p.m.
ok, got it.. I don't know the answer

but I agree, its probably a javascript function. I haven't seen any documented methods for determining details of the runtime from either workitems, menus or dashboards.


Your answer


Register or to post your answer.