thomas4019 / expressa

API creation middleware with an admin interface
MIT License
438 stars 27 forks source link

Admin: Large Arrays Cause Unresponsive Page #215

Open kane-mason opened 7 months ago

kane-mason commented 7 months ago

In /admin, if you have a document that has an array with many items in it (> 1000) then the page fails to load and the browser will prompt to say the page is unresponsive

I assume this is as a result of the browser trying to dunamically create all the div/li elements. A suggestion is to only display maybe 50 with a see more button to display the next 50 and so on

thomas4019 commented 7 months ago

@kane-mason which page is this on exactly? Is this on the edit page or on the page that shows a list of documents?

kane-mason commented 7 months ago

@thomas4019 this happens when trying to view / edit a single document that has a large array in it. I actually think the array has to be an array of objects

thomas4019 commented 7 months ago

Hmm, this is tricky since that page just uses the open source https://github.com/json-editor/json-editor. Can you explain a bit more about your design. I wonder if all this data needs to be in the same document. Could you put each row of the array into separate documents under a different collection?

kane-mason commented 7 months ago

So yes that is an option, but in both the cases for me when this happens, i feel a new collection is unncessary. One such example is storing coordinates of a map { lat: 1, lng: 2, ele: 3 }. As you know maps can have many many points, and creating a collection for each point seems unnecessary.

kane-mason commented 7 months ago

Found these:

https://github.com/json-editor/json-editor/issues/252 https://github.com/json-editor/json-editor/wiki/Handle-Large-Arrays-with-the-JSON-editor

thomas4019 commented 2 months ago

I took a look at the linked docs and unfortunately this doesn't seem very simple. The instructions aren't easy to follow and it it seems like it would involve some custom coding so I don't think I'll be able to get around to it soon.

It should be fairly straightforward to have fields with large payloads use a text editor so the page still loads (but those fields would then be more work to edit)

Have you found a workaround so far?