Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1aa87f33c4 | ||
|
|
5d4e855b8e | ||
|
|
87812d02d3 | ||
|
|
1104280c0c | ||
|
|
2e829b281b | ||
|
|
7adeb41402 | ||
|
|
c7f3fb0e6e | ||
|
|
ccabdc580c | ||
|
|
0350b80cda | ||
|
|
2dac1598ff | ||
|
|
32109debfd |
No files matched your search
@@ -6,7 +6,28 @@ on:
|
|||||||
- "main"
|
- "main"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
test-backend:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up JDK
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: temurin
|
||||||
|
java-version: "21"
|
||||||
|
cache: gradle
|
||||||
|
cache-dependency-path: |
|
||||||
|
private/minis-backend/*.gradle.kts
|
||||||
|
private/minis-backend/gradle/wrapper/gradle-wrapper.properties
|
||||||
|
|
||||||
|
- name: Run backend tests
|
||||||
|
working-directory: private/minis-backend
|
||||||
|
run: ./gradlew test --no-daemon
|
||||||
|
|
||||||
build:
|
build:
|
||||||
|
needs: test-backend
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
|||||||
@@ -2,3 +2,4 @@
|
|||||||
.idea
|
.idea
|
||||||
node_modules
|
node_modules
|
||||||
package-lock.json
|
package-lock.json
|
||||||
|
/.idea/
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
FROM gradle:7.5.1 as build_backend
|
FROM gradle:8.11-jdk-21-and-23 as build_backend
|
||||||
|
|
||||||
COPY --chown=gradle:gradle /private/minis-backend /home/gradle/src
|
COPY --chown=gradle:gradle /private/minis-backend /home/gradle/src
|
||||||
WORKDIR /home/gradle/src
|
WORKDIR /home/gradle/src
|
||||||
RUN gradle buildFatJar --no-daemon
|
RUN gradle buildFatJar --no-daemon
|
||||||
|
|
||||||
FROM node:18 as build_frontend
|
FROM node:24 as build_frontend
|
||||||
|
|
||||||
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
|
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
|
||||||
WORKDIR /home/node/app
|
WORKDIR /home/node/app
|
||||||
|
|||||||
@@ -8,8 +8,5 @@
|
|||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {}
|
||||||
"dropzone-vue3": "^1.0.2",
|
|
||||||
"rxjs": "^7.8.1"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -5,9 +5,9 @@ val logback_version: String by project
|
|||||||
val exposed_version: String by project
|
val exposed_version: String by project
|
||||||
val h2_version: String by project
|
val h2_version: String by project
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "1.9.0"
|
kotlin("jvm") version "2.3.21"
|
||||||
id("io.ktor.plugin") version "2.3.3"
|
id("io.ktor.plugin") version "3.5.1"
|
||||||
kotlin("plugin.serialization") version "1.9.0"
|
kotlin("plugin.serialization") version "2.3.21"
|
||||||
id("com.palantir.docker") version "0.36.0"
|
id("com.palantir.docker") version "0.36.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,10 +30,10 @@ dependencies {
|
|||||||
implementation("io.ktor:ktor-server-auth-jvm")
|
implementation("io.ktor:ktor-server-auth-jvm")
|
||||||
implementation("io.ktor:ktor-server-auth-jwt-jvm")
|
implementation("io.ktor:ktor-server-auth-jwt-jvm")
|
||||||
implementation("io.ktor:ktor-server-sessions-jvm")
|
implementation("io.ktor:ktor-server-sessions-jvm")
|
||||||
implementation("io.ktor:ktor-server-host-common-jvm")
|
|
||||||
implementation("io.ktor:ktor-server-cors-jvm")
|
implementation("io.ktor:ktor-server-cors-jvm")
|
||||||
implementation("io.ktor:ktor-server-content-negotiation-jvm")
|
implementation("io.ktor:ktor-server-content-negotiation-jvm")
|
||||||
implementation("io.ktor:ktor-serialization-kotlinx-json-jvm")
|
implementation("io.ktor:ktor-serialization-kotlinx-json-jvm")
|
||||||
|
implementation("io.ktor:ktor-server-swagger:$ktor_version")
|
||||||
implementation("org.jetbrains.exposed:exposed-core:$exposed_version")
|
implementation("org.jetbrains.exposed:exposed-core:$exposed_version")
|
||||||
implementation("org.jetbrains.exposed:exposed-jdbc:$exposed_version")
|
implementation("org.jetbrains.exposed:exposed-jdbc:$exposed_version")
|
||||||
implementation("io.ktor:ktor-server-netty-jvm")
|
implementation("io.ktor:ktor-server-netty-jvm")
|
||||||
@@ -52,6 +52,21 @@ dependencies {
|
|||||||
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version")
|
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ktor {
|
||||||
|
openApi {
|
||||||
|
enabled = true
|
||||||
|
codeInferenceEnabled = true
|
||||||
|
onlyCommented = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
docker {
|
docker {
|
||||||
name = "${project.name}:${project.version}"
|
name = "${project.name}:${project.version}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.test {
|
||||||
|
environment("SECRET", "testsecret")
|
||||||
|
environment("ADMIN", "admin123")
|
||||||
|
environment("PORT", "8080")
|
||||||
|
systemProperty("io.ktor.development", "true")
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
ktor_version=2.3.3
|
ktor_version=3.5.1
|
||||||
kotlin_version=1.9.0
|
kotlin_version=2.4.10
|
||||||
logback_version=1.4.14
|
logback_version=1.4.14
|
||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
exposed_version=0.43.0
|
exposed_version=0.43.0
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|||||||
@@ -3,11 +3,16 @@ package de.walamana
|
|||||||
import de.walamana.plugins.*
|
import de.walamana.plugins.*
|
||||||
import de.walamana.views.*
|
import de.walamana.views.*
|
||||||
import io.github.cdimascio.dotenv.dotenv
|
import io.github.cdimascio.dotenv.dotenv
|
||||||
|
import io.ktor.http.ContentType
|
||||||
|
import io.ktor.openapi.OpenApiInfo
|
||||||
import io.ktor.server.application.*
|
import io.ktor.server.application.*
|
||||||
import io.ktor.server.engine.*
|
import io.ktor.server.engine.*
|
||||||
import io.ktor.server.http.content.*
|
import io.ktor.server.http.content.*
|
||||||
import io.ktor.server.netty.*
|
import io.ktor.server.netty.*
|
||||||
|
import io.ktor.server.plugins.swagger.swaggerUI
|
||||||
import io.ktor.server.routing.*
|
import io.ktor.server.routing.*
|
||||||
|
import io.ktor.server.routing.openapi.OpenApiDocSource
|
||||||
|
import io.ktor.utils.io.ExperimentalKtorApi
|
||||||
|
|
||||||
//fun main() {
|
//fun main() {
|
||||||
// embeddedServer(Netty, port = 8080, host = "0.0.0.0", module = Application::module)
|
// embeddedServer(Netty, port = 8080, host = "0.0.0.0", module = Application::module)
|
||||||
@@ -23,6 +28,7 @@ fun main(args: Array<String>): Unit {
|
|||||||
EngineMain.main(args)
|
EngineMain.main(args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalKtorApi::class)
|
||||||
fun Application.module() {
|
fun Application.module() {
|
||||||
configureSecurity()
|
configureSecurity()
|
||||||
configureHTTP()
|
configureHTTP()
|
||||||
@@ -31,7 +37,7 @@ fun Application.module() {
|
|||||||
|
|
||||||
routing {
|
routing {
|
||||||
singlePageApplication {
|
singlePageApplication {
|
||||||
vue(System.getenv("FRONTEND_PATH"))
|
vue(System.getenv("FRONTEND_PATH") ?: "")
|
||||||
}
|
}
|
||||||
route("/api") {
|
route("/api") {
|
||||||
configureMinistrantenRoutes()
|
configureMinistrantenRoutes()
|
||||||
@@ -40,5 +46,12 @@ fun Application.module() {
|
|||||||
configurePlanRoutes()
|
configurePlanRoutes()
|
||||||
configureAuthenticationRoutes()
|
configureAuthenticationRoutes()
|
||||||
}
|
}
|
||||||
|
swaggerUI("/docs") {
|
||||||
|
info = OpenApiInfo("Ministranten App API", "1.0")
|
||||||
|
remotePath = "openapi.json"
|
||||||
|
source = OpenApiDocSource.Routing(ContentType.Application.Json) {
|
||||||
|
routingRoot.descendants()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,6 +45,14 @@ object MarksDao {
|
|||||||
}.resultedValues?.isNotEmpty() ?: false
|
}.resultedValues?.isNotEmpty() ?: false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun setMarks(marks: List<Mark>) = dbQuery {
|
||||||
|
Marks.batchUpsert(marks) { mark ->
|
||||||
|
this[Marks.mid] = mark.mid
|
||||||
|
this[Marks.gid] = mark.gid
|
||||||
|
this[Marks.value] = mark.value
|
||||||
|
}.isNotEmpty() ?: false
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun removeMark(ministrantId: Int, gottesdienstId: Int): Boolean = dbQuery {
|
suspend fun removeMark(ministrantId: Int, gottesdienstId: Int): Boolean = dbQuery {
|
||||||
Marks.deleteWhere {
|
Marks.deleteWhere {
|
||||||
(Marks.gid eq gottesdienstId) and
|
(Marks.gid eq gottesdienstId) and
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package de.walamana.models
|
package de.walamana.models
|
||||||
|
|
||||||
|
import at.favre.lib.crypto.bcrypt.BCrypt
|
||||||
import de.walamana.plugins.*
|
import de.walamana.plugins.*
|
||||||
import kotlinx.serialization.Contextual
|
import kotlinx.serialization.Contextual
|
||||||
import kotlinx.serialization.KSerializer
|
import kotlinx.serialization.KSerializer
|
||||||
@@ -101,16 +102,28 @@ object MinistrantenDao {
|
|||||||
) = dbQuery {
|
) = dbQuery {
|
||||||
val statement = Ministranten.insert {
|
val statement = Ministranten.insert {
|
||||||
it[Ministranten.username] = username
|
it[Ministranten.username] = username
|
||||||
it[Ministranten.passwordHash] = ""
|
it[Ministranten.passwordHash] = BCrypt.withDefaults()
|
||||||
|
.hashToString(SALT_ROUNDS, passwordHash.toCharArray())
|
||||||
it[Ministranten.firstname] = firstname
|
it[Ministranten.firstname] = firstname
|
||||||
it[Ministranten.lastname] = lastname
|
it[Ministranten.lastname] = lastname
|
||||||
it[Ministranten.birthday] = birthday?.time
|
it[Ministranten.birthday] = birthday?.time
|
||||||
it[Ministranten.privileges] = privileges.joinToString(",")
|
it[Ministranten.privileges] = privileges.joinToString(",")
|
||||||
}
|
}
|
||||||
Security.setPassword(username, passwordHash)
|
|
||||||
statement.resultedValues?.singleOrNull()?.let(::resultRowToMinistrant)
|
statement.resultedValues?.singleOrNull()?.let(::resultRowToMinistrant)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun getMinistrantById(id: Int): Ministrant? = dbQuery {
|
||||||
|
Ministranten.select(Ministranten.id eq id).map {
|
||||||
|
resultRowToMinistrant(it)
|
||||||
|
}.firstOrNull()
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun getMinistrantenById(ids: List<Int>): List<Ministrant> = dbQuery {
|
||||||
|
Ministranten.select { Ministranten.id inList ids }.map {
|
||||||
|
resultRowToMinistrant(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun deleteMinistrant(id: Int): Boolean = dbQuery {
|
suspend fun deleteMinistrant(id: Int): Boolean = dbQuery {
|
||||||
Ministranten.deleteWhere { Ministranten.id eq id } > 0
|
Ministranten.deleteWhere { Ministranten.id eq id } > 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ fun Application.configureDatabases() {
|
|||||||
SchemaUtils.create(Gottesdienste)
|
SchemaUtils.create(Gottesdienste)
|
||||||
SchemaUtils.create(Marks)
|
SchemaUtils.create(Marks)
|
||||||
// TODO Add proper versioning and migration for database
|
// TODO Add proper versioning and migration for database
|
||||||
exec("ALTER TABLE MINISTRANTEN ALTER COLUMN birthday BIGINT NULL;")
|
exec("ALTER TABLE MINISTRANTEN ALTER COLUMN birthday DROP NOT NULL;")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package de.walamana.plugins
|
|||||||
import at.favre.lib.crypto.bcrypt.BCrypt
|
import at.favre.lib.crypto.bcrypt.BCrypt
|
||||||
import com.auth0.jwt.JWT
|
import com.auth0.jwt.JWT
|
||||||
import com.auth0.jwt.algorithms.Algorithm
|
import com.auth0.jwt.algorithms.Algorithm
|
||||||
|
import com.auth0.jwt.interfaces.Claim
|
||||||
import com.auth0.jwt.interfaces.Payload
|
import com.auth0.jwt.interfaces.Payload
|
||||||
import de.walamana.models.Ministrant
|
import de.walamana.models.Ministrant
|
||||||
import de.walamana.models.MinistrantenDao
|
import de.walamana.models.MinistrantenDao
|
||||||
@@ -13,7 +14,7 @@ import io.ktor.server.auth.jwt.*
|
|||||||
import io.ktor.server.response.*
|
import io.ktor.server.response.*
|
||||||
import io.ktor.server.routing.*
|
import io.ktor.server.routing.*
|
||||||
import io.ktor.server.sessions.*
|
import io.ktor.server.sessions.*
|
||||||
import java.util.*
|
import java.util.Date
|
||||||
|
|
||||||
|
|
||||||
const val SALT_ROUNDS = 10;
|
const val SALT_ROUNDS = 10;
|
||||||
@@ -56,6 +57,22 @@ fun Application.getJWTEnvironment(): JWTEnvironment {
|
|||||||
|
|
||||||
fun Payload.username() = getClaim("username").asString()
|
fun Payload.username() = getClaim("username").asString()
|
||||||
fun Payload.mid() = getClaim("id").asInt()
|
fun Payload.mid() = getClaim("id").asInt()
|
||||||
|
fun Payload.privileges(): List<String> {
|
||||||
|
val claim = getClaim("privileges")
|
||||||
|
return if (claim.isNull || claim.asList(String::class.java).isNullOrEmpty()) emptyList() else claim.asList(String::class.java)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Payload.canAccessMinistrant(username: String): Boolean {
|
||||||
|
return this.username() == "admin" || this.privileges().contains(username)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Payload.canAccessMinistranten(usernames: List<String>): Boolean {
|
||||||
|
for (username in usernames) {
|
||||||
|
if(!canAccessMinistrant(username))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
object Security {
|
object Security {
|
||||||
|
|||||||
@@ -25,14 +25,6 @@ fun Application.configureSerialization() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
routing {
|
|
||||||
get("/json/kotlinx-serialization") {
|
|
||||||
println("Test")
|
|
||||||
// call.respond("Test")
|
|
||||||
call.respond(mapOf("hello" to "world"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typealias CommaSeperatedStringList = @Serializable(StringListAsCommaSeperatedString::class) List<String>;
|
typealias CommaSeperatedStringList = @Serializable(StringListAsCommaSeperatedString::class) List<String>;
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import io.ktor.server.auth.jwt.*
|
|||||||
import io.ktor.server.request.*
|
import io.ktor.server.request.*
|
||||||
import io.ktor.server.response.*
|
import io.ktor.server.response.*
|
||||||
import io.ktor.server.routing.*
|
import io.ktor.server.routing.*
|
||||||
|
import io.ktor.server.routing.openapi.describe
|
||||||
|
import io.ktor.utils.io.ExperimentalKtorApi
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
@@ -44,6 +46,7 @@ data class PasswordResetRequest(
|
|||||||
val username: String
|
val username: String
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@OptIn(ExperimentalKtorApi::class)
|
||||||
fun Route.configureAuthenticationRoutes() {
|
fun Route.configureAuthenticationRoutes() {
|
||||||
route("/auth") {
|
route("/auth") {
|
||||||
post {
|
post {
|
||||||
@@ -122,5 +125,7 @@ fun Route.configureAuthenticationRoutes() {
|
|||||||
call.respond(AuthenticationResult(true, newToken, ministrant.privileges))
|
call.respond(AuthenticationResult(true, newToken, ministrant.privileges))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}.describe {
|
||||||
|
tag("Authentication")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,22 +2,33 @@ package de.walamana.views
|
|||||||
|
|
||||||
import de.walamana.models.Gottesdienst
|
import de.walamana.models.Gottesdienst
|
||||||
import de.walamana.models.GottesdiensteDao
|
import de.walamana.models.GottesdiensteDao
|
||||||
|
import de.walamana.plugins.getJWTEnvironment
|
||||||
|
import de.walamana.plugins.username
|
||||||
import de.walamana.service.ZelebrationsplanParser
|
import de.walamana.service.ZelebrationsplanParser
|
||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
import io.ktor.http.content.*
|
import io.ktor.http.content.*
|
||||||
import io.ktor.server.application.*
|
import io.ktor.server.application.*
|
||||||
|
import io.ktor.server.auth.*
|
||||||
|
import io.ktor.server.auth.jwt.*
|
||||||
import io.ktor.server.request.*
|
import io.ktor.server.request.*
|
||||||
import io.ktor.server.response.*
|
import io.ktor.server.response.*
|
||||||
import io.ktor.server.routing.*
|
import io.ktor.server.routing.*
|
||||||
|
import io.ktor.server.routing.openapi.describe
|
||||||
import io.ktor.server.util.*
|
import io.ktor.server.util.*
|
||||||
|
import io.ktor.utils.io.ExperimentalKtorApi
|
||||||
|
|
||||||
|
@OptIn(ExperimentalKtorApi::class)
|
||||||
fun Route.configureGottesdiensteRoutes() {
|
fun Route.configureGottesdiensteRoutes() {
|
||||||
|
authenticate {
|
||||||
route("/gottesdienste") {
|
route("/gottesdienste") {
|
||||||
get {
|
get {
|
||||||
|
val principal = call.principal<JWTPrincipal>() ?: return@get call.respond(HttpStatusCode.Unauthorized)
|
||||||
val data = GottesdiensteDao.allGottesdienste()
|
val data = GottesdiensteDao.allGottesdienste()
|
||||||
call.respond(data)
|
call.respond(data)
|
||||||
}
|
}
|
||||||
put {
|
put {
|
||||||
|
val principal = call.principal<JWTPrincipal>() ?: return@put call.respond(HttpStatusCode.Unauthorized)
|
||||||
|
if (principal.payload.username() != "admin") return@put call.respond(HttpStatusCode.Forbidden, mapOf("msg" to "Nur Admin kann Gottesdienste erstellen"))
|
||||||
val data = call.receive<Gottesdienst>()
|
val data = call.receive<Gottesdienst>()
|
||||||
val gottesdienst = GottesdiensteDao.createGottesdienst(
|
val gottesdienst = GottesdiensteDao.createGottesdienst(
|
||||||
data.name,
|
data.name,
|
||||||
@@ -28,7 +39,8 @@ fun Route.configureGottesdiensteRoutes() {
|
|||||||
call.respond(mapOf("id" to gottesdienst?.id))
|
call.respond(mapOf("id" to gottesdienst?.id))
|
||||||
}
|
}
|
||||||
patch {
|
patch {
|
||||||
// TODO: Access only by admin
|
val principal = call.principal<JWTPrincipal>() ?: return@patch call.respond(HttpStatusCode.Unauthorized)
|
||||||
|
if (principal.payload.username() != "admin") return@patch call.respond(HttpStatusCode.Forbidden, mapOf("msg" to "Nur Admin kann Gottesdienste aktualisieren"))
|
||||||
val data = call.receive<Gottesdienst>()
|
val data = call.receive<Gottesdienst>()
|
||||||
val changed = GottesdiensteDao.updateGottesdienst(
|
val changed = GottesdiensteDao.updateGottesdienst(
|
||||||
data.id,
|
data.id,
|
||||||
@@ -40,12 +52,16 @@ fun Route.configureGottesdiensteRoutes() {
|
|||||||
call.respond(HttpStatusCode.OK)
|
call.respond(HttpStatusCode.OK)
|
||||||
}
|
}
|
||||||
delete {
|
delete {
|
||||||
val id = call.request.queryParameters["id"]?.toInt() ?: TODO("fail")
|
val principal = call.principal<JWTPrincipal>() ?: return@delete call.respond(HttpStatusCode.Unauthorized)
|
||||||
|
if (principal.payload.username() != "admin") return@delete call.respond(HttpStatusCode.Forbidden, mapOf("msg" to "Nur Admin kann Gottesdienste löschen"))
|
||||||
|
val id = call.request.queryParameters["id"]?.toInt() ?: return@delete call.respond(HttpStatusCode.BadRequest, mapOf("msg" to "Missing id parameter"))
|
||||||
GottesdiensteDao.deleteGottesdienst(id)
|
GottesdiensteDao.deleteGottesdienst(id)
|
||||||
call.respond(HttpStatusCode.OK)
|
call.respond(HttpStatusCode.OK)
|
||||||
}
|
}
|
||||||
|
|
||||||
post("/parseZelebrationsplan") {
|
post("/parseZelebrationsplan") {
|
||||||
|
val principal = call.principal<JWTPrincipal>() ?: return@post call.respond(HttpStatusCode.Unauthorized)
|
||||||
|
if (principal.payload.username() != "admin") return@post call.respond(HttpStatusCode.Forbidden, mapOf("msg" to "Nur Admin kann Pläne hochladen"))
|
||||||
val id = call.parameters.getOrFail("id").toInt()
|
val id = call.parameters.getOrFail("id").toInt()
|
||||||
val multipartData = call.receiveMultipart()
|
val multipartData = call.receiveMultipart()
|
||||||
multipartData.forEachPart { part ->
|
multipartData.forEachPart { part ->
|
||||||
@@ -56,5 +72,8 @@ fun Route.configureGottesdiensteRoutes() {
|
|||||||
part.dispose()
|
part.dispose()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}.describe {
|
||||||
|
tag("Gottesdienste")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,46 +1,75 @@
|
|||||||
package de.walamana.views
|
package de.walamana.views
|
||||||
|
|
||||||
import de.walamana.models.*
|
import de.walamana.models.*
|
||||||
|
import de.walamana.plugins.canAccessMinistrant
|
||||||
|
import de.walamana.plugins.canAccessMinistranten
|
||||||
|
import de.walamana.plugins.mid
|
||||||
|
import de.walamana.plugins.username
|
||||||
|
import de.walamana.service.PlanDao
|
||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
import io.ktor.server.application.*
|
import io.ktor.server.application.*
|
||||||
|
import io.ktor.server.auth.*
|
||||||
|
import io.ktor.server.auth.jwt.*
|
||||||
import io.ktor.server.request.*
|
import io.ktor.server.request.*
|
||||||
import io.ktor.server.response.*
|
import io.ktor.server.response.*
|
||||||
import io.ktor.server.routing.*
|
import io.ktor.server.routing.*
|
||||||
|
import io.ktor.server.routing.openapi.describe
|
||||||
import io.ktor.server.util.*
|
import io.ktor.server.util.*
|
||||||
|
import io.ktor.utils.io.ExperimentalKtorApi
|
||||||
|
|
||||||
|
|
||||||
|
@OptIn(ExperimentalKtorApi::class)
|
||||||
fun Route.configureMarksView() {
|
fun Route.configureMarksView() {
|
||||||
|
authenticate {
|
||||||
route("/marks") {
|
route("/marks") {
|
||||||
get {
|
get {
|
||||||
val data = MarksDao.allMarksForPlan(call.receiveParameters().getOrFail("id").toInt())
|
val principal = call.principal<JWTPrincipal>() ?: return@get call.respond(HttpStatusCode.Unauthorized)
|
||||||
|
val planId = call.request.queryParameters["id"]?.toInt()
|
||||||
|
?: return@get call.respond(HttpStatusCode.BadRequest, mapOf("msg" to "Missing id parameter"))
|
||||||
|
val plan = PlanDao.constructPlan(planId, isAnonymous = false)
|
||||||
|
val data = MarksDao.allMarksForPlan(planId)
|
||||||
call.respond(data)
|
call.respond(data)
|
||||||
}
|
}
|
||||||
put {
|
patch {
|
||||||
|
val principal = call.principal<JWTPrincipal>() ?: return@patch call.respond(HttpStatusCode.Unauthorized)
|
||||||
val changedMarks = call.receive<List<Mark>>()
|
val changedMarks = call.receive<List<Mark>>()
|
||||||
for(changedMark in changedMarks) {
|
val ministrantenIds = changedMarks.map { it.mid }.distinct()
|
||||||
val mark = MarksDao.setMark(
|
val ministrantenUsernames = MinistrantenDao.getMinistrantenById(ministrantenIds).map { it.username }
|
||||||
changedMark.mid,
|
if (ministrantenUsernames.size != ministrantenIds.size) {
|
||||||
changedMark.gid,
|
return@patch call.respond(
|
||||||
changedMark.value
|
HttpStatusCode.BadRequest,
|
||||||
|
mapOf("msg" to "Es wurden ungültige Ministranten IDs angegeben.")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
call.respond(HttpStatusCode.OK)
|
if (!principal.payload.canAccessMinistranten(ministrantenUsernames)) {
|
||||||
|
return@patch call.respond(
|
||||||
|
HttpStatusCode.Forbidden,
|
||||||
|
mapOf("msg" to "Sie haben keine Berechtigung für diese Ministrianten")
|
||||||
|
)
|
||||||
}
|
}
|
||||||
patch {
|
if (!MarksDao.setMarks(changedMarks)) {
|
||||||
// TODO: Access only by admin
|
return@patch call.respond(
|
||||||
val changedMarks = call.receive<List<Mark>>()
|
HttpStatusCode.InternalServerError,
|
||||||
for(changedMark in changedMarks) {
|
mapOf("msg" to "Server konnte Änderungen nicht speichern")
|
||||||
val mark = MarksDao.setMark(
|
|
||||||
changedMark.mid,
|
|
||||||
changedMark.gid,
|
|
||||||
changedMark.value
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
call.respond(HttpStatusCode.OK)
|
call.respond(HttpStatusCode.OK)
|
||||||
}
|
}
|
||||||
delete {
|
delete {
|
||||||
GottesdiensteDao.deleteGottesdienst(call.receiveParameters().getOrFail("id").toInt())
|
val principal = call.principal<JWTPrincipal>() ?: return@delete call.respond(HttpStatusCode.Unauthorized)
|
||||||
|
val ministerId = call.request.queryParameters["mid"]?.toInt() ?: return@delete call.respond(HttpStatusCode.BadRequest, mapOf("msg" to "Missing mid parameter"))
|
||||||
|
val gottesdienstId = call.request.queryParameters["gid"]?.toInt() ?: return@delete call.respond(HttpStatusCode.BadRequest, mapOf("msg" to "Missing gid parameter"))
|
||||||
|
val ministantUsername = if (ministerId == 0) "admin" else {
|
||||||
|
MinistrantenDao.getMinistrantById(ministerId)?.username ?: return@delete call.respond(HttpStatusCode.BadRequest, mapOf("msg" to "Ungültige Ministrianten-ID"))
|
||||||
|
}
|
||||||
|
if (!principal.payload.canAccessMinistrant(ministantUsername)) {
|
||||||
|
return@delete call.respond(HttpStatusCode.Forbidden, mapOf("msg" to "Sie haben keine Berechtigung für diese Ministrianten"))
|
||||||
|
}
|
||||||
|
MarksDao.removeMark(ministerId, gottesdienstId)
|
||||||
call.respond(HttpStatusCode.OK)
|
call.respond(HttpStatusCode.OK)
|
||||||
}
|
}
|
||||||
|
}.describe {
|
||||||
|
tag("Marks")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,21 +3,31 @@ package de.walamana.views
|
|||||||
import de.walamana.models.Ministrant
|
import de.walamana.models.Ministrant
|
||||||
import de.walamana.models.MinistrantenDao
|
import de.walamana.models.MinistrantenDao
|
||||||
import de.walamana.models.SimplifiedMinistrant
|
import de.walamana.models.SimplifiedMinistrant
|
||||||
|
import de.walamana.plugins.username
|
||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
import io.ktor.server.application.*
|
import io.ktor.server.application.*
|
||||||
|
import io.ktor.server.auth.*
|
||||||
|
import io.ktor.server.auth.jwt.*
|
||||||
import io.ktor.server.request.*
|
import io.ktor.server.request.*
|
||||||
import io.ktor.server.response.*
|
import io.ktor.server.response.*
|
||||||
import io.ktor.server.routing.*
|
import io.ktor.server.routing.*
|
||||||
|
import io.ktor.server.routing.openapi.describe
|
||||||
import io.ktor.server.util.*
|
import io.ktor.server.util.*
|
||||||
|
import io.ktor.utils.io.ExperimentalKtorApi
|
||||||
|
|
||||||
|
@ExperimentalKtorApi
|
||||||
fun Route.configureMinistrantenRoutes() {
|
fun Route.configureMinistrantenRoutes() {
|
||||||
|
authenticate {
|
||||||
route("/ministranten") {
|
route("/ministranten") {
|
||||||
get {
|
get {
|
||||||
|
call.principal<JWTPrincipal>() ?: return@get call.respond(HttpStatusCode.Unauthorized)
|
||||||
val data = MinistrantenDao.allMinistranten();
|
val data = MinistrantenDao.allMinistranten();
|
||||||
call.respond(data)
|
call.respond(data)
|
||||||
}
|
}
|
||||||
put {
|
put {
|
||||||
|
val principal = call.principal<JWTPrincipal>() ?: return@put call.respond(HttpStatusCode.Unauthorized)
|
||||||
val data = call.receive<Ministrant>()
|
val data = call.receive<Ministrant>()
|
||||||
|
if (principal.payload.username() != "admin") return@put call.respond(HttpStatusCode.Forbidden, mapOf("msg" to "Nur Admin kann Ministrianten erstellen"))
|
||||||
val passwordHash = data.passwordHash ?: return@put
|
val passwordHash = data.passwordHash ?: return@put
|
||||||
val ministrant = MinistrantenDao.createMinistrant(
|
val ministrant = MinistrantenDao.createMinistrant(
|
||||||
data.username,
|
data.username,
|
||||||
@@ -30,11 +40,12 @@ fun Route.configureMinistrantenRoutes() {
|
|||||||
call.respond(mapOf("id" to ministrant?.id))
|
call.respond(mapOf("id" to ministrant?.id))
|
||||||
}
|
}
|
||||||
patch {
|
patch {
|
||||||
// TODO: Access only by admin
|
val principal = call.principal<JWTPrincipal>() ?: return@patch call.respond(HttpStatusCode.Unauthorized)
|
||||||
|
if (principal.payload.username() != "admin") return@patch call.respond(HttpStatusCode.Forbidden, mapOf("msg" to "Nur Admin kann Ministrianten aktualisieren"))
|
||||||
val simple = false
|
val simple = false
|
||||||
if(simple) {
|
if(simple) {
|
||||||
val data = call.receive<SimplifiedMinistrant>()
|
val data = call.receive<SimplifiedMinistrant>()
|
||||||
val changed = MinistrantenDao.updateMinistrant(
|
MinistrantenDao.updateMinistrant(
|
||||||
id = data.id,
|
id = data.id,
|
||||||
username = data.username,
|
username = data.username,
|
||||||
firstname = data.firstname,
|
firstname = data.firstname,
|
||||||
@@ -42,7 +53,7 @@ fun Route.configureMinistrantenRoutes() {
|
|||||||
)
|
)
|
||||||
}else{
|
}else{
|
||||||
val data = call.receive<Ministrant>()
|
val data = call.receive<Ministrant>()
|
||||||
val changed = MinistrantenDao.updateMinistrant(
|
MinistrantenDao.updateMinistrant(
|
||||||
data.id,
|
data.id,
|
||||||
data.username,
|
data.username,
|
||||||
null,
|
null,
|
||||||
@@ -55,9 +66,14 @@ fun Route.configureMinistrantenRoutes() {
|
|||||||
call.respond(HttpStatusCode.OK)
|
call.respond(HttpStatusCode.OK)
|
||||||
}
|
}
|
||||||
delete {
|
delete {
|
||||||
val id = call.request.queryParameters["id"]?.toInt() ?: TODO("fail")
|
val principal = call.principal<JWTPrincipal>() ?: return@delete call.respond(HttpStatusCode.Unauthorized)
|
||||||
|
if (principal.payload.username() != "admin") return@delete call.respond(HttpStatusCode.Forbidden, mapOf("msg" to "Nur Admin kann Ministrianten löschen"))
|
||||||
|
val id = call.request.queryParameters["id"]?.toInt() ?: return@delete call.respond(HttpStatusCode.BadRequest, mapOf("msg" to "Missing id parameter"))
|
||||||
MinistrantenDao.deleteMinistrant(id)
|
MinistrantenDao.deleteMinistrant(id)
|
||||||
call.respond(HttpStatusCode.OK)
|
call.respond(HttpStatusCode.OK)
|
||||||
}
|
}
|
||||||
|
}.describe {
|
||||||
|
tag("Ministranten")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,16 +3,20 @@ package de.walamana.views
|
|||||||
import de.walamana.models.GottesdienstGroup
|
import de.walamana.models.GottesdienstGroup
|
||||||
import de.walamana.models.GottesdienstGroupDao
|
import de.walamana.models.GottesdienstGroupDao
|
||||||
import de.walamana.models.GottesdienstGroups
|
import de.walamana.models.GottesdienstGroups
|
||||||
import de.walamana.plugins.getJWTEnvironment
|
import de.walamana.plugins.username
|
||||||
import de.walamana.service.PlanDao
|
import de.walamana.service.PlanDao
|
||||||
|
import io.ktor.http.*
|
||||||
import io.ktor.server.application.*
|
import io.ktor.server.application.*
|
||||||
import io.ktor.server.auth.*
|
import io.ktor.server.auth.*
|
||||||
import io.ktor.server.auth.jwt.*
|
import io.ktor.server.auth.jwt.*
|
||||||
import io.ktor.server.request.*
|
import io.ktor.server.request.*
|
||||||
import io.ktor.server.response.*
|
import io.ktor.server.response.*
|
||||||
import io.ktor.server.routing.*
|
import io.ktor.server.routing.*
|
||||||
|
import io.ktor.server.routing.openapi.describe
|
||||||
import io.ktor.server.util.*
|
import io.ktor.server.util.*
|
||||||
|
import io.ktor.utils.io.ExperimentalKtorApi
|
||||||
|
|
||||||
|
@OptIn(ExperimentalKtorApi::class)
|
||||||
fun Route.configurePlanRoutes() {
|
fun Route.configurePlanRoutes() {
|
||||||
route("/plan") {
|
route("/plan") {
|
||||||
authenticate {
|
authenticate {
|
||||||
@@ -24,28 +28,42 @@ fun Route.configurePlanRoutes() {
|
|||||||
call.respond(plan)
|
call.respond(plan)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}.describe {
|
||||||
|
tag("Plan")
|
||||||
}
|
}
|
||||||
route("/groups") {
|
route("/groups") {
|
||||||
|
authenticate {
|
||||||
get {
|
get {
|
||||||
|
val principal = call.principal<JWTPrincipal>() ?: return@get call.respond(HttpStatusCode.Unauthorized)
|
||||||
|
if (principal.payload.username() != "admin") return@get call.respond(HttpStatusCode.Forbidden, mapOf("msg" to "Nur Admin kann Gruppen abfragen"))
|
||||||
val offset = call.parameters.get("offset")?.toLong() ?: 0
|
val offset = call.parameters.get("offset")?.toLong() ?: 0
|
||||||
val amount = call.parameters.get("amount")?.toInt() ?: 10
|
val amount = call.parameters.get("amount")?.toInt() ?: 10
|
||||||
val groups = GottesdienstGroupDao.getPlans(amount, offset)
|
val groups = GottesdienstGroupDao.getPlans(amount, offset)
|
||||||
call.respond(groups)
|
call.respond(groups)
|
||||||
}
|
}
|
||||||
post {
|
post {
|
||||||
|
val principal = call.principal<JWTPrincipal>() ?: return@post call.respond(HttpStatusCode.Unauthorized)
|
||||||
|
if (principal.payload.username() != "admin") return@post call.respond(HttpStatusCode.Forbidden, mapOf("msg" to "Nur Admin kann Gruppen erstellen"))
|
||||||
val group = call.receive<GottesdienstGroup>()
|
val group = call.receive<GottesdienstGroup>()
|
||||||
val res = GottesdienstGroupDao.createPlan(group.from, group.to) ?: TODO("fail")
|
val res = GottesdienstGroupDao.createPlan(group.from, group.to) ?: TODO("fail")
|
||||||
call.respond(res)
|
call.respond(res)
|
||||||
}
|
}
|
||||||
patch {
|
patch {
|
||||||
|
val principal = call.principal<JWTPrincipal>() ?: return@patch call.respond(HttpStatusCode.Unauthorized)
|
||||||
|
if (principal.payload.username() != "admin") return@patch call.respond(HttpStatusCode.Forbidden, mapOf("msg" to "Nur Admin kann Gruppen aktualisieren"))
|
||||||
val group = call.receive<GottesdienstGroup>()
|
val group = call.receive<GottesdienstGroup>()
|
||||||
val res = GottesdienstGroupDao.updatePlan(group) ?: TODO("fail")
|
val res = GottesdienstGroupDao.updatePlan(group) ?: TODO("fail")
|
||||||
call.respond(res)
|
call.respond(res)
|
||||||
}
|
}
|
||||||
delete {
|
delete {
|
||||||
|
val principal = call.principal<JWTPrincipal>() ?: return@delete call.respond(HttpStatusCode.Unauthorized)
|
||||||
|
if (principal.payload.username() != "admin") return@delete call.respond(HttpStatusCode.Forbidden, mapOf("msg" to "Nur Admin kann Gruppen löschen"))
|
||||||
val id = call.parameters.getOrFail("id").toInt()
|
val id = call.parameters.getOrFail("id").toInt()
|
||||||
val res = GottesdienstGroupDao.deletePlan(id)
|
val res = GottesdienstGroupDao.deletePlan(id)
|
||||||
call.respond(hashMapOf("success" to res))
|
call.respond(hashMapOf("success" to res))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}.describe {
|
||||||
|
tag("Plan")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,21 +1,118 @@
|
|||||||
package de.walamana
|
package de.walamana
|
||||||
|
|
||||||
import de.walamana.plugins.*
|
import de.walamana.models.Gottesdienst
|
||||||
|
import de.walamana.models.GottesdienstGroup
|
||||||
|
import de.walamana.models.Mark
|
||||||
|
import de.walamana.models.Ministrant
|
||||||
|
import de.walamana.views.AuthenticationRequest
|
||||||
|
import de.walamana.views.AuthenticationResult
|
||||||
import io.ktor.client.request.*
|
import io.ktor.client.request.*
|
||||||
import io.ktor.client.statement.*
|
import io.ktor.client.statement.*
|
||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
import io.ktor.server.testing.*
|
import io.ktor.server.testing.*
|
||||||
import kotlin.test.*
|
import kotlinx.serialization.json.Json
|
||||||
|
import kotlinx.serialization.json.jsonObject
|
||||||
|
import java.util.Date
|
||||||
|
import kotlin.test.Test
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
import kotlin.test.assertNotNull
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
class ApplicationTest {
|
class ApplicationTest {
|
||||||
// @Test
|
private val json = Json { ignoreUnknownKeys = true }
|
||||||
// fun testRoot() = testApplication {
|
|
||||||
// application {
|
@Test
|
||||||
// configureRouting()
|
fun `admin can manage a plan and regular users remain restricted`() = testApplication {
|
||||||
// }
|
environment {
|
||||||
// client.get("/").apply {
|
config = io.ktor.server.config.ApplicationConfig("application.conf")
|
||||||
// assertEquals(HttpStatusCode.OK, status)
|
}
|
||||||
// assertEquals("Hello World!", bodyAsText())
|
|
||||||
// }
|
fun authenticated(token: String) = "Bearer $token"
|
||||||
// }
|
|
||||||
|
val adminToken = client.post("/api/auth") {
|
||||||
|
contentType(ContentType.Application.Json)
|
||||||
|
setBody(json.encodeToString(AuthenticationRequest("admin", "admin123")))
|
||||||
|
}.let { response ->
|
||||||
|
assertEquals(HttpStatusCode.OK, response.status)
|
||||||
|
val result = json.decodeFromString<AuthenticationResult>(response.bodyAsText())
|
||||||
|
assertTrue(result.success)
|
||||||
|
assertNotNull(result.token)
|
||||||
|
}
|
||||||
|
|
||||||
|
client.get("/api/groups").also {
|
||||||
|
assertEquals(HttpStatusCode.Unauthorized, it.status)
|
||||||
|
}
|
||||||
|
|
||||||
|
val now = System.currentTimeMillis()
|
||||||
|
val group = client.post("/api/groups") {
|
||||||
|
header(HttpHeaders.Authorization, authenticated(adminToken))
|
||||||
|
contentType(ContentType.Application.Json)
|
||||||
|
setBody(json.encodeToString(GottesdienstGroup(-1, Date(now), Date(now + 86_400_000))))
|
||||||
|
}.let { response ->
|
||||||
|
assertEquals(HttpStatusCode.OK, response.status)
|
||||||
|
json.decodeFromString<GottesdienstGroup>(response.bodyAsText())
|
||||||
|
}
|
||||||
|
assertTrue(group.id > 0)
|
||||||
|
|
||||||
|
val ministrantId = client.put("/api/ministranten") {
|
||||||
|
header(HttpHeaders.Authorization, authenticated(adminToken))
|
||||||
|
contentType(ContentType.Application.Json)
|
||||||
|
setBody(json.encodeToString(Ministrant(-1, "testuser", "password123", "Test", "User", null, emptyList())))
|
||||||
|
}.let { response ->
|
||||||
|
assertEquals(HttpStatusCode.OK, response.status)
|
||||||
|
json.parseToJsonElement(response.bodyAsText()).jsonObject["id"]!!.toString().toInt()
|
||||||
|
}
|
||||||
|
|
||||||
|
val userToken = client.post("/api/auth") {
|
||||||
|
contentType(ContentType.Application.Json)
|
||||||
|
setBody(json.encodeToString(AuthenticationRequest("testuser", "password123")))
|
||||||
|
}.let { response ->
|
||||||
|
assertEquals(HttpStatusCode.OK, response.status)
|
||||||
|
assertNotNull(json.decodeFromString<AuthenticationResult>(response.bodyAsText()).token)
|
||||||
|
}
|
||||||
|
client.get("/api/groups") {
|
||||||
|
header(HttpHeaders.Authorization, authenticated(userToken))
|
||||||
|
}.also {
|
||||||
|
assertEquals(HttpStatusCode.Forbidden, it.status)
|
||||||
|
}
|
||||||
|
|
||||||
|
val service = client.put("/api/gottesdienste") {
|
||||||
|
header(HttpHeaders.Authorization, authenticated(adminToken))
|
||||||
|
contentType(ContentType.Application.Json)
|
||||||
|
setBody(json.encodeToString(Gottesdienst(0, "Test service", Date(now), Date(now + 1_800_000), group.id)))
|
||||||
|
}.let { response ->
|
||||||
|
assertEquals(HttpStatusCode.OK, response.status)
|
||||||
|
json.parseToJsonElement(response.bodyAsText()).jsonObject["id"]!!.toString().toInt()
|
||||||
|
}
|
||||||
|
|
||||||
|
client.patch("/api/marks") {
|
||||||
|
header(HttpHeaders.Authorization, authenticated(adminToken))
|
||||||
|
contentType(ContentType.Application.Json)
|
||||||
|
setBody(json.encodeToString(listOf(Mark(ministrantId, service, 1))))
|
||||||
|
}.also {
|
||||||
|
assertEquals(HttpStatusCode.OK, it.status)
|
||||||
|
}
|
||||||
|
|
||||||
|
client.get("/api/marks?id=${group.id}") {
|
||||||
|
header(HttpHeaders.Authorization, authenticated(adminToken))
|
||||||
|
}.let { response ->
|
||||||
|
assertEquals(HttpStatusCode.OK, response.status)
|
||||||
|
assertTrue(json.decodeFromString<List<Mark>>(response.bodyAsText()).contains(Mark(ministrantId, service, 1)))
|
||||||
|
}
|
||||||
|
|
||||||
|
client.get("/api/plan?id=${group.id}") {
|
||||||
|
header(HttpHeaders.Authorization, authenticated(adminToken))
|
||||||
|
}.also {
|
||||||
|
assertEquals(HttpStatusCode.OK, it.status)
|
||||||
|
}
|
||||||
|
|
||||||
|
client.get("/docs/openapi.json").let { response ->
|
||||||
|
assertEquals(HttpStatusCode.OK, response.status)
|
||||||
|
val specification = response.bodyAsText()
|
||||||
|
assertTrue(specification.contains("\"requestBody\""))
|
||||||
|
assertTrue(specification.contains("\"responses\""))
|
||||||
|
assertTrue(specification.contains("AuthenticationRequest"))
|
||||||
|
assertTrue(specification.contains("AuthenticationResult"))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
ktor {
|
||||||
|
development = true
|
||||||
|
deployment {
|
||||||
|
port = 8080
|
||||||
|
}
|
||||||
|
application {
|
||||||
|
modules = [ de.walamana.ApplicationKt.module ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
jwt {
|
||||||
|
secret = "testsecret"
|
||||||
|
issuer = "http://0.0.0.0:8080/"
|
||||||
|
audience = "http://0.0.0.0:8080/"
|
||||||
|
realm = "mini-data"
|
||||||
|
}
|
||||||
|
|
||||||
|
database {
|
||||||
|
url = "jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1"
|
||||||
|
driver = "org.h2.Driver"
|
||||||
|
}
|
||||||
|
|
||||||
|
admin {
|
||||||
|
password = "admin123"
|
||||||
|
}
|
||||||
@@ -26,3 +26,4 @@ coverage
|
|||||||
*.njsproj
|
*.njsproj
|
||||||
*.sln
|
*.sln
|
||||||
*.sw?
|
*.sw?
|
||||||
|
/dev-dist/
|
||||||
@@ -3,9 +3,14 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<link rel="icon" href="/favicon.ico">
|
<link rel="icon" href="/favicon.ico">
|
||||||
|
<link rel="apple-touch-icon" href="/minis_logo.png">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta name="theme-color" content="#ffffff">
|
||||||
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||||
|
<meta name="apple-mobile-web-app-title" content="Miniplan">
|
||||||
<title>Miniplan App</title>
|
<title>Miniplan App</title>
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" rel="stylesheet" />
|
<link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" rel="stylesheet">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
"type-check": "vue-tsc --noEmit -p tsconfig.app.json --composite false"
|
"type-check": "vue-tsc --noEmit -p tsconfig.app.json --composite false"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"crypto-js": "^4.2.0",
|
||||||
"dropzone-vue3": "^1.0.2",
|
"dropzone-vue3": "^1.0.2",
|
||||||
"rxjs": "^7.8.1",
|
"rxjs": "^7.8.1",
|
||||||
"underscore": "^1.13.7",
|
"underscore": "^1.13.7",
|
||||||
@@ -19,12 +20,15 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tsconfig/node18": "^18.2.0",
|
"@tsconfig/node18": "^18.2.0",
|
||||||
"@types/node": "^18.17.0",
|
"@types/node": "^18.17.0",
|
||||||
|
"@vite-pwa/assets-generator": "^1.0.2",
|
||||||
"@vitejs/plugin-vue": "^4.2.3",
|
"@vitejs/plugin-vue": "^4.2.3",
|
||||||
"@vue/tsconfig": "^0.4.0",
|
"@vue/tsconfig": "^0.4.0",
|
||||||
"less": "^4.2.0",
|
"less": "^4.2.0",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"typescript": "~5.1.6",
|
"typescript": "~5.1.6",
|
||||||
"vite": "^4.4.6",
|
"vite": "^5.4.0",
|
||||||
"vue-tsc": "^1.8.6"
|
"vite-plugin-pwa": "^1.3.0",
|
||||||
|
"vue-tsc": "^3.3.7",
|
||||||
|
"workbox-window": "^7.4.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 931 B |
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
|
<svg width="100%" height="100%" viewBox="0 0 4329 3848" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
||||||
|
<path id="Vectorized" d="M1614.618,3355.781C1612.41,3362.264 1607.496,3375.663 1593.41,3408.077C1585.444,3426.407 1651.514,3431.144 1621.881,3487.463C1604.36,3520.76 1502.049,3579.731 1451.548,3612.589C1424.195,3630.386 1446.948,3582.248 1433.365,3526.951C1428.86,3508.61 1373.802,3408.892 1433.375,3377.27C1445.358,3370.91 1463.335,3381.252 1464.436,3371.959C1464.69,3369.811 1471.061,3328.483 1462.206,3337.925C1444.527,3356.775 1407.045,3430.974 1221.971,3404.028C1196.362,3400.299 1118.26,3388.928 945.022,3236.884C928.084,3222.019 723.137,3018.522 649.735,2888.897C604.051,2808.221 379.235,2352.906 424.362,1988.669C435.713,1897.044 434.653,1865.497 561.162,1682.933C587.065,1645.553 619.919,1640.653 608.973,1637.128C554.936,1619.726 552.75,1628.258 552.173,1632.778C541.593,1715.743 464.962,1674.146 427.85,1614.435C376.873,1532.416 308.309,1489.225 327.936,1489.701C332.734,1489.817 331.754,1493.629 387.656,1495.517C457.697,1497.883 499.62,1443.047 549.675,1459.998C578.456,1469.745 519.991,1416.036 520.24,1326.662C520.288,1309.452 554.736,1116.901 677.825,958.147C733.642,886.157 836.884,736.019 1194.772,483.054C1250.736,443.497 1696.421,179.524 1890.283,271.861C1996.741,322.567 1976.711,370.09 1989.257,361.785C1989.347,361.726 2006.221,296.217 1999.657,292.972C1999.323,292.807 1909.634,309.003 1941.856,225.343C1959.035,180.739 1994.72,167.146 2026.649,93.759C2041.368,59.928 2042.753,58.743 2045.328,60.395C2127.957,113.395 2256.446,322.813 2123.088,299.707C2122.281,299.567 2118.139,298.849 2113.396,298.438C2106.099,297.806 2097.379,297.901 2097.197,301.945C2096.713,312.675 2090.413,374.771 2103.414,356.622C2110.381,346.896 2122.003,336.045 2137.65,325.716C2185.561,294.087 2271.208,267.356 2376.484,292.842C2432.551,306.415 3091.946,487.891 3304.396,768.264C3354.38,834.228 3466.209,977.364 3462.167,1231.625C3460.695,1324.264 3393.886,1330.949 3402.987,1338.87C3406.108,1341.587 3406.419,1338.758 3453.679,1328.583C3473.276,1324.364 3421.521,1243.818 3527.579,1261.5C3585.416,1271.143 3578.27,1294.512 3710.735,1317.634C3738.612,1322.5 3681.487,1342.933 3634.159,1390.618C3603.015,1421.996 3604.631,1459.669 3576.605,1469.756C3524.841,1488.385 3634.618,1465.177 3699.749,1601.613C3787.04,1784.469 3790.202,2028.141 3790.693,2065.994C3791.545,2131.594 3791.088,2131.262 3800.779,2196.229L3800.779,2270.16C3777.038,2570.815 3790.637,2762.719 3663.9,2931.003C3594.986,3022.509 3532.628,3035.334 3422.191,3002.882C3406.064,2998.143 3405.703,3000.926 3406.217,3002.098C3407.574,3005.195 3422.32,3038.851 3433.005,3034.789C3451.133,3027.899 3513.61,2986.635 3543.965,3083.764C3556.409,3123.582 3534.297,3160.309 3585.551,3233.886C3603.361,3259.452 3615.008,3266.507 3601.784,3265.691C3556.253,3262.881 3507.048,3240.022 3408.284,3243.088C3322.339,3245.757 3355.493,3140.43 3352.245,3139.18C3336.025,3132.939 3358.19,3155.457 3322.048,3208.989C3229.954,3345.395 3205.467,3371.482 2960.534,3483.371C2754.478,3577.5 1994.184,3764.217 1747.5,3575.029C1626.613,3482.317 1625.605,3380.69 1623.979,3350.816C1623.426,3340.674 1622.803,3338.802 1617.393,3348.356C1616.367,3350.167 1616.115,3351.383 1614.618,3355.781ZM3479.139,1453.803C3475.78,1456.85 3471.528,1456.593 3475.27,1459.499C3477.211,1461.006 3477.889,1456.152 3505.935,1461.504C3521.912,1464.553 3513.539,1441.295 3497.892,1447.394C3496.415,1447.969 3488.541,1451.038 3479.139,1453.803ZM609.5,1519.486C589.445,1502.297 590.439,1500.984 588.179,1500.767C580.787,1500.054 584.92,1519.322 585.261,1520.915C585.831,1523.571 629.603,1535.826 609.5,1519.486ZM2154.702,344.895C2145.608,351.682 2138.449,359.025 2128.519,367.255C2078.268,429.939 2090.405,436.417 2090.463,516.931C2090.494,559.742 1977.961,599.783 1977.599,492.307C1977.455,449.782 2019.582,80.463 1349.246,422.88C1302.302,446.86 984.862,621.933 744.718,916.016C744.144,916.718 623.268,1038.194 559.601,1259.59C521.704,1391.369 583.675,1550.509 799.554,1557.862C829.886,1558.896 847.566,1600.416 834.876,1632.69C824.454,1659.196 793.55,1679.466 732.348,1665.954C618.164,1640.744 605.645,1656.993 512.53,1803.012C487.094,1842.901 387.925,1998.415 484.905,2393.724C488.783,2409.535 588.038,2782.924 730.654,2962.481C889.514,3162.492 1100.131,3365.794 1232.496,3379.619C1371.461,3394.133 1400.816,3379.284 1492.003,3265.631C1544.576,3200.105 1531.735,3126.431 1602.126,3130.89C1681.168,3135.897 1665.783,3195.435 1663.886,3202.776C1654.134,3240.514 1633.113,3260.439 1644.827,3339.758C1647.216,3355.935 1650.966,3374.582 1656.452,3396.355C1692.609,3539.87 1829.108,3770.815 2781.856,3520.944C2938.315,3479.911 3162.075,3362.147 3203.567,3318.806C3225.364,3296.039 3324.686,3177.87 3320.658,3146.746C3311.459,3075.673 3142.536,2979.005 3173.052,2925.37C3184.041,2906.056 3245.847,2855.472 3277.381,2879.994C3303.743,2900.494 3328.56,2926.648 3365.546,2949.079C3402.733,2971.633 3452.222,2990.422 3527.95,2995.917C3552.411,2997.691 3712.94,2929.13 3747.06,2636.386C3768.589,2451.677 3773.14,2324.485 3772.814,2244.602C3772.764,2232.411 3772.6,2221.322 3772.366,2211.299C3Line truncated
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 58 KiB |
|
After Width: | Height: | Size: 9.5 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 891 B |
|
After Width: | Height: | Size: 59 KiB |
|
After Width: | Height: | Size: 43 KiB |
|
After Width: | Height: | Size: 64 KiB |
@@ -6,6 +6,8 @@ import {onMounted, ref} from "vue";
|
|||||||
import {Auth} from "@/services/auth";
|
import {Auth} from "@/services/auth";
|
||||||
import DialogHost from "@/components/dialog/DialogHost.vue";
|
import DialogHost from "@/components/dialog/DialogHost.vue";
|
||||||
import {LoginService} from "@/services/LoginService";
|
import {LoginService} from "@/services/LoginService";
|
||||||
|
import {Dialogs} from "@/services/DialogService";
|
||||||
|
import InstallPWADialog from "@/components/dialog/InstallPWADialog.vue";
|
||||||
|
|
||||||
let showPopup = ref(false)
|
let showPopup = ref(false)
|
||||||
let loggedIn = ref(false)
|
let loggedIn = ref(false)
|
||||||
@@ -33,6 +35,40 @@ LoginService.subject.subscribe(() => {
|
|||||||
showPopup.value = true
|
showPopup.value = true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const installEvent = ref<Event>()
|
||||||
|
|
||||||
|
window.addEventListener('beforeinstallprompt', (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
console.log("beforeinstallprompt")
|
||||||
|
installEvent.value = e
|
||||||
|
scheduleInstallDialog()
|
||||||
|
})
|
||||||
|
|
||||||
|
function scheduleInstallDialog() {
|
||||||
|
if (isPwa()) return
|
||||||
|
if (localStorage.getItem('installPromptDismissed')) return
|
||||||
|
if (!installEvent.value) return
|
||||||
|
|
||||||
|
Dialogs.createDialog(InstallPWADialog, {
|
||||||
|
onPositive(dontShowAgain: boolean) {
|
||||||
|
if (dontShowAgain) localStorage.setItem('installPromptDismissed', 'true')
|
||||||
|
;(installEvent.value as any).prompt()
|
||||||
|
},
|
||||||
|
onNegative(dontShowAgain: boolean) {
|
||||||
|
if (dontShowAgain) localStorage.setItem('installPromptDismissed', 'true')
|
||||||
|
},
|
||||||
|
onDismiss() {}
|
||||||
|
}, {})
|
||||||
|
}
|
||||||
|
|
||||||
|
function isPwa() {
|
||||||
|
return window.matchMedia('(display-mode: standalone)').matches
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('appinstalled', () => {
|
||||||
|
localStorage.setItem('installPromptDismissed', 'true')
|
||||||
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -1 +1,5 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 261.76 226.69"><path d="M161.096.001l-30.225 52.351L100.647.001H-.005l130.877 226.688L261.749.001z" fill="#41b883"/><path d="M161.096.001l-30.225 52.351L100.647.001H52.346l78.526 136.01L209.398.001z" fill="#34495e"/></svg>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
|
<svg width="100%" height="100%" viewBox="0 0 4329 3848" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
||||||
|
<path id="Vectorized" d="M1614.618,3355.781C1612.41,3362.264 1607.496,3375.663 1593.41,3408.077C1585.444,3426.407 1651.514,3431.144 1621.881,3487.463C1604.36,3520.76 1502.049,3579.731 1451.548,3612.589C1424.195,3630.386 1446.948,3582.248 1433.365,3526.951C1428.86,3508.61 1373.802,3408.892 1433.375,3377.27C1445.358,3370.91 1463.335,3381.252 1464.436,3371.959C1464.69,3369.811 1471.061,3328.483 1462.206,3337.925C1444.527,3356.775 1407.045,3430.974 1221.971,3404.028C1196.362,3400.299 1118.26,3388.928 945.022,3236.884C928.084,3222.019 723.137,3018.522 649.735,2888.897C604.051,2808.221 379.235,2352.906 424.362,1988.669C435.713,1897.044 434.653,1865.497 561.162,1682.933C587.065,1645.553 619.919,1640.653 608.973,1637.128C554.936,1619.726 552.75,1628.258 552.173,1632.778C541.593,1715.743 464.962,1674.146 427.85,1614.435C376.873,1532.416 308.309,1489.225 327.936,1489.701C332.734,1489.817 331.754,1493.629 387.656,1495.517C457.697,1497.883 499.62,1443.047 549.675,1459.998C578.456,1469.745 519.991,1416.036 520.24,1326.662C520.288,1309.452 554.736,1116.901 677.825,958.147C733.642,886.157 836.884,736.019 1194.772,483.054C1250.736,443.497 1696.421,179.524 1890.283,271.861C1996.741,322.567 1976.711,370.09 1989.257,361.785C1989.347,361.726 2006.221,296.217 1999.657,292.972C1999.323,292.807 1909.634,309.003 1941.856,225.343C1959.035,180.739 1994.72,167.146 2026.649,93.759C2041.368,59.928 2042.753,58.743 2045.328,60.395C2127.957,113.395 2256.446,322.813 2123.088,299.707C2122.281,299.567 2118.139,298.849 2113.396,298.438C2106.099,297.806 2097.379,297.901 2097.197,301.945C2096.713,312.675 2090.413,374.771 2103.414,356.622C2110.381,346.896 2122.003,336.045 2137.65,325.716C2185.561,294.087 2271.208,267.356 2376.484,292.842C2432.551,306.415 3091.946,487.891 3304.396,768.264C3354.38,834.228 3466.209,977.364 3462.167,1231.625C3460.695,1324.264 3393.886,1330.949 3402.987,1338.87C3406.108,1341.587 3406.419,1338.758 3453.679,1328.583C3473.276,1324.364 3421.521,1243.818 3527.579,1261.5C3585.416,1271.143 3578.27,1294.512 3710.735,1317.634C3738.612,1322.5 3681.487,1342.933 3634.159,1390.618C3603.015,1421.996 3604.631,1459.669 3576.605,1469.756C3524.841,1488.385 3634.618,1465.177 3699.749,1601.613C3787.04,1784.469 3790.202,2028.141 3790.693,2065.994C3791.545,2131.594 3791.088,2131.262 3800.779,2196.229L3800.779,2270.16C3777.038,2570.815 3790.637,2762.719 3663.9,2931.003C3594.986,3022.509 3532.628,3035.334 3422.191,3002.882C3406.064,2998.143 3405.703,3000.926 3406.217,3002.098C3407.574,3005.195 3422.32,3038.851 3433.005,3034.789C3451.133,3027.899 3513.61,2986.635 3543.965,3083.764C3556.409,3123.582 3534.297,3160.309 3585.551,3233.886C3603.361,3259.452 3615.008,3266.507 3601.784,3265.691C3556.253,3262.881 3507.048,3240.022 3408.284,3243.088C3322.339,3245.757 3355.493,3140.43 3352.245,3139.18C3336.025,3132.939 3358.19,3155.457 3322.048,3208.989C3229.954,3345.395 3205.467,3371.482 2960.534,3483.371C2754.478,3577.5 1994.184,3764.217 1747.5,3575.029C1626.613,3482.317 1625.605,3380.69 1623.979,3350.816C1623.426,3340.674 1622.803,3338.802 1617.393,3348.356C1616.367,3350.167 1616.115,3351.383 1614.618,3355.781ZM3479.139,1453.803C3475.78,1456.85 3471.528,1456.593 3475.27,1459.499C3477.211,1461.006 3477.889,1456.152 3505.935,1461.504C3521.912,1464.553 3513.539,1441.295 3497.892,1447.394C3496.415,1447.969 3488.541,1451.038 3479.139,1453.803ZM609.5,1519.486C589.445,1502.297 590.439,1500.984 588.179,1500.767C580.787,1500.054 584.92,1519.322 585.261,1520.915C585.831,1523.571 629.603,1535.826 609.5,1519.486ZM2154.702,344.895C2145.608,351.682 2138.449,359.025 2128.519,367.255C2078.268,429.939 2090.405,436.417 2090.463,516.931C2090.494,559.742 1977.961,599.783 1977.599,492.307C1977.455,449.782 2019.582,80.463 1349.246,422.88C1302.302,446.86 984.862,621.933 744.718,916.016C744.144,916.718 623.268,1038.194 559.601,1259.59C521.704,1391.369 583.675,1550.509 799.554,1557.862C829.886,1558.896 847.566,1600.416 834.876,1632.69C824.454,1659.196 793.55,1679.466 732.348,1665.954C618.164,1640.744 605.645,1656.993 512.53,1803.012C487.094,1842.901 387.925,1998.415 484.905,2393.724C488.783,2409.535 588.038,2782.924 730.654,2962.481C889.514,3162.492 1100.131,3365.794 1232.496,3379.619C1371.461,3394.133 1400.816,3379.284 1492.003,3265.631C1544.576,3200.105 1531.735,3126.431 1602.126,3130.89C1681.168,3135.897 1665.783,3195.435 1663.886,3202.776C1654.134,3240.514 1633.113,3260.439 1644.827,3339.758C1647.216,3355.935 1650.966,3374.582 1656.452,3396.355C1692.609,3539.87 1829.108,3770.815 2781.856,3520.944C2938.315,3479.911 3162.075,3362.147 3203.567,3318.806C3225.364,3296.039 3324.686,3177.87 3320.658,3146.746C3311.459,3075.673 3142.536,2979.005 3173.052,2925.37C3184.041,2906.056 3245.847,2855.472 3277.381,2879.994C3303.743,2900.494 3328.56,2926.648 3365.546,2949.079C3402.733,2971.633 3452.222,2990.422 3527.95,2995.917C3552.411,2997.691 3712.94,2929.13 3747.06,2636.386C3768.589,2451.677 3773.14,2324.485 3772.814,2244.602C3772.764,2232.411 3772.6,2221.322 3772.366,2211.299C3Line truncated
|
||||||
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 276 B After Width: | Height: | Size: 58 KiB |
@@ -0,0 +1,66 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
|
||||||
|
import {ref} from "vue";
|
||||||
|
import Dialog from "@/components/dialog/Dialog.vue";
|
||||||
|
import type {DialogControls} from "@/components/dialog/dialog";
|
||||||
|
|
||||||
|
interface InstallPWADialogProps extends DialogControls {
|
||||||
|
}
|
||||||
|
|
||||||
|
defineProps<InstallPWADialogProps>()
|
||||||
|
|
||||||
|
const dontShowAgain = ref<boolean>(false)
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
|
||||||
|
<Dialog class="dialog">
|
||||||
|
<h3 style="margin-bottom: 10px; display: flex; gap: 1rem; align-items: center">
|
||||||
|
Zum Startbildschirm hinzufügen
|
||||||
|
</h3>
|
||||||
|
<p style="line-height: 1.7rem">
|
||||||
|
Dein Miniplan kann jetzt auf Ihrem Gerät installiert werden, um schnell und einfach darauf zuzugreifen.
|
||||||
|
</p>
|
||||||
|
<label class="checkbox">
|
||||||
|
<input type="checkbox" v-model="dontShowAgain" />
|
||||||
|
Nicht mehr anzeigen
|
||||||
|
</label>
|
||||||
|
<div class="buttons">
|
||||||
|
<button @click="onNegative(dontShowAgain)" class="dismiss">Später</button>
|
||||||
|
<button @click="onPositive(dontShowAgain)" ><i>browser_updated</i>Jetzt hinzufügen</button>
|
||||||
|
</div>
|
||||||
|
</Dialog>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped lang="less">
|
||||||
|
|
||||||
|
.dialog {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
text-align: center;
|
||||||
|
width: 500px
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
margin-top: 16px;
|
||||||
|
font-size: 14px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.buttons {
|
||||||
|
display: flex;
|
||||||
|
justify-content: end;
|
||||||
|
margin-top: 20px;
|
||||||
|
|
||||||
|
.dismiss {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -4,6 +4,19 @@ import { createApp } from 'vue'
|
|||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import router from './router'
|
import router from './router'
|
||||||
|
|
||||||
|
import { registerSW } from 'virtual:pwa-register'
|
||||||
|
|
||||||
|
registerSW({
|
||||||
|
onNeedRefresh() {
|
||||||
|
if (confirm('New content available. Reload?')) {
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onOfflineReady() {
|
||||||
|
console.log('App ready to work offline')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
|
|
||||||
app.use(router)
|
app.use(router)
|
||||||
|
|||||||
@@ -1,16 +1,81 @@
|
|||||||
import { fileURLToPath, URL } from 'node:url'
|
import {fileURLToPath, URL} from 'node:url'
|
||||||
|
|
||||||
import { defineConfig } from 'vite'
|
import {defineConfig} from 'vite'
|
||||||
import vue from '@vitejs/plugin-vue'
|
import vue from '@vitejs/plugin-vue'
|
||||||
|
import {VitePWA} from 'vite-plugin-pwa'
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
export default defineConfig(({mode}) => (
|
||||||
export default defineConfig({
|
{
|
||||||
plugins: [
|
plugins: [
|
||||||
vue(),
|
vue(),
|
||||||
|
VitePWA({
|
||||||
|
registerType: 'autoUpdate',
|
||||||
|
includeAssets: ['favicon.ico', 'minis_logo.png'],
|
||||||
|
manifest: {
|
||||||
|
name: 'Miniplan App',
|
||||||
|
short_name: 'Miniplan',
|
||||||
|
description: 'Lade deinen Miniplan direkt auf dein Handy. So hast du den Miniplan jederzeit und schnell erreichbar.',
|
||||||
|
theme_color: '#ffffff',
|
||||||
|
background_color: '#ffffff',
|
||||||
|
display: 'standalone',
|
||||||
|
scope: '/',
|
||||||
|
start_url: '/',
|
||||||
|
screenshots: [
|
||||||
|
{
|
||||||
|
src: 'screenshot1.png',
|
||||||
|
sizes: '505x710',
|
||||||
|
type: 'image/png',
|
||||||
|
form_factor: "narrow",
|
||||||
|
label: "Miniplan Liste"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: 'screenshot2.png',
|
||||||
|
sizes: '505x711',
|
||||||
|
type: 'image/png',
|
||||||
|
form_factor: "narrow",
|
||||||
|
label: "Miniplan Tabelle"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: "screenshot3.png",
|
||||||
|
sizes: '1003x709',
|
||||||
|
type: 'image/png',
|
||||||
|
form_factor: "wide",
|
||||||
|
label: "Miniplan Tabelle"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
icons: [
|
||||||
|
{
|
||||||
|
src: "pwa-64x64.png",
|
||||||
|
sizes: "64x64",
|
||||||
|
type: "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: "pwa-192x192.png",
|
||||||
|
sizes: "192x192",
|
||||||
|
type: "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: "pwa-512x512.png",
|
||||||
|
sizes: "512x512",
|
||||||
|
type: "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: "maskable-icon-512x512.png",
|
||||||
|
sizes: "512x512",
|
||||||
|
type: "image/png",
|
||||||
|
purpose: "maskable"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
devOptions: {
|
||||||
|
enabled: mode === "development"
|
||||||
|
}
|
||||||
|
})
|
||||||
],
|
],
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
'@': fileURLToPath(new URL('./src', import.meta.url))
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
)
|
||||||