diff --git a/numass-web-control/.gitignore b/numass-web-control/.gitignore new file mode 100644 index 00000000..b63da455 --- /dev/null +++ b/numass-web-control/.gitignore @@ -0,0 +1,42 @@ +.gradle +build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/numass-web-control/build.gradle.kts b/numass-web-control/build.gradle.kts new file mode 100644 index 00000000..38079d2f --- /dev/null +++ b/numass-web-control/build.gradle.kts @@ -0,0 +1,25 @@ +plugins { + application +} + +group = "inr.numass" + +repositories { + mavenCentral() +} + +dependencies { + testImplementation(platform("org.junit:junit-bom:5.9.1")) + testImplementation("org.junit.jupiter:junit-jupiter") + implementation("io.ktor:ktor-server-core:2.3.7") + implementation("io.ktor:ktor-server-netty:2.3.7") + +} + +tasks.test { + useJUnitPlatform() +} + +application { + mainClass.set("inr.numass.webcontrol.ServerKt") +} \ No newline at end of file diff --git a/numass-web-control/src/main/java/inr/numass/webcontrol/Server.kt b/numass-web-control/src/main/java/inr/numass/webcontrol/Server.kt new file mode 100644 index 00000000..64fb20d6 --- /dev/null +++ b/numass-web-control/src/main/java/inr/numass/webcontrol/Server.kt @@ -0,0 +1,26 @@ +package inr.numass.webcontrol + +import io.ktor.server.routing.* +import io.ktor.http.* +import io.ktor.server.application.* +import io.ktor.server.response.* +import io.ktor.server.request.* +import io.ktor.server.engine.* +import io.ktor.server.netty.* +import java.nio.file.Paths +import io.ktor.server.http.content.* +fun main() { + var clickNumber = 0 + embeddedServer(Netty, port = 8000) { + + routing { + staticFiles("/", Paths.get(this.javaClass.classLoader.getResource("index.html").toURI()).toFile().parentFile) + get ("/api") { + call.respondText(call.parameters.toString()) + } + get ("/api/clicker") { + call.respondText(clickNumber++.toString()) + } + } + }.start(wait = true) +} \ No newline at end of file diff --git a/numass-web-control/src/main/resources/index.html b/numass-web-control/src/main/resources/index.html new file mode 100644 index 00000000..fbc62cf8 --- /dev/null +++ b/numass-web-control/src/main/resources/index.html @@ -0,0 +1,44 @@ + + + + + Amogus + + + +
+ + + + Update interval: + + + + + + +
+
+ + +
+ + + \ No newline at end of file diff --git a/numass-web-control/src/main/resources/script.js b/numass-web-control/src/main/resources/script.js new file mode 100644 index 00000000..b6c57036 --- /dev/null +++ b/numass-web-control/src/main/resources/script.js @@ -0,0 +1,15 @@ +function clickCounter(e) { + fetch("/api/clicker") + .then((response) => response.text()) + .then((text) => { document.querySelector("#click1").innerHTML=text } ) +} + +function cycle() { + console.log("asdffg") + + setTimeout(cycle, document.querySelector("input[name='interval']:checked").value * 1000) +} + + +//document.querySelector("#click1").addEventListener('click', clickCounter) +cycle() \ No newline at end of file diff --git a/numass-web-control/src/main/resources/styles.css b/numass-web-control/src/main/resources/styles.css new file mode 100644 index 00000000..ac41072c --- /dev/null +++ b/numass-web-control/src/main/resources/styles.css @@ -0,0 +1,74 @@ +.myButton { + color: bisque; + background: crimson; +} + +.testButton { + color: magenta; + background: cyan; +} +#log { + color: magenta; + background: cyan; + float: right; +} +#graph { + background: burlywood; + width: 80%; +} +body { + height: 100vh; + margin: 0; + padding: 0; + display: flex; + flex-direction: column; +} +#lower { + flex: 1; + display: flex; +} +.upperSection { + background: lightblue +} +#sidebar { + flex: 1; +} + +.card { + border: 1px black solid; + padding: .25em; +} + +input.switch { + position: relative; + float: right; + left: -1em; +} + +input.switch:before { + content: ' '; + display: block; + position: absolute; + width: 3em; + height: 1em; + background: gray; + left: -1em; + border-radius: 0.5em; +} + +input.switch:after { + content: ' '; + display: block; + position: absolute; + width: 1em; + height: 1em; + background: red; + left: -1em; + border-radius: 0.5em; + transition: .25s ease; +} + +input.switch:checked:after { + left: 1em; + background: green; +} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 9ec0ed8a..0737347a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -53,4 +53,4 @@ include("numass-core:numass-data-proto") include("numass-core:numass-signal-processing") include(":numass-viewer") - +include("numass-web-control")