Open igorsimb opened 3 months ago
The Minimum can be done by just refreshing the page and displaying the message, right?
Some useful info. This is how we can catch the before and after request using htmx.
add_items_form.html
...
<-- <form method="POST" action="{% url 'scrape_item' skus=form.skus.value %}" id="addItemsForm"> -->
<form hx-post="{% url 'scrape_item' skus=form.skus.value %}" id="addItemsForm"
hx-on-htmx-before-request="alert('Making a request!')"
hx-on-htmx-after-request="alert('Done making a request!')">
...
More info: https://htmx.org/attributes/hx-on/ Confirmation with sweetalert2: https://htmx.org/examples/confirm/
To avoid IP ban, a pause is needed somewhere between 2-20 seconds (
time.sleep(random.randint(2, 20))
)Problem
It looks very ugly on the frontend. When user clicks "Add" button, no front-facing feedback happens. Everything is staying the way it is, and a loading animation is playing on the browser's tab. Horrible UX. At least user can freely leave the page, or refresh the page - it will still work since scraping is done in the background a as a separate process.
What can we do?
When "Add" button is clicked:
Minimum:
Better:
Best: