From: charleswrayjr Date: Sun, 14 Sep 2025 00:06:42 +0000 (-0500) Subject: Cleaning up Docker.jsx main view. X-Git-Url: https://git.phasecustomsoft.com/static/gitweb.js?a=commitdiff_plain;h=968db08020bcb0b451a4335409348eb06bfc751d;p=phs-admin.git Cleaning up Docker.jsx main view. --- diff --git a/package-lock.json b/package-lock.json index 032d137..e333961 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,7 @@ "material-react-table": "^3.2.1", "notistack": "^3.0.2", "react": "^19.1.1", + "react-app-alias": "^2.2.2", "react-dom": "^19.1.1", "react-hook-form": "^7.62.0", "react-router-dom": "^7.8.2", @@ -13557,6 +13558,11 @@ "node": ">=0.10.0" } }, + "node_modules/react-app-alias": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/react-app-alias/-/react-app-alias-2.2.2.tgz", + "integrity": "sha512-mkebUkGLEBA8A8jripu5h1e3cccGl8wWHCUmyJo43/KhaN91DO3qyCLWGWneogqkG4PWhp2JHtlCJ06YSdHVYQ==" + }, "node_modules/react-app-polyfill": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/react-app-polyfill/-/react-app-polyfill-3.0.0.tgz", diff --git a/package.json b/package.json index 0f0a4cb..4883f88 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "material-react-table": "^3.2.1", "notistack": "^3.0.2", "react": "^19.1.1", + "react-app-alias": "^2.2.2", "react-dom": "^19.1.1", "react-hook-form": "^7.62.0", "react-router-dom": "^7.8.2", diff --git a/src/app/views/Docker/Docker.jsx b/src/app/views/Docker/Docker.jsx index f0c332c..d1f9caf 100644 --- a/src/app/views/Docker/Docker.jsx +++ b/src/app/views/Docker/Docker.jsx @@ -1,30 +1,29 @@ -import React, { useState, useEffect } from 'react'; -import { Container, Typography, TextField, Button } from '@mui/material'; -import { MaterialReactTable } from 'material-react-table'; +import React, { useEffect, useState } from 'react'; +import { Button, Container, TextField, Typography } from '@mui/material'; +import { MaterialReactTable, useMaterialReactTable } from 'material-react-table'; import { DockerService } from '../../services'; - const Docker = () => { - const [containers, setContainers] = useState([]); - const [images, setImages] = useState([]); - const [composeFile, setComposeFile] = useState(''); - const [message, setMessage] = useState(''); + const [containers, setContainers] = useState( [] ); + const [images, setImages] = useState( [] ); + const [composeFile, setComposeFile] = useState( '' ); + const [message, setMessage] = useState( '' ); const fetchContainers = async () => { try { - const containersData = await DockerService.fetchContainers( { all: true } ); // Assuming you have a service to fetch containers - setContainers(containersData); + const containersData = await DockerService.fetchContainers( { all:true } ); // Assuming you have a service to fetch containers + setContainers( containersData ); } catch (error) { - setMessage(error); + setMessage( error ); } }; const fetchImages = async () => { try { const imagesData = await DockerService.fetchImages(); // Assuming you have a service to fetch images - setImages(imagesData); + setImages( imagesData ); } catch (error) { - setMessage(error); + setMessage( error ); } }; @@ -33,76 +32,80 @@ const Docker = () => { fetchContainers().catch(); }, [] ); - const handleContainerAction = async (action, containerId) => { - await DockerService.containerAction(action, containerId); + const handleContainerAction = async ( action, containerId ) => { + await DockerService.containerAction( action, containerId ); await fetchContainers(); }; - const handleComposeSubmit = async (event) => { + const handleComposeSubmit = async ( event ) => { event.preventDefault(); setMessage( await DockerService.composeDown( composeFile ) ); }; - return( + const containerTable = useMaterialReactTable( { + columns:[ + { accessorKey:'id', header:'ID' }, + { accessorKey:'name', header:'Name' }, + { accessorKey:'state', header:'State' }, + { accessorKey:'status', header:'Status' }, + { + header:'Actions', + Cell:( { row } ) => ( + <> + + + + ), + }, + ], + data:containers + } ); + + const imageTable = useMaterialReactTable( { + columns:[ + { accessorKey:'id', header:'ID' }, + { accessorKey:'tags', header:'Tags', Cell:( { cell } ) => cell.getValue().join( ', ' ) }, + { accessorKey:'created', header:'Created' }, + ], + data:images + } ); + + return ( - Docker Containers - ( - <> - - - - ), - }, - ]} - data={containers} - /> + Docker Containers + - Docker Images - cell.getValue().join(', ') }, - { accessorKey: 'created', header: 'Created' }, - ]} - data={images} - /> + Docker Images + - Stop Docker Compose Services -
- setComposeFile(e.target.value)} - fullWidth - /> - + Stop Docker Compose Services + + setComposeFile( e.target.value ) } + fullWidth/> + - {message && {message}} + { message && { message } }
- ) -} + ); +}; export default Docker; \ No newline at end of file