Skip to content

Commit

Permalink
workaround for broken select
Browse files Browse the repository at this point in the history
  • Loading branch information
jillesvangurp committed Nov 9, 2024
1 parent b6eef98 commit f7b7fcf
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 30 deletions.
93 changes: 63 additions & 30 deletions src/jsMain/kotlin/searchpluginconfig/settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,46 +76,79 @@ fun RenderContext.settings() {
settingsStore.data handledBy {
settingsStore.configure()
}
val collapseStore = storeOf(true)
h2 {
+"AI Configuration"

textField(
"http://localhost:11434/v1",
"Base Url",
description = "Leave blank to use OpenAI or provide compatible alternative. When using ollama, this is the correct url: http://localhost:11434/v1"
) {
value(settingsStore.openAiBaseUrlStore)
a {
+"AI Configuration"
clicks handledBy {
collapseStore.update(!collapseStore.current)
}
}
val showApiKeyFieldStore = storeOf(false)
div {
a {
}
collapseStore.data.render {collapsed ->
if(!collapsed) {
textField(
"http://localhost:11434/v1",
"Base Url",
description = "Leave blank to use OpenAI or provide compatible alternative. When using ollama, this is the correct url: http://localhost:11434/v1"
) {
value(settingsStore.openAiBaseUrlStore)
}
val showApiKeyFieldStore = storeOf(false)
div {
a {
showApiKeyFieldStore.data.render { show ->
if (show) {
+"Hide API Key"
} else {
+"Edit API Key"
}
clicks handledBy {
showApiKeyFieldStore.update(!showApiKeyFieldStore.current)
}
}
}
showApiKeyFieldStore.data.render { show ->
if (show) {
+"Hide API Key"
} else {
+"Edit API Key"
}
clicks handledBy {
showApiKeyFieldStore.update(!showApiKeyFieldStore.current)
textField(
"XYZ",
"API Key",
description = "Your API key if one is needed. Leave blank for ollama."
) {
value(settingsStore.openAiApiKeyStore)
}
}
}
}
showApiKeyFieldStore.data.render { show ->
if(show) {
textField("XYZ", "API Key", description = "Your API key if one is needed. Leave blank for ollama.") {
value(settingsStore.openAiApiKeyStore)
settingsStore.data.render { s ->
settingsStore.models.data.render { models ->
label {
+"Pick a model"
// selectBox(settingsStore.modelStore, models, emptyItem = "-")
// buggy select in fritz2
settingsStore.modelStore.data.render { current ->
ul {
models.forEach { modelId ->
li {
if (current == modelId) {
b {
+modelId
}
} else {
a {
+modelId
clicks handledBy {
settingsStore.modelStore.update(modelId)
}
}
}
}
}
}
}
}
}
}
}
settingsStore.data.render { s ->
settingsStore.models.data.render { models ->
label {
+"Pick a model"
selectBox(settingsStore.modelStore, models, emptyItem = "-")
}
}
}
}

}
7 changes: 7 additions & 0 deletions src/jsMain/resources/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,11 @@
a {
@apply text-blueBright-600 hover:text-blueBright-400 underline cursor-pointer;
}
ul {
@apply list-disc list-inside pl-4 my-2;
}

ol {
@apply list-decimal list-inside pl-4 my-2;
}
}

0 comments on commit f7b7fcf

Please sign in to comment.