Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: in-browser graphical interface using GraphQL APIs #3136

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
343bdac
feat(webgui): added webgui module
ItsTiz Jan 19, 2024
9d79e5f
feat(webgui): added nodes subscription rendering
ItsTiz Jan 29, 2024
fd91d1c
feat(webgui): added nodes subscription rendering
ItsTiz Jan 29, 2024
7f2acf4
feat(webgui): code refactoring
ItsTiz Jan 31, 2024
2a3f0f4
feat(webgui): Added grid mesh visualization
ItsTiz Feb 1, 2024
e3e4a8c
fix: import of common components from mp projects
AngeloFilaseta Feb 1, 2024
40d4eb0
build: move javaQA and multiJvmTesting to jvm only projects
AngeloFilaseta Feb 1, 2024
15d44f8
build: remove ktor plugin
AngeloFilaseta Feb 1, 2024
a5b9759
chore: merge changes for aur releases
AngeloFilaseta Feb 6, 2024
9f7aaac
feat: Merge remote-tracking branch 'depfixPR/master'
ItsTiz Feb 7, 2024
0356159
feat(webgui): Added node inspection
ItsTiz Feb 12, 2024
ca32486
chore(webgui): Merge remote-tracking branch 'upstream/master'
ItsTiz Feb 12, 2024
5133f37
fix(webgui): Fixed subscription total block of the UI
ItsTiz Feb 15, 2024
f47aff8
ci(webgui): fixed missing imports
ItsTiz Feb 15, 2024
32cc442
chore(webgui): simplified click hanlder for play button
ItsTiz Feb 16, 2024
a7cafa6
chore(webgui): Merge remote-tracking branch 'upstream/master'
ItsTiz Feb 16, 2024
cad396c
Delete javadoc-io.json.orig
DanySK Feb 16, 2024
920dcf3
refactor: deleted unnecessary paranthesis
ItsTiz Feb 19, 2024
95794d3
chore: Merge branch 'master' of https://github.com/ItsTiz/Alchemist
ItsTiz Feb 19, 2024
33c8740
Merge branch 'master' into master
ItsTiz Feb 28, 2024
6f9e2a7
refactor: changed file names
ItsTiz Feb 29, 2024
e152f81
fix: added task compilation dependencies
ItsTiz Feb 29, 2024
bbdca1d
chore: Merge branch 'master' of https://github.com/ItsTiz/Alchemist
ItsTiz Feb 29, 2024
aa59686
Merge branch 'master' into master
ItsTiz Mar 5, 2024
b68920c
chore: disabled failing graphql task
ItsTiz Mar 6, 2024
e48b3ff
chore: Merge branch 'master' of https://github.com/ItsTiz/Alchemist
ItsTiz Mar 6, 2024
f488dd5
docs: added missing docs and fixed style warnings
ItsTiz Mar 6, 2024
36b10c7
Merge branch 'master' into master
ItsTiz Mar 6, 2024
ae5f53c
fix: fixed dependency injection warning
ItsTiz Mar 6, 2024
bbe85e1
chore: Merge branch 'master' of https://github.com/ItsTiz/Alchemist
ItsTiz Mar 6, 2024
2be1149
Merge branch 'master' into master
ItsTiz Mar 7, 2024
a6a6e91
fix: fixed jvm constructor overload
ItsTiz Mar 7, 2024
662ee9f
chore: Merge branch 'master' of https://github.com/ItsTiz/Alchemist
ItsTiz Mar 7, 2024
dfe7135
Merge branch 'master' into master
ItsTiz Mar 7, 2024
a95efc1
fix(build): solve task dependencies in webgui
AngeloFilaseta Mar 11, 2024
6231e0a
refactor(build): better organization
AngeloFilaseta Mar 11, 2024
029cb25
Merge pull request #1 from AngeloFilaseta/master
ItsTiz Mar 11, 2024
6bac6a1
Merge branch 'master' into master
ItsTiz Mar 11, 2024
72083ad
Merge branch 'master' into master
ItsTiz Mar 12, 2024
83ac81f
Merge branch 'master' into master
ItsTiz Mar 14, 2024
7ad6919
Merge branch 'master' into master
ItsTiz Mar 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
Empty file.
37 changes: 9 additions & 28 deletions alchemist-graphql/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@ import Libs.alchemist
import Libs.incarnation
import com.apollographql.apollo3.gradle.internal.ApolloGenerateSourcesTask
import com.expediagroup.graphql.plugin.gradle.tasks.AbstractGenerateClientTask
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import io.gitlab.arturbosch.detekt.Detekt
import java.io.File.separator

plugins {
application
alias(libs.plugins.kotest.multiplatform)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.ktor)
alias(libs.plugins.graphql.server)
alias(libs.plugins.graphql.client)
}
Expand Down Expand Up @@ -70,10 +67,6 @@ kotlin {
}
}

application {
mainClass.set("it.unibo.alchemist.Alchemist")
}

graphql {
schema {
packages = listOf(
Expand Down Expand Up @@ -127,30 +120,18 @@ tasks.withType<ApolloGenerateSourcesTask>().configureEach {
*/
val webpackTask = tasks.named("jsBrowserProductionWebpack")

tasks.named("run", JavaExec::class).configure {
classpath(
tasks.named("compileKotlinJvm"),
configurations.named("jvmRuntimeClasspath"),
webpackTask.map { task ->
task.outputs.files.map { file ->
file.parent
}
},
)
}

/**
* Configure the [ShadowJar] task to work exactly like the "jvmJar" task of Kotlin Multiplatform, but also
* Configure the shadowJar task to work exactly like the "jvmJar" task of Kotlin Multiplatform, but also
* include the JS artifacts by depending on the "jsBrowserProductionWebpack" task.
*/
tasks.withType<ShadowJar>().configureEach {
val jvmJarTask = tasks.named("jvmJar")
from(webpackTask)
from(jvmJarTask)
from(tasks.named("jsBrowserDistribution"))
mustRunAfter(tasks.distTar, tasks.distZip)
archiveClassifier.set("all")
}
// tasks.withType<ShadowJar>().configureEach {
// val jvmJarTask = tasks.named("jvmJar")
// from(webpackTask)
// from(jvmJarTask)
// from(tasks.named("jsBrowserDistribution"))
// mustRunAfter(tasks.distTar, tasks.distZip)
// archiveClassifier.set("all")
// }

fun PatternFilterable.excludeGenerated() = exclude { "build${separator}generated" in it.file.absolutePath }
tasks.withType<Detekt>().configureEach { excludeGenerated() }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
query EnvironmentQuery {
environment{
nodeToPos{
entries{
id
position{
coordinates
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
subscription Environment {
environment{
nodeToPos{
entries{
id
position{
coordinates
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
query Node($id: Int! = 0){

environment{
nodeById(id: $id){
id
moleculeCount
contents{
size
entries{
molecule{
name
}
concentration
}
}
properties
reactions{
inputContext
outputContext
node{
id
}
}
}
}

nodePosition(nodeId: $id) {
coordinates
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ package it.unibo.alchemist.boundary.launchers

import io.ktor.server.engine.ApplicationEngine
import io.ktor.server.engine.embeddedServer
import io.ktor.server.engine.stop
import io.ktor.server.netty.Netty
import it.unibo.alchemist.boundary.OutputMonitor
import it.unibo.alchemist.boundary.graphql.monitor.EnvironmentSubscriptionMonitor
Expand All @@ -25,15 +24,14 @@ import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.sync.Semaphore

/**
* An [OutputMonitor] observing the [environment] through a GraphQL server listening on [host]:[port].
* The server is started in a new coroutine on the [serverDispatcher] dispatcher.
* By default, the server is stopped after the simulation terminates.
* This behavior can be changed by setting [teardownOnSimulationTermination] to false.
*/
class GraphQLServer<T, P : Position<out P>> @JvmOverloads constructor(
open class GraphQLServer<T, P : Position<out P>> @JvmOverloads constructor(
val environment: Environment<T, P>,
val host: String = DefaultGraphQLSettings.DEFAULT_HOST,
val port: Int = DefaultGraphQLSettings.DEFAULT_PORT,
Expand Down
22 changes: 5 additions & 17 deletions alchemist-web-renderer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import Libs.alchemist
import Libs.incarnation

plugins {
application
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.kotest.multiplatform)
}
Expand All @@ -23,6 +22,11 @@ kotlin {
js(IR) {
browser {
binaries.executable()
testTask {
useKarma {
useChromeHeadless()
}
}
}
}
sourceSets {
Expand Down Expand Up @@ -86,27 +90,11 @@ kotlin {
}
}

application {
mainClass.set("it.unibo.alchemist.Alchemist")
}

/**
* Webpack task that generates the JS artifacts.
*/
val webpackTask = tasks.named("jsBrowserProductionWebpack")

tasks.named("run", JavaExec::class).configure {
classpath(
tasks.named("compileKotlinJvm"),
configurations.named("jvmRuntimeClasspath"),
webpackTask.map { task ->
task.outputs.files.map { file ->
file.parent
}
},
)
}

/*
* Configure the shadowJar task to work exactly like the "jvmJar" task of Kotlin Multiplatform, but also
* include the JS artifacts by depending on the "jsBrowserProductionWebpack" task.
Expand Down
Loading
Loading