From JS the best is probably to simply directly call Jira REST API and forget about http://extensions.xwiki.org/xwiki/bin/view/Extension/JIRA+REST+Integration.
On Mon, Sep 7, 2015 at 11:43 AM, Mohamed Boussaa <[email protected]> wrote:
The code used to call the Jira REST web service is a server side code then you can't excute the code in javascript.
You will need a wiki page, see here how to create a new page ( http://enterprise.xwiki.org/xwiki/bin/view/GettingStarted/CreatingAPage)
Put the groovy code in that page as explained in the service documentation.
Then you can communicate with the service with javascript using Ajax requests.
On Mon, Sep 7, 2015 at 10:10 AM, PATEL, ABDULKADAR < [email protected]> wrote:
Hi Mohamed Boussaa,
Thanks for your prompt reply.
Actually I am very new to xwiki and thus don’t know how to call even velocity code L
Let me tell you what I have done so far.
I have created a widget similar to gotopage widget in xwiki. This widget will load when user will hit some shortcut key (alt+shift+N) in my case.
For this I have written javascript code in xwiki-min.js under resources/js/wiki
This code is similar to gotopage widget code with few small changes of mine.
Now where can I write the groovy code to call jira REST web service?
Below is my code to open popup :
*var XWiki = (function(c) {*
* var a = c.widgets = c.widgets || {};*
* if (!c.widgets.ModalPopup) {*
* if (console && console.warn) {*
* console.warn("[JumpToJiraPage widget] Required class missing: XWiki.widgets.ModalPopup")*
* }*
* } else {*
* a.JumpToJiraPage = Class.create(a.ModalPopup, {*
* urlTemplate: "$xwiki.getURL('__space__.__document__', '__action__')",*
* initialize: function($super) {*
* var e = new Element("div");*
* this.input = new Element("input", {*
* type: "text",*
* id: "jmp_target",*
* title: "$services.localization.render('core.viewers.jump.dialog.input.tooltip')"*
* });*
* e.appendChild(this.input);*
* this.submitButton = this.createButton("button", "$services.localization.render('core.viewers.jump.dialog.actions.submit')", "$services.localization.render('core.viewers.jump.dialog.actions.submit.tooltip')", "jmp_view");*
* this.cancelButton = this.createButton("button", "$services.localization.render('core.viewers.jump.dialog.actions.cancel')", "$services.localization.render('core.viewers.jump.dialog.actions.cancel.tooltip')", "jmp_edit");*
* var d = new Element("div", {*
* "class": "buttons"*
* });*
* d.appendChild(this.submitButton);*
* d.appendChild(this.cancelButton);*
* e.appendChild(d);*
* $super(e, {*
* show: {*
* method: this.showDialog,*
* keys: [$services.localization.render("core.viewers.jump.shortcuts.jira")]*
* },*
* view: {*
* method: this.openDocument,*
* keys: [$services.localization.render("core.viewers.jump.dialog.actions.view.shortcuts")],*
* options: {*
* propagate: true*
* }*
* },*
* edit: {*
* method: this.openDocument,*
* keys: [$services.localization.render("core.viewers.jump.dialog.actions.edit.shortcuts")]*
* }*
* }, {*
* title: "$services.localization.render('core.viewers.jump.dialog.content')",*
* extraClassName: "jump-dialog",*
* verticalPosition: "top"*
* });*
* this.shortcuts.close.options = {*
* propagate: true*
* };*
* this.addQuickLinksEntry()*
* },*
* createDialog: function($super, d) {*
* Event.observe(this.submitButton, "click", this.openDocument.bindAsEventListener(this, "view"));*
* Event.observe(this.cancelButton, "click", this.closeDialog.bindAsEventListener(this, "edit"));*
* $super(d);*
* },*
* showDialog: function($super) {*
* $super();*
* this.input.value = "";*
* this.input.focus()*
* },*
* closeDialog: function($super, d) {*
* if (!d.type.startsWith("key") || !this.dialogBox.down(".ajaxsuggest")) {*
* $super();*
* this.input.__x_suggest.clearSuggestions()*
* }*
* },*
* openDocument: function(e, f) {*
* var issueSummary = this.input.value;*
* alert(issueSummary);*
* var createIssueData = "{\"fields\":{\"project\":{\"key\":\"Testing\"},\"summary\":\""+issueSummary+ "\"" +",\"issuetype\":{\"name\":\"Task\""+"}}}";*
* var url = "http://din51002056:8080/rest/api/2/project <http://din51002056:8080/rest/api/2/project>";*
* var xmlhttp;*
* if (typeof XMLHttpRequest != "undefined") {*
* //All modern browsers (IE7+, Firefox, Chrome, Safari, and Opera) uses XMLHttpRequest object*
* xmlhttp = new XMLHttpRequest();*
* }*
* else if (typeof ActiveXObject != "undefined") {*
* //Internet Explorer (IE5 and IE6) uses an ActiveX Object*
* xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");*
* }*
* xmlhttp.open('GET',url,true);*
* xmlhttp.setRequestHeader('Authorization','Basic abdpatel:Admin123');*
* xmlhttp.send(null);*
* xmlhttp.onreadystatechange = function() {*
* if (xmlhttp.readyState == 4) {*
* if ( xmlhttp.status == 200) {*
* var det = eval( "(" + xmlhttp.responseText + ")");*
* alert(det);*
* } else { *
* alert("status ->" + xmlhttp.status);*
* alert("Error ->" + xmlhttp.responseText);*
* }*
* } *
* };*
* },*
* addQuickLinksEntry: function() {*
* $$(".panel.QuickLinks .xwikipanelcontents").each(function(e) {*
* var d = new Element("span", {*
* "class": "jmp-activator"*
* });*
* d.update("$services.localization.render('core.viewers.jump.quickLinksText')");*
* Event.observe(d, "click", function(f) {*
* this.showDialog(f)*
* }.bindAsEventListener(this));*
* e.appendChild(d)*
* }.bind(this))*
* }*
* });*
* function b() {*
* return new a.JumpToJiraPage()*
* }(c.domIsLoaded && b()) || document.observe("xwiki:dom:loaded", b)*
* }*
* return c*
*}(XWiki || {}));*
Your help is very crucial for me. Thanks in advance.
Thanks & Regards,
Abdulkadar Patel
*From:* Mohamed Boussaa [mailto:[email protected]] *Sent:* Monday, September 07, 2015 2:32 PM *To:* XWiki Developers; PATEL, ABDULKADAR *Subject:* Re: [xwiki-devs] xwiki jira integration
Hi,
You can call the groovy code in a wiki page like a velocity code.
For exemple you can call the groovy code in the action page of your form.
Mohamed Boussaa
On Mon, Sep 7, 2015 at 9:39 AM, PATEL, ABDULKADAR < [email protected]> wrote:
In following article, it is nicely explained how we can integrate xwiki with jira using groovy http://extensions.xwiki.org/xwiki/bin/view/Extension/JIRA+REST+Integration But I don't understand how can I call this groovy code in xwiki. I have created a popup dialog which will take information from user and create jira issue on submit. How can I call groovy code on click of submit button? Any help will be highly appreciated.
Thanks & Regards, ____________________________________________________________________ [cid:[email protected]]Abdulkadar Patel Consultant | GESBU
Capgemini India | Pune Tel.: +91 20 6631 1755 - Extn: 20 12530 Mob.: + 91 8087683419 Email: [email protected]<mailto: [email protected]> www.capgemini.com<http://www.capgemini.com/> People matter, results count. _______________________________________________________________________ 7 Switch off as you go |q Recycle always | P Print only if absolutely necessary
This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne