Skip to content

Commit

Permalink
feat: dynamically provide version at runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
bayang committed Mar 8, 2022
1 parent f9a9df9 commit 3dce43e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ tasks.getByName<BootJar>("bootJar") {
}
}

springBoot {
buildInfo()
}

tasks.getByName<Jar>("jar") {
enabled = false
}
Expand Down
1 change: 1 addition & 0 deletions src/jelu-ui/src/model/ServerSettings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export interface ServerSettings {
metadataFetchEnabled: boolean,
metadataFetchCalibreEnabled: boolean,
appVersion: string
}
3 changes: 2 additions & 1 deletion src/jelu-ui/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const store = createStore<State>({
route: null,
serverSettings: {
metadataFetchEnabled: false,
metadataFetchCalibreEnabled: false
metadataFetchCalibreEnabled: false,
appVersion: ""
} as ServerSettings,
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package io.github.bayang.jelu.controllers
import io.github.bayang.jelu.config.JeluProperties
import io.github.bayang.jelu.dto.ServerSettingsDto
import io.swagger.v3.oas.annotations.Operation
import org.springframework.boot.info.BuildProperties
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
Expand All @@ -11,15 +12,16 @@ import org.springframework.web.bind.annotation.RestController
@RequestMapping("/api/v1")
class ServerSettingsController(
private val properties: JeluProperties,
private val buildProperties: BuildProperties
) {

@Operation(description = "Get the capabilities configured for this server, eg : is the metadata binary installed etc...")
@GetMapping(path = ["/server-settings"])
fun getServerSettings(): ServerSettingsDto {
return if (properties.metadata.calibre.path.isNullOrEmpty()) {
ServerSettingsDto(metadataFetchEnabled = false, metadataFetchCalibreEnabled = false)
ServerSettingsDto(metadataFetchEnabled = false, metadataFetchCalibreEnabled = false, buildProperties.version)
} else {
ServerSettingsDto(metadataFetchEnabled = true, metadataFetchCalibreEnabled = true)
ServerSettingsDto(metadataFetchEnabled = true, metadataFetchCalibreEnabled = true, buildProperties.version)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ data class ServerSettingsDto(
/**
* Is the calibre metadata provider activated
*/
val metadataFetchCalibreEnabled: Boolean
val metadataFetchCalibreEnabled: Boolean,
val appVersion: String
)

0 comments on commit 3dce43e

Please sign in to comment.