Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions apps/backend/handlers/onChange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const onChange = async (serverId: string) => {
await new Promise<void>((resolve, reject) => {
pm2.restart(change.fullDocument.pm_id, (err) => {
if (err) {
reject(err);
return reject(err);
}
resolve();
});
Expand All @@ -72,15 +72,15 @@ const onChange = async (serverId: string) => {
if (_status === "online") {
pm2.stop(process.pm_id, (err) => {
if (err) {
reject(err);
return reject(err);
}
resolve();
_status = "stopped";
});
} else {
pm2.restart(process.pm_id, (err) => {
if (err) {
reject(err);
return reject(err);
}
resolve();
_status = "online";
Expand All @@ -100,17 +100,19 @@ const onChange = async (serverId: string) => {
},
);
}
if (change.updateDescription?.updatedFields?.deleteCount) {
console.log(`[STREAM] Process ${change.fullDocument.name} deleted`);
await new Promise<void>((resolve, reject) => {
pm2.delete(change.fullDocument.pm_id, (err) => {
if (err) {
reject(err);
}
resolve();
});
});
if (!change.updateDescription?.updatedFields?.deleteCount) {
return;
}

console.log(`[STREAM] Process ${change.fullDocument.name} deleted`);
await new Promise<void>((resolve, reject) => {
pm2.delete(change.fullDocument.pm_id, (err) => {
if (err) {
return reject(err);
}
resolve();
});
});
});
};
export default onChange;
8 changes: 5 additions & 3 deletions apps/backend/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ async function createInterval() {
await updateData(logCapture.clear(), await getCachedSettings());
const settings = await getCachedSettings();
// if polling changed clear interval and create new one
if (settings.polling.backend !== polling.backend) {
clearInterval(interval);
await createInterval();
if (settings.polling.backend === polling.backend) {
return;
}

clearInterval(interval);
await createInterval();
}, polling.backend);
}

Expand Down
8 changes: 4 additions & 4 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@
"bcrypt": "^6.0.0",
"bytes-iec": "^3.1.1",
"dotenv": "^17.4.2",
"mongoose": "^9.7.1",
"pm2": "^7.0.1",
"systeminformation": "^5.31.7"
"mongoose": "^9.10.1",
"pm2": "^7.0.4",
"systeminformation": "^5.33.11"
},
"devDependencies": {
"@pm2.web/eslint-config": "workspace:*",
"@pm2.web/typescript-config": "workspace:*",
"@types/bcrypt": "^6.0.0",
"dotenv-cli": "^11.0.0",
"eslint": "^10.5.0",
"eslint": "^10.10.0",
"typescript": "^6.0.3"
}
}
2 changes: 2 additions & 0 deletions apps/dashboard/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
playwright-report/
test-results/
5 changes: 3 additions & 2 deletions apps/dashboard/components/context/SelectedProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ export function SelectedProvider({ children, servers }: { children: React.ReactN
if (!user || !user.acl) return false;
if (!user?.acl?.owner && !user?.acl?.admin) {
const serverAccess = new Access(user.acl?.servers ?? []);
if (permission) return serverAccess.getPerms(serverId, processId).has(PERMISSIONS[permission]);
return !!serverAccess.getPermsValue(serverId, processId);
return permission
? serverAccess.getPerms(serverId, processId).has(PERMISSIONS[permission])
: !!serverAccess.getPermsValue(serverId, processId);
}
return true;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* eslint-disable unicorn/prefer-negative-index */

/* Source: https://github.com/mantinedev/mantine/blob/master/packages/%40mantine/core/src/components/MultiSelect/MultiSelect.tsx */
/*
Source: https://github.com/mantinedev/mantine/blob/master/packages/%40mantine/core/src/components/MultiSelect/MultiSelect.tsx
*/

import {
Combobox,
Expand Down
7 changes: 3 additions & 4 deletions apps/dashboard/components/partials/Head.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ export function Head({ mobileOpened, toggleMobile }: { mobileOpened?: boolean; t
const hasAccess = (server_id: string, process_id: string) => {
const user = session?.user;
if (!user || !user.acl) return false;
if (!user?.acl?.owner && !user?.acl?.admin) {
return !!new Access(user.acl?.servers ?? []).getPermsValue(server_id, process_id);
}
return true;
return !user?.acl?.owner && !user?.acl?.admin
? !!new Access(user.acl?.servers ?? []).getPermsValue(server_id, process_id)
: true;
};

const MultiSelectItems = (
Expand Down
16 changes: 7 additions & 9 deletions apps/dashboard/components/partials/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,13 @@ function NavbarLink({ icon: Icon, label, active, href, onClick }: NavbarLinkProp
</Tooltip>
);

if (href) {
return (
<Link href={href} style={{ textDecoration: "none" }}>
{content}
</Link>
);
}

return content;
return href ? (
<Link href={href} style={{ textDecoration: "none" }}>
{content}
</Link>
) : (
content
);
}

const navLinks = [
Expand Down
6 changes: 6 additions & 0 deletions apps/dashboard/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ export default tsEslint.config(
"unicorn/prefer-global-this": "off",
"unicorn/no-global-object-property-assignment": "off",
"unicorn/no-declarations-before-early-exit": "off",
"unicorn/no-array-reduce": "off",
"unicorn/prefer-ternary": "off",
"unicorn/no-computed-property-existence-check": "off",
"unicorn/no-immediate-mutation": "off",
"unicorn/prefer-simple-condition-first": "off",
"unicorn/single-line-block-comment-style": "off",
"@typescript-eslint/no-unused-expressions": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-namespace": "off",
Expand Down
60 changes: 30 additions & 30 deletions apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,53 +29,53 @@
"format:check": "prettier --check ."
},
"dependencies": {
"@mantine/charts": "^9.3.2",
"@mantine/code-highlight": "^9.3.2",
"@mantine/core": "^9.3.2",
"@mantine/form": "^9.3.2",
"@mantine/hooks": "^9.3.2",
"@mantine/notifications": "^9.4.1",
"@mantine/charts": "^9.6.1",
"@mantine/code-highlight": "^9.6.1",
"@mantine/core": "^9.6.1",
"@mantine/form": "^9.6.1",
"@mantine/hooks": "^9.6.1",
"@mantine/notifications": "^9.6.1",
"@pm2.web/mongoose-models": "workspace:*",
"@pm2.web/typings": "workspace:*",
"@tabler/icons-react": "^3.44.0",
"@tanstack/react-query": "^5.101.0",
"@trpc/client": "^11.18.0",
"@trpc/next": "^11.18.0",
"@trpc/react-query": "^11.18.0",
"@trpc/server": "^11.18.0",
"@tabler/icons-react": "^3.46.0",
"@tanstack/react-query": "^5.103.1",
"@trpc/client": "^11.19.0",
"@trpc/next": "^11.19.0",
"@trpc/react-query": "^11.19.0",
"@trpc/server": "^11.19.0",
"bcrypt": "^6.0.0",
"clsx": "^2.1.1",
"cookies-next": "^6.1.1",
"dotenv": "^17.4.2",
"dotenv-cli": "^11.0.0",
"lodash": "^4.18.1",
"mongodb-memory-server": "^11.2.0",
"mongoose": "^9.7.1",
"mongoose": "^9.10.1",
"ms": "^2.1.3",
"next": "^16.2.9",
"next-auth": "^4.24.14",
"react": "^19.2.7",
"react-dom": "^19.2.7",
"recharts": "^3.8.1",
"next": "^16.3.5",
"next-auth": "^4.24.15",
"react": "^19.3.0",
"react-dom": "^19.3.0",
"recharts": "^3.10.1",
"superjson": "^2.2.6",
"zod": "^4.4.3"
"zod": "^4.6.5"
},
"devDependencies": {
"@next/eslint-plugin-next": "^16.2.9",
"@playwright/test": "^1.61.0",
"@next/eslint-plugin-next": "^16.3.5",
"@playwright/test": "^1.63.0",
"@types/bcrypt": "^6.0.0",
"@types/lodash": "^4.17.24",
"@types/lodash": "^4.17.25",
"@types/ms": "^2.1.0",
"@types/node": "26.0.0",
"@types/react": "^19.2.17",
"@types/react-dom": "^19.2.3",
"eslint": "^10.5.0",
"eslint-config-next": "^16.2.9",
"@types/node": "26.6.1",
"@types/react": "^19.3.0",
"@types/react-dom": "^19.3.0",
"eslint": "^10.10.0",
"eslint-config-next": "^16.3.5",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-simple-import-sort": "^13.0.0",
"eslint-plugin-unicorn": "^68.0.0",
"postcss": "^8.5.15",
"eslint-plugin-simple-import-sort": "^14.0.0",
"eslint-plugin-unicorn": "^75.0.0",
"postcss": "^8.5.28",
"postcss-preset-mantine": "^1.18.0",
"postcss-simple-vars": "^7.0.1",
"typescript": "6.0.3"
Expand Down
8 changes: 3 additions & 5 deletions apps/dashboard/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,7 @@ export default function HomePage({}: InferGetServerSidePropsType<typeof getServe
});
const data = dashboardQuery.data!;

if (dashboardQuery.status !== "success") {
return <></>;
}

return (
return dashboardQuery.status === "success" ? (
<>
<Head>
<title>pm2.web</title>
Expand All @@ -208,6 +204,8 @@ export default function HomePage({}: InferGetServerSidePropsType<typeof getServe
</Dashboard>
</SelectedProvider>
</>
) : (
<></>
);
}

Expand Down
8 changes: 3 additions & 5 deletions apps/dashboard/pages/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ export default function Settings({}: InferGetServerSidePropsType<typeof getServe
const hasPermission = session?.user?.acl?.owner || session?.user?.acl?.admin;
const isOAuth2 = !!session?.user?.oauth2?.provider;

if (getSettingsQuery.status !== "success") {
return <></>;
}

return (
return getSettingsQuery.status === "success" ? (
<>
<Head>
<title>pm2.web</title>
Expand Down Expand Up @@ -69,6 +65,8 @@ export default function Settings({}: InferGetServerSidePropsType<typeof getServe
</Grid>
</Dashboard>
</>
) : (
<></>
);
}

Expand Down
4 changes: 1 addition & 3 deletions apps/dashboard/theme.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { createTheme } from "@mantine/core";

export const theme = createTheme({
/* Put your mantine theme override here */
});
export const theme = createTheme({});
2 changes: 1 addition & 1 deletion apps/dashboard/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es5",
"target": "ES2022",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
Expand Down
3 changes: 1 addition & 2 deletions apps/dashboard/utils/access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ class Access {
const serverPerms = this.userPerms.find((x) => x.server.toString() === server);
if (serverPerms == undefined) return 0;
const processPerms = serverPerms.processes.find((x) => x.process.toString() === process);
if (processPerms == undefined) return serverPerms.perms;
return processPerms.perms;
return processPerms == undefined ? serverPerms.perms : processPerms.perms;
}

public getPerms(server: string, process: string) {
Expand Down
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,17 @@
"test:apps:dashboard": "turbo run test --filter=dashboard"
},
"devDependencies": {
"@eslint/compat": "^2.1.0",
"@eslint/eslintrc": "^3.3.5",
"@eslint/compat": "^2.1.1",
"@eslint/eslintrc": "^3.3.7",
"@eslint/js": "^10.0.1",
"@pm2.web/eslint-config": "workspace:*",
"@pm2.web/typescript-config": "workspace:*",
"eslint": "^10.5.0",
"globals": "^17.6.0",
"prettier": "^3.8.4",
"turbo": "^2.10.2",
"typescript-eslint": "^8.61.1"
"eslint": "^10.10.0",
"globals": "^17.12.0",
"prettier": "^3.9.7",
"turbo": "^2.10.13",
"typescript": "^6.0.3",
"typescript-eslint": "^8.70.0"
},
"packageManager": "pnpm@11.8.0"
}
6 changes: 6 additions & 0 deletions packages/eslint-config/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ export default tsEslint.config(
"unicorn/no-top-level-assignment-in-function": "off",
"unicorn/no-top-level-side-effects": "off",
"unicorn/prefer-export-from": "off",
"unicorn/no-array-reduce": "off",
"unicorn/prefer-ternary": "off",
"unicorn/no-computed-property-existence-check": "off",
"unicorn/no-immediate-mutation": "off",
"unicorn/prefer-simple-condition-first": "off",
"unicorn/single-line-block-comment-style": "off",
"import/newline-after-import": "off",
"unicorn/filename-case": [
"error",
Expand Down
10 changes: 5 additions & 5 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
"eslint.config.mjs"
],
"dependencies": {
"@typescript-eslint/eslint-plugin": "^8.61.1",
"@typescript-eslint/parser": "^8.61.1",
"@typescript-eslint/eslint-plugin": "^8.70.0",
"@typescript-eslint/parser": "^8.70.0",
"eslint-config-prettier": "^10.1.8",
"eslint-config-turbo": "2.9.18",
"eslint-config-turbo": "2.10.13",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-only-warn": "^1.2.1",
"eslint-plugin-prettier": "5.5.6",
"eslint-plugin-simple-import-sort": "^13.0.0",
"eslint-plugin-unicorn": "^68.0.0",
"eslint-plugin-simple-import-sort": "^14.0.0",
"eslint-plugin-unicorn": "^75.0.0",
"typescript": "^6.0.3"
}
}
2 changes: 1 addition & 1 deletion packages/mongoose-models/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@pm2.web/typescript-config": "workspace:*",
"@pm2.web/typings": "workspace:*",
"bcrypt": "^6.0.0",
"mongoose": "^9.7.1"
"mongoose": "^9.10.1"
},
"devDependencies": {
"@types/bcrypt": "^6.0.0",
Expand Down
Loading
Loading