-
Notifications
You must be signed in to change notification settings - Fork 441
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
Prevent request with page size of 9999 #3694
Changes from 17 commits
369cb3e
017d110
a9d1518
850a951
4cd5e0a
4830e46
ebb408e
4642ed1
ac7af44
b43e1f4
335fe62
d90a988
f5ec5f9
d4064f6
9f8083e
3ac6cb8
134ecd6
903daad
5f2cc86
25b2f68
c79affd
9570cd9
2847dc3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,10 +78,11 @@ export class BundleDataService extends IdentifiableDataService<Bundle> implement | |
* requested after the response becomes stale | ||
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which | ||
* {@link HALLink}s should be automatically resolved | ||
* @param options the {@link FindListOptions} for the request | ||
*/ | ||
// TODO should be implemented rest side | ||
findByItemAndName(item: Item, bundleName: string, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<Bundle>[]): Observable<RemoteData<Bundle>> { | ||
return this.findAllByItem(item, { elementsPerPage: 9999 }, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow).pipe( | ||
findByItemAndName(item: Item, bundleName: string, useCachedVersionIfAvailable = true, reRequestOnStale = true, options?: FindListOptions, ...linksToFollow: FollowLinkConfig<Bundle>[]): Observable<RemoteData<Bundle>> { | ||
return this.findAllByItem(item, options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow).pipe( | ||
map((rd: RemoteData<PaginatedList<Bundle>>) => { | ||
if (hasValue(rd.payload) && hasValue(rd.payload.page)) { | ||
const matchingBundle = rd.payload.page.find((bundle: Bundle) => | ||
|
@@ -114,6 +115,47 @@ export class BundleDataService extends IdentifiableDataService<Bundle> implement | |
); | ||
} | ||
|
||
// findByItemAndName(item: Item, bundleName: string, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<Bundle>[]): Observable<RemoteData<Bundle>> { | ||
// return this.findAllByItem(item, { elementsPerPage: 1, currentPage: 1 }, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow).pipe( | ||
// expand((rd: RemoteData<PaginatedList<Bundle>>) => { | ||
// if (rd.hasSucceeded && hasValue(rd.payload) && hasValue(rd.payload.page) && rd.payload.currentPage < rd.payload.totalPages) { | ||
// const nextPageOptions = { elementsPerPage: 1, currentPage: rd.payload.currentPage + 1 }; | ||
// return this.findAllByItem(item, nextPageOptions, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow); | ||
// } else { | ||
// return EMPTY; | ||
// } | ||
// }), | ||
// map((rd: RemoteData<PaginatedList<Bundle>>) => { | ||
// if (hasValue(rd.payload) && hasValue(rd.payload.page)) { | ||
// const matchingBundle = rd.payload.page.find((bundle: Bundle) => bundle.name === bundleName); | ||
// if (hasValue(matchingBundle)) { | ||
// return new RemoteData( | ||
// rd.timeCompleted, | ||
// rd.msToLive, | ||
// rd.lastUpdated, | ||
// RequestEntryState.Success, | ||
// null, | ||
// matchingBundle, | ||
// 200 | ||
// ); | ||
// } else { | ||
// return new RemoteData( | ||
// rd.timeCompleted, | ||
// rd.msToLive, | ||
// rd.lastUpdated, | ||
// RequestEntryState.Error, | ||
// `The bundle with name ${bundleName} was not found.`, | ||
// null, | ||
// 404 | ||
// ); | ||
// } | ||
// } else { | ||
// return rd as any; | ||
// } | ||
// }) | ||
// ); | ||
// } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can probably be removed |
||
|
||
/** | ||
* Get the bitstreams endpoint for a bundle | ||
* @param bundleId | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,9 @@ | |
[isFirstTable]="isFirst" | ||
aria-describedby="reorder-description"> | ||
</ds-item-edit-bitstream-bundle> | ||
<div class="d-flex justify-content-center" *ngIf="showLoadMoreLink$ | async"> | ||
<div class="btn btn-link py-3" (click)="loadBundles()"> {{'item.edit.bitstreams.load-more.link' | translate}}</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We've just done a major overhaul of this page to improve the accessibility in #3464 Please use an actual button here, so it can be accessed using the keyboard |
||
</div> | ||
</div> | ||
<div *ngIf="bundles?.length === 0" | ||
class="alert alert-info w-100 d-inline-block mt-4" role="alert"> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand how this change will work. The method worked by retrieving all bundles and filtering on their name client side. If we no longer retrieve all bundles that filter won't work. The only way it can be fixed is with a rest endpoint I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @artlowel thanks for the catch!
I though we could have use the limitation for bitstreams in the config ( I believe is 5 per page ) but is actually not true, that changes case by case, my bad.
I have kept the implementation because I think the method should support anyway the pagination and instead of the previous loop with expand I set the pagination parameter of 9999, I know this goes in the opposite direction of the PR but I agree that, in terms of rendering time, one big call is preferable to n small calls.
The solution, as you mentioned, will have to be a new endpoint that returns all the bitstreams by bundle name.
In addition to this I have also adapted my changes to the dynamic-list.component.ts as I realized that a "load more" button was not the right approach.
The issue that I noticed was happening in case the user would select an option out of range, save the submission, then reload the page; in this case the user would have had to load all options before being able to see his own selection.
The new solution I adopted is to keep the paginated calls, render the first ones as soon as they are ready, then keep loading the next ones in the background, adding them to the view progressively.
I will look forward to your feedback and thanks again!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @FrancescoMolinaro
I can't seem to find a submission config that actually ends up using
dynamic-list.component.ts
.Before I tested it by simply replacing the tag component with the list component here, and checking the subject field. However that keeps loading infinitely for me now. That might be due to differences between tags and lists tough.
Could you please let me know the backend submission field config you're using to test it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @artlowel , to visualize a dynamic-list in the submission form I am using a configuration like the following:
<field> <dc-schema>dc</dc-schema> <dc-element>identifier</dc-element> <label>Identifiers</label> <input-type value-pairs-name="common_identifiers">list</input-type> <repeatable>true</repeatable> <required /> <hint>Test hint</hint> </field>
The needed part is an input type of value "list" and a vocabulary, then we have two possible list based on the "repeatable" parameter.
Let me know in case this shouldn't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that config works.
I'd still remove the line break between the pages.
(In this screenshot I reduced the page size to 2, to get a better idea how pagination works)
After they've loaded it doesn't matter for the user where the page breaks were:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @artlowel , thanks again for the feedback, I have removed the br, I agree it would just weirdly separate the options.