Jump to content
We've recently updated our Privacy Statement, available here. ×

How to display a "Loading..." modal or show something on the clicked button while call to API is running?


Henry Heberle

Recommended Posts

In a text area I have button that call APIs and then refresh information links and tables. And to inform users it's running, I created a Loading... modal that blocks the user from clicking anything, so it doesn't look so bad with all the freeze status from Spotfire (happens very often in all computers).

Moreover, in the end, it jumps from one page to another, showing the result to the user.

I tried to​ monitor the state of the spinning icon from Spotfire, bottom-right. Although it worked in my tests, I noticed that users had problems, maybe because their computers are slower or so. So the hack is really a bad workaround or I'm missing a detail in the asynchronous calls and observers or monitoring of the state of that icon/DOM element.

What are the best solutions available?

Currently when they click the button I activate the modal that blocks the user from clicking it again... And inform that it's computing something. The icon doesn't spin until some seconds have passed, hence the need for such modal. Once clicked, it also monitors the DOM element of the spinning icon. If it stops spinning it should disable the modal. However, it also changes the view to another page.

Any idea on which element I need to monitor to make it more stable?​ Or which event? Anything better to know when the Information Links and tables are done via JavaScript?

The API is called and then the tables are updated, at least I believe it happens in sequence and not in parallel. But maybe that could be the problem too.

Both API and tables need to be ready/done to disable the modal.​

Link to comment
Share on other sites

So there is a pool of ongoing tasks that makes the icon spin?

Instead of hacking the html/JavaScript, can I then tell Spotfire when an API call starts and when it ends, so that the official icon from Spotfire starts spinning when that API is called and stops only when all tasks are done?

I wonder how I can deactivate the buttons that activate the API call and activate it again once all tasks are done, i.e., when the icon from Spotfire stops spinning. Or simply show a gray transparent modal anytime the Spotfire icon is spinning (assuming it will spin not only for official Spotfire tasks but for API calls and scripts too).

Thank you!

Link to comment
Share on other sites

The Button is clicked by the user, the iron python script runs and call an API, refresh tables, change document properties that updates information links, etc. But I don't know how to tell Spotfire when such script started and all tasks really ended. I could use a callback or so if there is a way to tell Spotfire when things are running.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...