From 2870c5ec01248f16044471f1be9113b162b1b7aa Mon Sep 17 00:00:00 2001 From: Andrew Charneski Date: Fri, 24 May 2024 20:14:15 -0500 Subject: [PATCH] 1.0.74 (#79) --- gradle.properties | 2 +- .../skyenet/webui/application/ApplicationServer.kt | 8 ++++++-- .../simiacryptus/skyenet/webui/servlet/AppInfoServlet.kt | 6 ++++-- webui/src/main/resources/application/main.js | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/gradle.properties b/gradle.properties index 4bfee4ce..0619b7ca 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ # Gradle Releases -> https://github.com/gradle/gradle/releases libraryGroup = com.simiacryptus.skyenet -libraryVersion = 1.0.73 +libraryVersion = 1.0.74 gradleVersion = 7.6.1 diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/application/ApplicationServer.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/application/ApplicationServer.kt index 141d7e0c..67ed1ac5 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/application/ApplicationServer.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/application/ApplicationServer.kt @@ -28,7 +28,7 @@ abstract class ApplicationServer( open val description: String = "" open val singleInput = true open val stickyInput = false - open val appInfo by lazy { + open val appInfo: Map by lazy { mapOf( "applicationName" to applicationName, "singleInput" to singleInput, @@ -40,7 +40,9 @@ abstract class ApplicationServer( final override val dataStorage: StorageInterface by lazy { dataStorageFactory(root) } - protected open val appInfoServlet by lazy { ServletHolder("appInfo", AppInfoServlet(appInfo)) } + protected open val appInfoServlet by lazy { ServletHolder("appInfo", AppInfoServlet { + session -> sessionAppInfoMap[session] ?: appInfo + }) } protected open val userInfo by lazy { ServletHolder("userInfo", UserInfoServlet()) } protected open val usageServlet by lazy { ServletHolder("usage", UsageServlet()) } protected open val fileZip by lazy { ServletHolder("fileZip", ZipServlet(dataStorage)) } @@ -177,6 +179,8 @@ abstract class ApplicationServer( fun HttpServletRequest.getCookie(name: String = AuthenticationInterface.AUTH_COOKIE) = cookies?.find { it.name == name }?.value + val sessionAppInfoMap = mutableMapOf>() + } } \ No newline at end of file diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/servlet/AppInfoServlet.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/servlet/AppInfoServlet.kt index 3b9099f8..57e6453c 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/servlet/AppInfoServlet.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/webui/servlet/AppInfoServlet.kt @@ -5,10 +5,12 @@ import jakarta.servlet.http.HttpServlet import jakarta.servlet.http.HttpServletRequest import jakarta.servlet.http.HttpServletResponse -class AppInfoServlet(val info: T) : HttpServlet() { +class AppInfoServlet(val info: (String?) -> T) : HttpServlet() { override fun doGet(req: HttpServletRequest, resp: HttpServletResponse) { + val session = req.getParameter("session") resp.contentType = "text/json" resp.status = HttpServletResponse.SC_OK - resp.writer.write(JsonUtil.objectMapper().writeValueAsString(info)) + resp.writer.write(JsonUtil.objectMapper().writeValueAsString(info(session))) } + } \ No newline at end of file diff --git a/webui/src/main/resources/application/main.js b/webui/src/main/resources/application/main.js index 9a60a0f0..6b3aa120 100644 --- a/webui/src/main/resources/application/main.js +++ b/webui/src/main/resources/application/main.js @@ -255,7 +255,7 @@ document.addEventListener('DOMContentLoaded', () => { window.open(url, "_blank"); }); - fetch('appInfo') + fetch('appInfo?session=' + sessionId) .then(response => { if (!response.ok) { throw new Error('Network response was not ok');