Skip to content

Implement Signposting on angular side#2248

Merged
tdonohue merged 29 commits intoDSpace:mainfrom
4Science:feature/CST-5729
Jun 9, 2023
Merged

Implement Signposting on angular side#2248
tdonohue merged 29 commits intoDSpace:mainfrom
4Science:feature/CST-5729

Conversation

@atarix83
Copy link
Contributor

@atarix83 atarix83 commented May 12, 2023

References

Description

Add angular implementation to provide signposting functionality

Instructions for Reviewers

List of changes in this PR:

  • Add new proxy to redirect every links/linksets routes /server/signposting endpoint
  • in the item page the signposting links are provided in the head of the page and in the http response headers
  • for the download bitstream page the signposting links are provided in the http response headers

Include guidance for how to test or review your PR.

Schermata da 2023-05-15 16-48-50

  • to verify the links are attached properly to the html page analyze the page is returned by using the elements tab of the dev tools
    Schermata da 2023-05-15 16-47-10

Checklist

  • 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 ESLint validation using yarn lint
  • My PR doesn't introduce circular dependencies (verified via yarn check-circ-deps)
  • 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 libraries/dependencies (in package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.
  • If my PR includes new features or configurations, I've provided basic technical documentation in the PR itself.
  • If my PR fixes an issue ticket, I've linked them together.

@atarix83 atarix83 changed the title Feature/cst 5729 Implement Signposting on angular side May 12, 2023
@tdonohue tdonohue self-requested a review May 12, 2023 19:07
@tdonohue tdonohue added new feature 1 APPROVAL pull request only requires a single approval to merge labels May 12, 2023
@tdonohue tdonohue added this to the 7.6 milestone May 12, 2023
Copy link
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.

@atarix83 : Overall, this looks good and it appears to work. I do have some minor suggestions to improve the code inline below. But, overall the direction looks good to me

I also noticed that the Link header is only returned when SSR is used. I'm assuming that probably the correct behavior, but I wanted to verify to be certain that's expected. I never see that Link header when CSR is used. If this is proper behavior, is there some way to ensure the logic in item-page.component.ts which builds that Link header is only used during SSR?

I can verify though that the HTML <link> tags in the <head> appear for either SSR or CSR.

@github-actions
Copy link

Hi @atarix83,
Conflicts have been detected against the base branch.
Please resolve these conflicts as soon as you can. Thanks!

atarix83 added 2 commits May 25, 2023 23:15
# Conflicts:
#	src/app/bitstream-page/bitstream-download-page/bitstream-download-page.component.ts
@atarix83 atarix83 requested a review from tdonohue May 25, 2023 21:19
Copy link
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.

@atarix83 : I re-reviewed this today and tested it with the backend. The code looks good & it is working. I can verify that in the Link Header is only returned in SSR mode... and both CSR and SSR will return the HTML links embedded in the page.

I've also verified that nothing crashes when Signposting is turned off (signposting.enabled = false in local.cfg). However, I have noticed that there's a somewhat odd, extra error in the DevTools console with Signposting turned off. Here's how to reproduce it:

  • Turn off signposting on backend (signposting.enabled = false in local.cfg)
  • Restart Tomcat (required to turn it off)
  • Now, visit any Item page in the UI, and you'll see two errors in the Console (anytime you access an Item page)
    • First, you'll get the expected 404 response from the signposting endpoint.
    • But, immediately after that you'll get a second error which appears to come from the Angular codebase related to that 404?
      two-errors

If this second error is possible to avoid, that'd be nice. However, I don't quite understand why it's displayed every time the (expected) 404 error occurs.

Overall, I'm +1 this PR. But, I'll need to retest it once the backend PR is updated/fixed based on my latest review. Thanks!

@atarix83
Copy link
Contributor Author

atarix83 commented Jun 5, 2023

@tdonohue

there was an additional log error message that i've removed because is not neccesary, could you check if is ok now ?

@atarix83 atarix83 requested a review from tdonohue June 5, 2023 13:13
@abollini abollini added the claimed: 4Science 4Science team is working on this issue & will contribute back label Jun 6, 2023
Copy link
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.

@atarix83 : This looks good to me now & works well. That said, I did find a very minor issue (at least I think it's an issue) where the Link type is sometimes returned as "undefined" like this:

<https://demo7.dspace.org/handle/123456789/233> ; rel="cite-as" ; type="undefined" , 

The same behavior occurs in the HTML <link> tags. I don't think it's harmful, but it might be good to simply leave out the type attribute if it is empty or undefined.

@atarix83
Copy link
Contributor Author

atarix83 commented Jun 8, 2023

@tdonohue

undefined type fixed

Copy link
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.

@atarix83 : This is looking great, but I noticed a new small bug in today's tests. It appears the UI Proxy for Signposting URLs is incorrect.

The generated URLs appear to always be [dspace.ui.url]/signposting/links*.... but the Proxy in this PR expects them to be [dspace.ui.url]/links*, so the generated links always return a 404.

I think it's probably best to fix the Proxy to use the /signposting path. See inline below. Once this minor change is made, everything else in this PR looks great!

server.ts Outdated
/**
* Proxy the linksets
*/
router.use('/links**', createProxyMiddleware({
Copy link
Member

@tdonohue tdonohue Jun 8, 2023

Choose a reason for hiding this comment

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

This proxy appears to be incorrect. Re-tested today and the signposting response for a Bitstream (http://localhost:8080/server/signposting/links/[bitstream-uuid]) looks like this:

[{"href":"http://localhost:4000/signposting/linksets/94554d4d-cfc5-44bb-96ab-1a80ed637a24","rel":"linkset","type":"application/linkset"},
{"href":"http://localhost:4000/signposting/linksets/94554d4d-cfc5-44bb-96ab-1a80ed637a24/json","rel":"linkset","type":"application/linkset+json"},
{"href":"http://localhost:4000/entities/publication/94554d4d-cfc5-44bb-96ab-1a80ed637a24","rel":"collection","type":"text/html"}]

Notice how the Angular UI URLs all start with /signposting/links*... but this Router appears to expect them to start with /links*

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tdonohue fixed

@atarix83 atarix83 requested a review from tdonohue June 9, 2023 17:26
Copy link
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 @atarix83 ! Verified all my feedback has been addressed (and latest bug fixed). Re-tested today with the backend and it all looks good!

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 claimed: 4Science 4Science team is working on this issue & will contribute back new feature

Projects

No open projects
Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

Signposting

3 participants