-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
083a27a
commit 48123ca
Showing
26 changed files
with
180 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
webui/src/main/kotlin/com/simiacryptus/skyenet/servers/CodingActorTestApp.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
webui/src/main/kotlin/com/simiacryptus/skyenet/servers/ParsedActorTestApp.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...ryptus/skyenet/webui/NewSessionServlet.kt → ...ptus/skyenet/servlet/NewSessionServlet.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...iacryptus/skyenet/webui/SessionServlet.kt → ...cryptus/skyenet/servlet/SessionServlet.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...acryptus/skyenet/webui/UserInfoServlet.kt → ...ryptus/skyenet/servlet/UserInfoServlet.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
webui/src/main/kotlin/com/simiacryptus/skyenet/servlet/UserSettingsServlet.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.simiacryptus.skyenet.servlet | ||
|
||
import com.google.api.services.oauth2.model.Userinfo | ||
import com.simiacryptus.util.JsonUtil | ||
import jakarta.servlet.http.HttpServlet | ||
import jakarta.servlet.http.HttpServletRequest | ||
import jakarta.servlet.http.HttpServletResponse | ||
|
||
class UserSettingsServlet : HttpServlet() { | ||
public override fun doGet(req: HttpServletRequest, resp: HttpServletResponse) { | ||
resp.contentType = "text/html" | ||
resp.status = HttpServletResponse.SC_OK | ||
val authId = req.cookies?.firstOrNull { it.name == "sessionId" }?.value | ||
if (null == authId) { | ||
resp.status = HttpServletResponse.SC_BAD_REQUEST | ||
} else { | ||
val userinfo = AuthenticatedWebsite.users[authId] | ||
if(null == userinfo) { | ||
resp.status = HttpServletResponse.SC_BAD_REQUEST | ||
} else { | ||
val settings = getUserSettings(userinfo) | ||
val json = if (settings != null) JsonUtil.toJson(settings) else "" | ||
//language=HTML | ||
resp.writer.write( | ||
""" | ||
|<html> | ||
|<head> | ||
| <title>Settings</title> | ||
| <link rel="icon" type="image/svg+xml" href="/favicon.svg"/> | ||
|</head> | ||
|<body> | ||
|<form action="/userSettings/" method="post"> | ||
| <input type="hidden" name="sessionId" value="$authId"/> | ||
| <input type="hidden" name="action" value="save"/> | ||
| <textarea name="settings" style="width: 100%; height: 100px;">$json</textarea> | ||
| <input type="submit" value="Save"/> | ||
|</form> | ||
|</body> | ||
|</html> | ||
""".trimMargin() | ||
) | ||
} | ||
} | ||
} | ||
|
||
public override fun doPost(req: HttpServletRequest, resp: HttpServletResponse) { | ||
val userinfo = AuthenticatedWebsite.getUser(req) | ||
if (null == userinfo) { | ||
resp.status = HttpServletResponse.SC_BAD_REQUEST | ||
} else { | ||
val settings = JsonUtil.fromJson<UserSettings>(req.getParameter("settings"), UserSettings::class.java) | ||
updateUserSettings(userinfo, settings) | ||
resp.sendRedirect("/") | ||
} | ||
} | ||
|
||
companion object { | ||
val log = org.slf4j.LoggerFactory.getLogger(UserSettingsServlet::class.java) | ||
private val userSettings = HashMap<String, UserSettings>() | ||
|
||
fun getUserSettings(userinfo: Userinfo): UserSettings { | ||
return userSettings.getOrPut(userinfo.id) { | ||
UserSettings() | ||
} | ||
} | ||
|
||
fun updateUserSettings(userinfo: Userinfo, settings: UserSettings) { | ||
userSettings[userinfo.id] = settings | ||
} | ||
|
||
} | ||
} | ||
data class UserSettings( | ||
val apiKey: String = "", | ||
) |
3 changes: 2 additions & 1 deletion
3
.../simiacryptus/skyenet/webui/ZipServlet.kt → ...imiacryptus/skyenet/servlet/ZipServlet.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ryptus/skyenet/webui/ClasspathResource.kt → ...cryptus/skyenet/util/ClasspathResource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...imiacryptus/skyenet/webui/MarkdownUtil.kt → ...simiacryptus/skyenet/util/MarkdownUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.