ondemand icon indicating copy to clipboard operation
ondemand copied to clipboard

refactor _inline_js.html.erb to use the config.js

Open johrstrom opened this issue 2 years ago • 2 comments

With #2506 we can move onto refactoring a little in how we pull data from the server into the HTML.

What I'd like to do is stop rendering this as a <script> and start rendering in the ood_config div that we can pull data from.

https://github.com/OSC/ondemand/blob/master/apps/dashboard/app/views/files/_inline_js.html.erb

Here's a more specific example. Instead of this being javascript https://github.com/OSC/ondemand/blob/f230efe132dbc218d2078a1ea272cc7bf7c9b3f1/apps/dashboard/app/views/files/_inline_js.html.erb#L4

We could instead embed it into this html meta tag.

  <meta id="ood_config"
    <!-- ... -->
    data-max-file-fize="<%= Configuration.file_upload_max %>" 
  />

Then in the runtime javascript using it would have to pull the value from the config.js.

https://github.com/OSC/ondemand/blob/bd3004adeee6522c58fce799e8825b7801c7e16d/apps/dashboard/app/javascript/packs/files/uppy_ops.js#L70

┆Issue is synchronized with this Asana task by Unito

johrstrom avatar Jan 24 '23 19:01 johrstrom

Then in the runtime javascript using it would have to pull the value from the config.js.

Is the idea that there is a function in the config.js to call this from uppy_apps.js?

Oglopf avatar Jan 24 '23 21:01 Oglopf

Then in the runtime javascript using it would have to pull the value from the config.js.

Is the idea that there is a function in the config.js to call this from uppy_apps.js?

Yea similar to setNavbarColor or even maybe it exposes all the data and and uppy_apps.js can reference something like configData['maxFileSize'].

johrstrom avatar Jan 24 '23 21:01 johrstrom