mirror of https://github.com/micromata/borgbackup-butler.git

WIP
Kai Reinhard
18.57.2021 44e725655c0cf53978fa20715b015a57769a574b
WIP
2 files modified
16 ■■■■ changed files
borgbutler-server/src/main/kotlin/de/micromata/borgbutler/server/RunningMode.kt 2 ●●● patch | view | raw | blame | history
borgbutler-server/src/main/kotlin/de/micromata/borgbutler/server/WebConfig.kt 14 ●●●●● patch | view | raw | blame | history
borgbutler-server/src/main/kotlin/de/micromata/borgbutler/server/RunningMode.kt
@@ -41,9 +41,9 @@
    val runningInIDE: Boolean
        get() {
            if (!webBundled()) {
                log.warn("*** BorgButler seems to run inside an IDE. ***")
                return true
            } else {
                log.warn("*** BorgButler seems to run inside an IDE. ***")
                return false
            }
        }
borgbutler-server/src/main/kotlin/de/micromata/borgbutler/server/WebConfig.kt
@@ -6,6 +6,9 @@
import org.springframework.web.servlet.ViewResolver
import org.springframework.web.servlet.config.annotation.*
import org.springframework.web.servlet.view.InternalResourceViewResolver
import java.io.File
import java.nio.file.Paths
import kotlin.io.path.Path
private val log = KotlinLogging.logger {}
@@ -15,7 +18,16 @@
open class WebConfig : WebMvcConfigurer {
    override fun addResourceHandlers(registry: ResourceHandlerRegistry) {
        registry.addResourceHandler("/**").addResourceLocations(*CLASSPATH_RESOURCE_LOCATIONS);
        if (RunningMode.webBundled()) {
            registry.addResourceHandler("/**").addResourceLocations(*CLASSPATH_RESOURCE_LOCATIONS);
        } else {
            val localWebDir = Paths.get(".", "borgbutler-webapp", "build").toFile()
            if (localWebDir.isDirectory) {
                registry.addResourceHandler("/**").addResourceLocations(localWebDir.toURI().toString());
            } else {
                log.warn { "*** Can't locate React application. You should run npm/yarn build/start and/or check this path: ${localWebDir.absolutePath}" }
            }
        }
    }
    @Bean