Merge branch 'develop' into refactor-login-page

This commit is contained in:
karenvicent committed 2025-08-11 18:22:11 -04:00
commit f0e79121a7
38 files changed
+4039 -2051

No files matched your search

@@ -50,6 +50,7 @@ const Select = ({
onChange,
onBlur,
sx,
error = false,
name = "",
labelControlSpacing = 6,
maxWidth,
@@ -93,6 +94,7 @@ const Select = ({
onChange={onChange}
onBlur={onBlur}
displayEmpty
error={error}
name={name}
inputProps={{ id: id }}
IconComponent={KeyboardArrowDownIcon}
@@ -172,6 +174,7 @@ Select.propTypes = {
label: PropTypes.string,
placeholder: PropTypes.string,
isHidden: PropTypes.bool,
error: PropTypes.bool,
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool])
.isRequired,
items: PropTypes.arrayOf(
+26 -1
View File
@@ -202,6 +202,25 @@ const useFetchStatsByMonitorId = ({
return [monitor, audits, isLoading, networkError];
};
const useFetchMonitorGames = ({ setGames, updateTrigger }) => {
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
const fetchGames = async () => {
try {
setIsLoading(true);
const res = await networkService.getMonitorGames();
setGames(res.data.data);
} catch (error) {
createToast({ body: error.message });
} finally {
setIsLoading(false);
}
};
fetchGames();
}, [setGames, updateTrigger]);
return [isLoading];
};
const useFetchMonitorById = ({ monitorId, setMonitor, updateTrigger }) => {
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
@@ -357,7 +376,12 @@ 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 == "game" && {
gameId: monitor.gameId,
}),
...(monitor.type === "hardware" && {
thresholds: monitor.thresholds,
secret: monitor.secret,
@@ -530,4 +554,5 @@ export {
useDeleteMonitorStats,
useCreateBulkMonitors,
useExportMonitors,
useFetchMonitorGames,
};
+60 -6
View File
@@ -41,6 +41,7 @@ import {
useUpdateMonitor,
usePauseMonitor,
useFetchMonitorById,
useFetchMonitorGames,
} from "../../../Hooks/monitorHooks";
/**
@@ -81,6 +82,7 @@ const UptimeCreate = ({ isClone = false }) => {
const [isOpen, setIsOpen] = useState(false);
const [useAdvancedMatching, setUseAdvancedMatching] = useState(false);
const [updateTrigger, setUpdateTrigger] = useState(false);
const [games, setGames] = useState({});
const triggerUpdate = () => {
setUpdateTrigger(!updateTrigger);
};
@@ -89,12 +91,22 @@ const UptimeCreate = ({ isClone = false }) => {
const [notifications, notificationsAreLoading, notificationsError] =
useGetNotificationsByTeamId();
const { determineState, statusColor } = useMonitorUtils();
// Network
const [isLoading] = useFetchMonitorById({
// Fetch monitor details
const [isFetchingMonitor] = useFetchMonitorById({
monitorId,
setMonitor,
updateTrigger: true,
});
// Fetch games
const [isFetchingGames] = useFetchMonitorGames({
setGames,
triggerUpdate: true,
});
// Combine the loading states
const isLoading = isFetchingMonitor || isFetchingGames;
const [createMonitor, isCreating] = useCreateMonitor();
const [pauseMonitor, isPausing] = usePauseMonitor({});
const [deleteMonitor, isDeleting] = useDeleteMonitor();
@@ -113,6 +125,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 +171,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 +192,14 @@ 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 +213,10 @@ 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) {
@@ -243,6 +270,11 @@ const UptimeCreate = ({ isClone = false }) => {
setMonitor((prev) => ({ ...prev, [name]: value }));
if (name === "type") {
setErrors({});
return;
}
const { error } = monitorValidation.validate(
{ type: monitor.type, [name]: value },
{ abortEarly: false }
@@ -250,7 +282,9 @@ const UptimeCreate = ({ isClone = false }) => {
setErrors((prev) => ({
...prev,
...(error ? { [name]: error.details[0].message } : { [name]: undefined }),
...(error && error.details[0].path[0] === name
? { [name]: error.details[0].message }
: { [name]: undefined }),
}));
};
@@ -486,6 +520,15 @@ const UptimeCreate = ({ isClone = false }) => {
checked={monitor.type === "port"}
onChange={onChange}
/>
<Radio
name="type"
title={t("gameServerMonitoring")}
desc={t("gameServerMonitoringDescription")}
size="small"
value="game"
checked={monitor.type === "game"}
onChange={onChange}
/>
{errors["type"] ? (
<Box className="error-container">
<Typography
@@ -547,8 +590,19 @@ const UptimeCreate = ({ isClone = false }) => {
onChange={onChange}
error={errors["port"] ? true : false}
helperText={errors["port"]}
hidden={monitor.type !== "port"}
hidden={monitor.type !== "port" && monitor.type !== "game"}
/>
{monitor.type === "game" && (
<Select
name="gameId"
label={t("chooseGame")}
value={monitor.gameId || ""}
placeholder={t("chooseGame")}
onChange={onChange}
items={GAMELIST}
error={errors["gameId"] ? true : false}
/>
)}
<TextInput
name="name"
type="text"
@@ -32,6 +32,7 @@ const getTypeOptions = () => [
{ value: "ping", label: "Ping" },
{ value: "docker", label: "Docker" },
{ value: "port", label: "Port" },
{ value: "game", label: "Game" },
];
// These functions were moved inline to ensure translations are applied correctly
+1 -1
View File
@@ -34,7 +34,7 @@ import {
} from "../../../Hooks/monitorHooks";
import { useTranslation } from "react-i18next";
const TYPES = ["http", "ping", "docker", "port"];
const TYPES = ["http", "ping", "docker", "port", "game"];
const CreateMonitorButton = ({ shouldRender }) => {
// Utils
const navigate = useNavigate();
+14
View File
@@ -74,6 +74,20 @@ class NetworkService {
}
}
/**
* Fetch the games associated with a monitor
*
* @async
* @returns {Promise<AxiosResponse>} The response from the axios GET request.
*/
async getMonitorGames() {
return this.axiosInstance.get(`/monitors/games`, {
headers: {
"Content-Type": "application/json",
},
});
}
/**
*
* ************************************
+11 -3
View File
@@ -184,12 +184,12 @@ const monitorValidation = joi.object({
.min(1)
.max(65535)
.when("type", {
is: "port",
then: joi.number().messages({
is: joi.valid("port", "game"),
then: joi.required().messages({
"number.base": "Port must be a number.",
"number.min": "Port must be at least 1.",
"number.max": "Port must be at most 65535.",
"any.required": "Port is required for port monitors.",
"any.required": "Port is required for port and game monitors.",
}),
otherwise: joi.optional(),
}),
@@ -205,6 +205,14 @@ const monitorValidation = joi.object({
expectedValue: joi.string().allow(null, ""),
jsonPath: joi.string().allow(null, ""),
matchMethod: joi.string().allow(null, ""),
gameId: joi.when("type", {
is: "game",
then: joi.string().required().messages({
"string.empty": "Game selection is required for game monitors.",
"any.required": "Game selection is required for game monitors.",
}),
otherwise: joi.string().allow(null, ""),
}),
});
const imageValidation = joi.object({
+3 -1
View File
@@ -260,6 +260,7 @@
"notifyEmails": "",
"seperateEmails": "",
"checkFrequency": "",
"chooseGame": "",
"matchMethod": "",
"expectedValue": "",
"deleteDialogTitle": "",
@@ -437,7 +438,8 @@
"http": "",
"ping": "",
"docker": "",
"port": ""
"port": "",
"game": ""
},
"common": {
"appName": "",
+3 -1
View File
@@ -260,6 +260,7 @@
"notifyEmails": "",
"seperateEmails": "",
"checkFrequency": "",
"chooseGame": "",
"matchMethod": "",
"expectedValue": "",
"deleteDialogTitle": "",
@@ -437,7 +438,8 @@
"http": "",
"ping": "",
"docker": "",
"port": ""
"port": "",
"game": ""
},
"common": {
"appName": "Checkmate",
+3 -1
View File
@@ -260,6 +260,7 @@
"notifyEmails": "Benachrichtige auch per E-Mail an mehrere Adressen (kommt bald)",
"seperateEmails": "Du kannst mehrere E-Mails mit einem Komma trennen",
"checkFrequency": "Überprüfungsfrequenz",
"chooseGame": "",
"matchMethod": "",
"expectedValue": "Erwarteter Wert",
"deleteDialogTitle": "Möchtest du diesen Monitor wirklich löschen?",
@@ -437,7 +438,8 @@
"http": "",
"ping": "",
"docker": "",
"port": ""
"port": "",
"game": ""
},
"common": {
"appName": "Checkmate",
+10 -1
View File
@@ -218,6 +218,7 @@
"cancel": "Cancel",
"checkFormError": "Please check the form for errors.",
"checkFrequency": "Check frequency",
"chooseGame": "Choose game",
"checkHooks": {
"failureResolveAll": "Failed to resolve all incidents.",
"failureResolveMonitor": "Failed to resolve monitor incidents.",
@@ -629,6 +630,11 @@
"label": "URL to monitor",
"namePlaceholder": "Localhost:5173",
"placeholder": "localhost"
},
"game": {
"label": "URL to monitor",
"namePlaceholder": "localhost:5173",
"placeholder": "localhost"
}
},
"ms": "ms",
@@ -750,6 +756,8 @@
"pingMonitoringDescription": "Check whether your server is available or not.",
"portMonitoring": "Port monitoring",
"portMonitoringDescription": "Check whether your port is open or not.",
"gameServerMonitoring": "Game Server Monitoring",
"gameServerMonitoringDescription": "Check whether your game server is running or not",
"portToMonitor": "Port to monitor",
"publicLink": "Public link",
"publicURL": "Public URL",
@@ -1012,7 +1020,8 @@
"docker": "Enter the Docker ID of your container. Docker IDs must be the full 64 char Docker ID. You can run docker inspect <short_id> to get the full container ID.",
"http": "Enter the URL or IP to monitor (e.g., https://example.com/ or 192.168.1.100) and add a clear display name that appears on the dashboard.",
"ping": "Enter the IP address or hostname to ping (e.g., 192.168.1.100 or example.com) and add a clear display name that appears on the dashboard.",
"port": "Enter the URL or IP of the server, the port number and a clear display name that appears on the dashboard."
"port": "Enter the URL or IP of the server, the port number and a clear display name that appears on the dashboard.",
"game": "Enter the IP address or hostname and the port number to ping (e.g., 192.168.1.100 or example.com) and choose game type."
},
"uptimeMonitor": {
"fallback": {
+3 -1
View File
@@ -260,6 +260,7 @@
"notifyEmails": "",
"seperateEmails": "",
"checkFrequency": "",
"chooseGame": "",
"matchMethod": "",
"expectedValue": "",
"deleteDialogTitle": "",
@@ -437,7 +438,8 @@
"http": "",
"ping": "",
"docker": "",
"port": ""
"port": "",
"game": ""
},
"common": {
"appName": "",
+3 -1
View File
@@ -260,6 +260,7 @@
"notifyEmails": "",
"seperateEmails": "",
"checkFrequency": "",
"chooseGame": "",
"matchMethod": "",
"expectedValue": "",
"deleteDialogTitle": "",
@@ -437,7 +438,8 @@
"http": "",
"ping": "",
"docker": "",
"port": ""
"port": "",
"game": ""
},
"common": {
"appName": "",
+3 -1
View File
@@ -264,6 +264,7 @@
"notifyEmails": "Envoyer également une notification par email à plusieurs adresses (bientôt).",
"seperateEmails": "Vous pouvez ajouter plusieurs adresses emails en les séparant par une virgule",
"checkFrequency": "Vérifier la fréquence",
"chooseGame": "",
"matchMethod": "Méthode de rapprochement",
"expectedValue": "Valeur attendue",
"deleteDialogTitle": "Voulez-vous vraiment supprimer ce moniteur ?",
@@ -441,7 +442,8 @@
"http": "Entrez l'URL ou l'IP du moniteur (par exemple https://exemple.fr ou 192.168.1.100) et ajoutez un nom familier qui apparaîtra sur le tableau de bord.",
"ping": "Entrez l'adresse IP ou le nom d'hôte à tester (par exemple, 192.168.1.100 ou exemple.fr) et ajoutez un nom familier qui apparaîtra sur le tableau de bord.",
"docker": "Entrer l'ID Docker du container. Les identifiants Docker doivent être les 64 caractères de l'ID Docker. Vous pouvez utiliser la commande docker inspect <short_id> pour avoir l'ID complet.",
"port": "Entrez l'URL ou l'adresse IP du serveur, le numéro de port et un nom d'affichage familier qui apparaîtra sur le tableau de bord."
"port": "Entrez l'URL ou l'adresse IP du serveur, le numéro de port et un nom d'affichage familier qui apparaîtra sur le tableau de bord.",
"game": ""
},
"common": {
"appName": "Checkmate",
+3 -1
View File
@@ -264,6 +264,7 @@
"notifyEmails": "複数のアドレスにメールでも通知(近日公開)",
"seperateEmails": "複数のメールはカンマで区切ることができます",
"checkFrequency": "チェック頻度",
"chooseGame": "",
"matchMethod": "マッチ方法",
"expectedValue": "期待値",
"deleteDialogTitle": "本当にこのモニターを削除しますか?",
@@ -441,7 +442,8 @@
"http": "監視するURLまたはIPを入力(例: https://example.com/ または 192.168.1.100)し、ダッシュボードに表示される明確な表示名を追加。",
"ping": "pingするIPアドレスまたはホスト名を入力(例: 192.168.1.100 または example.com)し、ダッシュボードに表示される明確な表示名を追加。",
"docker": "コンテナのDocker IDを入力。Docker IDは64文字のフルDocker IDである必要があります。docker inspect <short_id>を実行してフルコンテナIDを取得できます。",
"port": "サーバーのURLまたはIP、ポート番号、ダッシュボードに表示される明確な表示名を入力。"
"port": "サーバーのURLまたはIP、ポート番号、ダッシュボードに表示される明確な表示名を入力。",
"game": ""
},
"common": {
"appName": "Checkmate",
+3 -1
View File
@@ -260,6 +260,7 @@
"notifyEmails": "Também notificar por e-mail para vários endereços (em breve)",
"seperateEmails": "Você pode separar vários e-mails com uma vírgula",
"checkFrequency": "Verifique a frequência",
"chooseGame": "",
"matchMethod": "Método de correspondência",
"expectedValue": "Valor esperado",
"deleteDialogTitle": "Você realmente deseja excluir este monitor?",
@@ -437,7 +438,8 @@
"http": "Insira a URL ou IP para monitorar (ex. https://exemplo.com.br/ ou 192.168.1.100) e adicione uma descrição que aparecerá na dashboard.",
"ping": "Insira o endereço IP ou nome de domínio para ping (ex. 192.168.1.100 ou exemplo.com.br) e adicione uma descrição que aparecerá na dashboard.",
"docker": "Insira o Docker Id do seu container. Docker Ids devem ser todos os 64 caracteres. Você pode executar docker inspect <short_id> para descobrir o Id completo.",
"port": "Insira a URL ou o IP do servidor, aporta e uma descrição que aparecerá na dashboard."
"port": "Insira a URL ou o IP do servidor, aporta e uma descrição que aparecerá na dashboard.",
"game": ""
},
"common": {
"appName": "Checkmate",
+3 -1
View File
@@ -260,6 +260,7 @@
"notifyEmails": "Также уведомлять по электронной почте на несколько адресов (скоро)",
"seperateEmails": "Вы можете разделить несколько адресов электронной почты запятой.",
"checkFrequency": "Проверить частоту",
"chooseGame": "",
"matchMethod": "Метод сопоставления",
"expectedValue": "Ожидаемое значение",
"deleteDialogTitle": "Вы действительно хотите удалить этот монитор?",
@@ -437,7 +438,8 @@
"http": "",
"ping": "",
"docker": "",
"port": ""
"port": "",
"game": ""
},
"common": {
"appName": "",
+3 -1
View File
@@ -260,6 +260,7 @@
"notifyEmails": "Ayrıca birden fazla eposta adresine bildirim gönderebilirsiniz (yakında geliyor)",
"seperateEmails": "Birden fazla epostayı virgülle ayırabilirsiniz",
"checkFrequency": "Frekansı denetle",
"chooseGame": "Oyun seç",
"matchMethod": "Eşleşme yöntemi",
"expectedValue": "Beklenen değer",
"deleteDialogTitle": "Gerçekten bu monitörü silmek istiyor musunuz?",
@@ -437,7 +438,8 @@
"http": "",
"ping": "",
"docker": "",
"port": ""
"port": "",
"game": ""
},
"common": {
"appName": "Checkmate",
+3 -1
View File
@@ -260,6 +260,7 @@
"notifyEmails": "",
"seperateEmails": "",
"checkFrequency": "",
"chooseGame": "",
"matchMethod": "",
"expectedValue": "",
"deleteDialogTitle": "",
@@ -435,7 +436,8 @@
"http": "",
"ping": "",
"docker": "",
"port": ""
"port": "",
"game": ""
},
"common": {
"appName": "",
+3 -1
View File
@@ -260,6 +260,7 @@
"notifyEmails": "",
"seperateEmails": "",
"checkFrequency": "",
"chooseGame": "",
"matchMethod": "",
"expectedValue": "",
"deleteDialogTitle": "",
@@ -435,7 +436,8 @@
"http": "",
"ping": "",
"docker": "",
"port": ""
"port": "",
"game": ""
},
"common": {
"appName": "",
+3 -1
View File
@@ -260,6 +260,7 @@
"notifyEmails": "",
"seperateEmails": "",
"checkFrequency": "",
"chooseGame": "",
"matchMethod": "",
"expectedValue": "",
"deleteDialogTitle": "",
@@ -437,7 +438,8 @@
"http": "",
"ping": "",
"docker": "",
"port": ""
"port": "",
"game": ""
},
"common": {
"appName": "",