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

Add parameter for HTML request #242

Merged
merged 5 commits into from
Apr 12, 2022
Merged

Add parameter for HTML request #242

merged 5 commits into from
Apr 12, 2022

Conversation

Gigaszi
Copy link
Contributor

@Gigaszi Gigaszi commented Jan 25, 2022

Description

Add a parameter to the API endpoints to allow the request of a HTML snippet.

Corresponding issue

Closes #235

New or changed dependencies

  • jinja2

Checklist

@Gigaszi Gigaszi closed this Jan 25, 2022
@Gigaszi Gigaszi reopened this Jan 25, 2022
@Gigaszi Gigaszi marked this pull request as draft January 25, 2022 13:58
@Gigaszi
Copy link
Contributor Author

Gigaszi commented Feb 1, 2022

the CSS still needs to be integrated. Also the representation of the report results needs to be adjusted: the map as on the website does not work without javascript (maybe just a big traffic light like the small ones?)

Copy link
Collaborator

@matthiasschaub matthiasschaub left a comment

Choose a reason for hiding this comment

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

Looks good so far. I have not finished looking at every change yet. But here are some minor comments for the parts I already looked at.

  • Analogous to remove_svg_from_properties there should be a test for remove_html_from_properties.
tests/unittests/test_api.py
    def test_remove_svg_from_properties(self):
  • Update this branch to the latest commit in main.
  • Add jinja2 as dependency to pyproject.toml and poetry.lock using poetry add jinja2

workers/ohsome_quality_analyst/api/api.py Outdated Show resolved Hide resolved
workers/ohsome_quality_analyst/base/indicator.py Outdated Show resolved Hide resolved
workers/ohsome_quality_analyst/base/indicator.py Outdated Show resolved Hide resolved
workers/ohsome_quality_analyst/base/indicator.py Outdated Show resolved Hide resolved
@matthiasschaub
Copy link
Collaborator

the CSS still needs to be integrated. Also the representation of the report results needs to be adjusted: the map as on the website does not work without javascript (maybe just a big traffic light like the small ones?)

Lets have a discussion about the CSS and reports once I finished the first review.

Regarding the map on the website: It is not planned to include the map as part of the OQT API response. The response should only contain the description an plot for the results.

@Gigaszi
Copy link
Contributor Author

Gigaszi commented Mar 4, 2022

Screenshot 2022-03-04 at 10-34-33 Screenshot
This is how the html request looks for now. It's not finished yet, but maybe you already have some feedback. I'm not quite sure if I should resize the map to fit the size of the indicators or leave it larger so you can see more

@Gigaszi
Copy link
Contributor Author

Gigaszi commented Mar 7, 2022

I found this tool (https://github.com/rossant/smopy) to integrate OSM maps well with Python. The zoom is also adapted directly to the bounding box here. As far as I can see, there are no dependencies that we don't already have. So I would insert the map with it, if there is nothing against it from your side.

@matthiasschaub
Copy link
Collaborator

matthiasschaub commented Mar 8, 2022

I found this tool (https://github.com/rossant/smopy) to integrate OSM maps well with Python. The zoom is also adapted directly to the bounding box here. As far as I can see, there are no dependencies that we don't already have. So I would insert the map with it, if there is nothing against it from your side.

I am not sure this is a good idea. The packages has not been updated since 2 years, is not available through pypi and has no tests :D. On the other hand the package is quite small and consists only 400 lines of code.
If this is working good for our case this could be a possibility. I would say try it out and see how good it works for us.

@Gigaszi
Copy link
Contributor Author

Gigaszi commented Mar 14, 2022

Screenshot 2022-03-10 at 18-26-24 Screenshot

@matthiasschaub matthiasschaub added this to the Release 0.9.0 milestone Mar 14, 2022
@matthiasschaub matthiasschaub added enhancement New feature or request waiting An issue or PR which is waiting for an upstream bugfix, further information or is somehow blocked labels Mar 21, 2022
Copy link
Collaborator

@matthiasschaub matthiasschaub left a comment

Choose a reason for hiding this comment

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

Just a few commets while skiming the changes.
I have not yet tested it or looked at the HTML construction.

workers/ohsome_quality_analyst/api/api.py Outdated Show resolved Hide resolved
workers/tests/unittests/test_api.py Outdated Show resolved Hide resolved
workers/ohsome_quality_analyst/base/indicator.py Outdated Show resolved Hide resolved
workers/ohsome_quality_analyst/base/report.py Outdated Show resolved Hide resolved
workers/tests/integrationtests/test_api_indicator.py Outdated Show resolved Hide resolved
workers/tests/integrationtests/test_api_report.py Outdated Show resolved Hide resolved
@joker234 joker234 removed the waiting An issue or PR which is waiting for an upstream bugfix, further information or is somehow blocked label Mar 24, 2022
matthiasschaub added a commit that referenced this pull request Mar 28, 2022
The HTTP interactions introduced in #242 are containing binary data
(OSM Map tiles as PNG). JSON can not handle those. `vcrpy` does
recommend YAML in this case.

Recreate all VCR cassettes.
@matthiasschaub matthiasschaub mentioned this pull request Mar 28, 2022
2 tasks
matthiasschaub added a commit that referenced this pull request Mar 28, 2022
The HTTP interactions introduced in #242 are containing binary data
(OSM Map tiles as PNG). JSON can not handle those. `vcrpy` does
recommend YAML in this case.

Recreate all VCR cassettes.
matthiasschaub added a commit that referenced this pull request Mar 28, 2022
The HTTP interactions introduced in #242 are containing binary data
(OSM Map tiles as PNG). JSON can not handle those. `vcrpy` does
recommend YAML in this case.

Recreate all VCR cassettes.
matthiasschaub added a commit that referenced this pull request Mar 28, 2022
The HTTP interactions introduced in #242 are containing binary data
(OSM Map tiles as PNG). JSON can not handle those. `vcrpy` does
recommend YAML in this case.

Recreate all VCR cassettes.
matthiasschaub added a commit that referenced this pull request Mar 28, 2022
The HTTP interactions introduced in #242 are containing binary data
(OSM Map tiles as PNG). JSON can not handle those. `vcrpy` does
recommend YAML in this case.

Recreate all VCR cassettes.
@Gigaszi Gigaszi requested a review from joker234 March 31, 2022 15:09
@Gigaszi Gigaszi marked this pull request as ready for review April 1, 2022 17:03
@Gigaszi Gigaszi changed the title Add parameter for HTML request 🚧 Add parameter for HTML request Apr 1, 2022
Copy link
Member

@joker234 joker234 left a comment

Choose a reason for hiding this comment

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

A first review, still to review:

  • templates
  • tests
  • test website

CHANGELOG.md Outdated
@@ -17,10 +17,12 @@
- Fix concurrent execution of CLI function `create_all_indicators` using async and semaphores ([#254])
- Support choosing a single indicator and/or single layer for CLI command `create_all_indicators` ([#254])
- Indicators based on GHS-POP use raster file stored on disk instead of raster in the database ([#276])
- Add new parameter `includeHtml` to the API endpoints to allow the request of a HTML snippet of the report result ([#242])
Copy link
Member

Choose a reason for hiding this comment

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

It's not only for reports, but indicators as well, isn't it?

website/website/assets/js/map-en.js Show resolved Hide resolved
website/website/assets/js/map-en.js Show resolved Hide resolved
workers/ohsome_quality_analyst/api/api.py Outdated Show resolved Hide resolved
workers/ohsome_quality_analyst/base/indicator.py Outdated Show resolved Hide resolved
workers/ohsome_quality_analyst/base/indicator.py Outdated Show resolved Hide resolved
workers/ohsome_quality_analyst/base/report.py Outdated Show resolved Hide resolved
Use HTML templates to create HTML snippets containing the results of an
Indicator or Report.
('/indicator' and '/report'). If this parameter is set to True the
response will contain an HTML snippet with the Indicator or Report
results. The default is not HTML snippet will be included in the
response.
Report and embed the HTML snippet of the API response in the website.
@matthiasschaub matthiasschaub merged commit 49d50a6 into main Apr 12, 2022
@matthiasschaub matthiasschaub deleted the html_request branch April 12, 2022 06:29
matthiasschaub added a commit that referenced this pull request Apr 12, 2022
matthiasschaub added a commit that referenced this pull request Apr 12, 2022
matthiasschaub added a commit that referenced this pull request Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add parameter that returns rendered HTML snippets
3 participants