Created
January 18, 2016 12:35
-
-
Save robertmassaioli/4c25097e433fdd2b6c95 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<!-- jQuery --> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> | |
<!-- Atlassian User Interface (AUI) --> | |
<link rel="stylesheet" href="//aui-cdn.atlassian.com/aui-adg/5.7.0/css/aui.css" media="all"> | |
<script src="//aui-cdn.atlassian.com/aui-adg/5.7.0/js/aui.js"></script> | |
<script> | |
Utils = {}; | |
// This is required to get the base url of JIRA | |
Utils.getBaseUrl = function () { | |
var cp = this.getUrlParam('cp', true); | |
return this.getUrlParam('xdm_e', true) + ( cp ? cp : '') + '/atlassian-connect'; | |
}; | |
$(document).ready(function () { | |
var allJS = Utils.getBaseUrl() + '/all.js'; | |
$.getScript(allJS, function () { | |
//Call a REST endpoint using the Atlassian Connect Javascript library | |
AP.request({ | |
url: "/rest/api/latest/myself", | |
headers: {"accept": "application/json"}, | |
success: function (responseText) { | |
console.log(responseText); | |
var userJson = $.parseJSON(responseText); | |
$("#userName").text(userJson.displayName); | |
}, | |
error: function (responseText) { | |
$("#missing-read-scope").removeClass("hidden"); | |
} | |
}); | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<div class="ac-content"> | |
<div id="missing-read-scope" class="aui-message aui-message-error hidden"> | |
<p class="title"> | |
<strong>Missing read scope!</strong> | |
</p> | |
<p>Your addon requires read scope in order to make a request for the username of the currently logged in user. Please add read scope to the atlassian connect descriptor file and reinstall the addon. Then perform a hard browser refresh to clear any cached HTML or JS.</p> | |
</div> | |
<div class="aui-message success"> | |
<p class="title"> | |
<strong>Hello <span id="userName">World!</span></strong> | |
</p> | |
<p>Look at you, getting all fancy with your Atlassian Connect add-on :-) </p> | |
<p>Now you can relax and have fun with <a href="javascript:generateFunkyStuff()">this</a>.</p> | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment