From 088e68dd9a7cd95364864f864ab8c5565e926f7a Mon Sep 17 00:00:00 2001 From: Scai <59282365+alexevladgabriel@users.noreply.github.com> Date: Sun, 31 Dec 2023 17:50:13 +0200 Subject: [PATCH 1/3] add database host transformer --- .../Api/Application/NodeTransformer.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/Transformers/Api/Application/NodeTransformer.php b/app/Transformers/Api/Application/NodeTransformer.php index 093fcc9621..703a385051 100644 --- a/app/Transformers/Api/Application/NodeTransformer.php +++ b/app/Transformers/Api/Application/NodeTransformer.php @@ -14,7 +14,7 @@ class NodeTransformer extends Transformer /** * List of resources that can be included. */ - protected array $availableIncludes = ['allocations', 'location', 'servers']; + protected array $availableIncludes = ['allocations', 'location', 'servers', 'database_host']; /** * Return the resource name for the JSONAPI output. @@ -45,6 +45,18 @@ public function transform(Node $model): array return $response; } + /** + * Return the database host associated with this node. + */ + public function includeDatabaseHost(Node $node): Item|NullResource + { + if (!$this->authorize(AdminAcl::RESOURCE_DATABASE_HOSTS)) { + return $this->null(); + } + + return $this->item($node->databaseHost, new DatabaseHostTransformer()); + } + /** * Return the allocations associated with this node. */ From f3fcd48281ce99a9cec450107823b3a48282dd03 Mon Sep 17 00:00:00 2001 From: Scai <59282365+alexevladgabriel@users.noreply.github.com> Date: Sun, 31 Dec 2023 18:51:21 +0200 Subject: [PATCH 2/3] add node status --- .../components/admin/nodes/NodeStatus.tsx | 29 +++++++++++++++++++ .../components/admin/nodes/NodesContainer.tsx | 19 ++---------- 2 files changed, 31 insertions(+), 17 deletions(-) create mode 100644 resources/scripts/components/admin/nodes/NodeStatus.tsx diff --git a/resources/scripts/components/admin/nodes/NodeStatus.tsx b/resources/scripts/components/admin/nodes/NodeStatus.tsx new file mode 100644 index 0000000000..9b0bf93f62 --- /dev/null +++ b/resources/scripts/components/admin/nodes/NodeStatus.tsx @@ -0,0 +1,29 @@ +import getNodeInformation, { NodeInformation } from '@/api/admin/nodes/getNodeInformation'; +import Tooltip from '@/components/elements/tooltip/Tooltip'; +import { faHeartPulse } from '@fortawesome/free-solid-svg-icons'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { useEffect, useState } from 'react'; +import tw from 'twin.macro'; + +export default function NodeStatus({ node }: { node: number }) { + const [info, setInfo] = useState(null); + useEffect(() => { + const getNodeStatus = async () => { + getNodeInformation(node) + .then(info => setInfo(info)) + .catch(error => { + console.error(error); + }); + }; + getNodeStatus(); + }, []); + + return ( + + + + ); +} diff --git a/resources/scripts/components/admin/nodes/NodesContainer.tsx b/resources/scripts/components/admin/nodes/NodesContainer.tsx index 2ad97ad7fd..e1df424dbe 100644 --- a/resources/scripts/components/admin/nodes/NodesContainer.tsx +++ b/resources/scripts/components/admin/nodes/NodesContainer.tsx @@ -23,6 +23,7 @@ import AdminTable, { import Button from '@/components/elements/Button'; import CopyOnClick from '@/components/elements/CopyOnClick'; import { bytesToString, mbToBytes } from '@/lib/formatters'; +import NodeStatus from '@/components/admin/nodes/NodeStatus'; const RowCheckbox = ({ id }: { id: number }) => { const isChecked = AdminContext.useStoreState(state => state.nodes.selectedNodes.indexOf(id) >= 0); @@ -224,23 +225,7 @@ const NodesContainer = () => { {/* TODO: Change color based off of online/offline status */} - - - + ))} From eff1fa6ea887f7b2302f1d30b42fc124f7a8e6b9 Mon Sep 17 00:00:00 2001 From: Scai <59282365+alexevladgabriel@users.noreply.github.com> Date: Sun, 31 Dec 2023 18:55:40 +0200 Subject: [PATCH 3/3] add button size --- resources/scripts/components/admin/nodes/NodesContainer.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/scripts/components/admin/nodes/NodesContainer.tsx b/resources/scripts/components/admin/nodes/NodesContainer.tsx index e1df424dbe..ea375f1c46 100644 --- a/resources/scripts/components/admin/nodes/NodesContainer.tsx +++ b/resources/scripts/components/admin/nodes/NodesContainer.tsx @@ -24,6 +24,7 @@ import Button from '@/components/elements/Button'; import CopyOnClick from '@/components/elements/CopyOnClick'; import { bytesToString, mbToBytes } from '@/lib/formatters'; import NodeStatus from '@/components/admin/nodes/NodeStatus'; +import { Size } from '@/components/elements/button/types'; const RowCheckbox = ({ id }: { id: number }) => { const isChecked = AdminContext.useStoreState(state => state.nodes.selectedNodes.indexOf(id) >= 0);