Skip to content

Commit

Permalink
Plenary conference (#110)
Browse files Browse the repository at this point in the history
* Set plenary conference in backend.

* Finally separated event types in frontend.

* UI Changes

* Plenary conferences may be created and are provisionally marked.

* Fixed positional problems.

* Make border black

* Auto join plenary conference

* it's not faster, but more consistent. We're using the gradle-node plugin for the whole build process now.

* Buildfile cleanup.

* Cleanup
  • Loading branch information
snicki13 authored Nov 26, 2021
1 parent 74a142c commit c4ddc30
Show file tree
Hide file tree
Showing 31 changed files with 17,218 additions and 151 deletions.
14 changes: 7 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ COPY build.gradle.kts /code
WORKDIR /code
RUN gradle clean build -i -x bootJar

FROM node:16.13.0-alpine AS build-node
COPY ./web-gui /web-gui
WORKDIR web-gui
RUN npm ci
RUN npm run build
FROM gradle:6.8.3-jdk11 AS build-node
COPY ./ /build
WORKDIR /build/web-gui
RUN rm -rf node_modules
RUN gradle installDist

FROM gradle:6.8.3-jdk11 AS build-gradle
COPY . /build/
COPY --from=cache-gradle /cache-gradle /home/gradle/.gradle
COPY --from=build-node /web-gui/dist/web-gui/ /build/src/main/resources/static/
COPY --from=build-node /build/web-gui/dist/web-gui/ /build/src/main/resources/static/
WORKDIR /build/
RUN gradle dist -i -x npm_run_clean -x npm_run_build

FROM openjdk:11-jdk-slim
COPY --from=build-gradle /build/build/libs/*.jar /app/digital-classroom.jar
COPY --from=build-gradle /build/build/libs/digital-classroom-0.0.1-SNAPSHOT.jar /app/digital-classroom.jar
EXPOSE 8085
ENTRYPOINT ["java","-jar","/app/digital-classroom.jar"]
31 changes: 1 addition & 30 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("org.springframework.boot") version "2.5.5"
id("org.springframework.boot") version "2.5.6"
id("io.spring.dependency-management") version "1.0.11.RELEASE"
idea
kotlin("jvm") version "1.4.32"
Expand Down Expand Up @@ -55,32 +55,3 @@ tasks.withType<Test> {
tasks.register("dist") {
dependsOn("build", "web-gui:copyWebToBackend")
}

sourceSets {
main {
withConvention(org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet::class) {
this.kotlin.srcDirs("src/main/kotlin")
}
java {
setSrcDirs(emptyList<String>())
}
}
test {
withConvention(org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet::class) {
this.kotlin.srcDirs("src/test/kotlin")
}
java {
setSrcDirs(emptyList<String>())
}
}
}

idea {
module {
val kaptMain = file("${project.buildDir}/generated/source/kapt/main")
sourceDirs.add(kaptMain)
generatedSourceDirs.add(kaptMain)
outputDir = file("${project.buildDir}/classes/main")
testOutputDir = file("${project.buildDir}/classes/test")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.annotation.JsonSubTypes
import com.fasterxml.jackson.annotation.JsonTypeInfo
import de.thm.mni.ii.classroom.model.classroom.ClassroomInfo
import java.io.Serializable

@Suppress("unused")
Expand All @@ -20,3 +21,7 @@ abstract class ClassroomEvent(
) : Serializable {
@JsonIgnore abstract fun getClassroomId(): String
}

class ClassroomChangeEvent(val classroomInfo: ClassroomInfo): ClassroomEvent(ClassroomChangeEvent::class.simpleName!!) {
@JsonIgnore override fun getClassroomId() = classroomInfo.classroomId
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ enum class ConferenceAction {
CREATE,
CLOSE,
VISIBILITY,
PLENARY,
USER_CHANGE
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ class ClassroomInfo(
val classroomId: String,
val classroomName: String,
val logoutUrl: URL?,
val plenaryConference: String?
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Conference(
val attendees: LinkedHashSet<UserCredentials>,
val creationTimestamp: ZonedDateTime = ZonedDateTime.now(),
) : ClassroomDependent {

override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
Expand All @@ -32,6 +33,10 @@ class Conference(
return result
}

override fun toString(): String {
return "$conferenceId / $conferenceName"
}

fun toConferenceInfo(): ConferenceInfo {
return ConferenceInfo(this)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.thm.mni.ii.classroom.model.classroom

import de.thm.mni.ii.classroom.exception.classroom.ConferenceNotFoundException
import org.jetbrains.annotations.Contract
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono
import reactor.kotlin.core.publisher.toFlux
Expand All @@ -11,6 +12,16 @@ class ConferenceStorage {

private val usersConference = ConcurrentHashMap<UserCredentials, LinkedHashSet<Conference>>()
private val conferences = ConcurrentHashMap<String, Conference>()
private var plenaryConference: String? = null

fun getPlenaryConference() = plenaryConference

fun setPlenaryConference(confId: String): Mono<Void> {
if (plenaryConference != null)
return Mono.error(IllegalStateException("Plenary conference may only be set once."))
plenaryConference = confId
return Mono.empty()
}

fun getUsersOfConference(conference: Conference): Flux<UserCredentials> {
return conferences[conference.conferenceId]?.attendees?.toFlux()
Expand Down Expand Up @@ -56,6 +67,7 @@ class ConferenceStorage {
this.usersConference.values.forEach {
it.remove(conference)
}
if (conference.conferenceId == this.plenaryConference) plenaryConference = null
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class DigitalClassroom(

val creationTimestamp: ZonedDateTime = ZonedDateTime.now()

fun getClassroomInfo() = ClassroomInfo(classroomId, classroomName, logoutUrl)
fun getClassroomInfo() = ClassroomInfo(classroomId, classroomName, logoutUrl, conferences.getPlenaryConference())
fun hasUserJoined() = users.isNotEmpty()
fun hasBeenForciblyEnded() = false
fun getDuration() = ChronoUnit.MINUTES.between(creationTimestamp, ZonedDateTime.now())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class ClassroomEventReceiverService(
when (conferenceEvent.conferenceAction) {
ConferenceAction.CREATE -> logger.error("Received CREATE event from ${userCredentials.fullName}! This should never happen")
ConferenceAction.CLOSE -> logger.error("Received CREATE event from ${userCredentials.fullName}! This should never happen")
ConferenceAction.PLENARY -> conferenceService.setPlenaryConference(userCredentials, conferenceEvent.conferenceInfo)
ConferenceAction.VISIBILITY -> conferenceService.changeVisibility(userCredentials, conferenceEvent.conferenceInfo)
ConferenceAction.USER_CHANGE -> logger.error("Received USER_CHANGE event from ${userCredentials.fullName}! This should never happen")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package de.thm.mni.ii.classroom.services

import de.thm.mni.ii.classroom.event.*
import de.thm.mni.ii.classroom.exception.classroom.InvitationException
import de.thm.mni.ii.classroom.model.classroom.ClassroomInfo
import de.thm.mni.ii.classroom.model.classroom.Conference
import de.thm.mni.ii.classroom.model.classroom.ConferenceInfo
import de.thm.mni.ii.classroom.model.classroom.DigitalClassroom
Expand Down Expand Up @@ -61,8 +62,8 @@ class ConferenceService(
}.map(Tuple2<JoinLink, Conference>::getT1)
}

fun endConferenceManually(userCredentials: UserCredentials?, conferenceInfo: ConferenceInfo): Mono<Void> {
if (userCredentials != null && !userCredentials.isPrivileged() && userCredentials != conferenceInfo.creator) {
fun endConferenceManually(userCredentials: UserCredentials, conferenceInfo: ConferenceInfo): Mono<Void> {
if (!userCredentials.isPrivileged() && userCredentials != conferenceInfo.creator) {
logger.warn("User ${userCredentials.fullName} is not authorized to end ${conferenceInfo.conferenceName}!")
return Mono.empty()
}
Expand All @@ -85,6 +86,22 @@ class ConferenceService(
}
}

fun setPlenaryConference(userCredentials: UserCredentials, conferenceInfo: ConferenceInfo) {
if (!userCredentials.isPrivileged()) {
logger.warn("User ${userCredentials.fullName} is not authorized to end ${conferenceInfo.conferenceName}!")
return
}
classroomInstanceService.getClassroomInstance(userCredentials.classroomId)
.zipWhen { classroom ->
classroom.getConference(conferenceInfo.conferenceId!!)
}.delayUntil { (classroom, conference) ->
classroom.conferences.setPlenaryConference(conference.conferenceId)
}.delayUntil { (classroom, conference) ->
logger.info("Conference $conference is now the plenary conference.")
classroom.sendToAll(ClassroomChangeEvent(classroom.getClassroomInfo()))
}.subscribe()
}

private fun removeConferenceReferences(classroom: DigitalClassroom, conference: Conference): Flux<Void> {
return classroom.removeConferenceReferencesFromTickets(conference)
.flatMap { ticket ->
Expand Down Expand Up @@ -135,7 +152,7 @@ class ConferenceService(
}

fun updateConferences(classroom: DigitalClassroom) {
logger.info("Updating conferences of ${classroom.classroomName}.")
logger.debug("Updating conferences of ${classroom.classroomName}.")
classroom.conferences.getConferences()
.collectList()
.zipWhen { conferences -> this.upstreamBBBService.syncMeetings(classroom, conferences) }
Expand Down
8 changes: 2 additions & 6 deletions web-gui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ apply plugin: 'idea'

repositories {
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}

node {
version = '16.13.0'
npmVersion = '8.1.2'
npmVersion = '8.1.3'
//yarnVersion = '1.22.17'
download = true
}

Expand All @@ -34,8 +32,6 @@ distributions {
}
}



// After build the ng app, we copy the dist content to or spring boot webservice static resoorce path
// It will work on evry system, because of relative paths (at leat I hope so)

Expand Down
Loading

0 comments on commit c4ddc30

Please sign in to comment.