aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2019-02-18 17:10:10 +0100
committerRobert Jaros <rjaros@finn.pl>2019-02-18 17:10:10 +0100
commit667b3f983a3a77865e4fb89c0cf531ce982904ac (patch)
treea65572ca6ee9ee728d8fbe8b50bc18d866316cfb
parent29f0867506334d0f7387f654e7d84b6840a1ad86 (diff)
downloadkvision-667b3f983a3a77865e4fb89c0cf531ce982904ac.tar.gz
kvision-667b3f983a3a77865e4fb89c0cf531ce982904ac.tar.bz2
kvision-667b3f983a3a77865e4fb89c0cf531ce982904ac.zip
Make kvision-remote module independent of kvision itself.
Change the default JSON serialization format of Date objects (plain long value).
-rw-r--r--build.gradle8
-rw-r--r--kvision-modules/kvision-common-types/src/main/kotlin/pl/treksoft/kvision/types/Date.kt2
-rw-r--r--kvision-modules/kvision-remote/build.gradle34
-rw-r--r--kvision-modules/kvision-remote/package.json.d/project.info3
-rw-r--r--kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt6
-rw-r--r--kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVRemoteAgent.kt1
-rw-r--r--kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt12
-rw-r--r--kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/Security.kt1
-rw-r--r--kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/Utils.kt62
-rw-r--r--kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/types/Date.kt68
-rw-r--r--kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVModules.kt8
-rw-r--r--kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt6
-rw-r--r--kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/types/Date.kt2
-rw-r--r--kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVModules.kt6
-rw-r--r--kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt6
-rw-r--r--kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/types/Date.kt2
-rw-r--r--kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt6
-rw-r--r--kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/types/Date.kt2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/Form.kt3
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/types/Date.kt6
20 files changed, 183 insertions, 61 deletions
diff --git a/build.gradle b/build.gradle
index 69d5470a..e77cfc3f 100644
--- a/build.gradle
+++ b/build.gradle
@@ -114,10 +114,10 @@ dependencies {
compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serializationVersion"
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlinVersion"
}
- compile "com.github.snabbdom:snabbdom-kotlin:0.1.1"
- compile "pl.treksoft:navigo-kotlin:0.0.3"
- compile "pl.treksoft:jquery-kotlin:0.0.4"
- compile "pl.treksoft:kotlin-observable-js:0.0.4"
+ compile "com.github.snabbdom:snabbdom-kotlin:$snabbdomKotlinVersion"
+ compile "pl.treksoft:navigo-kotlin:$navigoKotlinVersion"
+ compile "pl.treksoft:jquery-kotlin:$jqueryKotlinVersion"
+ compile "pl.treksoft:kotlin-observable-js:$kotlinObservableVersion"
}
if (!project.gradle.startParameter.taskNames.contains("dokka")) {
diff --git a/kvision-modules/kvision-common-types/src/main/kotlin/pl/treksoft/kvision/types/Date.kt b/kvision-modules/kvision-common-types/src/main/kotlin/pl/treksoft/kvision/types/Date.kt
index 274bad61..909b0b95 100644
--- a/kvision-modules/kvision-common-types/src/main/kotlin/pl/treksoft/kvision/types/Date.kt
+++ b/kvision-modules/kvision-common-types/src/main/kotlin/pl/treksoft/kvision/types/Date.kt
@@ -23,8 +23,6 @@ package pl.treksoft.kvision.types
expect val KV_DEFAULT_DATE_FORMAT: String
-expect val KV_JSON_DATE_FORMAT: String
-
expect class Date
expect fun String.toDateF(format: String = KV_DEFAULT_DATE_FORMAT): Date
diff --git a/kvision-modules/kvision-remote/build.gradle b/kvision-modules/kvision-remote/build.gradle
index b99fb199..277cce18 100644
--- a/kvision-modules/kvision-remote/build.gradle
+++ b/kvision-modules/kvision-remote/build.gradle
@@ -1,5 +1,37 @@
-apply from: "../shared.gradle"
+apply plugin: 'kotlin-platform-js'
+apply plugin: 'kotlinx-serialization'
+
+task cleanLibs(type: Delete) {
+ delete 'build/js', 'build/libs'
+}
+
+if (project.gradle.startParameter.taskNames.contains("jar")) {
+ compileKotlin2Js.dependsOn 'cleanLibs'
+}
+
+jar {
+ duplicatesStrategy = DuplicatesStrategy.EXCLUDE
+}
+
+compileKotlin2Js {
+ kotlinOptions.metaInfo = true
+ kotlinOptions.outputFile = "$project.buildDir.path/js/${project.name}.js"
+ kotlinOptions.sourceMap = !production
+ kotlinOptions.moduleKind = 'umd'
+}
+
+compileTestKotlin2Js {
+ kotlinOptions.metaInfo = true
+ kotlinOptions.outputFile = "$project.buildDir.path/js-tests/${project.name}-tests.js"
+ kotlinOptions.sourceMap = !production
+ kotlinOptions.moduleKind = 'umd'
+}
dependencies {
expectedBy project(":kvision-modules:kvision-common-remote")
+ expectedBy project(":kvision-modules:kvision-common-types")
+ compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlinVersion"
+ compile "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$coroutinesVersion"
+ compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$serializationVersion"
+ compile "pl.treksoft:jquery-kotlin:$jqueryKotlinVersion"
}
diff --git a/kvision-modules/kvision-remote/package.json.d/project.info b/kvision-modules/kvision-remote/package.json.d/project.info
deleted file mode 100644
index cfee4b2f..00000000
--- a/kvision-modules/kvision-remote/package.json.d/project.info
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "description": "KVision Remote module"
-}
diff --git a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt
index 686d955b..06dd1330 100644
--- a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt
+++ b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt
@@ -30,10 +30,10 @@ import kotlinx.serialization.stringify
import pl.treksoft.jquery.JQueryAjaxSettings
import pl.treksoft.jquery.JQueryXHR
import pl.treksoft.jquery.jQuery
-import pl.treksoft.kvision.utils.JSON
-import pl.treksoft.kvision.utils.JSON.toObj
-import pl.treksoft.kvision.utils.obj
+import pl.treksoft.kvision.remote.JSON.toObj
import kotlin.js.Promise
+import kotlin.js.then
+import kotlin.js.undefined
import kotlin.js.JSON as NativeJSON
/**
diff --git a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVRemoteAgent.kt b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVRemoteAgent.kt
index bd53407e..6054592e 100644
--- a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVRemoteAgent.kt
+++ b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVRemoteAgent.kt
@@ -25,7 +25,6 @@ import kotlinx.coroutines.asDeferred
import kotlinx.serialization.ImplicitReflectionSerializer
import kotlinx.serialization.list
import kotlinx.serialization.serializer
-import pl.treksoft.kvision.utils.JSON
import kotlin.js.js
import kotlin.reflect.KClass
import kotlin.js.JSON as NativeJSON
diff --git a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt
index cbb2978a..52c0f7c3 100644
--- a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt
+++ b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt
@@ -34,9 +34,7 @@ import kotlinx.serialization.internal.ShortSerializer
import kotlinx.serialization.internal.StringSerializer
import kotlinx.serialization.list
import kotlinx.serialization.serializer
-import pl.treksoft.kvision.types.DateSerializer
-import pl.treksoft.kvision.types.toStringF
-import pl.treksoft.kvision.utils.JSON
+import pl.treksoft.kvision.types.JsonDateSerializer
import kotlin.js.Date
import kotlin.reflect.KClass
@@ -64,7 +62,7 @@ interface RemoteAgent {
JSON.plain.stringify(StringSerializer.list as KSerializer<Any>, value)
value[0] is Date ->
@Suppress("UNCHECKED_CAST")
- JSON.plain.stringify(DateSerializer.list as KSerializer<Any>, value)
+ JSON.plain.stringify(JsonDateSerializer.list as KSerializer<Any>, value)
value[0] is Int ->
@Suppress("UNCHECKED_CAST")
JSON.plain.stringify(IntSerializer.list as KSerializer<Any>, value)
@@ -115,7 +113,7 @@ interface RemoteAgent {
is Enum<*> -> "\"$value\""
is String -> value
is Char -> "\"$value\""
- is Date -> "\"${value.toStringF()}\""
+ is Date -> "\"${value.getTime()}\""
else -> try {
@Suppress("UNCHECKED_CAST")
JSON.plain.stringify(kClass.serializer(), value)
@@ -139,7 +137,7 @@ interface RemoteAgent {
"Boolean" -> JSON.plain.parse(BooleanSerializer, value) as RET
"BoxedChar" -> JSON.plain.parse(CharSerializer, value) as RET
"Short" -> JSON.plain.parse(ShortSerializer, value) as RET
- "Date" -> JSON.plain.parse(DateSerializer, value) as RET
+ "Date" -> JSON.plain.parse(JsonDateSerializer, value) as RET
"Byte" -> JSON.plain.parse(ByteSerializer, value) as RET
else -> throw NotStandardTypeException(jsType)
}
@@ -158,7 +156,7 @@ interface RemoteAgent {
"Boolean" -> JSON.plain.parse(BooleanSerializer.list, value) as List<RET>
"BoxedChar" -> JSON.plain.parse(CharSerializer.list, value) as List<RET>
"Short" -> JSON.plain.parse(ShortSerializer.list, value) as List<RET>
- "Date" -> JSON.plain.parse(DateSerializer.list, value) as List<RET>
+ "Date" -> JSON.plain.parse(JsonDateSerializer.list, value) as List<RET>
"Byte" -> JSON.plain.parse(ByteSerializer.list, value) as List<RET>
else -> throw NotStandardTypeException(jsType)
}
diff --git a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/Security.kt b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/Security.kt
index e96744a9..fd2b5cb0 100644
--- a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/Security.kt
+++ b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/Security.kt
@@ -23,7 +23,6 @@ package pl.treksoft.kvision.remote
import kotlinx.coroutines.asDeferred
import kotlinx.serialization.Serializable
-import pl.treksoft.kvision.utils.obj
/**
* A security exception.
diff --git a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/Utils.kt b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/Utils.kt
new file mode 100644
index 00000000..273c2a65
--- /dev/null
+++ b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/Utils.kt
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2017-present Robert Jaros
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package pl.treksoft.kvision.remote
+
+import kotlinx.serialization.SerializationStrategy
+import kotlinx.serialization.context.SimpleModule
+import kotlinx.serialization.json.Json
+import pl.treksoft.kvision.types.JsonDateSerializer
+import kotlin.js.Date
+
+/**
+ * JavaScript Object type
+ */
+external class Object
+
+/**
+ * Helper function for creating JavaScript objects.
+ */
+fun obj(init: dynamic.() -> Unit): dynamic {
+ return (Object()).apply(init)
+}
+
+/**
+ * JSON utility functions
+ */
+object JSON {
+
+ val plain = Json().apply {
+ install(SimpleModule(Date::class, JsonDateSerializer))
+ }
+
+ val nonstrict = Json(strictMode = false).apply {
+ install(SimpleModule(Date::class, JsonDateSerializer))
+ }
+
+ /**
+ * An extension function to convert Serializable object to JS dynamic object
+ * @param serializer a serializer for T
+ */
+ fun <T> T.toObj(serializer: SerializationStrategy<T>): dynamic {
+ return kotlin.js.JSON.parse(plain.stringify(serializer, this))
+ }
+}
diff --git a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/types/Date.kt b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/types/Date.kt
new file mode 100644
index 00000000..8cab5348
--- /dev/null
+++ b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/types/Date.kt
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2017-present Robert Jaros
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package pl.treksoft.kvision.types
+
+import kotlinx.serialization.Decoder
+import kotlinx.serialization.Encoder
+import kotlinx.serialization.KSerializer
+import kotlinx.serialization.SerialDescriptor
+import kotlinx.serialization.internal.SerialClassDescImpl
+import kotlin.js.Date
+
+actual typealias Date = kotlin.js.Date
+
+/**
+ * JSON date serializer.
+ */
+object JsonDateSerializer : KSerializer<Date> {
+ override val descriptor: SerialDescriptor = SerialClassDescImpl("kotlin.js.Date")
+
+ override fun deserialize(decoder: Decoder): Date {
+ return Date(decoder.decodeLong())
+ }
+
+ override fun serialize(encoder: Encoder, obj: Date) {
+ encoder.encodeLong(obj.getTime().toLong())
+ }
+}
+
+/**
+ * @suppress
+ * Not used in this module.
+ */
+actual val KV_DEFAULT_DATE_FORMAT = ""
+
+/**
+ * @suppress
+ * Not used in this module.
+ */
+actual fun String.toDateF(format: String): Date {
+ TODO("Unimplemented")
+}
+
+/**
+ * @suppress
+ * Not used in this module.
+ */
+actual fun Date.toStringF(format: String): String {
+ TODO("Unimplemented")
+}
diff --git a/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVModules.kt b/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVModules.kt
index 9ae6d0e7..34b2877f 100644
--- a/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVModules.kt
+++ b/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVModules.kt
@@ -21,17 +21,11 @@
*/
package pl.treksoft.kvision.remote
-import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import org.jooby.Kooby
import org.jooby.json.Jackson
-import pl.treksoft.kvision.types.KV_JSON_DATE_FORMAT
-import java.text.SimpleDateFormat
fun Kooby.kvisionInit() {
assets("/", "/assets/index.html")
assets("/**", "/assets/{0}").onMissing(0)
- val mapper = jacksonObjectMapper().apply {
- dateFormat = SimpleDateFormat(KV_JSON_DATE_FORMAT)
- }
- use(Jackson(mapper))
+ use(Jackson())
}
diff --git a/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt b/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt
index 456bb901..d1e64ce4 100644
--- a/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt
+++ b/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt
@@ -31,8 +31,6 @@ import org.jooby.Request
import org.jooby.Response
import org.slf4j.Logger
import org.slf4j.LoggerFactory
-import pl.treksoft.kvision.types.KV_JSON_DATE_FORMAT
-import java.text.SimpleDateFormat
import kotlin.reflect.KClass
/**
@@ -46,9 +44,7 @@ actual open class KVServiceManager<T : Any> actual constructor(val serviceClass:
}
val routes: MutableList<Kooby.() -> Unit> = mutableListOf()
- val mapper = jacksonObjectMapper().apply {
- dateFormat = SimpleDateFormat(KV_JSON_DATE_FORMAT)
- }
+ val mapper = jacksonObjectMapper()
var counter: Int = 0
/**
diff --git a/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/types/Date.kt b/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/types/Date.kt
index 86fab30a..b1f72d6f 100644
--- a/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/types/Date.kt
+++ b/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/types/Date.kt
@@ -25,8 +25,6 @@ import java.text.SimpleDateFormat
actual val KV_DEFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"
-actual val KV_JSON_DATE_FORMAT = "yyyy-MM-dd HH:mm:ssZ"
-
actual typealias Date = java.util.Date
actual fun String.toDateF(format: String): Date = SimpleDateFormat(format).parse(this)
diff --git a/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVModules.kt b/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVModules.kt
index 4ca27ebd..fef3c3c6 100644
--- a/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVModules.kt
+++ b/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVModules.kt
@@ -37,14 +37,10 @@ import io.ktor.http.content.static
import io.ktor.jackson.jackson
import io.ktor.routing.routing
import io.ktor.util.AttributeKey
-import pl.treksoft.kvision.types.KV_JSON_DATE_FORMAT
-import java.text.SimpleDateFormat
fun Application.kvisionInit(vararg modules: Module) {
install(ContentNegotiation) {
- jackson {
- dateFormat = SimpleDateFormat(KV_JSON_DATE_FORMAT)
- }
+ jackson()
}
routing {
static("/") {
diff --git a/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt b/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt
index 4b67bf43..d4985adf 100644
--- a/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt
+++ b/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt
@@ -36,8 +36,6 @@ import io.ktor.util.pipeline.PipelineContext
import kotlinx.coroutines.ExperimentalCoroutinesApi
import org.slf4j.Logger
import org.slf4j.LoggerFactory
-import pl.treksoft.kvision.types.KV_JSON_DATE_FORMAT
-import java.text.SimpleDateFormat
import kotlin.reflect.KClass
/**
@@ -58,9 +56,7 @@ actual open class KVServiceManager<T : Any> actual constructor(val serviceClass:
val optionsRequests: MutableMap<String, suspend PipelineContext<Unit, ApplicationCall>.(Unit) -> Unit> =
mutableMapOf()
- val mapper = jacksonObjectMapper().apply {
- dateFormat = SimpleDateFormat(KV_JSON_DATE_FORMAT)
- }
+ val mapper = jacksonObjectMapper()
var counter: Int = 0
/**
diff --git a/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/types/Date.kt b/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/types/Date.kt
index 86fab30a..b1f72d6f 100644
--- a/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/types/Date.kt
+++ b/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/types/Date.kt
@@ -25,8 +25,6 @@ import java.text.SimpleDateFormat
actual val KV_DEFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"
-actual val KV_JSON_DATE_FORMAT = "yyyy-MM-dd HH:mm:ssZ"
-
actual typealias Date = java.util.Date
actual fun String.toDateF(format: String): Date = SimpleDateFormat(format).parse(this)
diff --git a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt
index 838abd67..66dc4b99 100644
--- a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt
+++ b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt
@@ -29,8 +29,6 @@ import kotlinx.coroutines.launch
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.context.ApplicationContext
-import pl.treksoft.kvision.types.KV_JSON_DATE_FORMAT
-import java.text.SimpleDateFormat
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse
import kotlin.reflect.KClass
@@ -56,9 +54,7 @@ actual open class KVServiceManager<T : Any> actual constructor(val serviceClass:
val optionsRequests: MutableMap<String, (HttpServletRequest, HttpServletResponse, ApplicationContext) -> Unit> =
mutableMapOf()
- val mapper = jacksonObjectMapper().apply {
- dateFormat = SimpleDateFormat(KV_JSON_DATE_FORMAT)
- }
+ val mapper = jacksonObjectMapper()
var counter: Int = 0
/**
diff --git a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/types/Date.kt b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/types/Date.kt
index 86fab30a..b1f72d6f 100644
--- a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/types/Date.kt
+++ b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/types/Date.kt
@@ -25,8 +25,6 @@ import java.text.SimpleDateFormat
actual val KV_DEFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"
-actual val KV_JSON_DATE_FORMAT = "yyyy-MM-dd HH:mm:ssZ"
-
actual typealias Date = java.util.Date
actual fun String.toDateF(format: String): Date = SimpleDateFormat(format).parse(this)
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/Form.kt b/src/main/kotlin/pl/treksoft/kvision/form/Form.kt
index ccd6363b..983b83e5 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/Form.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/Form.kt
@@ -30,7 +30,6 @@ import kotlinx.serialization.serializer
import pl.treksoft.kvision.i18n.I18n.trans
import pl.treksoft.kvision.types.DateSerializer
import pl.treksoft.kvision.types.KFile
-import pl.treksoft.kvision.types.KV_JSON_DATE_FORMAT
import pl.treksoft.kvision.types.toStringF
import pl.treksoft.kvision.utils.JSON
import pl.treksoft.kvision.utils.getContent
@@ -91,7 +90,7 @@ class Form<K : Any>(private val panel: FormPanel<K>? = null, private val seriali
val map = it.flatMap { entry ->
when (entry.value) {
is Date -> {
- listOf(entry.key to (entry.value as? Date)?.toStringF(KV_JSON_DATE_FORMAT))
+ listOf(entry.key to (entry.value as? Date)?.toStringF())
}
is List<*> -> {
@Suppress("UNCHECKED_CAST")
diff --git a/src/main/kotlin/pl/treksoft/kvision/types/Date.kt b/src/main/kotlin/pl/treksoft/kvision/types/Date.kt
index 153003ab..ffa5008a 100644
--- a/src/main/kotlin/pl/treksoft/kvision/types/Date.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/types/Date.kt
@@ -31,8 +31,6 @@ import kotlin.js.Date
actual val KV_DEFAULT_DATE_FORMAT = "YYYY-MM-DD HH:mm:ss"
-actual val KV_JSON_DATE_FORMAT = "YYYY-MM-DD HH:mm:ssZZ"
-
actual typealias Date = kotlin.js.Date
/**
@@ -60,10 +58,10 @@ object DateSerializer : KSerializer<Date> {
override val descriptor: SerialDescriptor = SerialClassDescImpl("kotlin.js.Date")
override fun deserialize(decoder: Decoder): Date {
- return decoder.decodeString().toDateF(KV_JSON_DATE_FORMAT)
+ return decoder.decodeString().toDateF()
}
override fun serialize(encoder: Encoder, obj: Date) {
- encoder.encodeString(obj.toStringF(KV_JSON_DATE_FORMAT))
+ encoder.encodeString(obj.toStringF())
}
}