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\"}")
}
"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" -> {
var cityid = -1
try {
@ -162,6 +154,21 @@ class DeviceRequest : PostRequest() {
}
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()
}

View File

@ -70,15 +70,6 @@
<ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu"
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">
<a href="dashboard.html" class="nav-link">
<i class="nav-icon fas fa-columns"></i>
@ -98,14 +89,7 @@
</a>
</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">
<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"
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">
<a href="dashboard.html" class="nav-link">
<i class="nav-icon fas fa-columns"></i>
@ -98,14 +89,7 @@
</a>
</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">
<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"
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">
<a href="dashboard.html" class="nav-link">
<i class="nav-icon fas fa-columns"></i>
@ -90,9 +81,6 @@
</li>
<li id="devicepanel" class="nav-item">
<a href="device.html" class="nav-link">
<i class="nav-icon fas fa-desktop"></i>
@ -102,14 +90,7 @@
</a>
</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">
<a href="adminpanel.html" class="nav-link">
@ -175,9 +156,9 @@
<!-- small box -->
<div class="small-box bg-info">
<div class="inner">
<h3>TODO</h3>
<h3 id="devicenr-label">-1</h3>
<p>Todo</p>
<p>Devices</p>
</div>
<div class="icon">
<i class="ion ion-bag"></i>
@ -190,9 +171,9 @@
<!-- small box -->
<div class="small-box bg-success">
<div class="inner">
<h3>TODO</h3>
<h3 id="unconfigured-devices-label">-1</h3>
<p>Devices</p>
<p>Not Configured Devices</p>
</div>
<div class="icon">
<i class="ion ion-stats-bars"></i>

View File

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