0

I am making a control panel in which a user can see their RAM and CPU usage. I made the Laravel part of the project and started on the bootstrap. So far I am displaying the usage using bootstrap:

<div class="progress">

  <div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: {{$cpu}}%"></div>

</div>

I am retrieving the data in the Controller and then I am passing it to the view:

return view('control_panel', compact('cpu', 'ram'));

However, my problem is the user has to refresh the page constantly in order to get real time information. It is not such a big problem for now but in the future it may become a burden.

Is there a way to update the page automatically (every few seconds)? I worked a bit with jQuery but never with Ajax. Is there a simple solution to my problem?

GMBeniamin
  • 119
  • 1
  • 6
  • 12
  • 2
    A timed AJAX solution might fit the bill --> https://stackoverflow.com/questions/5687600/jquery-call-ajax-every-10-seconds – Zak Jun 13 '18 at 20:03

1 Answers1

1

For best solution, you should use broadcasting. So You don't have to refresh page. You can send data with Scheduling every one minute and broadcast data. Then you can show this data on page.

This is real time example project project with Laravel, Redis, Web socket and Laravel Echo Server

https://github.com/durmus-aydogdu/real-time-application

I hope this will help you.

webdevtr
  • 480
  • 2
  • 6