define class for dashboard
This commit is contained in:
parent
9cf713ab4a
commit
98b3c69c15
@ -1,30 +1,35 @@
|
|||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
/* Constants */
|
new Dashboard();
|
||||||
var citytable;
|
});
|
||||||
var datetable;
|
|
||||||
|
|
||||||
|
class Dashboard {
|
||||||
|
constructor() {
|
||||||
//load header data
|
//load header data
|
||||||
loadHeaderData();
|
this.loadHeaderData();
|
||||||
|
|
||||||
//load footer
|
//load footer
|
||||||
loadVersionFooter();
|
this.loadVersionFooter();
|
||||||
|
|
||||||
//reload city table
|
//reload city table
|
||||||
reloadtable();
|
this.reloadtable();
|
||||||
|
|
||||||
//reload Date table
|
//reload Date table
|
||||||
reloadDateTable();
|
this.reloadDateTable();
|
||||||
|
|
||||||
//init time picker
|
//init time picker
|
||||||
initDatePicker();
|
this.initDatePicker();
|
||||||
|
|
||||||
//add click listeners to all buttons
|
//add click listeners to all buttons
|
||||||
addClickListeners();
|
this.addClickListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Constants */
|
||||||
|
citytable;
|
||||||
|
datetable;
|
||||||
|
|
||||||
/* Btn Action Listeners */
|
/* Btn Action Listeners */
|
||||||
|
|
||||||
function addClickListeners() {
|
addClickListeners() {
|
||||||
//btn listeners
|
//btn listeners
|
||||||
$('#logoutbtn').click(function () {
|
$('#logoutbtn').click(function () {
|
||||||
$.post('/senddata/checkloginstate', 'action=logout', function (data) {
|
$.post('/senddata/checkloginstate', 'action=logout', function (data) {
|
||||||
@ -195,8 +200,7 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
|
|
||||||
/* Functions */
|
/* Functions */
|
||||||
|
initDatePicker() {
|
||||||
function initDatePicker() {
|
|
||||||
//Date picker pop up actions...
|
//Date picker pop up actions...
|
||||||
var date_input = $('input[name="date"]'); //our date input has the name "date"
|
var date_input = $('input[name="date"]'); //our date input has the name "date"
|
||||||
var container = $('.bootstrap-iso form').length > 0 ? $('.bootstrap-iso form').parent() : "body";
|
var container = $('.bootstrap-iso form').length > 0 ? $('.bootstrap-iso form').parent() : "body";
|
||||||
@ -209,7 +213,7 @@ $(document).ready(function () {
|
|||||||
date_input.datepicker(options);
|
date_input.datepicker(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadHeaderData() {
|
loadHeaderData() {
|
||||||
$.post('/senddata/wastedata', 'action=getStartHeaderData', function (data) {
|
$.post('/senddata/wastedata', 'action=getStartHeaderData', function (data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
$("#total-connection-labels").html(data.collectionnumber);
|
$("#total-connection-labels").html(data.collectionnumber);
|
||||||
@ -222,16 +226,16 @@ $(document).ready(function () {
|
|||||||
}, 'json');
|
}, 'json');
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadVersionFooter() {
|
loadVersionFooter() {
|
||||||
$.post('/senddata/wastedata', 'action=getversionandbuildtime', function (data) {
|
$.post('/senddata/wastedata', 'action=getversionandbuildtime', function (data) {
|
||||||
$("#version-footer-label").html("<b>Version</b> " + data.version + " <b>Build</b> " + data.buildtime);
|
$("#version-footer-label").html("<b>Version</b> " + data.version + " <b>Build</b> " + data.buildtime);
|
||||||
}, 'json');
|
}, 'json');
|
||||||
}
|
}
|
||||||
|
|
||||||
function reloadtable() {
|
reloadtable() {
|
||||||
$.post('/senddata/wastedata', 'action=getAllCities', function (data) {
|
$.post('/senddata/wastedata', 'action=getAllCities', function (data) {
|
||||||
if (citytable != null) {
|
if (this.citytable != null) {
|
||||||
citytable.destroy(); //delete table if already created
|
this.citytable.destroy(); //delete table if already created
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(data);
|
console.log(data);
|
||||||
@ -283,7 +287,7 @@ $(document).ready(function () {
|
|||||||
}, "json");
|
}, "json");
|
||||||
});
|
});
|
||||||
|
|
||||||
citytable = $("#example2").DataTable();
|
this.citytable = $("#example2").DataTable();
|
||||||
} else if (data.query == "nodbconn") {
|
} else if (data.query == "nodbconn") {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
type: "error",
|
type: "error",
|
||||||
@ -300,10 +304,10 @@ $(document).ready(function () {
|
|||||||
}, 'json');
|
}, 'json');
|
||||||
}
|
}
|
||||||
|
|
||||||
function reloadDateTable() {
|
reloadDateTable() {
|
||||||
$.post('/senddata/wastedata', 'action=getAllDates', function (data) {
|
$.post('/senddata/wastedata', 'action=getAllDates', function (data) {
|
||||||
if (datetable != null) {
|
if (this.datetable != null) {
|
||||||
datetable.destroy(); //delete table if already created
|
this.datetable.destroy(); //delete table if already created
|
||||||
}
|
}
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
|
||||||
@ -352,9 +356,11 @@ $(document).ready(function () {
|
|||||||
}, "json");
|
}, "json");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
datetable = $("#table-pickupdates").DataTable({
|
this.datetable = $("#table-pickupdates").DataTable({
|
||||||
"order": [[3, "asc"]]
|
"order": [[3, "asc"]]
|
||||||
});
|
});
|
||||||
}, "json");
|
}, "json");
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user