2020-12-23 09:11:11 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
{% include "common/common-head.html" %}
|
|
|
|
</head>
|
|
|
|
<body class="hold-transition skin-blue sidebar-mini">
|
|
|
|
<div class="wrapper">
|
|
|
|
|
|
|
|
{% include "common/page-header.html" %}
|
|
|
|
{% with pageselected="status" %}
|
|
|
|
{% include "common/sidebar-menu.html" %}
|
|
|
|
{% endwith %}
|
|
|
|
|
|
|
|
<!-- Content Wrapper. Contains page content -->
|
|
|
|
<div class="content-wrapper">
|
|
|
|
<!-- Content Header (Page header) -->
|
|
|
|
<section class="content-header">
|
|
|
|
<h1>
|
|
|
|
Outlet status
|
|
|
|
</h1>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<!-- Main content -->
|
|
|
|
<section class="content">
|
|
|
|
|
|
|
|
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-xs-12">
|
|
|
|
<div class="box">
|
|
|
|
|
|
|
|
<div class="box-body">
|
|
|
|
<table id="example2" class="table table-bordered table-hover">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th style="width: 15px">#</th>
|
2021-01-05 11:06:27 +00:00
|
|
|
<th>Description</th>
|
2020-12-23 09:11:11 +00:00
|
|
|
<th style="width: 30px">Status</th>
|
|
|
|
<th style="width: 300px">Power load</th>
|
|
|
|
<th style="width: 150px">Command</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<!-- /.box-body -->
|
|
|
|
</div>
|
|
|
|
<!-- /.box -->
|
|
|
|
</div>
|
|
|
|
<!-- /.col -->
|
|
|
|
</div>
|
|
|
|
<!-- /.row -->
|
|
|
|
|
|
|
|
</section>
|
|
|
|
<!-- /.content -->
|
|
|
|
</div>
|
|
|
|
<!-- /.content-wrapper -->
|
2021-01-05 08:15:27 +00:00
|
|
|
|
2020-12-23 09:11:11 +00:00
|
|
|
{% include "common/footer.html" %}
|
2021-01-05 08:15:27 +00:00
|
|
|
|
2020-12-23 09:11:11 +00:00
|
|
|
</div>
|
|
|
|
<!-- ./wrapper -->
|
2021-01-05 08:15:27 +00:00
|
|
|
|
2020-12-23 09:11:11 +00:00
|
|
|
{% include "common/common-js.html" %}
|
2021-01-05 08:15:27 +00:00
|
|
|
|
2020-12-23 09:11:11 +00:00
|
|
|
<!-- DataTables -->
|
|
|
|
<script src="../../bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
|
|
|
|
<script src="../../bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
$(function () {
|
|
|
|
var btnhtml = `<div class="btn-group">
|
|
|
|
<button type="button" class="btn btn-info" script="toggle">Toggle</button>
|
2021-01-05 08:43:50 +00:00
|
|
|
</div>`;
|
2020-12-23 09:11:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
var table = $('#example2').DataTable({
|
|
|
|
'ajax': '/json/status',
|
|
|
|
"columns" : [
|
2021-01-05 11:06:27 +00:00
|
|
|
{ "data" : "Num" },
|
|
|
|
{ "data" : "Description" },
|
|
|
|
{ "data" : "Status" },
|
2020-12-23 09:11:11 +00:00
|
|
|
{ "data" : null, "defaultContent": "<div class='progress progress-xs'><div class='progress-bar progress-bar-danger' style='width: 55%'></div></div>"},
|
|
|
|
{ "data" : null, "defaultContent":btnhtml }
|
|
|
|
],
|
2021-01-05 08:15:27 +00:00
|
|
|
'paging' : false,
|
2020-12-23 09:11:11 +00:00
|
|
|
'lengthChange': true,
|
|
|
|
'searching' : true,
|
|
|
|
'ordering' : true,
|
2021-01-05 08:43:50 +00:00
|
|
|
'info' : true,
|
|
|
|
'rowCallback': function( row, data ) {
|
2021-01-05 11:06:27 +00:00
|
|
|
if ( data.Status ) {
|
2021-01-05 08:43:50 +00:00
|
|
|
$('td:eq(2)', row).html( '<i class="fa fa-toggle-on"></i>' );
|
|
|
|
} else {
|
|
|
|
$('td:eq(2)', row).html( '<i class="fa fa-toggle-off"></i>' );
|
|
|
|
}
|
|
|
|
}
|
2020-12-23 09:11:11 +00:00
|
|
|
});
|
|
|
|
|
2021-01-05 08:43:50 +00:00
|
|
|
// autoreload every 3 seconds
|
|
|
|
setInterval( function () {
|
|
|
|
table.ajax.reload();
|
|
|
|
}, 3000 );
|
2020-12-23 09:11:11 +00:00
|
|
|
|
|
|
|
$('#example2 tbody').on( 'click', '[script="toggle"]', function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
var id = $( this ).closest('tr').find('td:first').text();
|
|
|
|
$.ajax({
|
|
|
|
url: '/json/outlet/'+id+'/toggle',
|
|
|
|
type: 'post'
|
|
|
|
})
|
|
|
|
.done(function(result) {
|
|
|
|
console.log(result);
|
|
|
|
table.ajax.reload();
|
|
|
|
})
|
|
|
|
.fail(function(jqXHR, textStatus, errorThrown) {
|
|
|
|
// needs to implement if it fails
|
|
|
|
console.log(textStatus);
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|