This commit is contained in:
Lars Westermann 2019-06-13 09:18:11 +02:00
parent dfb07e96ce
commit 4250497f80
Signed by: lars.westermann
GPG key ID: 9D417FA5BB9D5E1D
8 changed files with 41 additions and 11 deletions

View file

@ -91,6 +91,7 @@ kotlin {
implementation 'org.xerial:sqlite-jdbc:3.25.2'
api 'mysql:mysql-connector-java:8.0.16'
api 'org.mariadb.jdbc:mariadb-java-client:1.1.7'
implementation 'org.jetbrains.exposed:exposed:0.12.2'
implementation 'org.mindrot:jbcrypt:0.4'

View file

@ -330,6 +330,7 @@
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
height: 100%;
}
.calendar-table-box {
@ -669,16 +670,15 @@
.track-legend-list {
display: flex;
line-height: 2rem;
height: 2rem;
width: 100%;
padding: 0 1rem;
flex-wrap: wrap;
}
.track-legend {
flex-basis: 0;
flex-grow: 1;
flex-shrink: 1;
flex-basis: 10rem;
position: relative;
height: 2rem;
}
.track-legend-color {
@ -694,5 +694,5 @@
.track-legend-name {
position: absolute;
top: 0;
left: 2rem;
left: 1.5rem;
}

View file

@ -98,6 +98,7 @@ fun Application.main() {
// Web socket push notifications
pushService()
calendarExport()
}
}

View file

@ -138,6 +138,7 @@ object Configuration {
val url by required<String>()
val username by required<String>()
val password by required<String>()
val name by required<String>()
}
object Database {
@ -145,6 +146,7 @@ object Configuration {
val url by c(DatabaseSpec.url)
val username by c(DatabaseSpec.username)
val password by c(DatabaseSpec.password)
val name by c(DatabaseSpec.name)
}
init {

View file

@ -10,6 +10,7 @@ import org.jetbrains.exposed.sql.SchemaUtils
import org.jetbrains.exposed.sql.transactions.TransactionManager
import org.jetbrains.exposed.sql.transactions.transaction
import java.nio.file.Files
import java.sql.Connection.TRANSACTION_READ_COMMITTED
import java.sql.Connection.TRANSACTION_SERIALIZABLE
import kotlin.system.exitProcess
@ -30,31 +31,34 @@ object Connection {
val url = Configuration.Database.url
val username = Configuration.Database.username
val password = Configuration.Database.password
val name = Configuration.Database.name
when (type) {
"mysql" -> {
Database.connect(
"jdbc:mysql://$url:3306/akplan?user=$username&password=$password&serverTimezone=UTC",
"jdbc:mysql://$url:3306/$name?user=$username&password=$password&serverTimezone=UTC",
"com.mysql.cj.jdbc.Driver",
username,
password
)
TransactionManager.manager.defaultIsolationLevel = TRANSACTION_READ_COMMITTED
}
"mariadb" -> {
Database.connect(
"jdbc:mariadb://$url:3306/akplan?user=$username&password=$password&serverTimezone=UTC",
"jdbc:mariadb://$url:3306/$name?user=$username&password=$password&serverTimezone=UTC",
"org.mariadb.jdbc.Driver",
username,
password
)
TransactionManager.manager.defaultIsolationLevel = TRANSACTION_READ_COMMITTED
}
else -> {
val dbPath = Configuration.Path.databasePath.toString()
Database.connect("jdbc:sqlite:$dbPath", "org.sqlite.JDBC")
TransactionManager.manager.defaultIsolationLevel = TRANSACTION_SERIALIZABLE
}
}
TransactionManager.manager.defaultIsolationLevel = TRANSACTION_SERIALIZABLE
try {
create()
} catch (e: ExposedSQLException) {

View file

@ -282,13 +282,13 @@ fun Route.calendar() {
content {
div("header") {
div("header-left") {
if (editable || day - 1 > range.start) {
if (editable || day - 1 >= range.start) {
a("$prefix/calendar/${day - 1}") { i("material-icons") { +"chevron_left" } }
}
span {
+dateString
}
if (editable || day + 1 < range.endInclusive) {
if (editable || day + 1 <= range.endInclusive) {
a("$prefix/calendar/${day + 1}") { i("material-icons") { +"chevron_right" } }
}
}

View file

@ -0,0 +1,21 @@
package de.kif.backend.route
import de.kif.backend.repository.ScheduleRepository
import io.ktor.application.call
import io.ktor.http.ContentType
import io.ktor.response.respondText
import io.ktor.routing.Route
import io.ktor.routing.get
fun Route.calendarExport() {
get("export/kif.ics") {
val scheduleList = ScheduleRepository.all()
//TODO
val text = ""
call.respondText(contentType = ContentType.parse("text/calendar"), text = text)
}
}

View file

@ -38,3 +38,4 @@ type = "sqlite"
url = ""
username = ""
password = ""
name = ""