In this episode, we start working on displaying the progress of CSV imports in our app. The first thing we do is make sure the import queue is turned off—this is just to make sure we can test things out properly without our queue jobs running in the background.
Then, instead of lumping everything into our existing CSV importer component, we go ahead and generate a fresh Livewire component (called csv-imports
) to manage and display the import progress. This setup makes it easier to update and refresh just the import progress (using Livewire's polling feature), rather than the whole page or component. That way, we can keep everything looking smooth without overcomplicating things with real-time events.
We then add the basic markup for the import progress listing—a loop over the imports with file names, how many rows have been imported, and a progress bar. We hook this up to pull import data for the current user, and for now, it shows all imports, whether finished or not, and for any model.
After that, we create a simple method on the Import model to calculate the percentage progress. We use that to adjust the width of our progress bar dynamically. A quick test with some fake data shows everything working as expected.
By the end, we've got a nice import listing with real progress bars, but it's still a bit rough—it's showing all imports (even finished ones, and for all models). We'll clean all that up and scope it down properly in the next episode.