new admin panel
new date creation in dashboard.html
This commit is contained in:
parent
87bf1d7291
commit
59d18679ea
@ -2,6 +2,8 @@ package com.wasteinformationserver.website;
|
|||||||
|
|
||||||
import com.sun.net.httpserver.HttpServer;
|
import com.sun.net.httpserver.HttpServer;
|
||||||
import com.wasteinformationserver.basicutils.Log;
|
import com.wasteinformationserver.basicutils.Log;
|
||||||
|
import com.wasteinformationserver.website.datarequests.AdminRequests;
|
||||||
|
import com.wasteinformationserver.website.datarequests.NewDateRequest;
|
||||||
import com.wasteinformationserver.website.datarequests.login.CheckLoginState;
|
import com.wasteinformationserver.website.datarequests.login.CheckLoginState;
|
||||||
import com.wasteinformationserver.website.datarequests.DataRequest;
|
import com.wasteinformationserver.website.datarequests.DataRequest;
|
||||||
import com.wasteinformationserver.website.datarequests.login.LoginRequest;
|
import com.wasteinformationserver.website.datarequests.login.LoginRequest;
|
||||||
@ -27,6 +29,8 @@ public class Webserver {
|
|||||||
server.createContext("/senddata/registerpost",new RegisterRequest());
|
server.createContext("/senddata/registerpost",new RegisterRequest());
|
||||||
server.createContext("/senddata/checkloginstate",new CheckLoginState());
|
server.createContext("/senddata/checkloginstate",new CheckLoginState());
|
||||||
server.createContext("/senddata/wastedata",new DataRequest());
|
server.createContext("/senddata/wastedata",new DataRequest());
|
||||||
|
server.createContext("/senddata/admindata", new AdminRequests());
|
||||||
|
server.createContext("/senddata/newdate", new NewDateRequest());
|
||||||
|
|
||||||
server.setExecutor(null); // creates a default executor
|
server.setExecutor(null); // creates a default executor
|
||||||
server.start();
|
server.start();
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
package com.wasteinformationserver.website.datarequests;
|
||||||
|
|
||||||
|
import com.wasteinformationserver.basicutils.Log;
|
||||||
|
import com.wasteinformationserver.db.JDCB;
|
||||||
|
import com.wasteinformationserver.website.basicrequest.PostRequest;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class AdminRequests extends PostRequest {
|
||||||
|
@Override
|
||||||
|
public String request(HashMap<String, String> params) {
|
||||||
|
String result = "";
|
||||||
|
switch (params.get("action")) {
|
||||||
|
case "shutdownserver":
|
||||||
|
System.exit(0);
|
||||||
|
break;
|
||||||
|
case "restartserver":
|
||||||
|
final String javaBin = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
|
||||||
|
File currentJar = null;
|
||||||
|
try {
|
||||||
|
currentJar = new File(AdminRequests.class.getProtectionDomain().getCodeSource().getLocation().toURI());
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* is it a jar file? */
|
||||||
|
if(!currentJar.getName().endsWith(".jar"))
|
||||||
|
System.out.println("not jar");
|
||||||
|
|
||||||
|
/* Build command: java -jar application.jar */
|
||||||
|
final ArrayList<String> command = new ArrayList<String>();
|
||||||
|
command.add(javaBin);
|
||||||
|
command.add("-jar");
|
||||||
|
command.add(currentJar.getPath());
|
||||||
|
|
||||||
|
final ProcessBuilder builder = new ProcessBuilder(command);
|
||||||
|
try {
|
||||||
|
builder.start();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
System.exit(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
@ -45,24 +45,24 @@ public class DataRequest extends PostRequest {
|
|||||||
int status = jdcb.executeUpdate("INSERT INTO `cities`(`userid`, `name`, `wastetype`, `zone`) VALUES ('0','" + params.get("cityname") + "','" + params.get("wastetype") + "','" + params.get("wastezone") + "');");
|
int status = jdcb.executeUpdate("INSERT INTO `cities`(`userid`, `name`, `wastetype`, `zone`) VALUES ('0','" + params.get("cityname") + "','" + params.get("wastetype") + "','" + params.get("wastezone") + "');");
|
||||||
System.out.println(status);
|
System.out.println(status);
|
||||||
if (status == 1) {
|
if (status == 1) {
|
||||||
sb.append("\"status\" : \"inserted\"}");
|
sb.append("\"status\" : \"inserted\"");
|
||||||
} else {
|
} else {
|
||||||
sb.append("\"status\" : \"inserterror\"");
|
sb.append("\"status\" : \"inserterror\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (size > 1) {
|
} else if (size > 1) {
|
||||||
Log.warning("more than one entry in db!!!");
|
Log.warning("more than one entry in db!!!");
|
||||||
result = "\"status\" : \"exists\"";
|
sb.append("\"status\" : \"exists\"");
|
||||||
} else {
|
} else {
|
||||||
//already exists
|
//already exists
|
||||||
System.out.println("already exists");
|
System.out.println("already exists");
|
||||||
result = "\"status\" : \"exists\"";
|
sb.append("\"status\" : \"exists\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append(",\"query\":\"ok\"");
|
sb.append(",\"query\":\"ok\"");
|
||||||
sb.append("}");
|
sb.append("}");
|
||||||
|
|
||||||
Log.debug(result);
|
result = sb.toString();
|
||||||
break;
|
break;
|
||||||
case "getAllCities":
|
case "getAllCities":
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
@ -85,17 +85,34 @@ public class DataRequest extends PostRequest {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
builder.append("]}");
|
builder.append("]");
|
||||||
|
builder.append(",\"query\":\"ok\"");
|
||||||
|
builder.append("}");
|
||||||
result = builder.toString();
|
result = builder.toString();
|
||||||
Log.debug(result);
|
Log.debug(result);
|
||||||
break;
|
break;
|
||||||
case "deletecity":
|
case "deletecity":
|
||||||
//DELETE FROM `cities` WHERE `id`=0
|
//DELETE FROM `cities` WHERE `id`=0
|
||||||
|
|
||||||
|
StringBuilder sbb = new StringBuilder(); // TODO: 06.12.19 better naming and sb for all
|
||||||
|
|
||||||
Log.debug(params.get("id"));
|
Log.debug(params.get("id"));
|
||||||
int status= jdcb.executeUpdate("DELETE FROM `cities` WHERE `id`='" + params.get("id")+"'");
|
int status= jdcb.executeUpdate("DELETE FROM `cities` WHERE `id`='" + params.get("id")+"'");
|
||||||
Log.debug(status);
|
Log.debug(status);
|
||||||
|
|
||||||
|
sbb.append("{");
|
||||||
|
|
||||||
|
if (status == 1){
|
||||||
|
//success
|
||||||
|
sbb.append("\"status\" : \"success\"");
|
||||||
|
}else {
|
||||||
|
sbb.append("\"status\" : \"error\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
sbb.append(",\"query\":\"ok\"");
|
||||||
|
sbb.append("}");
|
||||||
|
result = sbb.toString();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -0,0 +1,76 @@
|
|||||||
|
package com.wasteinformationserver.website.datarequests;
|
||||||
|
|
||||||
|
import com.wasteinformationserver.basicutils.Log;
|
||||||
|
import com.wasteinformationserver.db.JDCB;
|
||||||
|
import com.wasteinformationserver.website.basicrequest.PostRequest;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class NewDateRequest extends PostRequest {
|
||||||
|
@Override
|
||||||
|
public String request(HashMap<String, String> params) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
JDCB jdcb;
|
||||||
|
try {
|
||||||
|
jdcb = JDCB.getInstance();
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.error("no connection to db");
|
||||||
|
return "{\"query\" : \"nodbconn\"}";
|
||||||
|
}
|
||||||
|
switch (params.get("action")) {
|
||||||
|
case "getCitynames":
|
||||||
|
ResultSet sett = jdcb.executeQuery("select * from cities");
|
||||||
|
Log.debug(sett.toString());
|
||||||
|
sb.append("{\"data\":[");
|
||||||
|
try {
|
||||||
|
String prev = "";
|
||||||
|
while (sett.next()) {
|
||||||
|
if (prev.equals(sett.getString("name"))){
|
||||||
|
|
||||||
|
}else {
|
||||||
|
sb.append("{\"cityname\":\"" + sett.getString("name") + "\"}");
|
||||||
|
if (!sett.isLast()) {
|
||||||
|
sb.append(",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
prev = sett.getString("name");
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
sb.append("]");
|
||||||
|
sb.append(",\"query\":\"ok\"");
|
||||||
|
sb.append("}");
|
||||||
|
break;
|
||||||
|
case "getzones":
|
||||||
|
ResultSet set = jdcb.executeQuery("select * from cities WHERE `name`='"+params.get("cityname")+"' ORDER BY zone ASC");
|
||||||
|
Log.debug(set.toString());
|
||||||
|
sb.append("{\"data\":[");
|
||||||
|
try {
|
||||||
|
int prev = 42;
|
||||||
|
while (set.next()) {
|
||||||
|
if (prev == set.getInt("zone")){
|
||||||
|
|
||||||
|
}else {
|
||||||
|
sb.append("{\"zone\":\"" + set.getInt("zone") + "\"}");
|
||||||
|
if (!set.isLast()) {
|
||||||
|
sb.append(",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
prev = set.getInt("zone");
|
||||||
|
System.out.println(prev);
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
sb.append("]");
|
||||||
|
sb.append(",\"query\":\"ok\"");
|
||||||
|
sb.append("}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -11,7 +11,7 @@ public class CheckLoginState extends PostRequest {
|
|||||||
Log.message("checking login state");
|
Log.message("checking login state");
|
||||||
if ((params.get("action")).equals("getloginstate")){
|
if ((params.get("action")).equals("getloginstate")){
|
||||||
if (LoginState.getObject().isLoggedIn()){
|
if (LoginState.getObject().isLoggedIn()){
|
||||||
return "{\"loggedin\":true, \"username\":\""+LoginState.getObject().getUsername()+"\"}";
|
return "{\"loggedin\":true, \"username\":\""+LoginState.getObject().getUsername()+"\", \"permission\":\""+LoginState.getObject().getPermission()+"\"}";
|
||||||
}else {
|
}else {
|
||||||
return "{\"loggedin\":false}";
|
return "{\"loggedin\":false}";
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public class LoginRequest extends PostRequest {
|
|||||||
if (HttpTools.StringToMD5(password).equals(s.getString("password"))) {
|
if (HttpTools.StringToMD5(password).equals(s.getString("password"))) {
|
||||||
Log.debug("login success");
|
Log.debug("login success");
|
||||||
LoginState.getObject().logIn();
|
LoginState.getObject().logIn();
|
||||||
LoginState.getObject().setAccountData(username,"","","");
|
LoginState.getObject().setAccountData(username,"","","", s.getInt("permission")); // TODO: 06.12.19
|
||||||
response = "{\"accept\": true}";
|
response = "{\"accept\": true}";
|
||||||
} else {
|
} else {
|
||||||
Log.debug("wrong password");
|
Log.debug("wrong password");
|
||||||
|
@ -13,8 +13,9 @@ public class LoginState {
|
|||||||
private String firstname;
|
private String firstname;
|
||||||
private String lastname;
|
private String lastname;
|
||||||
private String email;
|
private String email;
|
||||||
|
private int permission;
|
||||||
|
|
||||||
boolean loggedin = true; // TODO: 05.12.19 set back!!
|
boolean loggedin = false;
|
||||||
|
|
||||||
public void logIn(){
|
public void logIn(){
|
||||||
loggedin=true;
|
loggedin=true;
|
||||||
@ -24,11 +25,12 @@ public class LoginState {
|
|||||||
loggedin=false;
|
loggedin=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAccountData(String username, String firstname, String lastname, String email){
|
public void setAccountData(String username, String firstname, String lastname, String email, int permission){
|
||||||
this.username=username;
|
this.username=username;
|
||||||
this.firstname=firstname;
|
this.firstname=firstname;
|
||||||
this.lastname=lastname;
|
this.lastname=lastname;
|
||||||
this.email=email;
|
this.email=email;
|
||||||
|
this.permission = permission;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLoggedIn(){
|
public boolean isLoggedIn(){
|
||||||
@ -50,4 +52,8 @@ public class LoginState {
|
|||||||
public String getEmail() {
|
public String getEmail() {
|
||||||
return email;
|
return email;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPermission() {
|
||||||
|
return permission;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
275
src/resources/wwwroot/adminpanel.html
Normal file
275
src/resources/wwwroot/adminpanel.html
Normal file
@ -0,0 +1,275 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<title>WasteInformation Server</title>
|
||||||
|
<!-- Tell the browser to be responsive to screen width -->
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<!-- Font Awesome -->
|
||||||
|
<link rel="stylesheet" href="lib/AdminLTE/plugins/fontawesome-free/css/all.min.css">
|
||||||
|
<!-- Ionicons -->
|
||||||
|
<link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
|
||||||
|
<!-- DataTables -->
|
||||||
|
<link rel="stylesheet" href="lib/AdminLTE/plugins/datatables-bs4/css/dataTables.bootstrap4.css">
|
||||||
|
<!-- Tempusdominus Bbootstrap 4 -->
|
||||||
|
<link rel="stylesheet" href="lib/AdminLTE/plugins/tempusdominus-bootstrap-4/css/tempusdominus-bootstrap-4.min.css">
|
||||||
|
<!-- iCheck -->
|
||||||
|
<link rel="stylesheet" href="lib/AdminLTE/plugins/icheck-bootstrap/icheck-bootstrap.min.css">
|
||||||
|
<!-- JQVMap -->
|
||||||
|
<link rel="stylesheet" href="lib/AdminLTE/plugins/jqvmap/jqvmap.min.css">
|
||||||
|
<!-- Theme style -->
|
||||||
|
<link rel="stylesheet" href="lib/AdminLTE/dist/css/adminlte.min.css">
|
||||||
|
<!-- overlayScrollbars -->
|
||||||
|
<link rel="stylesheet" href="lib/AdminLTE/plugins/overlayScrollbars/css/OverlayScrollbars.min.css">
|
||||||
|
<!-- Daterange picker -->
|
||||||
|
<link rel="stylesheet" href="lib/AdminLTE/plugins/daterangepicker/daterangepicker.css">
|
||||||
|
<!-- summernote -->
|
||||||
|
<link rel="stylesheet" href="lib/AdminLTE/plugins/summernote/summernote-bs4.css">
|
||||||
|
<!-- Google Font: Source Sans Pro -->
|
||||||
|
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
|
||||||
|
|
||||||
|
<!-- Bootstrap Date-Picker Plugin -->
|
||||||
|
|
||||||
|
<link rel="stylesheet"
|
||||||
|
href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.1/css/bootstrap-datepicker3.css"/>
|
||||||
|
|
||||||
|
<!-- <link rel="stylesheet" type="text/css" href="css/user.css">-->
|
||||||
|
<link rel="stylesheet" type="text/css" href="css/general.css">
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body class="hold-transition sidebar-mini layout-fixed">
|
||||||
|
<div class="wrapper">
|
||||||
|
<!-- Main Sidebar Container -->
|
||||||
|
<aside class="main-sidebar sidebar-dark-primary elevation-4">
|
||||||
|
<!-- Brand Logo -->
|
||||||
|
<a href="dashboard.html" class="brand-link">
|
||||||
|
<img src="lib/AdminLTE/dist/img/AdminLTELogo.png" alt="AdminLTE Logo"
|
||||||
|
class="brand-image img-circle elevation-3"
|
||||||
|
style="opacity: .8">
|
||||||
|
<span class="brand-text font-weight-light">Waste Control</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<!-- Sidebar -->
|
||||||
|
<div class="sidebar">
|
||||||
|
<!-- Sidebar user panel (optional) -->
|
||||||
|
<div class="user-panel mt-3 pb-3 mb-3 d-flex">
|
||||||
|
<div class="image">
|
||||||
|
<!-- <img src="lib/AdminLTE/dist/img/user2-160x160.jpg" class="img-circle elevation-2" alt="User Image"> -->
|
||||||
|
<i class="nav-icon fas fa-user img-circle elevation-2" style="color:white"></i>
|
||||||
|
</div>
|
||||||
|
<!-- <i class="nav-icon fas fa-tachometer-alt"></i> -->
|
||||||
|
<div class="info">
|
||||||
|
<a href="user.html" class="d-block" id="userlabel">Username to set!</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Sidebar Menu -->
|
||||||
|
<nav class="mt-2">
|
||||||
|
<ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu"
|
||||||
|
data-accordion="false">
|
||||||
|
|
||||||
|
<li class="nav-item">
|
||||||
|
<a href="#todo" class="nav-link">
|
||||||
|
<i class="nav-icon fas fa-cog"></i>
|
||||||
|
<p>
|
||||||
|
Settings
|
||||||
|
</p>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li class="nav-item">
|
||||||
|
<a href="index.html" class="nav-link" id="logoutbtn">
|
||||||
|
<i class="nav-icon fas fa-sign-out-alt"></i>
|
||||||
|
<p>
|
||||||
|
Logout
|
||||||
|
</p>
|
||||||
|
</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">
|
||||||
|
<i class="nav-icon fas fa-plus-circle"></i>
|
||||||
|
<p>
|
||||||
|
Admin panel
|
||||||
|
</p>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
<!-- /.sidebar-menu -->
|
||||||
|
</div>
|
||||||
|
<!-- /.sidebar -->
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
<!-- Content Wrapper. Contains page content -->
|
||||||
|
<div class="content-wrapper">
|
||||||
|
<!-- Content Header (Page header) -->
|
||||||
|
<div class="content-header">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row mb-2">
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<h1 class="m-0 text-dark">Dashboard</h1>
|
||||||
|
</div><!-- /.col -->
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<ol class="breadcrumb float-sm-right">
|
||||||
|
<li class="breadcrumb-item"><a href="dashboard.html">Home</a></li>
|
||||||
|
<li class="breadcrumb-item active">Users</li>
|
||||||
|
</ol>
|
||||||
|
</div><!-- /.col -->
|
||||||
|
</div><!-- /.row -->
|
||||||
|
</div><!-- /.container-fluid -->
|
||||||
|
</div>
|
||||||
|
<!-- /.content-header -->
|
||||||
|
|
||||||
|
<!-- Main content -->
|
||||||
|
<section class="content">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<!-- Small boxes (Stat box) -->
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-3 col-6">
|
||||||
|
<!-- small box -->
|
||||||
|
<div class="small-box bg-info">
|
||||||
|
<div class="inner">
|
||||||
|
<h3>150</h3>
|
||||||
|
|
||||||
|
<p>Logins</p>
|
||||||
|
</div>
|
||||||
|
<div class="icon">
|
||||||
|
<i class="ion ion-bag"></i>
|
||||||
|
</div>
|
||||||
|
<a href="#" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- ./col -->
|
||||||
|
<div class="col-lg-3 col-6">
|
||||||
|
<!-- small box -->
|
||||||
|
<div class="small-box bg-success">
|
||||||
|
<div class="inner">
|
||||||
|
<h3>28.03.2019 18:53:05<sup style="font-size: 20px">.300</sup></h3>
|
||||||
|
|
||||||
|
<p>Zuletzt eingeloggt</p>
|
||||||
|
</div>
|
||||||
|
<div class="icon">
|
||||||
|
<i class="ion ion-stats-bars"></i>
|
||||||
|
</div>
|
||||||
|
<a href="#" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- ./col -->
|
||||||
|
</div>
|
||||||
|
<!-- /.row -->
|
||||||
|
<!-- Main row -->
|
||||||
|
<div class="row">
|
||||||
|
<!-- Left col -->
|
||||||
|
<section class="col-lg-7 connectedSortable">
|
||||||
|
<!-- Custom tabs (Charts with tabs)-->
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h3 class="card-title">
|
||||||
|
<i class="fas fa-chart-pie mr-1"></i>
|
||||||
|
Control Panel
|
||||||
|
</h3>
|
||||||
|
</div><!-- /.card-header -->
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="btn-group">
|
||||||
|
<button id="btn-shutdown" type="button" class="btn btn-danger">Shutdown Server</button>
|
||||||
|
<button id="btn-restart" type="button" class="btn btn-warning">Restart Server</button>
|
||||||
|
<button type="button" class="btn btn-primary">smth else</button>
|
||||||
|
</div>
|
||||||
|
</div><!-- /.card-body -->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</section>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- /.Left col -->
|
||||||
|
<!-- right col (We are only adding the ID to make the widgets sortable)-->
|
||||||
|
<section class="col-lg-5 connectedSortable">
|
||||||
|
|
||||||
|
<!-- /.card -->
|
||||||
|
</section>
|
||||||
|
<!-- right col -->
|
||||||
|
</div>
|
||||||
|
<!-- /.row (main row) -->
|
||||||
|
</div><!-- /.container-fluid -->
|
||||||
|
</section>
|
||||||
|
<!-- /.content -->
|
||||||
|
</div>
|
||||||
|
<!-- /.content-wrapper -->
|
||||||
|
<footer class="main-footer">
|
||||||
|
<strong>By Gregor Dutzler & Lukas Heiligenbrunner & Emil Meindl</strong>
|
||||||
|
<div class="float-right d-none d-sm-inline-block">
|
||||||
|
<b>Version</b> 3.0.0
|
||||||
|
<b>Build</b> 2019-8-8 9:30
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<!-- Control Sidebar -->
|
||||||
|
<aside class="control-sidebar control-sidebar-dark">
|
||||||
|
<!-- Control sidebar content goes here -->
|
||||||
|
</aside>
|
||||||
|
<!-- /.control-sidebar -->
|
||||||
|
</div>
|
||||||
|
<!-- ./wrapper -->
|
||||||
|
|
||||||
|
<!-- jQuery -->
|
||||||
|
<script src="lib/AdminLTE/plugins/jquery/jquery.min.js"></script>
|
||||||
|
<!-- jQuery UI 1.11.4 -->
|
||||||
|
<script src="lib/AdminLTE/plugins/jquery-ui/jquery-ui.min.js"></script>
|
||||||
|
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
|
||||||
|
<script>
|
||||||
|
$.widget.bridge('uibutton', $.ui.button)
|
||||||
|
</script>
|
||||||
|
<!-- Bootstrap 4 -->
|
||||||
|
<script src="lib/AdminLTE/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<!-- ChartJS -->
|
||||||
|
<script src="lib/AdminLTE/plugins/chart.js/Chart.min.js"></script>
|
||||||
|
<!-- Sparkline -->
|
||||||
|
<script src="lib/AdminLTE/plugins/sparklines/sparkline.js"></script>
|
||||||
|
<!-- JQVMap -->
|
||||||
|
<script src="lib/AdminLTE/plugins/jqvmap/jquery.vmap.min.js"></script>
|
||||||
|
<script src="lib/AdminLTE/plugins/jqvmap/maps/jquery.vmap.usa.js"></script>
|
||||||
|
<!-- jQuery Knob Chart -->
|
||||||
|
<script src="lib/AdminLTE/plugins/jquery-knob/jquery.knob.min.js"></script>
|
||||||
|
<!-- daterangepicker -->
|
||||||
|
<script src="lib/AdminLTE/plugins/moment/moment.min.js"></script>
|
||||||
|
<script src="lib/AdminLTE/plugins/daterangepicker/daterangepicker.js"></script>
|
||||||
|
<!-- Tempusdominus Bootstrap 4 -->
|
||||||
|
<script src="lib/AdminLTE/plugins/tempusdominus-bootstrap-4/js/tempusdominus-bootstrap-4.min.js"></script>
|
||||||
|
<!-- Summernote -->
|
||||||
|
<script src="lib/AdminLTE/plugins/summernote/summernote-bs4.min.js"></script>
|
||||||
|
<!-- overlayScrollbars -->
|
||||||
|
<script src="lib/AdminLTE/plugins/overlayScrollbars/js/jquery.overlayScrollbars.min.js"></script>
|
||||||
|
<!-- AdminLTE App -->
|
||||||
|
<script src="lib/AdminLTE/dist/js/adminlte.js"></script>
|
||||||
|
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
|
||||||
|
<script src="lib/AdminLTE/dist/js/pages/dashboard.js"></script>
|
||||||
|
<!-- AdminLTE for demo purposes -->
|
||||||
|
<script src="lib/AdminLTE/dist/js/demo.js"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript"
|
||||||
|
src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.1/js/bootstrap-datepicker.min.js"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript" src="js/adminpanel.js"></script>
|
||||||
|
<!-- DataTables -->
|
||||||
|
<script src="lib/AdminLTE/plugins/datatables/jquery.dataTables.js"></script>
|
||||||
|
<script src="lib/AdminLTE/plugins/datatables-bs4/js/dataTables.bootstrap4.js"></script>
|
||||||
|
|
||||||
|
<script src="lib/AdminLTE/plugins/sweetalert2/sweetalert2.all.js"></script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<title><title>WasteInformation Server</title></title>
|
<title>WasteInformation Server</title>
|
||||||
<!-- Tell the browser to be responsive to screen width -->
|
<!-- Tell the browser to be responsive to screen width -->
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<!-- Font Awesome -->
|
<!-- Font Awesome -->
|
||||||
@ -88,11 +88,11 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li class="nav-item">
|
<li id="adminpanel" class="nav-item hideit">
|
||||||
<a href="#todo" class="nav-link">
|
<a href="adminpanel.html" class="nav-link">
|
||||||
<i class="nav-icon fas fa-plus-circle"></i>
|
<i class="nav-icon fas fa-plus-circle"></i>
|
||||||
<p>
|
<p>
|
||||||
New Entry
|
Admin panel
|
||||||
</p>
|
</p>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@ -268,28 +268,42 @@
|
|||||||
<h4>Add Data:</h4>
|
<h4>Add Data:</h4>
|
||||||
<div class="input-group mt-3 mb-3" style="width: 100%;">
|
<div class="input-group mt-3 mb-3" style="width: 100%;">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<input id="input-wasteregion" type="text" class="form-control"
|
|
||||||
placeholder="Region">
|
|
||||||
<input id="input-wastezone" type="text" class="form-control" placeholder="Zone">
|
|
||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<button id="dropdown-wastetype-newdate" type="button"
|
<button id="dropdown-city" type="button"
|
||||||
|
class="btn btn-outline-dark dropdown-toggle"
|
||||||
|
data-toggle="dropdown">
|
||||||
|
Select city
|
||||||
|
</button>
|
||||||
|
<div id="dropdown-city-data" class="dropdown-menu">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<button id="dropdown-zone" type="button"
|
||||||
|
class="btn btn-outline-dark dropdown-toggle"
|
||||||
|
data-toggle="dropdown">
|
||||||
|
Select Zone
|
||||||
|
</button>
|
||||||
|
<div id="dropdown-zone-data" class="dropdown-menu">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<button id="dropdown-type-data1" type="button"
|
||||||
class="btn btn-outline-dark dropdown-toggle"
|
class="btn btn-outline-dark dropdown-toggle"
|
||||||
data-toggle="dropdown">
|
data-toggle="dropdown">
|
||||||
Select waste type
|
Select waste type
|
||||||
</button>
|
</button>
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
<a class="dropdown-item" href="#">Plastic</a>
|
<a class="dropdown-item-wastetype dropdown-item" href="#">Plastic</a>
|
||||||
<a class="dropdown-item" href="#">Metal</a>
|
<a class="dropdown-item-wastetype dropdown-item" href="#">Metal</a>
|
||||||
<a class="dropdown-item" href="#">Residual waste</a>
|
<a class="dropdown-item-wastetype dropdown-item" href="#">Residual waste</a>
|
||||||
<a class="dropdown-item" href="#">Biowaste</a>
|
<a class="dropdown-item-wastetype dropdown-item" href="#">Biowaste</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<input id="input-wastetime" style="width: 50px;" class="form-control" id="date"
|
<input id="input-wastetime" style="width: 50px;" class="form-control" id="date"
|
||||||
name="date" placeholder="MM/DD/YYY" type="text"/>
|
name="date" placeholder="MM/DD/YYY" type="text"/>
|
||||||
<button type="button" class="btn-addtolist btn btn-success"
|
<button type="button" class="btn-addtolist btn btn-success"
|
||||||
style="float:right;">Add to list
|
style="float:right;">Save
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -312,7 +326,6 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- /.Left col -->
|
<!-- /.Left col -->
|
||||||
<!-- right col (We are only adding the ID to make the widgets sortable)-->
|
<!-- right col (We are only adding the ID to make the widgets sortable)-->
|
||||||
<section class="col-lg-5 connectedSortable">
|
<section class="col-lg-5 connectedSortable">
|
||||||
|
34
src/resources/wwwroot/js/adminpanel.js
Normal file
34
src/resources/wwwroot/js/adminpanel.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
$(document).ready(function () {
|
||||||
|
console.log("page loaded");
|
||||||
|
$.post('/senddata/checkloginstate', 'action=getloginstate', function (data) {
|
||||||
|
console.log(data);
|
||||||
|
if (data.loggedin == true) {
|
||||||
|
$("#userlabel").html(" " + data.username);
|
||||||
|
if (data.permission > 0) {
|
||||||
|
$("#adminpanel").show();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$("#userlabel").html(" not logged in!!");
|
||||||
|
}
|
||||||
|
}, 'json');
|
||||||
|
|
||||||
|
|
||||||
|
$("#btn-shutdown").click(function (event) {
|
||||||
|
console.log("shutting down server");
|
||||||
|
|
||||||
|
$.post('/senddata/admindata', 'action=shutdownserver', function (data) {
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
|
}, 'json');
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#btn-restart").click(function (event) {
|
||||||
|
console.log("restarting server");
|
||||||
|
|
||||||
|
$.post('/senddata/admindata', 'action=restartserver', function (data) {
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
|
}, 'json');
|
||||||
|
});
|
||||||
|
});
|
@ -4,6 +4,9 @@ $(document).ready(function () {
|
|||||||
console.log(data);
|
console.log(data);
|
||||||
if (data.loggedin == true) {
|
if (data.loggedin == true) {
|
||||||
$("#userlabel").html(" " + data.username);
|
$("#userlabel").html(" " + data.username);
|
||||||
|
if (data.permission > 0) {
|
||||||
|
$("#adminpanel").show();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$("#userlabel").html(" not logged in!!");
|
$("#userlabel").html(" not logged in!!");
|
||||||
}
|
}
|
||||||
@ -16,6 +19,8 @@ $(document).ready(function () {
|
|||||||
console.log(data);
|
console.log(data);
|
||||||
if (data.query == "ok") {
|
if (data.query == "ok") {
|
||||||
$('#location-table-data').html("");
|
$('#location-table-data').html("");
|
||||||
|
$(".delbtn").off();
|
||||||
|
|
||||||
for (var i = 0; i < data.data.length; i++) {
|
for (var i = 0; i < data.data.length; i++) {
|
||||||
$('#location-table-data').append("<tr>" +
|
$('#location-table-data').append("<tr>" +
|
||||||
"<td>" + data.data[i].cityname + "</td>" +
|
"<td>" + data.data[i].cityname + "</td>" +
|
||||||
@ -23,15 +28,27 @@ $(document).ready(function () {
|
|||||||
"<td>" + data.data[i].wastetype + "</td>" +
|
"<td>" + data.data[i].wastetype + "</td>" +
|
||||||
"<td>" + "<button dataid='" + data.data[i].id + "' type='button' class='delbtn btn btn-danger'>X</button>" + "</td>" +
|
"<td>" + "<button dataid='" + data.data[i].id + "' type='button' class='delbtn btn btn-danger'>X</button>" + "</td>" +
|
||||||
"</tr>");
|
"</tr>");
|
||||||
|
}
|
||||||
|
|
||||||
$(".delbtn").click(function (event) {
|
$(".delbtn").click(function (event) {
|
||||||
var id = event.target.getAttribute("dataid");
|
var id = event.target.getAttribute("dataid");
|
||||||
console.log("clicked btn data " + id);
|
console.log("clicked btn data " + id);
|
||||||
$.post('/senddata/wastedata', 'action=deletecity&id=' + id, function (data) {
|
$.post('/senddata/wastedata', 'action=deletecity&id=' + id, function (data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
Swal.fire({
|
||||||
|
type: "success",
|
||||||
|
title: 'Successfully deleted city!',
|
||||||
|
html: 'This alert closes automatically.',
|
||||||
|
timer: 1000,
|
||||||
|
}).then((result) => {
|
||||||
|
console.log('Popup closed. ')
|
||||||
|
|
||||||
|
});
|
||||||
|
table.destroy(); //todo in reloadtable maybe
|
||||||
reloadtable();
|
reloadtable();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
|
||||||
//todo entweda 1 od 2
|
//todo entweda 1 od 2
|
||||||
// $("#example2").reload();
|
// $("#example2").reload();
|
||||||
table = $("#example2").DataTable();
|
table = $("#example2").DataTable();
|
||||||
@ -120,15 +137,60 @@ $(document).ready(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$('.btn-addtolist').click(function () {
|
/* new Date create: */
|
||||||
console.log("added new row to table");
|
$("#dropdown-city").click(function (event) {
|
||||||
$('#addtable-body').append("<tr>" +
|
event.preventDefault();
|
||||||
"<td class='td-dropdown-wastetype'>" + $('#dropdown-wastetype').html() + "</td>" +
|
var dropdata = $("#dropdown-city-data");
|
||||||
"<td class='td-input-wastetime'>" + $('#input-wastetime').val() + "</td>" +
|
dropdata.html("");
|
||||||
"<td class='td-input-wasteregion'>" + $('#input-wasteregion').val() + "</td>" +
|
|
||||||
"<td class='td-input-wastezone'>" + $('#input-wastezone').val() + "</td>" +
|
$.post('/senddata/newdate', 'action=getCitynames', function (data) {
|
||||||
"</tr>");
|
console.log(data);
|
||||||
|
if (data.query == "ok") {
|
||||||
|
var prev = "";
|
||||||
|
for (var i = 0; i < data.data.length; i++) {
|
||||||
|
var name = data.data[i].cityname;
|
||||||
|
dropdata.append("<a class=\"dropdown-data-cityname dropdown-item\" href=\"#\">" + name + "</a>");
|
||||||
|
}
|
||||||
|
|
||||||
|
$(".dropdown-data-cityname").off();
|
||||||
|
$(".dropdown-data-cityname").click(function (evnt) {
|
||||||
|
evnt.preventDefault();
|
||||||
|
console.log($(this).html());
|
||||||
|
$("#dropdown-city").html($(this).html());
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#dropdown-zone").click(function (event) {
|
||||||
|
event.preventDefault();
|
||||||
|
var dropdata = $("#dropdown-zone-data");
|
||||||
|
dropdata.html("");
|
||||||
|
|
||||||
|
$.post('/senddata/newdate', 'action=getzones&cityname='+$("#dropdown-city").html(), function (data) {
|
||||||
|
console.log(data);
|
||||||
|
if (data.query == "ok") {
|
||||||
|
var prev = "";
|
||||||
|
for (var i = 0; i < data.data.length; i++) {
|
||||||
|
var zone = data.data[i].zone;
|
||||||
|
dropdata.append("<a class=\"dropdown-data-zonename dropdown-item\" href=\"#\">" + zone + "</a>");
|
||||||
|
}
|
||||||
|
|
||||||
|
$(".dropdown-data-zonename").off();
|
||||||
|
$(".dropdown-data-zonename").click(function (evnt) {
|
||||||
|
evnt.preventDefault();
|
||||||
|
console.log($(this).html());
|
||||||
|
$("#dropdown-zone").html($(this).html());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".dropdown-item-wastetype").click(function (event) {
|
||||||
|
event.preventDefault();
|
||||||
|
$("#dropdown-type-data1").html($(this).html());
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
$('#btn-savelist').click(function () {
|
$('#btn-savelist').click(function () {
|
||||||
console.log("saving list");
|
console.log("saving list");
|
||||||
|
Loading…
Reference in New Issue
Block a user