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
7714 configure download all ds #7806
Conversation
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.
Nice work. A lot of suggested small tweaks, and some changes due to calls being made from rendered attributes.
|
||
|
||
public Long getSizeOfDatasetNumeric() { | ||
//get min of orig/archival |
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.
let's have this call the methods in this class that do the specific thing (a little cleaner / easier to read)
} | ||
|
||
public Long getSizeOfDatasetOrigNumeric() { | ||
boolean original = true; |
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.
simplify to one line
|
||
public Long getSizeOfDatasetArchivalNumeric() { | ||
boolean original = false; | ||
return DatasetUtil.getDownloadSizeNumeric(workingVersion, original); |
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.
simplify to one line
} | ||
|
||
public String getSizeOfSelectedMaxAsString(){ | ||
return FileSizeChecker.bytesToHumanReadable(Math.max(getSizeOfSelectedOrigNumeric(), getSizeOfDatasetArchivalNumeric()) ); |
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.
Shouldn't the 2nd call here be for selected?
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.
yes. good catch.
} | ||
|
||
public Long getSizeOfSelectedOrigNumeric(){ | ||
boolean original = true; |
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.
simplify to one line
return FileSizeChecker.bytesToHumanReadable(getDownloadSizeNumeric(dsv, original)); | ||
} | ||
|
||
public static Long getDownloadSizeNumeric(DatasetVersion dsv, boolean original) { |
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.
we can just have this method call the next, passing in the file metadatas (deduplication of logic)
src/main/webapp/dataset.xhtml
Outdated
<!-- DOWNLOAD --> | ||
<ui:fragment rendered="#{DatasetPage.canDownloadFiles()}"> | ||
<ui:fragment rendered="#{DatasetPage.canDownloadFiles() and !(DatasetPage.sizeOfDatasetNumeric > settingsWrapper.zipDownloadLimit) }"> |
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.
renders get called multiple times, so we are doing the work here multiple times (please confirm this is true, by adding a temporary debug method in the method this calls); so we should store the values from the first time it's called (or even add the setting into init) to avoid that.
src/main/webapp/dataset.xhtml
Outdated
<li jsf:rendered="#{DatasetPage.versionHasTabular and DatasetPage.sizeOfDatasetOrig != '0 B' }"> | ||
<p:commandLink update="@form" actionListener="#{DatasetPage.validateAllFilesForDownloadOriginal()}" styleClass="btn-download"> | ||
<li jsf:rendered="#{DatasetPage.versionHasTabular and DatasetPage.sizeOfDatasetOrig != '0 B' and !(DatasetPage.sizeOfDatasetOrigNumeric > settingsWrapper.zipDownloadLimit) }"> | ||
<p:commandLink update="@form" actionListener="#{DatasetPage.validateAllFilesForDownloadOriginal()}" |
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.
it probably make sense, but can you explain the reason behind this change (and the similar one below 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.
We don't want to render the download all here if the size exceeds the zip limit. Instead we show a message pointing the user to use the files table to select files.
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.
Right, I guess I'm trying to understand why there's a rendered on the li but also the validate method called on the link.
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.
The validate method on the link does a bunch of things like check to see if you have permission to download the files and compare the size of files you are asking for to the zip limit (which is more for the case where you select from the files table, but I put it in one method to prevent a lot of duplicate code from the prior version.) Then depending on whether you have selected files for which you don't have permission or too large of a download shows different popups - which is why your suggestion that we put the logic for displaying popups in the page may be hard to accomplish. i'll see what I can do there.
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.
right, but then what is the rendering checking? I must be missing something, if it helps explain it, we could do a quick call later.
Re: the popups, we should be trying to minimize the popups as much as possible; i.e. single message popups that have just a close. I would suggest trying to see if you can use the validate message to set what the message is in the popup (making sure the page updates the popup) and then the code to show the popup happens on the page. Let me know if that makes sense.
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.
The rendering here is checking for whether there are tabular files because it shows multiple links if there are (original or archival downloads). Maybe there's a different approach to take here, but I didn't really change it much except to add the various size tests(and I did set booleans in the init so that the renders won't have to do the same calculation multiple times)
Re: popups I thought you were objecting to the method actually opening them. I can work with the idea of having a single popup where the message changes - we already do that because we list the files that you don't have permission to download.
And Tania asked for the "just close" popup for when the size is too big - it also includes a link to the Download API in the guides.
@@ -3025,6 +3010,11 @@ public boolean isSelectAllFiles() { | |||
public void setSelectAllFiles(boolean selectAllFiles) { | |||
this.selectAllFiles = selectAllFiles; | |||
} | |||
|
|||
public void handleFileSelectClick(){ |
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.
is this used anywhere? It's new, but I don't see any other reference.
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.
Removed. I think I put it in in anticipation of giving immediate feedback when the files selected were too large for zip.
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.
Some additional review.
} | ||
|
||
public String getSizeOfDataset() { | ||
boolean original = false; |
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.
not enough reason for the extra boolean here
|
||
|
||
public void openDownloadPopupForMultipleFileDownload() { | ||
if (this.selectedFiles.isEmpty()) { | ||
//RequestContext requestContext = RequestContext.getCurrentInstance(); | ||
PrimeFaces.current().executeScript("PF('selectFilesForDownload').show()"); |
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.
should we consider removing this one while we're here as well? (or is that out of scope)
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.
Yeah, it's only used for the download mixed popup (some restricted; some not) so we know there are valid files selected so we can just put the openguestbook popup in the onComplete.
|
||
// There's a chance that this is not really a batch download - i.e., | ||
// there may only be one file on the downloadable list. But the fileDownloadService | ||
// method below will check for that, and will redirect to the single download, if | ||
// that's the case. -- L.A. | ||
|
||
this.guestbookResponse.setDownloadtype("Download"); | ||
//RequestContext requestContext = RequestContext.getCurrentInstance(); | ||
PrimeFaces.current().executeScript("PF('downloadPopup').show();handleResizeDialog('downloadPopup');"); |
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.
another one here.
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 removed the whole method - see above.
src/main/webapp/dataset.xhtml
Outdated
<li class="dropdown-header">#{bundle['dataset.accessBtn.header.download']} <span class="glyphicon glyphicon-download-alt"/></li> | ||
<!-- NORMAL DOWNLOAD BUTTON (NO TABULAR FILES) --> | ||
<li jsf:rendered="#{!DatasetPage.versionHasTabular}"> | ||
<p:commandLink update="@form" actionListener="#{DatasetPage.validateAllFilesForDownloadArchival()}" styleClass="btn-download"> | ||
<li jsf:rendered="#{!DatasetPage.versionHasTabular and !(DatasetPage.tooLargeToDownload)}"> |
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.
isn't the 2nd part of the rendered always true? (since it's in the ui fragment)
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.
The difference here is that we render different command links depending on whether there are tabular files in the dataset - line 153 for no tabular files and 164 below for has tabular files.
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 get that, but that explains the tabular check on the renders of the li tags. But I'm talking about the ui:fragment surrounding these li tags. Let me know if it's easier to discuss on a call, viewing the code.
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.
Ok I get what you're saying now. I can remove it.
src/main/webapp/dataset.xhtml
Outdated
<!-- DOWNLOAD ORIGINAL BUTTON (TABULAR FILES PRESENT) --> | ||
<li jsf:rendered="#{DatasetPage.versionHasTabular and DatasetPage.sizeOfDatasetOrig != '0 B' }"> | ||
<p:commandLink update="@form" actionListener="#{DatasetPage.validateAllFilesForDownloadOriginal()}" styleClass="btn-download"> | ||
<li jsf:rendered="#{DatasetPage.versionHasTabular and DatasetPage.sizeOfDatasetOrig != '0 B' and !(DatasetPage.tooLargeToDownloadOriginal) }"> |
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.
same. May make sense to review all the renders in these sections.
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.
@sekmiller Thanks for making those latest changes - I think this hierarchical format is so miuch easier to understand (so maintainable).
I'll approve, but can you add to the QA notes to make sure to test all these different scenarios of original vs archival, etc? Thanks.
What this PR does / why we need it: Modifies messaging when a download exceeds the limit for zipping. Previously we would zip as many files as possible and put the names of the missing files in the manifest file. This was confusing and annoying to users who assumed they got all of the files requested. With this change we will inform the user that they have selected files in excess of the limit and let them know what their options are.
Which issue(s) this PR closes:
Closes #7714 Configuration for Availability of "Download All"
Special notes for your reviewer:
Suggestions on how to test this:
The Access Dataset Button will display in various ways depending on the size of the files relative to the ZipDownloadLimit.
Assuming the user may download files the Access Dataset button will be available, but when the user clicks into it instead of a download link they may see a note saying the files are too large to be downloaded. Also if there are tabular files present and the original format is too large, while the archival version is smaller than the limit they will see one download link and one note saying the format is too large (or vice versa).
In order to exercise the various scenarios it will be useful to put various values in:
curl -X PUT -d 5000000 http://localhost:8080/api/admin/settings/:ZipDownloadLimit
to test
Does this PR introduce a user interface change? If mockups are available, please link/include them here:
https://docs.google.com/presentation/d/1aSTQKu5t2fEM9oGUuvKo0yyj-wbjKfYuYqrsmdhe4RQ/edit#slide=id.g7673497ae2_0_0
Is there a release notes update needed for this change?:
Additional documentation: