Pocket Query: Question on Dynamic Parameters

Pranjal Shukla February 12, 2016
  • Is it possible to have Dropdown for parameters out of the box? I did some change to the template example and made it work but it's very rough. Needs lot of structuring.
<form method="get" class="aui pq-dynamic-parameter-form" action="">
  <button type="submit" class="pq-change-button aui-button aui-style aui-button-primary">Change!</button>
  #foreach($key in $queryParameters.keySet())
  #set($reqKey = "pq_$key")
  <div>
    <label for="$reqKey">$key</label>
    <select class="text" id="$reqKey" name="$reqKey" value="$!req.getParameter($reqKey)">
		<option value="CRITICAL">CRITICAL</option>
		<option value="MAJOR">MAJOR</option>
		<option value="WARNING">WARNING</option>
		</select>
  </div>
  #end
</form>
$PocketQuery.template("default")
  • When i try to draw a chart (Using Confluence Chart Macro and Using PC Templates to draw charts) with results of a query that has dynamic parameters, i don't see an option to change the parameter. I'd like to re-draw a chart based on changed parameters.
  • How do i provide value in LIKE clause using dynamic parameters?
  • How do i bring in Date Picker in the parameters?

5 answers

0 votes
Felix Grund (Scandio)
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.
February 26, 2016

P5: DatePicker

Put this in your template:

<div class="field-group">
	<label for="input-date">Choose Date:</label>
	<input id="input-date" class="pq-datepicker" />
</div>

Then later in the script tag call this:

jQuery('.pq-datepicker').datePicker({overrideBrowserDefault: true});

P6: LIKE

1.) Full LIKE clause

Example Query:

SELECT Name, Population
FROM Country
WHERE Name LIKE :CountryNameFullLike

For CountryName "Germany" you could enter this in your macro, for example: %erma%

2.) Only part of the LIKE clause

SELECT Name, Population
FROM Country
WHERE Name LIKE CONCAT('%',:CountryNameMiddlePart,'%')

For CountryName "Germany" you could enter this in your macro, for example: erma

===

Let me know if this helps!

0 votes
Pranjal Shukla February 25, 2016

Felix,

In my initial question i asked for 3 points. On first one, discussion is going on. Could you please answer the remaining two i.e. 

  • How do i provide value in LIKE clause using dynamic parameters?
  • How do i bring in Date Picker in the parameters?
0 votes
Felix Grund (Scandio)
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.
February 25, 2016

P4:

Actually, I think this is an issue very similar to this one: https://answers.atlassian.com/questions/32997105

Maybe you can first evaluate if this helps you?

Felix Grund (Scandio)
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.
February 25, 2016

I just found that it could be the JS Code in the template in my answer might not work in PQ >= 2.0.2. I asked the author of the question if it still works.

Felix Grund (Scandio)
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.
February 25, 2016

...I'm actually working on a better solution currently...

Felix Grund (Scandio)
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.
February 25, 2016

Communication on the other ticket ongoing. Please check...

0 votes
Pranjal Shukla February 18, 2016

Felix,

Since i had one field in the form, i hardcoded the field and here it is like.

<form method="get" class="aui pq-dynamic-parameter-form" action="">
  <button type="submit" class="pq-change-button aui-button aui-style aui-button-primary">Change!</button>
  <div>
    <label for="pq_Severity">Severity</label>
    <select id="pq_Severity" name="pq_Severity" selected="$!req.getParameter("pq_Severity")">
		    <option value="CRITICAL">CRITICAL</option>
        <option value="MAJOR">MAJOR</option>
        <option value="WARNING">WARNING</option>
		</select>
  </div>
</form>
<script>
PocketQuery.chart('BarChart', {
	title: "Alerts by Severity",
	width: 600,
	height: 400,
	bar: {groupWidth: "95%"},
	legend: { position: "none" },
});
</script>
  • The form works as expected when "Load Macro Dynamically" is Unchecked but the parameters does not get appended to the URL when is "Load Macro Dynamically" is checked.

My requirement is, based on the value of Severity Chosen, the char should get refreshed without page reload.

Any help on Dynamic Parameters with different form type elements would help. May be another article from your side on this would be beneficial from your side.

 

0 votes
Pranjal Shukla February 17, 2016

Felix,

Any views on above queries??

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events