0
I am creating a task management system and I have a Dashboard that displays the activity updates. The problem is that I can only update this Dashboard when I refresh the page because I am displaying the information with a query in Mysql with PHP.
I would like when I update the status of a task, it be updated in real time, on Dashboard. No need for refresh on the page.
I have already thought of several solutions with AJAX, and even making changes visually in HTML to "fool" the user until he loads the page. But it’s been a lot of work and it seems to me.
Do you have a solution for me? I’m depending on it a lot.
See below the Dashboard image and the task list.
Below is the code I use to fill out the Dashboard.
<div class="row " id="row-resultados-dashboard">
<div class=" col-sm-12 col-sm-offset-0 col-md-10 col-md-offset-1 col-lg-12 col-lg-offset-0" id="resultados-dashboard">
<div class="col-xs-6 col-sm-4 col-lg-2 .relatorios dashboardhover" id="resultados-pendentes">
<p>Tarefas do mês</p>
<?php
while($linha_pendentes = mysqli_fetch_assoc($lista_pendentes))
{
?>
<h1>
<?php echo $linha_pendentes['count(codigo)']; ?>
</h1>
<?php
}
?>
</div>
<div class="col-xs-6 col-sm-4 col-lg-2 .relatorios dashboardhover" id="resultados-iniciados">
<p>Fazendo</p>
<?php
while($linha_iniciados = mysqli_fetch_assoc($lista_iniciados))
{
?>
<h1>
<?php echo $linha_iniciados['count(codigo)']; ?>
</h1>
<?php
}
?>
</div>
<div class="col-xs-6 col-sm-4 col-lg-2 .relatorios dashboardhover" id="resultados-iniciados-vencidos">
<p>Fazendo fora do prazo</p>
<?php
while($linha_iniciados_vencidos = mysqli_fetch_assoc($lista_iniciados_vencidos))
{
?>
<h1>
<?php echo $linha_iniciados_vencidos['count(codigo)']; ?>
</h1>
<?php
}
?>
</div>
<div class="col-xs-6 col-sm-4 col-lg-2 .relatorios dashboardhover" id="resultados-vencidos">
<p>Fora do prazo</p>
<?php
while($linha_vencidos = mysqli_fetch_assoc($lista_vencidos))
{
?>
<h1>
<?php echo $linha_vencidos['count(codigo)']; ?>
</h1>
<?php
}
?>
</div>
<div class="col-xs-6 col-sm-4 col-lg-2 .relatorios dashboardhover " id="resultados-concluidos">
<p>Feito no mês</p>
<?php
while($linha_concluidos = mysqli_fetch_assoc($lista_concluidos))
{
?>
<h1>
<?php echo $linha_concluidos['count(codigo)']; ?>
</h1>
<?php
}
?>
</div>
<div class="col-xs-6 col-sm-4 col-lg-2 .relatorios dashboardhover" id="resultados-concluidos-vencidos">
<p>Feito fora do prazo</p>
<?php
while($linha_concluidos_vencidos = mysqli_fetch_assoc($lista_concluidos_vencidos))
{
?>
<h1>
<?php echo $linha_concluidos_vencidos['count(codigo)']; ?>
</h1>
<?php
}
?>
</div>
</div>
Thank you!
Will, your suggestion was valid. But my intention would be that Dashboard be updated according to user interaction. For example: "If it changes the status of a task, Dashboard changes in real time".
– Gato de Schrödinger
then you can decrease the amount of checks in the function... instead of 15 seconds, you can reduce the time, check 1 in 1 second... but I don’t recommend loading the request server like this. Maybe every 3 seconds... the case is that you need to let him read something so he knows when to update, be it a text file or some column of the database...
– Will Knippelberg
I agree, Will. But my need would be to update only when the user changes the status of the task. I would not like a function to be rolling in the setInterval. But thanks anyway.
– Gato de Schrödinger
Will, if I use this function to run the Cade 1 second, it will not generate huge processing on the system ?
– Gato de Schrödinger
... But still your answer was very helpful to me, Will. Thank you!
– Gato de Schrödinger
Thiago , if you put every 1s will peak on the server yes... ideal is that this process is a little more reduced, I usually give a range of 5 or 10s
– Will Knippelberg
What things are our orders
– Will Knippelberg