Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a56bfec5c | ||
|
|
83c3054802
|
||
|
|
d84cc52e3c
|
||
|
|
62243161f3
|
||
|
|
eb9ed2a208
|
No files matched your search
@@ -13,7 +13,7 @@ plugins {
|
||||
alias(libs.plugins.buildconfig)
|
||||
}
|
||||
|
||||
version = PhoebenchVersion(1, 2, 1, "autoscroll")
|
||||
version = PhoebenchVersion(1, 2, 2, "csv-export")
|
||||
|
||||
if((version as PhoebenchVersion) < (rootProject.version as PhoebenchVersion))
|
||||
throw GradleException("UI Clients version must be at least as high as protocol/common version")
|
||||
@@ -96,6 +96,7 @@ kotlin {
|
||||
implementation(libs.lucide)
|
||||
implementation(libs.koala)
|
||||
implementation(libs.kolor)
|
||||
implementation(libs.filekit)
|
||||
}
|
||||
desktopMain.dependencies {
|
||||
implementation(compose.desktop.currentOs)
|
||||
|
||||
@@ -37,4 +37,6 @@ expect fun <T> drag(data: T, serializer: KSerializer<T>): DragAndDropTransferDat
|
||||
|
||||
inline fun <reified T> drop(data: DragAndDropEvent): T? = drop(data, serializer<T>())
|
||||
|
||||
expect fun <T> drop(data: DragAndDropEvent, serializer: KSerializer<T>): T?
|
||||
expect fun <T> drop(data: DragAndDropEvent, serializer: KSerializer<T>): T?
|
||||
|
||||
expect suspend fun onDownload(contents: String, nameHint: String, extension: String)
|
||||
+29
-2
@@ -1,6 +1,5 @@
|
||||
package com.jaytux.phoebench.clients.data
|
||||
|
||||
import androidx.compose.runtime.mutableStateListOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.lifecycle.ViewModel
|
||||
@@ -13,6 +12,7 @@ import com.jaytux.phoebench.clients.hexString
|
||||
import com.jaytux.phoebench.clients.immutable
|
||||
import com.jaytux.phoebench.clients.insort
|
||||
import com.jaytux.phoebench.clients.insortIdx
|
||||
import com.jaytux.phoebench.clients.onDownload
|
||||
import com.jaytux.phoebench.clients.replace
|
||||
import com.jaytux.phoebench.clients.withScope
|
||||
import com.jaytux.phoebench.common.BenchmarkResponse
|
||||
@@ -21,7 +21,7 @@ import com.jaytux.phoebench.common.VersionResponse
|
||||
import com.jaytux.phoebench.common.ProjectEvent
|
||||
import com.jaytux.phoebench.common.ServerMonitorEvent
|
||||
import com.jaytux.phoebench.common.TimeUnit
|
||||
import com.jaytux.phoebench.common.fold
|
||||
import io.ktor.http.quote
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlin.time.Clock
|
||||
import kotlin.time.Instant
|
||||
@@ -322,4 +322,31 @@ class ProjectVM(
|
||||
fun clearMonitor() = withScope {
|
||||
_repo.deleteMonitorLogs().snackOnError()
|
||||
}
|
||||
|
||||
fun triggerCsvDownload() = withScope {
|
||||
data class CsvEntry(val id: Uuid, val bench: Uuid, val benchName: String, val runner: Uuid, val runnerName: String, val runnerHex: String, val input: String, val hardware: String, val timing: List<Float>)
|
||||
|
||||
val benchmarks = _benchmarks.value.flatMap { bench ->
|
||||
bench.entries.map {
|
||||
CsvEntry(
|
||||
id = it.id, bench = bench.id, benchName = bench.name,
|
||||
runner = it.label.id, runnerName = it.label.name, runnerHex = it.label.colorStr,
|
||||
input = it.input, hardware = it.hardware, timing = it.measurements
|
||||
)
|
||||
}
|
||||
}
|
||||
val dataCount = benchmarks.maxOf { it.timing.size }
|
||||
|
||||
val header = listOf("id", "benchmark-id", "benchmark-name", "runner-id", "runner-name", "runner-hex", "input", "hardware") + List(dataCount) { "entry-$it" }
|
||||
val body = benchmarks.map {
|
||||
listOf(
|
||||
it.id.toHexDashString(), it.bench.toHexDashString(), it.benchName.quote(),
|
||||
it.runner.toHexDashString(), it.runnerName.quote(), it.runnerHex,
|
||||
it.input.quote(), it.hardware.quote()
|
||||
) + List(dataCount) { i -> it.timing.getOrNull(i)?.toString() ?: "" }
|
||||
}
|
||||
|
||||
val csv = "${header.joinToString(",")}\n${body.joinToString("\n"){ it.joinToString(",") }}"
|
||||
onDownload(csv, name.value ?: "PhoeBench-project", "csv")
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -80,8 +80,10 @@ fun ProjectView(id: Uuid, forceBack: () -> Unit) {
|
||||
IconButton({ vm.openMonitor() }) {
|
||||
Icon(Lucide.SquareTerminal, "Open monitor")
|
||||
}
|
||||
IconButton({ vm.triggerCsvDownload() }) {
|
||||
Icon(Lucide.FileDown, "Download CSV")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
owner?.let { Text("${if(public) "Public" else "Private"} project by user $it") }
|
||||
Spacer(Modifier.height(15.dp))
|
||||
|
||||
+15
-1
@@ -6,6 +6,10 @@ import androidx.compose.ui.draganddrop.*
|
||||
import androidx.compose.ui.platform.ClipEntry
|
||||
import com.github.javakeyring.Keyring
|
||||
import com.jaytux.phoebench.clients.ui.DefaultServerSelect
|
||||
import io.github.vinceglb.filekit.FileKit
|
||||
import io.github.vinceglb.filekit.dialogs.FileKitDialogException
|
||||
import io.github.vinceglb.filekit.dialogs.openFileSaver
|
||||
import io.github.vinceglb.filekit.writeString
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.engine.okhttp.*
|
||||
import kotlinx.serialization.KSerializer
|
||||
@@ -77,4 +81,14 @@ actual fun <T> drag(data: T, serializer: KSerializer<T>): DragAndDropTransferDat
|
||||
actual fun <T> drop(data: DragAndDropEvent, serializer: KSerializer<T>): T? =
|
||||
if(data.awtTransferable.isDataFlavorSupported(DataFlavor.stringFlavor))
|
||||
Json.decodeFromString(serializer, data.awtTransferable.getTransferData(DataFlavor.stringFlavor) as String)
|
||||
else null
|
||||
else null
|
||||
|
||||
actual suspend fun onDownload(contents: String, nameHint: String, extension: String) {
|
||||
try {
|
||||
val file = FileKit.openFileSaver(suggestedName = nameHint, defaultExtension = extension)
|
||||
file?.writeString(contents)
|
||||
}
|
||||
catch(e: FileKitDialogException) {
|
||||
SnackProvider.get().send("Failed to save CSV: ${e.message}")
|
||||
}
|
||||
}
|
||||
+7
-1
@@ -7,6 +7,8 @@ import androidx.compose.ui.draganddrop.DragAndDropTransferData
|
||||
import androidx.compose.ui.draganddrop.domDataTransferOrNull
|
||||
import androidx.compose.ui.platform.ClipEntry
|
||||
import com.jaytux.phoebench.clients.ui.constantServerSelect
|
||||
import io.github.vinceglb.filekit.FileKit
|
||||
import io.github.vinceglb.filekit.download
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.engine.js.*
|
||||
import kotlinx.browser.window
|
||||
@@ -93,4 +95,8 @@ actual fun <T> drag(data: T, serializer: KSerializer<T>): DragAndDropTransferDat
|
||||
actual fun <T> drop(data: DragAndDropEvent, serializer: KSerializer<T>): T? =
|
||||
data.transferData?.domDataTransferOrNull?.getData("application/json")?.let {
|
||||
Json.decodeFromString(serializer, it)
|
||||
}
|
||||
}
|
||||
|
||||
actual suspend fun onDownload(contents: String, nameHint: String, extension: String) {
|
||||
FileKit.download(contents.encodeToByteArray(), fileName = "$nameHint.$extension")
|
||||
}
|
||||
@@ -7,9 +7,9 @@ exposed = "1.3.1"
|
||||
ksoup = "0.2.6"
|
||||
sqlite = "3.53.2.0"
|
||||
mariadb = "3.5.9"
|
||||
androidx-lifecycle = "2.10.0"
|
||||
compose-multiplatform = "1.11.1"
|
||||
kotlin = "2.4.21"
|
||||
androidx-lifecycle = "2.11.0"
|
||||
compose-multiplatform = "1.12.2"
|
||||
kotlin = "2.4.10"
|
||||
kotlinx-coroutines = "1.11.0"
|
||||
ktor = "3.5.1"
|
||||
spring-sec = "7.1.0"
|
||||
@@ -24,6 +24,7 @@ shadow = "9.3.0"
|
||||
clikt = "5.0.3"
|
||||
buildconfig = "6.0.10"
|
||||
process = "1.5.1"
|
||||
filekit = "0.17.0"
|
||||
|
||||
[libraries]
|
||||
androidx-lifecycle-viewmodel = { group = "org.jetbrains.androidx.lifecycle", name = "lifecycle-viewmodel", version.ref = "androidx-lifecycle" }
|
||||
@@ -91,6 +92,7 @@ java-keystore = { module = "com.github.javakeyring:java-keyring", version.ref =
|
||||
|
||||
clikt = { module = "com.github.ajalt.clikt:clikt", version.ref = "clikt" }
|
||||
process = { module = "com.github.pgreze:kotlin-process", version.ref = "process" }
|
||||
filekit = { module = "io.github.vinceglb:filekit-dialogs-compose", version.ref = "filekit" }
|
||||
|
||||
[plugins]
|
||||
composeMultiplatform = { id = "org.jetbrains.compose", version.ref = "compose-multiplatform" }
|
||||
|
||||
Reference in new issue
Block a user