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()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -49,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'
|
||||||
@@ -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