diff --git a/build_system.d b/build_system.d index 80344a8..e5df173 100755 --- a/build_system.d +++ b/build_system.d @@ -11,33 +11,53 @@ module build_system; import dsh; +import std.stdio; +import std.string; const DIST = "./src/main/resources/app"; const DIST_ORIGIN = "./quasar-app/dist/spa"; const APP_BUILD = "quasar build -m spa"; +const API_BUILD = "mvn clean package spring-boot:repackage -DskipTests=true"; void main(string[] args) { print("Building RailSignalAPI"); + string baseDomain = "localhost:8080"; + bool useHttps = false; + if (args.length >= 2) { + baseDomain = args[1]; + if (args.length >= 3 && args[2] == "secure") { + useHttps = true; + print("Will configure web app to use secure connections."); + } + } + string apiUrl = format!"%s://%s/api"(useHttps ? "https" : "http", baseDomain); + string wsUrl = format!"%s://%s/api/ws/app"(useHttps ? "wss" : "ws", baseDomain); + print("Building web app using API url %s and WS url %s", apiUrl, wsUrl); + sleepSeconds(3); + chdir("quasar-app"); print("Building app..."); + setEnv("RAIL_SIGNAL_API_URL", apiUrl); + setEnv("RAIL_SIGNAL_WS_URL", wsUrl); runOrQuit(APP_BUILD); print("Copying dist from %s to %s", DIST_ORIGIN, DIST); chdir(".."); removeIfExists(DIST); mkdir(DIST); copyDir(DIST_ORIGIN, DIST); - print("Building API..."); - runOrQuit("mvn clean package spring-boot:repackage -DskipTests=true"); - print("Build complete!"); - if (args.length > 1 && args[1] == "run") { - string f = findFile("target", "^.+\\.jar$", false); - if (f == null) { - error("Could not find jar file!"); - } else { - print("Running the program."); - run("java -jar " ~ f); - } - } + print("Building API..."); + runOrQuit(API_BUILD); + print("Build complete!"); + string jarFile = findFile(".", "\\.jar", false); + + print("Generating run script..."); + auto scriptFile = File("target/run.sh", "w"); + scriptFile.write("#!/usr/bin/bash\n"); + scriptFile.write("RAIL_SIGNAL_API_URL=http://localhost:8080/api\n"); + scriptFile.write("RAIL_SIGNAL_WS_URL=ws://localhost:8080/api/ws/app\n"); + scriptFile.write("java -jar " ~ jarFile ~ "\n"); + scriptFile.close(); + print("Script file generated."); } diff --git a/quasar-app/quasar.config.js b/quasar-app/quasar.config.js index fa10ccb..828acf8 100644 --- a/quasar-app/quasar.config.js +++ b/quasar-app/quasar.config.js @@ -71,8 +71,8 @@ module.exports = configure(function (ctx) { publicPath: "/app/", // analyze: true, env: { - API_URL: ctx.dev ? "http://localhost:8080/api" : "http://localhost:8080/api", - WS_URL: ctx.dev ? "ws://localhost:8080/api/ws/app" : "ws://localhost:8080/api/ws/app" + API_URL: ctx.dev ? "http://localhost:8080/api" : process.env.RAIL_SIGNAL_API_URL, + WS_URL: ctx.dev ? "ws://localhost:8080/api/ws/app" : process.env.RAIL_SIGNAL_WS_URL }, // rawDefine: {} // ignorePublicFolder: true, diff --git a/quasar-app/src/api/constants.js b/quasar-app/src/api/constants.js index 4cef92c..bec15ce 100644 --- a/quasar-app/src/api/constants.js +++ b/quasar-app/src/api/constants.js @@ -1,2 +1,4 @@ export const API_URL = process.env.API_URL; export const WS_URL = process.env.WS_URL; +console.log("Using API url: " + API_URL); +console.log("Using WS url: " + WS_URL); diff --git a/quasar-app/src/components/rs/SelectedComponentView.vue b/quasar-app/src/components/rs/SelectedComponentView.vue index b27ccfe..a7fbb08 100644 --- a/quasar-app/src/components/rs/SelectedComponentView.vue +++ b/quasar-app/src/components/rs/SelectedComponentView.vue @@ -99,8 +99,6 @@ dense size="sm" :label="node.name" - :color="component.activeConfiguration && component.activeConfiguration.id === config.id ? 'primary' : 'secondary'" - :text-color="'white'" clickable @click="select(node)" />