diff --git a/client/src/App.js b/client/src/App.js index 0308193..154cd00 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -1,5 +1,5 @@ import React from 'react'; -import { BrowserRouter, Route, Routes } from 'react-router-dom'; +import { Route, Routes } from 'react-router-dom'; import './App.css'; import Navigation from './components/Navigation'; import Home from './components/Home'; @@ -15,7 +15,7 @@ import Metric from './components/Metric'; function App() { return ( - +
@@ -26,13 +26,10 @@ function App() { } /> } /> } /> - } /> {/* Replace Home with your actual home component */} - {/* Add routes for update and create if needed, with corresponding components: */} - {/* } /> */} - {/* } /> */} + } />
-
+ ); } diff --git a/client/src/components/Home.js b/client/src/components/Home.js index 254b518..518c59c 100644 --- a/client/src/components/Home.js +++ b/client/src/components/Home.js @@ -1,27 +1,41 @@ -import React from 'react'; +import React, { useEffect, useState } from 'react'; import '../style/home.css'; -import { Link } from 'react-router-dom'; +// import { Link } from 'react-router-dom'; export default function Home() { - const execCMD = () => { - // Make a request to the server-side endpoint - fetch('/rundocker') - .then(response => { - if (!response.ok) { - throw new Error('Network response was not ok'); - } - return response.text(); - }) - .then(data => { - console.log(data); - alert('Command executed successfully'); - }) - .catch(error => { - console.error('There was a problem with the fetch operation:', error); - alert('Failed to execute command'); - }); - }; + const [data, setData] = useState([]); + const getDetails = () => { + console.log("Working") + fetch('/getdata') + .then((response) => { + return response.json(); + }) + .then((data) => { + console.log(data); + // Handle the fetched data as needed + }) + .catch((error) => { + console.error('Error fetching data:', error); + // Handle the error appropriately + }); + + } + +// const getDetails = (){ +// console.log("button is working") +// useEffect(() => { +// fetch('/getdata') +// .then((data) => { +// return data.json() +// }) +// .then((res) => { +// console.log(res); +// setData(res) + +// }) +// }) +// } return (
@@ -35,7 +49,28 @@ export default function Home() {

Docker is a platform designed to help developers build, share, and run container applications. We handle the tedious setup, so you can focus on the code.

- + + +
+
+

Container Id

+

Process name

+
+ +
+ + { + data.map((item)=>{ + return
+

{item["Container Id"]}

+

{item["Process name"]}

+
+ + }) + } + +
+
{/* Get Started */}
diff --git a/client/src/index.js b/client/src/index.js index d563c0f..6d9f919 100644 --- a/client/src/index.js +++ b/client/src/index.js @@ -1,5 +1,6 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; +import { BrowserRouter } from 'react-router-dom'; import './index.css'; import App from './App'; import reportWebVitals from './reportWebVitals'; @@ -7,7 +8,9 @@ import reportWebVitals from './reportWebVitals'; const root = ReactDOM.createRoot(document.getElementById('root')); root.render( + + ); diff --git a/client/src/style/home.css b/client/src/style/home.css index 605aa32..7d2d85a 100644 --- a/client/src/style/home.css +++ b/client/src/style/home.css @@ -83,4 +83,21 @@ button > *{ text-decoration: none; color: black; - } \ No newline at end of file + } + + .information .table-head{ + display: flex; + gap: 20px; + font-size: large; + color: aliceblue; + } + .information .table-data{ + display: flex; + flex-direction: column; + } + + .information .table-data .data{ + display: flex; + gap: 25px; + } + diff --git a/pull_request_template.md b/pull_request_template.md index 4f1e465..dc2c6f1 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -15,7 +15,7 @@ ## Checklist -- [x] My code follows the code style of this project. +- [ ] My code follows the code style of this project. - [ ] I have reviewed my code and ensured it's functioning as expected. - [ ] I have added appropriate comments to my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation accordingly. diff --git a/server/data/cpu_utilization.json b/server/data/cpu_utilization.json new file mode 100644 index 0000000..22da025 --- /dev/null +++ b/server/data/cpu_utilization.json @@ -0,0 +1,82 @@ +[ + { + "Container Id": "user.qwer1234", + "Process name": "process-1", + "CPU user": 34567890, + "CPU quota": 0, + "CPU throttling": 0, + "CPU kernel": 12345678 + }, + { + "Container Id": "user.asdf5678", + "Process name": "process-2", + "CPU user": 90876543, + "CPU quota": 0, + "CPU throttling": 0, + "CPU kernel": 87654321 + }, + { + "Container Id": "user.zxcv9012", + "Process name": "process-3", + "CPU user": 56789012, + "CPU quota": 0, + "CPU throttling": 0, + "CPU kernel": 21098765 + }, + { + "Container Id": "user.poiuy3456", + "Process name": "process-4", + "CPU user": 123456789, + "CPU quota": 0, + "CPU throttling": 0, + "CPU kernel": 98765432 + }, + { + "Container Id": "user.lkjh7890", + "Process name": "process-5", + "CPU user": 67890123, + "CPU quota": 0, + "CPU throttling": 0, + "CPU kernel": 32109876 + }, + { + "Container Id": "user.hjkl1234", + "Process name": "process-6", + "CPU user": 234567890, + "CPU quota": 0, + "CPU throttling": 0, + "CPU kernel": 10987654 + }, + { + "Container Id": "user.gfed5678", + "Process name": "process-7", + "CPU user": 78901234, + "CPU quota": 0, + "CPU throttling": 0, + "CPU kernel": 43210987 + }, + { + "Container Id": "user.tyuio9012", + "Process name": "process-8", + "CPU user": 345678901, + "CPU quota": 0, + "CPU throttling": 0, + "CPU kernel": 11098765 + }, + { + "Container Id": "user.rewq2345", + "Process name": "process-9", + "CPU user": 89012345, + "CPU quota": 0, + "CPU throttling": 0, + "CPU kernel": 54321098 + }, + { + "Container Id": "user.asdfg6789", + "Process name": "process-10", + "CPU user": 45678901, + "CPU quota": 0, + "CPU throttling": 0, + "CPU kernel": 12109876 + } +] diff --git a/server/server.js b/server/server.js index ae94001..c0edc68 100644 --- a/server/server.js +++ b/server/server.js @@ -1,17 +1,19 @@ const express = require('express'); -const cors = require('cors') -const { exec } = require('child_process'); +const cors = require('cors'); +const cpuData = require('./data/cpu_utilization.json'); // Changed variable name for better readability const app = express(); -app.use(cors()); const port = 3001; -app.listen(port, () => { - console.log(`Server is running on port ${port}`); -}); - +// Middleware to enable CORS +app.use(cors()); -app.get('/rundocker', (req, res) => { +// Route handler for GET requests to /getdata endpoint +app.get('/getdata', (req, res) => { + req.send("Hello from server"); // Sending JSON data as response +}); - +// Start the server +app.listen(port, () => { + console.log(`Server is running on port ${port}`); });