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

[Feature] Enable Client Side Timer for all Queries & JS #6217

Closed
ajinkyakulkarni opened this issue Jul 28, 2021 · 19 comments
Closed

[Feature] Enable Client Side Timer for all Queries & JS #6217

ajinkyakulkarni opened this issue Jul 28, 2021 · 19 comments
Assignees
Labels
Community Reported issues reported by community members Enhancement New feature or request Javascript Product Issues related to users writing javascript in appsmith JS Evaluation Issues related to JS evaluation on the platform Low An issue that is neither critical nor breaks a user flow

Comments

@ajinkyakulkarni
Copy link
Contributor

Summary

Add a new Timer widget to execute triggers on a certain frequency

Motivation

Currently, it is not possible to run triggers (call queries, functions, APIs) on a schedule. A Timer widget would be very handy. It will help users build auto-updating, real-time internal tools. On a timer event, we can trigger JS bindings.

Additional Context

Visual Basic (6 and .Net) had a Timer widget which you can drop on the Canvas/form and then set properties. It was very useful to build timers.

image

image

image

image

@ajinkyakulkarni ajinkyakulkarni added Enhancement New feature or request UI Building Product Issues related to the UI Building experience High impact labels Jul 28, 2021
@ajinkyakulkarni
Copy link
Contributor Author

Related feature #3312

@somangshu
Copy link
Contributor

We also have #738 and #1950 related to similar functionality. We have disabled setTimeout like functions due to security reason.

The above mentioned issues are not prioritised and needs discussion for the same.

@Nikhil-Nandagopal
Copy link
Contributor

If it doesn't have a UI, I don't think this should be a widget. A protected setTimeout seems to be the right way to achieve this.

@Nikhil-Nandagopal Nikhil-Nandagopal added Core Query Execution Issues related to the execution of all queries and removed UI Building Product Issues related to the UI Building experience UI Building Pod labels Jul 28, 2021
@somangshu somangshu removed their assignment Jul 28, 2021
@ajinkyakulkarni
Copy link
Contributor Author

If it is a widget, we can add multiple timers with different intervals. We can also bind enabled property of a timer to some JS condition. If we don't go with the widget approach, will we be supporting just one timer or come up with a different way to support multiple timers?

@ajinkyakulkarni
Copy link
Contributor Author

ajinkyakulkarni commented Jul 28, 2021

If not a widget, should this be a section on the settings page (a section for timers and their properties/binding)?

@Nikhil-Nandagopal
Copy link
Contributor

@ajinkyakulkarni this could simply be writing a JS function in the editor and marking it onPageLoad as

export default {
  run: () => {
     setSafeTimeout(() => {
        API1.run();
     }, 1000);
  }
}

Then you can do multiple timers, functions, basically whatever the user wants will be possible. But we need to get the JS Editor experience right and enable this safe timeout functionality

@Nikhil-Nandagopal Nikhil-Nandagopal changed the title [Feature] Add Timer widget [Feature] Enable Safe Set Timeout in JS Aug 16, 2021
@Nikhil-Nandagopal Nikhil-Nandagopal added JS Evaluation Issues related to JS evaluation on the platform and removed Core Query Execution Issues related to the execution of all queries labels Aug 16, 2021
@Nikhil-Nandagopal Nikhil-Nandagopal changed the title [Feature] Enable Safe Set Timeout in JS [Feature] Enable Client Side Timer for all Queries & JS Sep 1, 2021
@PaoloConte
Copy link

+1 on this, I'm building dashboards to monitor remote plants, this would be helpful to always show fresh data from the API, the user cannot keep clicking on refresh ;)

@somangshu somangshu added the Community Reported issues reported by community members label Sep 6, 2021
@somangshu
Copy link
Contributor

@PaoloConte thank for the comment here, This will help us in prioritising the issue

@hetunandu
Copy link
Member

closing in favour of #3312

@areyabhishek
Copy link
Contributor

areyabhishek commented Nov 15, 2021

Reopening this because this issue isn't solved completely by #3312. This issue will enable the timer to run automatically without any user intervention vs. the other issue requires user input. @cokoghenun pointed this out.
@hetunandu @ajinkyakulkarni Please correct me if I've misunderstood this.

@areyabhishek areyabhishek reopened this Nov 15, 2021
@hetunandu
Copy link
Member

@areyabhishek this issue can be closed once we have all the parts ready. The usage would be to use setInterval in a JS function which is run on page load.

@megaconfidence
Copy link
Contributor

How about we make this built-in, in the entity settings page. We already have a checkbox to run queries on page load. We could add one for polling (as a user, I'll expect it to be here)

Screenshot 2021-11-16 at 12 06 19 PM

@hetunandu
Copy link
Member

How about we make this built-in, in the entity settings page. We already have a checkbox to run queries on page load. We could add one for polling (as a user, I'll expect it to be here)

Screenshot 2021-11-16 at 12 06 19 PM

We thought about this but found it pretty limitting. Incase you want some complex logic to run at a fixed interval, it would not be possible as this feature could only run that single action. Adding it as a function gives it much more flexibility of usage

@megaconfidence
Copy link
Contributor

Not sure what you mean by "some complex logic". The only logic here is to poll the API right?

@hetunandu
Copy link
Member

Not sure what you mean by "some complex logic". The only logic here is to poll the API right?

you could have some if statements to decide if you want to poll the api. You could want to capture some data from some widgets or other responses and pass that as params to the api you are polling. Many things can be possible

@megaconfidence
Copy link
Contributor

Hmm, you're right. My thought initially was, we could have a simple form in the UI for this (because requests I've seen around this are simple get requests), then also add a note or something that if the user wants more control, they could use setInterval/clearInterval

@areyabhishek
Copy link
Contributor

Can we do both? Exposing it in the API pane will enable discovery. Discovering this function is difficult unless you try it or read the documentation. While it's easy to discover the simple option in the API pane and we can add a tooltip explaining that they can also use a function.

@Nikhil-Nandagopal Nikhil-Nandagopal added High This issue blocks a user from building or impacts a lot of users and removed High impact labels Apr 4, 2022
@github-actions github-actions bot added the Javascript Product Issues related to users writing javascript in appsmith label Apr 4, 2022
@hetunandu hetunandu removed their assignment Jul 5, 2022
@danciaclara
Copy link
Contributor

A user requested this feature on Discord - Usecase below
something a bit of a normal timer which i can start, stop/pause, resume and once stoped get the timeElapsed() to get the time series data fetched from the TSDB (influx) via an API call.

https://discord.com/channels/725602949748752515/760761686549463060/1004025639139037204

@bharath31 bharath31 added Low An issue that is neither critical nor breaks a user flow and removed High This issue blocks a user from building or impacts a lot of users labels Nov 30, 2022
@bharath31
Copy link

closing this since we now support setTimeout() and setInterval()

@bharath31 bharath31 closed this as not planned Won't fix, can't repro, duplicate, stale Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Reported issues reported by community members Enhancement New feature or request Javascript Product Issues related to users writing javascript in appsmith JS Evaluation Issues related to JS evaluation on the platform Low An issue that is neither critical nor breaks a user flow
Projects
None yet
Development

No branches or pull requests