generated from Luis/nextjs-python-web-template
Before Milestone Meeting Final Changes #40
@@ -266,7 +266,7 @@ def test_entity(api: TestClient) -> None:
|
|||||||
request_body = {
|
request_body = {
|
||||||
"did": default_entity_did,
|
"did": default_entity_did,
|
||||||
"name": "C1",
|
"name": "C1",
|
||||||
"ip": "127.0.0.1",
|
"ip": "127.0.0.1:5555",
|
||||||
"attached": False,
|
"attached": False,
|
||||||
"visible": True,
|
"visible": True,
|
||||||
"other": {
|
"other": {
|
||||||
@@ -283,7 +283,7 @@ def test_entity2(api: TestClient) -> None:
|
|||||||
request_body = {
|
request_body = {
|
||||||
"did": default_entity_did2,
|
"did": default_entity_did2,
|
||||||
"name": "C2",
|
"name": "C2",
|
||||||
"ip": "127.0.0.2",
|
"ip": "127.0.0.1:5555",
|
||||||
"attached": False,
|
"attached": False,
|
||||||
"visible": True,
|
"visible": True,
|
||||||
"other": {
|
"other": {
|
||||||
|
|||||||
@@ -1,56 +1,77 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import { mutate } from "swr";
|
||||||
|
import { useGetAttachedEntities } from "@/api/entities/entities";
|
||||||
|
import { useGetRepositories } from "@/api/repositories/repositories";
|
||||||
import SummaryDetails from "@/components/summary_card";
|
import SummaryDetails from "@/components/summary_card";
|
||||||
import CustomTable from "@/components/table";
|
import CustomTable from "@/components/table";
|
||||||
import {
|
import {
|
||||||
APSummaryDetails,
|
APSummaryDetails,
|
||||||
APAttachmentsDummyData,
|
|
||||||
APAttachmentsTableConfig,
|
APAttachmentsTableConfig,
|
||||||
APServiceRepositoryTableConfig,
|
APServiceRepositoryTableConfig,
|
||||||
} from "@/mock/access_point";
|
} from "@/config/access_point";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect } from "react";
|
||||||
|
|
||||||
interface RepositoryData {
|
|
||||||
entity_name: string;
|
|
||||||
entity_did: string;
|
|
||||||
network: string;
|
|
||||||
ip_address: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function AccessPoint() {
|
export default function AccessPoint() {
|
||||||
const [repositoryData, setRepositoryData] = useState<RepositoryData[]>([]);
|
const {
|
||||||
|
data: APAttachementData,
|
||||||
|
isLoading: loadingAttachements,
|
||||||
|
swrKey: attachedEntitiesKeyFunc,
|
||||||
|
} = useGetAttachedEntities();
|
||||||
|
const {
|
||||||
|
data: APRepositories,
|
||||||
|
isLoading: laodingRepositories,
|
||||||
|
swrKey: repositoriesKeyFunc,
|
||||||
|
} = useGetRepositories();
|
||||||
|
|
||||||
|
const onRefresh = () => {
|
||||||
|
const attachedEntitiesKey =
|
||||||
|
typeof attachedEntitiesKeyFunc === "function"
|
||||||
|
? attachedEntitiesKeyFunc()
|
||||||
|
: attachedEntitiesKeyFunc;
|
||||||
|
const repositoriesKey =
|
||||||
|
typeof repositoriesKeyFunc === "function"
|
||||||
|
? repositoriesKeyFunc()
|
||||||
|
: repositoriesKeyFunc;
|
||||||
|
|
||||||
|
if (attachedEntitiesKey) {
|
||||||
|
mutate(attachedEntitiesKey);
|
||||||
|
}
|
||||||
|
if (repositoriesKey) {
|
||||||
|
mutate(repositoriesKey);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch("http://localhost:2979/api/v1/get_repositories", {
|
const interval = setInterval(() => {
|
||||||
method: "GET",
|
onRefresh();
|
||||||
})
|
}, 1000);
|
||||||
.then((resp) =>
|
|
||||||
resp.json().then((jsonData) => {
|
return () => clearInterval(interval);
|
||||||
console.log(jsonData);
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
setRepositoryData(jsonData);
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.then()
|
|
||||||
.catch();
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="m-10">
|
<div className="m-10">
|
||||||
<SummaryDetails
|
<SummaryDetails
|
||||||
|
fake
|
||||||
hasRefreshButton
|
hasRefreshButton
|
||||||
|
onRefresh={onRefresh}
|
||||||
entity={{ name: "Access Point", details: APSummaryDetails }}
|
entity={{ name: "Access Point", details: APSummaryDetails }}
|
||||||
/>
|
/>
|
||||||
<div>
|
<div>
|
||||||
<h4>Attachment View</h4>
|
<h4>Attachment View</h4>
|
||||||
<CustomTable
|
<CustomTable
|
||||||
data={APAttachmentsDummyData}
|
loading={loadingAttachements}
|
||||||
|
data={APAttachementData?.data}
|
||||||
configuration={APAttachmentsTableConfig}
|
configuration={APAttachmentsTableConfig}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h4>Service Repository View </h4>
|
<h4>Service Repository View </h4>
|
||||||
<CustomTable
|
<CustomTable
|
||||||
data={repositoryData}
|
loading={laodingRepositories}
|
||||||
|
data={APRepositories?.data}
|
||||||
configuration={APServiceRepositoryTableConfig}
|
configuration={APServiceRepositoryTableConfig}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,68 +1,168 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
import { useEffect, useRef, useState } from "react";
|
||||||
import SummaryDetails from "@/components/summary_card";
|
|
||||||
import {
|
import {
|
||||||
Client1SummaryDetails,
|
|
||||||
Client1ConsumerTableConfig,
|
Client1ConsumerTableConfig,
|
||||||
Client1ProducerTableConfig,
|
Client1ProducerTableConfig,
|
||||||
} from "@/mock/client_1";
|
} from "@/config/client_1";
|
||||||
import CustomTable from "@/components/table";
|
import CustomTable from "@/components/table";
|
||||||
import { useEffect, useState } from "react";
|
import useGetEntityByName from "@/components/hooks/useGetEntityById";
|
||||||
|
import {
|
||||||
|
Alert,
|
||||||
|
Button,
|
||||||
|
Card,
|
||||||
|
CardContent,
|
||||||
|
CardHeader,
|
||||||
|
Skeleton,
|
||||||
|
Snackbar,
|
||||||
|
Typography,
|
||||||
|
} from "@mui/material";
|
||||||
|
import CopyToClipboard from "@/components/copy_to_clipboard";
|
||||||
|
import { mutate } from "swr";
|
||||||
|
import { useGetEntity } from "@/api/entities/entities";
|
||||||
|
import { BASE_URL } from "@/constants";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
export default function Client1() {
|
export default function Client1() {
|
||||||
const [consumerData, setConsumerData] = useState([]);
|
const { entity } = useGetEntityByName("C1");
|
||||||
const [producerData, setProducerData] = useState([]);
|
const {
|
||||||
|
data: client1,
|
||||||
|
isLoading,
|
||||||
|
swrKey: entityKeyFunc,
|
||||||
|
} = useGetEntity({ entity_did: entity?.did });
|
||||||
|
const cardContentRef = useRef(null);
|
||||||
|
const [isAttached, setIsAttached] = useState(entity?.attached || false);
|
||||||
|
const [snackbarOpen, setSnackbarOpen] = useState(false);
|
||||||
|
const [snackbarMessage, setSnackbarMessage] = useState("");
|
||||||
|
|
||||||
|
const closeSnackBar = () => {
|
||||||
|
setSnackbarMessage("");
|
||||||
|
setSnackbarOpen(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onAttachEntity = async () => {
|
||||||
|
try {
|
||||||
|
const response = await axios.post(`${BASE_URL}/attach`, {
|
||||||
|
entity_did: entity?.did,
|
||||||
|
});
|
||||||
|
setSnackbarMessage(response.data.message);
|
||||||
|
setSnackbarOpen(true);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
} finally {
|
||||||
|
setIsAttached(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const onDetachEntity = async () => {
|
||||||
|
try {
|
||||||
|
const response = await axios.post(`${BASE_URL}/detach`, {
|
||||||
|
entity_did: entity?.did,
|
||||||
|
});
|
||||||
|
console.log(response);
|
||||||
|
setSnackbarMessage("Entity detached successfully.");
|
||||||
|
setSnackbarOpen(true);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
} finally {
|
||||||
|
setIsAttached(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const onRefresh = () => {
|
||||||
|
const entityKey =
|
||||||
|
typeof entityKeyFunc === "function" ? entityKeyFunc() : entityKeyFunc;
|
||||||
|
if (entityKey) mutate(entityKey);
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch("http://localhost:2979/api/v1/get_consumers", {
|
const interval = setInterval(() => {
|
||||||
method: "GET",
|
onRefresh();
|
||||||
})
|
}, 1000);
|
||||||
.then((resp) =>
|
|
||||||
resp.json().then((jsonData) => {
|
|
||||||
console.log(jsonData);
|
|
||||||
setConsumerData(jsonData);
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.then()
|
|
||||||
.catch();
|
|
||||||
|
|
||||||
fetch("http://localhost:2979/api/v1/get_producers", {
|
return () => clearInterval(interval);
|
||||||
method: "GET",
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
})
|
|
||||||
.then((resp) =>
|
|
||||||
resp.json().then((jsonData) => {
|
|
||||||
console.log(jsonData);
|
|
||||||
setProducerData(jsonData);
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.then()
|
|
||||||
.catch();
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
if (isLoading) return <Skeleton height={500} />;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="m-10">
|
<div className="m-10">
|
||||||
<SummaryDetails
|
<div
|
||||||
hasAttachDetach
|
style={{
|
||||||
hasRefreshButton
|
display: "flex",
|
||||||
entity={{
|
alignItems: "center",
|
||||||
name: "Client 1",
|
justifyContent: "space-between",
|
||||||
details: Client1SummaryDetails,
|
|
||||||
}}
|
}}
|
||||||
/>
|
>
|
||||||
|
<h2>Client 1</h2>
|
||||||
|
<div>
|
||||||
|
{isAttached === false ? (
|
||||||
|
<Button
|
||||||
|
onClick={onAttachEntity}
|
||||||
|
className="mr-6"
|
||||||
|
variant="contained"
|
||||||
|
>
|
||||||
|
Attach
|
||||||
|
</Button>
|
||||||
|
) : (
|
||||||
|
<Button
|
||||||
|
onClick={onDetachEntity}
|
||||||
|
className="mr-6"
|
||||||
|
variant="contained"
|
||||||
|
>
|
||||||
|
Detach
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Button onClick={onRefresh} variant="contained">
|
||||||
|
Refresh
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Card variant="outlined">
|
||||||
|
<CardHeader
|
||||||
|
subheader="Summary"
|
||||||
|
action={<CopyToClipboard contentRef={cardContentRef} />}
|
||||||
|
/>
|
||||||
|
<CardContent ref={cardContentRef}>
|
||||||
|
<Typography color="text.primary" gutterBottom>
|
||||||
|
DID: <code>{client1?.data?.did}</code>
|
||||||
|
</Typography>
|
||||||
|
<Typography color="text.primary" gutterBottom>
|
||||||
|
IP: <code>{client1?.data?.ip}</code>
|
||||||
|
</Typography>
|
||||||
|
<Typography color="text.primary" gutterBottom>
|
||||||
|
Network: <code>{client1?.data?.other?.network}</code>
|
||||||
|
</Typography>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
<div>
|
<div>
|
||||||
<h4>Consumer View</h4>
|
<h4>Consumer View</h4>
|
||||||
<CustomTable
|
<CustomTable
|
||||||
data={consumerData}
|
loading={isLoading}
|
||||||
|
data={client1?.data?.producers}
|
||||||
configuration={Client1ConsumerTableConfig}
|
configuration={Client1ConsumerTableConfig}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h4>Producer View</h4>
|
<h4>Producer View</h4>
|
||||||
<CustomTable
|
<CustomTable
|
||||||
data={producerData}
|
loading={isLoading}
|
||||||
|
data={client1?.data?.producers}
|
||||||
configuration={Client1ProducerTableConfig}
|
configuration={Client1ProducerTableConfig}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<Snackbar
|
||||||
|
onClose={closeSnackBar}
|
||||||
|
anchorOrigin={{ vertical: "top", horizontal: "center" }}
|
||||||
|
open={snackbarOpen}
|
||||||
|
autoHideDuration={1000}
|
||||||
|
>
|
||||||
|
<Alert severity="success" sx={{ width: "100%" }}>
|
||||||
|
{snackbarMessage}
|
||||||
|
</Alert>
|
||||||
|
</Snackbar>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,69 +1,165 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
import { useEffect, useRef, useState } from "react";
|
||||||
import SummaryDetails from "@/components/summary_card";
|
|
||||||
import {
|
import {
|
||||||
Client2ConsumerTableConfig,
|
Client2ConsumerTableConfig,
|
||||||
Client2ProducerTableConfig,
|
Client2ProducerTableConfig,
|
||||||
Client2SummaryDetails,
|
} from "@/config/client_2";
|
||||||
} from "@/mock/client_2";
|
|
||||||
import CustomTable from "@/components/table";
|
import CustomTable from "@/components/table";
|
||||||
import { useEffect, useState } from "react";
|
import useGetEntityByName from "@/components/hooks/useGetEntityById";
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Card,
|
||||||
|
CardContent,
|
||||||
|
CardHeader,
|
||||||
|
Skeleton,
|
||||||
|
Typography,
|
||||||
|
Snackbar,
|
||||||
|
Alert,
|
||||||
|
} from "@mui/material";
|
||||||
|
import CopyToClipboard from "@/components/copy_to_clipboard";
|
||||||
|
import { useGetEntity } from "@/api/entities/entities";
|
||||||
|
import { mutate } from "swr";
|
||||||
|
import axios from "axios";
|
||||||
|
import { BASE_URL } from "@/constants";
|
||||||
|
|
||||||
export default function Client1() {
|
export default function Client2() {
|
||||||
const [consumerData, setConsumerData] = useState([]);
|
const { entity } = useGetEntityByName("C2");
|
||||||
const [producerData, setProducerData] = useState([]);
|
const {
|
||||||
|
data: client2,
|
||||||
|
isLoading,
|
||||||
|
swrKey: entityKeyFunc,
|
||||||
|
} = useGetEntity({ entity_did: entity?.did });
|
||||||
|
const cardContentRef = useRef(null);
|
||||||
|
const [isAttached, setIsAttached] = useState(entity?.attached);
|
||||||
|
const [snackbarOpen, setSnackbarOpen] = useState(false);
|
||||||
|
const [snackbarMessage, setSnackbarMessage] = useState("");
|
||||||
|
|
||||||
|
const closeSnackBar = () => {
|
||||||
|
setSnackbarMessage("");
|
||||||
|
setSnackbarOpen(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onAttachEntity = async () => {
|
||||||
|
try {
|
||||||
|
const response = await axios.post(`${BASE_URL}/attach`, {
|
||||||
|
entity_did: entity?.did,
|
||||||
|
});
|
||||||
|
alert(response.data.message);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
} finally {
|
||||||
|
setIsAttached(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const onDetachEntity = async () => {
|
||||||
|
try {
|
||||||
|
const response = await axios.post(`${BASE_URL}/detach`, {
|
||||||
|
entity_did: entity?.did,
|
||||||
|
});
|
||||||
|
console.log("detach", response);
|
||||||
|
alert("Entity Detached Successfully.");
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
} finally {
|
||||||
|
setIsAttached(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const onRefresh = () => {
|
||||||
|
const entityKey =
|
||||||
|
typeof entityKeyFunc === "function" ? entityKeyFunc() : entityKeyFunc;
|
||||||
|
if (entityKey) mutate(entityKey);
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch("http://localhost:2979/api/v1/get_consumers", {
|
const interval = setInterval(() => {
|
||||||
method: "GET",
|
onRefresh();
|
||||||
})
|
}, 1000);
|
||||||
.then((resp) =>
|
|
||||||
resp.json().then((jsonData) => {
|
|
||||||
console.log(jsonData);
|
|
||||||
setConsumerData(jsonData);
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.then()
|
|
||||||
.catch();
|
|
||||||
|
|
||||||
fetch("http://localhost:2979/api/v1/get_producers", {
|
return () => clearInterval(interval);
|
||||||
method: "GET",
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
// credentials: 'include',
|
|
||||||
})
|
|
||||||
.then((resp) =>
|
|
||||||
resp.json().then((jsonData) => {
|
|
||||||
console.log(jsonData);
|
|
||||||
setProducerData(jsonData);
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.then()
|
|
||||||
.catch();
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
if (isLoading) return <Skeleton height={500} />;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="m-10">
|
<div className="m-10">
|
||||||
<SummaryDetails
|
<div
|
||||||
hasAttachDetach
|
style={{
|
||||||
hasRefreshButton
|
display: "flex",
|
||||||
entity={{
|
alignItems: "center",
|
||||||
name: "Client 2",
|
justifyContent: "space-between",
|
||||||
details: Client2SummaryDetails,
|
|
||||||
}}
|
}}
|
||||||
/>
|
>
|
||||||
|
<h2>Client 2</h2>
|
||||||
|
<div>
|
||||||
|
{isAttached === false ? (
|
||||||
|
<Button
|
||||||
|
onClick={onAttachEntity}
|
||||||
|
className="mr-6"
|
||||||
|
variant="contained"
|
||||||
|
>
|
||||||
|
Attach
|
||||||
|
</Button>
|
||||||
|
) : (
|
||||||
|
<Button
|
||||||
|
onClick={onDetachEntity}
|
||||||
|
className="mr-6"
|
||||||
|
variant="contained"
|
||||||
|
>
|
||||||
|
Detach
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
<Button onClick={onRefresh} variant="contained">
|
||||||
|
Refresh
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Card variant="outlined">
|
||||||
|
<CardHeader
|
||||||
|
subheader="Summary"
|
||||||
|
action={<CopyToClipboard contentRef={cardContentRef} />}
|
||||||
|
/>
|
||||||
|
<CardContent ref={cardContentRef}>
|
||||||
|
<Typography color="text.primary" gutterBottom>
|
||||||
|
DID: <code>{client2?.data?.did}</code>
|
||||||
|
</Typography>
|
||||||
|
<Typography color="text.primary" gutterBottom>
|
||||||
|
IP: <code>{client2?.data?.ip}</code>
|
||||||
|
</Typography>
|
||||||
|
<Typography color="text.primary" gutterBottom>
|
||||||
|
Network: <code>{client2?.data?.other?.network}</code>
|
||||||
|
</Typography>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
<div>
|
<div>
|
||||||
<h4>Consumer View</h4>
|
<h4>Consumer View</h4>
|
||||||
<CustomTable
|
<CustomTable
|
||||||
data={consumerData}
|
loading={isLoading}
|
||||||
|
data={client2?.data?.producers}
|
||||||
configuration={Client2ConsumerTableConfig}
|
configuration={Client2ConsumerTableConfig}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h4>Producer View</h4>
|
<h4>Producer View</h4>
|
||||||
<CustomTable
|
<CustomTable
|
||||||
data={producerData}
|
loading={isLoading}
|
||||||
|
data={client2?.data?.producers}
|
||||||
configuration={Client2ProducerTableConfig}
|
configuration={Client2ProducerTableConfig}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<Snackbar
|
||||||
|
onClose={closeSnackBar}
|
||||||
|
anchorOrigin={{ vertical: "top", horizontal: "center" }}
|
||||||
|
open={snackbarOpen}
|
||||||
|
autoHideDuration={1000}
|
||||||
|
>
|
||||||
|
<Alert severity="success" sx={{ width: "100%" }}>
|
||||||
|
{snackbarMessage}
|
||||||
|
</Alert>
|
||||||
|
</Snackbar>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,37 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { DLGResolutionTableConfig, DLGSummaryDetails } from "@/mock/dlg";
|
import { DLGResolutionTableConfig, DLGSummaryDetails } from "@/config/dlg";
|
||||||
import CustomTable from "@/components/table";
|
import CustomTable from "@/components/table";
|
||||||
import SummaryDetails from "@/components/summary_card";
|
import SummaryDetails from "@/components/summary_card";
|
||||||
import { useEffect, useState } from "react";
|
import useFetch from "@/components/hooks/useFetch";
|
||||||
|
import { useEffect } from "react";
|
||||||
|
|
||||||
export default function DLG() {
|
export default function DLG() {
|
||||||
const [resolutionData, setResolutionData] = useState([]);
|
const {
|
||||||
|
data: resolutionData,
|
||||||
|
loading: loadingResolutions,
|
||||||
|
fetch,
|
||||||
|
} = useFetch("/get_resolutions");
|
||||||
|
|
||||||
|
const onRefresh = () => {
|
||||||
|
fetch();
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch("http://localhost:2979/api/v1/get_resolutions", {
|
const interval = setInterval(() => {
|
||||||
method: "GET",
|
onRefresh();
|
||||||
})
|
}, 5000);
|
||||||
.then((resp) =>
|
|
||||||
resp.json().then((jsonData) => {
|
return () => clearInterval(interval);
|
||||||
console.log(jsonData);
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
setResolutionData(jsonData);
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.then()
|
|
||||||
.catch();
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="m-10">
|
<div className="m-10">
|
||||||
<SummaryDetails
|
<SummaryDetails
|
||||||
|
fake
|
||||||
hasRefreshButton
|
hasRefreshButton
|
||||||
|
onRefresh={onRefresh}
|
||||||
entity={{
|
entity={{
|
||||||
name: "Distributed Ledger Gateway",
|
name: "Distributed Ledger Gateway",
|
||||||
details: DLGSummaryDetails,
|
details: DLGSummaryDetails,
|
||||||
@@ -34,6 +40,7 @@ export default function DLG() {
|
|||||||
<div>
|
<div>
|
||||||
<h4>DID Resolution View</h4>
|
<h4>DID Resolution View</h4>
|
||||||
<CustomTable
|
<CustomTable
|
||||||
|
loading={loadingResolutions}
|
||||||
data={resolutionData}
|
data={resolutionData}
|
||||||
configuration={DLGResolutionTableConfig}
|
configuration={DLGResolutionTableConfig}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,39 +1,51 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import { useAppState } from "@/components/hooks/useAppContext";
|
||||||
import { NoDataOverlay } from "@/components/noDataOverlay";
|
import { NoDataOverlay } from "@/components/noDataOverlay";
|
||||||
import SummaryDetails from "@/components/summary_card";
|
import SummaryDetails from "@/components/summary_card";
|
||||||
import CustomTable from "@/components/table";
|
import CustomTable from "@/components/table";
|
||||||
import { HomeTableConfig } from "@/mock/home";
|
import { HomeTableConfig } from "@/config/home";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect } from "react";
|
||||||
|
import { mutate } from "swr";
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
const [homeData, setHomeData] = useState([]);
|
const { data } = useAppState();
|
||||||
|
|
||||||
|
const entitiesKeyFunc = data.entitiesKeyFunc;
|
||||||
|
|
||||||
|
const onRefresh = () => {
|
||||||
|
const entityKey =
|
||||||
|
typeof entitiesKeyFunc === "function"
|
||||||
|
? entitiesKeyFunc()
|
||||||
|
: entitiesKeyFunc;
|
||||||
|
if (entitiesKeyFunc) mutate(entityKey);
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch("http://localhost:2979/api/v1/get_entities", {
|
const interval = setInterval(() => {
|
||||||
method: "GET",
|
onRefresh();
|
||||||
})
|
}, 500);
|
||||||
.then((resp) =>
|
|
||||||
resp.json().then((jsonData) => {
|
return () => clearInterval(interval);
|
||||||
console.log(jsonData);
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
setHomeData(jsonData);
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.then()
|
|
||||||
.catch();
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="m-10">
|
<div className="m-10">
|
||||||
<SummaryDetails
|
<SummaryDetails
|
||||||
entity={{ name: "Home", details: [] }}
|
entity={{ name: "Home", details: [] }}
|
||||||
hasRefreshButton={false}
|
hasRefreshButton={true}
|
||||||
|
onRefresh={onRefresh}
|
||||||
hasAttachDetach={false}
|
hasAttachDetach={false}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<h4>Home View Table</h4>
|
<h4>Home View Table</h4>
|
||||||
<CustomTable data={homeData} configuration={HomeTableConfig} />
|
<CustomTable
|
||||||
|
loading={data.loadingEntities}
|
||||||
|
data={data?.allEntities}
|
||||||
|
configuration={HomeTableConfig}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { useGetEntities } from "@/api/entities/entities";
|
||||||
|
import { Entity } from "@/api/model";
|
||||||
import { AxiosError } from "axios";
|
import { AxiosError } from "axios";
|
||||||
import React, {
|
import React, {
|
||||||
createContext,
|
createContext,
|
||||||
@@ -5,6 +7,7 @@ import React, {
|
|||||||
ReactNode,
|
ReactNode,
|
||||||
SetStateAction,
|
SetStateAction,
|
||||||
useState,
|
useState,
|
||||||
|
useEffect,
|
||||||
} from "react";
|
} from "react";
|
||||||
|
|
||||||
type AppContextType = {
|
type AppContextType = {
|
||||||
@@ -18,7 +21,11 @@ type AppContextType = {
|
|||||||
|
|
||||||
export const AppContext = createContext<AppContextType>({} as AppContextType);
|
export const AppContext = createContext<AppContextType>({} as AppContextType);
|
||||||
|
|
||||||
type AppState = NonNullable<unknown>;
|
type AppState = {
|
||||||
|
allEntities: Entity[] | undefined;
|
||||||
|
loadingEntities: boolean;
|
||||||
|
entitiesKeyFunc: any;
|
||||||
|
};
|
||||||
|
|
||||||
interface AppContextProviderProps {
|
interface AppContextProviderProps {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
@@ -26,10 +33,28 @@ interface AppContextProviderProps {
|
|||||||
export const WithAppState = (props: AppContextProviderProps) => {
|
export const WithAppState = (props: AppContextProviderProps) => {
|
||||||
const { children } = props;
|
const { children } = props;
|
||||||
|
|
||||||
|
const { data: entityData, swrKey: entitiesKeyFunc } = useGetEntities();
|
||||||
|
|
||||||
const isLoading = false;
|
const isLoading = false;
|
||||||
const error = undefined;
|
const error = undefined;
|
||||||
|
|
||||||
const [data, setAppState] = useState<AppState>({});
|
const [data, setAppState] = useState<AppState>({
|
||||||
|
allEntities: [],
|
||||||
|
loadingEntities: true,
|
||||||
|
entitiesKeyFunc,
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (entityData) {
|
||||||
|
setAppState((prevState) => ({
|
||||||
|
...prevState,
|
||||||
|
allEntities: entityData.data,
|
||||||
|
entitiesKeyFunc,
|
||||||
|
loadingEntities: false,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [entityData]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppContext.Provider
|
<AppContext.Provider
|
||||||
|
|||||||
33
pkgs/ui/src/components/hooks/useFetch.tsx
Normal file
33
pkgs/ui/src/components/hooks/useFetch.tsx
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import { useState, useEffect } from "react";
|
||||||
|
import axios from "axios";
|
||||||
|
import { BASE_URL } from "@/constants";
|
||||||
|
|
||||||
|
const useFetch = (url: string) => {
|
||||||
|
const [data, setData] = useState([]);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [error, setError] = useState(null);
|
||||||
|
|
||||||
|
const fetch = () => {
|
||||||
|
setLoading(true);
|
||||||
|
axios
|
||||||
|
.get(BASE_URL + url)
|
||||||
|
.then((response) => {
|
||||||
|
setData(response.data);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
setError(error);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetch();
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [url]);
|
||||||
|
|
||||||
|
return { data, loading, error, fetch };
|
||||||
|
};
|
||||||
|
|
||||||
|
export default useFetch;
|
||||||
19
pkgs/ui/src/components/hooks/useGetEntityById.tsx
Normal file
19
pkgs/ui/src/components/hooks/useGetEntityById.tsx
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import { useContext } from "react";
|
||||||
|
import { AppContext } from "./useAppContext";
|
||||||
|
|
||||||
|
const useGetEntityByName = (nameOrDid: string) => {
|
||||||
|
const { data } = useContext(AppContext);
|
||||||
|
const allEntities = data.allEntities;
|
||||||
|
|
||||||
|
if (!allEntities) {
|
||||||
|
return { entity: undefined, isLoading: true };
|
||||||
|
}
|
||||||
|
|
||||||
|
const entity = allEntities.find(
|
||||||
|
(entity) => entity.name === nameOrDid || entity.did === nameOrDid,
|
||||||
|
);
|
||||||
|
|
||||||
|
return { entity, isLoading: false };
|
||||||
|
};
|
||||||
|
|
||||||
|
export default useGetEntityByName;
|
||||||
@@ -14,6 +14,8 @@ const SummaryDetails = ({
|
|||||||
entity,
|
entity,
|
||||||
hasRefreshButton,
|
hasRefreshButton,
|
||||||
hasAttachDetach,
|
hasAttachDetach,
|
||||||
|
fake,
|
||||||
|
onRefresh,
|
||||||
}: ISummaryDetails) => {
|
}: ISummaryDetails) => {
|
||||||
const cardContentRef = useRef(null);
|
const cardContentRef = useRef(null);
|
||||||
const hasDetails = entity.details && entity.details.length > 0;
|
const hasDetails = entity.details && entity.details.length > 0;
|
||||||
@@ -34,13 +36,17 @@ const SummaryDetails = ({
|
|||||||
Attach / Detach
|
Attach / Detach
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{hasRefreshButton && <Button variant="contained">Refresh</Button>}
|
{hasRefreshButton && (
|
||||||
|
<Button onClick={onRefresh} variant="contained">
|
||||||
|
Refresh
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{hasDetails && (
|
{hasDetails && (
|
||||||
<Card variant="outlined">
|
<Card variant="outlined">
|
||||||
<CardHeader
|
<CardHeader
|
||||||
subheader="Summary"
|
subheader={fake ? "Summary (Fake Data)" : "Summary"}
|
||||||
action={<CopyToClipboard contentRef={cardContentRef} />}
|
action={<CopyToClipboard contentRef={cardContentRef} />}
|
||||||
/>
|
/>
|
||||||
<CardContent ref={cardContentRef}>
|
<CardContent ref={cardContentRef}>
|
||||||
|
|||||||
@@ -9,9 +9,12 @@ import Paper from "@mui/material/Paper";
|
|||||||
import { NoDataOverlay } from "@/components/noDataOverlay";
|
import { NoDataOverlay } from "@/components/noDataOverlay";
|
||||||
import { StyledTableCell, StyledTableRow } from "./style";
|
import { StyledTableCell, StyledTableRow } from "./style";
|
||||||
import { ICustomTable, CustomTableConfiguration } from "@/types";
|
import { ICustomTable, CustomTableConfiguration } from "@/types";
|
||||||
import { Checkbox } from "@mui/material";
|
import { Checkbox, Skeleton } from "@mui/material";
|
||||||
|
|
||||||
|
const CustomTable = ({ configuration, data, loading }: ICustomTable) => {
|
||||||
|
if (loading)
|
||||||
|
return <Skeleton variant="rectangular" animation="wave" height={200} />;
|
||||||
|
|
||||||
const CustomTable = ({ configuration, data }: ICustomTable) => {
|
|
||||||
// display empty icon in case there is no data
|
// display empty icon in case there is no data
|
||||||
if (!data || data.length === 0)
|
if (!data || data.length === 0)
|
||||||
return <NoDataOverlay label="No Activity yet" />;
|
return <NoDataOverlay label="No Activity yet" />;
|
||||||
|
|||||||
80
pkgs/ui/src/config/access_point/index.tsx
Normal file
80
pkgs/ui/src/config/access_point/index.tsx
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
// AP - Summary
|
||||||
|
|
||||||
|
export const APSummaryDetails = [
|
||||||
|
{
|
||||||
|
label: "DID",
|
||||||
|
value: "did:sov:test:1274",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "IP",
|
||||||
|
value: "127.0.0.2",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Network",
|
||||||
|
value: "Carlo's Home Network",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const APAttachmentsTableConfig = [
|
||||||
|
{
|
||||||
|
key: "name",
|
||||||
|
label: "Entity name",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "did",
|
||||||
|
label: "Entity DID",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "other",
|
||||||
|
label: "Network",
|
||||||
|
render: (value: any) => {
|
||||||
|
let renderedValue = "";
|
||||||
|
if (typeof value === "object") renderedValue = value?.network;
|
||||||
|
return renderedValue;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "ip",
|
||||||
|
label: "IP address",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const APServiceRepositoryTableConfig = [
|
||||||
|
{
|
||||||
|
key: "service_name",
|
||||||
|
label: "Service name",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "service_type",
|
||||||
|
label: "Service type",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "endpoint_url",
|
||||||
|
label: "End point",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "entity_did",
|
||||||
|
label: "Entity DID",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "status",
|
||||||
|
label: "Status",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "other",
|
||||||
|
label: "Type",
|
||||||
|
render: (value: any) => {
|
||||||
|
let renderedValue: any = "";
|
||||||
|
if (typeof value === "object") {
|
||||||
|
const label = Object.keys(value)[0];
|
||||||
|
const info = value[label];
|
||||||
|
renderedValue = (
|
||||||
|
<code>
|
||||||
|
{label} {info}
|
||||||
|
</code>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return renderedValue;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
77
pkgs/ui/src/config/client_1/index.tsx
Normal file
77
pkgs/ui/src/config/client_1/index.tsx
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
import { Button } from "@mui/material";
|
||||||
|
|
||||||
|
export const Client1ConsumerTableConfig = [
|
||||||
|
{
|
||||||
|
key: "service_name",
|
||||||
|
label: "Service name",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "service_type",
|
||||||
|
label: "Service Type",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "endpoint_url",
|
||||||
|
label: "End Point",
|
||||||
|
render: () => {
|
||||||
|
return (
|
||||||
|
<Button disabled variant="outlined">
|
||||||
|
Consume
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// key: "entity",
|
||||||
|
// label: "Entity",
|
||||||
|
// },
|
||||||
|
{
|
||||||
|
key: "entity_did",
|
||||||
|
label: "Entity DID",
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// key: "network",
|
||||||
|
// label: "Network",
|
||||||
|
// },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const Client1ProducerTableConfig = [
|
||||||
|
{
|
||||||
|
key: "service_name",
|
||||||
|
label: "Service name",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "service_type",
|
||||||
|
label: "Service Type",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "endpoint_url",
|
||||||
|
label: "End Point",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "entity_did",
|
||||||
|
label: "Entity DID",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "status",
|
||||||
|
label: "Status",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "other",
|
||||||
|
label: "Action",
|
||||||
|
render: (value: any) => {
|
||||||
|
let renderedValue: any = "";
|
||||||
|
if (typeof value === "object")
|
||||||
|
renderedValue = (
|
||||||
|
<>
|
||||||
|
{value.action.map((actionType: string) => (
|
||||||
|
<>
|
||||||
|
<code>{actionType}</code>
|
||||||
|
<br />
|
||||||
|
</>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
return renderedValue;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
77
pkgs/ui/src/config/client_2/index.tsx
Normal file
77
pkgs/ui/src/config/client_2/index.tsx
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
import { Button } from "@mui/material";
|
||||||
|
|
||||||
|
export const Client2ConsumerTableConfig = [
|
||||||
|
{
|
||||||
|
key: "service_name",
|
||||||
|
label: "Service name",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "service_type",
|
||||||
|
label: "Service Type",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "endpoint_url",
|
||||||
|
label: "End Point",
|
||||||
|
render: () => {
|
||||||
|
return (
|
||||||
|
<Button disabled variant="outlined">
|
||||||
|
Consume
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// key: "entity",
|
||||||
|
// label: "Entity",
|
||||||
|
// },
|
||||||
|
{
|
||||||
|
key: "entity_did",
|
||||||
|
label: "Entity DID",
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// key: "network",
|
||||||
|
// label: "Network",
|
||||||
|
// },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const Client2ProducerTableConfig = [
|
||||||
|
{
|
||||||
|
key: "service_name",
|
||||||
|
label: "Service name",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "service_type",
|
||||||
|
label: "Service Type",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "endpoint_url",
|
||||||
|
label: "End Point",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "entity_did",
|
||||||
|
label: "Entity DID",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "status",
|
||||||
|
label: "Status",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "other",
|
||||||
|
label: "Action",
|
||||||
|
render: (value: any) => {
|
||||||
|
let renderedValue: any = "";
|
||||||
|
if (typeof value === "object")
|
||||||
|
renderedValue = (
|
||||||
|
<>
|
||||||
|
{value.action.map((actionType: string) => (
|
||||||
|
<>
|
||||||
|
<code>{actionType}</code>
|
||||||
|
<br />
|
||||||
|
</>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
return renderedValue;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
// DLG Summary Details
|
// DLG Summary Details
|
||||||
|
|
||||||
|
import { formatDateTime } from "@/utils/helpers";
|
||||||
|
|
||||||
export const DLGSummaryDetails = [
|
export const DLGSummaryDetails = [
|
||||||
{
|
{
|
||||||
label: "DID",
|
label: "DID",
|
||||||
@@ -44,5 +46,6 @@ export const DLGResolutionTableConfig = [
|
|||||||
{
|
{
|
||||||
key: "timestamp",
|
key: "timestamp",
|
||||||
label: "Timestamp",
|
label: "Timestamp",
|
||||||
|
render: (value: string) => formatDateTime(value),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
35
pkgs/ui/src/config/home/index.ts
Normal file
35
pkgs/ui/src/config/home/index.ts
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
export const HomeTableConfig = [
|
||||||
|
{
|
||||||
|
key: "name",
|
||||||
|
label: "Entity name",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "did",
|
||||||
|
label: "Entity DID",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "other",
|
||||||
|
label: "Network",
|
||||||
|
render: (value: any) => {
|
||||||
|
const renderedValue = typeof value === "object" ? value?.network : "-";
|
||||||
|
return renderedValue;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "ip",
|
||||||
|
label: "IP address",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "other",
|
||||||
|
label: "Roles",
|
||||||
|
render: (value: any) => {
|
||||||
|
const renderedValue =
|
||||||
|
typeof value === "object" ? value?.roles?.join(", ") : "-";
|
||||||
|
return renderedValue;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "attached",
|
||||||
|
label: "Attached",
|
||||||
|
},
|
||||||
|
];
|
||||||
9
pkgs/ui/src/constants/index.ts
Normal file
9
pkgs/ui/src/constants/index.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
const BASE_URL = "http://localhost:2979/api/v1";
|
||||||
|
|
||||||
|
// Home View
|
||||||
|
const HOME_VIEW_TABLE = "/get_entities";
|
||||||
|
|
||||||
|
// Access Point
|
||||||
|
const SERVICE_REPOSITORY_URL = "/get_repositories";
|
||||||
|
|
||||||
|
export { BASE_URL, HOME_VIEW_TABLE, SERVICE_REPOSITORY_URL };
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
// AP - Summary
|
|
||||||
|
|
||||||
export const APSummaryDetails = [
|
|
||||||
{
|
|
||||||
label: "DID",
|
|
||||||
value: "did:sov:test:1274",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "IP",
|
|
||||||
value: "127.0.0.2",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Network",
|
|
||||||
value: "Carlo's Home Network",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
// AP - Attachements
|
|
||||||
|
|
||||||
export const APAttachmentsDummyData = [
|
|
||||||
{
|
|
||||||
entity_name: "C1",
|
|
||||||
entity_did: "did:sov:test:1234",
|
|
||||||
network: "Carlo's Home Network",
|
|
||||||
ip_address: "127.0.0.1",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
entity_name: "C2",
|
|
||||||
entity_did: "did:sov:test:4567",
|
|
||||||
network: "Steve's Home Network",
|
|
||||||
ip_address: "127.0.0.1",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
entity_name: "C1-TEST",
|
|
||||||
entity_did: "did:sov:test:0001",
|
|
||||||
network: "Test Network A",
|
|
||||||
ip_address: "127.0.0.1",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
entity_name: "C2-TEST",
|
|
||||||
entity_did: "did:sov:test:0002",
|
|
||||||
network: "Test Network B",
|
|
||||||
ip_address: "127.0.0.1",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
export const APAttachmentsTableConfig = [
|
|
||||||
{
|
|
||||||
key: "entity_name",
|
|
||||||
label: "Entity name",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "entity_did",
|
|
||||||
label: "Entity DID",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "network",
|
|
||||||
label: "Network",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "ip_address",
|
|
||||||
label: "IP address",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
// AP - Service Repository
|
|
||||||
export const APServiceRepositoryDummyData = [
|
|
||||||
{
|
|
||||||
service_name: "Carlo's Printing",
|
|
||||||
service_type: "3D Printing",
|
|
||||||
endpoint_url: "URL",
|
|
||||||
entity: "C1",
|
|
||||||
entity_did: "did:sov:test:1234",
|
|
||||||
network: "Carlo's Home Network",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
service_name: "Jeff's Printing",
|
|
||||||
service_type: "3D Printing",
|
|
||||||
endpoint_url: "URL",
|
|
||||||
entity: "C2",
|
|
||||||
entity_did: "did:sov:test:5678",
|
|
||||||
network: "Jeff's Home Network",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
export const APServiceRepositoryTableConfig = [
|
|
||||||
{
|
|
||||||
key: "service_name",
|
|
||||||
label: "Service name",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "service_type",
|
|
||||||
label: "Service type",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "endpoint_url",
|
|
||||||
label: "End point",
|
|
||||||
},
|
|
||||||
// {
|
|
||||||
// key: "entity",
|
|
||||||
// label: "Entity",
|
|
||||||
// },
|
|
||||||
{
|
|
||||||
key: "entity_did",
|
|
||||||
label: "Entity DID",
|
|
||||||
},
|
|
||||||
// {
|
|
||||||
// key: "network",
|
|
||||||
// label: "Network",
|
|
||||||
// },
|
|
||||||
{
|
|
||||||
key: "status",
|
|
||||||
label: "Status",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
@@ -1,140 +0,0 @@
|
|||||||
// Client1 - Summary
|
|
||||||
|
|
||||||
export const Client1SummaryDetails = [
|
|
||||||
{
|
|
||||||
label: "DID",
|
|
||||||
value: "did:sov:test:1234",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "IP",
|
|
||||||
value: "127.0.0.1",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Network",
|
|
||||||
value: "Carlo's Home Network",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export const Client1ConsumerData = [
|
|
||||||
{
|
|
||||||
service_name: "Carlo's Printing",
|
|
||||||
service_type: "3D Printing",
|
|
||||||
endpoint_url: "Consume",
|
|
||||||
entity: "C2",
|
|
||||||
entity_did: "did:sov:test:1223",
|
|
||||||
network: "Carlo's Home Network",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
service_name: "Steve's Printing",
|
|
||||||
service_type: "3D Printing",
|
|
||||||
endpoint_url: "Consume",
|
|
||||||
entity: "C2",
|
|
||||||
entity_did: "did:sov:test:1234",
|
|
||||||
network: "Steve's Home Network",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
service_name: "Test A",
|
|
||||||
service_type: "3D Printing",
|
|
||||||
endpoint_url: "Consume",
|
|
||||||
entity: "C2",
|
|
||||||
entity_did: "did:sov:test:4567",
|
|
||||||
network: "Test Network A",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
service_name: "Test B",
|
|
||||||
service_type: "3D Printing",
|
|
||||||
endpoint_url: "Consume",
|
|
||||||
entity: "C2",
|
|
||||||
entity_did: "did:sov:test:0062",
|
|
||||||
network: "Test Network B",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export const Client1ConsumerTableConfig = [
|
|
||||||
{
|
|
||||||
key: "service_name",
|
|
||||||
label: "Service name",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "service_type",
|
|
||||||
label: "Service Type",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "endpoint_url",
|
|
||||||
label: "End Point",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "entity",
|
|
||||||
label: "Entity",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "entity_did",
|
|
||||||
label: "Entity DID",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "network",
|
|
||||||
label: "Network",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export const Client1ProducerData = [
|
|
||||||
{
|
|
||||||
service_name: "Carlo's Printing",
|
|
||||||
service_type: "3D Printing",
|
|
||||||
endpoint_url: "URL",
|
|
||||||
usage: "C1(3), C3(4)",
|
|
||||||
status: "DRAFT, REGISTERED",
|
|
||||||
action: "Register, Deregister, Delete",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
service_name: "Steve's Printing",
|
|
||||||
service_type: "3D Printing",
|
|
||||||
endpoint_url: "URL",
|
|
||||||
usage: "C1(3), C3(4)",
|
|
||||||
status: "REGISTERED",
|
|
||||||
action: "Create",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
service_name: "Test Printing A",
|
|
||||||
service_type: "3D Printing",
|
|
||||||
endpoint_url: "URL",
|
|
||||||
usage: "C1(3), C3(4)",
|
|
||||||
status: "DRAFT",
|
|
||||||
action: "Register, Deregister",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
service_name: "Test Printing B",
|
|
||||||
service_type: "3D Printing",
|
|
||||||
endpoint_url: "URL",
|
|
||||||
usage: "C1(3), C3(4)",
|
|
||||||
status: "DRAFT, REGISTERED",
|
|
||||||
action: "Delete, Create",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export const Client1ProducerTableConfig = [
|
|
||||||
{
|
|
||||||
key: "service_name",
|
|
||||||
label: "Service name",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "service_type",
|
|
||||||
label: "Service Type",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "endpoint_url",
|
|
||||||
label: "End Point",
|
|
||||||
},
|
|
||||||
// {
|
|
||||||
// key: "usage",
|
|
||||||
// label: "Usage",
|
|
||||||
// },
|
|
||||||
{
|
|
||||||
key: "status",
|
|
||||||
label: "Status",
|
|
||||||
},
|
|
||||||
// {
|
|
||||||
// key: "action",
|
|
||||||
// label: "Action",
|
|
||||||
// },
|
|
||||||
];
|
|
||||||
@@ -1,140 +0,0 @@
|
|||||||
// Client2 - Summary
|
|
||||||
|
|
||||||
export const Client2SummaryDetails = [
|
|
||||||
{
|
|
||||||
label: "DID",
|
|
||||||
value: "did:sov:test:1234",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "IP",
|
|
||||||
value: "127.0.0.2",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Network",
|
|
||||||
value: "Carlo's Home Network",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export const Client2ConsumerData = [
|
|
||||||
{
|
|
||||||
service_name: "Carlo's Printing",
|
|
||||||
service_type: "3D Printing",
|
|
||||||
endpoint_url: "Consume",
|
|
||||||
entity: "C2",
|
|
||||||
entity_did: "did:sov:test:1223",
|
|
||||||
network: "Carlo's Home Network",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
service_name: "Steve's Printing",
|
|
||||||
service_type: "3D Printing",
|
|
||||||
endpoint_url: "Consume",
|
|
||||||
entity: "C2",
|
|
||||||
entity_did: "did:sov:test:1234",
|
|
||||||
network: "Steve's Home Network",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
service_name: "Test A",
|
|
||||||
service_type: "3D Printing",
|
|
||||||
endpoint_url: "Consume",
|
|
||||||
entity: "C2",
|
|
||||||
entity_did: "did:sov:test:4567",
|
|
||||||
network: "Test Network A",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
service_name: "Test B",
|
|
||||||
service_type: "3D Printing",
|
|
||||||
endpoint_url: "Consume",
|
|
||||||
entity: "C2",
|
|
||||||
entity_did: "did:sov:test:0062",
|
|
||||||
network: "Test Network B",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export const Client2ConsumerTableConfig = [
|
|
||||||
{
|
|
||||||
key: "service_name",
|
|
||||||
label: "Service name",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "service_type",
|
|
||||||
label: "Service Type",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "endpoint_url",
|
|
||||||
label: "End Point",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "entity",
|
|
||||||
label: "Entity",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "entity_did",
|
|
||||||
label: "Entity DID",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "network",
|
|
||||||
label: "Network",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export const Client2ProducerData = [
|
|
||||||
{
|
|
||||||
service_name: "Carlo's Printing",
|
|
||||||
service_type: "3D Printing",
|
|
||||||
endpoint_url: "URL",
|
|
||||||
usage: "C1(3), C3(4)",
|
|
||||||
status: "DRAFT, REGISTERED",
|
|
||||||
action: "Register, Deregister, Delete",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
service_name: "Steve's Printing",
|
|
||||||
service_type: "3D Printing",
|
|
||||||
endpoint_url: "URL",
|
|
||||||
usage: "C1(3), C3(4)",
|
|
||||||
status: "REGISTERED",
|
|
||||||
action: "Create",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
service_name: "Test Printing A",
|
|
||||||
service_type: "3D Printing",
|
|
||||||
endpoint_url: "URL",
|
|
||||||
usage: "C1(3), C3(4)",
|
|
||||||
status: "DRAFT",
|
|
||||||
action: "Register, Deregister",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
service_name: "Test Printing B",
|
|
||||||
service_type: "3D Printing",
|
|
||||||
endpoint_url: "URL",
|
|
||||||
usage: "C1(3), C3(4)",
|
|
||||||
status: "DRAFT, REGISTERED",
|
|
||||||
action: "Delete, Create",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export const Client2ProducerTableConfig = [
|
|
||||||
{
|
|
||||||
key: "service_name",
|
|
||||||
label: "Service name",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "service_type",
|
|
||||||
label: "Service Type",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "endpoint_url",
|
|
||||||
label: "End Point",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "usage",
|
|
||||||
label: "Usage",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "status",
|
|
||||||
label: "Status",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "action",
|
|
||||||
label: "Action",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
// HOME - Table Data
|
|
||||||
|
|
||||||
export const HomeDummyData = [
|
|
||||||
{
|
|
||||||
entity_name: "C1",
|
|
||||||
entity_DID: "did:sov:test:1234",
|
|
||||||
network: "Carlo's Home Network",
|
|
||||||
ip_address: "127.0.0.1",
|
|
||||||
roles: "service repository, service consumer, DLG",
|
|
||||||
visible: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
entity_name: "C2",
|
|
||||||
entity_DID: "did:sov:test:4567",
|
|
||||||
network: "Steve's Home Network",
|
|
||||||
ip_address: "127.0.0.1",
|
|
||||||
roles: "service repository, service consumer, DLG",
|
|
||||||
visible: false,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export const HomeTableConfig = [
|
|
||||||
{
|
|
||||||
key: "name",
|
|
||||||
label: "Entity name",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "did",
|
|
||||||
label: "Entity DID",
|
|
||||||
},
|
|
||||||
// {
|
|
||||||
// key: "network",
|
|
||||||
// label: "Network",
|
|
||||||
// },
|
|
||||||
{
|
|
||||||
key: "ip",
|
|
||||||
label: "IP address",
|
|
||||||
},
|
|
||||||
// {
|
|
||||||
// key: "roles",
|
|
||||||
// label: "Roles",
|
|
||||||
// },
|
|
||||||
{
|
|
||||||
key: "attached",
|
|
||||||
label: "Attached",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
@@ -7,6 +7,7 @@ export interface CustomTableConfiguration {
|
|||||||
export interface ICustomTable {
|
export interface ICustomTable {
|
||||||
configuration: CustomTableConfiguration[];
|
configuration: CustomTableConfiguration[];
|
||||||
data: any;
|
data: any;
|
||||||
|
loading?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EntityDetails {
|
export interface EntityDetails {
|
||||||
@@ -20,7 +21,9 @@ export interface Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ISummaryDetails {
|
export interface ISummaryDetails {
|
||||||
entity: Entity;
|
entity: any;
|
||||||
|
fake?: boolean;
|
||||||
hasRefreshButton?: boolean;
|
hasRefreshButton?: boolean;
|
||||||
hasAttachDetach?: boolean;
|
hasAttachDetach?: boolean;
|
||||||
|
onRefresh?: () => void;
|
||||||
}
|
}
|
||||||
|
|||||||
12
pkgs/ui/src/utils/helpers.ts
Normal file
12
pkgs/ui/src/utils/helpers.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
export const formatDateTime = (date: string) => {
|
||||||
|
const _date = new Date(date);
|
||||||
|
return _date.toLocaleDateString("en-US", {
|
||||||
|
year: "numeric",
|
||||||
|
month: "long",
|
||||||
|
day: "numeric",
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit",
|
||||||
|
second: "2-digit",
|
||||||
|
hour12: true,
|
||||||
|
});
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user