Bugfixes
This commit is contained in:
parent
0c6f52b0bc
commit
0cb890de07
|
@ -1,19 +1,27 @@
|
||||||
package de.kif.common
|
package de.kif.common
|
||||||
|
|
||||||
import com.soywiz.klock.DateFormat
|
import com.soywiz.klock.*
|
||||||
import com.soywiz.klock.KlockLocale
|
|
||||||
import com.soywiz.klock.format
|
|
||||||
import com.soywiz.klock.locale.german
|
import com.soywiz.klock.locale.german
|
||||||
|
|
||||||
fun formatDateTime(unix: Long) =
|
fun formatDateTime(unix: Long, timezone: Long) =
|
||||||
DateFormat("EEEE, d. MMMM y HH:mm")
|
DateFormat("EEEE, d. MMMM y HH:mm")
|
||||||
.withLocale(KlockLocale.german)
|
.withLocale(KlockLocale.german)
|
||||||
.format(unix)
|
.format(DateTimeTz.utc(DateTime(unix), TimezoneOffset(timezone.toDouble())))
|
||||||
|
|
||||||
fun formatDate(unix: Long) =
|
fun formatDate(unix: Long, timezone: Long) =
|
||||||
DateFormat("EEEE, d. MMMM y")
|
DateFormat("EEEE, d. MMMM y")
|
||||||
.withLocale(KlockLocale.german)
|
.withLocale(KlockLocale.german)
|
||||||
.format(unix)
|
.format(DateTimeTz.utc(DateTime(unix), TimezoneOffset(timezone.toDouble())))
|
||||||
|
|
||||||
|
fun formatDateWithoutYear(unix: Long, timezone: Long) =
|
||||||
|
DateFormat("EEEE, d. MMMM")
|
||||||
|
.withLocale(KlockLocale.german)
|
||||||
|
.format(DateTimeTz.utc(DateTime(unix), TimezoneOffset(timezone.toDouble())))
|
||||||
|
|
||||||
|
fun formatTime(unix: Long, timezone: Long) =
|
||||||
|
DateFormat("HH:mm")
|
||||||
|
.withLocale(KlockLocale.german)
|
||||||
|
.format(DateTimeTz.utc(DateTime(unix), TimezoneOffset(timezone.toDouble())))
|
||||||
|
|
||||||
fun formatTimeDiff(time: Long, now: Long): String {
|
fun formatTimeDiff(time: Long, now: Long): String {
|
||||||
var dt = (time - now) / 1000
|
var dt = (time - now) / 1000
|
||||||
|
@ -42,12 +50,15 @@ fun formatTimeDiff(time: Long, now: Long): String {
|
||||||
.withLocale(KlockLocale.german)
|
.withLocale(KlockLocale.german)
|
||||||
.format(time)
|
.format(time)
|
||||||
|
|
||||||
if ((ht.substringBefore(":").toIntOrNull() ?: 0) < nowHour ) {
|
if ((ht.substringBefore(":").toIntOrNull() ?: 0) < nowHour) {
|
||||||
"morgen"
|
"morgen"
|
||||||
} else "um $ht"
|
} else "um $ht"
|
||||||
}
|
}
|
||||||
hours > 0L -> {
|
hours > 0L -> {
|
||||||
"in " +hours.toString().padStart(2, '0') + ":" + (minutes + if (seconds > 0) 1 else 0).toString().padStart(2, '0')
|
"in " + hours.toString().padStart(2, '0') + ":" + (minutes + if (seconds > 0) 1 else 0).toString().padStart(
|
||||||
|
2,
|
||||||
|
'0'
|
||||||
|
)
|
||||||
}
|
}
|
||||||
minutes > 0L -> {
|
minutes > 0L -> {
|
||||||
"in 00:" + (minutes + if (seconds > 0) 1 else 0).toString().padStart(2, '0')
|
"in 00:" + (minutes + if (seconds > 0) 1 else 0).toString().padStart(2, '0')
|
||||||
|
|
|
@ -10,11 +10,16 @@ import de.kif.frontend.views.overview.initPostEdit
|
||||||
import de.kif.frontend.views.overview.initPosts
|
import de.kif.frontend.views.overview.initPosts
|
||||||
import de.kif.frontend.views.table.initTableLayout
|
import de.kif.frontend.views.table.initTableLayout
|
||||||
import de.westermann.kwebview.components.init
|
import de.westermann.kwebview.components.init
|
||||||
|
import org.w3c.dom.get
|
||||||
import kotlin.browser.document
|
import kotlin.browser.document
|
||||||
|
|
||||||
|
var timezoneOffset = 0L
|
||||||
|
|
||||||
fun main() = init {
|
fun main() = init {
|
||||||
PushServiceClient()
|
PushServiceClient()
|
||||||
|
|
||||||
|
timezoneOffset = document.body?.dataset?.get("timezone")?.toLongOrNull() ?: 0L
|
||||||
|
|
||||||
if (document.getElementsByClassName("calendar").length > 0) {
|
if (document.getElementsByClassName("calendar").length > 0) {
|
||||||
initCalendar()
|
initCalendar()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package de.kif.frontend.views
|
package de.kif.frontend.views
|
||||||
|
|
||||||
import de.kif.common.formatDate
|
import de.kif.common.formatDate
|
||||||
|
import de.kif.frontend.timezoneOffset
|
||||||
import de.westermann.kwebview.View
|
import de.westermann.kwebview.View
|
||||||
import de.westermann.kwebview.components.InputType
|
import de.westermann.kwebview.components.InputType
|
||||||
import de.westermann.kwebview.components.InputView
|
import de.westermann.kwebview.components.InputView
|
||||||
|
@ -22,7 +23,7 @@ fun initRoomConstraints() {
|
||||||
|
|
||||||
fun updateDateView(inputGroup: HTMLElement, day: Int) {
|
fun updateDateView(inputGroup: HTMLElement, day: Int) {
|
||||||
val date = referenceDate + (day * 1000 * 60 * 60 * 24)
|
val date = referenceDate + (day * 1000 * 60 * 60 * 24)
|
||||||
val dateName = formatDate(date)
|
val dateName = formatDate(date, timezoneOffset)
|
||||||
inputGroup.dataset["hint"] = dateName
|
inputGroup.dataset["hint"] = dateName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,8 +70,8 @@ fun initRoomConstraints() {
|
||||||
})
|
})
|
||||||
|
|
||||||
for (e in child.children.iterator()) {
|
for (e in child.children.iterator()) {
|
||||||
if (e.classList.contains("-day-")) {
|
if (e is HTMLInputElement && e.name.contains("-day-")) {
|
||||||
val input = InputView.wrap(e as HTMLInputElement)
|
val input = InputView.wrap(e)
|
||||||
|
|
||||||
updateDateView(child, input.value.toIntOrNull() ?: 0)
|
updateDateView(child, input.value.toIntOrNull() ?: 0)
|
||||||
input.valueProperty.onChange {
|
input.valueProperty.onChange {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import de.kif.common.formatDate
|
||||||
import de.kif.frontend.launch
|
import de.kif.frontend.launch
|
||||||
import de.kif.frontend.repository.RoomRepository
|
import de.kif.frontend.repository.RoomRepository
|
||||||
import de.kif.frontend.repository.WorkGroupRepository
|
import de.kif.frontend.repository.WorkGroupRepository
|
||||||
|
import de.kif.frontend.timezoneOffset
|
||||||
import de.westermann.kobserve.event.EventListener
|
import de.westermann.kobserve.event.EventListener
|
||||||
import de.westermann.kwebview.View
|
import de.westermann.kwebview.View
|
||||||
import de.westermann.kwebview.async
|
import de.westermann.kwebview.async
|
||||||
|
@ -41,7 +42,7 @@ fun initWorkGroupConstraints() {
|
||||||
|
|
||||||
fun updateDateView(inputGroup: HTMLElement, day: Int) {
|
fun updateDateView(inputGroup: HTMLElement, day: Int) {
|
||||||
val date = referenceDate + (day * 1000 * 60 * 60 * 24)
|
val date = referenceDate + (day * 1000 * 60 * 60 * 24)
|
||||||
val dateName = formatDate(date)
|
val dateName = formatDate(date, timezoneOffset)
|
||||||
inputGroup.dataset["hint"] = dateName
|
inputGroup.dataset["hint"] = dateName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,8 +280,8 @@ fun initWorkGroupConstraints() {
|
||||||
})
|
})
|
||||||
|
|
||||||
for (e in child.children.iterator()) {
|
for (e in child.children.iterator()) {
|
||||||
if (e.classList.contains("-day-")) {
|
if (e is HTMLInputElement && e.name.contains("-day-")) {
|
||||||
val input = InputView.wrap(e as HTMLInputElement)
|
val input = InputView.wrap(e)
|
||||||
|
|
||||||
updateDateView(child, input.value.toIntOrNull() ?: 0)
|
updateDateView(child, input.value.toIntOrNull() ?: 0)
|
||||||
input.valueProperty.onChange {
|
input.valueProperty.onChange {
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
package de.kif.frontend.views.board
|
package de.kif.frontend.views.board
|
||||||
|
|
||||||
import com.soywiz.klock.DateFormat
|
import de.kif.common.formatDate
|
||||||
import com.soywiz.klock.DateTimeTz
|
import de.kif.common.formatTime
|
||||||
import com.soywiz.klock.KlockLocale
|
|
||||||
import com.soywiz.klock.locale.german
|
|
||||||
import de.kif.frontend.launch
|
import de.kif.frontend.launch
|
||||||
import de.kif.frontend.repository.ScheduleRepository
|
import de.kif.frontend.repository.ScheduleRepository
|
||||||
|
import de.kif.frontend.timezoneOffset
|
||||||
import de.kif.frontend.views.overview.getByClassOrCreate
|
import de.kif.frontend.views.overview.getByClassOrCreate
|
||||||
import de.westermann.kwebview.interval
|
import de.westermann.kwebview.interval
|
||||||
import de.westermann.kwebview.iterator
|
import de.westermann.kwebview.iterator
|
||||||
|
@ -26,7 +25,6 @@ fun initBoard() {
|
||||||
val referenceInitTime = dateContainer.dataset["now"]?.toLongOrNull() ?: initTime
|
val referenceInitTime = dateContainer.dataset["now"]?.toLongOrNull() ?: initTime
|
||||||
val diff = initTime - referenceInitTime
|
val diff = initTime - referenceInitTime
|
||||||
|
|
||||||
|
|
||||||
val boardRunning = document.getElementsByClassName("board-running")[0] as HTMLElement
|
val boardRunning = document.getElementsByClassName("board-running")[0] as HTMLElement
|
||||||
val scheduleList = mutableListOf<BoardSchedule>()
|
val scheduleList = mutableListOf<BoardSchedule>()
|
||||||
val runningReferenceTime = boardRunning.dataset["reference"]?.toLongOrNull() ?: 0L
|
val runningReferenceTime = boardRunning.dataset["reference"]?.toLongOrNull() ?: 0L
|
||||||
|
@ -58,16 +56,8 @@ fun initBoard() {
|
||||||
interval(1000) {
|
interval(1000) {
|
||||||
val now = Date.now().toLong() + diff
|
val now = Date.now().toLong() + diff
|
||||||
|
|
||||||
val dt = DateTimeTz.fromUnixLocal(now)
|
timeView.textContent = formatTime(now, timezoneOffset)
|
||||||
|
dateView.textContent = formatDate(now, timezoneOffset)
|
||||||
timeView.textContent = DateFormat("HH:mm")
|
|
||||||
.withLocale(KlockLocale.german)
|
|
||||||
.format(dt)
|
|
||||||
|
|
||||||
dateView.textContent = DateFormat("EEEE, d. MMMM y")
|
|
||||||
.withLocale(KlockLocale.german)
|
|
||||||
.format(dt)
|
|
||||||
|
|
||||||
|
|
||||||
scheduleList.forEach { it.updateTime(now) }
|
scheduleList.forEach { it.updateTime(now) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package de.kif.frontend.views.overview
|
||||||
import de.kif.common.formatDateTime
|
import de.kif.common.formatDateTime
|
||||||
import de.kif.frontend.launch
|
import de.kif.frontend.launch
|
||||||
import de.kif.frontend.repository.PostRepository
|
import de.kif.frontend.repository.PostRepository
|
||||||
|
import de.kif.frontend.timezoneOffset
|
||||||
import de.westermann.kobserve.event.emit
|
import de.westermann.kobserve.event.emit
|
||||||
import de.westermann.kwebview.View
|
import de.westermann.kwebview.View
|
||||||
import de.westermann.kwebview.components.Link
|
import de.westermann.kwebview.components.Link
|
||||||
|
@ -45,7 +46,7 @@ class PostView(
|
||||||
}
|
}
|
||||||
|
|
||||||
contentView.innerHTML = PostRepository.htmlByUrl(p.url)
|
contentView.innerHTML = PostRepository.htmlByUrl(p.url)
|
||||||
footerView.innerText = formatDateTime(p.createdAt)
|
footerView.innerText = formatDateTime(p.createdAt, timezoneOffset)
|
||||||
|
|
||||||
emit(PostChangeEvent(postId))
|
emit(PostChangeEvent(postId))
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,13 @@ object Configuration {
|
||||||
val referenceDate: Date by lazy {
|
val referenceDate: Date by lazy {
|
||||||
val sdf = SimpleDateFormat("yyyy-MM-dd")
|
val sdf = SimpleDateFormat("yyyy-MM-dd")
|
||||||
sdf.timeZone = TimeZone.getTimeZone(ZoneId.of("UTC"))
|
sdf.timeZone = TimeZone.getTimeZone(ZoneId.of("UTC"))
|
||||||
sdf.parse(reference)
|
val calendar = Calendar.getInstance()
|
||||||
|
calendar.time = sdf.parse(reference)
|
||||||
|
calendar.set(Calendar.HOUR_OF_DAY, 0)
|
||||||
|
calendar.set(Calendar.MINUTE, 0)
|
||||||
|
calendar.set(Calendar.SECOND, 0)
|
||||||
|
calendar.set(Calendar.MILLISECOND, 0)
|
||||||
|
calendar.time
|
||||||
}
|
}
|
||||||
|
|
||||||
val offset by c(ScheduleSpec.offset)
|
val offset by c(ScheduleSpec.offset)
|
||||||
|
|
|
@ -25,7 +25,7 @@ data class BoardSchedule(
|
||||||
|
|
||||||
suspend fun getUpcoming(limit: Int = 8): List<Schedule> {
|
suspend fun getUpcoming(limit: Int = 8): List<Schedule> {
|
||||||
val now =
|
val now =
|
||||||
((Date().time + Configuration.Schedule.offset) / (1000 * 60)).toInt() -
|
((Date().time) / (1000 * 60)).toInt() -
|
||||||
(Configuration.Schedule.referenceDate.time / (1000 * 60))
|
(Configuration.Schedule.referenceDate.time / (1000 * 60))
|
||||||
return ScheduleRepository.all()
|
return ScheduleRepository.all()
|
||||||
.map {
|
.map {
|
||||||
|
@ -49,7 +49,6 @@ fun Route.board() {
|
||||||
|
|
||||||
val now = Date()
|
val now = Date()
|
||||||
val referenceTime = Configuration.Schedule.referenceDate.time
|
val referenceTime = Configuration.Schedule.referenceDate.time
|
||||||
val timeOffset = Configuration.Schedule.offset
|
|
||||||
|
|
||||||
val refDate = Configuration.Schedule.referenceDate
|
val refDate = Configuration.Schedule.referenceDate
|
||||||
|
|
||||||
|
@ -86,7 +85,7 @@ fun Route.board() {
|
||||||
min = (min / 60 - 1) * 60
|
min = (min / 60 - 1) * 60
|
||||||
max = (max / 60 + 2) * 60
|
max = (max / 60 + 2) * 60
|
||||||
|
|
||||||
val nowLocale = now.time + timeOffset
|
val nowLocale = now.time
|
||||||
respondMain(true, true) { theme ->
|
respondMain(true, true) { theme ->
|
||||||
content {
|
content {
|
||||||
val announcement = AnnouncementRepository.getAnnouncement()
|
val announcement = AnnouncementRepository.getAnnouncement()
|
||||||
|
@ -162,7 +161,7 @@ fun Route.board() {
|
||||||
div("board-logo") {
|
div("board-logo") {
|
||||||
img("KIF 47.0", "$prefix/static/images/logo.svg")
|
img("KIF 47.0", "$prefix/static/images/logo.svg")
|
||||||
div("board-header-date") {
|
div("board-header-date") {
|
||||||
attributes["data-now"] = (now.time - timeOffset).toString()
|
attributes["data-now"] = (now.time).toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package de.kif.backend.route
|
package de.kif.backend.route
|
||||||
|
|
||||||
import com.soywiz.klock.*
|
import com.soywiz.klock.*
|
||||||
import com.soywiz.klock.locale.german
|
import com.soywiz.klock.jvm.toDateTime
|
||||||
import de.kif.backend.Configuration
|
import de.kif.backend.Configuration
|
||||||
import de.kif.backend.isAuthenticated
|
import de.kif.backend.isAuthenticated
|
||||||
import de.kif.backend.prefix
|
import de.kif.backend.prefix
|
||||||
|
@ -10,6 +10,7 @@ import de.kif.backend.repository.ScheduleRepository
|
||||||
import de.kif.backend.repository.TrackRepository
|
import de.kif.backend.repository.TrackRepository
|
||||||
import de.kif.backend.view.respondMain
|
import de.kif.backend.view.respondMain
|
||||||
import de.kif.common.CALENDAR_GRID_WIDTH
|
import de.kif.common.CALENDAR_GRID_WIDTH
|
||||||
|
import de.kif.common.formatDateWithoutYear
|
||||||
import de.kif.common.model.Permission
|
import de.kif.common.model.Permission
|
||||||
import de.kif.common.model.Room
|
import de.kif.common.model.Room
|
||||||
import de.kif.common.model.Schedule
|
import de.kif.common.model.Schedule
|
||||||
|
@ -148,7 +149,7 @@ fun DIV.renderCalendar(
|
||||||
|
|
||||||
val cellSchedules = (start..end).flatMap { schedules[room]?.get(it) ?: emptyList() }
|
val cellSchedules = (start..end).flatMap { schedules[room]?.get(it) ?: emptyList() }
|
||||||
|
|
||||||
for(schedule in cellSchedules) {
|
for (schedule in cellSchedules) {
|
||||||
calendarEntry(schedule, diff, currentTime)
|
calendarEntry(schedule, diff, currentTime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -266,9 +267,7 @@ fun Route.calendar() {
|
||||||
|
|
||||||
val refDate = DateTime(Configuration.Schedule.referenceDate.time)
|
val refDate = DateTime(Configuration.Schedule.referenceDate.time)
|
||||||
val date = refDate + day.days
|
val date = refDate + day.days
|
||||||
val dateString = DateFormat("EEEE, d. MMMM")
|
val dateString = formatDateWithoutYear(date.unixMillisLong, Configuration.Schedule.offset)
|
||||||
.withLocale(KlockLocale.german)
|
|
||||||
.format(date)
|
|
||||||
|
|
||||||
respondMain {
|
respondMain {
|
||||||
content {
|
content {
|
||||||
|
|
|
@ -60,7 +60,7 @@ fun DIV.createPost(post: Post, editable: Boolean = false, additionalClasses: Str
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
div("post-footer") {
|
div("post-footer") {
|
||||||
+formatDateTime(post.createdAt)
|
+formatDateTime(post.createdAt, Configuration.Schedule.offset)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package de.kif.backend.view
|
package de.kif.backend.view
|
||||||
|
|
||||||
|
import de.kif.backend.Configuration
|
||||||
import de.kif.backend.PortalSession
|
import de.kif.backend.PortalSession
|
||||||
import de.kif.backend.Resources
|
import de.kif.backend.Resources
|
||||||
import de.kif.backend.prefix
|
import de.kif.backend.prefix
|
||||||
|
@ -74,9 +75,11 @@ class MainTemplate(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
attributes["data-timestamp"] = currentTimeMillis().toString()
|
attributes["data-timestamp"] = currentTimeMillis().toString()
|
||||||
attributes["data-signature"] = PushService.signature
|
attributes["data-signature"] = PushService.signature
|
||||||
|
attributes["data-timezone"] = Configuration.Schedule.offset.toString()
|
||||||
|
|
||||||
if (!noMenu) {
|
if (!noMenu) {
|
||||||
insert(MenuTemplate(url, user)) {}
|
insert(MenuTemplate(url, user)) {}
|
||||||
|
|
Loading…
Reference in a new issue