From 27dd65ccfae76c881ffce2777fcb37f8e9fd2fac Mon Sep 17 00:00:00 2001 From: MuhammadKhalilzadeh Date: Thu, 20 Jun 2024 21:47:07 +0330 Subject: [PATCH] hardcode removed --- Client/src/Mock/sample_data.json | 78 +++++++++++++++++++++ Client/src/Pages/Monitors/CurrentStats.jsx | 80 +--------------------- Client/src/Pages/Monitors/index.jsx | 8 +-- 3 files changed, 83 insertions(+), 83 deletions(-) diff --git a/Client/src/Mock/sample_data.json b/Client/src/Mock/sample_data.json index f5a57982d..b391f4678 100644 --- a/Client/src/Mock/sample_data.json +++ b/Client/src/Mock/sample_data.json @@ -15,6 +15,24 @@ "updatedAt": "2024-06-18T18:56:06.212Z", "__v": 0, "checks": [ + { + "_id": "6671d84a9ba14f9f260eed27", + "monitorId": "6671d8469ba14f9f260eed23", + "status": true, + "responseTime": 143, + "createdAt": "2024-06-18T18:56:10.082Z", + "updatedAt": "2024-06-18T18:56:10.082Z", + "__v": 0 + }, + { + "_id": "6671d84a9ba14f9f260eed27", + "monitorId": "6671d8469ba14f9f260eed23", + "status": true, + "responseTime": 70, + "createdAt": "2024-06-18T18:56:10.082Z", + "updatedAt": "2024-06-18T18:56:10.082Z", + "__v": 0 + }, { "_id": "6671d84a9ba14f9f260eed27", "monitorId": "6671d8469ba14f9f260eed23", @@ -210,6 +228,26 @@ "updatedAt": "2024-06-18T18:56:20.190Z", "__v": 0 }, + { + "_id": "6671d85e9ba14f9f260eed3e", + "monitorId": "6671d8529ba14f9f260eed2b", + "status": false, + "responseTime": 228, + "statusCode": 404, + "createdAt": "2024-06-18T18:56:30.279Z", + "updatedAt": "2024-06-18T18:56:30.279Z", + "__v": 0 + }, + { + "_id": "6671d8669ba14f9f260eed47", + "monitorId": "6671d8529ba14f9f260eed2b", + "status": true, + "responseTime": 112, + "statusCode": 200, + "createdAt": "2024-06-18T18:56:38.381Z", + "updatedAt": "2024-06-18T18:56:38.381Z", + "__v": 0 + }, { "_id": "6671d8879ba14f9f260eed74", "monitorId": "6671d8529ba14f9f260eed2b", @@ -285,6 +323,26 @@ "updatedAt": "2024-06-18T18:57:48.532Z", "__v": 0 }, + { + "_id": "6671d8a59ba14f9f260eed98", + "monitorId": "6671d8529ba14f9f260eed2b", + "status": false, + "responseTime": 271, + "statusCode": 404, + "createdAt": "2024-06-18T18:57:41.421Z", + "updatedAt": "2024-06-18T18:57:41.421Z", + "__v": 0 + }, + { + "_id": "6671d8ac9ba14f9f260eeda1", + "monitorId": "6671d8529ba14f9f260eed2b", + "status": true, + "responseTime": 127, + "statusCode": 200, + "createdAt": "2024-06-18T18:57:48.532Z", + "updatedAt": "2024-06-18T18:57:48.532Z", + "__v": 0 + }, { "_id": "6671d8b29ba14f9f260eedaa", "monitorId": "6671d8529ba14f9f260eed2b", @@ -440,6 +498,26 @@ "updatedAt": "2024-06-18T18:59:16.089Z", "__v": 0 }, + { + "_id": "6671d8d89ba14f9f260eede0", + "monitorId": "6671d8529ba14f9f260eed2b", + "status": false, + "responseTime": 218, + "statusCode": 404, + "createdAt": "2024-06-18T18:58:32.311Z", + "updatedAt": "2024-06-18T18:58:32.311Z", + "__v": 0 + }, + { + "_id": "6671d8df9ba14f9f260eede9", + "monitorId": "6671d8529ba14f9f260eed2b", + "status": true, + "responseTime": 138, + "statusCode": 200, + "createdAt": "2024-06-18T18:58:39.422Z", + "updatedAt": "2024-06-18T18:58:39.422Z", + "__v": 0 + }, { "_id": "6671d9089ba14f9f260eee28", "monitorId": "6671d8529ba14f9f260eed2b", diff --git a/Client/src/Pages/Monitors/CurrentStats.jsx b/Client/src/Pages/Monitors/CurrentStats.jsx index c27bbeef5..de15d953c 100644 --- a/Client/src/Pages/Monitors/CurrentStats.jsx +++ b/Client/src/Pages/Monitors/CurrentStats.jsx @@ -8,88 +8,10 @@ import ServerStatus from "../../Components/Charts/Servers/ServerStatus"; import CurrentMonitors from "../../Components/CurrentMonitors"; import MockData from "../../Mock/sample_data.json"; -const hardCodedMonitors = [ - { - host: Host( - "Discord", - 100, - "var(--env-var-color-17)", - "https://www.google.com" - ), - status: HostStatus( - "var(--env-var-color-20)", - "Up", - "var(--env-var-color-17)" - ), - team: , - actions: HostActions(), - }, - { - host: Host( - "Google", - 99.9, - "var(--env-var-color-17)", - "https://www.google.com" - ), - status: HostStatus( - "var(--env-var-color-20)", - "Up", - "var(--env-var-color-17)" - ), - team: , - actions: HostActions(), - }, - { - host: Host( - "NBC", - 98.1, - "var(--env-var-color-18)", - "https://www.google.com" - ), - status: HostStatus( - "var(--env-var-color-20)", - "Up", - "var(--env-var-color-17)" - ), - team: , - actions: HostActions(), - }, - { - host: Host( - "Google", - 95.1, - "var(--env-var-color-19)", - "https://www.google.com" - ), - status: HostStatus( - "var(--env-var-color-21)", - "Down", - "var(--env-var-color-19)" - ), - team: , - actions: HostActions(), - }, - { - host: Host( - "NBC", - 99.9, - "var(--env-var-color-17)", - "https://www.google.com" - ), - status: HostStatus( - "var(--env-var-color-15)", - "Cannot resolve", - "var(--env-var-color-22)" - ), - team: , - actions: HostActions(), - }, -]; - const CurrentStats = (mockdata = true) => { // The hardcoded part is passed as default value for the purpose of demonstration. // Pass an empty array, [], before fetching the data - const [monitors, setMonitors] = useState(hardCodedMonitors); + const [monitors, setMonitors] = useState([]); useEffect(() => { if (mockdata) { diff --git a/Client/src/Pages/Monitors/index.jsx b/Client/src/Pages/Monitors/index.jsx index fbc0413d0..a1dd61f0c 100644 --- a/Client/src/Pages/Monitors/index.jsx +++ b/Client/src/Pages/Monitors/index.jsx @@ -1,13 +1,13 @@ -import CreateNewMonitor from "./CreateNewMonitor"; -// import CurrentStats from "./CurrentStats"; +// import CreateNewMonitor from "./CreateNewMonitor"; +import CurrentStats from "./CurrentStats"; import "./index.css"; import React from "react"; const Monitors = () => { return (
- {/* */} - + + {/* */}
); };