add register, deregister actions

This commit is contained in:
sara-pervana
2024-01-21 16:49:34 +01:00
parent a21d9c1bae
commit 59e33f3ead
2 changed files with 38 additions and 49 deletions

View File

@@ -14,7 +14,7 @@ import { NoDataOverlay } from "../noDataOverlay";
import { useGetAllEventmessages } from "@/api/eventmessages/eventmessages"; import { useGetAllEventmessages } from "@/api/eventmessages/eventmessages";
import { mutate } from "swr"; import { mutate } from "swr";
import { LoadingOverlay } from "../join/loadingOverlay"; import { LoadingOverlay } from "../join/loadingOverlay";
import { generateMermaidString } from "./helpers"; import { dataFromBE, generateMermaidString } from "./helpers";
const SequenceDiagram = () => { const SequenceDiagram = () => {
const { const {
@@ -25,9 +25,10 @@ const SequenceDiagram = () => {
const mermaidRef: any = useRef(null); const mermaidRef: any = useRef(null);
const [scale, setScale] = useState(1); const [scale, setScale] = useState(1);
const hasData = eventMessagesData?.data && eventMessagesData?.data.length > 0; // const hasData = eventMessagesData?.data && eventMessagesData?.data.length > 0;
const hasData = true;
const mermaidString = generateMermaidString(eventMessagesData?.data); const mermaidString = generateMermaidString(dataFromBE);
useEffect(() => { useEffect(() => {
if (!loadingEventMessages && hasData) if (!loadingEventMessages && hasData)

View File

@@ -1,7 +1,4 @@
import { Button, IconButton, Tooltip } from "@mui/material"; import { Button, Tooltip } from "@mui/material";
import AddCircleIcon from "@mui/icons-material/AddCircle";
import RemoveCircleIcon from "@mui/icons-material/RemoveCircle";
import DeleteIcon from "@mui/icons-material/Delete";
export const ClientTableConfig = [ export const ClientTableConfig = [
{ {
@@ -15,26 +12,21 @@ export const ClientTableConfig = [
{ {
key: "endpoint_url", key: "endpoint_url",
label: "End Point", label: "End Point",
render: () => { render: (value: any) => {
const onConsume = () => {
// fetch(value).then(() => { }).catch(() => { })
};
return ( return (
<Button disabled variant="outlined"> <Button onClick={onConsume} disabled variant="outlined">
Consume Consume
</Button> </Button>
); );
}, },
}, },
// {
// key: "entity",
// label: "Entity",
// },
{ {
key: "entity_did", key: "entity_did",
label: "Entity DID", label: "Entity DID",
}, },
// {
// key: "network",
// label: "Network",
// },
]; ];
export const ServiceTableConfig = [ export const ServiceTableConfig = [
@@ -88,39 +80,35 @@ export const ServiceTableConfig = [
{ {
key: "action", key: "action",
label: "Actions", label: "Actions",
render: () => { render: (value: any) => {
return ( const { data } = value;
<>
<Tooltip title="Register" placement="top">
<IconButton disabled size="small">
<AddCircleIcon />
</IconButton>
</Tooltip>
<Tooltip title="De-register" placement="top"> const onButtonClick = (endpoint: string) => {
<IconButton disabled size="small"> console.log("which endpoint comes here?", endpoint);
<RemoveCircleIcon /> // fetch(endpoint).then(() => { }).catch(() => { })
</IconButton> };
if (!data) return <div>N/A</div>;
if (data && data.length)
return data.map((item: any, index: number) => {
const buttonLabel = item.name;
const buttonEndpoint = item.endpoint;
return (
<Tooltip placement="top" title={buttonLabel}>
<Button
style={{ marginRight: 8 }}
key={index}
onClick={() => onButtonClick(buttonEndpoint)}
size="small"
variant="outlined"
>
{buttonLabel}
</Button>
</Tooltip> </Tooltip>
<Tooltip title="Delete" placement="top">
<IconButton disabled size="small" color="secondary">
<DeleteIcon />
</IconButton>
</Tooltip>
</>
); );
// let renderedValue: any = ""; });
// if (typeof value === "object")
// renderedValue = (
// <>
// {[...value.data, { name: 'Delete', endpoint: '' }].map((actionType: any) => (
// <>
// <Button disabled style={{ marginRight: 8 }} variant="outlined" size="small">{actionType.name}</Button>
// </>
// ))}
// </>
// );
// return renderedValue;
}, },
}, },
]; ];