Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GEOS-11390] Replace TestWfsPost with Javascript Demo Page #7672

Merged
merged 13 commits into from
May 31, 2024

Conversation

davidblasby
Copy link
Contributor

@davidblasby davidblasby commented May 21, 2024

GEOS-11390 Powered by Pull Request Badge

This PR removes the TestWfsPost servlet and replaces it with 100% javascript functionality (running on the browser).

  1. I've included some MIT-licensed JS code.
    SEE: demo-requests.js Line 211 to 277
  2. See screenshots, below
    Trying to incorporate andrea's and peter's feedback.
    • button order change on WPS/WCS page to be consistent with Demo Request Page
    • changed button text to be more consistent " in Request Builder" " in new page" (verb=Execute, Get Coverage, or Show Result)
  3. I will add documentation (new screen shots) once everyone agrees on UX (see screenshots)

Demo Page:
image

WPS:
image

WCS:
image

Demo Requests:
image

Checklist

For core and extension modules:

  • New unit tests have been added covering the changes.
  • [after feedback] Documentation has been updated (if change is visible to end users).
  • [n/a] The REST API docs have been updated (when changing configuration objects or the REST controllers).
  • There is an issue in the GeoServer Jira (except for changes that do not affect administrators or end users in any way).
  • Commit message(s) must be in the form [GEOS-XYZWV] Title of the Jira ticket.
  • Bug fixes and small new features are presented as a single commit.
  • Each commit has a single objective (if there are multiple commits, each has a separate JIRA ticket describing its goal).

@davidblasby davidblasby marked this pull request as draft May 21, 2024 18:36
@davidblasby davidblasby requested review from aaime, prushforth and petersmythe and removed request for prushforth May 21, 2024 18:37
@jodygarnett
Copy link
Member

@davidblasby I really like the consistent action button names + workflow.

@jodygarnett jodygarnett changed the title [GEOS-11390] Remove test wfs post servlet [GEOS-11390] Replace TestWfsPost with Javascript Demo Page May 21, 2024
Copy link
Member

@jodygarnett jodygarnett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor feedback (missing header). When folks are happy with button names we can update the docs and get this moving.

I would appreciate squash and merge (or interactive rebase) to collapse this to a single commit for backport.

Excellent work David.

Copy link
Contributor

@petersmythe petersmythe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am happy with the consistent button naming, thank you.

Additional non blocking feedback from me:

  • Clicking Show Result, the Response Body spills over the right edge of the bolded Response Body panel, instead of wrapping.

image

  • The (red) Busy spinner icon is not the expected green/black busy standard icon of other GeoServer pages, nor is it in the top right corner, where I expected it to be.

  • DemoRequests > Show Result in New Page does not open in a new tab, as expected, but rather in the current tab. Control/Shift clicking does not change this.

// ======================================================
// https://www.npmjs.com/package/prettify-xml
//
// The MIT License (MIT)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an MIT License right in the middle of the javascript, is that intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - there's MIT code in the JS. Thats the "xml pretty print" code.

I can move it to its own file??

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could move it to the top of the file, we have an example for GeoTools here:

https://github.com/geotools/geotools/blob/main/modules/library/main/src/main/java/org/geotools/feature/type/DateUtil.java

Copy link
Member

@aaime aaime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strong recommendation to remove the black boxes around the headers and responses, they are alien to the GeoServer UI, can make the output harder to read.

image

Instead, use horizontal line separators like in the rest of the GUI (same appearance),
they would fit better and not interfere with the output.

image

In addition, just thinking out loud, is the XML pretty printer able to wrap text at a certain amount of columns? Geometries may otherwise be represented as a very very very long line.

The two other builders look good, but one button label is misleading in both the WCS and WPS pages:

image

There is no such thing as a "Demo Request Builder", had it been a "builder" we would have had no need for the WCS/WPS one. Just say "Get Coverage in Demo requests" and "Execute in Demo requests" instead.

Finally, as @jodygarnett always reminds me, documentation should be updated any time we touch the GUI.

These pages have been affected by the change, screenshots should be re-made, and descriptive text updated accordingly:

</div>
<div style="display:flex; flex-direction: row">
<div class="button-group selfclear">
<a onclick="document.getElementById('openNewWindow').checked = false; submitRequest()" ><wicket:message key="submit">Submit</wicket:message></a>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe @sikeoka won't be happy about more inline javascript, he's been doing a number of PRs to avoid having it, so that CSP headers can be enabled (which will in turn lead to better protection against XSS attacks).
Just one example for reference:
#7560

See open and closed PRs in this search for more context:
https://github.com/geoserver/geoserver/pulls?q=is%3Apr+author%3Asikeoka+is%3Aclosed+inline+javascript

<div wicket:id="requestBuilder"></div>
<ul>
<li class="button-group selfclear">
<button wicket:id="execute" type="submit"><wicket:message key="execute">execute</wicket:message></button>
<button wicket:id="executeXML" type="submit"><wicket:message key="showXML">show xml</wicket:message></button>
<!-- <button onclick="getCoverage()" type="submit"><wicket:message key="execute">execute</wicket:message></button>-->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't leave commented out sections.

Comment on lines 205 to 212
String js = "";
js += "function getCoverage() {\n";
js += " var url ='" + url + "';\n";
js += " var xml = document.getElementById(\"xml\").value;\n";
js += " var user ='';\n";
js += " var pass= '';\n";
js += " openInNewWindow(url,xml,user,pass);\n";
js += "}\n";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably going to be a problem, CSP wise, too.

@jodygarnett jodygarnett reopened this May 27, 2024
@jodygarnett
Copy link
Member

Sorry I accidentally closed, was trying to take it out of draft and add a checklist

jodygarnett
jodygarnett previously approved these changes May 27, 2024
@jodygarnett jodygarnett dismissed their stale review May 27, 2024 17:09

workflow feedback addressed, but docs remain pending. I will review when docs are ready

@davidblasby
Copy link
Contributor Author

@aaime

  1. Added "standard" GS Spinner

  2. DemoRequests > Show Result in New Page does not open in a new tab, as expected, but rather in the current tab. Control/Shift clicking does not change this. - didn't do anything on this. Its doing a POST, so control/shift clicking will not work (its not a link). In the future, we can probably set the form to target="_blank". However, I like the fact it opens the requests in its own page.

  3. I've moved the "main" javascript into two files - demo-requests.js and xml-pretty-print.js
    However, there's a few lines left over;
    a) on the elements (click). This is probably removable by adding the click handler with something in the demo-requests.js, but I'm not sure with the wicket page-lifestyle if it will be correctly handled.
    b) in the Wicket AJAX callback.

    I'm not sure how to address this - I'm not sure if its possible. Wicket puts JS in the page - and definitely in the ajax callbacks (search the GS codebase for appendJavaScript). The Wicket page-lifestyle model makes this difficult as well.

    I've done what I can - not sure how to move forward on this. Like I said, I'm not sure if its possible (look at the source for a wicket page and you will see a bunch of inline script tags) - but perhaps someone with a lot more wicket knowledge than I can move this forward.

  4. I removed the headers/response border and used the standard to do a horizontal line

  5. I changed the output so it does a word-wrap. Not 100% sure if I like this (i.e. a big geometry now takes up a lot of vertical space) or not, but its in and I think useful.

  6. changed to "Demo Requests" (from Demo Requests Builder).

I actually went back to the old Demo Requests - and the new one is very much an improvement.

image

@@ -1 +1,68 @@
.. _wps_request_builder:WPS Request Builder===================The GeoServer WPS extension includes a request builder for testing out WPS processes through the :ref:`web_admin`. This tool can also be used to demonstrate processes, and construct your own examples.Accessing the request builder---------------------------------To access the WPS Request Builder:#. Navigate to the main :ref:`web_admin`.#. Click on the :guilabel:`Demos` link on the left side.#. Select :guilabel:`WPS Request Builder` from the list of demos... figure:: images/demospage.png :align: center *WPS request builder in the list of demos*Using the request builder-------------------------The WPS Request Builder primarily consists of a selection box listing all of the available processes, and two buttons, one to submit the WPS request, and another to display what the POST request looks like... figure:: images/requestbuilderblank.png :align: center *Blank WPS request builder form*The display changes depending on the process and input selected. JTS processes have available as inputs any of a GML/WKT-based feature collection, URL reference, or subprocess. GeoServer-specific processes have all these as options and also includes the ability to choose a GeoServer layer as input.For each process, a form will display based on the required and optional parameters associated with that process, if any... figure:: images/requestbuildertoppstates.png :align: center *WPS request builder form to determine the bounds of topp:states*To see the process as a POST request, click the :guilabel:`Generate XML from process inputs/outputs` button... figure:: images/requestbuilderrequest.png :align: center *Raw WPS POST request for the above process*To execute the process, click the :guilabel:`Execute Process` button. The response will be displayed in a window or.. figure:: images/requestbuilderresponse.png :align: center *WPS server response*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this really have windows line formatting before? Wow ...

Copy link
Member

@jodygarnett jodygarnett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding documentation and addressing feedback.

@jodygarnett jodygarnett marked this pull request as ready for review May 28, 2024 15:34
@jodygarnett
Copy link
Member

With documentation included I have marked this as "ready for review".

I believe Andrea's changes have been addressed and this can now go ahead.

@jodygarnett
Copy link
Member

jodygarnett commented May 29, 2024

@aaime if I understand correctly David is at the limits of what he can do with respect to inline javascript and forthcoming CSP restrictions in Wicket 9. Reading wicket 9 guidance the result is to restrict, but a setting can be defined per page to allow pages like this to function.

Reference:

@aaime
Copy link
Member

aaime commented May 29, 2024

@jodygarnett I was just pointing out the conflict with @sikeoka work, if this gets merged as is, I guess Steve is going (unhappily maybe) to pick it up and move the JS out of the HTML pages.

I know @aaime I was just hunting down the link to #7154 to share with David who is not aware of that work. I was looking in that PR for examples and I mostly see him picking up inline styles.

Since David is at the limits of his wicket ability we need an example.

Update:

  • David you asked to search for script=".." and yes there are lots of examples
  • Searching Steve's wicket update work I see style="..." being replaced, but not script="..." being replace
  • Andrea do you know if only style is being a problem? Or is script being a problem also? As David points out it is very common in our codebase and a supported interaction in the wicket design.

@sikeoka
Copy link
Contributor

sikeoka commented May 29, 2024

I actually don't care about inline JavaScript in Wicket pages. Wicket 9 has its own complex and strict way of handling Content-Security-Policy and my work just assumes that it will cover everything else in GeoServer while letting Wicket do its own thing.

@jodygarnett
Copy link
Member

@jodygarnett
Copy link
Member

@sikeoka perhaps you could look at this PR; it would make us feel a lot better if someone with your wicket experience is comfortable with the change.

@jodygarnett
Copy link
Member

@aaime I think with @sikeoka 's comment all your feedback has been addressed.

@aaime
Copy link
Member

aaime commented May 30, 2024

Yes yes, my comment was meant to catch Steve's attention, not to raise a blocker.

@jodygarnett jodygarnett added backport 2.24.x Instructs the bot to create a 2.24.x backport PR on merge backport 2.25.x labels May 31, 2024
@jodygarnett jodygarnett merged commit eb13121 into geoserver:main May 31, 2024
13 checks passed
@jodygarnett
Copy link
Member

I will manually backport given the squash and merge approach for clean history.

jodygarnett pushed a commit to jodygarnett/geoserver that referenced this pull request May 31, 2024
…#7672)

* Remove Demo Request proxy server - TestWFSPost
* update WCS request page to piggy back on top of DemoRequests page
* handle WPS request builder
* Remove demo request, fix test cases, add new test cases
* Feeback from peter and andrea
* fix QA warning
* Add header
* feedback from andrea
* update documentation with new screenshots and functionality

---------

Authored-by: david.blasby <david.blasby@geocat.net>
# Conflicts:
#	src/wfs/src/main/java/org/vfny/geoserver/wfs/servlets/TestWfsPost.java
#	src/wfs/src/test/java/org/vfny/geoserver/wfs/servlets/TestWfsPostTest.java
jodygarnett pushed a commit to jodygarnett/geoserver that referenced this pull request May 31, 2024
…#7672)

* Remove Demo Request proxy server - TestWFSPost
* update WCS request page to piggy back on top of DemoRequests page
* handle WPS request builder
* Remove demo request, fix test cases, add new test cases
* Feeback from peter and andrea
* fix QA warning
* Add header
* feedback from andrea
* update documentation with new screenshots and functionality

---------

Authored-by: david.blasby <david.blasby@geocat.net>
# Conflicts:
#	src/wfs/src/main/java/org/vfny/geoserver/wfs/servlets/TestWfsPost.java
#	src/wfs/src/test/java/org/vfny/geoserver/wfs/servlets/TestWfsPostTest.java
jodygarnett pushed a commit to jodygarnett/geoserver that referenced this pull request May 31, 2024
…#7672)

* Remove Demo Request proxy server - TestWFSPost
* update WCS request page to piggy back on top of DemoRequests page
* handle WPS request builder
* Remove demo request, fix test cases, add new test cases
* Feeback from peter and andrea
* fix QA warning
* Add header
* feedback from andrea
* update documentation with new screenshots and functionality

---------

Authored-by: david.blasby <david.blasby@geocat.net>
# Conflicts:
#	src/wfs/src/main/java/org/vfny/geoserver/wfs/servlets/TestWfsPost.java
#	src/wfs/src/test/java/org/vfny/geoserver/wfs/servlets/TestWfsPostTest.java
@geoserver geoserver deleted a comment from aaime May 31, 2024
@geoserver geoserver deleted a comment from aaime May 31, 2024
jodygarnett pushed a commit that referenced this pull request May 31, 2024
* Remove Demo Request proxy server - TestWFSPost
* update WCS request page to piggy back on top of DemoRequests page
* handle WPS request builder
* Remove demo request, fix test cases, add new test cases
* Feeback from peter and andrea
* fix QA warning
* Add header
* feedback from andrea
* update documentation with new screenshots and functionality

---------

Authored-by: david.blasby <david.blasby@geocat.net>
# Conflicts:
#	src/wfs/src/main/java/org/vfny/geoserver/wfs/servlets/TestWfsPost.java
#	src/wfs/src/test/java/org/vfny/geoserver/wfs/servlets/TestWfsPostTest.java
jodygarnett pushed a commit that referenced this pull request May 31, 2024
* Remove Demo Request proxy server - TestWFSPost
* update WCS request page to piggy back on top of DemoRequests page
* handle WPS request builder
* Remove demo request, fix test cases, add new test cases
* Feeback from peter and andrea
* fix QA warning
* Add header
* feedback from andrea
* update documentation with new screenshots and functionality

---------

Authored-by: david.blasby <david.blasby@geocat.net>
# Conflicts:
#	src/wfs/src/main/java/org/vfny/geoserver/wfs/servlets/TestWfsPost.java
#	src/wfs/src/test/java/org/vfny/geoserver/wfs/servlets/TestWfsPostTest.java
}

@Override
public void renderHead(IHeaderResponse response) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-opening https://osgeo-org.atlassian.net/browse/GEOS-11390 due to missing call to super.render(response) here, required to ensure header contributions are included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.24.x Instructs the bot to create a 2.24.x backport PR on merge backport 2.25.x failed backport
Projects
None yet
5 participants