Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a0396ab2d | ||
|
|
b3960653ca | ||
|
|
af321c8aad | ||
|
|
16939c7b6a | ||
|
|
fbc53b97f5 |
No files matched your search
+28
@@ -0,0 +1,28 @@
|
|||||||
|
language: java
|
||||||
|
jdk: oraclejdk8
|
||||||
|
dist: trusty
|
||||||
|
|
||||||
|
# Make the gradle wrapper executable
|
||||||
|
# before_install: chmod +x gradlew
|
||||||
|
before_install:
|
||||||
|
- wget https://services.gradle.org/distributions/gradle-6.1.1-all.zip
|
||||||
|
- unzip -qq gradle-6.1.1-all.zip
|
||||||
|
- export GRADLE_HOME=$PWD/gradle-6.1.1
|
||||||
|
- export PATH=$GRADLE_HOME/bin:$PATH
|
||||||
|
- gradle -v
|
||||||
|
|
||||||
|
script:
|
||||||
|
#- gradle check jacocoTestReport
|
||||||
|
# Also upload test coverage to codecov
|
||||||
|
#- bash <(curl -s https://codecov.io/bash)
|
||||||
|
|
||||||
|
before_cache:
|
||||||
|
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
|
||||||
|
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
|
||||||
|
- rm -f $HOME/.gradle/caches/*/fileHashes/fileHashes.bin
|
||||||
|
- rm -f $HOME/.gradle/caches/*/fileHashes/fileHashes.lock
|
||||||
|
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- $HOME/.gradle/caches/
|
||||||
|
- $HOME/.gradle/wrapper/
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
//plugins {
|
||||||
|
// id 'org.jetbrains.kotlin.js' version '1.3.70-eap-184'
|
||||||
|
//}
|
||||||
|
|
||||||
|
//group 'org.example'
|
||||||
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
ext.kotlin_version = '1.3.61'
|
||||||
|
ext.web_dir = '../src/resources/wwwroot/js/'
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin2js'
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main.java.srcDirs = ["src/js/"]
|
||||||
|
test.java.srcDirs = ["src/js/test"]
|
||||||
|
}
|
||||||
|
|
||||||
|
compileKotlin2Js {
|
||||||
|
kotlinOptions.outputFile = "${projectDir}/build/web/WasteInformationServer.js"
|
||||||
|
kotlinOptions.moduleKind = "plain"
|
||||||
|
kotlinOptions.sourceMap = true
|
||||||
|
}
|
||||||
|
|
||||||
|
compileTestKotlin2Js {
|
||||||
|
kotlinOptions.moduleKind = "plain"
|
||||||
|
kotlinOptions.sourceMap = true
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
maven {
|
||||||
|
url "http://dl.bintray.com/kotlin/kotlin-eap-1.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
|
||||||
|
testCompile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
|
||||||
|
}
|
||||||
|
|
||||||
|
clean.doFirst() {
|
||||||
|
delete("${web_dir}")
|
||||||
|
}
|
||||||
|
|
||||||
|
build.doLast() {
|
||||||
|
// Copy kotlin.js and kotlin-meta.js from jar into web directory
|
||||||
|
configurations.compile.each { File file ->
|
||||||
|
copy {
|
||||||
|
includeEmptyDirs = false
|
||||||
|
|
||||||
|
from zipTree(file.absolutePath)
|
||||||
|
into "${projectDir}/${web_dir}/lib"
|
||||||
|
include { fileTreeElement ->
|
||||||
|
def path = fileTreeElement.path
|
||||||
|
path.endsWith(".js") && (path.startsWith("META-INF/resources/") || !path.startsWith("META-INF/"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unpack build contents
|
||||||
|
// TODO Remove this step when a CDN link is available.
|
||||||
|
copy {
|
||||||
|
File artifact = new File("build/libs/${project.name}-${project.version}.jar")
|
||||||
|
includeEmptyDirs = false
|
||||||
|
|
||||||
|
from zipTree(artifact)
|
||||||
|
into "${web_dir}"
|
||||||
|
include { fileTreeElement ->
|
||||||
|
def path = fileTreeElement.path
|
||||||
|
!(path.startsWith("META-INF/") || path.startsWith("${project.name}"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy scripts to web directory
|
||||||
|
copy {
|
||||||
|
includeEmptyDirs = false
|
||||||
|
from new File("build/classes/main")
|
||||||
|
into "${web_dir}/lib"
|
||||||
|
}
|
||||||
|
|
||||||
|
copy {
|
||||||
|
includeEmptyDirs = false
|
||||||
|
from new File("build/classes/test")
|
||||||
|
into "${web_dir}/lib"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
rootProject.name = 'WebServer'
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import org.w3c.fetch.RequestInit
|
||||||
|
import kotlin.browser.document
|
||||||
|
import kotlin.browser.window
|
||||||
|
import kotlin.js.Json
|
||||||
|
|
||||||
|
class Dashboard {
|
||||||
|
init {
|
||||||
|
window.fetch("/senddata/wastedata", RequestInit(method = "POST", body = "action=getStartHeaderData")).then { it -> it.text().then {
|
||||||
|
println("response text is: "+it)
|
||||||
|
val json = JSON.parse<Json>(it)
|
||||||
|
document.getElementById("total-connection-labels")?.innerHTML = json["collectionnumber"] as String
|
||||||
|
document.getElementById("planed-collection-label")?.innerHTML = json["futurecollections"] as String
|
||||||
|
|
||||||
|
document.getElementById("finished-collection-label")?.innerHTML = json["finshedcollections"] as String
|
||||||
|
|
||||||
|
document.getElementById("total-city-number-label")?.innerHTML = json["citynumber"] as String
|
||||||
|
} }
|
||||||
|
|
||||||
|
window.fetch("/senddata/wastedata", RequestInit(method = "POST", body = "action=getversionandbuildtime")).then { it -> it.text().then {
|
||||||
|
val json = JSON.parse<Json>(it)
|
||||||
|
document.getElementById("version-footer-label")?.innerHTML = "<b>Version</b> " + json["version"] + " <b>Build</b> " + json["buildtime"] as String
|
||||||
|
} }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
import org.w3c.dom.HTMLInputElement
|
||||||
|
import org.w3c.fetch.RequestInit
|
||||||
|
import kotlin.browser.document
|
||||||
|
import kotlin.browser.window
|
||||||
|
import kotlin.js.Json
|
||||||
|
|
||||||
|
class Index {
|
||||||
|
init {
|
||||||
|
document.getElementById("loginbtn")?.addEventListener("click", {
|
||||||
|
it.preventDefault()
|
||||||
|
println("clicked!!!")
|
||||||
|
|
||||||
|
val username = document.getElementById("userfield") as HTMLInputElement
|
||||||
|
val passfield = document.getElementById("passfield") as HTMLInputElement
|
||||||
|
println(username.value)
|
||||||
|
|
||||||
|
console.log("fetch 'data.json' with 'post'")
|
||||||
|
window.fetch("/senddata/loginget", RequestInit(method = "POST", body = "username=${username.value}&password=${passfield.value}")).then { response ->
|
||||||
|
response.text().then { text ->
|
||||||
|
val json = JSON.parse<Json>(text)
|
||||||
|
if (json["status"] == "nodbconn") {
|
||||||
|
js("""Swal.fire({
|
||||||
|
type: "error",
|
||||||
|
title: 'No connection to Database',
|
||||||
|
html: 'Setup DB here --> <a href="index.html">click<a/>.'
|
||||||
|
})""")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (json["accept"] == true) {
|
||||||
|
println("successfully logged in!")
|
||||||
|
document.cookie = "username=$username"
|
||||||
|
window.location.replace("dashboard.html")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// todo register pwa correctly
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import kotlin.browser.window
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
val callurl = window.document.URL
|
||||||
|
window.onload = {
|
||||||
|
if (callurl.endsWith("/") || callurl.contains("index.html")) {
|
||||||
|
println("loaded sucessfully")
|
||||||
|
Index()
|
||||||
|
}
|
||||||
|
else if (callurl.contains("dashboard.html")) {
|
||||||
|
Dashboard()
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
println("js called from undefined html file")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import org.w3c.xhr.XMLHttpRequest
|
||||||
|
|
||||||
|
class Requester {
|
||||||
|
fun request(){
|
||||||
|
val test = XMLHttpRequest()
|
||||||
|
|
||||||
|
test.open("GET","https://api.ipify.org?format=json")
|
||||||
|
|
||||||
|
test.onload = {
|
||||||
|
println(test.responseText)
|
||||||
|
}
|
||||||
|
|
||||||
|
test.send()
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-1
@@ -30,7 +30,6 @@ dependencies {
|
|||||||
compile group: 'org.eclipse.paho', name: 'org.eclipse.paho.client.mqttv3', version: '1.2.2'
|
compile group: 'org.eclipse.paho', name: 'org.eclipse.paho.client.mqttv3', version: '1.2.2'
|
||||||
compile group: 'mysql',name:'mysql-connector-java',version: '8.0.18'
|
compile group: 'mysql',name:'mysql-connector-java',version: '8.0.18'
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||||
implementation 'com.google.code.gson:gson:2.8.6'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
task run (type: JavaExec){
|
task run (type: JavaExec){
|
||||||
@@ -50,6 +49,8 @@ task createProperties(dependsOn: processResources) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.processResources.dependsOn("WebServer:build")
|
||||||
|
|
||||||
task myJavadocs(type: Javadoc) {
|
task myJavadocs(type: Javadoc) {
|
||||||
title = "JAVADOC WasteInformationServer"
|
title = "JAVADOC WasteInformationServer"
|
||||||
source = sourceSets.main.allJava
|
source = sourceSets.main.allJava
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
rootProject.name = 'WasteInformationServer'
|
rootProject.name = 'WasteInformationServer'
|
||||||
|
|
||||||
|
include 'WebServer'
|
||||||
@@ -1,9 +1,5 @@
|
|||||||
package com.wasteinformationserver.website.datarequests
|
package com.wasteinformationserver.website.datarequests
|
||||||
|
|
||||||
import com.google.gson.Gson
|
|
||||||
import com.google.gson.JsonArray
|
|
||||||
import com.google.gson.JsonObject
|
|
||||||
import com.wasteinformationserver.basicutils.Log
|
|
||||||
import com.wasteinformationserver.basicutils.Log.Log.debug
|
import com.wasteinformationserver.basicutils.Log.Log.debug
|
||||||
import com.wasteinformationserver.basicutils.Log.Log.error
|
import com.wasteinformationserver.basicutils.Log.Log.error
|
||||||
import com.wasteinformationserver.db.JDBC
|
import com.wasteinformationserver.db.JDBC
|
||||||
@@ -23,58 +19,39 @@ class DeviceRequest : PostRequest() {
|
|||||||
}
|
}
|
||||||
val sb = StringBuilder()
|
val sb = StringBuilder()
|
||||||
var deviceset: ResultSet
|
var deviceset: ResultSet
|
||||||
|
|
||||||
val gson = Gson()
|
|
||||||
val elem = gson.toJsonTree(Object())
|
|
||||||
|
|
||||||
when (params["action"]) {
|
when (params["action"]) {
|
||||||
"getdevices" -> {
|
"getdevices" -> {
|
||||||
deviceset = jdbc!!.executeQuery("SELECT * FROM `devices")
|
deviceset = jdbc!!.executeQuery("SELECT * FROM `devices")
|
||||||
elem.asJsonObject.add("data", JsonArray())
|
|
||||||
sb.append("{\"data\":[")
|
sb.append("{\"data\":[")
|
||||||
try {
|
try {
|
||||||
while (deviceset.next()) {
|
while (deviceset.next()) {
|
||||||
val deviceid = deviceset.getInt("DeviceID")
|
val deviceid = deviceset.getInt("DeviceID")
|
||||||
val cityid = deviceset.getInt("CityID")
|
val cityid = deviceset.getInt("CityID")
|
||||||
if (cityid == -1) {
|
if (cityid == -1) {
|
||||||
val obj = JsonObject()
|
sb.append("{\"deviceid\":\"").append(deviceid).append("\",\"cityid\":\"").append(cityid).append("\"}")
|
||||||
obj.addProperty("deviceid", deviceid)
|
|
||||||
obj.addProperty("cityid", cityid)
|
|
||||||
elem.asJsonObject.get("data").asJsonArray.add(obj)
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
val obj = JsonObject()
|
|
||||||
val devicename = deviceset.getString("DeviceName")
|
val devicename = deviceset.getString("DeviceName")
|
||||||
val devicelocation = deviceset.getString("DeviceLocation")
|
val devicelocation = deviceset.getString("DeviceLocation")
|
||||||
obj.addProperty("deviceid", deviceid)
|
sb.append("{\"deviceid\":\"").append(deviceid).append("\",\"devicename\":\"").append(devicename).append("\",\"devicelocation\":\"").append(devicelocation).append("\",\"devices\":[")
|
||||||
obj.addProperty("devicename", devicename)
|
|
||||||
obj.addProperty("devicelocation", devicelocation)
|
|
||||||
|
|
||||||
val locations = JsonArray()
|
|
||||||
obj.add("locations", locations)
|
|
||||||
|
|
||||||
elem.asJsonObject.get("data").asJsonArray.add(obj)
|
|
||||||
|
|
||||||
val devicecities = jdbc.executeQuery("SELECT * FROM `device_city` INNER JOIN `cities` ON device_city.CityID=cities.id WHERE `DeviceID`='$deviceid'")
|
val devicecities = jdbc.executeQuery("SELECT * FROM `device_city` INNER JOIN `cities` ON device_city.CityID=cities.id WHERE `DeviceID`='$deviceid'")
|
||||||
while (devicecities.next()) {
|
while (devicecities.next()) {
|
||||||
val cityidd = devicecities.getInt("id")
|
val cityidd = devicecities.getInt("id")
|
||||||
val cityname = devicecities.getString("name")
|
val cityname = devicecities.getString("name")
|
||||||
val wastetype = devicecities.getString("wastetype")
|
val wastetype = devicecities.getString("wastetype")
|
||||||
val zone = devicecities.getString("zone")
|
val zone = devicecities.getString("zone")
|
||||||
|
sb.append("{\"cityid\":\"").append(cityidd).append("\",\"cityname\":\"").append(cityname).append("\",\"wastetype\":\"").append(wastetype).append("\",\"zone\":\"").append(zone).append("\"}")
|
||||||
val objc = JsonObject()
|
if (!devicecities.isLast) {
|
||||||
objc.addProperty("cityid", cityidd)
|
sb.append(",")
|
||||||
objc.addProperty("cityname", cityname)
|
}
|
||||||
objc.addProperty("wastetype", wastetype)
|
|
||||||
objc.addProperty("zone", zone)
|
|
||||||
|
|
||||||
locations.add(objc)
|
|
||||||
// todo better var names
|
|
||||||
// todo implement in js and other methods
|
|
||||||
}
|
}
|
||||||
|
sb.append("]}")
|
||||||
|
}
|
||||||
|
if (!deviceset.isLast) {
|
||||||
|
sb.append(",")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.debug(gson.toJson(elem))
|
sb.append("]}")
|
||||||
} catch (e: SQLException) {
|
} catch (e: SQLException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class LoginState {
|
|||||||
private String email;
|
private String email;
|
||||||
private int permission;
|
private int permission;
|
||||||
|
|
||||||
boolean loggedin = false;
|
boolean loggedin = true;
|
||||||
|
|
||||||
public void logIn() {
|
public void logIn() {
|
||||||
loggedin = true;
|
loggedin = true;
|
||||||
|
|||||||
@@ -448,8 +448,8 @@
|
|||||||
|
|
||||||
<!-- OWN -->
|
<!-- OWN -->
|
||||||
|
|
||||||
<script type="text/javascript" src="js/dashboard.js"></script>
|
<script type="text/javascript" src="js/lib/kotlin.js"></script>
|
||||||
<script src="js/userManager.js"></script>
|
<script type="text/javascript" src="js/WasteInformationServer.js"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -24,13 +24,15 @@
|
|||||||
<!--Custom styles-->
|
<!--Custom styles-->
|
||||||
<link rel="stylesheet" type="text/css" href="css/index.css">
|
<link rel="stylesheet" type="text/css" href="css/index.css">
|
||||||
|
|
||||||
<script type="text/javascript" src="js/index.js"></script>
|
|
||||||
|
|
||||||
<script src="lib/AdminLTE/plugins/sweetalert2/sweetalert2.all.js"></script>
|
<script src="lib/AdminLTE/plugins/sweetalert2/sweetalert2.all.js"></script>
|
||||||
|
|
||||||
<link rel="manifest" href="/manifest.json">
|
<link rel="manifest" href="/manifest.json">
|
||||||
|
|
||||||
<link rel="icon" type="image/png" href="/favicon.png">
|
<link rel="icon" type="image/png" href="/favicon.png">
|
||||||
|
|
||||||
|
<script type="text/javascript" src="js/lib/kotlin.js"></script>
|
||||||
|
<script type="text/javascript" src="js/WasteInformationServer.js"></script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Reference in new issue
Block a user