diff --git a/pom.xml b/pom.xml
index df8b4ca..3f86661 100644
--- a/pom.xml
+++ b/pom.xml
@@ -15,7 +15,6 @@
4.4.0
17
- 1.8.21
false
${maven.build.timestamp}
yyyy-MM-dd HH:mm:ss
@@ -24,11 +23,31 @@
+
+ logback-classic
+ ch.qos.logback
+ 1.4.11
+
+
+ kotlin-stdlib
+ org.jetbrains.kotlin
+ 1.9.10
+
org.jetbrains.kotlinx
kotlinx-coroutines-core-jvm
1.7.3
+
+ org.jetbrains.exposed
+ exposed-jdbc
+ 0.41.1
+
+
+ org.jetbrains.exposed
+ exposed-java-time
+ 0.41.1
+
org.yaml
snakeyaml
@@ -41,9 +60,59 @@
io.insert-koin
- koin-core
+ koin-core-jvm
3.4.2
+
+ jackson-module-kotlin
+ com.fasterxml.jackson.module
+ 2.15.2
+
+
+ h2
+ com.h2database
+ 2.2.224
+
+
+ httpclient
+ org.apache.httpcomponents
+ 4.5.14
+
+
+ htmlcleaner
+ net.sourceforge.htmlcleaner
+ 2.26
+
+
+ failsafe
+ net.jodah
+ 2.4.4
+
+
+ caffeine
+ com.github.ben-manes.caffeine
+ 3.1.8
+
+
+ jackson-databind
+ com.fasterxml.jackson.core
+ 2.15.2
+
+
+ com.fasterxml.jackson.dataformat
+ jackson-dataformat-yaml
+ 2.15.2
+
+
+ com.fasterxml.jackson.datatype
+ jackson-datatype-jsr310
+ 2.15.2
+
+
+ net.java.dev.jna
+ jna-platform
+ 5.13.0
+
diff --git a/vripper-core/pom.xml b/vripper-core/pom.xml
index cdea4eb..8667de6 100644
--- a/vripper-core/pom.xml
+++ b/vripper-core/pom.xml
@@ -17,92 +17,70 @@
logback-classic
ch.qos.logback
- 1.4.11
-
-
- kotlin-reflect
- org.jetbrains.kotlin
- 1.8.22
kotlin-stdlib
org.jetbrains.kotlin
- 1.9.0
org.jetbrains.kotlinx
kotlinx-coroutines-core-jvm
- 1.7.3
org.jetbrains.exposed
exposed-jdbc
- 0.41.1
org.jetbrains.exposed
exposed-java-time
- 0.41.1
io.insert-koin
koin-core-jvm
- 3.4.2
jackson-module-kotlin
com.fasterxml.jackson.module
- 2.15.2
h2
com.h2database
- 2.2.224
httpclient
org.apache.httpcomponents
- 4.5.14
htmlcleaner
net.sourceforge.htmlcleaner
- 2.26
reactor-core
io.projectreactor
- 3.5.10
failsafe
net.jodah
- 2.4.4
caffeine
com.github.ben-manes.caffeine
- 3.1.8
jackson-databind
com.fasterxml.jackson.core
- 2.15.2
com.fasterxml.jackson.dataformat
jackson-dataformat-yaml
- 2.15.2
com.fasterxml.jackson.datatype
jackson-datatype-jsr310
- 2.15.2
net.java.dev.jna
jna-platform
- 5.13.0
@@ -128,13 +106,6 @@
-
-
- kotlin-maven-allopen
- org.jetbrains.kotlin
- ${kotlin.version}
-
-
diff --git a/vripper-core/src/main/kotlin/me/mnlr/vripper/Module.kt b/vripper-core/src/main/kotlin/me/mnlr/vripper/Module.kt
index 240c53a..9ce43b0 100644
--- a/vripper-core/src/main/kotlin/me/mnlr/vripper/Module.kt
+++ b/vripper-core/src/main/kotlin/me/mnlr/vripper/Module.kt
@@ -18,7 +18,7 @@ val coreModule = module {
SettingsService(get())
}
single {
- ImageRepositoryImpl(get())
+ ImageRepositoryImpl()
}
single {
PostDownloadStateRepositoryImpl()
diff --git a/vripper-core/src/main/kotlin/me/mnlr/vripper/download/DownloadService.kt b/vripper-core/src/main/kotlin/me/mnlr/vripper/download/DownloadService.kt
index ff0ac7b..ae05c2d 100644
--- a/vripper-core/src/main/kotlin/me/mnlr/vripper/download/DownloadService.kt
+++ b/vripper-core/src/main/kotlin/me/mnlr/vripper/download/DownloadService.kt
@@ -245,9 +245,10 @@ class DownloadService(
private fun afterJobFinish(imageDownloadRunnable: ImageDownloadRunnable) {
lock.withLock {
- running[imageDownloadRunnable.context.image.host]!!.remove(imageDownloadRunnable)
- if (!isPending(imageDownloadRunnable.context.image.postId) && !isRunning(
- imageDownloadRunnable.context.image.postId
+ val image = imageDownloadRunnable.context.image
+ running[image.host]!!.remove(imageDownloadRunnable)
+ if (!isPending(image.postId) && !isRunning(
+ image.postId
)
) {
dataTransaction.finishPost(imageDownloadRunnable.context.post)
diff --git a/vripper-core/src/main/kotlin/me/mnlr/vripper/event/Event.kt b/vripper-core/src/main/kotlin/me/mnlr/vripper/event/Event.kt
index 4c737f5..9d3e0b3 100644
--- a/vripper-core/src/main/kotlin/me/mnlr/vripper/event/Event.kt
+++ b/vripper-core/src/main/kotlin/me/mnlr/vripper/event/Event.kt
@@ -2,6 +2,6 @@ package me.mnlr.vripper.event
data class Event(val kind: Kind, val data: T?) {
enum class Kind {
- POST_CREATE, POST_UPDATE, POST_REMOVE, IMAGE_UPDATE, METADATA_UPDATE, THREAD_CREATE, THREAD_REMOVE, LOG_EVENT_UPDATE, LOG_EVENT_REMOVE, VG_USER, DOWNLOAD_STATUS, SETTINGS_UPDATE, THREAD_CLEAR
+ POST_CREATE, POST_UPDATE, POST_REMOVE, IMAGE_CREATE, IMAGE_UPDATE, METADATA_UPDATE, THREAD_CREATE, THREAD_REMOVE, LOG_EVENT_UPDATE, LOG_EVENT_REMOVE, VG_USER, DOWNLOAD_STATUS, SETTINGS_UPDATE, THREAD_CLEAR
}
}
\ No newline at end of file
diff --git a/vripper-core/src/main/kotlin/me/mnlr/vripper/event/EventBusScheduler.kt b/vripper-core/src/main/kotlin/me/mnlr/vripper/event/EventBusScheduler.kt
index 09015d2..3a9efee 100644
--- a/vripper-core/src/main/kotlin/me/mnlr/vripper/event/EventBusScheduler.kt
+++ b/vripper-core/src/main/kotlin/me/mnlr/vripper/event/EventBusScheduler.kt
@@ -6,6 +6,6 @@ import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
object EventBusScheduler {
- private val executor: ExecutorService = Executors.newSingleThreadExecutor()
+ private val executor: ExecutorService = Executors.newCachedThreadPool()
val scheduler: Scheduler = Schedulers.fromExecutor(executor)
}
\ No newline at end of file
diff --git a/vripper-core/src/main/kotlin/me/mnlr/vripper/repositories/impl/ImageRepositoryImpl.kt b/vripper-core/src/main/kotlin/me/mnlr/vripper/repositories/impl/ImageRepositoryImpl.kt
index 12914c2..a411a18 100644
--- a/vripper-core/src/main/kotlin/me/mnlr/vripper/repositories/impl/ImageRepositoryImpl.kt
+++ b/vripper-core/src/main/kotlin/me/mnlr/vripper/repositories/impl/ImageRepositoryImpl.kt
@@ -3,17 +3,15 @@ package me.mnlr.vripper.repositories.impl
import me.mnlr.vripper.entities.ImageDownloadState
import me.mnlr.vripper.entities.domain.Status
import me.mnlr.vripper.event.Event
-import me.mnlr.vripper.event.EventBus
import me.mnlr.vripper.repositories.ImageRepository
import me.mnlr.vripper.tables.ImageTable
import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
import java.util.*
-class ImageRepositoryImpl(private val eventBus: EventBus) : ImageRepository {
+class ImageRepositoryImpl : ImageRepository {
override fun save(imageDownloadState: ImageDownloadState): ImageDownloadState {
-
- val insertStatement = ImageTable.insert {
+ val id = ImageTable.insertAndGetId {
it[current] = imageDownloadState.current
it[host] = imageDownloadState.host
it[index] = imageDownloadState.index
@@ -22,11 +20,8 @@ class ImageRepositoryImpl(private val eventBus: EventBus) : ImageRepository {
it[total] = imageDownloadState.total
it[url] = imageDownloadState.url
it[postIdRef] = imageDownloadState.postIdRef
- }
- eventBus.publishEvent(Event(Event.Kind.IMAGE_UPDATE, insertStatement[ImageTable.id].value))
- return imageDownloadState.copy(
- id = insertStatement[ImageTable.id].value
- )
+ }.value
+ return imageDownloadState.copy(id = id)
}
override fun save(imageDownloadStateList: List) {
@@ -43,7 +38,7 @@ class ImageRepositoryImpl(private val eventBus: EventBus) : ImageRepository {
}
override fun deleteAllByPostId(postId: String) {
- ImageTable.deleteWhere {ImageTable.postId eq postId}
+ ImageTable.deleteWhere { ImageTable.postId eq postId }
}
override fun findByPostId(postId: String): List {
@@ -67,7 +62,7 @@ class ImageRepositoryImpl(private val eventBus: EventBus) : ImageRepository {
}
override fun stopByPostIdAndIsNotCompleted(postId: String): Int {
- return ImageTable.update({(ImageTable.postId eq postId) and (ImageTable.status neq Status.FINISHED.name)}) {
+ return ImageTable.update({ (ImageTable.postId eq postId) and (ImageTable.status neq Status.FINISHED.name) }) {
it[status] = Status.STOPPED.name
}
}
@@ -90,12 +85,11 @@ class ImageRepositoryImpl(private val eventBus: EventBus) : ImageRepository {
}
override fun update(imageDownloadState: ImageDownloadState) {
- ImageTable.update({ImageTable.id eq imageDownloadState.id}) {
+ ImageTable.update({ ImageTable.id eq imageDownloadState.id }) {
it[status] = imageDownloadState.status.name
it[current] = imageDownloadState.current
it[total] = imageDownloadState.total
}
- eventBus.publishEvent(Event(Event.Kind.IMAGE_UPDATE, imageDownloadState.id))
}
private fun transform(resultRow: ResultRow): ImageDownloadState {
diff --git a/vripper-core/src/main/kotlin/me/mnlr/vripper/repositories/impl/PostDownloadStateRepositoryImpl.kt b/vripper-core/src/main/kotlin/me/mnlr/vripper/repositories/impl/PostDownloadStateRepositoryImpl.kt
index a6cab6d..f417531 100644
--- a/vripper-core/src/main/kotlin/me/mnlr/vripper/repositories/impl/PostDownloadStateRepositoryImpl.kt
+++ b/vripper-core/src/main/kotlin/me/mnlr/vripper/repositories/impl/PostDownloadStateRepositoryImpl.kt
@@ -67,7 +67,7 @@ class PostDownloadStateRepositoryImpl :
}
override fun existByPostId(postId: String): Boolean {
- return PostTable.slice(PostTable.id).selectAll().count() > 0
+ return PostTable.slice(PostTable.id).select { PostTable.postId eq postId }.count() > 0
}
override fun setDownloadingToStopped(): Int {
diff --git a/vripper-core/src/main/kotlin/me/mnlr/vripper/services/DataTransaction.kt b/vripper-core/src/main/kotlin/me/mnlr/vripper/services/DataTransaction.kt
index 4bcf424..84bf05d 100644
--- a/vripper-core/src/main/kotlin/me/mnlr/vripper/services/DataTransaction.kt
+++ b/vripper-core/src/main/kotlin/me/mnlr/vripper/services/DataTransaction.kt
@@ -12,6 +12,7 @@ import me.mnlr.vripper.repositories.ImageRepository
import me.mnlr.vripper.repositories.MetadataRepository
import me.mnlr.vripper.repositories.PostDownloadStateRepository
import me.mnlr.vripper.repositories.ThreadRepository
+import me.mnlr.vripper.tables.ImageTable
import org.jetbrains.exposed.sql.transactions.transaction
import java.util.*
import kotlin.io.path.pathString
@@ -48,6 +49,7 @@ class DataTransaction(
fun update(imageDownloadState: ImageDownloadState) {
transaction { imageRepository.update(imageDownloadState) }
+ eventBus.publishEvent(Event(Event.Kind.IMAGE_UPDATE, imageDownloadState))
}
fun exists(postId: String): Boolean {
@@ -93,6 +95,9 @@ class DataTransaction(
private fun save(images: List) {
transaction { imageRepository.save(images) }
+ images.forEach {
+ eventBus.publishEvent(Event(Event.Kind.IMAGE_CREATE, it))
+ }
}
fun finishPost(postDownloadState: PostDownloadState) {
diff --git a/vripper-gui/pom.xml b/vripper-gui/pom.xml
index ed08b07..0bea617 100644
--- a/vripper-gui/pom.xml
+++ b/vripper-gui/pom.xml
@@ -16,20 +16,13 @@
20.0.1
-
- kotlin-reflect
- org.jetbrains.kotlin
- 1.8.22
-
kotlin-stdlib
org.jetbrains.kotlin
- 1.9.0
org.jetbrains.kotlinx
kotlinx-coroutines-core-jvm
- 1.7.3
org.jetbrains.kotlinx
@@ -138,13 +131,6 @@
-Xjsr305=strict
-
-
- kotlin-maven-allopen
- org.jetbrains.kotlin
- ${kotlin.version}
-
-
diff --git a/vripper-gui/src/main/kotlin/me/mnlr/vripper/gui/VripperGuiApplication.kt b/vripper-gui/src/main/kotlin/me/mnlr/vripper/gui/VripperGuiApplication.kt
index cf77d09..9094afa 100644
--- a/vripper-gui/src/main/kotlin/me/mnlr/vripper/gui/VripperGuiApplication.kt
+++ b/vripper-gui/src/main/kotlin/me/mnlr/vripper/gui/VripperGuiApplication.kt
@@ -38,6 +38,8 @@ class VripperGuiApplication : App(
with(stage) {
width = 1200.0
height = 600.0
+ minWidth = 600.0
+ minHeight = 400.0
icons.addAll(
listOf(
Image("icons/16x16.png"),
diff --git a/vripper-gui/src/main/kotlin/me/mnlr/vripper/gui/clipboard/ClipboardService.kt b/vripper-gui/src/main/kotlin/me/mnlr/vripper/gui/clipboard/ClipboardService.kt
index 13833b4..02466cb 100644
--- a/vripper-gui/src/main/kotlin/me/mnlr/vripper/gui/clipboard/ClipboardService.kt
+++ b/vripper-gui/src/main/kotlin/me/mnlr/vripper/gui/clipboard/ClipboardService.kt
@@ -17,6 +17,7 @@ class ClipboardService(
private val eventBusDisposable: Disposable
private var current: String? = null
private var coroutineScope = CoroutineScope(Dispatchers.JavaFx)
+ private var pollJob: Job? = null
init {
eventBusDisposable = eventBus
@@ -26,9 +27,9 @@ class ClipboardService(
}
fun init() {
- coroutineScope.cancel()
+ pollJob?.cancel()
if(settingsService.settings.clipboardSettings.enable) {
- coroutineScope.launch {
+ pollJob = coroutineScope.launch {
while (isActive) {
poll()
delay(settingsService.settings.clipboardSettings.pollingRate.toLong())
diff --git a/vripper-gui/src/main/kotlin/me/mnlr/vripper/gui/controller/ImageController.kt b/vripper-gui/src/main/kotlin/me/mnlr/vripper/gui/controller/ImageController.kt
index ceb4a18..c258be2 100644
--- a/vripper-gui/src/main/kotlin/me/mnlr/vripper/gui/controller/ImageController.kt
+++ b/vripper-gui/src/main/kotlin/me/mnlr/vripper/gui/controller/ImageController.kt
@@ -14,11 +14,7 @@ class ImageController : Controller() {
return dataTransaction.findImagesByPostId(postId).map(::mapper)
}
- fun findImageById(id: Long): Optional {
- return dataTransaction.findImageById(id).map(::mapper)
- }
-
- private fun mapper(it: ImageDownloadState): ImageModel {
+ fun mapper(it: ImageDownloadState): ImageModel {
return ImageModel(
it.id!!,
it.index + 1,
diff --git a/vripper-gui/src/main/kotlin/me/mnlr/vripper/gui/view/tables/ImagesTableView.kt b/vripper-gui/src/main/kotlin/me/mnlr/vripper/gui/view/tables/ImagesTableView.kt
index a7813ac..ab109e0 100644
--- a/vripper-gui/src/main/kotlin/me/mnlr/vripper/gui/view/tables/ImagesTableView.kt
+++ b/vripper-gui/src/main/kotlin/me/mnlr/vripper/gui/view/tables/ImagesTableView.kt
@@ -7,6 +7,7 @@ import javafx.scene.control.*
import javafx.scene.image.ImageView
import javafx.scene.input.MouseButton
import javafx.util.Callback
+import me.mnlr.vripper.entities.ImageDownloadState
import me.mnlr.vripper.event.Event
import me.mnlr.vripper.event.EventBus
import me.mnlr.vripper.gui.controller.ImageController
@@ -36,11 +37,9 @@ class ImagesTableView : Fragment("Photos") {
val disposable = eventBus
.flux()
- .filter { it!!.kind == Event.Kind.IMAGE_UPDATE }
- .map { imageController.findImageById(it!!.data as Long) }
- .filter { it.isPresent }
- .map { it.get() }
- .filter { it.postId == postId }
+ .filter { it.kind == Event.Kind.IMAGE_UPDATE }
+ .filter { (it.data as ImageDownloadState).postId == postId }
+ .map { imageController.mapper(it.data as ImageDownloadState) }
.publishOn(FxScheduler)
.doOnNext { image ->
val find = items
diff --git a/vripper-gui/src/main/kotlin/me/mnlr/vripper/gui/view/tables/PostsTableView.kt b/vripper-gui/src/main/kotlin/me/mnlr/vripper/gui/view/tables/PostsTableView.kt
index 9cb632b..02f0f1f 100644
--- a/vripper-gui/src/main/kotlin/me/mnlr/vripper/gui/view/tables/PostsTableView.kt
+++ b/vripper-gui/src/main/kotlin/me/mnlr/vripper/gui/view/tables/PostsTableView.kt
@@ -2,9 +2,13 @@ package me.mnlr.vripper.gui.view.tables
import javafx.collections.FXCollections
import javafx.collections.ObservableList
+import javafx.event.EventHandler
import javafx.scene.control.*
+import javafx.scene.control.cell.TextFieldTableCell
import javafx.scene.image.ImageView
import javafx.scene.input.MouseButton
+import javafx.stage.Stage
+import javafx.stage.StageStyle
import javafx.util.Callback
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@@ -29,6 +33,7 @@ class PostsTableView : View() {
lateinit var tableView: TableView
private var items: ObservableList = FXCollections.observableArrayList()
+ private var previewStage: Stage? = null
init {
titleProperty.bind(items.sizeProperty.map {
@@ -170,6 +175,33 @@ class PostsTableView : View() {
}
column("Title", PostModel::titleProperty) {
prefWidth = 300.0
+
+ cellFactory = Callback {
+ val cell = TextFieldTableCell()
+ cell.onMouseEntered = EventHandler {
+ previewStage?.close()
+ if(cell.text != null && cell.text.isNotBlank()) {
+ previewStage = find(mapOf(Preview::images to listOf(
+
+ ))).openWindow(stageStyle = StageStyle.UNDECORATED, owner = null)?.apply {
+ isAlwaysOnTop = true
+ x = it.screenX + 10
+ y = it.screenY
+ }
+ }
+ }
+ cell.onMouseMoved = EventHandler {
+ previewStage?.apply {
+ x = it.screenX + 10
+ y = it.screenY
+ }
+ }
+ cell.onMouseExited = EventHandler {
+ previewStage?.close()
+ }
+ cell
+ }
+
}
column("Progress", PostModel::progressProperty) {
cellFactory = Callback {
@@ -249,4 +281,19 @@ class PostsTableView : View() {
private fun openPhotos(postId: String) {
find(mapOf(ImagesTableView::postId to postId)).openModal()
}
+}
+
+
+class Preview : Fragment("Preview") {
+
+ val images: List by param()
+
+ override val root = hbox {
+ images.forEach {
+ imageview(it, lazyload = false) {
+ fitWidth = 250.0
+ isPreserveRatio = true
+ }
+ }
+ }
}
\ No newline at end of file