Skip to content
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

Update the uploaded files count on the request page #781

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

rebkwok
Copy link
Contributor

@rebkwok rebkwok commented Feb 14, 2025

Fixes #774

When a request is approved and has files uploading in the background, we want to be able to keep the user updated as the files upload. This adds a view that renders just the uploaded file count snippet, and uses htmx to poll it for updates. If the request isn't in an upload-in-progress state, we don't include the htmx attributes, so we don't poll when nothing will change.

If the request moves out of uploading state (either because it complete, or because it fails and won't re-try anything automatically anymore), we reload the page so we update other relevant elements as well (request status, release button etc).

Note that the audit log on the overview page should technically be also updated along with the file count, but I think it's probably acceptable that it does update until the page is reloaded. If users are staying on the page to wait for the uploads to complete, they probably aren't looking at the audit log until the request either completes or fails, and then it'll be reloaded and updated anyway.

Copy link

cloudflare-workers-and-pages bot commented Feb 14, 2025

Deploying airlock-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: f1e3826
Status: ✅  Deploy successful!
Preview URL: https://422274bf.airlock.pages.dev
Branch Preview URL: https://htmx-upload-changes.airlock.pages.dev

View logs

We're going to want to replace this snippet with htmx so we can
update the file upload progress.

Also adds upload_in_progess as a variable in the request view
context as we're going to need this more than once and it'll
avoid repeatedly calling the method which hits the db.
If a request has uploads in progress, we poll every second for updates
and replace the uploaded_files_count element.

If on an update we find that the request is no longer actively
uploading,
we reload the page to update the various other elements that might need
to change, and we stop polling.
@rebkwok rebkwok force-pushed the htmx-upload-changes branch from f1e3826 to df4e803 Compare February 14, 2025 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add some htmx polling to update the status and upload count without having to manually refresh the page
1 participant