From 9ad3b58fcd1b74f02c6a810f90534323a7723bcd Mon Sep 17 00:00:00 2001 From: Burak Arslan Date: Sat, 2 Aug 2025 02:04:06 +0300 Subject: [PATCH 01/19] Added game server support --- client/src/Hooks/monitorHooks.js | 2 +- client/src/Pages/Uptime/Create/index.jsx | 40 +- .../Monitors/Components/Filter/index.jsx | 1 + client/src/Pages/Uptime/Monitors/index.jsx | 2 +- client/src/Utils/games.js | 3450 +++++++++++++++++ client/src/Validation/validation.js | 1 + client/src/locales/ar.json | 4 +- client/src/locales/cs.json | 4 +- client/src/locales/de.json | 4 +- client/src/locales/en.json | 11 +- client/src/locales/es.json | 4 +- client/src/locales/fi.json | 4 +- client/src/locales/fr.json | 4 +- client/src/locales/ja.json | 4 +- client/src/locales/pt-BR.json | 4 +- client/src/locales/ru.json | 4 +- client/src/locales/tr.json | 4 +- client/src/locales/uk.json | 4 +- client/src/locales/vi.json | 4 +- client/src/locales/zh-TW.json | 4 +- server/package-lock.json | 565 ++- server/package.json | 1 + server/src/db/models/Monitor.js | 5 +- server/src/db/mongo/modules/checkModule.js | 1 + server/src/db/mongo/modules/monitorModule.js | 2 +- .../db/mongo/modules/monitorModuleQueries.js | 2 +- server/src/service/business/monitorService.js | 14 +- .../service/infrastructure/bufferService.js | 1 + .../service/infrastructure/networkService.js | 55 + server/src/validation/joi.js | 8 +- 30 files changed, 4110 insertions(+), 103 deletions(-) create mode 100644 client/src/Utils/games.js diff --git a/client/src/Hooks/monitorHooks.js b/client/src/Hooks/monitorHooks.js index 616a37877..4a19f2fa7 100644 --- a/client/src/Hooks/monitorHooks.js +++ b/client/src/Hooks/monitorHooks.js @@ -357,7 +357,7 @@ const useUpdateMonitor = () => { expectedValue: monitor.expectedValue, ignoreTlsErrors: monitor.ignoreTlsErrors, jsonPath: monitor.jsonPath, - ...(monitor.type === "port" && { port: monitor.port }), + ...((monitor.type === "port" || monitor.type === "game") && { port: monitor.port }), ...(monitor.type === "hardware" && { thresholds: monitor.thresholds, secret: monitor.secret, diff --git a/client/src/Pages/Uptime/Create/index.jsx b/client/src/Pages/Uptime/Create/index.jsx index 2d918cb9f..3a1080421 100644 --- a/client/src/Pages/Uptime/Create/index.jsx +++ b/client/src/Pages/Uptime/Create/index.jsx @@ -43,6 +43,8 @@ import { useFetchMonitorById, } from "../../../Hooks/monitorHooks"; +import { GAMES } from '../../../Utils/games'; + /** * Parses a URL string and returns a URL object. * @@ -113,6 +115,12 @@ const UptimeCreate = ({ isClone = false }) => { { _id: 4, name: t("time.fourMinutes") }, { _id: 5, name: t("time.fiveMinutes") }, ]; + + const GAMELIST = Object.entries(GAMES).map(([key, value]) => ({ + _id: key, + name: value.name + })); + const CRUMBS = [ { name: "uptime", path: "/uptime" }, ...(isCreate @@ -153,6 +161,11 @@ const UptimeCreate = ({ isClone = false }) => { placeholder: t("monitorType.port.placeholder"), namePlaceholder: t("monitorType.port.namePlaceholder"), }, + game: { + label: t("monitorType.game.label"), + placeholder: t("monitorType.game.placeholder"), + namePlaceholder: t("monitorType.game.namePlaceholder"), + } }; // Handlers @@ -169,12 +182,13 @@ const UptimeCreate = ({ isClone = false }) => { : monitor.url, name: monitor.name || monitor.url.substring(0, 50), type: monitor.type, - port: monitor.type === "port" ? monitor.port : undefined, + port: (monitor.type === "port" || monitor.type === "game") ? monitor.port : undefined, interval: monitor.interval, matchMethod: monitor.matchMethod, expectedValue: monitor.expectedValue, jsonPath: monitor.jsonPath, ignoreTlsErrors: monitor.ignoreTlsErrors, + gameId: monitor.gameId || undefined, }; } else { form = { @@ -188,8 +202,9 @@ const UptimeCreate = ({ isClone = false }) => { interval: monitor.interval, teamId: monitor.teamId, userId: monitor.userId, - port: monitor.type === "port" ? monitor.port : undefined, + port: (monitor.type === "port" || monitor.type === "game") ? monitor.port : undefined, ignoreTlsErrors: monitor.ignoreTlsErrors, + gameId: monitor.gameId || undefined, }; } if (!useAdvancedMatching) { @@ -486,6 +501,15 @@ const UptimeCreate = ({ isClone = false }) => { checked={monitor.type === "port"} onChange={onChange} /> + {errors["type"] ? ( { onChange={onChange} error={errors["port"] ? true : false} helperText={errors["port"]} - hidden={monitor.type !== "port"} + hidden={monitor.type !== "port" && monitor.type !== "game"} /> + { + monitor.type === "game" && + ()} + {monitor.type === "game" && ( +