Hi I’ve been trying to get a Jira gadget working using a rest resource by following this tutorial:
https://developer.atlassian.com/jiradev/jira-platform/guides/dashboards/tutorial-writing-gadgets-for-jira
I’ve managed to create the module and add the gadget to a dashboard. However, when I load the dashboard it appears as blank and when I inspect the dashboard element the console in chrome outputs the error:
Uncaught TypeError: Cannot read property 'getViewportDimensions' of undefined
at HTMLDocument.showLoading (com.atlassian.gadgets.publisher:ajs-gadgets.js:formatted:540)
at HTMLDocument.<anonymous> (com.atlassian.gadgets.publisher:ajs-gadgets.js:formatted:750)
at HTMLDocument.dispatch (com.atlassian.plugins.jquery:jquery.js:formatted:1814)
at HTMLDocument.h (com.atlassian.plugins.jquery:jquery.js:formatted:1619)
at Object.trigger (com.atlassian.plugins.jquery:jquery.js:formatted:1745)
at Object.trigger (com.atlassian.plugins.jquery:jquery.js:formatted:1762)
at Function.jQuery.ajax (com.atlassian.gadgets.publisher:ajax.js:24)
at Object.<anonymous> (com.atlassian.gadgets.publisher:ajs-gadgets.js:formatted:66)
at Function.each (com.atlassian.plugins.jquery:jquery.js:formatted:481)
at init.each (com.atlassian.plugins.jquery:jquery.js:formatted:298)
I’ve tried searching around for a solution to this problem but it doesn’t seem anyone has had a similar issue. From what I can tell, somewhere within the AJS gadget code, it tries to call a function on a null object but I can’t seem to see where that null object is.
Here is my content element from the gadget.xml if that helps as well:
<![CDATA[
#requireResource("com.atlassian.jira.gadgets:common")
#includeResources()
<script type="text/javascript">
(function () {
var gadget = AJS.Gadget({
baseUrl: "__ATLASSIAN_BASE_URL__",
useOauth: "/rest/gadget/1.0/currentUser",
view: {
template: function(args) {
var gadget = this;
var projectList = AJS.$("<ul/>");
AJS.$(args.projectData).each(function() {
projectList.append(
AJS.$("<li/>").append(
AJS.$("<a/>").attr({
target: "_parent",
title: gadgets.util.escapeString(this.key),
href: "__ATLASSIAN_BASE_URL__" + "/browse/" + this.key
}).text(this.name)
)
);
});
gadget.getView().html(projectList);
},
args: [{
key: "projectData",
ajaxOptions: function() {
return {
url: "/rest/issuehierarchy/1.0/issuehierarchy?jql="
};
}
}]
}
});
})();
</script>
]]>