Run server connect each minute

I want to load a server connect each minute, is this possible with the Wappler UI?

I think it should be something with the date and time component, but I’m not sure how I can load a server action based on each interval (minute in my case).

Or is cronjob the only option here?

That is very simple in Wappler. That is exactly what the action scheduler does.

3 Likes

Oohh so good, I was searching for “date” or “time” and could not find an element. Thanks!

No problem, good luck :wink:

Works like a charm, but still a question: I would like to make the delay based on a variable, like this:

Knipsel

This doesn’t seem to work out of the box, is this possible some other way?

@Teodor is this possible with the UI? Or code maybe?

Hi Nevil,
As almost all of the attributes you can make the delay dynamic by adding dmx-bind: in front of it.
So in your case it will look like: dmx-bind:delay="var1.value" - just put your dynamic value instead of var1.value :slight_smile:

1 Like

Awesome, this works great. Can you make this with a data picker too in future versions?

Also other question, how can I start or stop the action scheduler?

I have seen start with static events, but it has no data picker:

Knipsel

1 Like

I believe this should be possible :slight_smile: @George

When do you want to start/stop it?

Static events do not have data picker as they are only used to run custom js code/functions, static events are not used to control app connect components.
Dynamic events control the components actions - so they do have data picker.

Other components can control action scheduler through dynamic events.

1 Like

I want to start or stop the action scheduler based on the value in a select or if a switch/checkbox is checked. Eventually I want to do it based on MySQL data, but that’s for later.

I have only seen 2 choices: running and percent. Not really a start stop as choices

Seems there is a small error in the properties of the scheduler. The scheduler only has a Tick event, not a Start event. The static events should show the same as the dynamic events, difference is that the dynamic events are used to trigger actions/methods from app connect components and the static event are for normal javascript execution, that is why the static events doesn’t have an action picker.

The start/stop methods are only available in the actions picker on dynamic events, the running and percent are data properties available using the data picker.

Did a small test with the checkbox and noticed that the updated event was also missing in the UI, so here the code to start/stop the scheduler with the checkbox:

<input type="checkbox" dmx-on:updated="checked ? scheduler1.start() : scheduler1.stop()">

Your code doesn’t seem to work. This is what I have now:

 <div class="custom-control custom-switch">
    <input class="custom-control-input" type="checkbox" value="" id="checkbox1" name="checkbox1" dmx-on:updated="checked ? scheduler1.start() : scheduler1.stop()">
    <label class="custom-control-label" for="checkbox1">Default switch</label>
  </div>

The scheduler ID is correct.

When I literally copy paste your code and insert in a div, nothing shows up on the design side.

What do you mean with nothing shows up? I tested it with a checkbox and the above code, I’ve set the No Auto Run on the scheduler to disable it on page load and it starts when the checkbox is being checked and stops when checkbox is being unchecked.