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

Report viewer: Allow loading results by URL #910

Merged
merged 1 commit into from
Feb 8, 2023

Conversation

jtotht
Copy link
Contributor

@jtotht jtotht commented Feb 5, 2023

When integrating with other software (TMS in my case), it’s useful to be able to send users to a URL that will automatically load the results, without having to recompile the report viewer on the live server every time (to make use of overview.json). This pull request introduces a new file query parameter, which, if provided, makes the report viewer load the results from the given URL. Similarly to the drag-and-drop upload, the URL can point to both ZIPs and JSONs; since the URL may not have an appropriate extension, let the browser figure out the type based on the HTTP headers. Browsers can figure out the MIME type of drag-and-drop files as well (usually based on the extension), so migrate also the drag-and-drop to MIME-based type determination, dropping the getFileExtension function. Also improve error handling: instead of just logging to the browser console, present the error using alert – not a five-star UX, but still much better than nothing.

When integrating with other software ([TMS](https://gitlab.com/tms-elte)
in my case), it’s useful to be able to send users to a URL that will
automatically load the results, without having to recompile the report
viewer on the live server every time (to make use of overview.json).
This pull request introduces a new `file` query parameter, which, if
provided, makes the report viewer load the results from the given URL.
Similarly to the drag-and-drop upload, the URL can point to both ZIPs
and JSONs; since the URL may not have an appropriate extension, let the
browser figure out the type based on the HTTP headers. Browsers can
figure out the MIME type of drag-and-drop files as well (usually based
on the extension), so migrate also the drag-and-drop to MIME-based type
determination, dropping the `getFileExtension` function. Also improve
error handling: instead of just logging to the browser console, present
the error using `alert` – not a five-star UX, but still much better than
nothing.
@tsaglam tsaglam added enhancement Issue/PR that involves features, improvements and other changes minor Minor issue/feature/contribution/change report-viewer PR / Issue deals (partly) with the report viewer and thus involves web-dev technologies labels Feb 6, 2023
@tsaglam
Copy link
Member

tsaglam commented Feb 6, 2023

Thanks for the contribution! We are currently working on improving the error messages of the report viewer (see #710). The report viewer still has a long way to go. If you want to use the newly implemented features early, you can test the development version of the report viewer at https://jplag.github.io/JPlag-Dev/ (deployed from develop branch).

@sonarcloud
Copy link

sonarcloud bot commented Feb 6, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@sebinside
Copy link
Member

It works fine, thank you. Windows uses a different MIME type, I will update that myself.

Also, just a reminder to configure CORS accordingly.

@sebinside sebinside merged commit 8a4e832 into jplag:develop Feb 8, 2023
@sebinside sebinside removed the request for review from cyfml February 8, 2023 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Issue/PR that involves features, improvements and other changes minor Minor issue/feature/contribution/change report-viewer PR / Issue deals (partly) with the report viewer and thus involves web-dev technologies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants