nyudlts / ultraviolet

UltraViolet 💜 is NYU Libraries' DLTS deployment of the InvenioRDM framework. All info in the link.
https://nyudlts.github.io/ultraviolet/
5 stars 5 forks source link

Change number of files and storage size allowed for submission #66

Closed ekate closed 1 week ago

ekate commented 2 years ago

We assumed that those parameters are configurable. It appeared that both maximum number of files and storage quota are hard coded. https://github.com/inveniosoftware/invenio-app-rdm/blob/47001d2e1ef6ab7ac040139aad77d8396d2f150e/invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/deposit/RDMDepositForm.js#L168-L173 There is no way we can change it without modifying the deposit form

dismorfo commented 2 years ago

See: deposit_create() inside deposists.py from https://github.com/inveniosoftware/invenio-app-rdm

We might want to add the file-size information as part of the 'forms_config', so that "deposits-config" has that info as props (deposit.html)

dismorfo commented 2 years ago

Looks like updating deposit_create and deposit_edit from deposists.py to have something along the lines of:

forms_config=get_form_config(
    createUrl=("/api/records"),
    maxStorage=current_app.config.get("FILE_UPLOADER_QUOTA_MAX_STORAGE"),
    maxFiles=current_app.config.get("FILE_UPLOADER_QUOTA_MAX_FILES")
)

And adding the values to invenio.cfg can do the trick. I have not tested any of this.

Once we have the value in the form_config, I can access the value and pass it as props for the component FileUploader

dismorfo commented 2 years ago

See: https://github.com/nyudlts/ultraviolet-deposit/commit/06d3a6a4fb3cf8b8a551d03292bf0a59dd2b8cc2

If we manage to update deposists.py, we can read from invenio.cfg the following value:

FILE_UPLOADER_QUOTA_MAX_FILES = 10 FILE_UPLOADER_QUOTA_MAX_STORAGE = 10000000000

ekate commented 2 years ago

@dismorfo I am looking at this now. The templates can read variables from invenio.cfg directly so I am trying to see if I can just inject some variables into the form. If that does not work I will try to submit a pull request to main code of invenio-app-rdm with additional parameters, as I do not see how else deposits.py can be modified without forking

dismorfo commented 2 years ago

Another way to do it (feels like a hack), we can add another element to deposit.html. Example:

{%- if forms_config %}
  <input type="hidden" name="deposits-config" value='{{forms_config | tojson }}'></input>
{%- endif %}
{%- if ultraviolet_config %}
  <input type="hidden" name="ultraviolet-config" value='{{ultraviolet_config | tojson }}'></input>
{%- endif %}

And then we can update index.js to be something along the lines of:

const deposits_config = getInputFromDOM("deposits-config");
const ultraviolet_config = getInputFromDOM("ultraviolet-config");

const form_config = {...deposits_config, ...ultraviolet_config};

ReactDOM.render(
  <RDMDepositForm
    record={getInputFromDOM("deposits-record")}
    files={getInputFromDOM("deposits-record-files")}
    config={form_config}
    permissions={getInputFromDOM("deposits-record-permissions")}
  />,
  document.getElementById("deposit-form")
);

The code is not tested and most likely will need some modification.

ekate commented 2 years ago

I think that will work. Let me check