Remove WebServerVerticle and update API endpoints in settings.json; fix base URL formatting in multiple components
This commit is contained in:
@@ -85,16 +85,6 @@ public class MainVerticle extends AbstractVerticle {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
vertx.deployVerticle(new WebServerVerticle(), result -> {
|
|
||||||
if (result.succeeded()) {
|
|
||||||
Constants.LOGGER.info("🟢 WebServerVerticle desplegado");
|
|
||||||
Constants.LOGGER.info("\t🔗 WEB SERVER URL: " + configManager.getHost()
|
|
||||||
+ ":" + configManager.getWebserverPort());
|
|
||||||
} else {
|
|
||||||
Constants.LOGGER.error("🔴 Error deploying WebServerVerticle: " + result.cause());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
startPromise.complete();
|
startPromise.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
package net.miarma.contaminus.server;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
|
|
||||||
import io.vertx.core.AbstractVerticle;
|
|
||||||
import io.vertx.core.Promise;
|
|
||||||
import io.vertx.ext.web.Router;
|
|
||||||
import io.vertx.ext.web.handler.StaticHandler;
|
|
||||||
import net.miarma.contaminus.common.ConfigManager;
|
|
||||||
import net.miarma.contaminus.common.Constants;
|
|
||||||
|
|
||||||
public class WebServerVerticle extends AbstractVerticle {
|
|
||||||
private ConfigManager configManager;
|
|
||||||
|
|
||||||
public WebServerVerticle() {
|
|
||||||
configManager = ConfigManager.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void start(Promise<Void> startPromise) {
|
|
||||||
Constants.LOGGER.info("📡 Iniciando WebServerVerticle...");
|
|
||||||
|
|
||||||
Router router = Router.router(vertx);
|
|
||||||
|
|
||||||
Path webRootPath = Paths.get(configManager.getWebRoot());
|
|
||||||
|
|
||||||
if (webRootPath.isAbsolute()) {
|
|
||||||
Path basePath = Paths.get(System.getProperty("user.dir")); // Directorio actual
|
|
||||||
webRootPath = basePath.relativize(webRootPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
router.route("/*")
|
|
||||||
.handler(
|
|
||||||
StaticHandler.create(webRootPath.toString())
|
|
||||||
.setCachingEnabled(false)
|
|
||||||
.setDefaultContentEncoding("UTF-8")
|
|
||||||
);
|
|
||||||
|
|
||||||
router.route("/dashboard/*").handler(ctx -> {
|
|
||||||
ctx.reroute("/index.html");
|
|
||||||
});
|
|
||||||
|
|
||||||
vertx.createHttpServer()
|
|
||||||
.requestHandler(router)
|
|
||||||
.listen(configManager.getWebserverPort(), configManager.getHost());
|
|
||||||
|
|
||||||
startPromise.complete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,8 +7,8 @@
|
|||||||
},
|
},
|
||||||
"appConfig": {
|
"appConfig": {
|
||||||
"endpoints": {
|
"endpoints": {
|
||||||
"DATA_URL": "http://localhost:8081/api/v1",
|
"DATA_URL": "https://contaminus.miarma.net/api/raw/v1",
|
||||||
"LOGIC_URL": "http://localhost:8082/api/v1",
|
"LOGIC_URL": "https://contaminus.miarma.net/api/v1",
|
||||||
"GET_GROUPS": "/groups",
|
"GET_GROUPS": "/groups",
|
||||||
"GET_GROUP_BY_ID": "/groups/{0}",
|
"GET_GROUP_BY_ID": "/groups/{0}",
|
||||||
"GET_GROUP_DEVICES": "/groups/{0}/devices",
|
"GET_GROUP_DEVICES": "/groups/{0}/devices",
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ const HistoryCharts = () => {
|
|||||||
const ENDPOINT = config.appConfig.endpoints.sensors;
|
const ENDPOINT = config.appConfig.endpoints.sensors;
|
||||||
|
|
||||||
const reqConfig = {
|
const reqConfig = {
|
||||||
baseUrl: `${BASE}/${ENDPOINT}`,
|
baseUrl: `${BASE}${ENDPOINT}`,
|
||||||
params: {}
|
params: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ const PollutionMap = ({ deviceId }) => {
|
|||||||
let endp = ENDPOINT.replace('{0}', deviceId);
|
let endp = ENDPOINT.replace('{0}', deviceId);
|
||||||
|
|
||||||
const reqConfig = {
|
const reqConfig = {
|
||||||
baseUrl: `${BASE}/${endp}`,
|
baseUrl: `${BASE}${endp}`,
|
||||||
params: {}
|
params: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ const SideMenu = ({ isOpen, onClose }) => {
|
|||||||
const ENDPOINT = config.appConfig.endpoints.GET_DEVICES;
|
const ENDPOINT = config.appConfig.endpoints.GET_DEVICES;
|
||||||
|
|
||||||
const reqConfig = {
|
const reqConfig = {
|
||||||
baseUrl: `${BASE}/${ENDPOINT}`,
|
baseUrl: `${BASE}${ENDPOINT}`,
|
||||||
params: {}
|
params: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ const SummaryCards = ({ deviceId }) => {
|
|||||||
const endp = ENDPOINT.replace('{0}', deviceId);
|
const endp = ENDPOINT.replace('{0}', deviceId);
|
||||||
|
|
||||||
const reqConfig = {
|
const reqConfig = {
|
||||||
baseUrl: `${BASE}/${endp}`,
|
baseUrl: `${BASE}${endp}`,
|
||||||
params: {}
|
params: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from 'vite'
|
||||||
import react from '@vitejs/plugin-react'
|
import react from '@vitejs/plugin-react'
|
||||||
import cleanPlugin from 'vite-plugin-clean'
|
import cleanPlugin from 'vite-plugin-clean'
|
||||||
import path from 'path'
|
|
||||||
import os from 'os'
|
|
||||||
|
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
@@ -19,10 +17,7 @@ export default defineConfig({
|
|||||||
"chartjs": ["chart.js"]
|
"chartjs": ["chart.js"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
outDir: path.join(
|
|
||||||
os.platform() === 'win32' ? os.homedir() + '\\.contaminus\\webroot' : os.homedir() + '/.config/contaminus/webroot'
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
publicDir: 'public',
|
publicDir: 'public',
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user