refactor(modules): moved modules to app to control everything based on there active setting
This commit is contained in:
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@@ -8,6 +8,7 @@
|
|||||||
"source.organizeImports.biome": "explicit"
|
"source.organizeImports.biome": "explicit"
|
||||||
},
|
},
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
|
"acitve",
|
||||||
"alpla",
|
"alpla",
|
||||||
"alplamart",
|
"alplamart",
|
||||||
"alplaprod",
|
"alplaprod",
|
||||||
|
|||||||
@@ -4,16 +4,12 @@ meta {
|
|||||||
seq: 7
|
seq: 7
|
||||||
}
|
}
|
||||||
|
|
||||||
patch {
|
get {
|
||||||
url: {{url}}/lst/api/admin/users/:userID/grant
|
url: {{url}}/lst/api/user/roles
|
||||||
body: json
|
body: json
|
||||||
auth: inherit
|
auth: inherit
|
||||||
}
|
}
|
||||||
|
|
||||||
params:path {
|
|
||||||
userID: 0hlO48C7Jw1J804FxrCnonKjQ2zh48R6
|
|
||||||
}
|
|
||||||
|
|
||||||
body:json {
|
body:json {
|
||||||
{
|
{
|
||||||
"module":"siloAdjustments",
|
"module":"siloAdjustments",
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ post {
|
|||||||
|
|
||||||
body:json {
|
body:json {
|
||||||
{
|
{
|
||||||
"username": "cowch",
|
"username": "matthes01",
|
||||||
"password": "Alpla2025!"
|
"password": "nova0511"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
meta {
|
||||||
|
name: GetModules
|
||||||
|
type: http
|
||||||
|
seq: 3
|
||||||
|
}
|
||||||
|
|
||||||
|
get {
|
||||||
|
url: {{url}}/lst/api/system/modules
|
||||||
|
body: none
|
||||||
|
auth: inherit
|
||||||
|
}
|
||||||
|
|
||||||
|
settings {
|
||||||
|
encodeUrl: true
|
||||||
|
timeout: 0
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
meta {
|
||||||
|
name: Update Modules
|
||||||
|
type: http
|
||||||
|
seq: 2
|
||||||
|
}
|
||||||
|
|
||||||
|
patch {
|
||||||
|
url: {{url}}/lst/api/system/modules/update/:module
|
||||||
|
body: json
|
||||||
|
auth: inherit
|
||||||
|
}
|
||||||
|
|
||||||
|
params:path {
|
||||||
|
module: materialHelper
|
||||||
|
}
|
||||||
|
|
||||||
|
body:json {
|
||||||
|
{
|
||||||
|
"active": true,
|
||||||
|
"updateAll": true
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
settings {
|
||||||
|
encodeUrl: true
|
||||||
|
timeout: 0
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
meta {
|
||||||
|
name: modules
|
||||||
|
seq: 3
|
||||||
|
}
|
||||||
|
|
||||||
|
auth {
|
||||||
|
mode: inherit
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
vars {
|
vars {
|
||||||
url: http://localhost:4200
|
url: https://usmcd1vms036.alpla.net
|
||||||
session_cookie:
|
session_cookie:
|
||||||
urlv2: http://localhost:3000
|
urlv2: http://localhost:3000
|
||||||
jwtV2:
|
jwtV2:
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { userMigrate } from "./src/internal/auth/controller/userMigrate.js";
|
|||||||
import { schedulerManager } from "./src/internal/logistics/controller/schedulerManager.js";
|
import { schedulerManager } from "./src/internal/logistics/controller/schedulerManager.js";
|
||||||
import { printers } from "./src/internal/ocp/printers/printers.js";
|
import { printers } from "./src/internal/ocp/printers/printers.js";
|
||||||
import { setupRoutes } from "./src/internal/routerHandler/routeHandler.js";
|
import { setupRoutes } from "./src/internal/routerHandler/routeHandler.js";
|
||||||
|
import { baseModules } from "./src/internal/system/controller/modules/baseModules.js";
|
||||||
import { baseSettings } from "./src/internal/system/controller/settings/baseSettings.js";
|
import { baseSettings } from "./src/internal/system/controller/settings/baseSettings.js";
|
||||||
import { auth } from "./src/pkg/auth/auth.js";
|
import { auth } from "./src/pkg/auth/auth.js";
|
||||||
import { db } from "./src/pkg/db/db.js";
|
import { db } from "./src/pkg/db/db.js";
|
||||||
@@ -184,6 +185,7 @@ const main = async () => {
|
|||||||
// start all systems after we are intiallally up and running
|
// start all systems after we are intiallally up and running
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
baseSettings();
|
baseSettings();
|
||||||
|
baseModules();
|
||||||
printers();
|
printers();
|
||||||
schedulerManager();
|
schedulerManager();
|
||||||
|
|
||||||
|
|||||||
@@ -1,32 +1,34 @@
|
|||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
|
import { requireAuth } from "../../../../pkg/middleware/authMiddleware.js";
|
||||||
|
import { restrictToHosts } from "../../../../pkg/middleware/restrictToHosts.js";
|
||||||
import addServer from "./addServer.js";
|
import addServer from "./addServer.js";
|
||||||
import getServers from "./getServers.js";
|
import getServers from "./getServers.js";
|
||||||
import updateServer from "./updateServer.js";
|
import updateServer from "./updateServer.js";
|
||||||
import { restrictToHosts } from "../../../../pkg/middleware/restrictToHosts.js";
|
|
||||||
import { requireAuth } from "../../../../pkg/middleware/authMiddleware.js";
|
|
||||||
|
|
||||||
const router = Router();
|
const router = Router();
|
||||||
|
|
||||||
router.use("/", getServers);
|
router.use("/", getServers);
|
||||||
router.use(
|
router.use(
|
||||||
"/",
|
"/",
|
||||||
requireAuth("user", ["systemAdmin", "admin"]),
|
requireAuth("user", ["systemAdmin", "admin"]),
|
||||||
restrictToHosts([
|
restrictToHosts([
|
||||||
"usmcd1vms036.alpla.net",
|
"localhost:5500",
|
||||||
"USMCD1VMS036.alpla.net",
|
"usmcd1vms036.alpla.net",
|
||||||
"https://usmcd1vms036.alpla.net",
|
"USMCD1VMS036.alpla.net",
|
||||||
]),
|
"https://usmcd1vms036.alpla.net",
|
||||||
addServer
|
]),
|
||||||
|
addServer,
|
||||||
);
|
);
|
||||||
router.use(
|
router.use(
|
||||||
"/",
|
"/",
|
||||||
requireAuth("user", ["systemAdmin", "admin"]),
|
requireAuth("user", ["systemAdmin", "admin"]),
|
||||||
restrictToHosts([
|
restrictToHosts([
|
||||||
"usmcd1vms036.alpla.net",
|
"localhost:5500",
|
||||||
"USMCD1VMS036.alpla.net",
|
"usmcd1vms036.alpla.net",
|
||||||
"https://usmcd1vms036.alpla.net",
|
"USMCD1VMS036.alpla.net",
|
||||||
]),
|
"https://usmcd1vms036.alpla.net",
|
||||||
updateServer
|
]),
|
||||||
|
updateServer,
|
||||||
);
|
);
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -42,8 +42,12 @@ router.post("/", async (req: Request, res: Response) => {
|
|||||||
.update(user)
|
.update(user)
|
||||||
.set({ lastLogin: sql`NOW()` })
|
.set({ lastLogin: sql`NOW()` })
|
||||||
.where(eq(user.id, newUser.user.id));
|
.where(eq(user.id, newUser.user.id));
|
||||||
return res.status(201).json(user);
|
|
||||||
|
return res
|
||||||
|
.status(201)
|
||||||
|
.json({ success: true, message: "User created", data: newUser });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
if (err instanceof z.ZodError) {
|
if (err instanceof z.ZodError) {
|
||||||
const flattened = z.flattenError(err);
|
const flattened = z.flattenError(err);
|
||||||
return res.status(400).json({
|
return res.status(400).json({
|
||||||
@@ -59,6 +63,12 @@ router.post("/", async (req: Request, res: Response) => {
|
|||||||
error: err.status,
|
error: err.status,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return res.status(200).json({
|
||||||
|
success: false,
|
||||||
|
message: "There was an error creating your user.",
|
||||||
|
error: err,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,46 @@
|
|||||||
|
import { sql } from "drizzle-orm";
|
||||||
import { readFileSync } from "fs";
|
import { readFileSync } from "fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { fileURLToPath } from "url";
|
import { fileURLToPath } from "url";
|
||||||
|
import { db } from "../../../../pkg/db/db.js";
|
||||||
|
import { modules } from "../../../../pkg/db/schema/modules.js";
|
||||||
|
import { createLogger } from "../../../../pkg/logger/logger.js";
|
||||||
|
import { tryCatch } from "../../../../pkg/utils/tryCatch.js";
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
const __dirname = path.dirname(__filename);
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
export const baseModules = async () => {
|
export const baseModules = async () => {
|
||||||
|
const log = createLogger({ module: "system", subModule: "base modules" });
|
||||||
const modulePath = path.resolve(__dirname, "./modules.json");
|
const modulePath = path.resolve(__dirname, "./modules.json");
|
||||||
|
const newModules = JSON.parse(readFileSync(modulePath, "utf-8"));
|
||||||
|
|
||||||
|
for (const m of newModules) {
|
||||||
|
const { data, error } = await tryCatch(
|
||||||
|
db
|
||||||
|
.insert(modules)
|
||||||
|
.values(m)
|
||||||
|
.onConflictDoUpdate({
|
||||||
|
target: modules.name,
|
||||||
|
set: {
|
||||||
|
category: m.category,
|
||||||
|
link: m.link,
|
||||||
|
icon: m.icon,
|
||||||
|
roles: m.roles,
|
||||||
|
upd_date: sql`NOW()`,
|
||||||
|
upd_user: "LST-user",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.returning({ name: modules.name }),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
console.log(error);
|
||||||
|
log.error({ error }, "There was an error adding new settings");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
log.info({ newModulesAdded: data }, "New settings added");
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,30 +1,122 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "plantToken",
|
"name": "users",
|
||||||
"value": "test3",
|
"category": "admin",
|
||||||
"description": "The plant token for the plant IE: test3 or usday1",
|
"icon": "User",
|
||||||
"moduleName": "system",
|
"link": "/lst/app/admin/users",
|
||||||
"roles": ["systemAdmin"]
|
"active": true,
|
||||||
|
"roles": ["systemAdmin", "admin"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "dbServer",
|
"name": "system",
|
||||||
"value": "usmcd1vms036",
|
"category": "admin",
|
||||||
"description": "What is the db server",
|
"icon": "MonitorCog",
|
||||||
"moduleName": "system",
|
"link": "/lst/app/system",
|
||||||
"roles": ["systemAdmin"]
|
"active": true,
|
||||||
|
"roles": ["systemAdmin", "admin"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "v1Server",
|
"name": "ocp",
|
||||||
"value": "localhost",
|
"category": "production",
|
||||||
"description": "What is the port the v1app is on",
|
"icon": "Printer",
|
||||||
"moduleName": "system",
|
"link": "/lst/app/old/ocp",
|
||||||
"roles": ["systemAdmin"]
|
"active": true,
|
||||||
|
"roles": ["viewer", "manager", "tester", "systemAdmin", "admin"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "v1Port",
|
"name": "rfidReaders",
|
||||||
"value": "3000",
|
"category": "production",
|
||||||
"description": "What is the port the v1app is on",
|
"icon": "Tags",
|
||||||
"moduleName": "system",
|
"link": "/lst/app/old/rfid",
|
||||||
"roles": ["systemAdmin"]
|
"active": false,
|
||||||
|
"roles": ["viewer", "manager", "tester", "systemAdmin", "admin"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ocmeCycleCounts",
|
||||||
|
"category": "ocme",
|
||||||
|
"icon": "Package",
|
||||||
|
"link": "/lst/app/old/ocme/cyclecount",
|
||||||
|
"active": false,
|
||||||
|
"roles": ["manager", "tester", "systemAdmin", "admin"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "siloAdjustments",
|
||||||
|
"category": "logistics",
|
||||||
|
"icon": "Database",
|
||||||
|
"link": "/lst/app/old/siloAdjustments",
|
||||||
|
"active": true,
|
||||||
|
"roles": ["manager", "admin", "tester", "systemAdmin"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "demandManagement",
|
||||||
|
"category": "logistics",
|
||||||
|
"icon": "Truck",
|
||||||
|
"link": "/lst/app/old/dm",
|
||||||
|
"active": true,
|
||||||
|
"roles": ["manager", "admin", "tester", "systemAdmin"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "logistics",
|
||||||
|
"category": "logistics",
|
||||||
|
"icon": "",
|
||||||
|
"link": "/lst/app/old",
|
||||||
|
"active": false,
|
||||||
|
"roles": ["admin", "systemAdmin", "manager", "viewer", "tester"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "helperCommands",
|
||||||
|
"category": "logistics",
|
||||||
|
"icon": "Package",
|
||||||
|
"link": "/lst/app/old/helperCommands",
|
||||||
|
"active": true,
|
||||||
|
"roles": ["admin", "systemAdmin", "manager", "viewer", "tester"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "materialHelper",
|
||||||
|
"category": "logistics",
|
||||||
|
"active": true,
|
||||||
|
"icon": "Package",
|
||||||
|
"link": "/lst/app/old/materialHelper/consumption",
|
||||||
|
"roles": ["admin", "systemAdmin", "manager", "viewer", "tester"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "openOrders",
|
||||||
|
"category": "logistics",
|
||||||
|
"active": true,
|
||||||
|
"icon": "Truck",
|
||||||
|
"link": "/lst/app/old/openOrders",
|
||||||
|
"roles": ["admin", "systemAdmin", "manager", "viewer", "tester"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "production",
|
||||||
|
"category": "production",
|
||||||
|
"active": false,
|
||||||
|
"icon": "",
|
||||||
|
"link": "",
|
||||||
|
"roles": ["admin", "systemAdmin", "manager", "viewer", "tester"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "quality",
|
||||||
|
"category": "quality",
|
||||||
|
"active": false,
|
||||||
|
"icon": "",
|
||||||
|
"link": "",
|
||||||
|
"roles": ["admin", "systemAdmin", "manager", "viewer", "tester"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "eom",
|
||||||
|
"category": "logistics",
|
||||||
|
"active": true,
|
||||||
|
"icon": "",
|
||||||
|
"link": "/lst/app/old/eom",
|
||||||
|
"roles": ["admin", "systemAdmin", "manager", "tester"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "forklifts",
|
||||||
|
"category": "logistics",
|
||||||
|
"active": false,
|
||||||
|
"icon": "",
|
||||||
|
"link": "/lst/app/old/forklifts",
|
||||||
|
"roles": ["admin", "systemAdmin", "manager", "tester"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import type { Express, Request, Response } from "express";
|
import type { Express, Request, Response } from "express";
|
||||||
|
import modules from "./routes/modules/moduleRoutes.js";
|
||||||
import settings from "./routes/settings/settingRoutes.js";
|
import settings from "./routes/settings/settingRoutes.js";
|
||||||
import stats from "./routes/stats.js";
|
import stats from "./routes/stats.js";
|
||||||
|
|
||||||
@@ -9,4 +10,8 @@ export const setupSystemRoutes = (app: Express, basePath: string) => {
|
|||||||
basePath + "/api/system/settings", // will pass bc system admin but this is just telling us we need this
|
basePath + "/api/system/settings", // will pass bc system admin but this is just telling us we need this
|
||||||
settings,
|
settings,
|
||||||
);
|
);
|
||||||
|
app.use(
|
||||||
|
basePath + "/api/system/modules", // will pass bc system admin but this is just telling us we need this
|
||||||
|
modules,
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
36
app/src/internal/system/routes/modules/getModules.ts
Normal file
36
app/src/internal/system/routes/modules/getModules.ts
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import { and, asc, eq } from "drizzle-orm";
|
||||||
|
import type { Request, Response } from "express";
|
||||||
|
import { Router } from "express";
|
||||||
|
import { db } from "../../../../pkg/db/db.js";
|
||||||
|
import { modules } from "../../../../pkg/db/schema/modules.js";
|
||||||
|
import { serverData } from "../../../../pkg/db/schema/servers.js";
|
||||||
|
import { tryCatch } from "../../../../pkg/utils/tryCatch.js";
|
||||||
|
|
||||||
|
const router = Router();
|
||||||
|
|
||||||
|
router.get("/", async (req: Request, res: Response) => {
|
||||||
|
// const token = req.query.token;
|
||||||
|
|
||||||
|
// const conditions = [];
|
||||||
|
|
||||||
|
// if (token !== undefined) {
|
||||||
|
// conditions.push(eq(serverData.plantToken, `${token}`));
|
||||||
|
// }
|
||||||
|
|
||||||
|
//conditions.push(eq(serverData.active, true));
|
||||||
|
|
||||||
|
const { data, error } = await tryCatch(
|
||||||
|
db
|
||||||
|
.select()
|
||||||
|
.from(modules)
|
||||||
|
//.where(and(...conditions))
|
||||||
|
.orderBy(asc(modules.name)),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return res.status(400).json({ error: error });
|
||||||
|
}
|
||||||
|
res.status(200).json({ message: "Current modules", data: data });
|
||||||
|
});
|
||||||
|
|
||||||
|
export default router;
|
||||||
15
app/src/internal/system/routes/modules/moduleRoutes.ts
Normal file
15
app/src/internal/system/routes/modules/moduleRoutes.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { Router } from "express";
|
||||||
|
import { requireAuth } from "../../../../pkg/middleware/authMiddleware.js";
|
||||||
|
import getModules from "./getModules.js";
|
||||||
|
import updateModules from "./updateModules.js";
|
||||||
|
|
||||||
|
const router = Router();
|
||||||
|
|
||||||
|
router.use("/", getModules);
|
||||||
|
router.use(
|
||||||
|
"/update",
|
||||||
|
requireAuth("system", ["systemAdmin", "admin"]),
|
||||||
|
updateModules,
|
||||||
|
);
|
||||||
|
|
||||||
|
export default router;
|
||||||
131
app/src/internal/system/routes/modules/updateModules.ts
Normal file
131
app/src/internal/system/routes/modules/updateModules.ts
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
import axios from "axios";
|
||||||
|
import { eq, sql } from "drizzle-orm";
|
||||||
|
import type { Request, Response } from "express";
|
||||||
|
import { Router } from "express";
|
||||||
|
import https from "https";
|
||||||
|
import { db } from "../../../../pkg/db/db.js";
|
||||||
|
import { modules } from "../../../../pkg/db/schema/modules.js";
|
||||||
|
import { serverData } from "../../../../pkg/db/schema/servers.js";
|
||||||
|
import { createLogger } from "../../../../pkg/logger/logger.js";
|
||||||
|
import { tryCatch } from "../../../../pkg/utils/tryCatch.js";
|
||||||
|
|
||||||
|
const router = Router();
|
||||||
|
|
||||||
|
router.patch("/:module", async (req: Request, res: Response) => {
|
||||||
|
const log = createLogger({ module: "admin", subModule: "update module" });
|
||||||
|
|
||||||
|
// when a server is updated and is posted from localhost or 127.0.0.1 we also want to post it to the test server so we can see it from there, we want to insert with update on conflict.
|
||||||
|
const module = req.params.module;
|
||||||
|
const updates: Record<string, any> = {};
|
||||||
|
|
||||||
|
if (req.body?.active !== undefined) {
|
||||||
|
updates.active = req.body.active;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.body?.icon !== undefined) {
|
||||||
|
updates.icon = req.body.icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.body?.link !== undefined) {
|
||||||
|
updates.link = req.body.link;
|
||||||
|
}
|
||||||
|
|
||||||
|
updates.upd_user = req.user!.username || "lst_user";
|
||||||
|
updates.upd_date = sql`NOW()`;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (Object.keys(updates).length > 0) {
|
||||||
|
await db.update(modules).set(updates).where(eq(modules.name, module));
|
||||||
|
}
|
||||||
|
|
||||||
|
// if we pass updateAll:true then we want to update all servers this will help kill all bad stuff if we have it.
|
||||||
|
|
||||||
|
if (req.body?.updateAll) {
|
||||||
|
const { data: serverInfo, error: errorData } = await tryCatch(
|
||||||
|
db.select().from(serverData),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (errorData) {
|
||||||
|
log.error(
|
||||||
|
{ error: errorData },
|
||||||
|
"There was an error getting the serverData",
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const s of serverInfo) {
|
||||||
|
try {
|
||||||
|
const url = s.plantToken.includes("test")
|
||||||
|
? `https://${s.serverDNS}.alpla.net`
|
||||||
|
: `https://${s.plantToken}prod.alpla.net`;
|
||||||
|
const axiosInstance = axios.create({
|
||||||
|
httpsAgent: new https.Agent({ rejectUnauthorized: false }),
|
||||||
|
withCredentials: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const loginRes = (await axiosInstance.post(
|
||||||
|
`${url}/lst/api/auth/sign-in/username`,
|
||||||
|
{
|
||||||
|
username: process.env.MAIN_SERVER_USERNAME,
|
||||||
|
password: process.env.MAIN_SERVER_PASSWORD,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
},
|
||||||
|
)) as any;
|
||||||
|
|
||||||
|
const setCookie = loginRes?.headers["set-cookie"][0];
|
||||||
|
|
||||||
|
//console.log(setCookie.split(";")[0].replace("__Secure-", ""));
|
||||||
|
|
||||||
|
if (!setCookie) {
|
||||||
|
throw new Error("Did not receive a Set-Cookie header from login");
|
||||||
|
}
|
||||||
|
|
||||||
|
const { data, error } = await tryCatch(
|
||||||
|
axios.patch(`${url}/lst/api/system/modules/${module}`, updates, {
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Cookie: setCookie.split(";")[0],
|
||||||
|
},
|
||||||
|
withCredentials: true,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
//console.log(error);
|
||||||
|
log.error(
|
||||||
|
{ stack: error },
|
||||||
|
"There was an error updating the system",
|
||||||
|
);
|
||||||
|
return res.status(400).json({
|
||||||
|
message: `${module} encountered an error updating on the servers`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
log.info({ stack: data?.data }, "module was just updated.");
|
||||||
|
|
||||||
|
return res
|
||||||
|
.status(200)
|
||||||
|
.json({ message: `${module} was just updated on all servers` });
|
||||||
|
} catch (e) {
|
||||||
|
log.error(
|
||||||
|
{ error: e },
|
||||||
|
`There was an error updating the module setting on ${s.name}`,
|
||||||
|
);
|
||||||
|
return res.status(400).json({
|
||||||
|
message: `${module} encountered an error updating on the servers`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return res
|
||||||
|
.status(200)
|
||||||
|
.json({ message: `${module}, was just updated to this server only` });
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
res.status(400).json({ message: "Error Server updated", error });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default router;
|
||||||
42
app/src/pkg/db/schema/modules.ts
Normal file
42
app/src/pkg/db/schema/modules.ts
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import {
|
||||||
|
boolean,
|
||||||
|
jsonb,
|
||||||
|
pgTable,
|
||||||
|
text,
|
||||||
|
timestamp,
|
||||||
|
uniqueIndex,
|
||||||
|
uuid,
|
||||||
|
} from "drizzle-orm/pg-core";
|
||||||
|
import { createSelectSchema } from "drizzle-zod";
|
||||||
|
//import {z} from "zod";
|
||||||
|
|
||||||
|
export const modules = pgTable(
|
||||||
|
"modules",
|
||||||
|
{
|
||||||
|
module_id: uuid("module_id").defaultRandom().primaryKey(),
|
||||||
|
name: text("name").notNull(),
|
||||||
|
active: boolean("active").default(false),
|
||||||
|
category: text("category"),
|
||||||
|
icon: text("icon"),
|
||||||
|
link: text("link"),
|
||||||
|
//roles: text("roles").notNull().default(`["view", "systemAdmin"]`), // ["view", "technician", "supervisor","manager", "admin","systemAdmin"]
|
||||||
|
roles: jsonb("roles").notNull().default(["view", "systemAdmin"]), // ["view", "technician", "supervisor","manager", "admin","systemAdmin"]
|
||||||
|
add_User: text("add_User").default("LST_System").notNull(),
|
||||||
|
add_Date: timestamp("add_Date").defaultNow(),
|
||||||
|
upd_user: text("upd_User").default("LST_System").notNull(),
|
||||||
|
upd_date: timestamp("upd_date").defaultNow(),
|
||||||
|
},
|
||||||
|
(table) => [
|
||||||
|
// uniqueIndex('emailUniqueIndex').on(sql`lower(${table.email})`),
|
||||||
|
uniqueIndex("module_name").on(table.name),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
// Schema for inserting a user - can be used to validate API requests
|
||||||
|
// export const insertModuleSchema = createInsertSchema(modules, {
|
||||||
|
// name: z.string().min(3, {message: "Module name should be longer than 3 letters"}),
|
||||||
|
// });
|
||||||
|
// Schema for selecting a Expenses - can be used to validate API responses
|
||||||
|
export const selectModuleSchema = createSelectSchema(modules);
|
||||||
|
|
||||||
|
export type Modules = typeof modules;
|
||||||
@@ -2,7 +2,6 @@ import { useRouter } from "@tanstack/react-router";
|
|||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { useModuleStore } from "../../routes/_old/old/-lib/store/useModuleStore";
|
import { useModuleStore } from "../../routes/_old/old/-lib/store/useModuleStore";
|
||||||
import { useSettingStore } from "../../routes/_old/old/-lib/store/useSettings";
|
import { useSettingStore } from "../../routes/_old/old/-lib/store/useSettings";
|
||||||
import { useSubModuleStore } from "../../routes/_old/old/-lib/store/useSubModuleStore";
|
|
||||||
import { useSession, useUserRoles } from "../authClient";
|
import { useSession, useUserRoles } from "../authClient";
|
||||||
|
|
||||||
export function SessionGuard({ children }: { children: React.ReactNode }) {
|
export function SessionGuard({ children }: { children: React.ReactNode }) {
|
||||||
@@ -10,7 +9,6 @@ export function SessionGuard({ children }: { children: React.ReactNode }) {
|
|||||||
const { fetchRoles } = useUserRoles();
|
const { fetchRoles } = useUserRoles();
|
||||||
const { fetchModules } = useModuleStore();
|
const { fetchModules } = useModuleStore();
|
||||||
const { fetchSettings } = useSettingStore();
|
const { fetchSettings } = useSettingStore();
|
||||||
const { fetchSubModules } = useSubModuleStore();
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -19,7 +17,6 @@ export function SessionGuard({ children }: { children: React.ReactNode }) {
|
|||||||
// }
|
// }
|
||||||
fetchModules();
|
fetchModules();
|
||||||
fetchSettings();
|
fetchSettings();
|
||||||
fetchSubModules();
|
|
||||||
//if (session) {
|
//if (session) {
|
||||||
fetchRoles();
|
fetchRoles();
|
||||||
//}
|
//}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export default function LoginForm({ redirectPath }: { redirectPath: string }) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await axios.post("/lst/api/user/login", {
|
await axios.post("/lst/api/user/login", {
|
||||||
username: value.username,
|
username: value.username.toLowerCase(),
|
||||||
password: value.password,
|
password: value.password,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Link } from "@tanstack/react-router";
|
import { Link, useNavigate } from "@tanstack/react-router";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import {
|
import {
|
||||||
CardContent,
|
CardContent,
|
||||||
@@ -11,6 +11,7 @@ import { useAppForm } from "@/lib/formStuff";
|
|||||||
import { LstCard } from "@/routes/_old/old/-components/extendedUi/LstCard";
|
import { LstCard } from "@/routes/_old/old/-components/extendedUi/LstCard";
|
||||||
|
|
||||||
export default function SignupForm() {
|
export default function SignupForm() {
|
||||||
|
const navigate = useNavigate();
|
||||||
const form = useAppForm({
|
const form = useAppForm({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
username: "",
|
username: "",
|
||||||
@@ -31,7 +32,13 @@ export default function SignupForm() {
|
|||||||
password: value.password,
|
password: value.password,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res.status === 200) {
|
if (!res.data.success) {
|
||||||
|
toast.error(res.data.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res.data.success) {
|
||||||
|
form.reset();
|
||||||
|
navigate({ to: "/" });
|
||||||
toast.success(`Welcome ${value.username}, to lst.`);
|
toast.success(`Welcome ${value.username}, to lst.`);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
userAccess,
|
userAccess,
|
||||||
useUserRoles,
|
useUserRoles,
|
||||||
} from "../../../../../lib/authClient";
|
} from "../../../../../lib/authClient";
|
||||||
import { useModuleStore } from "../../-lib/store/useModuleStore";
|
|
||||||
import { AdminSideBar } from "./side-components/admin";
|
import { AdminSideBar } from "./side-components/admin";
|
||||||
import { EomSideBar } from "./side-components/eom";
|
import { EomSideBar } from "./side-components/eom";
|
||||||
import { ForkliftSideBar } from "./side-components/forklift";
|
import { ForkliftSideBar } from "./side-components/forklift";
|
||||||
@@ -24,20 +24,13 @@ import { QualitySideBar } from "./side-components/quality";
|
|||||||
export function AppSidebar() {
|
export function AppSidebar() {
|
||||||
const { session } = useAuth();
|
const { session } = useAuth();
|
||||||
const { userRoles } = useUserRoles();
|
const { userRoles } = useUserRoles();
|
||||||
const { modules } = useModuleStore();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Sidebar collapsible="icon">
|
<Sidebar collapsible="icon">
|
||||||
<SidebarContent>
|
<SidebarContent>
|
||||||
<Header />
|
<Header />
|
||||||
|
|
||||||
<ProductionSideBar
|
<ProductionSideBar user={session?.user as any} userRoles={userRoles} />
|
||||||
user={session?.user as any}
|
|
||||||
moduleID={
|
|
||||||
modules.filter((n) => n.name === "production")[0]
|
|
||||||
?.module_id as string
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* userAccess("logistics", ["systemAdmin", "admin","manager","viewer"]) */}
|
{/* userAccess("logistics", ["systemAdmin", "admin","manager","viewer"]) */}
|
||||||
<LogisticsSideBar user={session?.user as any} userRoles={userRoles} />
|
<LogisticsSideBar user={session?.user as any} userRoles={userRoles} />
|
||||||
|
|||||||
@@ -1,4 +1,13 @@
|
|||||||
import { Barcode, Command, Cylinder, Package, Truck } from "lucide-react";
|
import {
|
||||||
|
Barcode,
|
||||||
|
Cat,
|
||||||
|
Command,
|
||||||
|
Cylinder,
|
||||||
|
Database,
|
||||||
|
Package,
|
||||||
|
Truck,
|
||||||
|
} from "lucide-react";
|
||||||
|
|
||||||
import type { UserRoles } from "@/lib/authClient";
|
import type { UserRoles } from "@/lib/authClient";
|
||||||
import {
|
import {
|
||||||
SidebarGroup,
|
SidebarGroup,
|
||||||
@@ -8,7 +17,7 @@ import {
|
|||||||
SidebarMenuButton,
|
SidebarMenuButton,
|
||||||
SidebarMenuItem,
|
SidebarMenuItem,
|
||||||
} from "../../../../../../components/ui/sidebar";
|
} from "../../../../../../components/ui/sidebar";
|
||||||
import { useSubModuleStore } from "../../../-lib/store/useSubModuleStore";
|
import { useModuleStore } from "../../../-lib/store/useModuleStore";
|
||||||
import type { User } from "../../../-types/users";
|
import type { User } from "../../../-types/users";
|
||||||
import { hasPageAccess } from "../../../-utils/userAccess";
|
import { hasPageAccess } from "../../../-utils/userAccess";
|
||||||
|
|
||||||
@@ -18,6 +27,8 @@ const iconMap: any = {
|
|||||||
Cylinder: Cylinder,
|
Cylinder: Cylinder,
|
||||||
Barcode: Barcode,
|
Barcode: Barcode,
|
||||||
Command: Command,
|
Command: Command,
|
||||||
|
Cat: Cat,
|
||||||
|
Database: Database,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function LogisticsSideBar({
|
export function LogisticsSideBar({
|
||||||
@@ -27,9 +38,9 @@ export function LogisticsSideBar({
|
|||||||
user: User | null;
|
user: User | null;
|
||||||
userRoles: UserRoles[] | null;
|
userRoles: UserRoles[] | null;
|
||||||
}) {
|
}) {
|
||||||
const { subModules } = useSubModuleStore();
|
const { modules } = useModuleStore();
|
||||||
|
|
||||||
const items = subModules?.filter((m) => m.moduleName === "logistics");
|
const items = modules?.filter((m) => m.category === "logistics");
|
||||||
const userUpdate = { ...user, roles: userRoles };
|
const userUpdate = { ...user, roles: userRoles };
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -38,9 +49,10 @@ export function LogisticsSideBar({
|
|||||||
<SidebarGroupContent>
|
<SidebarGroupContent>
|
||||||
<SidebarMenu>
|
<SidebarMenu>
|
||||||
{items.map((item) => {
|
{items.map((item) => {
|
||||||
const Icon = iconMap[item.icon];
|
const Icon = iconMap[item.icon === "" ? "Cat" : item.icon];
|
||||||
|
if (!item.active) return;
|
||||||
return (
|
return (
|
||||||
<SidebarMenuItem key={item.submodule_id}>
|
<SidebarMenuItem key={item.module_id}>
|
||||||
{hasPageAccess(userUpdate as any, item.roles, item.name) && (
|
{hasPageAccess(userUpdate as any, item.roles, item.name) && (
|
||||||
<>
|
<>
|
||||||
<SidebarMenuButton asChild>
|
<SidebarMenuButton asChild>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Printer, Tag } from "lucide-react";
|
import { Cat, Printer, Tag } from "lucide-react";
|
||||||
|
import type { UserRoles } from "@/lib/authClient";
|
||||||
import {
|
import {
|
||||||
SidebarGroup,
|
SidebarGroup,
|
||||||
SidebarGroupContent,
|
SidebarGroupContent,
|
||||||
@@ -7,54 +8,53 @@ import {
|
|||||||
SidebarMenuButton,
|
SidebarMenuButton,
|
||||||
SidebarMenuItem,
|
SidebarMenuItem,
|
||||||
} from "../../../../../../components/ui/sidebar";
|
} from "../../../../../../components/ui/sidebar";
|
||||||
|
import { useModuleStore } from "../../../-lib/store/useModuleStore";
|
||||||
import type { User } from "../../../-types/users";
|
import type { User } from "../../../-types/users";
|
||||||
import { hasPageAccess } from "../../../-utils/userAccess";
|
import { hasPageAccess } from "../../../-utils/userAccess";
|
||||||
|
|
||||||
|
const iconMap: any = {
|
||||||
|
Printer: Printer,
|
||||||
|
Tag: Tag,
|
||||||
|
|
||||||
|
Cat: Cat,
|
||||||
|
};
|
||||||
|
|
||||||
export function ProductionSideBar({
|
export function ProductionSideBar({
|
||||||
user,
|
user,
|
||||||
moduleID,
|
userRoles,
|
||||||
}: {
|
}: {
|
||||||
user: User | null;
|
user: User | null;
|
||||||
moduleID: string;
|
userRoles: UserRoles[] | null;
|
||||||
}) {
|
}) {
|
||||||
const url: string = window.location.host.split(":")[0];
|
//const url: string = window.location.host.split(":")[0];
|
||||||
const items = [
|
const { modules } = useModuleStore();
|
||||||
{
|
|
||||||
title: "One Click Print",
|
const items = modules?.filter((m) => m.category === "production");
|
||||||
url: "/lst/app/old/ocp",
|
const userUpdate = { ...user, roles: userRoles };
|
||||||
icon: Printer,
|
|
||||||
role: ["viewer"],
|
|
||||||
module: "ocp",
|
|
||||||
active: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "Rfid Readers",
|
|
||||||
url: "/lst/app/old/rfid",
|
|
||||||
icon: Tag,
|
|
||||||
role: ["viewer"],
|
|
||||||
module: "production",
|
|
||||||
active: url === "usday1vms006" || url === "localhost" ? true : false,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
return (
|
return (
|
||||||
<SidebarGroup>
|
<SidebarGroup>
|
||||||
<SidebarGroupLabel>Production</SidebarGroupLabel>
|
<SidebarGroupLabel>Production</SidebarGroupLabel>
|
||||||
<SidebarGroupContent>
|
<SidebarGroupContent>
|
||||||
<SidebarMenu>
|
<SidebarMenu>
|
||||||
{items.map((item) => (
|
{items.map((item) => {
|
||||||
<SidebarMenuItem key={item.title}>
|
if (!item.active) return;
|
||||||
<>
|
const Icon = iconMap[item.icon === "" ? "Cat" : item.icon];
|
||||||
{hasPageAccess(user, item.role, moduleID) && item.active && (
|
return (
|
||||||
<SidebarMenuButton asChild>
|
<SidebarMenuItem key={item.module_id}>
|
||||||
<a href={item.url}>
|
<>
|
||||||
<item.icon />
|
{hasPageAccess(userUpdate as any, item.roles, item.name) && (
|
||||||
<span>{item.title}</span>
|
<SidebarMenuButton asChild>
|
||||||
</a>
|
<a href={item.link}>
|
||||||
</SidebarMenuButton>
|
<Icon />
|
||||||
)}
|
<span>{item.name}</span>
|
||||||
</>
|
</a>
|
||||||
</SidebarMenuItem>
|
</SidebarMenuButton>
|
||||||
))}
|
)}
|
||||||
|
</>
|
||||||
|
</SidebarMenuItem>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</SidebarMenu>
|
</SidebarMenu>
|
||||||
</SidebarGroupContent>
|
</SidebarGroupContent>
|
||||||
</SidebarGroup>
|
</SidebarGroup>
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ export default function Lots() {
|
|||||||
"technician",
|
"technician",
|
||||||
"admin",
|
"admin",
|
||||||
"manager",
|
"manager",
|
||||||
|
"supervisor",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (session?.user && accessRoles) {
|
if (session?.user && accessRoles) {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export const useModuleStore = create<SettingState>()((set) => ({
|
|||||||
fetchModules: async () => {
|
fetchModules: async () => {
|
||||||
try {
|
try {
|
||||||
//const response = await axios.get<{data: Setting[]}>(`${process.env.NEXT_PUBLIC_URL}/api/settings/client`);
|
//const response = await axios.get<{data: Setting[]}>(`${process.env.NEXT_PUBLIC_URL}/api/settings/client`);
|
||||||
const response = await axios.get(`/lst/old/api/server/modules`, {});
|
const response = await axios.get(`/lst/api/system/modules`, {});
|
||||||
const data: FetchModulesResponse = response.data; //await response.json();
|
const data: FetchModulesResponse = response.data; //await response.json();
|
||||||
//console.log(data);
|
//console.log(data);
|
||||||
set({ modules: data.data });
|
set({ modules: data.data });
|
||||||
|
|||||||
@@ -1,20 +1,23 @@
|
|||||||
export interface Modules {
|
export interface Modules {
|
||||||
module_id: string;
|
module_id: string;
|
||||||
name: string;
|
icon: string;
|
||||||
active: boolean;
|
name: string;
|
||||||
roles: string;
|
link: string;
|
||||||
add_user: string;
|
active: boolean;
|
||||||
add_date: Date;
|
roles: string;
|
||||||
upd_user: string;
|
category: string;
|
||||||
upd_date: Date;
|
add_user: string;
|
||||||
|
add_date: Date;
|
||||||
|
upd_user: string;
|
||||||
|
upd_date: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SubModules {
|
export interface SubModules {
|
||||||
submodule_id: string;
|
submodule_id: string;
|
||||||
name: string;
|
name: string;
|
||||||
link: string;
|
link: string;
|
||||||
icon: string;
|
icon: string;
|
||||||
moduleName: string;
|
moduleName: string;
|
||||||
active: boolean;
|
active: boolean;
|
||||||
roles: string[];
|
roles: string[];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,4 +68,6 @@ select IdMaschinen_ProdPlanung as LabelOnlineID,
|
|||||||
|
|
||||||
|
|
||||||
where IsTechnicallyReleased = 1 and DruckStatus = 1
|
where IsTechnicallyReleased = 1 and DruckStatus = 1
|
||||||
|
|
||||||
|
order by MaschinenStandort
|
||||||
`;
|
`;
|
||||||
|
|||||||
23
migrations/0021_motionless_ezekiel.sql
Normal file
23
migrations/0021_motionless_ezekiel.sql
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
CREATE TABLE "forecast_Data" (
|
||||||
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||||
|
"customer_article_number" text,
|
||||||
|
"date_requested" timestamp DEFAULT now(),
|
||||||
|
"quantity" real,
|
||||||
|
"request_date" timestamp NOT NULL,
|
||||||
|
"article" integer,
|
||||||
|
"customer_id" integer NOT NULL,
|
||||||
|
"created_at" timestamp DEFAULT now()
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE TABLE "modules" (
|
||||||
|
"module_id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||||
|
"name" text NOT NULL,
|
||||||
|
"active" boolean DEFAULT false,
|
||||||
|
"roles" jsonb DEFAULT '["view","systemAdmin"]'::jsonb NOT NULL,
|
||||||
|
"add_User" text DEFAULT 'LST_System' NOT NULL,
|
||||||
|
"add_Date" timestamp DEFAULT now(),
|
||||||
|
"upd_User" text DEFAULT 'LST_System' NOT NULL,
|
||||||
|
"upd_date" timestamp DEFAULT now()
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE UNIQUE INDEX "module_name" ON "modules" USING btree ("name");
|
||||||
1
migrations/0022_old_next_avengers.sql
Normal file
1
migrations/0022_old_next_avengers.sql
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE "modules" ADD COLUMN "category" text;
|
||||||
2
migrations/0023_minor_marvel_zombies.sql
Normal file
2
migrations/0023_minor_marvel_zombies.sql
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE "modules" ADD COLUMN "icon" text;--> statement-breakpoint
|
||||||
|
ALTER TABLE "modules" ADD COLUMN "link" text;
|
||||||
1721
migrations/meta/0021_snapshot.json
Normal file
1721
migrations/meta/0021_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
1727
migrations/meta/0022_snapshot.json
Normal file
1727
migrations/meta/0022_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
1739
migrations/meta/0023_snapshot.json
Normal file
1739
migrations/meta/0023_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -148,6 +148,27 @@
|
|||||||
"when": 1760703799708,
|
"when": 1760703799708,
|
||||||
"tag": "0020_conscious_hairball",
|
"tag": "0020_conscious_hairball",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 21,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1761776315202,
|
||||||
|
"tag": "0021_motionless_ezekiel",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 22,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1761780723108,
|
||||||
|
"tag": "0022_old_next_avengers",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 23,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1761781568161,
|
||||||
|
"tag": "0023_minor_marvel_zombies",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,13 @@ const dest_settings = path.resolve(
|
|||||||
"dist/src/internal/system/controller/settings/settings.json",
|
"dist/src/internal/system/controller/settings/settings.json",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const src_modules = path.resolve(
|
||||||
|
"app/src/internal/system/controller/modules/modules.json",
|
||||||
|
);
|
||||||
|
const dest_modules = path.resolve(
|
||||||
|
"dist/src/internal/system/controller/modules/modules.json",
|
||||||
|
);
|
||||||
|
|
||||||
// Delete old views if they exist
|
// Delete old views if they exist
|
||||||
if (fs.existsSync(dest_views)) {
|
if (fs.existsSync(dest_views)) {
|
||||||
fs.rmSync(dest_views, { recursive: true, force: true });
|
fs.rmSync(dest_views, { recursive: true, force: true });
|
||||||
@@ -21,14 +28,24 @@ if (fs.existsSync(dest_settings)) {
|
|||||||
fs.rmSync(dest_settings, { force: true }); // for single files we dont need the recursive
|
fs.rmSync(dest_settings, { force: true }); // for single files we dont need the recursive
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fs.existsSync(dest_modules)) {
|
||||||
|
fs.rmSync(dest_modules, { force: true }); // for single files we dont need the recursive
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure the destination directory exists for settings.json
|
// Ensure the destination directory exists for settings.json
|
||||||
const dest_settings_dir = path.dirname(dest_settings);
|
const dest_settings_dir = path.dirname(dest_settings);
|
||||||
if (!fs.existsSync(dest_settings_dir)) {
|
if (!fs.existsSync(dest_settings_dir)) {
|
||||||
fs.mkdirSync(dest_settings_dir, { recursive: true });
|
fs.mkdirSync(dest_settings_dir, { recursive: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const dest_modules_dir = path.dirname(dest_modules);
|
||||||
|
if (!fs.existsSync(dest_modules_dir)) {
|
||||||
|
fs.mkdirSync(dest_modules_dir, { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
// Copy files
|
// Copy files
|
||||||
fs.copyFileSync(src_settings, dest_settings);
|
fs.copyFileSync(src_settings, dest_settings);
|
||||||
|
fs.copyFileSync(src_modules, dest_modules);
|
||||||
fs.cpSync(src_views, dest_views, { recursive: true });
|
fs.cpSync(src_views, dest_views, { recursive: true });
|
||||||
|
|
||||||
console.log(`All files copied`);
|
console.log(`All files copied`);
|
||||||
|
|||||||
Reference in New Issue
Block a user