updated index2.html to display data

This commit is contained in:
kicap 2024-06-10 16:48:48 +08:00
parent 927d265bd3
commit 9273d712bb
2 changed files with 22 additions and 8 deletions

2
app.py
View File

@ -483,7 +483,7 @@ async def check_jumlah_kenderaan():
kenderaan_kiri = result[0][4] kenderaan_kiri = result[0][4]
kenderaan_kanan = result[0][5] kenderaan_kanan = result[0][5]
waktu_sekarang = result[0][3] waktu_sekarang = result[0][3]
return jsonify({'jumlah_kenderaan': jumlah_kenderaan, 'kenderaan_kiri': kenderaan_kiri, 'kenderaan_kanan': kenderaan_kanan, 'waktu_sekarang':waktu_sekarang}) return jsonify({'jumlah_kenderaan': jumlah_kenderaan, 'kenderaan_kiri': kenderaan_kiri, 'kenderaan_kanan': kenderaan_kanan, 'waktu_sekarang':waktu_sekarang , selesainya: selesainya})
# return jsonify({'jumlah_kenderaan': jumlah_kenderaan, 'kenderaan_kiri': kenderaan_kiri, 'kenderaan_kanan': kenderaan_kanan}) # return jsonify({'jumlah_kenderaan': jumlah_kenderaan, 'kenderaan_kiri': kenderaan_kiri, 'kenderaan_kanan': kenderaan_kanan})

View File

@ -133,13 +133,15 @@
<div class="col-lg-8 col-md-10 col-xs-12"> <div class="col-lg-8 col-md-10 col-xs-12">
<div class="box-content"> <div class="box-content">
<h4 class="box-title">Hasil Pengolahan Video {% if stat != "Belum Ada Data" %} <i>({{ stat[6] }}) </i>{% endif %}</h4> <h4 class="box-title">Hasil Pengolahan Video {% if stat != "Belum Ada Data" %} <i>({{ stat[6]
}}) </i>{% endif %}</h4>
<div class="card-content" id="div-ini-data"> <div class="card-content" id="div-ini-data">
<div id="data-video" style="display: none;"></div> <div id="data-video" style="display: none;"></div>
{% if stat == "Belum Ada Data" %} {% if stat == "Belum Ada Data" %}
<div class="form-group"> <div class="form-group">
<p id="p-ket">{{ stat }}</p> <p id="p-ket">{{ stat }}</p>
<button type="button" class="btn btn-primary" onclick="proses_video('{{ video }}')" id="btn-proses">Proses</button> <button type="button" class="btn btn-primary" onclick="proses_video('{{ video }}')"
id="btn-proses">Proses</button>
</div> </div>
{% else %} {% else %}
<div class="form-group text-center"> <div class="form-group text-center">
@ -167,7 +169,8 @@
</table> </table>
</div> </div>
<div class="form-group text-center"> <div class="form-group text-center">
<button type="button" class="btn btn-primary" onclick="proses_video('{{ video }}')" id="btn-proses">Proses</button> <button type="button" class="btn btn-primary" onclick="proses_video('{{ video }}')"
id="btn-proses">Proses</button>
</div> </div>
{% endif %} {% endif %}
</div> </div>
@ -262,14 +265,14 @@
document.getElementById('kanan').innerHTML = data.kenderaan_kanan document.getElementById('kanan').innerHTML = data.kenderaan_kanan
document.getElementById('total').innerHTML = data.jumlah_kenderaan document.getElementById('total').innerHTML = data.jumlah_kenderaan
if(document.getElementById('example')){ if (document.getElementById('example')) {
$("#td-waktu-sekarang").text(data.waktu_sekarang); $("#td-waktu-sekarang").text(data.waktu_sekarang);
$("#td-jumlah").text(data.jumlah_kenderaan); $("#td-jumlah").text(data.jumlah_kenderaan);
$("#td-kiri").text(data.kenderaan_kiri); $("#td-kiri").text(data.kenderaan_kiri);
$("#td-kanan").text(data.kenderaan_kanan); $("#td-kanan").text(data.kenderaan_kanan);
} }
if(data.selesainya == true){ if (data.selesainya == true) {
// reload page // reload page
window.location.reload(); window.location.reload();
} }
@ -283,12 +286,23 @@
// open url in new tab but stay in current tab and dont redirect or reload this page // open url in new tab but stay in current tab and dont redirect or reload this page
let html = "<iframe src='/video_feed?video=" + video + "' width='100%' height='100%' frameborder='0' allowfullscreen></iframe>" let html = "<iframe src='/video_feed?video=" + video + "' width='100%' height='100%' frameborder='0' allowfullscreen></iframe>"
$("#data-video").html(html) $("#data-video").html(html)
$("#btn-proses").attr("disabled", true) $("#btn-proses").attr("disabled", true)
$("#btn-proses").html("Memproses ....") $("#btn-proses").html("Memproses ....")
if(document.getElementById('p-ket')){ if (document.getElementById('p-ket')) {
$("#p-ket").html("Window pengolahan video sedang berjalan....") $("#p-ket").html("Window pengolahan video sedang berjalan....")
} }
document.getElementById('kiri').innerHTML = 0
document.getElementById('kanan').innerHTML = 0
document.getElementById('total').innerHTML = 0
if (document.getElementById('example')) {
$("#td-waktu-sekarang").text(0);
$("#td-jumlah").text(0);
$("#td-kiri").text(0);
$("#td-kanan").text(0);
}
} }
// run check_jumlah_kenderaan every 1.5 seconds\ // run check_jumlah_kenderaan every 1.5 seconds\