sidebar values improvement

load header data on devicepage
This commit is contained in:
Lukas-Heiligenbrunner 2020-02-28 11:48:41 +01:00
parent 8e4aad4691
commit c839c8506c
6 changed files with 49 additions and 96 deletions

View File

@ -142,14 +142,6 @@ class DeviceRequest : PostRequest() {
} }
sb.append("{\"status\":\"success\"}") sb.append("{\"status\":\"success\"}")
} }
"getDeviceNumber" -> try {
val numberset = jdbc!!.executeQuery("SELECT * FROM devices")
numberset.last()
val devicenr = numberset.row
sb.append("{\"devicenr\":\"$devicenr\"}")
} catch (e: SQLException) {
e.printStackTrace()
}
"addtodb" -> { "addtodb" -> {
var cityid = -1 var cityid = -1
try { try {
@ -162,6 +154,21 @@ class DeviceRequest : PostRequest() {
} }
sb.append("{\"success\":true}") sb.append("{\"success\":true}")
} }
"getheader" -> {
try {
var numberset = jdbc!!.executeQuery("SELECT * FROM devices")
numberset.last()
val devicenr = numberset.row
numberset = jdbc!!.executeQuery("SELECT * FROM devices WHERE CityID=-1")
numberset.last()
val unconfigureddevices = numberset.row
sb.append("{\"success\":true,\"devicenumber\":$devicenr, \"unconfigureddevices\":$unconfigureddevices}")
} catch (e: SQLException) {
e.printStackTrace()
}
}
} }
return sb.toString() return sb.toString()
} }

View File

@ -70,15 +70,6 @@
<ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu"
data-accordion="false"> data-accordion="false">
<li class="nav-item">
<a href="ShedulePickUp.html" class="nav-link">
<i class="nav-icon fas fa-calendar-alt"></i>
<p>
Shedule Pick-up
</p>
</a>
</li>
<li class="nav-item"> <li class="nav-item">
<a href="dashboard.html" class="nav-link"> <a href="dashboard.html" class="nav-link">
<i class="nav-icon fas fa-columns"></i> <i class="nav-icon fas fa-columns"></i>
@ -98,14 +89,7 @@
</a> </a>
</li> </li>
<li class="nav-item">
<a href="#todo" class="nav-link">
<i class="nav-icon fas fa-plus-circle"></i>
<p>
New Entry
</p>
</a>
</li>
<li id="adminpanel" class="nav-item hideit"> <li id="adminpanel" class="nav-item hideit">
<a href="adminpanel.html" class="nav-link"> <a href="adminpanel.html" class="nav-link">

View File

@ -72,15 +72,6 @@
<ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu"
data-accordion="false"> data-accordion="false">
<li class="nav-item">
<a href="ShedulePickUp.html" class="nav-link">
<i class="nav-icon fas fa-calendar-alt"></i>
<p>
Shedule Pick-up
</p>
</a>
</li>
<li class="nav-item"> <li class="nav-item">
<a href="dashboard.html" class="nav-link"> <a href="dashboard.html" class="nav-link">
<i class="nav-icon fas fa-columns"></i> <i class="nav-icon fas fa-columns"></i>
@ -98,14 +89,7 @@
</a> </a>
</li> </li>
<li class="nav-item">
<a href="#todo" class="nav-link">
<i class="nav-icon fas fa-plus-circle"></i>
<p>
New Entry
</p>
</a>
</li>
<li id="adminpanel" class="nav-item hideit"> <li id="adminpanel" class="nav-item hideit">
<a href="adminpanel.html" class="nav-link"> <a href="adminpanel.html" class="nav-link">

View File

@ -71,15 +71,6 @@
<ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu"
data-accordion="false"> data-accordion="false">
<li class="nav-item">
<a href="ShedulePickUp.html" class="nav-link">
<i class="nav-icon fas fa-calendar-alt"></i>
<p>
Shedule Pick-up
</p>
</a>
</li>
<li class="nav-item"> <li class="nav-item">
<a href="dashboard.html" class="nav-link"> <a href="dashboard.html" class="nav-link">
<i class="nav-icon fas fa-columns"></i> <i class="nav-icon fas fa-columns"></i>
@ -90,9 +81,6 @@
</li> </li>
<li id="devicepanel" class="nav-item"> <li id="devicepanel" class="nav-item">
<a href="device.html" class="nav-link"> <a href="device.html" class="nav-link">
<i class="nav-icon fas fa-desktop"></i> <i class="nav-icon fas fa-desktop"></i>
@ -102,14 +90,7 @@
</a> </a>
</li> </li>
<li class="nav-item">
<a href="#todo" class="nav-link">
<i class="nav-icon fas fa-plus-circle"></i>
<p>
New Entry
</p>
</a>
</li>
<li id="adminpanel" class="nav-item hideit"> <li id="adminpanel" class="nav-item hideit">
<a href="adminpanel.html" class="nav-link"> <a href="adminpanel.html" class="nav-link">
@ -175,9 +156,9 @@
<!-- small box --> <!-- small box -->
<div class="small-box bg-info"> <div class="small-box bg-info">
<div class="inner"> <div class="inner">
<h3>TODO</h3> <h3 id="devicenr-label">-1</h3>
<p>Todo</p> <p>Devices</p>
</div> </div>
<div class="icon"> <div class="icon">
<i class="ion ion-bag"></i> <i class="ion ion-bag"></i>
@ -190,9 +171,9 @@
<!-- small box --> <!-- small box -->
<div class="small-box bg-success"> <div class="small-box bg-success">
<div class="inner"> <div class="inner">
<h3>TODO</h3> <h3 id="unconfigured-devices-label">-1</h3>
<p>Devices</p> <p>Not Configured Devices</p>
</div> </div>
<div class="icon"> <div class="icon">
<i class="ion ion-stats-bars"></i> <i class="ion ion-stats-bars"></i>
@ -234,7 +215,7 @@
<th><i class="fas fa-id-card"></i> Device ID</th> <th><i class="fas fa-id-card"></i> Device ID</th>
<th><i class="fas fa-signature"></i> Devicename</th> <th><i class="fas fa-signature"></i> Devicename</th>
<th><i class="fas fa-search-location"></i> Devicelocation</th> <th><i class="fas fa-search-location"></i> Devicelocation</th>
<th> <i class="fas fa-recycle"></i> WasteType</th> <th><i class="fas fa-recycle"></i> WasteType</th>
<th><i class="fas fa-edit"></i> Action</th> <th><i class="fas fa-edit"></i> Action</th>
</tr> </tr>
</tfoot> </tfoot>

View File

@ -1,11 +1,12 @@
$(document).ready(function () { $(function () {
new Device(); new Device();
}); });
class Device { class Device {
constructor() { constructor() {
this.reloadDevices() this.reloadDevices();
this.loadHeader();
} }
devicetable = null; devicetable = null;
@ -50,9 +51,9 @@ class Device {
} }
} }
_this.addDeleteButton(); _this._addDeleteButton();
_this.addAddButton(); _this._addAddButton();
_this.addConfigDialog(); _this._addConfigDialog();
_this.devicetable = $('#table-devices').DataTable(); _this.devicetable = $('#table-devices').DataTable();
}, 'json'); }, 'json');
} }
@ -60,7 +61,8 @@ class Device {
/** /**
* add click listener to add button to add new city entries to current device * add click listener to add button to add new city entries to current device
*/ */
addAddButton() { _addAddButton() {
var _this = this;
$('.addbtn').click(function (event) { $('.addbtn').click(function (event) {
var id = event.target.getAttribute("dataid"); var id = event.target.getAttribute("dataid");
var cityname; var cityname;
@ -83,8 +85,6 @@ class Device {
} }
]).then((result) => { ]).then((result) => {
if (result.value) { if (result.value) {
console.log(result.value);
const answers = JSON.stringify(result.value);
cityname = result.value[0]; cityname = result.value[0];
console.log("cityname=" + cityname); console.log("cityname=" + cityname);
@ -103,7 +103,6 @@ class Device {
} }
]).then((result) => { ]).then((result) => {
if (result.value) { if (result.value) {
console.log(result.value);
zone = result.value[0]; zone = result.value[0];
$.post('/senddata/Devicedata', 'action=gettypes&cityname=' + cityname + '&zonename=' + zone, function (data) { $.post('/senddata/Devicedata', 'action=gettypes&cityname=' + cityname + '&zonename=' + zone, function (data) {
Swal.mixin({ Swal.mixin({
@ -120,11 +119,8 @@ class Device {
} }
]).then((result) => { ]).then((result) => {
if (result.value) { if (result.value) {
console.log(result.value);
wastetype = result.value[0]; wastetype = result.value[0];
//todo add to db
$.post('/senddata/Devicedata', 'action=addtodb&deviceid=' + id + '&cityname=' + cityname + '&zonename=' + zone + '&wastetype=' + wastetype, function (data) { $.post('/senddata/Devicedata', 'action=addtodb&deviceid=' + id + '&cityname=' + cityname + '&zonename=' + zone + '&wastetype=' + wastetype, function (data) {
if (data.success) { if (data.success) {
Swal.fire({ Swal.fire({
@ -133,8 +129,7 @@ class Device {
html: 'This alert closes added.', html: 'This alert closes added.',
timer: 1000, timer: 1000,
}).then((result) => { }).then((result) => {
console.log('Popup closed. '); _this.reloadDevices();
reloadDevices();
}); });
} }
}); });
@ -153,7 +148,7 @@ class Device {
/** /**
* add click listener to delete button to delete this device entry * add click listener to delete button to delete this device entry
*/ */
addDeleteButton() { _addDeleteButton() {
var _this = this; var _this = this;
$(".delbtn").click(function (event) { $(".delbtn").click(function (event) {
var id = event.target.getAttribute("dataid"); var id = event.target.getAttribute("dataid");
@ -190,7 +185,8 @@ class Device {
/** /**
* add click listener to unconfigured device to show configure dialog * add click listener to unconfigured device to show configure dialog
*/ */
addConfigDialog() { _addConfigDialog() {
var _this = this;
$(".configuredevicebutton").click(function (event) { $(".configuredevicebutton").click(function (event) {
var id = event.target.getAttribute("deviceid"); var id = event.target.getAttribute("deviceid");
var cityname; var cityname;
@ -271,7 +267,7 @@ class Device {
timer: 1000, timer: 1000,
}).then((result) => { }).then((result) => {
console.log('Popup closed. '); console.log('Popup closed. ');
reloadDevices(); _this.reloadDevices();
}); });
} }
}); });
@ -284,10 +280,18 @@ class Device {
} }
}); });
}); });
});
}
/**
console.log("click..." + id); * Load header tiles
*/
loadHeader(){
$.post('/senddata/Devicedata', 'action=getheader', function (data) {
if (data.success) {
$("#devicenr-label").html(data.devicenumber);
$("#unconfigured-devices-label").html(data.unconfigureddevices);
}
}); });
} }
} }

View File

@ -88,14 +88,7 @@
</a> </a>
</li> </li>
<li class="nav-item">
<a href="#todo" class="nav-link">
<i class="nav-icon fas fa-plus-circle"></i>
<p>
New Entry
</p>
</a>
</li>
</ul> </ul>
</nav> </nav>
<!-- /.sidebar-menu --> <!-- /.sidebar-menu -->