feat(frontend): migrated old > new silo adjustments

moved the apps around so we can use 1 url for cors bs
This commit is contained in:
2025-10-25 17:22:51 -05:00
parent d46ef922f3
commit 425f8f5f71
179 changed files with 7511 additions and 2724 deletions

View File

@@ -4,6 +4,7 @@ import { serve } from "@hono/node-server";
import { serveStatic } from "@hono/node-server/serve-static";
import { OpenAPIHono } from "@hono/zod-openapi";
import { cors } from "hono/cors";
import { html } from "hono/html";
import { logger } from "hono/logger";
import os from "os";
import auth from "./services/auth/authService.js";
@@ -152,9 +153,66 @@ app.route("/ocme/", ocme);
// the catch all api route
app.all("/api/*", (c) => c.json({ error: "API route not found" }, 404));
const newPageDoc = `
<!doctype html>
<h1>Hello!</h1>
`;
app.all("*", (c) => {
const testServers = ["test1", "test2", "test3"];
const server = serverIntialized.filter((n: any) => n.name === "plantToken");
let url = "";
if (testServers.includes(server[0].value)) {
const dbServer = serverIntialized.filter((n: any) => n.name === "dbServer");
url = `https://${dbServer[0].value}.alpla.net/lst/app/old${c.req.path}`;
} else {
url = `https://${server[0].value}prod.alpla.net/lst/app/old${c.req.path}`;
}
const target = url;
const waitSeconds = 10;
return c.html(html`<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Lst Moved</title>
<style>
body{font-family:sans-serif;display:flex;flex-direction:column;
align-items:center;justify-content:center;height:100vh;}
button{margin-top:1rem;padding:0.6rem 1.2rem;font-size:1rem;cursor:pointer;}
</style>
</head>
<body>
<h1>Weve moved!</h1>
<p>With new security and updating to mobile version the app had to be moved. You will be redirected to.</p>
<p><a href="${target}">${target}</a></p>
<p>Redirecting in <span id="countdown">${waitSeconds}</span> seconds…</p>
<button id="goNow">Go now</button>
<script>
let s = ${waitSeconds};
const el = document.getElementById('countdown');
const btn = document.getElementById('goNow');
const timer = setInterval(()=>{
s--;
el.textContent = s;
if(s <= 0){ clearInterval(timer); window.location.href='${target}'; }
},1000);
btn.addEventListener('click',()=>{
clearInterval(timer); window.location.href='${target}';
});
</script>
</body>
</html>`);
});
// app.all("/*", (c) => {
// console.log(c.req.path);
// return c.html(html`${newPageDoc}`);
// });
// front end static files
app.use("/*", serveStatic({ root: "./frontend/dist" }));
app.use("*", serveStatic({ path: "./frontend/dist/index.html" }));
//app.use("/*", serveStatic({ root: "./frontend/dist" }));
//app.use("*", serveStatic({ path: "./frontend/dist/index.html" }));
// Handle app exit signals
process.on("SIGINT", async () => {

View File

@@ -13,7 +13,7 @@ const newSubModules = [
name: "RFID",
moduleName: "prodcution",
description: "RFID stuff",
link: "/rfid",
link: "/lst/app/old/rfid",
icon: "Tags",
active: true,
roles: [
@@ -30,7 +30,7 @@ const newSubModules = [
name: "siloAdjustments",
moduleName: "logistics",
description: "Do a silo adjustments",
link: "/siloAdjustments",
link: "/lst/app/old/siloAdjustments",
icon: "Cylinder",
active: false,
roles: ["technician", "supervisor", "manager", "admin", "systemAdmin"],
@@ -40,7 +40,7 @@ const newSubModules = [
name: "demandManagement",
moduleName: "logistics",
description: "Bulk order and Forecast imports",
link: "/dm",
link: "/lst/app/old/dm",
icon: "Truck",
roles: ["technician", "supervisor", "manager", "admin", "systemAdmin"],
active: false,
@@ -60,7 +60,7 @@ const newSubModules = [
name: "Material Helper",
moduleName: "logistics",
description: "",
link: "/materialHelper/consumption",
link: "/lst/app/old/materialHelper/consumption",
icon: "Package",
roles: [
"viewer",
@@ -77,7 +77,7 @@ const newSubModules = [
name: "Ocme Cyclecount",
moduleName: "logistics",
description: "",
link: "/cyclecount",
link: "/lst/app/old/cyclecount",
icon: "Package",
roles: ["technician", "supervisor", "manager", "admin", "systemAdmin"],
active: false,
@@ -87,7 +87,7 @@ const newSubModules = [
name: "Open Orders",
moduleName: "logistics",
description: "Open orders",
link: "/openOrders",
link: "/lst/app/old/openOrders",
icon: "Truck",
roles: [
"viewer",
@@ -104,7 +104,7 @@ const newSubModules = [
name: "Barcodes",
moduleName: "logistics",
description: "Barcodes, lanes and scanable",
link: "/barcodegen",
link: "/lst/app/old/barcodegen",
icon: "Barcode",
roles: [
"viewer",
@@ -121,7 +121,7 @@ const newSubModules = [
name: "Helper Commands",
moduleName: "logistics",
description: "Commands to assist when a scanner is not avalible",
link: "/helpercommands",
link: "/lst/app/old/helpercommands",
icon: "Command",
roles: ["technician", "supervisor", "manager", "admin", "systemAdmin"],
active: true,
@@ -222,6 +222,7 @@ const newSubModules = [
},
];
export const areSubModulesIn = async () => {
await db.delete(subModules);
try {
for (let i = 0; i < newSubModules.length; i++) {
const subModuleUpdate = await db