Add blocked rooms
This commit is contained in:
parent
4aeb97a79e
commit
d8c770054d
24 changed files with 396 additions and 84 deletions
|
@ -22,6 +22,7 @@ class PushServiceClient {
|
|||
private var timestamp = body.dataset["timestamp"]?.toLongOrNull() ?: 0L
|
||||
private val signature = body.dataset["signature"] ?: ""
|
||||
private var intervalId: Int? = null
|
||||
private var errorTimeout = ERROR_TIMEOUT
|
||||
|
||||
private fun reload() {
|
||||
val id = intervalId ?: return
|
||||
|
@ -33,6 +34,7 @@ class PushServiceClient {
|
|||
|
||||
private fun onMessage(messageBox: MessageBox) {
|
||||
body.classList.remove("offline")
|
||||
errorTimeout = ERROR_TIMEOUT
|
||||
|
||||
if (messageBox.valid && signature == messageBox.signature) {
|
||||
timestamp = messageBox.timestamp
|
||||
|
@ -54,6 +56,11 @@ class PushServiceClient {
|
|||
}
|
||||
|
||||
private fun onError(code: Int) {
|
||||
if (errorTimeout > 0) {
|
||||
errorTimeout--
|
||||
return
|
||||
}
|
||||
|
||||
if (!body.classList.contains("offline")) {
|
||||
console.log("Offline reason: $code")
|
||||
}
|
||||
|
@ -105,6 +112,10 @@ class PushServiceClient {
|
|||
request()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val ERROR_TIMEOUT = 2
|
||||
}
|
||||
}
|
||||
|
||||
abstract class MessageHandler(val repository: RepositoryType) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package de.kif.frontend
|
|||
import de.kif.frontend.views.board.initBoard
|
||||
import de.kif.frontend.views.calendar.initCalendar
|
||||
import de.kif.frontend.views.initAnnouncement
|
||||
import de.kif.frontend.views.initRoomConstraints
|
||||
import de.kif.frontend.views.initWorkGroupConstraints
|
||||
import de.kif.frontend.views.overview.initOverviewMain
|
||||
import de.kif.frontend.views.overview.initPostEdit
|
||||
|
@ -23,6 +24,9 @@ fun main() = init {
|
|||
if (document.getElementsByClassName("work-group-constraints").length > 0) {
|
||||
initWorkGroupConstraints()
|
||||
}
|
||||
if (document.getElementsByClassName("room-constraints").length > 0) {
|
||||
initRoomConstraints()
|
||||
}
|
||||
if (document.getElementsByClassName("overview-main").length > 0) {
|
||||
initOverviewMain()
|
||||
}
|
||||
|
|
57
src/jsMain/kotlin/de/kif/frontend/views/RoomConstraints.kt
Normal file
57
src/jsMain/kotlin/de/kif/frontend/views/RoomConstraints.kt
Normal file
|
@ -0,0 +1,57 @@
|
|||
package de.kif.frontend.views
|
||||
|
||||
import de.westermann.kwebview.View
|
||||
import de.westermann.kwebview.components.InputType
|
||||
import de.westermann.kwebview.components.InputView
|
||||
import de.westermann.kwebview.components.TextView
|
||||
import de.westermann.kwebview.createHtmlView
|
||||
import de.westermann.kwebview.iterator
|
||||
import org.w3c.dom.HTMLDivElement
|
||||
import org.w3c.dom.HTMLElement
|
||||
import org.w3c.dom.get
|
||||
import kotlin.browser.document
|
||||
|
||||
fun initRoomConstraints() {
|
||||
var index = 10000
|
||||
|
||||
val constraints =
|
||||
document.getElementsByClassName("room-constraints")[0] as HTMLElement
|
||||
val addButton =
|
||||
View.wrap(document.getElementsByClassName("room-constraints-add")[0] as HTMLElement)
|
||||
|
||||
addButton.onClick {
|
||||
constraints.appendChild(View.wrap(createHtmlView<HTMLDivElement>()) {
|
||||
classList += "input-group"
|
||||
html.appendChild(TextView("Gesperrt").apply {
|
||||
classList += "form-btn"
|
||||
onClick { this@wrap.html.remove() }
|
||||
}.html)
|
||||
html.appendChild(InputView(InputType.TEXT).apply {
|
||||
classList += "form-control"
|
||||
html.name = "constraint-room-day-${index}"
|
||||
placeholder = "Tag"
|
||||
}.html)
|
||||
html.appendChild(InputView(InputType.TEXT).apply {
|
||||
classList += "form-control"
|
||||
html.name = "constraint-room-start-${index}"
|
||||
placeholder = "Start"
|
||||
}.html)
|
||||
html.appendChild(InputView(InputType.TEXT).apply {
|
||||
classList += "form-control"
|
||||
html.name = "constraint-room-end-${index++}"
|
||||
placeholder = "Ende"
|
||||
}.html)
|
||||
}.html)
|
||||
}
|
||||
|
||||
for (child in constraints.children.iterator()) {
|
||||
if (child.classList.contains("input-group")) {
|
||||
val span = child.firstElementChild as HTMLElement
|
||||
|
||||
span.addEventListener("click", org.w3c.dom.events.EventListener {
|
||||
println("click")
|
||||
child.remove()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
|
@ -83,12 +83,10 @@ fun initWorkGroupConstraints() {
|
|||
html.name = "constraint-only-before-time-day-${index}"
|
||||
placeholder = "Tag (optional)"
|
||||
}.html)
|
||||
html.appendChild(InputView(InputType.NUMBER).apply {
|
||||
html.appendChild(InputView(InputType.TEXT).apply {
|
||||
classList += "form-control"
|
||||
html.name = "constraint-only-before-time-${index++}"
|
||||
min = -1337.0
|
||||
max = 133700.0
|
||||
placeholder = "Minuten"
|
||||
placeholder = "HH:MM | Min"
|
||||
}.html)
|
||||
}.html)
|
||||
}
|
||||
|
@ -106,12 +104,10 @@ fun initWorkGroupConstraints() {
|
|||
html.name = "constraint-only-after-time-day-${index}"
|
||||
placeholder = "Tag (optional)"
|
||||
}.html)
|
||||
html.appendChild(InputView(InputType.NUMBER).apply {
|
||||
html.appendChild(InputView(InputType.TEXT).apply {
|
||||
classList += "form-control"
|
||||
html.name = "constraint-only-after-time-${index++}"
|
||||
min = -1337.0
|
||||
max = 133700.0
|
||||
placeholder = "Minuten"
|
||||
placeholder = "HH:MM | Min"
|
||||
}.html)
|
||||
}.html)
|
||||
}
|
||||
|
@ -174,10 +170,8 @@ fun initWorkGroupConstraints() {
|
|||
}
|
||||
|
||||
for (child in constraints.children.iterator()) {
|
||||
console.log(child)
|
||||
if (child.classList.contains("input-group")) {
|
||||
val span = child.firstElementChild as HTMLElement
|
||||
console.log(span)
|
||||
|
||||
span.addEventListener("click", org.w3c.dom.events.EventListener {
|
||||
println("click")
|
||||
|
|
|
@ -161,6 +161,10 @@
|
|||
}
|
||||
}
|
||||
|
||||
.calendar-cell[data-blocked = "true"] {
|
||||
background-color: var(--table-header-color) !important;
|
||||
}
|
||||
|
||||
.calendar-tools {
|
||||
position: absolute;
|
||||
top: -5rem;
|
||||
|
|
|
@ -160,4 +160,48 @@
|
|||
position: absolute !important;
|
||||
top: 0.6rem;
|
||||
left: 6rem;
|
||||
}
|
||||
}
|
||||
|
||||
.room-constraints {
|
||||
position: relative;
|
||||
|
||||
& > label {
|
||||
margin-bottom: 0.8rem;
|
||||
}
|
||||
|
||||
.input-group {
|
||||
margin-bottom: 0.5rem;
|
||||
|
||||
span {
|
||||
width: 8rem;
|
||||
flex-basis: 8rem;
|
||||
flex-grow: 0;
|
||||
position: relative;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
|
||||
&:hover::after {
|
||||
content: 'LÖSCHEN';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
|
||||
font-weight: bold;
|
||||
color: var(--primary-text-color);
|
||||
background: var(--primary-color);
|
||||
}
|
||||
}
|
||||
|
||||
.form-control {
|
||||
width: 12rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.room-constraints-add {
|
||||
position: absolute;
|
||||
top: -0.5rem;
|
||||
right: 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue