traffic-counter/templates/index2.html

354 lines
16 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="description" content="">
<meta name="author" content="">
<title>Traffic Counter | Halaman Utama</title>
<!-- Main Styles -->
<link rel="stylesheet" href="assets/styles/style.min.css">
<!-- mCustomScrollbar -->
<link rel="stylesheet" href="assets/plugin/mCustomScrollbar/jquery.mCustomScrollbar.min.css">
<!-- Waves Effect -->
<link rel="stylesheet" href="assets/plugin/waves/waves.min.css">
<!-- Sweet Alert -->
<link rel="stylesheet" href="assets/plugin/sweet-alert/sweetalert.css">
<!-- Color Picker -->
<link rel="stylesheet" href="assets/color-switcher/color-switcher.min.css">
</head>
<body>
<div class="main-menu">
<header class="header">
<a href="#" class="logo">Traffic Counter</a>
<button type="button" class="button-close fa fa-times js__menu_close"></button>
<div class="user">
<a href="#" class="avatar"><img src="http://placehold.it/80x80" alt=""><span
class="status online"></span></a>
<h5 class="name"><a href="#">Admin</a></h5>
<h5 class="position">Administrator</h5>
<!-- /.name -->
<!-- <div class="control-wrap js__drop_down">
<i class="fa fa-caret-down js__drop_down_button"></i>
<div class="control-list">
<div class="control-item"><a href="profile.html"><i class="fa fa-user"></i> Profile</a></div>
<div class="control-item"><a href="#"><i class="fa fa-gear"></i> Settings</a></div>
<div class="control-item"><a href="#"><i class="fa fa-sign-out"></i> Log out</a></div>
</div>
</div> -->
<!-- /.control-wrap -->
</div>
<!-- /.user -->
</header>
<!-- /.header -->
<div class="content">
<div class="navigation">
<h5 class="title">Navigasi</h5>
<!-- /.title -->
<ul class="menu js__accordion">
<li class="current">
<a class="waves-effect" href="{{ url_for('index') }}"><i
class="menu-icon fa fa-home"></i><span>Halaman
Utama</span></a>
</li>
<li>
<a class="waves-effect" href="{{ url_for('video_list') }}"><i
class="menu-icon fa fa-home"></i><span>Video
Data</span></a>
</li>
</ul>
</div>
<!-- /.navigation -->
</div>
<!-- /.content -->
</div>
<!-- /.main-menu -->
<div class="fixed-navbar">
<div class="pull-left">
<button type="button"
class="menu-mobile-button glyphicon glyphicon-menu-hamburger js__menu_mobile"></button>
<h1 class="page-title">Halaman Utama</h1>
<!-- /.page-title -->
</div>
<!-- /.pull-left -->
</div>
<!-- /.fixed-navbar -->
<div id="wrapper">
<div class="main-content">
<div class="row small-spacing">
<div class="col-lg-2 col-md-1 col-xs-12"></div>
<div class="col-lg-8 col-md-10 col-xs-12">
<div class="box-content">
<h4 class="box-title">Form Analisa Video {{ minimal_kepadatan }}</h4>
<div class="card-content">
<div class="form-group">
<label for="video">Pilih Video:</label>
<select class="form-control" id="video" name="video">
<option value="-Pilih Video-" disabled selected>-Pilih Video-</option>
{% for video_var in video_list %}
<option value="{{ video_var }}" {% if video_var==video %}selected{% endif %}>{{
video_var }}</option>
{% endfor %}
</select>
</div>
<div class="form-group">
<label for="video">Minimal Kepadatan:</label>
<select class="form-control" id="minimal_kepadatan" name="minimal_kepadatan">
<option value="-Minimal Kepadatan-" disabled selected>-Pilih Minimal Kepadatan-
</option>
<option value="2" {% if minimal_kepadatan==2 %}selected{% endif %}>2</option>
<option value="3" {% if minimal_kepadatan==3 %}selected{% endif %}>3</option>
<option value="4" {% if minimal_kepadatan==4 %}selected{% endif %}>4</option>
<option value="5" {% if minimal_kepadatan==5 %}selected{% endif %}>5</option>
<option value="6" {% if minimal_kepadatan==6 %}selected{% endif %}>6</option>
<option value="7" {% if minimal_kepadatan==7 %}selected{% endif %}>7</option>
<option value="8" {% if minimal_kepadatan==8 %}selected{% endif %}>8</option>
<option value="9" {% if minimal_kepadatan==9 %}selected{% endif %}>9</option>
<option value="10" {% if minimal_kepadatan==10 %}selected{% endif %}>10</option>
</select>
</div>
<div class="form-group text-center">
<button type="button" class="btn btn-primary" onclick="olah_video()">Proses
Video</button>
</div>
</div>
</div>
</div>
<div class="col-lg-2 col-md-1 col-xs-12"></div>
</div>
<div class="row small-spacing">
<div class="col-lg-2 col-md-1 col-xs-12"></div>
<div class="col-lg-8 col-md-10 col-xs-12">
<div class="box-content">
<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 id="data-video" style="display: none;"></div>
{% if stat == "Belum Ada Data" %}
<div class="form-group">
<p id="p-ket">{{ stat }}</p>
<button type="button" class="btn btn-primary" onclick="proses_video('{{ video }}')"
id="btn-proses">Proses</button>
</div>
{% else %}
<div class="form-group text-center">
<table id="example" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
<th>Video</th>
<th>Waktu</th>
<th>Last Scan</th>
<th>Kiri</th>
<th>Kanan</th>
<th>Jumlah</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ stat[1] }}</td>
<td>{{ stat[2] }} detik</td>
<td id="td-waktu-sekarang">{{ stat[3] }} detik</td>
<td id="td-kiri">{{ stat[4] }}</td>
<td id="td-kanan">{{ stat[5] }}</td>
<td id="td-jumlah">{{ stat[4] + stat[5] }}</td>
</tr>
</tbody>
</table>
</div>
<div class="form-group text-center">
<button type="button" class="btn btn-primary" onclick="proses_video('{{ video }}')"
id="btn-proses">Proses</button>
</div>
{% endif %}
</div>
</div>
</div>
<div class="col-lg-2 col-md-1 col-xs-12"></div>
</div>
<div class="row small-spacing">
<div class="col-lg-3 col-md-3 col-xs-12">
<div class="box-content">
<div class="statistics-box with-icon">
<!-- <i class="ico fa fa-car text-info"></i> -->
<h2 class="counter text-info" id="kiri">...</h2>
<p class="text">Kenderaan Kiri</p>
</div>
</div>
<!-- /.box-content -->
</div>
<div class="col-lg-3 col-md-3 col-xs-12">
<div class="box-content">
<div class="statistics-box with-icon">
<!-- <i class="ico fa fa-car text-info"></i> -->
<h2 class="counter text-info" id="kanan">...</h2>
<p class="text">Kenedraan Kanan</p>
</div>
</div>
<!-- /.box-content -->
</div>
<input type="hidden" id="minimal_value" value="{{ minimal_kepadatan }}">
<div class="col-lg-3 col-md-3 col-xs-12">
<div class="box-content">
<div class="statistics-box with-icon">
<!-- <i class="ico fa fa-car text-info"></i> -->
<h2 class="counter text-info" id="total">...</h2>
<p class="text">Jumlah Kenderaan</p>
</div>
</div>
<!-- /.box-content -->
</div>
<div class="col-lg-3 col-md-3 col-xs-12">
<div class="box-content">
<div class="statistics-box with-icon">
<!-- <i class="ico fa fa-car text-info"></i> -->
<h2 class="counter text-info" id="kepadatan">...</h2>
<p class="text">Kepadatan Kenderaan</p>
</div>
</div>
<!-- /.box-content -->
</div>
</div>
<footer class="footer">
<ul class="list-inline">
<li>2024 © Traffic Counter.</li>
<!-- <li><a href="#">Privacy</a></li>
<li><a href="#">Terms</a></li>
<li><a href="#">Help</a></li> -->
</ul>
</footer>
</div>
<!-- /.main-content -->
</div><!--/#wrapper -->
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="assets/script/html5shiv.min.js"></script>
<script src="assets/script/respond.min.js"></script>
<![endif]-->
<!--
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="assets/scripts/jquery.min.js"></script>
<script src="assets/scripts/modernizr.min.js"></script>
<script src="assets/plugin/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/plugin/mCustomScrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
<script src="assets/plugin/nprogress/nprogress.js"></script>
<script src="assets/plugin/sweet-alert/sweetalert.min.js"></script>
<script src="assets/plugin/waves/waves.min.js"></script>
<!-- Full Screen Plugin -->
<script src="assets/plugin/fullscreen/jquery.fullscreen-min.js"></script>
<script src="assets/scripts/main.min.js"></script>
<script src="assets/color-switcher/color-switcher.min.js"></script>
<script>
var minimal_kepadatan = document.getElementById('minimal_value').value;
$("#minimal_kepadatan").val(minimal_kepadatan);
function olah_video() {
var video = document.getElementById('video').value;
var minimal_kepadatan = document.getElementById('minimal_kepadatan').value;
// var threshold = document.getElementById('threshold').value;
var threshold = 450;
window.location.href = '/?video=' + video + '&threshold=' + threshold + '&minimal_kepadatan=' + minimal_kepadatan;
}
function check_jumlah_kenderaan() {
// create an ajax
$.ajax({
type: "GET",
url: "/check_jumlah_kenderaan",
success: function (data) {
// console.log(data)
console.log(data.kenderaan_sekarang)
if (data.kenderaan_sekarang == undefined) {
document.getElementById('kepadatan').innerHTML = "Belum Diproses"
} else if (data.kenderaan_sekarang >= minimal_kepadatan) {
document.getElementById('kepadatan').innerHTML = "Padat"
} else {
document.getElementById('kepadatan').innerHTML = "Tidak Padat"
}
document.getElementById('kiri').innerHTML = data.kenderaan_kiri
document.getElementById('kanan').innerHTML = data.kenderaan_kanan
document.getElementById('total').innerHTML = data.jumlah_kenderaan
if (document.getElementById('example')) {
$("#td-waktu-sekarang").text(data.waktu_sekarang);
$("#td-jumlah").text(data.jumlah_kenderaan);
$("#td-kiri").text(data.kenderaan_kiri);
$("#td-kanan").text(data.kenderaan_kanan);
}
if (data.selesainya == true) {
// reload page
window.location.reload();
}
}
});
}
function proses_video(video) {
console.log(video)
// 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>"
$("#data-video").html(html)
$("#btn-proses").attr("disabled", true)
$("#btn-proses").html("Memproses ....")
if (document.getElementById('p-ket')) {
$("#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\
setInterval(check_jumlah_kenderaan, 1500);
// check_jumlah_kenderaan();
</script>
</body>
</html>