Skip to content

Fixes search passthrough to Mirador#1630

Merged
tdonohue merged 4 commits intoDSpace:mainfrom
mspalti:mirador-search-passthrough
Jun 21, 2022
Merged

Fixes search passthrough to Mirador#1630
tdonohue merged 4 commits intoDSpace:mainfrom
mspalti:mirador-search-passthrough

Conversation

@mspalti
Copy link
Copy Markdown
Member

@mspalti mspalti commented Apr 28, 2022

Description

The mirador Angular component should pass DSpace discovery query terms to the Mirador viewer whenever the previous route in history was a search request. I'm not sure why this stopped working. The PR fixes the problem by simplifying the utility function that checks for a search and returns the query terms (if found). The expected behavior is that the Mirador viewer will be initialized with search results present. New tests are provided.

Instructions for Reviewers

Testing this is difficult at the moment because it requires installing and populating a separate Solr core and indexing OCR data from Item Bitstreams (in ALTO, hOCR, or MiniOcr). That's possible if you have some data available. Also, some tooling and a preconfigured core are under review for a later release in this PR #8241. Some folks will be working with the experimental IIIF search support so I would be helpful to get this minor Angular fix added to 7.3.

List of changes in this PR:

  • Small update to item-iiif-utils function.
  • Adds tests

Checklist

This checklist provides a reminder of what we are going to look for when reviewing your PR. You need not complete this checklist prior to creating your PR (draft PRs are always welcome). If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!

  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
  • My PR passes TSLint validation using yarn run lint
  • My PR doesn't introduce circular dependencies
  • My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
  • My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
  • If my PR includes new, third-party dependencies (in package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.

@mspalti mspalti self-assigned this Apr 28, 2022
@tdonohue tdonohue added bug integration: IIIF Related to International Image Interoperability Framework (IIIF) support labels Apr 28, 2022
@tdonohue tdonohue requested a review from abollini May 5, 2022 14:09
@tdonohue tdonohue added the 1 APPROVAL pull request only requires a single approval to merge label May 5, 2022
Copy link
Copy Markdown
Member

@abollini abollini left a comment

Choose a reason for hiding this comment

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

hi @mspalti
it looks to work for me in the basic scenarios but I would like to get your feedback on my two inline comments and see if the suggested code/test improvements are feasible

const arr = r.split('&');
const q = arr[1];
const v = q.split('=');
const v = r.split('query=');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this look to me a bit fragile... are there other built-in mechanism in Angular to parse an URL to extract a parameter value?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use const u = new URL(r) and find what you want in u.searchParams? https://stackoverflow.com/a/24006120/2916377

Agreed: one should always think long and hard before writing one of these ad-hoc parsers for something as complex as a URL.

mockRouteService.getPreviousUrl.and.returnValue(of(['/search?q=bird&motivation=painting','/item']));
const localMockRouteService = {
getPreviousUrl(): Observable<string> {
return of('/search?query=test');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm worried about queries that include url encoded character such as a space or an unicode character, other than URL with additional parameters that could go after the query param (i.e. page size, direction, etc)

@mspalti
Copy link
Copy Markdown
Member Author

mspalti commented May 23, 2022

Now using an Angular route parser. Thanks for the suggestion! You're right that the previous approach was lazy on my part.

Tests are passing. I haven't been able to run in a dev environment because I've been traveling with a laptop that isn't configured properly. Will have time to fully test myself when I get back on 5/25.

Lint fix
@mspalti mspalti force-pushed the mirador-search-passthrough branch from 4bd52e2 to 5ec460d Compare May 23, 2022 15:55
@mspalti
Copy link
Copy Markdown
Member Author

mspalti commented May 25, 2022

I just tested this in a development environment. The query DSpace query passthrough worked fine. I tested using a multi-word query and sorting. I believe this is ready for review.

Copy link
Copy Markdown
Member

@abollini abollini left a comment

Choose a reason for hiding this comment

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

hi @mspalti unfortunately, my re-review and approval was never submitted...
there is a small conflict right now, can you resolve it so that this can be merged?

@tdonohue
Copy link
Copy Markdown
Member

@mspalti : If you have any time in the coming days, this can be included in 7.3 if the merge conflicts are resolved before Tuesday. After Tuesday, I'll likely have to reschedule this for 7.4. Thanks!

@mspalti
Copy link
Copy Markdown
Member Author

mspalti commented Jun 17, 2022

@tdonohue , @abollini , this should be ready to merge.

Copy link
Copy Markdown
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

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

👍 Thanks @mspalti . I gave this a quick code review and it seems reasonable. I was not able to test it (as I don't have the setup you describe above), but I did install it and verify that the new code doesn't break anything (doesn't appear to based on my basic tests).

@tdonohue tdonohue merged commit eb662fc into DSpace:main Jun 21, 2022
@mspalti mspalti deleted the mirador-search-passthrough branch October 13, 2023 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 APPROVAL pull request only requires a single approval to merge bug integration: IIIF Related to International Image Interoperability Framework (IIIF) support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants