diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 7bd67f72b..ce5f79c50 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -38,9 +38,6 @@ dependencies { implementation(libs.jmh.gradle) implementation(libs.dokka.gradle) - implementation(libs.jandex.gradle) implementation(libs.quarkus.gradle.application) implementation(libs.quarkus.gradle.extension) - - implementation(libs.gradle.node) } diff --git a/buildSrc/src/main/kotlin/quarkus-conventions.gradle.kts b/buildSrc/src/main/kotlin/quarkus-conventions.gradle.kts index 3bd3d85ae..e811519ef 100644 --- a/buildSrc/src/main/kotlin/quarkus-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/quarkus-conventions.gradle.kts @@ -23,10 +23,7 @@ import org.gradle.api.artifacts.type.ArtifactTypeDefinition import org.gradle.api.attributes.Category import org.gradle.api.attributes.VerificationType -import org.gradle.kotlin.dsl.dependencies import org.gradle.kotlin.dsl.get -import org.gradle.kotlin.dsl.kotlin -import org.gradle.kotlin.dsl.withType plugins { id("java-conventions") @@ -48,7 +45,6 @@ configurations.create("coverageDataElementsForQuarkus") { extendsFrom(configurations["implementation"], configurations["runtimeOnly"]) - @Suppress("UnstableApiUsage") attributes { attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category::class.java, Category.VERIFICATION)) attribute(VerificationType.VERIFICATION_TYPE_ATTRIBUTE, objects.named(VerificationType::class.java, VerificationType.JACOCO_RESULTS)) @@ -56,7 +52,6 @@ configurations.create("coverageDataElementsForQuarkus") { artifacts { add("coverageDataElementsForQuarkus", layout.buildDirectory.file("jacoco-quarkus.exec")) { - @Suppress("UnstableApiUsage") type = ArtifactTypeDefinition.BINARY_DATA_TYPE builtBy(tasks.test) } diff --git a/buildSrc/src/main/kotlin/spotless-conventions.gradle.kts b/buildSrc/src/main/kotlin/spotless-conventions.gradle.kts index 11131cc85..7a2b0a1c6 100644 --- a/buildSrc/src/main/kotlin/spotless-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/spotless-conventions.gradle.kts @@ -42,7 +42,6 @@ spotless { pluginManager.withPlugin("org.jetbrains.kotlin.jvm") { kotlin { ktlint() - .setUseExperimental(false) trimTrailingWhitespace() endWithNewline() diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index cff1c3302..245fc6199 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,31 +1,31 @@ [versions] -calcite = "1.34.0" -clikt = "3.5.2" +calcite = "1.35.0" +clikt = "4.2.1" commons-math3 = "3.6.1" -dokka = "1.8.10" -gradle-node = "3.5.1" -hadoop = "3.3.5" -hypersistence-utils = "3.2.0" -jackson = "2.14.2" -jandex-gradle = "1.1.0" +dokka = "1.9.10" +hadoop = "3.3.6" +hypersistence-utils = "3.6.0" +jackson = "2.15.3" java = "17" jline = "3.23.0" -jmh-gradle = "0.7.0" -jakarta-validation = "2.0.2" -junit-jupiter = "5.9.1" -kotlin = "1.8.10" +jmh-gradle = "0.7.1" +jakarta-validation = "3.0.2" +jakarta-ws-rs = "3.1.0" +junit-jupiter = "5.10.0" +kotlin = "1.9.10" kotlin-logging = "3.0.5" -kotlinx-coroutines = "1.6.4" -log4j = "2.20.0" -microprofile-openapi = "3.0" -microprofile-config = "3.0.1" -mockk = "1.13.4" -node = "18.15.0" -parquet = "1.12.3" -progressbar = "0.9.5" -quarkus = "2.16.5.Final" -sentry = "6.16.0" -slf4j = "2.0.7" +kotlinx-coroutines = "1.7.3" +log4j = "2.21.0" +microprofile-rest-client = "3.0.1" +microprofile-openapi = "3.1.1" +microprofile-config = "3.1" +mockk = "1.13.8" +parquet = "1.13.1" +progressbar = "0.10.0" +quarkus = "3.2.7.Final" +quarkus-quinoa = "2.2.1" +sentry = "6.32.0" +slf4j = "2.0.9" spotless = "6.12.0" [libraries] @@ -84,7 +84,9 @@ quarkus-hibernate-validator = { module = "io.quarkus:quarkus-hibernate-validator quarkus-jdbc-h2 = { module = "io.quarkus:quarkus-jdbc-h2" } quarkus-jdbc-postgresql = { module = "io.quarkus:quarkus-jdbc-postgresql" } quarkus-flyway = { module = "io.quarkus:quarkus-flyway" } -hypersistence-utils-hibernate = { module = "io.hypersistence:hypersistence-utils-hibernate-55", version.ref = "hypersistence-utils" } +hypersistence-utils-hibernate = { module = "io.hypersistence:hypersistence-utils-hibernate-62", version.ref = "hypersistence-utils" } +quarkus-quinoa-runtime = { module = "io.quarkiverse.quinoa:quarkus-quinoa", version.ref = "quarkus-quinoa" } +quarkus-quinoa-deployment = { module = "io.quarkiverse.quinoa:quarkus-quinoa-deployment", version.ref = "quarkus-quinoa" } # Quarkus (Testing) quarkus-junit5-core = { module = "io.quarkus:quarkus-junit5" } @@ -99,15 +101,15 @@ jline = { module = "org.jline:jline", version.ref = "jline" } # Other jakarta-validation = { module = "jakarta.validation:jakarta.validation-api", version.ref = "jakarta-validation" } +jakarta-ws-rs-api = { module = "jakarta.ws.rs:jakarta.ws.rs-api", version.ref = "jakarta-ws-rs" } hadoop-common = { module = "org.apache.hadoop:hadoop-common", version.ref = "hadoop" } hadoop-mapreduce-client-core = { module = "org.apache.hadoop:hadoop-mapreduce-client-core", version.ref = "hadoop" } commons-math3 = { module = "org.apache.commons:commons-math3", version.ref = "commons-math3" } +microprofile-rest-client-api = { module = "org.eclipse.microprofile.rest.client:microprofile-rest-client-api", version.ref = "microprofile-rest-client" } microprofile-openapi-api = { module = "org.eclipse.microprofile.openapi:microprofile-openapi-api", version.ref = "microprofile-openapi" } microprofile-config = { module = "org.eclipse.microprofile.config:microprofile-config-api", version.ref = "microprofile-config" } # Other (Build) dokka-gradle = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" } -gradle-node = { module = "com.github.node-gradle:gradle-node-plugin", version.ref = "gradle-node" } -jandex-gradle = { module = "org.kordamp.gradle:jandex-gradle-plugin", version.ref = "jandex-gradle" } jmh-gradle = { module = "me.champeau.jmh:jmh-gradle-plugin", version.ref = "jmh-gradle" } spotless-gradle = { module = "com.diffplug.spotless:spotless-plugin-gradle", version.ref = "spotless" } diff --git a/opendc-experiments/opendc-experiments-capelin/build.gradle.kts b/opendc-experiments/opendc-experiments-capelin/build.gradle.kts index da45adde2..7557a469d 100644 --- a/opendc-experiments/opendc-experiments-capelin/build.gradle.kts +++ b/opendc-experiments/opendc-experiments-capelin/build.gradle.kts @@ -54,7 +54,7 @@ val createCapelinApp by tasks.creating(CreateStartScripts::class) { applicationName = "capelin" mainClass.set("org.opendc.experiments.capelin.CapelinCli") classpath = tasks.jar.get().outputs.files + configurations["runtimeClasspath"] - outputDir = project.buildDir.resolve("scripts") + outputDir = project.layout.buildDirectory.dir("scripts").get().asFile } /* Create custom Capelin distribution */ diff --git a/opendc-web/opendc-web-proto/build.gradle.kts b/opendc-web/opendc-web-proto/build.gradle.kts index 4a566346a..04e9f3093 100644 --- a/opendc-web/opendc-web-proto/build.gradle.kts +++ b/opendc-web/opendc-web-proto/build.gradle.kts @@ -24,16 +24,13 @@ description = "Web communication protocol for OpenDC" /* Build configuration */ plugins { - `kotlin-library-conventions` - id("org.kordamp.gradle.jandex") // Necessary for Quarkus to process annotations + `java-library-conventions` } dependencies { implementation(libs.jackson.annotations) implementation(libs.jakarta.validation) + implementation(libs.jakarta.ws.rs.api) + implementation(libs.microprofile.rest.client.api) implementation(libs.microprofile.openapi.api) } - -tasks.withType { - kotlinOptions.javaParameters = true -} diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/JobState.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/JobState.java similarity index 93% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/JobState.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/JobState.java index 38b8ca427..14a0faba4 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/JobState.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/JobState.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,12 +20,12 @@ * SOFTWARE. */ -package org.opendc.web.proto +package org.opendc.web.proto; /** * State of a scenario for the simulator runner. */ -public enum class JobState { +public enum JobState { /** * The job is pending to be claimed by a runner. */ @@ -49,5 +49,5 @@ public enum class JobState { /** * The job has failed. */ - FAILED; + FAILED } diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/OperationalPhenomena.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/OperationalPhenomena.java similarity index 87% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/OperationalPhenomena.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/OperationalPhenomena.java index f3164f647..cf492e382 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/OperationalPhenomena.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/OperationalPhenomena.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,12 +20,9 @@ * SOFTWARE. */ -package org.opendc.web.proto +package org.opendc.web.proto; /** * Object describing the enabled operational phenomena for a scenario. */ -public data class OperationalPhenomena( - val failures: Boolean, - val interference: Boolean -) +public record OperationalPhenomena(boolean failures, boolean interference) {} diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/ProtocolError.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/ProtocolError.java similarity index 89% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/ProtocolError.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/ProtocolError.java index e7fe2702f..cb9324ea7 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/ProtocolError.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/ProtocolError.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,9 +20,9 @@ * SOFTWARE. */ -package org.opendc.web.proto +package org.opendc.web.proto; /** * Container for reporting errors. */ -public data class ProtocolError(val code: Int, val message: String) +public record ProtocolError(int code, String message) {} diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Targets.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Targets.java similarity index 85% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Targets.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Targets.java index a0100f72b..4823bb665 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Targets.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Targets.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,9 +20,10 @@ * SOFTWARE. */ -package org.opendc.web.proto +package org.opendc.web.proto; -import javax.validation.constraints.Min +import jakarta.validation.constraints.Min; +import java.util.Set; /** * The targets of a portfolio. @@ -30,8 +31,4 @@ * @param metrics The selected metrics to track during simulation. * @param repeats The number of repetitions per scenario. */ -public data class Targets( - val metrics: Set, - @field:Min(1) - val repeats: Int = 1 -) +public record Targets(Set metrics, @Min(1) int repeats) {} diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Trace.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Trace.java similarity index 88% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Trace.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Trace.java index 1c086cd83..adf916d3a 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Trace.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Trace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,7 @@ * SOFTWARE. */ -package org.opendc.web.proto +package org.opendc.web.proto; /** * A workload trace available for simulation. @@ -29,8 +29,4 @@ * @param name The name of the trace. * @param type The type of trace. */ -public data class Trace( - val id: String, - val name: String, - val type: String -) +public record Trace(String id, String name, String type) {} diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Workload.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Workload.java similarity index 72% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Workload.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Workload.java index cc6e0ed8e..e8f552d6a 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Workload.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/Workload.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,25 +20,24 @@ * SOFTWARE. */ -package org.opendc.web.proto +package org.opendc.web.proto; -import javax.validation.constraints.DecimalMax -import javax.validation.constraints.DecimalMin +import jakarta.validation.constraints.DecimalMax; +import jakarta.validation.constraints.DecimalMin; /** * The workload to simulate for a scenario. */ -public data class Workload(val trace: Trace, val samplingFraction: Double) { +public record Workload(Trace trace, double samplingFraction) { /** * Specification for a workload. * * @param trace The unique identifier of the trace. * @param samplingFraction The fraction of the workload to sample. */ - public data class Spec( - val trace: String, - @DecimalMin(value = "0.001", message = "Sampling fraction must be non-zero") - @DecimalMax(value = "1", message = "Sampling fraction cannot exceed one") - val samplingFraction: Double - ) + public record Spec( + String trace, + @DecimalMin(value = "0.001", message = "Sampling fraction must be non-zero") + @DecimalMax(value = "1", message = "Sampling fraction cannot exceed one") + double samplingFraction) {} } diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Job.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Job.java similarity index 68% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Job.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Job.java index 4f21f0bbe..587fe4518 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Job.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Job.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,32 +20,32 @@ * SOFTWARE. */ -package org.opendc.web.proto.runner +package org.opendc.web.proto.runner; -import org.eclipse.microprofile.openapi.annotations.media.Schema -import org.opendc.web.proto.JobState -import java.time.Instant +import java.time.Instant; +import java.util.Map; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.opendc.web.proto.JobState; /** * A simulation job to be simulated by a runner. */ @Schema(name = "Runner.Job") -public data class Job( - val id: Long, - val scenario: Scenario, - val state: JobState, - val createdAt: Instant, - val updatedAt: Instant, - val runtime: Int, - val results: Map? = null -) { +public record Job( + long id, + Scenario scenario, + JobState state, + Instant createdAt, + Instant updatedAt, + int runtime, + Map results) { /** * A request to update the state of a job. * - * @property state The next state of the job. - * @property runtime The runtime of the job (in seconds). - * @property results The results of the job. + * @param state The next state of the job. + * @param runtime The runtime of the job (in seconds). + * @param results The results of the job. */ @Schema(name = "Runner.Job.Update") - public data class Update(val state: JobState, val runtime: Int, val results: Map? = null) + public record Update(JobState state, int runtime, Map results) {} } diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/JobService.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/JobService.java new file mode 100644 index 000000000..33b520a0d --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/JobService.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2023 AtLarge Research + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package org.opendc.web.proto.runner; + +import jakarta.validation.Valid; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import java.util.List; +import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; + +/** + * Service for interacting with the OpenDC job server. + */ +@Path("/jobs") +@RegisterRestClient +public interface JobService { + /** + * Obtain all pending simulation jobs. + */ + @GET + List queryPending(); + + /** + * Get a job by identifier. + */ + @GET + @Path("{job}") + Job get(@PathParam("job") long id); + + /** + * Atomically update the state of a job. + */ + @POST + @Path("{job}") + @Consumes("application/json") + Job update(@PathParam("job") long id, @Valid Job.Update update); +} diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Portfolio.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Portfolio.java similarity index 81% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Portfolio.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Portfolio.java index 5faad5b3f..44f0b500f 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Portfolio.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Portfolio.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,14 +20,13 @@ * SOFTWARE. */ -package org.opendc.web.proto.runner +package org.opendc.web.proto.runner; -import org.eclipse.microprofile.openapi.annotations.media.Schema -import org.opendc.web.proto.Targets -import org.opendc.web.proto.user.Portfolio +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.opendc.web.proto.Targets; /** - * A [Portfolio] as seen from the runner's perspective. + * A {@link Portfolio} as seen from the runner's perspective. * * @param id The unique identifier of the portfolio. * @param number The number of the portfolio for the project. @@ -35,9 +34,4 @@ * @param targets The targets of the portfolio. */ @Schema(name = "Runner.Portfolio") -public data class Portfolio( - val id: Long, - val number: Int, - val name: String, - val targets: Targets -) +public record Portfolio(long id, int number, String name, Targets targets) {} diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Scenario.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Scenario.java similarity index 72% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Scenario.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Scenario.java index aeffc4d7b..8005ac3bd 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Scenario.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Scenario.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,23 +20,22 @@ * SOFTWARE. */ -package org.opendc.web.proto.runner +package org.opendc.web.proto.runner; -import org.eclipse.microprofile.openapi.annotations.media.Schema -import org.opendc.web.proto.OperationalPhenomena -import org.opendc.web.proto.Workload +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.opendc.web.proto.OperationalPhenomena; +import org.opendc.web.proto.Workload; /** - * A [Scenario] that is exposed to an OpenDC runner. + * A {@link Scenario} that is exposed to an OpenDC runner. */ @Schema(name = "Runner.Scenario") -public data class Scenario( - val id: Long, - val number: Int, - val portfolio: Portfolio, - val name: String, - val workload: Workload, - val topology: Topology, - val phenomena: OperationalPhenomena, - val schedulerName: String -) +public record Scenario( + long id, + int number, + Portfolio portfolio, + String name, + Workload workload, + Topology topology, + OperationalPhenomena phenomena, + String schedulerName) {} diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Topology.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Topology.java similarity index 80% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Topology.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Topology.java index bc185aead..fdabd12df 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/runner/Topology.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/runner/Topology.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,21 +20,15 @@ * SOFTWARE. */ -package org.opendc.web.proto.runner +package org.opendc.web.proto.runner; -import org.eclipse.microprofile.openapi.annotations.media.Schema -import org.opendc.web.proto.Room -import java.time.Instant +import java.time.Instant; +import java.util.List; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.opendc.web.proto.topology.Room; /** * A [Topology] that is exposed to an OpenDC runner. */ @Schema(name = "Runner.Topology") -public data class Topology( - val id: Long, - val number: Int, - val name: String, - val rooms: List, - val createdAt: Instant, - val updatedAt: Instant -) +public record Topology(long id, int number, String name, List rooms, Instant createdAt, Instant updatedAt) {} diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/Machine.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/Machine.java new file mode 100644 index 000000000..ec78f2490 --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/Machine.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2023 AtLarge Research + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package org.opendc.web.proto.topology; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** + * A machine in a rack. + */ +public record Machine( + String id, + int position, + List cpus, + List gpus, + @JsonProperty("memories") List memory, + @JsonProperty("storages") List storage, + String rackId) {} diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/MemoryUnit.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/MemoryUnit.java similarity index 82% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/MemoryUnit.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/MemoryUnit.java index 1fc604fad..a53b584a8 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/MemoryUnit.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/MemoryUnit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,15 +20,9 @@ * SOFTWARE. */ -package org.opendc.web.proto +package org.opendc.web.proto.topology; /** * A memory unit in a system. */ -public data class MemoryUnit( - val id: String, - val name: String, - val speedMbPerS: Double, - val sizeMb: Double, - val energyConsumptionW: Double -) +public record MemoryUnit(String id, String name, double speedMbPerS, double sizeMb, double energyConsumptionW) {} diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/ProcessingUnit.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/ProcessingUnit.java similarity index 82% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/ProcessingUnit.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/ProcessingUnit.java index 5f79d1bd6..baa61aace 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/ProcessingUnit.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/ProcessingUnit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,15 +20,10 @@ * SOFTWARE. */ -package org.opendc.web.proto +package org.opendc.web.proto.topology; /** * A CPU model. */ -public data class ProcessingUnit( - val id: String, - val name: String, - val clockRateMhz: Double, - val numberOfCores: Int, - val energyConsumptionW: Double -) +public record ProcessingUnit( + String id, String name, double clockRateMhz, int numberOfCores, double energyConsumptionW) {} diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Rack.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/Rack.java similarity index 83% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Rack.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/Rack.java index 131aa1846..b68fddd3d 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Rack.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/Rack.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,15 +20,11 @@ * SOFTWARE. */ -package org.opendc.web.proto +package org.opendc.web.proto.topology; + +import java.util.List; /** * A rack in a datacenter. */ -public data class Rack( - val id: String, - val name: String, - val capacity: Int, - val powerCapacityW: Double, - val machines: List -) +public record Rack(String id, String name, int capacity, double powerCapacityW, List machines) {} diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Room.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/Room.java similarity index 84% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Room.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/Room.java index c54991501..530d21f5c 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Room.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/Room.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,14 +20,11 @@ * SOFTWARE. */ -package org.opendc.web.proto +package org.opendc.web.proto.topology; + +import java.util.Set; /** * A room in a datacenter. */ -public data class Room( - val id: String, - val name: String, - val tiles: Set, - val topologyId: String? = null -) +public record Room(String id, String name, Set tiles, String topologyId) {} diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/RoomTile.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/RoomTile.java new file mode 100644 index 000000000..a72405413 --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/topology/RoomTile.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 AtLarge Research + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package org.opendc.web.proto.topology; + +/** + * A location in a room. + */ +public record RoomTile(String id, double positionX, double positionY, Rack rack, String roomId) {} diff --git a/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Job.java b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Job.java new file mode 100644 index 000000000..480efdad9 --- /dev/null +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Job.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 AtLarge Research + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package org.opendc.web.proto.user; + +import java.time.Instant; +import java.util.Map; +import org.opendc.web.proto.JobState; + +/** + * A simulation job that is associated with a {@link Scenario}. + *

+ * This entity is exposed in the runner-facing API via {@link Job}. + */ +public record Job(long id, JobState state, Instant createdAt, Instant updatedAt, Map results) {} diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Portfolio.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Portfolio.java similarity index 75% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Portfolio.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Portfolio.java index 99d0f65e4..ff8d9e82c 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Portfolio.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Portfolio.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,11 +20,12 @@ * SOFTWARE. */ -package org.opendc.web.proto.user +package org.opendc.web.proto.user; -import org.eclipse.microprofile.openapi.annotations.media.Schema -import org.opendc.web.proto.Targets -import javax.validation.constraints.NotBlank +import jakarta.validation.constraints.NotBlank; +import java.util.List; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.opendc.web.proto.Targets; /** * A portfolio is the composition of multiple scenarios. @@ -36,23 +37,13 @@ * @param targets The targets of the portfolio. * @param scenarios The scenarios in the portfolio. */ -public data class Portfolio( - val id: Long, - val number: Int, - val project: Project, - val name: String, - val targets: Targets, - val scenarios: List -) { +public record Portfolio( + long id, int number, Project project, String name, Targets targets, List scenarios) { /** * A request to create a new portfolio. */ @Schema(name = "Portfolio.Update") - public data class Create( - @field:NotBlank(message = "Name must not be empty") - val name: String, - val targets: Targets - ) + public record Create(@NotBlank(message = "Name must not be empty") String name, Targets targets) {} /** * A summary view of a [Portfolio] provided for nested relations. @@ -63,10 +54,5 @@ public data class Create( * @param targets The targets of the portfolio. */ @Schema(name = "Portfolio.Summary") - public data class Summary( - val id: Long, - val number: Int, - val name: String, - val targets: Targets - ) + public record Summary(long id, int number, String name, Targets targets) {} } diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Project.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Project.java similarity index 77% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Project.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Project.java index 3a2807ca6..534fdb266 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Project.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Project.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,25 +20,19 @@ * SOFTWARE. */ -package org.opendc.web.proto.user +package org.opendc.web.proto.user; -import org.eclipse.microprofile.openapi.annotations.media.Schema -import java.time.Instant -import javax.validation.constraints.NotBlank +import jakarta.validation.constraints.NotBlank; +import java.time.Instant; +import org.eclipse.microprofile.openapi.annotations.media.Schema; /** * A project in OpenDC encapsulates all the datacenter designs and simulation runs for a set of users. */ -public data class Project( - val id: Long, - val name: String, - val createdAt: Instant, - val updatedAt: Instant, - val role: ProjectRole -) { +public record Project(long id, String name, Instant createdAt, Instant updatedAt, ProjectRole role) { /** * A request to create a new project. */ @Schema(name = "Project.Create") - public data class Create(@field:NotBlank(message = "Name must not be empty") val name: String) + public record Create(@NotBlank(message = "Name must not be empty") String name) {} } diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/ProjectRole.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/ProjectRole.java similarity index 92% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/ProjectRole.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/ProjectRole.java index ea6a30abc..3d3ba5068 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/ProjectRole.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/ProjectRole.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,12 +20,12 @@ * SOFTWARE. */ -package org.opendc.web.proto.user +package org.opendc.web.proto.user; /** * The role of a user in a project. */ -public enum class ProjectRole { +public enum ProjectRole { /** * The user is allowed to view the project. */ diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Scenario.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Scenario.java similarity index 64% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Scenario.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Scenario.java index b9c7a4cfe..7add5656d 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Scenario.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Scenario.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,28 +20,28 @@ * SOFTWARE. */ -package org.opendc.web.proto.user +package org.opendc.web.proto.user; -import org.eclipse.microprofile.openapi.annotations.media.Schema -import org.opendc.web.proto.OperationalPhenomena -import org.opendc.web.proto.Workload -import javax.validation.constraints.NotBlank +import jakarta.validation.constraints.NotBlank; +import java.util.List; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.opendc.web.proto.OperationalPhenomena; +import org.opendc.web.proto.Workload; /** * A single scenario to be explored by the simulator. */ -public data class Scenario( - val id: Long, - val number: Int, - val project: Project, - val portfolio: Portfolio.Summary, - val name: String, - val workload: Workload, - val topology: Topology.Summary, - val phenomena: OperationalPhenomena, - val schedulerName: String, - val jobs: List -) { +public record Scenario( + long id, + int number, + Project project, + Portfolio.Summary portfolio, + String name, + Workload workload, + Topology.Summary topology, + OperationalPhenomena phenomena, + String schedulerName, + List jobs) { /** * Create a new scenario. * @@ -52,14 +52,12 @@ public data class Scenario( * @param schedulerName The name of the scheduler. */ @Schema(name = "Scenario.Create") - public data class Create( - @field:NotBlank(message = "Name must not be empty") - val name: String, - val workload: Workload.Spec, - val topology: Long, - val phenomena: OperationalPhenomena, - val schedulerName: String - ) + public record Create( + @NotBlank(message = "Name must not be empty") String name, + Workload.Spec workload, + long topology, + OperationalPhenomena phenomena, + String schedulerName) {} /** * A summary view of a [Scenario] provided for nested relations. @@ -70,17 +68,16 @@ public data class Create( * @param workload The workload to be modeled by the scenario. * @param phenomena The phenomena simulated for this scenario. * @param schedulerName The scheduler name to use for the experiment. - * @param job The simulation job associated with the scenario. + * @param jobs The simulation jobs associated with the scenario. */ @Schema(name = "Scenario.Summary") - public data class Summary( - val id: Long, - val number: Int, - val name: String, - val workload: Workload, - val topology: Topology.Summary, - val phenomena: OperationalPhenomena, - val schedulerName: String, - val jobs: List - ) + public record Summary( + long id, + int number, + String name, + Workload workload, + Topology.Summary topology, + OperationalPhenomena phenomena, + String schedulerName, + List jobs) {} } diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Topology.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Topology.java similarity index 70% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Topology.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Topology.java index 73748bb9b..7291c77bc 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Topology.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/Topology.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,40 +20,30 @@ * SOFTWARE. */ -package org.opendc.web.proto.user +package org.opendc.web.proto.user; -import org.eclipse.microprofile.openapi.annotations.media.Schema -import org.opendc.web.proto.Room -import java.time.Instant -import javax.validation.constraints.NotBlank +import jakarta.validation.constraints.NotBlank; +import java.time.Instant; +import java.util.List; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.opendc.web.proto.topology.Room; /** * Model for an OpenDC topology. */ -public data class Topology( - val id: Long, - val number: Int, - val project: Project, - val name: String, - val rooms: List, - val createdAt: Instant, - val updatedAt: Instant -) { +public record Topology( + long id, int number, Project project, String name, List rooms, Instant createdAt, Instant updatedAt) { /** * Create a new topology for a project. */ @Schema(name = "Topology.Create") - public data class Create( - @field:NotBlank(message = "Name must not be empty") - val name: String, - val rooms: List - ) + public record Create(@NotBlank(message = "Name must not be empty") String name, List rooms) {} /** * Update an existing topology. */ @Schema(name = "Topology.Update") - public data class Update(val rooms: List) + public record Update(List rooms) {} /** * A summary view of a [Topology] provided for nested relations. @@ -65,11 +55,5 @@ public data class Update(val rooms: List) * @param updatedAt The instant at which the topology was updated. */ @Schema(name = "Topology.Summary") - public data class Summary( - val id: Long, - val number: Int, - val name: String, - val createdAt: Instant, - val updatedAt: Instant - ) + public record Summary(long id, int number, String name, Instant createdAt, Instant updatedAt) {} } diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/User.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/User.java similarity index 87% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/User.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/User.java index f18cda617..030d92074 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/User.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/User.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,12 +20,9 @@ * SOFTWARE. */ -package org.opendc.web.proto.user +package org.opendc.web.proto.user; /** * A user of OpenDC. */ -public data class User( - val userId: String, - val accounting: UserAccounting -) +public record User(String userId, UserAccounting accounting) {} diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/UserAccounting.kt b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/UserAccounting.java similarity index 83% rename from opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/UserAccounting.kt rename to opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/UserAccounting.java index 2441983a5..3831381f5 100644 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/UserAccounting.kt +++ b/opendc-web/opendc-web-proto/src/main/java/org/opendc/web/proto/user/UserAccounting.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,15 +20,11 @@ * SOFTWARE. */ -package org.opendc.web.proto.user +package org.opendc.web.proto.user; -import java.time.LocalDate +import java.time.LocalDate; /** * Accounting data for a user. */ -public data class UserAccounting( - val periodEnd: LocalDate, - val simulationTime: Int, - val simulationTimeBudget: Int -) +public record UserAccounting(LocalDate periodEnd, int simulationTime, int simulationTimeBudget) {} diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Machine.kt b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Machine.kt deleted file mode 100644 index f5c50cc3c..000000000 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/Machine.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2022 AtLarge Research - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package org.opendc.web.proto - -import com.fasterxml.jackson.annotation.JsonProperty - -/** - * A machine in a rack. - */ -public data class Machine( - val id: String, - val position: Int, - val cpus: List = emptyList(), - val gpus: List = emptyList(), - @JsonProperty("memories") - val memory: List = emptyList(), - @JsonProperty("storages") - val storage: List = emptyList(), - val rackId: String? = null -) diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/RoomTile.kt b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/RoomTile.kt deleted file mode 100644 index 53cb53cde..000000000 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/RoomTile.kt +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2022 AtLarge Research - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package org.opendc.web.proto - -/** - * A room tile. - */ -public data class RoomTile( - val id: String, - val positionX: Double, - val positionY: Double, - val rack: Rack? = null, - val roomId: String? = null -) diff --git a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Job.kt b/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Job.kt deleted file mode 100644 index de5f8de3b..000000000 --- a/opendc-web/opendc-web-proto/src/main/kotlin/org/opendc/web/proto/user/Job.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2022 AtLarge Research - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package org.opendc.web.proto.user - -import org.opendc.web.proto.JobState -import org.opendc.web.proto.runner.Job -import java.time.Instant - -/** - * A simulation job that is associated with a [Scenario]. - * - * This entity is exposed in the runner-facing API via [Job]. - */ -public data class Job( - val id: Long, - val state: JobState, - val createdAt: Instant, - val updatedAt: Instant, - val results: Map? = null -) diff --git a/opendc-web/opendc-web-proto/src/main/resources/META-INF/beans.xml b/opendc-web/opendc-web-proto/src/main/resources/META-INF/beans.xml new file mode 100644 index 000000000..e69de29bb diff --git a/opendc-web/opendc-web-ui-quarkus-deployment/build.gradle.kts b/opendc-web/opendc-web-quarkus-deployment/build.gradle.kts similarity index 90% rename from opendc-web/opendc-web-ui-quarkus-deployment/build.gradle.kts rename to opendc-web/opendc-web-quarkus-deployment/build.gradle.kts index 5a42aaea9..a32e24b14 100644 --- a/opendc-web/opendc-web-ui-quarkus-deployment/build.gradle.kts +++ b/opendc-web/opendc-web-quarkus-deployment/build.gradle.kts @@ -30,10 +30,11 @@ plugins { dependencies { implementation(platform(libs.quarkus.bom)) - implementation(projects.opendcWeb.opendcWebUi) - implementation(projects.opendcWeb.opendcWebUiQuarkus) + implementation(projects.opendcWeb.opendcWebQuarkus) + implementation(projects.opendcTrace.opendcTraceApi) implementation(libs.quarkus.core.deployment) implementation(libs.quarkus.vertx.http.deployment) implementation(libs.quarkus.arc.deployment) + implementation(libs.quarkus.quinoa.deployment) } diff --git a/opendc-web/opendc-web-runner-quarkus-deployment/src/main/java/org/opendc/web/runner/deployment/OpenDCRunnerBuildItem.java b/opendc-web/opendc-web-quarkus-deployment/src/main/java/org/opendc/web/quarkus/deployment/runner/OpenDCRunnerBuildItem.java similarity index 94% rename from opendc-web/opendc-web-runner-quarkus-deployment/src/main/java/org/opendc/web/runner/deployment/OpenDCRunnerBuildItem.java rename to opendc-web/opendc-web-quarkus-deployment/src/main/java/org/opendc/web/quarkus/deployment/runner/OpenDCRunnerBuildItem.java index 3be15ee33..544365c88 100644 --- a/opendc-web/opendc-web-runner-quarkus-deployment/src/main/java/org/opendc/web/runner/deployment/OpenDCRunnerBuildItem.java +++ b/opendc-web/opendc-web-quarkus-deployment/src/main/java/org/opendc/web/quarkus/deployment/runner/OpenDCRunnerBuildItem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,7 @@ * SOFTWARE. */ -package org.opendc.web.runner.deployment; +package org.opendc.web.quarkus.deployment.runner; import io.quarkus.builder.item.SimpleBuildItem; import io.quarkus.runtime.RuntimeValue; diff --git a/opendc-web/opendc-web-runner-quarkus-deployment/src/main/java/org/opendc/web/runner/deployment/OpenDCRunnerConfig.java b/opendc-web/opendc-web-quarkus-deployment/src/main/java/org/opendc/web/quarkus/deployment/runner/OpenDCRunnerConfig.java similarity index 94% rename from opendc-web/opendc-web-runner-quarkus-deployment/src/main/java/org/opendc/web/runner/deployment/OpenDCRunnerConfig.java rename to opendc-web/opendc-web-quarkus-deployment/src/main/java/org/opendc/web/quarkus/deployment/runner/OpenDCRunnerConfig.java index ccbc5e19f..1bc201b20 100644 --- a/opendc-web/opendc-web-runner-quarkus-deployment/src/main/java/org/opendc/web/runner/deployment/OpenDCRunnerConfig.java +++ b/opendc-web/opendc-web-quarkus-deployment/src/main/java/org/opendc/web/quarkus/deployment/runner/OpenDCRunnerConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,7 @@ * SOFTWARE. */ -package org.opendc.web.runner.deployment; +package org.opendc.web.quarkus.deployment.runner; import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigRoot; diff --git a/opendc-web/opendc-web-runner-quarkus-deployment/src/main/java/org/opendc/web/runner/deployment/OpenDCRunnerProcessor.java b/opendc-web/opendc-web-quarkus-deployment/src/main/java/org/opendc/web/quarkus/deployment/runner/OpenDCRunnerProcessor.java similarity index 95% rename from opendc-web/opendc-web-runner-quarkus-deployment/src/main/java/org/opendc/web/runner/deployment/OpenDCRunnerProcessor.java rename to opendc-web/opendc-web-quarkus-deployment/src/main/java/org/opendc/web/quarkus/deployment/runner/OpenDCRunnerProcessor.java index 85a973e71..a796c01d3 100644 --- a/opendc-web/opendc-web-runner-quarkus-deployment/src/main/java/org/opendc/web/runner/deployment/OpenDCRunnerProcessor.java +++ b/opendc-web/opendc-web-quarkus-deployment/src/main/java/org/opendc/web/quarkus/deployment/runner/OpenDCRunnerProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,7 @@ * SOFTWARE. */ -package org.opendc.web.runner.deployment; +package org.opendc.web.quarkus.deployment.runner; import static io.quarkus.deployment.annotations.ExecutionTime.RUNTIME_INIT; @@ -36,10 +36,10 @@ import java.util.Set; import java.util.function.BooleanSupplier; import org.opendc.trace.spi.TraceFormat; +import org.opendc.web.quarkus.runtime.runner.OpenDCRunnerRecorder; +import org.opendc.web.quarkus.runtime.runner.OpenDCRunnerRuntimeConfig; import org.opendc.web.runner.JobManager; import org.opendc.web.runner.OpenDCRunner; -import org.opendc.web.runner.runtime.OpenDCRunnerRecorder; -import org.opendc.web.runner.runtime.OpenDCRunnerRuntimeConfig; /** * Build processor for the OpenDC web runner Quarkus extension. diff --git a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiRoutingBuildItem.java b/opendc-web/opendc-web-quarkus-deployment/src/main/java/org/opendc/web/quarkus/deployment/ui/NextRouteManifestBuildItem.java similarity index 55% rename from opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiRoutingBuildItem.java rename to opendc-web/opendc-web-quarkus-deployment/src/main/java/org/opendc/web/quarkus/deployment/ui/NextRouteManifestBuildItem.java index 6cf448936..4640b04b9 100644 --- a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiRoutingBuildItem.java +++ b/opendc-web/opendc-web-quarkus-deployment/src/main/java/org/opendc/web/quarkus/deployment/ui/NextRouteManifestBuildItem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,28 +20,28 @@ * SOFTWARE. */ -package org.opendc.web.ui.deployment; +package org.opendc.web.quarkus.deployment.ui; import io.quarkus.builder.item.SimpleBuildItem; import java.util.List; /** - * Build item containing the routes for the OpenDC web UI. + * Build item containing the route manifest of the Next.js application. */ -public final class OpenDCUiRoutingBuildItem extends SimpleBuildItem { +public final class NextRouteManifestBuildItem extends SimpleBuildItem { private final boolean custom404; private final List pages; private final List redirects; /** - * Construct a {@link OpenDCUiRoutingBuildItem} instance. + * Construct a {@link NextRouteManifestBuildItem} object. * * @param routes The routes defined by Next.js. * @param redirects The redirects that have been defined by Next.js. * @param custom404 A flag to indicate that custom 404 pages are enabled. */ - public OpenDCUiRoutingBuildItem(List routes, List redirects, boolean custom404) { + public NextRouteManifestBuildItem(List routes, List redirects, boolean custom404) { this.custom404 = custom404; this.pages = routes; this.redirects = redirects; @@ -61,58 +61,18 @@ public boolean hasCustom404() { /** * A redirect defined by the Next.js routes manifest. + * + * @param path The path that should result in a redirect. + * @param destination The destination of the redirect. + * @param statusCode The status code of the redirect. */ - public static final class Redirect { - - private final String path; - private final String destination; - private final int statusCode; - - /** - * Construct a {@link Redirect} route. - * - * @param path The path that should result in a redirect. - * @param destination The destination of the redirect. - * @param statusCode The status code of the redirect. - */ - public Redirect(String path, String destination, int statusCode) { - this.statusCode = statusCode; - this.path = path; - this.destination = destination; - } - - public String getPath() { - return path; - } - - public String getDestination() { - return destination; - } - - public int getStatusCode() { - return statusCode; - } - } + public record Redirect(String path, String destination, int statusCode) {} /** * A page defined by the Next.js routes manifest. + * + * @param path The path that to the page. + * @param name The name of the page. */ - public static final class Page { - - private final String path; - private final String name; - - public Page(String path, String page) { - this.path = path; - this.name = page; - } - - public String getPath() { - return path; - } - - public String getName() { - return name; - } - } + public record Page(String path, String name) {} } diff --git a/opendc-web/opendc-web-quarkus-deployment/src/main/java/org/opendc/web/quarkus/deployment/ui/OpenDCUiProcessor.java b/opendc-web/opendc-web-quarkus-deployment/src/main/java/org/opendc/web/quarkus/deployment/ui/OpenDCUiProcessor.java new file mode 100644 index 000000000..8b2c0244e --- /dev/null +++ b/opendc-web/opendc-web-quarkus-deployment/src/main/java/org/opendc/web/quarkus/deployment/ui/OpenDCUiProcessor.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023 AtLarge Research + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package org.opendc.web.quarkus.deployment.ui; + +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.annotations.ExecutionTime; +import io.quarkus.deployment.annotations.Record; +import io.quarkus.vertx.http.deployment.HttpRootPathBuildItem; +import io.quarkus.vertx.http.deployment.RouteBuildItem; +import org.opendc.web.quarkus.runtime.ui.OpenDCUiConfig; +import org.opendc.web.quarkus.runtime.ui.OpenDCUiRecorder; + +/** + * Quarkus build processor for the OpenDC web UI. + */ +public class OpenDCUiProcessor { + /** + * Register a route handler for serving the config of the OpenDC web UI. + */ + @BuildStep + @Record(ExecutionTime.RUNTIME_INIT) + public RouteBuildItem registerConfigHandler( + OpenDCUiRecorder openDCUiRecorder, + BuildProducer routes, + HttpRootPathBuildItem httpRootPathBuildItem, + OpenDCUiConfig openDCUiConfig) { + + String basePath = httpRootPathBuildItem.getRootPath(); + + return httpRootPathBuildItem + .routeBuilder() + .route(basePath + "/__ENV.js") + .handler(openDCUiRecorder.configHandler(openDCUiConfig)) + .build(); + } +} diff --git a/opendc-web/opendc-web-quarkus-deployment/src/main/java/org/opendc/web/quarkus/deployment/ui/QuinoaNextRoutingProcessor.java b/opendc-web/opendc-web-quarkus-deployment/src/main/java/org/opendc/web/quarkus/deployment/ui/QuinoaNextRoutingProcessor.java new file mode 100644 index 000000000..ddaa88096 --- /dev/null +++ b/opendc-web/opendc-web-quarkus-deployment/src/main/java/org/opendc/web/quarkus/deployment/ui/QuinoaNextRoutingProcessor.java @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2023 AtLarge Research + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package org.opendc.web.quarkus.deployment.ui; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import io.quarkiverse.quinoa.deployment.items.BuiltResourcesBuildItem; +import io.quarkiverse.quinoa.deployment.items.ConfiguredQuinoaBuildItem; +import io.quarkiverse.quinoa.deployment.items.TargetDirBuildItem; +import io.quarkus.deployment.IsNormal; +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.annotations.ExecutionTime; +import io.quarkus.deployment.annotations.Record; +import io.quarkus.vertx.http.deployment.HttpRootPathBuildItem; +import io.quarkus.vertx.http.deployment.RouteBuildItem; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.regex.Pattern; +import org.opendc.web.quarkus.runtime.ui.QuinoaNextRoutingRecorder; + +/** + * Quarkus build processor for enabling dynamic routes and redirects in Quinoa for Next.js applications. + */ +public class QuinoaNextRoutingProcessor { + private static final Pattern PATH_PARAM_PATTERN = Pattern.compile("\\[(\\w+)]"); + private final ObjectMapper objectMapper = new ObjectMapper(); + + /** + * Build the dynamic routes of the application based on the route manifest generated by Next.js. + * + * @param configuredQuinoa Quinoa configuration pointing to the UI directory. + * @param targetDirBuildItem Dependency on the build directory to ensure the Next.js is built before this build step + * is run. + * @return Routing manifest generated by the Next.js application. + */ + @BuildStep + public NextRouteManifestBuildItem buildRoutes( + ConfiguredQuinoaBuildItem configuredQuinoa, TargetDirBuildItem targetDirBuildItem) throws IOException { + if (configuredQuinoa == null) { + return null; + } + + Path routeManifestPath = configuredQuinoa.uiDir().resolve(".next/routes-manifest.json"); + if (Files.notExists(routeManifestPath)) { + throw new FileNotFoundException("Cannot find " + routeManifestPath + " for creating route map"); + } + + JsonNode routeManifest = objectMapper.readTree(routeManifestPath.toFile()); + + var pages = new ArrayList(); + for (Iterator it = routeManifest.get("staticRoutes").elements(); it.hasNext(); ) { + JsonNode route = it.next(); + + String page = route.get("page").asText(); + + // Static routes do not have any path parameters + pages.add(new NextRouteManifestBuildItem.Page(page, page)); + } + + for (Iterator it = routeManifest.get("dynamicRoutes").elements(); it.hasNext(); ) { + JsonNode route = it.next(); + + String page = route.get("page").asText(); + String path = PATH_PARAM_PATTERN.matcher(page).replaceAll(r -> ":" + r.group(1)); + + pages.add(new NextRouteManifestBuildItem.Page(path, page)); + } + + var redirects = new ArrayList(); + for (Iterator it = routeManifest.get("redirects").elements(); it.hasNext(); ) { + JsonNode redirect = it.next(); + if (redirect.has("internal")) { + continue; + } + + int statusCode = redirect.get("statusCode").asInt(); + String path = redirect.get("source").asText(); + String destination = redirect.get("destination").asText(); + + if (path.isEmpty()) { + path = "/"; + } + + redirects.add(new NextRouteManifestBuildItem.Redirect(path, destination, statusCode)); + } + + var custom404 = routeManifest.get("pages404").asBoolean(); + return new NextRouteManifestBuildItem(pages, redirects, custom404); + } + + /** + * Register the dynamic routes and redirects of the Next.js application. + */ + @Record(ExecutionTime.RUNTIME_INIT) + @BuildStep(onlyIf = IsNormal.class) + public void registerNextRoutes( + QuinoaNextRoutingRecorder recorder, + BuildProducer routes, + HttpRootPathBuildItem httpRootPathBuildItem, + BuiltResourcesBuildItem uiResources, + NextRouteManifestBuildItem routeManifestBuildItem) { + + if (uiResources.getNames().isEmpty()) { + return; + } + + String basePath = httpRootPathBuildItem.getRootPath(); + + /* Construct redirects */ + for (var redirect : routeManifestBuildItem.getRedirects()) { + String destination = basePath.equals("/") ? redirect.destination() : basePath + redirect.destination(); + + routes.produce(httpRootPathBuildItem + .routeBuilder() + .route(basePath + redirect.path()) + .handler(recorder.redirectHandler(destination, redirect.statusCode())) + .build()); + } + + /* Construct dynamic routes */ + for (var page : routeManifestBuildItem.getPages()) { + routes.produce(httpRootPathBuildItem + .routeBuilder() + .route(basePath + page.path()) + .handler(recorder.pageHandler(basePath, page.name())) + .build()); + } + } +} diff --git a/opendc-web/opendc-web-ui-quarkus/build.gradle.kts b/opendc-web/opendc-web-quarkus/build.gradle.kts similarity index 90% rename from opendc-web/opendc-web-ui-quarkus/build.gradle.kts rename to opendc-web/opendc-web-quarkus/build.gradle.kts index 3f8887f6b..a48c2eb38 100644 --- a/opendc-web/opendc-web-ui-quarkus/build.gradle.kts +++ b/opendc-web/opendc-web-quarkus/build.gradle.kts @@ -28,15 +28,15 @@ plugins { } quarkusExtension { - deploymentModule.set("opendc-web-ui-quarkus-deployment") + deploymentModule.set("opendc-web-quarkus-deployment") } dependencies { implementation(platform(libs.quarkus.bom)) + api(projects.opendcWeb.opendcWebRunner) + implementation(libs.quarkus.core.runtime) implementation(libs.quarkus.vertx.http.runtime) implementation(libs.quarkus.arc.runtime) } - -evaluationDependsOn(projects.opendcWeb.opendcWebUiQuarkusDeployment.dependencyProject.path) diff --git a/opendc-web/opendc-web-runner-quarkus/src/main/java/org/opendc/web/runner/runtime/OpenDCRunnerRecorder.java b/opendc-web/opendc-web-quarkus/src/main/java/org/opendc/web/quarkus/runtime/runner/OpenDCRunnerRecorder.java similarity index 95% rename from opendc-web/opendc-web-runner-quarkus/src/main/java/org/opendc/web/runner/runtime/OpenDCRunnerRecorder.java rename to opendc-web/opendc-web-quarkus/src/main/java/org/opendc/web/quarkus/runtime/runner/OpenDCRunnerRecorder.java index 76f2368fa..814ddf15e 100644 --- a/opendc-web/opendc-web-runner-quarkus/src/main/java/org/opendc/web/runner/runtime/OpenDCRunnerRecorder.java +++ b/opendc-web/opendc-web-quarkus/src/main/java/org/opendc/web/quarkus/runtime/runner/OpenDCRunnerRecorder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,13 +20,13 @@ * SOFTWARE. */ -package org.opendc.web.runner.runtime; +package org.opendc.web.quarkus.runtime.runner; import io.quarkus.runtime.RuntimeValue; import io.quarkus.runtime.ShutdownContext; import io.quarkus.runtime.annotations.Recorder; +import jakarta.enterprise.inject.spi.CDI; import java.io.File; -import javax.enterprise.inject.spi.CDI; import org.jboss.logging.Logger; import org.opendc.web.runner.JobManager; import org.opendc.web.runner.OpenDCRunner; diff --git a/opendc-web/opendc-web-runner-quarkus/src/main/java/org/opendc/web/runner/runtime/OpenDCRunnerRuntimeConfig.java b/opendc-web/opendc-web-quarkus/src/main/java/org/opendc/web/quarkus/runtime/runner/OpenDCRunnerRuntimeConfig.java similarity index 96% rename from opendc-web/opendc-web-runner-quarkus/src/main/java/org/opendc/web/runner/runtime/OpenDCRunnerRuntimeConfig.java rename to opendc-web/opendc-web-quarkus/src/main/java/org/opendc/web/quarkus/runtime/runner/OpenDCRunnerRuntimeConfig.java index 61c07e481..fbc56bfaa 100644 --- a/opendc-web/opendc-web-runner-quarkus/src/main/java/org/opendc/web/runner/runtime/OpenDCRunnerRuntimeConfig.java +++ b/opendc-web/opendc-web-quarkus/src/main/java/org/opendc/web/quarkus/runtime/runner/OpenDCRunnerRuntimeConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,7 @@ * SOFTWARE. */ -package org.opendc.web.runner.runtime; +package org.opendc.web.quarkus.runtime.runner; import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; diff --git a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/AuthConfiguration.java b/opendc-web/opendc-web-quarkus/src/main/java/org/opendc/web/quarkus/runtime/ui/AuthConfiguration.java similarity index 95% rename from opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/AuthConfiguration.java rename to opendc-web/opendc-web-quarkus/src/main/java/org/opendc/web/quarkus/runtime/ui/AuthConfiguration.java index 82e025495..10f919238 100644 --- a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/AuthConfiguration.java +++ b/opendc-web/opendc-web-quarkus/src/main/java/org/opendc/web/quarkus/runtime/ui/AuthConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,7 @@ * SOFTWARE. */ -package org.opendc.web.ui.deployment; +package org.opendc.web.quarkus.runtime.ui; import io.quarkus.runtime.annotations.ConfigGroup; import io.quarkus.runtime.annotations.ConfigItem; diff --git a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiConfig.java b/opendc-web/opendc-web-quarkus/src/main/java/org/opendc/web/quarkus/runtime/ui/OpenDCUiConfig.java similarity index 83% rename from opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiConfig.java rename to opendc-web/opendc-web-quarkus/src/main/java/org/opendc/web/quarkus/runtime/ui/OpenDCUiConfig.java index 091e60ab7..541cfdc19 100644 --- a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiConfig.java +++ b/opendc-web/opendc-web-quarkus/src/main/java/org/opendc/web/quarkus/runtime/ui/OpenDCUiConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 AtLarge Research + * Copyright (c) 2023 AtLarge Research * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,23 +20,18 @@ * SOFTWARE. */ -package org.opendc.web.ui.deployment; +package org.opendc.web.quarkus.runtime.ui; import io.quarkus.runtime.annotations.ConfigItem; +import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import java.util.Optional; /** - * Build-time configuration for the OpenDC UI extension. + * Configuration for the OpenDC web UI. */ -@ConfigRoot(name = "opendc-ui") +@ConfigRoot(phase = ConfigPhase.RUN_TIME, name = "opendc-ui") public class OpenDCUiConfig { - /** - * A flag to include the OpenDC UI extension into the build. - */ - @ConfigItem(defaultValue = "true") - boolean include; - /** * The base URL of the OpenDC API. */ diff --git a/opendc-web/opendc-web-quarkus/src/main/java/org/opendc/web/quarkus/runtime/ui/OpenDCUiRecorder.java b/opendc-web/opendc-web-quarkus/src/main/java/org/opendc/web/quarkus/runtime/ui/OpenDCUiRecorder.java new file mode 100644 index 000000000..5783e4318 --- /dev/null +++ b/opendc-web/opendc-web-quarkus/src/main/java/org/opendc/web/quarkus/runtime/ui/OpenDCUiRecorder.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2023 AtLarge Research + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package org.opendc.web.quarkus.runtime.ui; + +import static io.vertx.ext.web.handler.StaticHandler.DEFAULT_MAX_AGE_SECONDS; + +import io.quarkus.runtime.annotations.Recorder; +import io.vertx.core.Handler; +import io.vertx.core.http.HttpHeaders; +import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.HttpServerRequest; +import io.vertx.core.json.JsonObject; +import io.vertx.ext.web.RoutingContext; +import io.vertx.ext.web.impl.Utils; + +/** + * Recorder class for the OpenDC web UI. + */ +@Recorder +public class OpenDCUiRecorder { + /** + * Construct a {@link Handler} for serving the configuration of the OpenDC web UI. + */ + public Handler configHandler(OpenDCUiConfig config) { + return (event) -> { + HttpServerRequest request = event.request(); + if (request.method() != HttpMethod.GET && request.method() != HttpMethod.HEAD) { + event.next(); + return; + } + + event.response() + .setStatusCode(200) + .putHeader(HttpHeaders.CONTENT_TYPE, "text/javascript") + .putHeader(HttpHeaders.CACHE_CONTROL, "public, immutable, max-age=" + DEFAULT_MAX_AGE_SECONDS) + .putHeader(HttpHeaders.DATE, Utils.formatRFC1123DateTime(System.currentTimeMillis())) + .end(OpenDCUiRecorder.serializeConfig(config)); + }; + } + + /** + * Serialize the configuration of the OpenDC web UI into JSON. + * + * @param config The configuration of the OpenDC web UI specified by the user. + * @return JS serialized version of the OpenDC web UI config. + */ + private static String serializeConfig(OpenDCUiConfig config) { + JsonObject configJson = JsonObject.of("NEXT_PUBLIC_API_BASE_URL", config.apiBaseUrl); + config.auth.domain.ifPresent(s -> configJson.put("NEXT_PUBLIC_AUTH0_DOMAIN", s)); + config.auth.clientId.ifPresent(s -> configJson.put("NEXT_PUBLIC_AUTH0_CLIENT_ID", s)); + config.auth.audience.ifPresent(s -> configJson.put("NEXT_PUBLIC_AUTH0_AUDIENCE", s)); + config.sentryDsn.ifPresent(s -> configJson.put("NEXT_PUBLIC_SENTRY_DSN", s)); + + return "window.__ENV = " + configJson.encode() + ";"; + } +} diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/error/MissingKotlinParameterExceptionMapper.java b/opendc-web/opendc-web-quarkus/src/main/java/org/opendc/web/quarkus/runtime/ui/QuinoaNextRoutingRecorder.java similarity index 51% rename from opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/error/MissingKotlinParameterExceptionMapper.java rename to opendc-web/opendc-web-quarkus/src/main/java/org/opendc/web/quarkus/runtime/ui/QuinoaNextRoutingRecorder.java index 3b6be42e5..c511220db 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/error/MissingKotlinParameterExceptionMapper.java +++ b/opendc-web/opendc-web-quarkus/src/main/java/org/opendc/web/quarkus/runtime/ui/QuinoaNextRoutingRecorder.java @@ -20,27 +20,36 @@ * SOFTWARE. */ -package org.opendc.web.server.rest.error; +package org.opendc.web.quarkus.runtime.ui; -import com.fasterxml.jackson.module.kotlin.MissingKotlinParameterException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; -import org.opendc.web.proto.ProtocolError; +import io.quarkus.runtime.annotations.Recorder; +import io.vertx.core.Handler; +import io.vertx.ext.web.RoutingContext; /** - * An [ExceptionMapper] for [MissingKotlinParameterException] thrown by Jackson. + * Recorder class for building route handlers for Next.js pages and redirects. */ -@Provider -public final class MissingKotlinParameterExceptionMapper implements ExceptionMapper { - @Override - public Response toResponse(MissingKotlinParameterException exception) { - return Response.status(Response.Status.BAD_REQUEST) - .entity(new ProtocolError( - Response.Status.BAD_REQUEST.getStatusCode(), - "Field " + exception.getParameter().getName() + " is missing from body.")) - .type(MediaType.APPLICATION_JSON) - .build(); +@Recorder +public class QuinoaNextRoutingRecorder { + /** + * Construct a {@link Handler} for serving a dynamic route of a Next.js application. + */ + public Handler pageHandler(String basePath, String page) { + return (event) -> event.reroute(basePath + page + ".html"); + } + + /** + * Construct a {@link Handler} for handling redirects of a Next.js application. + */ + public Handler redirectHandler(String destination, int statusCode) { + return (event) -> { + String query = event.request().query(); + String fullDestination = query != null ? destination + "?" + query : destination; + + event.response() + .setStatusCode(statusCode) + .putHeader("Location", fullDestination) + .end(); + }; } } diff --git a/opendc-web/opendc-web-ui-quarkus/src/main/resources/META-INF/quarkus-extension.yaml b/opendc-web/opendc-web-quarkus/src/main/resources/META-INF/quarkus-extension.yaml similarity index 100% rename from opendc-web/opendc-web-ui-quarkus/src/main/resources/META-INF/quarkus-extension.yaml rename to opendc-web/opendc-web-quarkus/src/main/resources/META-INF/quarkus-extension.yaml diff --git a/opendc-web/opendc-web-runner-quarkus-deployment/build.gradle.kts b/opendc-web/opendc-web-runner-quarkus-deployment/build.gradle.kts deleted file mode 100644 index b3f1ec3b0..000000000 --- a/opendc-web/opendc-web-runner-quarkus-deployment/build.gradle.kts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2022 AtLarge Research - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -description = "Quarkus extension for the OpenDC experiment runner" - -/* Build configuration */ -plugins { - `java-library-conventions` -} - -dependencies { - implementation(projects.opendcWeb.opendcWebRunnerQuarkus) - implementation(projects.opendcTrace.opendcTraceApi) - - implementation(platform(libs.quarkus.bom)) - implementation(libs.quarkus.core.deployment) - implementation(libs.quarkus.arc.deployment) -} diff --git a/opendc-web/opendc-web-runner-quarkus/build.gradle.kts b/opendc-web/opendc-web-runner-quarkus/build.gradle.kts deleted file mode 100644 index 8e4e08d5d..000000000 --- a/opendc-web/opendc-web-runner-quarkus/build.gradle.kts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2022 AtLarge Research - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -description = "Quarkus extension for the OpenDC experiment runner" - -plugins { - `java-library-conventions` - id("io.quarkus.extension") -} - -quarkusExtension { - deploymentModule.set("opendc-web-runner-quarkus-deployment") -} - -dependencies { - modules { - module("javax.annotation:javax.annotation-api") { - replacedBy("jakarta.annotation:jakarta.annotation-api", "javax has been replaced by Jakarta") - } - } - - api(projects.opendcWeb.opendcWebRunner) - - implementation(platform(libs.quarkus.bom)) - implementation(libs.quarkus.core.runtime) -} - -evaluationDependsOn(projects.opendcWeb.opendcWebRunnerQuarkusDeployment.dependencyProject.path) diff --git a/opendc-web/opendc-web-runner-quarkus/src/main/resources/META-INF/quarkus-extension.yaml b/opendc-web/opendc-web-runner-quarkus/src/main/resources/META-INF/quarkus-extension.yaml deleted file mode 100644 index b93b467ab..000000000 --- a/opendc-web/opendc-web-runner-quarkus/src/main/resources/META-INF/quarkus-extension.yaml +++ /dev/null @@ -1,5 +0,0 @@ ---- -name: "OpenDC Web Runner" -metadata: - status: "preview" - unlisted: true diff --git a/opendc-web/opendc-web-runner/build.gradle.kts b/opendc-web/opendc-web-runner/build.gradle.kts index 531a96319..14bab521f 100644 --- a/opendc-web/opendc-web-runner/build.gradle.kts +++ b/opendc-web/opendc-web-runner/build.gradle.kts @@ -71,7 +71,7 @@ val createCli by tasks.creating(CreateStartScripts::class) { applicationName = "opendc-runner" mainClass.set("org.opendc.web.runner.cli.MainKt") classpath = cliJar.outputs.files + cliRuntimeClasspath - outputDir = project.buildDir.resolve("scripts") + outputDir = project.layout.buildDirectory.dir("scripts").get().asFile } distributions { diff --git a/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/internal/JobManagerImpl.kt b/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/internal/JobManagerImpl.kt index 5b1b71325..6b58cc001 100644 --- a/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/internal/JobManagerImpl.kt +++ b/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/internal/JobManagerImpl.kt @@ -37,7 +37,7 @@ internal class JobManagerImpl(private val client: OpenDCRunnerClient) : JobManag override fun claim(id: Long): Boolean { return try { - client.jobs.update(id, Job.Update(JobState.CLAIMED, 0)) + client.jobs.update(id, Job.Update(JobState.CLAIMED, 0, null)) true } catch (e: IllegalStateException) { false @@ -45,15 +45,15 @@ internal class JobManagerImpl(private val client: OpenDCRunnerClient) : JobManag } override fun heartbeat(id: Long, runtime: Int): Boolean { - val res = client.jobs.update(id, Job.Update(JobState.RUNNING, runtime)) + val res = client.jobs.update(id, Job.Update(JobState.RUNNING, runtime, null)) return res?.state != JobState.FAILED } override fun fail(id: Long, runtime: Int) { - client.jobs.update(id, Job.Update(JobState.FAILED, runtime)) + client.jobs.update(id, Job.Update(JobState.FAILED, runtime, null)) } override fun finish(id: Long, runtime: Int, results: Map) { - client.jobs.update(id, Job.Update(JobState.FINISHED, runtime)) + client.jobs.update(id, Job.Update(JobState.FINISHED, runtime, results)) } } diff --git a/opendc-web/opendc-web-server/build.gradle.kts b/opendc-web/opendc-web-server/build.gradle.kts index d05210ac6..3a99f3cea 100644 --- a/opendc-web/opendc-web-server/build.gradle.kts +++ b/opendc-web/opendc-web-server/build.gradle.kts @@ -22,7 +22,7 @@ description = "Web server of OpenDC" -/* Build configuration */ +// Build configuration plugins { `quarkus-conventions` distribution @@ -32,10 +32,8 @@ dependencies { implementation(enforcedPlatform(libs.quarkus.bom)) implementation(projects.opendcWeb.opendcWebProto) - compileOnly(projects.opendcWeb.opendcWebUiQuarkusDeployment) /* Temporary fix for Quarkus/Gradle issues */ - compileOnly(projects.opendcWeb.opendcWebRunnerQuarkusDeployment) - implementation(projects.opendcWeb.opendcWebUiQuarkus) - implementation(projects.opendcWeb.opendcWebRunnerQuarkus) + compileOnly(projects.opendcWeb.opendcWebQuarkusDeployment) + implementation(projects.opendcWeb.opendcWebQuarkus) implementation(libs.quarkus.kotlin) implementation(libs.quarkus.resteasy.core) @@ -45,6 +43,7 @@ dependencies { implementation(libs.quarkus.security) implementation(libs.quarkus.oidc) + implementation(libs.quarkus.quinoa.runtime) implementation(libs.quarkus.hibernate.orm.core) implementation(libs.quarkus.hibernate.orm.panache) @@ -66,7 +65,7 @@ val createStartScripts by tasks.creating(CreateStartScripts::class) { applicationName = "opendc-server" mainClass.set("io.quarkus.bootstrap.runner.QuarkusEntryPoint") classpath = files("lib/quarkus-run.jar") - outputDir = project.buildDir.resolve("scripts") + outputDir = project.layout.buildDirectory.dir("scripts").get().asFile } distributions { diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Job.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Job.java index c5fb208e5..3044d9c5a 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Job.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Job.java @@ -22,23 +22,25 @@ package org.opendc.web.server.model; +import io.hypersistence.utils.hibernate.type.basic.PostgreSQLEnumType; +import io.hypersistence.utils.hibernate.type.json.JsonType; import io.quarkus.hibernate.orm.panache.Panache; import io.quarkus.hibernate.orm.panache.PanacheEntity; import io.quarkus.hibernate.orm.panache.PanacheQuery; import io.quarkus.panache.common.Parameters; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; +import jakarta.persistence.ForeignKey; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.NamedQueries; +import jakarta.persistence.NamedQuery; +import jakarta.persistence.Table; import java.time.Instant; import java.util.Map; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.FetchType; -import javax.persistence.ForeignKey; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.NamedQueries; -import javax.persistence.NamedQuery; -import javax.persistence.Table; import org.hibernate.annotations.Type; import org.opendc.web.proto.JobState; @@ -83,7 +85,7 @@ public class Job extends PanacheEntity { /** * The state of the job. */ - @Type(type = "io.hypersistence.utils.hibernate.type.basic.PostgreSQLEnumType") + @Type(PostgreSQLEnumType.class) @Column(nullable = false, columnDefinition = "enum") @Enumerated(EnumType.STRING) public JobState state = JobState.PENDING; @@ -97,7 +99,7 @@ public class Job extends PanacheEntity { /** * Experiment results in JSON */ - @Type(type = "io.hypersistence.utils.hibernate.type.json.JsonType") + @Type(JsonType.class) @Column(columnDefinition = "jsonb") public Map results = null; diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Portfolio.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Portfolio.java index 3a406683b..0be2aad00 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Portfolio.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Portfolio.java @@ -22,23 +22,24 @@ package org.opendc.web.server.model; +import io.hypersistence.utils.hibernate.type.json.JsonType; import io.quarkus.hibernate.orm.panache.PanacheEntity; import io.quarkus.hibernate.orm.panache.PanacheQuery; import io.quarkus.panache.common.Parameters; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.NamedQueries; +import jakarta.persistence.NamedQuery; +import jakarta.persistence.OneToMany; +import jakarta.persistence.OrderBy; +import jakarta.persistence.Table; +import jakarta.persistence.UniqueConstraint; import java.util.HashSet; import java.util.Set; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Index; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.NamedQueries; -import javax.persistence.NamedQuery; -import javax.persistence.OneToMany; -import javax.persistence.OrderBy; -import javax.persistence.Table; -import javax.persistence.UniqueConstraint; import org.hibernate.annotations.Type; import org.opendc.web.proto.Targets; @@ -83,7 +84,7 @@ public class Portfolio extends PanacheEntity { /** * The portfolio targets (metrics, repetitions). */ - @Type(type = "io.hypersistence.utils.hibernate.type.json.JsonType") + @Type(JsonType.class) @Column(columnDefinition = "jsonb", nullable = false, updatable = false) public Targets targets; diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Project.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Project.java index 5836e33f0..865b4de06 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Project.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Project.java @@ -25,17 +25,17 @@ import io.quarkus.hibernate.orm.panache.Panache; import io.quarkus.hibernate.orm.panache.PanacheEntity; import io.quarkus.panache.common.Parameters; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.NamedQueries; +import jakarta.persistence.NamedQuery; +import jakarta.persistence.OneToMany; +import jakarta.persistence.OrderBy; +import jakarta.persistence.Table; import java.time.Instant; import java.util.HashSet; import java.util.Set; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.NamedQueries; -import javax.persistence.NamedQuery; -import javax.persistence.OneToMany; -import javax.persistence.OrderBy; -import javax.persistence.Table; /** * A project in OpenDC encapsulates all the datacenter designs and simulation runs for a set of users. diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/ProjectAuthorization.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/ProjectAuthorization.java index 1238f58de..4bc9dee79 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/ProjectAuthorization.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/ProjectAuthorization.java @@ -22,25 +22,26 @@ package org.opendc.web.server.model; +import io.hypersistence.utils.hibernate.type.basic.PostgreSQLEnumType; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; import io.quarkus.hibernate.orm.panache.PanacheQuery; import io.quarkus.panache.common.Parameters; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import jakarta.persistence.EmbeddedId; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; +import jakarta.persistence.ForeignKey; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.MapsId; +import jakarta.persistence.NamedQueries; +import jakarta.persistence.NamedQuery; +import jakarta.persistence.Table; import java.io.Serializable; import java.util.Objects; -import javax.persistence.Column; -import javax.persistence.Embeddable; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.FetchType; -import javax.persistence.ForeignKey; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.MapsId; -import javax.persistence.NamedQueries; -import javax.persistence.NamedQuery; -import javax.persistence.Table; import org.hibernate.annotations.Type; import org.opendc.web.proto.user.ProjectRole; @@ -82,9 +83,9 @@ public class ProjectAuthorization extends PanacheEntityBase { /** * The role of the user in the project. */ - @Type(type = "io.hypersistence.utils.hibernate.type.basic.PostgreSQLEnumType") @Column(nullable = false, columnDefinition = "enum") @Enumerated(EnumType.STRING) + @Type(PostgreSQLEnumType.class) public ProjectRole role; /** diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Scenario.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Scenario.java index 016e931b9..ffc62599a 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Scenario.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Scenario.java @@ -22,25 +22,26 @@ package org.opendc.web.server.model; +import io.hypersistence.utils.hibernate.type.json.JsonType; import io.quarkus.hibernate.orm.panache.PanacheEntity; import io.quarkus.hibernate.orm.panache.PanacheQuery; import io.quarkus.panache.common.Parameters; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.ForeignKey; +import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.NamedQueries; +import jakarta.persistence.NamedQuery; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; +import jakarta.persistence.UniqueConstraint; import java.util.ArrayList; import java.util.List; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.ForeignKey; -import javax.persistence.Index; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.NamedQueries; -import javax.persistence.NamedQuery; -import javax.persistence.OneToMany; -import javax.persistence.Table; -import javax.persistence.UniqueConstraint; import org.hibernate.annotations.Type; import org.opendc.web.proto.OperationalPhenomena; @@ -114,7 +115,7 @@ public class Scenario extends PanacheEntity { /** * Operational phenomena activated in the scenario. */ - @Type(type = "io.hypersistence.utils.hibernate.type.json.JsonType") + @Type(JsonType.class) @Column(columnDefinition = "jsonb", nullable = false, updatable = false) public OperationalPhenomena phenomena; diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Topology.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Topology.java index 05a1ac12b..ca5664488 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Topology.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Topology.java @@ -22,22 +22,23 @@ package org.opendc.web.server.model; +import io.hypersistence.utils.hibernate.type.json.JsonType; import io.quarkus.hibernate.orm.panache.PanacheEntity; import io.quarkus.hibernate.orm.panache.PanacheQuery; import io.quarkus.panache.common.Parameters; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.NamedQueries; +import jakarta.persistence.NamedQuery; +import jakarta.persistence.Table; +import jakarta.persistence.UniqueConstraint; import java.time.Instant; import java.util.List; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Index; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.NamedQueries; -import javax.persistence.NamedQuery; -import javax.persistence.Table; -import javax.persistence.UniqueConstraint; import org.hibernate.annotations.Type; -import org.opendc.web.proto.Room; +import org.opendc.web.proto.topology.Room; /** * A datacenter design in OpenDC. @@ -92,7 +93,7 @@ public class Topology extends PanacheEntity { /** * Datacenter design in JSON */ - @Type(type = "io.hypersistence.utils.hibernate.type.json.JsonType") + @Type(JsonType.class) @Column(columnDefinition = "jsonb", nullable = false) public List rooms; diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Trace.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Trace.java index 36d27abcb..2d2bb26cc 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Trace.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Trace.java @@ -23,10 +23,10 @@ package org.opendc.web.server.model; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; /** * A workload trace available for simulation. diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/UserAccounting.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/UserAccounting.java index fda4302fb..27a7590b1 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/UserAccounting.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/UserAccounting.java @@ -24,13 +24,13 @@ import io.quarkus.hibernate.orm.panache.PanacheEntityBase; import io.quarkus.panache.common.Parameters; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.NamedQueries; +import jakarta.persistence.NamedQuery; +import jakarta.persistence.Table; import java.time.LocalDate; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.NamedQueries; -import javax.persistence.NamedQuery; -import javax.persistence.Table; /** * Entity to track the number of simulation minutes used by a user. diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Workload.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Workload.java index 129fb0c50..fd7010d2e 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Workload.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/model/Workload.java @@ -22,9 +22,9 @@ package org.opendc.web.server.model; -import javax.persistence.Column; -import javax.persistence.Embeddable; -import javax.persistence.ManyToOne; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import jakarta.persistence.ManyToOne; /** * Specification of the workload for a {@link Scenario} diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/SchedulerResource.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/SchedulerResource.java index 0fd581829..d7bb8f69b 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/SchedulerResource.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/SchedulerResource.java @@ -22,10 +22,10 @@ package org.opendc.web.server.rest; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; import java.util.List; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; /** * A resource representing the available schedulers that can be used during experiments. diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/TraceResource.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/TraceResource.java index 7316c93fc..daec01cd6 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/TraceResource.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/TraceResource.java @@ -22,13 +22,13 @@ package org.opendc.web.server.rest; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.WebApplicationException; import java.util.List; import java.util.stream.Stream; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.WebApplicationException; import org.opendc.web.server.model.Trace; /** diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/error/WebApplicationExceptionMapper.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/error/WebApplicationExceptionMapper.java index ad1bb05e2..e027e5597 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/error/WebApplicationExceptionMapper.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/error/WebApplicationExceptionMapper.java @@ -22,11 +22,11 @@ package org.opendc.web.server.rest.error; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; +import jakarta.ws.rs.WebApplicationException; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.ext.ExceptionMapper; +import jakarta.ws.rs.ext.Provider; import org.opendc.web.proto.ProtocolError; /** diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/runner/JobResource.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/runner/JobResource.java index dff525261..2b7740820 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/runner/JobResource.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/runner/JobResource.java @@ -22,17 +22,17 @@ package org.opendc.web.server.rest.runner; +import jakarta.annotation.security.RolesAllowed; +import jakarta.transaction.Transactional; +import jakarta.validation.Valid; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.WebApplicationException; import java.util.List; -import javax.annotation.security.RolesAllowed; -import javax.transaction.Transactional; -import javax.validation.Valid; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.WebApplicationException; import org.opendc.web.proto.JobState; import org.opendc.web.server.model.Job; import org.opendc.web.server.service.JobService; @@ -98,7 +98,7 @@ public org.opendc.web.proto.runner.Job update( } try { - jobService.updateJob(job, update.getState(), update.getRuntime(), update.getResults()); + jobService.updateJob(job, update.state(), update.runtime(), update.results()); } catch (IllegalArgumentException e) { throw new WebApplicationException(e, 400); } catch (IllegalStateException e) { diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/PortfolioResource.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/PortfolioResource.java index d1fc980d5..e4d5362c9 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/PortfolioResource.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/PortfolioResource.java @@ -23,19 +23,19 @@ package org.opendc.web.server.rest.user; import io.quarkus.security.identity.SecurityIdentity; +import jakarta.annotation.security.RolesAllowed; +import jakarta.transaction.Transactional; +import jakarta.validation.Valid; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.DELETE; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.WebApplicationException; import java.time.Instant; import java.util.List; -import javax.annotation.security.RolesAllowed; -import javax.transaction.Transactional; -import javax.validation.Valid; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.WebApplicationException; import org.opendc.web.server.model.Portfolio; import org.opendc.web.server.model.ProjectAuthorization; @@ -100,7 +100,7 @@ public org.opendc.web.proto.user.Portfolio create( var project = auth.project; int number = project.allocatePortfolio(now); - Portfolio portfolio = new Portfolio(project, number, request.getName(), request.getTargets()); + Portfolio portfolio = new Portfolio(project, number, request.name(), request.targets()); project.portfolios.add(portfolio); portfolio.persist(); diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/PortfolioScenarioResource.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/PortfolioScenarioResource.java index a058cd313..ea87a7ad4 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/PortfolioScenarioResource.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/PortfolioScenarioResource.java @@ -23,18 +23,18 @@ package org.opendc.web.server.rest.user; import io.quarkus.security.identity.SecurityIdentity; +import jakarta.annotation.security.RolesAllowed; +import jakarta.transaction.Transactional; +import jakarta.validation.Valid; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.WebApplicationException; import java.time.Instant; import java.util.List; -import javax.annotation.security.RolesAllowed; -import javax.transaction.Transactional; -import javax.validation.Valid; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.WebApplicationException; import org.opendc.web.proto.JobState; import org.opendc.web.server.model.Job; import org.opendc.web.server.model.Portfolio; @@ -118,12 +118,12 @@ public org.opendc.web.proto.user.Scenario create( throw new WebApplicationException("Portfolio not found", 404); } - Topology topology = Topology.findByProject(projectId, (int) request.getTopology()); + Topology topology = Topology.findByProject(projectId, (int) request.topology()); if (topology == null) { throw new WebApplicationException("Referred topology does not exist", 400); } - Trace trace = Trace.findById(request.getWorkload().getTrace()); + Trace trace = Trace.findById(request.workload().trace()); if (trace == null) { throw new WebApplicationException("Referred trace does not exist", 400); } @@ -136,14 +136,14 @@ public org.opendc.web.proto.user.Scenario create( project, portfolio, number, - request.getName(), - new Workload(trace, request.getWorkload().getSamplingFraction()), + request.name(), + new Workload(trace, request.workload().samplingFraction()), topology, - request.getPhenomena(), - request.getSchedulerName()); + request.phenomena(), + request.schedulerName()); scenario.persist(); - Job job = new Job(scenario, userId, now, portfolio.targets.getRepeats()); + Job job = new Job(scenario, userId, now, portfolio.targets.repeats()); job.persist(); // Fail the job if there is not enough budget for the simulation diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/ProjectResource.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/ProjectResource.java index da47c3ff2..39903e4d2 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/ProjectResource.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/ProjectResource.java @@ -23,19 +23,19 @@ package org.opendc.web.server.rest.user; import io.quarkus.security.identity.SecurityIdentity; +import jakarta.annotation.security.RolesAllowed; +import jakarta.transaction.Transactional; +import jakarta.validation.Valid; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.DELETE; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.WebApplicationException; import java.time.Instant; import java.util.List; -import javax.annotation.security.RolesAllowed; -import javax.transaction.Transactional; -import javax.validation.Valid; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.WebApplicationException; import org.opendc.web.proto.user.ProjectRole; import org.opendc.web.server.model.Project; import org.opendc.web.server.model.ProjectAuthorization; @@ -79,7 +79,7 @@ public List getAll() { @Consumes("application/json") public org.opendc.web.proto.user.Project create(@Valid org.opendc.web.proto.user.Project.Create request) { Instant now = Instant.now(); - Project entity = new Project(request.getName(), now); + Project entity = new Project(request.name(), now); entity.persist(); ProjectAuthorization authorization = diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/ScenarioResource.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/ScenarioResource.java index cf933c322..bb3eb89bf 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/ScenarioResource.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/ScenarioResource.java @@ -23,15 +23,15 @@ package org.opendc.web.server.rest.user; import io.quarkus.security.identity.SecurityIdentity; +import jakarta.annotation.security.RolesAllowed; +import jakarta.transaction.Transactional; +import jakarta.ws.rs.DELETE; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.WebApplicationException; import java.util.List; -import javax.annotation.security.RolesAllowed; -import javax.transaction.Transactional; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.WebApplicationException; import org.opendc.web.server.model.ProjectAuthorization; import org.opendc.web.server.model.Scenario; diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/TopologyResource.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/TopologyResource.java index 71491801d..25819e325 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/TopologyResource.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/TopologyResource.java @@ -24,21 +24,21 @@ import io.quarkus.hibernate.orm.panache.Panache; import io.quarkus.security.identity.SecurityIdentity; +import jakarta.annotation.security.RolesAllowed; +import jakarta.persistence.PersistenceException; +import jakarta.transaction.Transactional; +import jakarta.validation.Valid; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.DELETE; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.PUT; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.WebApplicationException; import java.time.Instant; import java.util.List; -import javax.annotation.security.RolesAllowed; -import javax.persistence.PersistenceException; -import javax.transaction.Transactional; -import javax.validation.Valid; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.WebApplicationException; import org.opendc.web.server.model.Project; import org.opendc.web.server.model.ProjectAuthorization; import org.opendc.web.server.model.Topology; @@ -104,7 +104,7 @@ public org.opendc.web.proto.user.Topology create( Project project = auth.project; int number = project.allocateTopology(now); - Topology topology = new Topology(project, number, request.getName(), now, request.getRooms()); + Topology topology = new Topology(project, number, request.name(), now, request.rooms()); project.topologies.add(topology); topology.persist(); @@ -164,7 +164,7 @@ public org.opendc.web.proto.user.Topology update( } entity.updatedAt = Instant.now(); - entity.rooms = request.getRooms(); + entity.rooms = request.rooms(); return UserProtocol.toDto(entity, auth); } diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/UserResource.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/UserResource.java index c3fb28665..c8cda2b76 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/UserResource.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/rest/user/UserResource.java @@ -23,10 +23,10 @@ package org.opendc.web.server.rest.user; import io.quarkus.security.identity.SecurityIdentity; -import javax.annotation.security.RolesAllowed; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; +import jakarta.annotation.security.RolesAllowed; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; import org.opendc.web.proto.user.User; import org.opendc.web.proto.user.UserAccounting; import org.opendc.web.server.service.UserAccountingService; diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/service/JobService.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/service/JobService.java index ed0eaf9c8..709335205 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/service/JobService.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/service/JobService.java @@ -22,9 +22,9 @@ package org.opendc.web.server.service; +import jakarta.enterprise.context.ApplicationScoped; import java.time.Instant; import java.util.Map; -import javax.enterprise.context.ApplicationScoped; import org.opendc.web.proto.JobState; import org.opendc.web.server.model.Job; diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/service/UserAccountingService.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/service/UserAccountingService.java index e5003cb4a..73fa2a3e1 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/service/UserAccountingService.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/service/UserAccountingService.java @@ -22,11 +22,11 @@ package org.opendc.web.server.service; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.persistence.EntityExistsException; import java.time.Duration; import java.time.LocalDate; import java.time.temporal.TemporalAdjusters; -import javax.enterprise.context.ApplicationScoped; -import javax.persistence.EntityExistsException; import org.eclipse.microprofile.config.inject.ConfigProperty; import org.opendc.web.server.model.UserAccounting; diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/util/DevSecurityOverrideFilter.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/util/DevSecurityOverrideFilter.java index de4478cb6..103f868d5 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/util/DevSecurityOverrideFilter.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/util/DevSecurityOverrideFilter.java @@ -23,12 +23,12 @@ package org.opendc.web.server.util; import io.quarkus.arc.properties.IfBuildProperty; +import jakarta.ws.rs.container.ContainerRequestContext; +import jakarta.ws.rs.container.ContainerRequestFilter; +import jakarta.ws.rs.container.PreMatching; +import jakarta.ws.rs.core.SecurityContext; +import jakarta.ws.rs.ext.Provider; import java.security.Principal; -import javax.ws.rs.container.ContainerRequestContext; -import javax.ws.rs.container.ContainerRequestFilter; -import javax.ws.rs.container.PreMatching; -import javax.ws.rs.core.SecurityContext; -import javax.ws.rs.ext.Provider; /** * Helper class to disable security for the OpenDC web API when in development mode. diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/util/KotlinModuleCustomizer.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/util/KotlinModuleCustomizer.java index c30edcbff..ff3ba1cd1 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/util/KotlinModuleCustomizer.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/util/KotlinModuleCustomizer.java @@ -25,7 +25,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.module.kotlin.KotlinModule; import io.quarkus.jackson.ObjectMapperCustomizer; -import javax.inject.Singleton; +import jakarta.inject.Singleton; /** * Helper class to register the Kotlin Jackson module. diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/util/QuarkusObjectMapperSupplier.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/util/QuarkusObjectMapperSupplier.java index e46c74ed5..60ca77e5e 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/util/QuarkusObjectMapperSupplier.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/util/QuarkusObjectMapperSupplier.java @@ -25,7 +25,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import io.hypersistence.utils.hibernate.type.util.ObjectMapperSupplier; import io.quarkus.runtime.annotations.RegisterForReflection; -import javax.enterprise.inject.spi.CDI; +import jakarta.enterprise.inject.spi.CDI; /** * A supplier for an {@link ObjectMapper} used by the Hypersistence utilities. diff --git a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/util/runner/QuarkusJobManager.java b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/util/runner/QuarkusJobManager.java index 0331eacfa..47d397f33 100644 --- a/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/util/runner/QuarkusJobManager.java +++ b/opendc-web/opendc-web-server/src/main/java/org/opendc/web/server/util/runner/QuarkusJobManager.java @@ -22,9 +22,9 @@ package org.opendc.web.server.util.runner; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.transaction.Transactional; import java.util.Map; -import javax.enterprise.context.ApplicationScoped; -import javax.transaction.Transactional; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.opendc.web.proto.JobState; diff --git a/opendc-web/opendc-web-server/src/main/resources/application-dev.properties b/opendc-web/opendc-web-server/src/main/resources/application-dev.properties index 5fbc4c042..c4463939a 100644 --- a/opendc-web/opendc-web-server/src/main/resources/application-dev.properties +++ b/opendc-web/opendc-web-server/src/main/resources/application-dev.properties @@ -29,6 +29,9 @@ quarkus.flyway.clean-at-start=true # Disable authentication opendc.security.enabled=false +# Quinoa +quarkus.quinoa.dev-server=true + # Mount web UI at root and API at "/api" quarkus.resteasy.path=/api diff --git a/opendc-web/opendc-web-server/src/main/resources/application.properties b/opendc-web/opendc-web-server/src/main/resources/application.properties index 0f47db30b..8daeccf3a 100644 --- a/opendc-web/opendc-web-server/src/main/resources/application.properties +++ b/opendc-web/opendc-web-server/src/main/resources/application.properties @@ -22,6 +22,9 @@ quarkus.http.cors=true quarkus.http.cors.origins=http://localhost:3000,https://opendc.org +# Quinoa +quarkus.quinoa.dev-server=false + # Security quarkus.oidc.enabled=${opendc.security.enabled} diff --git a/opendc-web/opendc-web-server/src/main/resources/db/migration/V3.0__core.sql b/opendc-web/opendc-web-server/src/main/resources/db/migration/V3.0__core.sql index 40654b6b7..ebf9988f3 100644 --- a/opendc-web/opendc-web-server/src/main/resources/db/migration/V3.0__core.sql +++ b/opendc-web/opendc-web-server/src/main/resources/db/migration/V3.0__core.sql @@ -14,6 +14,8 @@ create table projects primary key (id) ); +create sequence projects_SEQ start with 1 increment by 50; + create type project_role as enum ('OWNER', 'EDITOR', 'VIEWER'); -- Project authorizations authorize users specific permissions to a project. @@ -38,6 +40,8 @@ create table topologies primary key (id) ); +create sequence topologies_SEQ start with 1 increment by 50; + -- Portfolios create table portfolios ( @@ -49,6 +53,8 @@ create table portfolios primary key (id) ); +create sequence portfolios_SEQ start with 1 increment by 50; + create table scenarios ( id bigint not null, @@ -64,6 +70,8 @@ create table scenarios primary key (id) ); +create sequence scenarios_SEQ start with 1 increment by 50; + create type job_state as enum ('PENDING', 'CLAIMED', 'RUNNING', 'FINISHED', 'FAILED'); create table jobs @@ -80,6 +88,8 @@ create table jobs primary key (id) ); +create sequence jobs_SEQ start with 1 increment by 50; + -- User accounting create table user_accounting ( diff --git a/opendc-web/opendc-web-server/src/main/resources/db/testing/V3.0.1__entities.sql b/opendc-web/opendc-web-server/src/main/resources/db/testing/V3.0.1__entities.sql index 1b702f4e0..aa64bf259 100644 --- a/opendc-web/opendc-web-server/src/main/resources/db/testing/V3.0.1__entities.sql +++ b/opendc-web/opendc-web-server/src/main/resources/db/testing/V3.0.1__entities.sql @@ -1,6 +1,10 @@ -- Test entities -alter sequence hibernate_sequence restart with 500; +alter sequence projects_SEQ restart with 500; +alter sequence portfolios_SEQ restart with 500; +alter sequence topologies_SEQ restart with 500; +alter sequence scenarios_SEQ restart with 500; +alter sequence jobs_SEQ restart with 500; insert into projects (id, created_at, name, portfolios_created, scenarios_created, topologies_created, updated_at) values (1, current_timestamp(), 'Test Project', 1, 2, 1, current_timestamp()); diff --git a/opendc-web/opendc-web-ui/.dockerignore b/opendc-web/opendc-web-server/src/main/webui/.dockerignore similarity index 100% rename from opendc-web/opendc-web-ui/.dockerignore rename to opendc-web/opendc-web-server/src/main/webui/.dockerignore diff --git a/opendc-web/opendc-web-ui/.eslintrc b/opendc-web/opendc-web-server/src/main/webui/.eslintrc similarity index 100% rename from opendc-web/opendc-web-ui/.eslintrc rename to opendc-web/opendc-web-server/src/main/webui/.eslintrc diff --git a/opendc-web/opendc-web-ui/.gitignore b/opendc-web/opendc-web-server/src/main/webui/.gitignore similarity index 94% rename from opendc-web/opendc-web-ui/.gitignore rename to opendc-web/opendc-web-server/src/main/webui/.gitignore index 54eada4cd..0f845719e 100644 --- a/opendc-web/opendc-web-ui/.gitignore +++ b/opendc-web/opendc-web-server/src/main/webui/.gitignore @@ -6,6 +6,7 @@ # Production /build +/public/__ENV.js # Misc .DS_Store diff --git a/opendc-web/opendc-web-ui/.prettierrc.yaml b/opendc-web/opendc-web-server/src/main/webui/.prettierrc.yaml similarity index 100% rename from opendc-web/opendc-web-ui/.prettierrc.yaml rename to opendc-web/opendc-web-server/src/main/webui/.prettierrc.yaml diff --git a/opendc-web/opendc-web-ui/Dockerfile b/opendc-web/opendc-web-server/src/main/webui/Dockerfile similarity index 61% rename from opendc-web/opendc-web-ui/Dockerfile rename to opendc-web/opendc-web-server/src/main/webui/Dockerfile index 24ca2b3e0..3079a9df4 100644 --- a/opendc-web/opendc-web-ui/Dockerfile +++ b/opendc-web/opendc-web-server/src/main/webui/Dockerfile @@ -11,21 +11,13 @@ FROM node:18-slim AS build COPY ./ /opendc COPY --from=staging /opendc/node_modules /opendc/node_modules RUN cd /opendc/ \ - # Environmental variables that will be substituted during image runtime - && export NEXT_PUBLIC_API_BASE_URL="%%NEXT_PUBLIC_API_BASE_URL%%" \ - NEXT_PUBLIC_SENTRY_DSN="%%NEXT_PUBLIC_SENTRY_DSN%%" \ - NEXT_PUBLIC_AUTH0_DOMAIN="%%NEXT_PUBLIC_AUTH0_DOMAIN%%" \ - NEXT_PUBLIC_AUTH0_CLIENT_ID="%%NEXT_PUBLIC_AUTH0_CLIENT_ID%%" \ - NEXT_PUBLIC_AUTH0_AUDIENCE="%%NEXT_PUBLIC_AUTH0_AUDIENCE%%" \ && npm run build \ - && npm cache clean --force \ - && mv build/next build/next.template - + && npm cache clean --force FROM node:18-slim COPY --from=build /opendc /opendc WORKDIR /opendc -CMD ./scripts/envsubst.sh; npm run start +CMD npm run start LABEL org.opencontainers.image.authors="OpenDC Maintainers " LABEL org.opencontainers.image.url="https://opendc.org" diff --git a/opendc-web/opendc-web-ui/README.md b/opendc-web/opendc-web-server/src/main/webui/README.md similarity index 93% rename from opendc-web/opendc-web-ui/README.md rename to opendc-web/opendc-web-server/src/main/webui/README.md index a11334756..24788e37c 100644 --- a/opendc-web/opendc-web-ui/README.md +++ b/opendc-web/opendc-web-server/src/main/webui/README.md @@ -10,7 +10,7 @@ dynamic components and their styles are contained in `src`. ### Pages -All pages are represented by a component in the `src/pages` directory, following +All pages are represented by a component in the `pages` directory, following the [Next.js conventions](https://nextjs.org/docs/routing/introduction) for routing. There are components for the following pages: @@ -40,8 +40,8 @@ located in `src/api`. The actual logic responsible for calling these functions i ### State Management State for the topology editor is managed via a Redux store. State is kept there in an immutable form, only to be modified through -actions being dispatched. These actions are contained in the `src/actions` folder, and the reducers (managing how state -is updated according to dispatched actions) are located in `src/reducers`. If you're not familiar with the Redux +actions being dispatched. These actions are contained in the `actions` folder, and the reducers (managing how state +is updated according to dispatched actions) are located in `reducers`. If you're not familiar with the Redux approach to state management, have a look at their [official documentation](https://redux.js.org/). ## Running the development server diff --git a/opendc-web/opendc-web-ui/src/api/index.js b/opendc-web/opendc-web-server/src/main/webui/api/index.js similarity index 100% rename from opendc-web/opendc-web-ui/src/api/index.js rename to opendc-web/opendc-web-server/src/main/webui/api/index.js diff --git a/opendc-web/opendc-web-ui/src/api/portfolios.js b/opendc-web/opendc-web-server/src/main/webui/api/portfolios.js similarity index 100% rename from opendc-web/opendc-web-ui/src/api/portfolios.js rename to opendc-web/opendc-web-server/src/main/webui/api/portfolios.js diff --git a/opendc-web/opendc-web-ui/src/api/projects.js b/opendc-web/opendc-web-server/src/main/webui/api/projects.js similarity index 100% rename from opendc-web/opendc-web-ui/src/api/projects.js rename to opendc-web/opendc-web-server/src/main/webui/api/projects.js diff --git a/opendc-web/opendc-web-ui/src/api/scenarios.js b/opendc-web/opendc-web-server/src/main/webui/api/scenarios.js similarity index 100% rename from opendc-web/opendc-web-ui/src/api/scenarios.js rename to opendc-web/opendc-web-server/src/main/webui/api/scenarios.js diff --git a/opendc-web/opendc-web-ui/src/api/schedulers.js b/opendc-web/opendc-web-server/src/main/webui/api/schedulers.js similarity index 100% rename from opendc-web/opendc-web-ui/src/api/schedulers.js rename to opendc-web/opendc-web-server/src/main/webui/api/schedulers.js diff --git a/opendc-web/opendc-web-ui/src/api/topologies.js b/opendc-web/opendc-web-server/src/main/webui/api/topologies.js similarity index 100% rename from opendc-web/opendc-web-ui/src/api/topologies.js rename to opendc-web/opendc-web-server/src/main/webui/api/topologies.js diff --git a/opendc-web/opendc-web-ui/src/api/traces.js b/opendc-web/opendc-web-server/src/main/webui/api/traces.js similarity index 100% rename from opendc-web/opendc-web-ui/src/api/traces.js rename to opendc-web/opendc-web-server/src/main/webui/api/traces.js diff --git a/opendc-web/opendc-web-ui/src/api/users.js b/opendc-web/opendc-web-server/src/main/webui/api/users.js similarity index 100% rename from opendc-web/opendc-web-ui/src/api/users.js rename to opendc-web/opendc-web-server/src/main/webui/api/users.js diff --git a/opendc-web/opendc-web-ui/src/auth.js b/opendc-web/opendc-web-server/src/main/webui/auth.js similarity index 100% rename from opendc-web/opendc-web-ui/src/auth.js rename to opendc-web/opendc-web-server/src/main/webui/auth.js diff --git a/opendc-web/opendc-web-ui/src/components/AppHeader.js b/opendc-web/opendc-web-server/src/main/webui/components/AppHeader.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/AppHeader.js rename to opendc-web/opendc-web-server/src/main/webui/components/AppHeader.js diff --git a/opendc-web/opendc-web-ui/src/components/AppHeader.module.css b/opendc-web/opendc-web-server/src/main/webui/components/AppHeader.module.css similarity index 100% rename from opendc-web/opendc-web-ui/src/components/AppHeader.module.css rename to opendc-web/opendc-web-server/src/main/webui/components/AppHeader.module.css diff --git a/opendc-web/opendc-web-ui/src/components/AppHeaderTools.js b/opendc-web/opendc-web-server/src/main/webui/components/AppHeaderTools.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/AppHeaderTools.js rename to opendc-web/opendc-web-server/src/main/webui/components/AppHeaderTools.js diff --git a/opendc-web/opendc-web-ui/src/components/AppHeaderUser.js b/opendc-web/opendc-web-server/src/main/webui/components/AppHeaderUser.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/AppHeaderUser.js rename to opendc-web/opendc-web-server/src/main/webui/components/AppHeaderUser.js diff --git a/opendc-web/opendc-web-ui/src/components/AppPage.js b/opendc-web/opendc-web-server/src/main/webui/components/AppPage.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/AppPage.js rename to opendc-web/opendc-web-server/src/main/webui/components/AppPage.js diff --git a/opendc-web/opendc-web-ui/src/components/context/ContextSelectionSection.js b/opendc-web/opendc-web-server/src/main/webui/components/context/ContextSelectionSection.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/context/ContextSelectionSection.js rename to opendc-web/opendc-web-server/src/main/webui/components/context/ContextSelectionSection.js diff --git a/opendc-web/opendc-web-ui/src/components/context/ContextSelectionSection.module.css b/opendc-web/opendc-web-server/src/main/webui/components/context/ContextSelectionSection.module.css similarity index 100% rename from opendc-web/opendc-web-ui/src/components/context/ContextSelectionSection.module.css rename to opendc-web/opendc-web-server/src/main/webui/components/context/ContextSelectionSection.module.css diff --git a/opendc-web/opendc-web-ui/src/components/context/ContextSelector.js b/opendc-web/opendc-web-server/src/main/webui/components/context/ContextSelector.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/context/ContextSelector.js rename to opendc-web/opendc-web-server/src/main/webui/components/context/ContextSelector.js diff --git a/opendc-web/opendc-web-ui/src/components/context/ContextSelector.module.css b/opendc-web/opendc-web-server/src/main/webui/components/context/ContextSelector.module.css similarity index 100% rename from opendc-web/opendc-web-ui/src/components/context/ContextSelector.module.css rename to opendc-web/opendc-web-server/src/main/webui/components/context/ContextSelector.module.css diff --git a/opendc-web/opendc-web-ui/src/components/context/PortfolioSelector.js b/opendc-web/opendc-web-server/src/main/webui/components/context/PortfolioSelector.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/context/PortfolioSelector.js rename to opendc-web/opendc-web-server/src/main/webui/components/context/PortfolioSelector.js diff --git a/opendc-web/opendc-web-ui/src/components/context/ProjectSelector.js b/opendc-web/opendc-web-server/src/main/webui/components/context/ProjectSelector.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/context/ProjectSelector.js rename to opendc-web/opendc-web-server/src/main/webui/components/context/ProjectSelector.js diff --git a/opendc-web/opendc-web-ui/src/components/context/TopologySelector.js b/opendc-web/opendc-web-server/src/main/webui/components/context/TopologySelector.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/context/TopologySelector.js rename to opendc-web/opendc-web-server/src/main/webui/components/context/TopologySelector.js diff --git a/opendc-web/opendc-web-ui/src/components/portfolios/NewScenario.js b/opendc-web/opendc-web-server/src/main/webui/components/portfolios/NewScenario.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/portfolios/NewScenario.js rename to opendc-web/opendc-web-server/src/main/webui/components/portfolios/NewScenario.js diff --git a/opendc-web/opendc-web-ui/src/components/portfolios/NewScenarioModal.js b/opendc-web/opendc-web-server/src/main/webui/components/portfolios/NewScenarioModal.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/portfolios/NewScenarioModal.js rename to opendc-web/opendc-web-server/src/main/webui/components/portfolios/NewScenarioModal.js diff --git a/opendc-web/opendc-web-ui/src/components/portfolios/PortfolioOverview.js b/opendc-web/opendc-web-server/src/main/webui/components/portfolios/PortfolioOverview.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/portfolios/PortfolioOverview.js rename to opendc-web/opendc-web-server/src/main/webui/components/portfolios/PortfolioOverview.js diff --git a/opendc-web/opendc-web-ui/src/components/portfolios/PortfolioResultInfo.js b/opendc-web/opendc-web-server/src/main/webui/components/portfolios/PortfolioResultInfo.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/portfolios/PortfolioResultInfo.js rename to opendc-web/opendc-web-server/src/main/webui/components/portfolios/PortfolioResultInfo.js diff --git a/opendc-web/opendc-web-ui/src/components/portfolios/PortfolioResults.js b/opendc-web/opendc-web-server/src/main/webui/components/portfolios/PortfolioResults.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/portfolios/PortfolioResults.js rename to opendc-web/opendc-web-server/src/main/webui/components/portfolios/PortfolioResults.js diff --git a/opendc-web/opendc-web-ui/src/components/portfolios/ScenarioState.js b/opendc-web/opendc-web-server/src/main/webui/components/portfolios/ScenarioState.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/portfolios/ScenarioState.js rename to opendc-web/opendc-web-server/src/main/webui/components/portfolios/ScenarioState.js diff --git a/opendc-web/opendc-web-ui/src/components/portfolios/ScenarioTable.js b/opendc-web/opendc-web-server/src/main/webui/components/portfolios/ScenarioTable.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/portfolios/ScenarioTable.js rename to opendc-web/opendc-web-server/src/main/webui/components/portfolios/ScenarioTable.js diff --git a/opendc-web/opendc-web-ui/src/components/projects/FilterPanel.js b/opendc-web/opendc-web-server/src/main/webui/components/projects/FilterPanel.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/projects/FilterPanel.js rename to opendc-web/opendc-web-server/src/main/webui/components/projects/FilterPanel.js diff --git a/opendc-web/opendc-web-ui/src/components/projects/FilterPanel.module.css b/opendc-web/opendc-web-server/src/main/webui/components/projects/FilterPanel.module.css similarity index 100% rename from opendc-web/opendc-web-ui/src/components/projects/FilterPanel.module.css rename to opendc-web/opendc-web-server/src/main/webui/components/projects/FilterPanel.module.css diff --git a/opendc-web/opendc-web-ui/src/components/projects/NewPortfolio.js b/opendc-web/opendc-web-server/src/main/webui/components/projects/NewPortfolio.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/projects/NewPortfolio.js rename to opendc-web/opendc-web-server/src/main/webui/components/projects/NewPortfolio.js diff --git a/opendc-web/opendc-web-ui/src/components/projects/NewPortfolioModal.js b/opendc-web/opendc-web-server/src/main/webui/components/projects/NewPortfolioModal.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/projects/NewPortfolioModal.js rename to opendc-web/opendc-web-server/src/main/webui/components/projects/NewPortfolioModal.js diff --git a/opendc-web/opendc-web-ui/src/components/projects/NewTopology.js b/opendc-web/opendc-web-server/src/main/webui/components/projects/NewTopology.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/projects/NewTopology.js rename to opendc-web/opendc-web-server/src/main/webui/components/projects/NewTopology.js diff --git a/opendc-web/opendc-web-ui/src/components/projects/NewTopologyModal.js b/opendc-web/opendc-web-server/src/main/webui/components/projects/NewTopologyModal.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/projects/NewTopologyModal.js rename to opendc-web/opendc-web-server/src/main/webui/components/projects/NewTopologyModal.js diff --git a/opendc-web/opendc-web-ui/src/components/projects/PortfolioTable.js b/opendc-web/opendc-web-server/src/main/webui/components/projects/PortfolioTable.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/projects/PortfolioTable.js rename to opendc-web/opendc-web-server/src/main/webui/components/projects/PortfolioTable.js diff --git a/opendc-web/opendc-web-ui/src/components/projects/ProjectCollection.js b/opendc-web/opendc-web-server/src/main/webui/components/projects/ProjectCollection.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/projects/ProjectCollection.js rename to opendc-web/opendc-web-server/src/main/webui/components/projects/ProjectCollection.js diff --git a/opendc-web/opendc-web-ui/src/components/projects/ProjectOverview.js b/opendc-web/opendc-web-server/src/main/webui/components/projects/ProjectOverview.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/projects/ProjectOverview.js rename to opendc-web/opendc-web-server/src/main/webui/components/projects/ProjectOverview.js diff --git a/opendc-web/opendc-web-ui/src/components/projects/TopologyTable.js b/opendc-web/opendc-web-server/src/main/webui/components/projects/TopologyTable.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/projects/TopologyTable.js rename to opendc-web/opendc-web-server/src/main/webui/components/projects/TopologyTable.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/RoomTable.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/RoomTable.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/RoomTable.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/RoomTable.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/TopologyMap.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/TopologyMap.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/TopologyMap.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/TopologyMap.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/TopologyOverview.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/TopologyOverview.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/TopologyOverview.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/TopologyOverview.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/GrayContainer.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/GrayContainer.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/GrayContainer.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/GrayContainer.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/MapConstants.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/MapConstants.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/MapConstants.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/MapConstants.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/MapStage.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/MapStage.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/MapStage.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/MapStage.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/MapStage.module.css b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/MapStage.module.css similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/MapStage.module.css rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/MapStage.module.css diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/RackContainer.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/RackContainer.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/RackContainer.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/RackContainer.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/RackEnergyFillContainer.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/RackEnergyFillContainer.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/RackEnergyFillContainer.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/RackEnergyFillContainer.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/RackSpaceFillContainer.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/RackSpaceFillContainer.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/RackSpaceFillContainer.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/RackSpaceFillContainer.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/RoomContainer.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/RoomContainer.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/RoomContainer.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/RoomContainer.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/TileContainer.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/TileContainer.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/TileContainer.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/TileContainer.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/TopologyContainer.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/TopologyContainer.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/TopologyContainer.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/TopologyContainer.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/WallContainer.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/WallContainer.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/WallContainer.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/WallContainer.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/controls/Collapse.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/controls/Collapse.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/controls/Collapse.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/controls/Collapse.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/controls/Collapse.module.css b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/controls/Collapse.module.css similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/controls/Collapse.module.css rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/controls/Collapse.module.css diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/controls/ScaleIndicator.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/controls/ScaleIndicator.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/controls/ScaleIndicator.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/controls/ScaleIndicator.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/controls/ScaleIndicator.module.css b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/controls/ScaleIndicator.module.css similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/controls/ScaleIndicator.module.css rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/controls/ScaleIndicator.module.css diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/controls/Toolbar.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/controls/Toolbar.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/controls/Toolbar.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/controls/Toolbar.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/controls/Toolbar.module.css b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/controls/Toolbar.module.css similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/controls/Toolbar.module.css rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/controls/Toolbar.module.css diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/elements/Backdrop.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/elements/Backdrop.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/elements/Backdrop.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/elements/Backdrop.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/elements/GrayLayer.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/elements/GrayLayer.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/elements/GrayLayer.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/elements/GrayLayer.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/elements/HoverTile.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/elements/HoverTile.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/elements/HoverTile.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/elements/HoverTile.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/elements/ImageComponent.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/elements/ImageComponent.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/elements/ImageComponent.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/elements/ImageComponent.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/elements/RackFillBar.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/elements/RackFillBar.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/elements/RackFillBar.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/elements/RackFillBar.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/elements/RoomTile.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/elements/RoomTile.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/elements/RoomTile.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/elements/RoomTile.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/elements/TileObject.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/elements/TileObject.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/elements/TileObject.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/elements/TileObject.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/elements/TilePlusIcon.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/elements/TilePlusIcon.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/elements/TilePlusIcon.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/elements/TilePlusIcon.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/elements/WallSegment.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/elements/WallSegment.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/elements/WallSegment.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/elements/WallSegment.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/groups/GridGroup.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/groups/GridGroup.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/groups/GridGroup.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/groups/GridGroup.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/groups/RackGroup.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/groups/RackGroup.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/groups/RackGroup.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/groups/RackGroup.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/groups/RoomGroup.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/groups/RoomGroup.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/groups/RoomGroup.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/groups/RoomGroup.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/groups/TileGroup.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/groups/TileGroup.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/groups/TileGroup.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/groups/TileGroup.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/groups/TopologyGroup.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/groups/TopologyGroup.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/groups/TopologyGroup.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/groups/TopologyGroup.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/groups/WallGroup.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/groups/WallGroup.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/groups/WallGroup.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/groups/WallGroup.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/layers/HoverLayerComponent.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/layers/HoverLayerComponent.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/layers/HoverLayerComponent.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/layers/HoverLayerComponent.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/layers/MapLayer.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/layers/MapLayer.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/layers/MapLayer.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/layers/MapLayer.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/layers/ObjectHoverLayer.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/layers/ObjectHoverLayer.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/layers/ObjectHoverLayer.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/layers/ObjectHoverLayer.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/map/layers/RoomHoverLayer.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/map/layers/RoomHoverLayer.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/map/layers/RoomHoverLayer.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/map/layers/RoomHoverLayer.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/NameComponent.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/NameComponent.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/NameComponent.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/NameComponent.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/TopologySidebar.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/TopologySidebar.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/TopologySidebar.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/TopologySidebar.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/TopologySidebar.module.css b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/TopologySidebar.module.css similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/TopologySidebar.module.css rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/TopologySidebar.module.css diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/building/BuildingSidebar.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/building/BuildingSidebar.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/building/BuildingSidebar.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/building/BuildingSidebar.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/building/NewRoomConstructionComponent.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/building/NewRoomConstructionComponent.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/building/NewRoomConstructionComponent.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/building/NewRoomConstructionComponent.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/building/NewRoomConstructionContainer.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/building/NewRoomConstructionContainer.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/building/NewRoomConstructionContainer.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/building/NewRoomConstructionContainer.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/machine/DeleteMachine.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/machine/DeleteMachine.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/machine/DeleteMachine.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/machine/DeleteMachine.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/machine/MachineSidebar.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/machine/MachineSidebar.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/machine/MachineSidebar.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/machine/MachineSidebar.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/machine/UnitAddComponent.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/machine/UnitAddComponent.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/machine/UnitAddComponent.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/machine/UnitAddComponent.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/machine/UnitAddContainer.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/machine/UnitAddContainer.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/machine/UnitAddContainer.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/machine/UnitAddContainer.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/machine/UnitListComponent.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/machine/UnitListComponent.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/machine/UnitListComponent.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/machine/UnitListComponent.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/machine/UnitListContainer.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/machine/UnitListContainer.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/machine/UnitListContainer.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/machine/UnitListContainer.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/machine/UnitTabsComponent.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/machine/UnitTabsComponent.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/machine/UnitTabsComponent.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/machine/UnitTabsComponent.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/machine/UnitType.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/machine/UnitType.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/machine/UnitType.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/machine/UnitType.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/rack/AddPrefab.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/rack/AddPrefab.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/rack/AddPrefab.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/rack/AddPrefab.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/rack/DeleteRackContainer.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/rack/DeleteRackContainer.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/rack/DeleteRackContainer.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/rack/DeleteRackContainer.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/rack/MachineComponent.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/rack/MachineComponent.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/rack/MachineComponent.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/rack/MachineComponent.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/rack/MachineListComponent.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/rack/MachineListComponent.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/rack/MachineListComponent.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/rack/MachineListComponent.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/rack/MachineListContainer.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/rack/MachineListContainer.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/rack/MachineListContainer.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/rack/MachineListContainer.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/rack/RackNameContainer.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/rack/RackNameContainer.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/rack/RackNameContainer.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/rack/RackNameContainer.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/rack/RackSidebar.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/rack/RackSidebar.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/rack/RackSidebar.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/rack/RackSidebar.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/rack/RackSidebar.module.css b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/rack/RackSidebar.module.css similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/rack/RackSidebar.module.css rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/rack/RackSidebar.module.css diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/room/DeleteRoomContainer.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/room/DeleteRoomContainer.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/room/DeleteRoomContainer.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/room/DeleteRoomContainer.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/room/EditRoomContainer.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/room/EditRoomContainer.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/room/EditRoomContainer.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/room/EditRoomContainer.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/room/RackConstructionComponent.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/room/RackConstructionComponent.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/room/RackConstructionComponent.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/room/RackConstructionComponent.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/room/RackConstructionContainer.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/room/RackConstructionContainer.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/room/RackConstructionContainer.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/room/RackConstructionContainer.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/room/RoomName.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/room/RoomName.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/room/RoomName.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/room/RoomName.js diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/room/RoomSidebar.js b/opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/room/RoomSidebar.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/topologies/sidebar/room/RoomSidebar.js rename to opendc-web/opendc-web-server/src/main/webui/components/topologies/sidebar/room/RoomSidebar.js diff --git a/opendc-web/opendc-web-ui/src/components/util/TableEmptyState.js b/opendc-web/opendc-web-server/src/main/webui/components/util/TableEmptyState.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/util/TableEmptyState.js rename to opendc-web/opendc-web-server/src/main/webui/components/util/TableEmptyState.js diff --git a/opendc-web/opendc-web-ui/src/components/util/modals/ConfirmationModal.js b/opendc-web/opendc-web-server/src/main/webui/components/util/modals/ConfirmationModal.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/util/modals/ConfirmationModal.js rename to opendc-web/opendc-web-server/src/main/webui/components/util/modals/ConfirmationModal.js diff --git a/opendc-web/opendc-web-ui/src/components/util/modals/Modal.js b/opendc-web/opendc-web-server/src/main/webui/components/util/modals/Modal.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/util/modals/Modal.js rename to opendc-web/opendc-web-server/src/main/webui/components/util/modals/Modal.js diff --git a/opendc-web/opendc-web-ui/src/components/util/modals/TextInputModal.js b/opendc-web/opendc-web-server/src/main/webui/components/util/modals/TextInputModal.js similarity index 100% rename from opendc-web/opendc-web-ui/src/components/util/modals/TextInputModal.js rename to opendc-web/opendc-web-server/src/main/webui/components/util/modals/TextInputModal.js diff --git a/opendc-web/opendc-web-ui/src/config.js b/opendc-web/opendc-web-server/src/main/webui/config.js similarity index 81% rename from opendc-web/opendc-web-ui/src/config.js rename to opendc-web/opendc-web-server/src/main/webui/config.js index 52952d69a..1a0ba02c5 100644 --- a/opendc-web/opendc-web-ui/src/config.js +++ b/opendc-web/opendc-web-server/src/main/webui/config.js @@ -20,22 +20,24 @@ * SOFTWARE. */ +import { env } from 'next-runtime-env'; + /** * URL to OpenDC API. */ -export const apiUrl = process.env.NEXT_PUBLIC_API_BASE_URL +export const apiUrl = env("NEXT_PUBLIC_API_BASE_URL") /** * Authentication configuration. */ export const auth = { - domain: process.env.NEXT_PUBLIC_AUTH0_DOMAIN, - clientId: process.env.NEXT_PUBLIC_AUTH0_CLIENT_ID, - audience: process.env.NEXT_PUBLIC_AUTH0_AUDIENCE, + domain: env("NEXT_PUBLIC_AUTH0_DOMAIN"), + clientId: env("NEXT_PUBLIC_AUTH0_CLIENT_ID"), + audience: env("NEXT_PUBLIC_AUTH0_AUDIENCE"), redirectUri: global.window && global.window.location.origin, } /** * Sentry DSN for web frontend. */ -export const sentryDsn = process.env.NEXT_PUBLIC_SENTRY_DSN +export const sentryDsn = env("NEXT_PUBLIC_SENTRY_DSN") diff --git a/opendc-web/opendc-web-ui/src/data/experiments.js b/opendc-web/opendc-web-server/src/main/webui/data/experiments.js similarity index 100% rename from opendc-web/opendc-web-ui/src/data/experiments.js rename to opendc-web/opendc-web-server/src/main/webui/data/experiments.js diff --git a/opendc-web/opendc-web-ui/src/data/project.js b/opendc-web/opendc-web-server/src/main/webui/data/project.js similarity index 100% rename from opendc-web/opendc-web-ui/src/data/project.js rename to opendc-web/opendc-web-server/src/main/webui/data/project.js diff --git a/opendc-web/opendc-web-ui/src/data/query.js b/opendc-web/opendc-web-server/src/main/webui/data/query.js similarity index 100% rename from opendc-web/opendc-web-ui/src/data/query.js rename to opendc-web/opendc-web-server/src/main/webui/data/query.js diff --git a/opendc-web/opendc-web-ui/src/data/topology.js b/opendc-web/opendc-web-server/src/main/webui/data/topology.js similarity index 100% rename from opendc-web/opendc-web-ui/src/data/topology.js rename to opendc-web/opendc-web-server/src/main/webui/data/topology.js diff --git a/opendc-web/opendc-web-ui/src/data/user.js b/opendc-web/opendc-web-server/src/main/webui/data/user.js similarity index 100% rename from opendc-web/opendc-web-ui/src/data/user.js rename to opendc-web/opendc-web-server/src/main/webui/data/user.js diff --git a/opendc-web/opendc-web-ui/next.config.js b/opendc-web/opendc-web-server/src/main/webui/next.config.js similarity index 92% rename from opendc-web/opendc-web-ui/next.config.js rename to opendc-web/opendc-web-server/src/main/webui/next.config.js index f761ba747..a11b47780 100644 --- a/opendc-web/opendc-web-ui/next.config.js +++ b/opendc-web/opendc-web-server/src/main/webui/next.config.js @@ -23,13 +23,16 @@ // PatternFly 4 uses global CSS imports in its distribution files. Therefore, // we need to transpile the modules before we can use them. const { withGlobalCss } = require('next-global-css') -const { PHASE_DEVELOPMENT_SERVER } = require("next/constants"); const withConfig = withGlobalCss() +// Generate dynamic env file +const { configureRuntimeEnv } = require('next-runtime-env/build/configure'); + +configureRuntimeEnv(); + module.exports = (phase) => withConfig({ basePath: process.env.NEXT_BASE_PATH && '/' + process.env.NEXT_BASE_PATH, reactStrictMode: true, - distDir: phase === PHASE_DEVELOPMENT_SERVER ? 'build/next-dev' : 'build/next', async redirects() { return [ { diff --git a/opendc-web/opendc-web-ui/package-lock.json b/opendc-web/opendc-web-server/src/main/webui/package-lock.json similarity index 99% rename from opendc-web/opendc-web-ui/package-lock.json rename to opendc-web/opendc-web-server/src/main/webui/package-lock.json index 9e194c994..5100074ae 100644 --- a/opendc-web/opendc-web-ui/package-lock.json +++ b/opendc-web/opendc-web-server/src/main/webui/package-lock.json @@ -22,6 +22,7 @@ "mathjs": "^11.7.0", "next": "^13.5.4", "next-global-css": "^1.3.1", + "next-runtime-env": "^1.7.1", "normalizr": "^3.6.2", "prettier": "^2.8.7", "prop-types": "^15.8.1", @@ -932,7 +933,6 @@ "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -1199,7 +1199,6 @@ "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -1269,7 +1268,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, "dependencies": { "color-name": "~1.1.4" }, @@ -1280,8 +1278,7 @@ "node_modules/color-name": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, "node_modules/complex.js": { "version": "2.1.1", @@ -2470,7 +2467,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, "engines": { "node": ">=8" } @@ -3204,6 +3200,14 @@ "resolved": "https://registry.npmjs.org/next-global-css/-/next-global-css-1.3.1.tgz", "integrity": "sha512-+OnTwQKmv1lDP7r4R3T94oq6372R9UGVivchBQu49j7ZjzvSXHCnv93yAuhgMkvUgAbGifTs8sQ5YL9wjyAxfA==" }, + "node_modules/next-runtime-env": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/next-runtime-env/-/next-runtime-env-1.7.1.tgz", + "integrity": "sha512-KIWciYVcYBoc0dBTyx7tEogyESacAJCkseU9+AcIYbkq3MiV6WyhHHPfDONpXbJSlpT3u3utrSrngua2EFlfyA==", + "dependencies": { + "chalk": "^4.1.2" + } + }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -4130,7 +4134,6 @@ "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, "dependencies": { "has-flag": "^4.0.0" }, @@ -5457,7 +5460,6 @@ "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, "requires": { "color-convert": "^2.0.1" } @@ -5656,7 +5658,6 @@ "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, "requires": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -5705,7 +5706,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, "requires": { "color-name": "~1.1.4" } @@ -5713,8 +5713,7 @@ "color-name": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, "complex.js": { "version": "2.1.1", @@ -6617,8 +6616,7 @@ "has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" }, "has-property-descriptors": { "version": "1.0.0", @@ -7132,6 +7130,14 @@ "resolved": "https://registry.npmjs.org/next-global-css/-/next-global-css-1.3.1.tgz", "integrity": "sha512-+OnTwQKmv1lDP7r4R3T94oq6372R9UGVivchBQu49j7ZjzvSXHCnv93yAuhgMkvUgAbGifTs8sQ5YL9wjyAxfA==" }, + "next-runtime-env": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/next-runtime-env/-/next-runtime-env-1.7.1.tgz", + "integrity": "sha512-KIWciYVcYBoc0dBTyx7tEogyESacAJCkseU9+AcIYbkq3MiV6WyhHHPfDONpXbJSlpT3u3utrSrngua2EFlfyA==", + "requires": { + "chalk": "^4.1.2" + } + }, "normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -7736,7 +7742,6 @@ "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, "requires": { "has-flag": "^4.0.0" } diff --git a/opendc-web/opendc-web-ui/package.json b/opendc-web/opendc-web-server/src/main/webui/package.json similarity index 96% rename from opendc-web/opendc-web-ui/package.json rename to opendc-web/opendc-web-server/src/main/webui/package.json index 18840db64..8e5bda2a7 100644 --- a/opendc-web/opendc-web-ui/package.json +++ b/opendc-web/opendc-web-server/src/main/webui/package.json @@ -39,6 +39,7 @@ "react-konva": "^18.2.5", "react-query": "^3.39.3", "react-redux": "^8.0.5", + "next-runtime-env": "^1.7.1", "redux": "^4.2.1", "redux-logger": "^3.0.6", "redux-saga": "^1.2.3", @@ -57,7 +58,7 @@ "precommit": "lint-staged", "dev": "next dev", "lint": "next lint", - "build": "next build", + "build": "next build && next export", "start": "next start", "export": "next export -o build/export" }, diff --git a/opendc-web/opendc-web-ui/src/pages/404.js b/opendc-web/opendc-web-server/src/main/webui/pages/404.js similarity index 100% rename from opendc-web/opendc-web-ui/src/pages/404.js rename to opendc-web/opendc-web-server/src/main/webui/pages/404.js diff --git a/opendc-web/opendc-web-ui/src/pages/_app.js b/opendc-web/opendc-web-server/src/main/webui/pages/_app.js similarity index 100% rename from opendc-web/opendc-web-ui/src/pages/_app.js rename to opendc-web/opendc-web-server/src/main/webui/pages/_app.js diff --git a/opendc-web/opendc-web-ui/src/pages/_document.js b/opendc-web/opendc-web-server/src/main/webui/pages/_document.js similarity index 97% rename from opendc-web/opendc-web-ui/src/pages/_document.js rename to opendc-web/opendc-web-server/src/main/webui/pages/_document.js index 9f84b2abe..0a01a3eb7 100644 --- a/opendc-web/opendc-web-ui/src/pages/_document.js +++ b/opendc-web/opendc-web-server/src/main/webui/pages/_document.js @@ -63,6 +63,8 @@ class OpenDCDocument extends Document { content="OpenDC provides collaborative online datacenter modeling, diverse and effective datacenter simulation, and exploratory datacenter performance feedback." /> + {/* Load config before Next scripts */} +