generated from Luis/nextjs-python-web-template
Rename producer to service and consumer to client #41
@@ -17,11 +17,19 @@ from .routers import endpoints, health, root, socket_manager2 # sql router hinz
|
||||
from .sql_db import engine
|
||||
from .tags import tags_metadata
|
||||
|
||||
origins = [
|
||||
"http://localhost:3000",
|
||||
"http://127.0.0.1:3000",
|
||||
"http://0.0.0.0:3000",
|
||||
cors_url = [
|
||||
"http://localhost",
|
||||
"http://127.0.0.1",
|
||||
"http://0.0.0.0",
|
||||
"http://[::]",
|
||||
]
|
||||
cors_ports = [2979, 3000]
|
||||
cors_whitelist = []
|
||||
for u in cors_url:
|
||||
for p in cors_ports:
|
||||
cors_whitelist.append(f"{u}:{p}")
|
||||
|
||||
|
||||
# Logging setup
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -44,7 +52,7 @@ def setup_app() -> FastAPI:
|
||||
app = FastAPI(lifespan=lifespan, swagger_ui_parameters={"tryItOutEnabled": True})
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=origins,
|
||||
allow_origins=cors_whitelist,
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import random
|
||||
import uuid
|
||||
|
||||
from openapi_client import ApiClient
|
||||
from openapi_client.api import DefaultApi
|
||||
from openapi_client.api.entities_api import EntitiesApi
|
||||
@@ -10,18 +13,11 @@ from openapi_client.models import (
|
||||
Status,
|
||||
)
|
||||
|
||||
uuids = [
|
||||
"e95bb72f-b1b3-4452-8065-c7acf09068fc",
|
||||
"411d772e-1ad0-4d99-8da0-133ab2972322",
|
||||
"8cfdf359-c3b9-4951-9e51-08dce797725a",
|
||||
"24b5b4de-9f5f-4e60-878e-cc5be085fd0d",
|
||||
"d45f9687-c413-43b9-8e0d-cb610b39fcaf",
|
||||
"083e09a0-1d71-4819-83e2-ce2a6d831713",
|
||||
"e6f74e55-c163-4368-98c0-a2b04c99d6e3",
|
||||
"1b577ba7-c9dd-4e66-b695-9350e9db0b6c",
|
||||
"bfd9e653-98a4-4451-9d97-bcc2908f213d",
|
||||
"0e481624-b886-437c-89a0-b9e73651cc72",
|
||||
]
|
||||
random.seed(42)
|
||||
|
||||
|
||||
num_uuids = 100
|
||||
uuids = [str(uuid.UUID(int=random.getrandbits(128))) for i in range(num_uuids)]
|
||||
|
||||
|
||||
def test_health(api_client: ApiClient) -> None:
|
||||
@@ -75,7 +71,8 @@ def test_create_entities(api_client: ApiClient) -> None:
|
||||
def test_create_services(api_client: ApiClient) -> None:
|
||||
sapi = ServicesApi(api_client=api_client)
|
||||
eapi = EntitiesApi(api_client=api_client)
|
||||
for idx, entity in enumerate(eapi.get_all_entities()):
|
||||
service_obj = create_service(idx, entity)
|
||||
service = sapi.create_service(service_obj)
|
||||
assert service.uuid == service_obj.uuid
|
||||
for midx, entity in enumerate(eapi.get_all_entities()):
|
||||
for idx in range(4):
|
||||
service_obj = create_service(idx + 4 * midx, entity)
|
||||
service = sapi.create_service(service_obj)
|
||||
assert service.uuid == service_obj.uuid
|
||||
|
||||
@@ -65,6 +65,7 @@ export default function AccessPoint() {
|
||||
loading={loadingAttachements}
|
||||
data={APAttachementData?.data}
|
||||
configuration={APAttachmentsTableConfig}
|
||||
tkey="attachment-table"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
@@ -73,6 +74,7 @@ export default function AccessPoint() {
|
||||
loading={laodingRepositories}
|
||||
data={APRepositories?.data}
|
||||
configuration={APServiceRepositoryTableConfig}
|
||||
tkey="service-repository-table"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -41,7 +41,7 @@ export default function Client({
|
||||
});
|
||||
}
|
||||
return [];
|
||||
}, [services]);
|
||||
}, [services, entity?.did]);
|
||||
|
||||
const onRefresh = () => {
|
||||
const entityKey =
|
||||
@@ -52,7 +52,7 @@ export default function Client({
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
onRefresh();
|
||||
}, 1000);
|
||||
}, 5000);
|
||||
|
||||
return () => clearInterval(interval);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
@@ -162,7 +162,7 @@ export default function Client({
|
||||
loading={services_loading}
|
||||
data={clients}
|
||||
configuration={ClientTableConfig}
|
||||
key="client-table"
|
||||
tkey="client-table"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
@@ -171,7 +171,7 @@ export default function Client({
|
||||
loading={services_loading}
|
||||
data={services?.data?.services}
|
||||
configuration={ServiceTableConfig}
|
||||
key="service-table"
|
||||
tkey="service-table"
|
||||
/>
|
||||
</div>
|
||||
<Snackbar
|
||||
|
||||
@@ -43,6 +43,7 @@ export default function DLG() {
|
||||
loading={loadingResolutions}
|
||||
data={resolutionData}
|
||||
configuration={DLGResolutionTableConfig}
|
||||
tkey="resolution_table"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -24,7 +24,7 @@ export default function Home() {
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
onRefresh();
|
||||
}, 500);
|
||||
}, 5000);
|
||||
|
||||
return () => clearInterval(interval);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
@@ -45,6 +45,7 @@ export default function Home() {
|
||||
loading={data.loadingEntities}
|
||||
data={data?.allEntities}
|
||||
configuration={HomeTableConfig}
|
||||
tkey="home_table"
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import { StyledTableCell, StyledTableRow } from "./style";
|
||||
import { ICustomTable, CustomTableConfiguration } from "@/types";
|
||||
import { Checkbox, Skeleton } from "@mui/material";
|
||||
|
||||
const CustomTable = ({ configuration, data, loading, key }: ICustomTable) => {
|
||||
const CustomTable = ({ configuration, data, loading, tkey }: ICustomTable) => {
|
||||
if (loading)
|
||||
return <Skeleton variant="rectangular" animation="wave" height={200} />;
|
||||
|
||||
@@ -25,7 +25,7 @@ const CustomTable = ({ configuration, data, loading, key }: ICustomTable) => {
|
||||
render?: (param: any) => void | undefined,
|
||||
) => {
|
||||
let renderedValue = value;
|
||||
console.log(cellKey);
|
||||
|
||||
// cover use case if the data is an array
|
||||
if (Array.isArray(value)) renderedValue = value.join(", ");
|
||||
|
||||
@@ -36,6 +36,7 @@ const CustomTable = ({ configuration, data, loading, key }: ICustomTable) => {
|
||||
// cover use case if we want to render a component
|
||||
if (render) renderedValue = render(value);
|
||||
|
||||
console.log("renderTableCell key", cellKey);
|
||||
return (
|
||||
<StyledTableCell key={cellKey} align="left">
|
||||
{renderedValue}
|
||||
@@ -59,7 +60,7 @@ const CustomTable = ({ configuration, data, loading, key }: ICustomTable) => {
|
||||
{configuration.map(
|
||||
(column: CustomTableConfiguration, columnIndex: number) => {
|
||||
const cellValue: any = data[column.key];
|
||||
const cellKey = key + ":" + column.key + ":" + rowIndex;
|
||||
const cellKey = tkey + ":" + column.key + ":" + rowIndex;
|
||||
const renderComponent = column?.render;
|
||||
return renderTableCell(
|
||||
cellValue,
|
||||
|
||||
@@ -71,6 +71,7 @@ export const ServiceTableConfig = [
|
||||
))}
|
||||
</>
|
||||
);
|
||||
console.log("render", renderedValue);
|
||||
return renderedValue;
|
||||
},
|
||||
},
|
||||
|
||||
@@ -8,7 +8,7 @@ export interface ICustomTable {
|
||||
configuration: CustomTableConfiguration[];
|
||||
data: any;
|
||||
loading?: boolean;
|
||||
key: string;
|
||||
tkey: string;
|
||||
}
|
||||
|
||||
export interface EntityDetails {
|
||||
|
||||
Reference in New Issue
Block a user