How do I dynamically list a set of JIRA dashboards in a Confluence page; not render them?

Looking for a better way to collect and manage our team and department dashboards.  It's difficult for someone to go into JIRA and find a dashboard if they don't know how it was saved; short of creating their own view.

 

The current workaround is maintaining a manual hyperlinked list to the various JIRA dashboards within Confluence.  There's got to be a better way to identify a dashboard object to do a query and display this in Confluence?

1 answer

0 vote
Steven Behnke Community Champion Aug 12, 2016

There's no way to generate a dynamic list of JIRA Dashboards in Confluence out-of-the-box, no.

Edit: You could write a simple User Macro that accomplished this with Javascript for instance –JIRA has an API to get all dashboards. https://docs.atlassian.com/jira/REST/cloud/#api/2/dashboard

Thanks.

I was hoping there'd be an easy way to identify a Dashboard ObjectID and then discriminate based on names.

Steven Behnke Community Champion Aug 16, 2016

I've only poked at this a little, but you could try your hand as well. I need to refactor this into functions before I keep working at it.

image2016-8-16 10:56:42.png

## @noparams
#set($D = "$")
#set($P = "#")
<div id="jra-dash-lister"><ul><span id="jra-dash-loading" class="aui-icon aui-icon-wait">Loading...</span></ul></div>
<pre><script>  
// <![CDATA[
	AJS.toInit(function(){
		AJS.${D}.ajax({
			url: '/rest/jiraanywhere/1.0/servers',
			type: "GET",
			contentType: "application/json",
			success: function(jiraLinks){
				primaryJiraId = jiraLinks[0].id;
				primaryJiraAddress = jiraLinks[0].url;
				AJS.${D}.ajax({
					url: '/plugins/servlet/applinks/proxy?appId=' + primaryJiraId + '&path=' + primaryJiraAddress + '/rest/api/2/dashboard',
					type: "GET",
					contentType: "application/json",
					success: function(dashboardList){
						AJS.${D}('${P}jra-dash-loading').remove()
						dashboards = dashboardList.dashboards;
						for (i = 0; i < dashboards.length; i++) {
							AJS.${D}('${P}jra-dash-lister ul').append('<li><a href="' + dashboards[i].view + '">' + dashboards[i].name + '</a></li>')
						}
						AJS.${D}('${P}jra-dash-lister ul').append('<p id="jra-dash-count">Showing ' + dashboardList.maxResults + ' of ' + dashboardList.total + ' <a id="jra-dash-next" href="' + dashboardList.next + '">Next Page</a></p>');
						AJS.${D}('a${P}jra-dash-next').click(function(event){
							event.preventDefault();
							AJS.${D}('${P}jra-dash-lister li').remove()
							AJS.${D}.ajax({
								url: '/plugins/servlet/applinks/proxy?appId=' + primaryJiraId + '&path=' + ${D}(this).attr('href'),
								type: "GET",
								contentType: "application/json",
								success: function(dashboardList){
									AJS.${D}('${P}jra-dash-loading').remove()
									AJS.${D}('${P}jra-dash-count').remove()
									dashboards = dashboardList.dashboards;
									for (i = 0; i < dashboards.length; i++) {
										AJS.${D}('${P}jra-dash-lister ul').append('<li><a href="' + dashboards[i].view + '">' + dashboards[i].name + '</a></li>')
									}
									AJS.${D}('${P}jra-dash-lister ul').append('<p>Showing ' + dashboardList.maxResults + ' of ' + dashboardList.total + ' <a id="jra-dash-next" href="' + dashboardList.next + '">Next Page</a></p>');
								}
							})
						})
					}
				})
			}
		})
	})
// ]]>
</script></pre>

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

77 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you