refactor(modules): moved modules to app to control everything based on there active setting

This commit is contained in:
2025-10-29 21:57:11 -05:00
parent 6493e0398a
commit 99b2d762d6
35 changed files with 5807 additions and 121 deletions

View File

@@ -8,6 +8,7 @@
"source.organizeImports.biome": "explicit"
},
"cSpell.words": [
"acitve",
"alpla",
"alplamart",
"alplaprod",

View File

@@ -4,16 +4,12 @@ meta {
seq: 7
}
patch {
url: {{url}}/lst/api/admin/users/:userID/grant
get {
url: {{url}}/lst/api/user/roles
body: json
auth: inherit
}
params:path {
userID: 0hlO48C7Jw1J804FxrCnonKjQ2zh48R6
}
body:json {
{
"module":"siloAdjustments",

View File

@@ -12,8 +12,8 @@ post {
body:json {
{
"username": "cowch",
"password": "Alpla2025!"
"username": "matthes01",
"password": "nova0511"
}
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -0,0 +1,8 @@
meta {
name: modules
seq: 3
}
auth {
mode: inherit
}

View File

@@ -1,5 +1,5 @@
vars {
url: http://localhost:4200
url: https://usmcd1vms036.alpla.net
session_cookie:
urlv2: http://localhost:3000
jwtV2:

View File

@@ -13,6 +13,7 @@ import { userMigrate } from "./src/internal/auth/controller/userMigrate.js";
import { schedulerManager } from "./src/internal/logistics/controller/schedulerManager.js";
import { printers } from "./src/internal/ocp/printers/printers.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 { auth } from "./src/pkg/auth/auth.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
setTimeout(() => {
baseSettings();
baseModules();
printers();
schedulerManager();

View File

@@ -1,9 +1,9 @@
import { Router } from "express";
import { requireAuth } from "../../../../pkg/middleware/authMiddleware.js";
import { restrictToHosts } from "../../../../pkg/middleware/restrictToHosts.js";
import addServer from "./addServer.js";
import getServers from "./getServers.js";
import updateServer from "./updateServer.js";
import { restrictToHosts } from "../../../../pkg/middleware/restrictToHosts.js";
import { requireAuth } from "../../../../pkg/middleware/authMiddleware.js";
const router = Router();
@@ -12,21 +12,23 @@ router.use(
"/",
requireAuth("user", ["systemAdmin", "admin"]),
restrictToHosts([
"localhost:5500",
"usmcd1vms036.alpla.net",
"USMCD1VMS036.alpla.net",
"https://usmcd1vms036.alpla.net",
]),
addServer
addServer,
);
router.use(
"/",
requireAuth("user", ["systemAdmin", "admin"]),
restrictToHosts([
"localhost:5500",
"usmcd1vms036.alpla.net",
"USMCD1VMS036.alpla.net",
"https://usmcd1vms036.alpla.net",
]),
updateServer
updateServer,
);
export default router;

View File

@@ -42,8 +42,12 @@ router.post("/", async (req: Request, res: Response) => {
.update(user)
.set({ lastLogin: sql`NOW()` })
.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) {
console.log(err);
if (err instanceof z.ZodError) {
const flattened = z.flattenError(err);
return res.status(400).json({
@@ -59,6 +63,12 @@ router.post("/", async (req: Request, res: Response) => {
error: err.status,
});
}
return res.status(200).json({
success: false,
message: "There was an error creating your user.",
error: err,
});
}
});

View File

@@ -1,10 +1,46 @@
import { sql } from "drizzle-orm";
import { readFileSync } from "fs";
import path from "path";
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 __dirname = path.dirname(__filename);
export const baseModules = async () => {
const log = createLogger({ module: "system", subModule: "base modules" });
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");
}
}
};

View File

@@ -1,30 +1,122 @@
[
{
"name": "plantToken",
"value": "test3",
"description": "The plant token for the plant IE: test3 or usday1",
"moduleName": "system",
"roles": ["systemAdmin"]
"name": "users",
"category": "admin",
"icon": "User",
"link": "/lst/app/admin/users",
"active": true,
"roles": ["systemAdmin", "admin"]
},
{
"name": "dbServer",
"value": "usmcd1vms036",
"description": "What is the db server",
"moduleName": "system",
"roles": ["systemAdmin"]
"name": "system",
"category": "admin",
"icon": "MonitorCog",
"link": "/lst/app/system",
"active": true,
"roles": ["systemAdmin", "admin"]
},
{
"name": "v1Server",
"value": "localhost",
"description": "What is the port the v1app is on",
"moduleName": "system",
"roles": ["systemAdmin"]
"name": "ocp",
"category": "production",
"icon": "Printer",
"link": "/lst/app/old/ocp",
"active": true,
"roles": ["viewer", "manager", "tester", "systemAdmin", "admin"]
},
{
"name": "v1Port",
"value": "3000",
"description": "What is the port the v1app is on",
"moduleName": "system",
"roles": ["systemAdmin"]
"name": "rfidReaders",
"category": "production",
"icon": "Tags",
"link": "/lst/app/old/rfid",
"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"]
}
]

View File

@@ -1,4 +1,5 @@
import type { Express, Request, Response } from "express";
import modules from "./routes/modules/moduleRoutes.js";
import settings from "./routes/settings/settingRoutes.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
settings,
);
app.use(
basePath + "/api/system/modules", // will pass bc system admin but this is just telling us we need this
modules,
);
};

View 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;

View 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;

View 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;

View 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;

View File

@@ -2,7 +2,6 @@ import { useRouter } from "@tanstack/react-router";
import { useEffect } from "react";
import { useModuleStore } from "../../routes/_old/old/-lib/store/useModuleStore";
import { useSettingStore } from "../../routes/_old/old/-lib/store/useSettings";
import { useSubModuleStore } from "../../routes/_old/old/-lib/store/useSubModuleStore";
import { useSession, useUserRoles } from "../authClient";
export function SessionGuard({ children }: { children: React.ReactNode }) {
@@ -10,7 +9,6 @@ export function SessionGuard({ children }: { children: React.ReactNode }) {
const { fetchRoles } = useUserRoles();
const { fetchModules } = useModuleStore();
const { fetchSettings } = useSettingStore();
const { fetchSubModules } = useSubModuleStore();
const router = useRouter();
useEffect(() => {
@@ -19,7 +17,6 @@ export function SessionGuard({ children }: { children: React.ReactNode }) {
// }
fetchModules();
fetchSettings();
fetchSubModules();
//if (session) {
fetchRoles();
//}

View File

@@ -36,7 +36,7 @@ export default function LoginForm({ redirectPath }: { redirectPath: string }) {
try {
await axios.post("/lst/api/user/login", {
username: value.username,
username: value.username.toLowerCase(),
password: value.password,
});

View File

@@ -1,4 +1,4 @@
import { Link } from "@tanstack/react-router";
import { Link, useNavigate } from "@tanstack/react-router";
import { toast } from "sonner";
import {
CardContent,
@@ -11,6 +11,7 @@ import { useAppForm } from "@/lib/formStuff";
import { LstCard } from "@/routes/_old/old/-components/extendedUi/LstCard";
export default function SignupForm() {
const navigate = useNavigate();
const form = useAppForm({
defaultValues: {
username: "",
@@ -31,7 +32,13 @@ export default function SignupForm() {
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.`);
}
} catch (error) {

View File

@@ -12,7 +12,7 @@ import {
userAccess,
useUserRoles,
} from "../../../../../lib/authClient";
import { useModuleStore } from "../../-lib/store/useModuleStore";
import { AdminSideBar } from "./side-components/admin";
import { EomSideBar } from "./side-components/eom";
import { ForkliftSideBar } from "./side-components/forklift";
@@ -24,20 +24,13 @@ import { QualitySideBar } from "./side-components/quality";
export function AppSidebar() {
const { session } = useAuth();
const { userRoles } = useUserRoles();
const { modules } = useModuleStore();
return (
<Sidebar collapsible="icon">
<SidebarContent>
<Header />
<ProductionSideBar
user={session?.user as any}
moduleID={
modules.filter((n) => n.name === "production")[0]
?.module_id as string
}
/>
<ProductionSideBar user={session?.user as any} userRoles={userRoles} />
{/* userAccess("logistics", ["systemAdmin", "admin","manager","viewer"]) */}
<LogisticsSideBar user={session?.user as any} userRoles={userRoles} />

View File

@@ -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 {
SidebarGroup,
@@ -8,7 +17,7 @@ import {
SidebarMenuButton,
SidebarMenuItem,
} from "../../../../../../components/ui/sidebar";
import { useSubModuleStore } from "../../../-lib/store/useSubModuleStore";
import { useModuleStore } from "../../../-lib/store/useModuleStore";
import type { User } from "../../../-types/users";
import { hasPageAccess } from "../../../-utils/userAccess";
@@ -18,6 +27,8 @@ const iconMap: any = {
Cylinder: Cylinder,
Barcode: Barcode,
Command: Command,
Cat: Cat,
Database: Database,
};
export function LogisticsSideBar({
@@ -27,9 +38,9 @@ export function LogisticsSideBar({
user: User | 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 };
return (
@@ -38,9 +49,10 @@ export function LogisticsSideBar({
<SidebarGroupContent>
<SidebarMenu>
{items.map((item) => {
const Icon = iconMap[item.icon];
const Icon = iconMap[item.icon === "" ? "Cat" : item.icon];
if (!item.active) return;
return (
<SidebarMenuItem key={item.submodule_id}>
<SidebarMenuItem key={item.module_id}>
{hasPageAccess(userUpdate as any, item.roles, item.name) && (
<>
<SidebarMenuButton asChild>

View File

@@ -1,4 +1,5 @@
import { Printer, Tag } from "lucide-react";
import { Cat, Printer, Tag } from "lucide-react";
import type { UserRoles } from "@/lib/authClient";
import {
SidebarGroup,
SidebarGroupContent,
@@ -7,54 +8,53 @@ import {
SidebarMenuButton,
SidebarMenuItem,
} from "../../../../../../components/ui/sidebar";
import { useModuleStore } from "../../../-lib/store/useModuleStore";
import type { User } from "../../../-types/users";
import { hasPageAccess } from "../../../-utils/userAccess";
const iconMap: any = {
Printer: Printer,
Tag: Tag,
Cat: Cat,
};
export function ProductionSideBar({
user,
moduleID,
userRoles,
}: {
user: User | null;
moduleID: string;
userRoles: UserRoles[] | null;
}) {
const url: string = window.location.host.split(":")[0];
const items = [
{
title: "One Click Print",
url: "/lst/app/old/ocp",
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,
},
];
//const url: string = window.location.host.split(":")[0];
const { modules } = useModuleStore();
const items = modules?.filter((m) => m.category === "production");
const userUpdate = { ...user, roles: userRoles };
return (
<SidebarGroup>
<SidebarGroupLabel>Production</SidebarGroupLabel>
<SidebarGroupContent>
<SidebarMenu>
{items.map((item) => (
<SidebarMenuItem key={item.title}>
{items.map((item) => {
if (!item.active) return;
const Icon = iconMap[item.icon === "" ? "Cat" : item.icon];
return (
<SidebarMenuItem key={item.module_id}>
<>
{hasPageAccess(user, item.role, moduleID) && item.active && (
{hasPageAccess(userUpdate as any, item.roles, item.name) && (
<SidebarMenuButton asChild>
<a href={item.url}>
<item.icon />
<span>{item.title}</span>
<a href={item.link}>
<Icon />
<span>{item.name}</span>
</a>
</SidebarMenuButton>
)}
</>
</SidebarMenuItem>
))}
);
})}
</SidebarMenu>
</SidebarGroupContent>
</SidebarGroup>

View File

@@ -77,6 +77,7 @@ export default function Lots() {
"technician",
"admin",
"manager",
"supervisor",
]);
if (session?.user && accessRoles) {

View File

@@ -18,7 +18,7 @@ export const useModuleStore = create<SettingState>()((set) => ({
fetchModules: async () => {
try {
//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();
//console.log(data);
set({ modules: data.data });

View File

@@ -1,8 +1,11 @@
export interface Modules {
module_id: string;
icon: string;
name: string;
link: string;
active: boolean;
roles: string;
category: string;
add_user: string;
add_date: Date;
upd_user: string;

View File

@@ -68,4 +68,6 @@ select IdMaschinen_ProdPlanung as LabelOnlineID,
where IsTechnicallyReleased = 1 and DruckStatus = 1
order by MaschinenStandort
`;

View 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");

View File

@@ -0,0 +1 @@
ALTER TABLE "modules" ADD COLUMN "category" text;

View File

@@ -0,0 +1,2 @@
ALTER TABLE "modules" ADD COLUMN "icon" text;--> statement-breakpoint
ALTER TABLE "modules" ADD COLUMN "link" text;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -148,6 +148,27 @@
"when": 1760703799708,
"tag": "0020_conscious_hairball",
"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
}
]
}

View File

@@ -11,6 +11,13 @@ const dest_settings = path.resolve(
"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
if (fs.existsSync(dest_views)) {
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
}
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
const dest_settings_dir = path.dirname(dest_settings);
if (!fs.existsSync(dest_settings_dir)) {
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
fs.copyFileSync(src_settings, dest_settings);
fs.copyFileSync(src_modules, dest_modules);
fs.cpSync(src_views, dest_views, { recursive: true });
console.log(`All files copied`);