Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
kaleanych committed Nov 21, 2023
1 parent bab655c commit 1dd8351
Show file tree
Hide file tree
Showing 18 changed files with 1,319 additions and 20 deletions.
4 changes: 3 additions & 1 deletion mapping_workbench/backend/core/entrypoints/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from fastapi.middleware.cors import CORSMiddleware
from httpx_oauth.clients.google import GoogleOAuth2

from mapping_workbench.backend.fields_registry.entrypoints.api import routes as fields_registry
from mapping_workbench.backend.conceptual_mapping_rule.entrypoints.api import routes as conceptual_mapping_rule_routes
from mapping_workbench.backend.config import settings
from mapping_workbench.backend.config.entrypoints.api import routes as config_routes
Expand Down Expand Up @@ -77,7 +78,8 @@ async def on_startup():
generic_triple_map_fragment_routes.router,
config_routes.router,
ontology_routes.router,
tasks_routes.router
tasks_routes.router,
fields_registry.router
]

for secured_router in secured_routers:
Expand Down
29 changes: 17 additions & 12 deletions mapping_workbench/backend/fields_registry/entrypoints/api/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from mapping_workbench.backend.core.models.api_response import APIEmptyContentWithIdResponse
from mapping_workbench.backend.fields_registry.models.field_registry import FieldsRegistryOut, FieldsRegistryCreateIn, \
FieldsRegistryUpdateIn, FieldsRegistry, APIListFieldsRegistrysPaginatedResponse
FieldsRegistryUpdateIn, FieldsRegistry, APIListFieldsRegistriesPaginatedResponse
from mapping_workbench.backend.fields_registry.models.field_registry_diff import FieldsRegistryDiff
from mapping_workbench.backend.fields_registry.services.api import (
list_fields_registries,
Expand Down Expand Up @@ -38,18 +38,24 @@
"",
description=f"List {NAME_FOR_MANY}",
name=f"{NAME_FOR_MANY}:list",
response_model=APIListFieldsRegistrysPaginatedResponse
response_model=APIListFieldsRegistriesPaginatedResponse
)
async def route_list_fields_registries(
project: PydanticObjectId = None
project: PydanticObjectId = None,
page: int = None,
limit: int = None,
q: str = None
):
filters: dict = {}
if project:
filters['project'] = Project.link_from_id(project)
items: List[FieldsRegistryOut] = await list_fields_registries(filters)
return APIListFieldsRegistrysPaginatedResponse(
if q is not None:
filters['q'] = q

items, total_count = await list_fields_registries(filters, page, limit)
return APIListFieldsRegistriesPaginatedResponse(
items=items,
count=len(items)
count=total_count
)


Expand All @@ -61,10 +67,10 @@ async def route_list_fields_registries(
status_code=status.HTTP_201_CREATED
)
async def route_create_fields_registry(
fields_registry_data: FieldsRegistryCreateIn,
data: FieldsRegistryCreateIn,
user: User = Depends(current_active_user)
):
return await create_fields_registry(fields_registry_data=fields_registry_data, user=user)
return await create_fields_registry(data=data, user=user)


@router.patch(
Expand All @@ -74,12 +80,11 @@ async def route_create_fields_registry(
response_model=FieldsRegistryOut
)
async def route_update_fields_registry(
id: PydanticObjectId,
fields_registry_data: FieldsRegistryUpdateIn,
data: FieldsRegistryUpdateIn,
fields_registry: FieldsRegistry = Depends(get_fields_registry),
user: User = Depends(current_active_user)
):
await update_fields_registry(id=id, fields_registry_data=fields_registry_data, user=user)
return await get_fields_registry_out(id)
return await update_fields_registry(fields_registry=fields_registry, data=data, user=user)


@router.get(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pydantic import BaseModel
from typing import Optional, List

from mapping_workbench.backend.core.models.api_response import APIListPaginatedResponse
from mapping_workbench.backend.core.models.base_project_resource_entity import BaseProjectResourceEntity


Expand Down Expand Up @@ -46,26 +47,26 @@ class Settings(BaseProjectResourceEntity.Settings):
name = "fields_registry"


class FieldsRegistryCreateIn:
class FieldsRegistryCreateIn(BaseModel):
title: str
fields: List[StructuralField] = []
nodes: List[StructuralNode] = []
root_node_id: Optional[str] = None


class FieldsRegistryUpdateIn:
class FieldsRegistryUpdateIn(BaseModel):
title: str
fields: List[StructuralField] = []
nodes: List[StructuralNode] = []
root_node_id: Optional[str] = None


class FieldsRegistryOut:
class FieldsRegistryOut(BaseModel):
title: str
fields: List[StructuralField] = []
nodes: List[StructuralNode] = []
root_node_id: Optional[str] = None


class APIListFieldsRegistrysPaginatedResponse:
class APIListFieldsRegistriesPaginatedResponse(APIListPaginatedResponse):
items: List[FieldsRegistryOut]
1 change: 1 addition & 0 deletions mapping_workbench/backend/fields_registry/services/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ async def list_fields_registries(filters: dict = None, page: int = None, limit:
skip=skip,
limit=limit
).to_list()

total_count: int = await FieldsRegistry.find(query_filters).count()
return items, total_count

Expand Down
17 changes: 17 additions & 0 deletions mapping_workbench/frontend/src/api/fields-registry/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {SectionApi} from "../section";

class FieldsRegistryApi extends SectionApi {
get SECTION_TITLE() {
return "Fields Registry";
}

get SECTION_ITEM_TITLE() {
return "Fields Registry";
}

constructor() {
super("fields_registry");
}
}

export const fieldsRegistryApi = new FieldsRegistryApi();
19 changes: 19 additions & 0 deletions mapping_workbench/frontend/src/layouts/app/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,25 @@ export const useSections = () => {
path: paths.app.specific_triple_map_fragments.index
}
]
},
{
title: t(tokens.nav.fields_registry),
path: paths.app.fields_registry.index,
icon: (
<SvgIcon fontSize="small">
<HiveIcon/>
</SvgIcon>
),
items: [
{
title: t(tokens.nav.list),
path: paths.app.fields_registry.index
},
{
title: t(tokens.nav.create),
path: paths.app.fields_registry.create
}
]
});
}
items.resources.push(sections);
Expand Down
1 change: 1 addition & 0 deletions mapping_workbench/frontend/src/locales/tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export const tokens = {
triple_map_fragments: 'nav.triple_map_fragments',
generic_triple_map_fragments: 'nav.generic_triple_map_fragments',
specific_triple_map_fragments: 'nav.specific_triple_map_fragments',
fields_registry: 'nav.fields_registry',

admin: 'nav.admin',
users: 'nav.users',
Expand Down
1 change: 1 addition & 0 deletions mapping_workbench/frontend/src/locales/translations/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export const en = {
[tokens.nav.triple_map_fragments]: 'Triple Maps',
[tokens.nav.specific_triple_map_fragments]: 'Specific Triple Maps',
[tokens.nav.generic_triple_map_fragments]: 'Generic Triple Maps',
[tokens.nav.fields_registry]: 'Fields Registry',
[tokens.nav.terms_validator]: 'Terms Validator',
[tokens.nav.tasks]: 'Tasks',
[tokens.nav.generate_cm_assertions_queries]: 'Generate CM Assertions Queries',
Expand Down
107 changes: 107 additions & 0 deletions mapping_workbench/frontend/src/pages/app/fields-registry/[id]/edit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import ArrowLeftIcon from '@untitled-ui/icons-react/build/esm/ArrowLeft';
import Chip from '@mui/material/Chip';
import Link from '@mui/material/Link';
import Stack from '@mui/material/Stack';
import SvgIcon from '@mui/material/SvgIcon';
import Typography from '@mui/material/Typography';

import {fieldsRegistryApi as sectionApi} from 'src/api/fields-registry';
import {RouterLink} from 'src/components/router-link';
import {Seo} from 'src/components/seo';
import {usePageView} from 'src/hooks/use-page-view';
import {Layout as AppLayout} from 'src/layouts/app';
import {paths} from 'src/paths';
import {EditForm} from 'src/sections/app/fields-registry/edit-form';
import {ForItemEditForm} from "src/contexts/app/section/for-item-form";
import {useItem} from "src/contexts/app/section/for-item-data-state";
import {useRouter} from "src/hooks/use-router";


const Page = () => {
const router = useRouter();
if (!router.isReady) return;

const {id} = router.query;

if (!id) {
return;
}

const formState = useItem(sectionApi, id);
const item = formState.item;

usePageView();

if (!item) {
return;
}

return (
<>
<Seo title={`App: ${sectionApi.SECTION_ITEM_TITLE} Edit`}/>
<Stack spacing={4}>
<Stack spacing={4}>
<div>
<Link
color="text.primary"
component={RouterLink}
href={paths.app[sectionApi.section].index}
sx={{
alignItems: 'center',
display: 'inline-flex'
}}
underline="hover"
>
<SvgIcon sx={{mr: 1}}>
<ArrowLeftIcon/>
</SvgIcon>
<Typography variant="subtitle2">
{sectionApi.SECTION_TITLE}
</Typography>
</Link>
</div>
<Stack
alignItems="flex-start"
direction={{
xs: 'column',
md: 'row'
}}
justifyContent="space-between"
spacing={4}
>
<Stack
alignItems="center"
direction="row"
spacing={2}
>
<Stack spacing={1}>
<Typography variant="h4">
{item.prefix}
</Typography>
<Stack
alignItems="center"
direction="row"
spacing={1}
>
<Chip
label={item._id}
size="small"
/>
</Stack>
</Stack>
</Stack>
</Stack>
</Stack>
<EditForm itemctx={new ForItemEditForm(item, sectionApi, formState.setState)}/>
</Stack>
</>
);
};

Page.getLayout = (page) => (
<AppLayout>
{page}
</AppLayout>
);

export default Page;
Loading

0 comments on commit 1dd8351

Please sign in to comment.