From 43e5bac871e69a50a72cc936f409ea2533d3eecf Mon Sep 17 00:00:00 2001 From: Lars Westermann Date: Mon, 10 Jun 2019 20:00:00 +0200 Subject: [PATCH] Add pool, change design, did stuf --- .../kotlin/de/kif/common/model/Room.kt | 10 +++++- .../frontend/views/calendar/CalendarEntry.kt | 1 + .../resources/style/components/_board.scss | 13 ++++--- .../resources/style/components/_calendar.scss | 32 +++++++++++++++++ .../style/components/_table-layout.scss | 11 ++++++ .../resources/style/components/_wall.scss | 6 +++- .../kotlin/de/kif/backend/database/Schema.kt | 1 + .../kif/backend/repository/RoomRepository.kt | 4 +++ .../kotlin/de/kif/backend/route/Account.kt | 6 ++-- .../kotlin/de/kif/backend/route/Calendar.kt | 28 ++++++++++++++- .../kotlin/de/kif/backend/route/Room.kt | 34 ++++++++++++++++++- .../kotlin/de/kif/backend/route/Track.kt | 11 +++--- 12 files changed, 141 insertions(+), 16 deletions(-) diff --git a/src/commonMain/kotlin/de/kif/common/model/Room.kt b/src/commonMain/kotlin/de/kif/common/model/Room.kt index f51085f..adbbab1 100644 --- a/src/commonMain/kotlin/de/kif/common/model/Room.kt +++ b/src/commonMain/kotlin/de/kif/common/model/Room.kt @@ -13,6 +13,7 @@ data class Room( val whiteboard: Boolean, val blackboard: Boolean, val accessible: Boolean, + val pool: Boolean, override val createdAt: Long = 0, override val updateAt: Long = 0 ) : Model { @@ -23,7 +24,12 @@ data class Room( mapOf( "name" to name ), mapOf( - "projector" to projector + "projector" to projector, + "internet" to internet, + "whiteboard" to whiteboard, + "blackboard" to blackboard, + "accessible" to accessible, + "pool" to pool ), mapOf( "places" to places.toDouble() ) @@ -43,6 +49,7 @@ data class Room( if (whiteboard != other.whiteboard) return false if (blackboard != other.blackboard) return false if (accessible != other.accessible) return false + if (pool != other.pool) return false return true } @@ -58,6 +65,7 @@ data class Room( result = 31 * result + whiteboard.hashCode() result = 31 * result + blackboard.hashCode() result = 31 * result + accessible.hashCode() + result = 31 * result + pool.hashCode() return result } } diff --git a/src/jsMain/kotlin/de/kif/frontend/views/calendar/CalendarEntry.kt b/src/jsMain/kotlin/de/kif/frontend/views/calendar/CalendarEntry.kt index efa1447..d3ba2ae 100644 --- a/src/jsMain/kotlin/de/kif/frontend/views/calendar/CalendarEntry.kt +++ b/src/jsMain/kotlin/de/kif/frontend/views/calendar/CalendarEntry.kt @@ -251,6 +251,7 @@ class CalendarEntry(private val calendar: CalendarBody, view: HTMLElement) : Vie language = workGroup.language.code this.workGroup = workGroup + html.removeAttribute("style") style { val size = workGroup.length / CALENDAR_GRID_WIDTH.toDouble() diff --git a/src/jsMain/resources/style/components/_board.scss b/src/jsMain/resources/style/components/_board.scss index 62a38a1..4abf210 100644 --- a/src/jsMain/resources/style/components/_board.scss +++ b/src/jsMain/resources/style/components/_board.scss @@ -31,7 +31,7 @@ bottom: 0; left: 100%; margin-left: 1rem; - border-right: solid 1px var(--table-border-color); + border-right: solid 1px var(--input-border-color); } } @@ -45,19 +45,22 @@ .board-header { height: 8rem !important; + margin-top:0.3rem; & > div { height: 100%; } &:after { - content: ''; + content: ""; position: absolute; left: 0; width: 100%; - top: 100%; - margin-top: 0.5rem; + height: 100%; border-bottom: solid 1px var(--table-border-color); + box-shadow: 0 0 4px black; + top: -1rem; + padding-top: 1.2rem; } } @@ -112,7 +115,7 @@ } .board-schedule-color { - width: 1.2rem; + width: 1.5rem; span { display: block; diff --git a/src/jsMain/resources/style/components/_calendar.scss b/src/jsMain/resources/style/components/_calendar.scss index 1f448b8..2b02f24 100644 --- a/src/jsMain/resources/style/components/_calendar.scss +++ b/src/jsMain/resources/style/components/_calendar.scss @@ -349,6 +349,7 @@ width: 12rem; position: relative; padding-left: 0.2rem; + text-align: center; &::before { content: ''; @@ -638,3 +639,34 @@ display: block; } } + +.track-legend-list { + display: flex; + line-height: 2rem; + height: 2rem; + width: 100%; + padding: 0 1rem; +} + +.track-legend { + flex-basis: 0; + flex-grow: 1; + flex-shrink: 1; + position: relative; +} + +.track-legend-color { + width: 1rem; + height: 1rem; + border-radius: 100%; + position: absolute; + left: 0; + top: 0.5rem; + background-color: var(--primary-color); +} + +.track-legend-name { + position: absolute; + top: 0; + left: 2rem; +} \ No newline at end of file diff --git a/src/jsMain/resources/style/components/_table-layout.scss b/src/jsMain/resources/style/components/_table-layout.scss index 1755184..3e94b01 100644 --- a/src/jsMain/resources/style/components/_table-layout.scss +++ b/src/jsMain/resources/style/components/_table-layout.scss @@ -22,6 +22,7 @@ th, td { padding: 0 0.6rem; + position: relative; } .action { @@ -30,6 +31,7 @@ tr { border-top: solid 1px var(--table-border-color); + position: relative; &:first-child { background-color: var(--table-header-color); @@ -148,4 +150,13 @@ &.active { display: block; } +} + +.track-table-color { + width: 1rem; + height: 1rem; + border-radius: 100%; + position: absolute !important; + top: 0.6rem; + left: 6rem; } \ No newline at end of file diff --git a/src/jsMain/resources/style/components/_wall.scss b/src/jsMain/resources/style/components/_wall.scss index 0743bfb..d493d49 100644 --- a/src/jsMain/resources/style/components/_wall.scss +++ b/src/jsMain/resources/style/components/_wall.scss @@ -51,7 +51,7 @@ .calendar-body { display: flex; - width: calc(100vw - 9.6rem); + width: calc(100vw - 8.6rem); } .calendar-row { @@ -75,6 +75,8 @@ position: absolute; top: 0; left: 0; + width: 100%; + text-align: center; } } } @@ -83,6 +85,8 @@ .calendar-cell { overflow: hidden; text-overflow: ellipsis; + width: 6rem !important; + text-align: center; span { padding: 0 0.2rem; diff --git a/src/jvmMain/kotlin/de/kif/backend/database/Schema.kt b/src/jvmMain/kotlin/de/kif/backend/database/Schema.kt index d71d65b..5d2e535 100644 --- a/src/jvmMain/kotlin/de/kif/backend/database/Schema.kt +++ b/src/jvmMain/kotlin/de/kif/backend/database/Schema.kt @@ -49,6 +49,7 @@ object DbRoom : Table() { val whiteboard = bool("whiteboard") val blackboard = bool("blackboard") val accessible = bool("accessible") + val pool = bool("pool").default(false) val createdAt = long("createdAt") val updatedAt = long("updatedAt") diff --git a/src/jvmMain/kotlin/de/kif/backend/repository/RoomRepository.kt b/src/jvmMain/kotlin/de/kif/backend/repository/RoomRepository.kt index 557e96c..571d4ba 100644 --- a/src/jvmMain/kotlin/de/kif/backend/repository/RoomRepository.kt +++ b/src/jvmMain/kotlin/de/kif/backend/repository/RoomRepository.kt @@ -25,6 +25,7 @@ object RoomRepository : Repository { val whiteboard = row[DbRoom.whiteboard] val blackboard = row[DbRoom.blackboard] val accessible = row[DbRoom.accessible] + val pool = row[DbRoom.pool] val createdAt = row[DbRoom.createdAt] val updatedAt = row[DbRoom.updatedAt] @@ -38,6 +39,7 @@ object RoomRepository : Repository { whiteboard, blackboard, accessible, + pool, createdAt, updatedAt ) @@ -61,6 +63,7 @@ object RoomRepository : Repository { it[whiteboard] = model.whiteboard it[blackboard] = model.blackboard it[accessible] = model.accessible + it[pool] = model.pool it[createdAt] = now it[updatedAt] = now }[DbRoom.id] ?: throw IllegalStateException("Cannot create model!") @@ -85,6 +88,7 @@ object RoomRepository : Repository { it[whiteboard] = model.whiteboard it[blackboard] = model.blackboard it[accessible] = model.accessible + it[pool] = model.pool it[updatedAt] = now } diff --git a/src/jvmMain/kotlin/de/kif/backend/route/Account.kt b/src/jvmMain/kotlin/de/kif/backend/route/Account.kt index 78f1705..785d29b 100644 --- a/src/jvmMain/kotlin/de/kif/backend/route/Account.kt +++ b/src/jvmMain/kotlin/de/kif/backend/route/Account.kt @@ -47,12 +47,12 @@ fun Route.account() { } } - a(href = "/account/backup", classes = "form-btn") { + a(href = "$prefix/account/backup", classes = "form-btn") { +"Sicherung" } if (user.checkPermission(Permission.ADMIN)) { - a(href = "/account/import", classes = "form-btn") { + a(href = "$prefix/account/import", classes = "form-btn") { +"Aus Wiki importieren" } } @@ -116,7 +116,7 @@ fun Route.account() { div("account-import") { form( - action = "/account/restore", + action = "$prefix/account/restore", method = FormMethod.post, encType = FormEncType.multipartFormData ) { diff --git a/src/jvmMain/kotlin/de/kif/backend/route/Calendar.kt b/src/jvmMain/kotlin/de/kif/backend/route/Calendar.kt index 55ba0f7..1750893 100644 --- a/src/jvmMain/kotlin/de/kif/backend/route/Calendar.kt +++ b/src/jvmMain/kotlin/de/kif/backend/route/Calendar.kt @@ -4,13 +4,16 @@ import com.soywiz.klock.* import com.soywiz.klock.locale.german import de.kif.backend.Configuration import de.kif.backend.isAuthenticated +import de.kif.backend.prefix import de.kif.backend.repository.RoomRepository import de.kif.backend.repository.ScheduleRepository +import de.kif.backend.repository.TrackRepository import de.kif.backend.view.respondMain import de.kif.common.CALENDAR_GRID_WIDTH import de.kif.common.model.Permission import de.kif.common.model.Room import de.kif.common.model.Schedule +import de.kif.common.model.Track import io.ktor.application.call import io.ktor.response.respondRedirect import io.ktor.routing.Route @@ -26,7 +29,6 @@ import kotlin.collections.component2 import kotlin.collections.set import kotlin.math.max import kotlin.math.min -import de.kif.backend.prefix const val MINUTES_OF_DAY = 24 * 60 @@ -150,6 +152,27 @@ fun DIV.renderCalendar( } } +fun HtmlBlockTag.renderTrackLegend(tracks: List) { + val list = listOf(null) + tracks + div("track-legend-list") { + for (track in list) { + div("track-legend") { + span("track-legend-color") { + attributes["style"] = CSSBuilder().apply { + val c = track?.color + if (c != null) { + backgroundColor = Color(c.toString()) + } + }.toString() + } + span("track-legend-name") { + +(track?.name ?: "Allgemein") + } + } + } + } +} + fun Route.calendar() { get("/calendar") { @@ -200,6 +223,7 @@ fun Route.calendar() { */ val rooms = RoomRepository.all() + val tracks = TrackRepository.all() val orientation = call.request.cookies["orientation"]?.let { name -> CalendarOrientation.values().find { it.name == name } @@ -278,6 +302,8 @@ fun Route.calendar() { } } + renderTrackLegend(tracks) + div("calendar") { attributes["data-editable"] = editable.toString() diff --git a/src/jvmMain/kotlin/de/kif/backend/route/Room.kt b/src/jvmMain/kotlin/de/kif/backend/route/Room.kt index 4cf751b..ec8cad1 100644 --- a/src/jvmMain/kotlin/de/kif/backend/route/Room.kt +++ b/src/jvmMain/kotlin/de/kif/backend/route/Room.kt @@ -221,6 +221,21 @@ fun Route.room() { +"Barrierefreier Zugang" } } + + div("form-group form-switch") { + input( + name = "pool", + classes = "form-control", + type = InputType.checkBox + ) { + id = "pool" + checked = editRoom.pool + } + label { + htmlFor = "pool" + +"PC-Pool" + } + } } div("form-group") { @@ -259,6 +274,7 @@ fun Route.room() { params["whiteboard"]?.let { room = room.copy(whiteboard = it == "on") } params["blackboard"]?.let { room = room.copy(blackboard = it == "on") } params["accessible"]?.let { room = room.copy(accessible = it == "on") } + params["pool"]?.let { room = room.copy(pool = it == "on") } RoomRepository.update(room) @@ -380,6 +396,21 @@ fun Route.room() { +"Barrierefreier Zugang" } } + + div("form-group form-switch") { + input( + name = "pool", + classes = "form-control", + type = InputType.checkBox + ) { + id = "pool" + checked = false + } + label { + htmlFor = "pool" + +"PC-Pool" + } + } } div("form-group") { @@ -411,8 +442,9 @@ fun Route.room() { val whiteboard = params["whiteboard"] == "on" val blackboard = params["blackboard"] == "on" val accessible = params["accessible"] == "on" + val pool = params["pool"] == "on" - val room = Room(null, name, places, projector, internet, whiteboard, blackboard, accessible) + val room = Room(null, name, places, projector, internet, whiteboard, blackboard, accessible, pool) RoomRepository.create(room) diff --git a/src/jvmMain/kotlin/de/kif/backend/route/Track.kt b/src/jvmMain/kotlin/de/kif/backend/route/Track.kt index dd94322..81b9d35 100644 --- a/src/jvmMain/kotlin/de/kif/backend/route/Track.kt +++ b/src/jvmMain/kotlin/de/kif/backend/route/Track.kt @@ -1,9 +1,8 @@ package de.kif.backend.route import de.kif.backend.authenticateOrRedirect +import de.kif.backend.prefix import de.kif.backend.repository.TrackRepository -import de.kif.backend.view.MainTemplate -import de.kif.backend.view.MenuTemplate import de.kif.backend.view.TableTemplate import de.kif.backend.view.respondMain import de.kif.common.Search @@ -12,7 +11,6 @@ import de.kif.common.model.Permission import de.kif.common.model.Track import io.ktor.application.call import io.ktor.html.insert -import io.ktor.html.respondHtmlTemplate import io.ktor.request.receiveParameters import io.ktor.response.respondRedirect import io.ktor.routing.Route @@ -24,7 +22,6 @@ import kotlinx.css.Display import kotlinx.html.* import kotlin.collections.set import kotlin.random.Random -import de.kif.backend.prefix fun DIV.colorPicker(color: Color?) { val colorString = color?.toString() ?: Color( @@ -126,6 +123,12 @@ fun Route.track() { } td { +u.color.toString() + + span("track-table-color") { + attributes["style"] = CSSBuilder().apply { + backgroundColor = kotlinx.css.Color(u.color.toString()) + }.toString() + } } td(classes = "action") { a("$prefix/track/${u.id}") {