Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Display external website in dialog

Benny Argo April 30, 2019

Is it possible to display an external website with a Scriptrunner Custom web item. I have a jira site that is used for publication documents and one of the sub-task requires printer information such as printer name, address email etc. I am pulling the printer information into site with nfeed, but I need to allow users to add, edit and delete printer. I have setup a Custom web item before which will redirect the browser to another url but really need to be able to allow user to see the information in a dialog or a modal.

1 answer

1 accepted

0 votes
Answer accepted
PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 30, 2019

If the target site doesn't have same-origin restrictions, you might be able to include it in an iframe inside a custom dialog.

Benny Argo May 1, 2019

Thanks Peter,

I have create a rest endpoint that will display and iframe. My next question is how to connect the Custom web item to a rest endpoint.

In the Custom web item I have the "Do what" set to "Run code and display a dialog" but the https://scriptrunner.adaptavist.com/5.4.12/jira/fragments/WebItem.html is not clear on how to connect a Custom web item to an rest endpoint.

PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 1, 2019

Assuming your rest endpoint returns the HTML for a dialog (<section role="dialog" ...etc), you just make the rest endpoint the target of the webItem in the "link" field. 

Like this:

2019-05-01 12_27_50-Script Fragments - https___projects-test.qad.com_plugins_servlet_scriptrunner_ad.png

Benny Argo May 8, 2019

Peter,

I had to walk away from this item for a bit because of other obligation.

I have followed your suggestion on the web-item and add the link as you recommended

/rest/scriptrunner/latest/custom/getProjectConfigDialog?pkey=${project.key}

The dialog box is still not opening at all.  I have my rest end point inline script set to:

import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import groovy.transform.BaseScript

import javax.ws.rs.core.MediaType
import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.core.Response

@BaseScript CustomEndpointDelegate delegate

showDialog() { MultivaluedMap queryParams ->

// get a reference to the current page...
// def page = getPage(queryParams)

def dialog =
"""<section role="dialog" id="sr-dialog" class="aui-layer aui-dialog2 aui-dialog2-medium" aria-hidden="true" data-aui-remove-on-hide="true">
<header class="aui-dialog2-header">
<h2 class="aui-dialog2-header-main">Some dialog</h2>
<a class="aui-dialog2-header-close">
<span class="aui-icon aui-icon-small aui-iconfont-close-dialog">Close</span>
</a>
</header>
<div class="aui-dialog2-content">
<iframe src="https;//www.my-website.com" width="800" height="600"></iframe>
</div>
<footer class="aui-dialog2-footer">
<div class="aui-dialog2-footer-actions">
<button id="dialog-close-button" class="aui-button aui-button-link">Close</button>
</div>
</footer>
</section>
"""

Response.ok().type(MediaType.TEXT_HTML).entity(dialog.toString()).build()
}

PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 8, 2019

Maybe that's too obvious to mention ... but I the target in your case should be 

/rest/scriptrunner/latest/custom/showDialog

Also, I'm not sure if that part matters, but usually, I don't have parens for rest endpoints:

showDialog { MultivaluedMap queryParams ->

What happens when you go directly to your rest endpoint? From the script rest endpoint screen, there should be a link you can click. It should open a page with just your dialog's html

Benny Argo May 8, 2019

Peter,

Thanks for you help. I now can add my part with php.

Suggest an answer

Log in or Sign up to answer