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

Extend layerSpecificExport for APIs #2053

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

MattiasSp
Copy link
Contributor

Fixes #2040.

The PR includes several improvements to the layerSpecificExport handling to make the configuration more flexible and adaptable to more different types of APIs. It does not include authentication in any way, but that would be a useful next addition.

  • Allow setting exportedFileName and button per layer or specific URL
    • The handling of export options was not entirely consistent, but now these options (and all the others except url) can be set as defaults per layer, or overriden for specific export URLs.
  • New export option: urlParameters
    • Add URL parameters as key-value pairs
    • Fill parameter values with values from selected objects' attributes by specifying an object with an attribute property: { "attribute": "objekt_id", "separator": ";"}. The separator character can be customized but uses semicolon by default.
    • Set a parameter's value to {{no_value}} to add the parameter without the equals sign or value.
    • The example config below will result in e g the following url: https://my.api.se/postSomething?param1=value1&featureid=1;3;12&silent
{
  "url": "https://my.api.se/postSomething",
  "urlParameters": {
    "param1": "value1",
    "featureid": { "attribute": "id", "separator": ";"},
    "silent": "{{no_value}}"
  },
  "attributesToSendToExport": ["id","comment"],
  "button": {
    "buttonText": "Post IDs"
  }
}
  • New export options requestMethod (POST_JSON | OPEN | GET) and displayExportResponse (true | false) added
    • POST_JSON is the default option and posts JSON the usual way as the layerSpecificExport works.
    • OPEN opens the URL in a new window.
    • GET makes a GET request
      • Includes any urlParameters specified (but not attributesToSendToExport of course)
      • If displayExportResponse is set to true (for the layer or the specific url) the request's response will be displayed in the infowindow. Supports images and text (if from the same domain or otherwise allowed by CORS restrictions). Defaults to false.
  • Added a material design icon article because it looks nice for opening reports etc.

@steff-o
Copy link
Contributor

steff-o commented Nov 13, 2024

A lot of things to test, so I haven't had the time to test yet as it requires some hefty set up to actually test the export result handling. Guess I will just test that old functionality is not broken and configuration is backwards compatible.

But the silent parameter, why not just set it to null or empty string? Null could be sent as completely empty and empty string "PARAM=" if there is a difference between "PARAM" and "PARAM=" in the backend.

The {{}} notation is not really intuitive and can potentially interfere with a future variable substitution syntax by disallowing the variable name "no_value" (whoever calls a variable that)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extension of layerSpecificExport to allow more config options
2 participants