feat: add game server monitoring support
- Added a new `/games` route in `monitorRoute.js` to fetch all supported games. - Implemented `getAllGames` method in `monitorController.js` using the `gamedig` library. - Introduced `useFetchMonitorGames` hook in `monitorHooks.js` to fetch game data in the frontend. - Updated `UptimeCreate` page to support game server monitoring: - Added a new monitor type `"game"`. - Dynamically fetches and displays game options using the new `/games` API. - Removed hardcoded `GAMES` object and replaced it with dynamic fetching from the backend. - Updated `NetworkService.js` with a new `getMonitorGames` method for API calls. This update introduces game server monitoring functionality, allowing users to monitor game servers dynamically.
This commit is contained in:
1 parent
b53650a50f
commit
281cbbc30f
6 files changed
+67
-3455
No files matched your search
@@ -41,10 +41,9 @@ import {
|
||||
useUpdateMonitor,
|
||||
usePauseMonitor,
|
||||
useFetchMonitorById,
|
||||
useFetchMonitorGames,
|
||||
} from "../../../Hooks/monitorHooks";
|
||||
|
||||
import { GAMES } from "../../../Utils/games";
|
||||
|
||||
/**
|
||||
* Parses a URL string and returns a URL object.
|
||||
*
|
||||
@@ -83,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);
|
||||
};
|
||||
@@ -91,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();
|
||||
@@ -116,7 +126,7 @@ const UptimeCreate = ({ isClone = false }) => {
|
||||
{ _id: 5, name: t("time.fiveMinutes") },
|
||||
];
|
||||
|
||||
const GAMELIST = Object.entries(GAMES).map(([key, value]) => ({
|
||||
const GAMELIST = Object.entries(games).map(([key, value]) => ({
|
||||
_id: key,
|
||||
name: value.name,
|
||||
}));
|
||||
|
||||
Reference in new issue
Block a user