From e539c290134d255456b6777fa7ec9bd68af72f6b Mon Sep 17 00:00:00 2001 From: changyonglik Date: Fri, 26 Aug 2022 23:12:26 +0800 Subject: [PATCH 01/20] Added button for data source Signed-off-by: changyonglik --- ui/src/components/dataSourceList.tsx | 23 +++++++++++-- ui/src/pages/dataSource/dataSources.tsx | 7 +++- .../pages/dataSource/detailSourceDetails.tsx | 34 +++++++++++++++++++ 3 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 ui/src/pages/dataSource/detailSourceDetails.tsx diff --git a/ui/src/components/dataSourceList.tsx b/ui/src/components/dataSourceList.tsx index 08e0cf5e7..d8dfe2ea9 100644 --- a/ui/src/components/dataSourceList.tsx +++ b/ui/src/components/dataSourceList.tsx @@ -1,9 +1,16 @@ import React, { useCallback, useEffect, useState } from "react"; -import { Form, Select, Table } from "antd"; +import { useNavigate } from "react-router-dom"; +import { Form, Select, Table, Button } from "antd"; import { DataSource } from "../models/model"; import { fetchDataSources, fetchProjects } from "../api"; -const DataSourceList = () => { +type Props = { + projectProp: string; + keywordProp: string; +}; + +const DataSourceList = ({ projectProp, keywordProp }: Props) => { + const navigate = useNavigate(); const columns = [ { title:
Name
, @@ -11,7 +18,17 @@ const DataSourceList = () => { align: "center" as "center", width: 120, render: (row: DataSource) => { - return row.attributes.name; + // return row.attributes.name; + return ( + + ) }, onCell: () => { return { diff --git a/ui/src/pages/dataSource/dataSources.tsx b/ui/src/pages/dataSource/dataSources.tsx index df3c3bf08..b49528321 100644 --- a/ui/src/pages/dataSource/dataSources.tsx +++ b/ui/src/pages/dataSource/dataSources.tsx @@ -1,15 +1,20 @@ import React from "react"; import { Card, Typography } from "antd"; +import { useNavigate, useSearchParams } from "react-router-dom"; import DataSourceList from "../../components/dataSourceList"; const { Title } = Typography; const DataSources = () => { + const [searchParams] = useSearchParams(); + const project = (searchParams.get("project") as string) ?? ""; + const keyword = (searchParams.get("keyword") as string) ?? ""; + return (
Data Sources - +
); diff --git a/ui/src/pages/dataSource/detailSourceDetails.tsx b/ui/src/pages/dataSource/detailSourceDetails.tsx new file mode 100644 index 000000000..a4178fac5 --- /dev/null +++ b/ui/src/pages/dataSource/detailSourceDetails.tsx @@ -0,0 +1,34 @@ +import React from "react"; +import { Button, Card, Row, Space, Typography } from "antd"; + +const { Title } = Typography; + +const FeatureDetails: React.FC = () => { + // return
Hello World
; + return ( + + data.attributes.name +
+ + + +
+
+ + Test + {/* + + + + + */} + +
+
+ ) +}; + +export default FeatureDetails; From 6f54a420499e231219b07b07a9716cc93f1546e6 Mon Sep 17 00:00:00 2001 From: changyonglik Date: Mon, 29 Aug 2022 17:45:16 +0800 Subject: [PATCH 02/20] Added action to dataSourceList Signed-off-by: changyonglik --- ui/src/components/dataSourceList.tsx | 46 ++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/ui/src/components/dataSourceList.tsx b/ui/src/components/dataSourceList.tsx index d8dfe2ea9..d3d478492 100644 --- a/ui/src/components/dataSourceList.tsx +++ b/ui/src/components/dataSourceList.tsx @@ -1,6 +1,7 @@ import React, { useCallback, useEffect, useState } from "react"; -import { useNavigate } from "react-router-dom"; -import { Form, Select, Table, Button } from "antd"; +import { useNavigate, Link } from "react-router-dom"; +import { Form, Select, Table, Button, Menu, Dropdown, Tooltip } from "antd"; +import { DownOutlined } from "@ant-design/icons"; import { DataSource } from "../models/model"; import { fetchDataSources, fetchProjects } from "../api"; @@ -23,7 +24,7 @@ const DataSourceList = ({ projectProp, keywordProp }: Props) => { + + + ); + }} + > + + + ), + }, ]; const [page, setPage] = useState(1); const [loading, setLoading] = useState(false); From 2f70ec8ab1e61b00a189857e967131e72cff474f Mon Sep 17 00:00:00 2001 From: changyonglik Date: Mon, 29 Aug 2022 18:01:28 +0800 Subject: [PATCH 03/20] Added path for dataSource Signed-off-by: changyonglik --- ui/src/app.tsx | 5 ++ ui/src/components/dataSourceList.tsx | 11 +++- ui/src/pages/dataSource/dataSourceDetails.tsx | 54 +++++++++++++++++++ ui/src/pages/dataSource/dataSources.tsx | 1 - .../pages/dataSource/detailSourceDetails.tsx | 34 ------------ 5 files changed, 68 insertions(+), 37 deletions(-) create mode 100644 ui/src/pages/dataSource/dataSourceDetails.tsx delete mode 100644 ui/src/pages/dataSource/detailSourceDetails.tsx diff --git a/ui/src/app.tsx b/ui/src/app.tsx index be6452636..5984717f9 100644 --- a/ui/src/app.tsx +++ b/ui/src/app.tsx @@ -10,6 +10,7 @@ import Features from "./pages/feature/features"; import NewFeature from "./pages/feature/newFeature"; import FeatureDetails from "./pages/feature/featureDetails"; import DataSources from "./pages/dataSource/dataSources"; +import DataSourceDetails from "./pages/dataSource/dataSourceDetails"; import Jobs from "./pages/jobs/jobs"; import Monitoring from "./pages/monitoring/monitoring"; import LineageGraph from "./pages/feature/lineageGraph"; @@ -44,6 +45,10 @@ const App = () => { path="/projects/:project/features/:featureId" element={} /> + } + /> } diff --git a/ui/src/components/dataSourceList.tsx b/ui/src/components/dataSourceList.tsx index d3d478492..948b992ac 100644 --- a/ui/src/components/dataSourceList.tsx +++ b/ui/src/components/dataSourceList.tsx @@ -1,6 +1,14 @@ import React, { useCallback, useEffect, useState } from "react"; import { useNavigate, Link } from "react-router-dom"; -import { Form, Select, Table, Button, Menu, Dropdown, Tooltip } from "antd"; +import { + Form, + Select, + Table, + Button, + Menu, + Dropdown, + Tooltip +} from "antd"; import { DownOutlined } from "@ant-design/icons"; import { DataSource } from "../models/model"; import { fetchDataSources, fetchProjects } from "../api"; @@ -19,7 +27,6 @@ const DataSourceList = ({ projectProp, keywordProp }: Props) => { align: "center" as "center", width: 120, render: (row: DataSource) => { - // return row.attributes.name; return ( + // + // + //
+ // + // Test + // {/* + // + // + // + // + // */} + // + //
+ // + // ) +}; + +export default DataSourceDetails; diff --git a/ui/src/pages/dataSource/dataSources.tsx b/ui/src/pages/dataSource/dataSources.tsx index b49528321..161922a6b 100644 --- a/ui/src/pages/dataSource/dataSources.tsx +++ b/ui/src/pages/dataSource/dataSources.tsx @@ -1,4 +1,3 @@ -import React from "react"; import { Card, Typography } from "antd"; import { useNavigate, useSearchParams } from "react-router-dom"; import DataSourceList from "../../components/dataSourceList"; diff --git a/ui/src/pages/dataSource/detailSourceDetails.tsx b/ui/src/pages/dataSource/detailSourceDetails.tsx deleted file mode 100644 index a4178fac5..000000000 --- a/ui/src/pages/dataSource/detailSourceDetails.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import React from "react"; -import { Button, Card, Row, Space, Typography } from "antd"; - -const { Title } = Typography; - -const FeatureDetails: React.FC = () => { - // return
Hello World
; - return ( - - data.attributes.name -
- - - -
-
- - Test - {/* - - - - - */} - -
-
- ) -}; - -export default FeatureDetails; From d16c1d152c352b940588674d4ce6421a3401b144 Mon Sep 17 00:00:00 2001 From: changyonglik Date: Mon, 29 Aug 2022 18:10:50 +0800 Subject: [PATCH 04/20] Added fetchDataSources Signed-off-by: changyonglik --- ui/src/pages/dataSource/dataSourceDetails.tsx | 88 +++++++++++++++++-- 1 file changed, 83 insertions(+), 5 deletions(-) diff --git a/ui/src/pages/dataSource/dataSourceDetails.tsx b/ui/src/pages/dataSource/dataSourceDetails.tsx index 3eb889867..16a2fc73a 100644 --- a/ui/src/pages/dataSource/dataSourceDetails.tsx +++ b/ui/src/pages/dataSource/dataSourceDetails.tsx @@ -2,12 +2,18 @@ import React from "react"; import { LoadingOutlined } from "@ant-design/icons"; import { useNavigate, useParams } from "react-router-dom"; import { + Alert, Button, Card, Row, Space, + Spin, Typography } from "antd"; +import { QueryStatus, useQuery } from "react-query"; +import { AxiosError } from "axios"; +import { fetchDataSources } from "../../api"; +import { DataSource, DataSourceAttributes } from "../../models/model"; const { Title } = Typography; @@ -20,11 +26,12 @@ const DataSourceDetails = () => { const { project, dataSourceId } = useParams() as Params; const navigate = useNavigate(); const loadingIcon = ; - // const { status, error, data } = useQuery( - // ["dataSourceId", dataSourceId], - // () => fetchFeature(project, featureId) - // ); - return
Hello World
; + const { status, error, data } = useQuery( + ["dataSourceId", dataSourceId], + () => fetchDataSources(project, dataSourceId) + ); + + // return
Hello World
; // return ( // // data.attributes.name @@ -49,6 +56,77 @@ const DataSourceDetails = () => { // // // ) + const render = (status: QueryStatus): JSX.Element => { + switch (status) { + case "error": + return ( + + + + ); + case "idle": + return ( + + + + ); + case "loading": + return ( + + + + ); + case "success": + if (data === undefined) { + return ( + + + + ); + } else { + return ( + <> + + + {data.attributes.name} +
+ + + +
+
+ + Test + {/* + + + + + */} + +
+
+ + ); + } + } + }; + + return
{render(status)}
; }; export default DataSourceDetails; From 4c83a0867a26472c3eecb91bad9555dcbce35e53 Mon Sep 17 00:00:00 2001 From: changyonglik Date: Mon, 29 Aug 2022 21:14:41 +0800 Subject: [PATCH 05/20] Added fetchDataSource api Signed-off-by: changyonglik --- ui/src/api/api.tsx | 11 +++++++++++ ui/src/pages/dataSource/dataSourceDetails.tsx | 8 ++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ui/src/api/api.tsx b/ui/src/api/api.tsx index 167bd05ee..5a41789d0 100644 --- a/ui/src/api/api.tsx +++ b/ui/src/api/api.tsx @@ -32,6 +32,17 @@ export const fetchDataSources = async (project: string) => { }); }; +export const fetchDataSource = async (project: string, dataSourceId: string) => { + const axios = await authAxios(msalInstance); + return axios + .get(`${getApiBaseUrl()}/projects/${project}/dataSources/${dataSourceId}`, { + params: { project: project }, + }) + .then((response) => { + return response.data; + }); +}; + export const fetchProjects = async () => { const axios = await authAxios(msalInstance); return axios diff --git a/ui/src/pages/dataSource/dataSourceDetails.tsx b/ui/src/pages/dataSource/dataSourceDetails.tsx index 16a2fc73a..41e90c41a 100644 --- a/ui/src/pages/dataSource/dataSourceDetails.tsx +++ b/ui/src/pages/dataSource/dataSourceDetails.tsx @@ -12,7 +12,7 @@ import { } from "antd"; import { QueryStatus, useQuery } from "react-query"; import { AxiosError } from "axios"; -import { fetchDataSources } from "../../api"; +import { fetchDataSource } from "../../api"; import { DataSource, DataSourceAttributes } from "../../models/model"; const { Title } = Typography; @@ -28,7 +28,7 @@ const DataSourceDetails = () => { const loadingIcon = ; const { status, error, data } = useQuery( ["dataSourceId", dataSourceId], - () => fetchDataSources(project, dataSourceId) + () => fetchDataSource(project, dataSourceId) ); // return
Hello World
; @@ -101,13 +101,13 @@ const DataSourceDetails = () => { {data.attributes.name} -
+ {/*
-
+
*/}
Test From 88c08f682e7d5caa83acbfbdd3ce84b2ca20dd44 Mon Sep 17 00:00:00 2001 From: changyonglik Date: Tue, 30 Aug 2022 23:19:58 +0800 Subject: [PATCH 06/20] Fixed URI bug Signed-off-by: changyonglik --- ui/src/api/api.tsx | 2 +- ui/src/components/dataSourceList.tsx | 4 +- ui/src/pages/dataSource/dataSourceDetails.tsx | 48 +++++++++---------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/ui/src/api/api.tsx b/ui/src/api/api.tsx index 5a41789d0..4814a1cba 100644 --- a/ui/src/api/api.tsx +++ b/ui/src/api/api.tsx @@ -35,7 +35,7 @@ export const fetchDataSources = async (project: string) => { export const fetchDataSource = async (project: string, dataSourceId: string) => { const axios = await authAxios(msalInstance); return axios - .get(`${getApiBaseUrl()}/projects/${project}/dataSources/${dataSourceId}`, { + .get(`${getApiBaseUrl()}/projects/${project}/dataSources/${dataSourceId}`, { params: { project: project }, }) .then((response) => { diff --git a/ui/src/components/dataSourceList.tsx b/ui/src/components/dataSourceList.tsx index 948b992ac..820f8bc4f 100644 --- a/ui/src/components/dataSourceList.tsx +++ b/ui/src/components/dataSourceList.tsx @@ -31,7 +31,7 @@ const DataSourceList = ({ projectProp, keywordProp }: Props) => { - // - //
- //
- // - // Test - // {/* - // - // - // - // - // */} - // - //
- //
- // ) + return ( + + data.attributes.name +
+ + + +
+
+ + Test + {/* + + + + + */} + +
+
+ ) const render = (status: QueryStatus): JSX.Element => { switch (status) { case "error": From 11b44431a83c87a48c37f6edfe19f3752453569a Mon Sep 17 00:00:00 2001 From: changyonglik Date: Wed, 31 Aug 2022 12:40:58 +0800 Subject: [PATCH 07/20] Checking dataSourceId's API Signed-off-by: changyonglik --- ui/src/api/api.tsx | 1 + ui/src/pages/dataSource/dataSourceDetails.tsx | 32 +++---------------- 2 files changed, 5 insertions(+), 28 deletions(-) diff --git a/ui/src/api/api.tsx b/ui/src/api/api.tsx index 4814a1cba..aec06fde3 100644 --- a/ui/src/api/api.tsx +++ b/ui/src/api/api.tsx @@ -39,6 +39,7 @@ export const fetchDataSource = async (project: string, dataSourceId: string) => params: { project: project }, }) .then((response) => { + console.log(response.data); return response.data; }); }; diff --git a/ui/src/pages/dataSource/dataSourceDetails.tsx b/ui/src/pages/dataSource/dataSourceDetails.tsx index 2b05041c0..a6a81baa9 100644 --- a/ui/src/pages/dataSource/dataSourceDetails.tsx +++ b/ui/src/pages/dataSource/dataSourceDetails.tsx @@ -31,31 +31,6 @@ const DataSourceDetails = () => { () => fetchDataSource(project, dataSourceId) ); - // return
Hello World
; - return ( - - data.attributes.name -
- - - -
-
- - Test - {/* - - - - - */} - -
-
- ) const render = (status: QueryStatus): JSX.Element => { switch (status) { case "error": @@ -97,7 +72,7 @@ const DataSourceDetails = () => { return ( <> {data.attributes.name} @@ -110,7 +85,7 @@ const DataSourceDetails = () => { */}
- Test + Test Below {/* @@ -126,7 +101,8 @@ const DataSourceDetails = () => { } }; - return
{render(status)}
; + // return
{render(status)}
; + return
{data}
; }; export default DataSourceDetails; From bd366a38bffbd6d645a9f8eaa6e076790815ca0f Mon Sep 17 00:00:00 2001 From: changyonglik Date: Wed, 7 Sep 2022 18:21:33 +0900 Subject: [PATCH 08/20] Added dataSource API endpoint in registry Signed-off-by: changyonglik --- registry/sql-registry/main.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/registry/sql-registry/main.py b/registry/sql-registry/main.py index 00ac1d422..da4c52306 100644 --- a/registry/sql-registry/main.py +++ b/registry/sql-registry/main.py @@ -47,6 +47,16 @@ def get_project_datasources(project: str) -> list: return list([e.to_dict() for e in sources]) +@router.get("/projects/{project}/datasources/{datasource}") +def get_datasource(project: str, datasource: str) -> dict: + p = registry.get_entity(project) + for s in p.attributes.sources: + if str(s.id) == datasource: + return s + # If datasource is not found, raise 404 error + raise HTTPException( + status_code=404, detail=f"Data Source {datasource} not found") + @router.get("/projects/{project}/features") def get_project_features(project: str, keyword: Optional[str] = None, page: Optional[int] = None, limit: Optional[int] = None) -> list: if keyword: @@ -54,7 +64,7 @@ def get_project_features(project: str, keyword: Optional[str] = None, page: Opti size = None if page is not None and limit is not None: start = (page - 1) * limit - size = limit + size = limit efs = registry.search_entity( keyword, [EntityType.AnchorFeature, EntityType.DerivedFeature], project=project, start=start, size=size) feature_ids = [ef.id for ef in efs] From 4068fe717022d3093032806e382e217d78a8b13d Mon Sep 17 00:00:00 2001 From: changyonglik Date: Thu, 8 Sep 2022 20:26:49 +0900 Subject: [PATCH 09/20] Added localhost dev environment variables Signed-off-by: changyonglik --- ui/.env.development | 4 ++++ ui/src/api/api.tsx | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 ui/.env.development diff --git a/ui/.env.development b/ui/.env.development new file mode 100644 index 000000000..50e5c488b --- /dev/null +++ b/ui/.env.development @@ -0,0 +1,4 @@ +REACT_APP_AZURE_CLIENT_ID=db8dc4b0-202e-450c-b38d-7396ad9631a5 +REACT_APP_AZURE_TENANT_ID=common +REACT_APP_API_ENDPOINT=http://127.0.0.1:8000 +REACT_APP_ENABLE_RBAC=false diff --git a/ui/src/api/api.tsx b/ui/src/api/api.tsx index aec06fde3..c7b813afe 100644 --- a/ui/src/api/api.tsx +++ b/ui/src/api/api.tsx @@ -35,11 +35,10 @@ export const fetchDataSources = async (project: string) => { export const fetchDataSource = async (project: string, dataSourceId: string) => { const axios = await authAxios(msalInstance); return axios - .get(`${getApiBaseUrl()}/projects/${project}/dataSources/${dataSourceId}`, { - params: { project: project }, + .get(`${getApiBaseUrl()}/projects/${project}/datasources/${dataSourceId}`, { + params: { project: project, datasource: dataSourceId }, }) .then((response) => { - console.log(response.data); return response.data; }); }; @@ -79,6 +78,9 @@ export const fetchFeature = async (project: string, featureId: string) => { params: { project: project }, }) .then((response) => { + console.log('Feature') + console.log(response.data); + console.log(response.data.attributes.name); return response.data; }); }; From e5880da87f2c592e49d87a731f95d4405ded9202 Mon Sep 17 00:00:00 2001 From: changyonglik Date: Thu, 8 Sep 2022 20:57:49 +0900 Subject: [PATCH 10/20] Added dataSourceDetails Signed-off-by: changyonglik --- ui/src/components/dataSourceList.tsx | 2 +- ui/src/pages/dataSource/dataSourceDetails.tsx | 46 ++++++++++++------- ui/src/pages/dataSource/dataSources.tsx | 2 +- ui/src/site.css | 4 ++ 4 files changed, 35 insertions(+), 19 deletions(-) diff --git a/ui/src/components/dataSourceList.tsx b/ui/src/components/dataSourceList.tsx index 820f8bc4f..b84a5d561 100644 --- a/ui/src/components/dataSourceList.tsx +++ b/ui/src/components/dataSourceList.tsx @@ -79,7 +79,7 @@ const DataSourceList = ({ projectProp, keywordProp }: Props) => { }, }, { - title:
Pre Processing
, + title:
Preprocessing
, key: "preprocessing", align: "center" as "center", width: 190, diff --git a/ui/src/pages/dataSource/dataSourceDetails.tsx b/ui/src/pages/dataSource/dataSourceDetails.tsx index a6a81baa9..9efa4725c 100644 --- a/ui/src/pages/dataSource/dataSourceDetails.tsx +++ b/ui/src/pages/dataSource/dataSourceDetails.tsx @@ -5,8 +5,8 @@ import { Alert, Button, Card, + Col, Row, - Space, Spin, Typography } from "antd"; @@ -17,6 +17,32 @@ import { DataSource, DataSourceAttributes } from "../../models/model"; const { Title } = Typography; +type DataSourceKeyProps = { dataSource: DataSource }; +const DataSourceKey = ({ dataSource }: DataSourceKeyProps) => { + const keys = dataSource.attributes; + return ( + <> + {keys && ( + + + Data Source Attributes +
+

Name: {keys.name}

+

Type: {keys.type}

+

Path: {keys.path}

+

Preprocessing: {keys.preprocessing}

+

Event Timestamp Column: {keys.eventTimestampColumn}

+

Timestamp Format: {keys.timestampFormat}

+

Qualified Name: {keys.qualifiedName}

+

Tags: {JSON.stringify(keys.tags)}

+
+
+ + )} + + ); +}; + type Params = { project: string; dataSourceId: string; @@ -76,22 +102,9 @@ const DataSourceDetails = () => { {data.attributes.name} - {/*
- - - -
*/}
- Test Below - {/* - - - - - */} +
@@ -101,8 +114,7 @@ const DataSourceDetails = () => { } }; - // return
{render(status)}
; - return
{data}
; + return
{render(status)}
; }; export default DataSourceDetails; diff --git a/ui/src/pages/dataSource/dataSources.tsx b/ui/src/pages/dataSource/dataSources.tsx index 161922a6b..6d84aa0af 100644 --- a/ui/src/pages/dataSource/dataSources.tsx +++ b/ui/src/pages/dataSource/dataSources.tsx @@ -1,5 +1,5 @@ import { Card, Typography } from "antd"; -import { useNavigate, useSearchParams } from "react-router-dom"; +import { useSearchParams } from "react-router-dom"; import DataSourceList from "../../components/dataSourceList"; const { Title } = Typography; diff --git a/ui/src/site.css b/ui/src/site.css index be060dc20..2d90b28bf 100644 --- a/ui/src/site.css +++ b/ui/src/site.css @@ -56,3 +56,7 @@ .feature-container p { break-inside: avoid-column; } + +.dataSource-container { + column-count: 1; +} From 845f3bae87ad815b18963f06932ba5fb665eb8fa Mon Sep 17 00:00:00 2001 From: changyonglik Date: Thu, 8 Sep 2022 21:00:54 +0900 Subject: [PATCH 11/20] Removed console log Signed-off-by: changyonglik --- ui/src/api/api.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/ui/src/api/api.tsx b/ui/src/api/api.tsx index c7b813afe..53b704d32 100644 --- a/ui/src/api/api.tsx +++ b/ui/src/api/api.tsx @@ -78,9 +78,6 @@ export const fetchFeature = async (project: string, featureId: string) => { params: { project: project }, }) .then((response) => { - console.log('Feature') - console.log(response.data); - console.log(response.data.attributes.name); return response.data; }); }; From 8a9b97aabbf0b3a529635456f744c6b48093f2a0 Mon Sep 17 00:00:00 2001 From: changyonglik Date: Thu, 15 Sep 2022 07:31:42 +0800 Subject: [PATCH 12/20] Added api endpoint in purview Signed-off-by: changyonglik --- registry/purview-registry/main.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/registry/purview-registry/main.py b/registry/purview-registry/main.py index 5818cd513..ccc7b99d5 100644 --- a/registry/purview-registry/main.py +++ b/registry/purview-registry/main.py @@ -62,6 +62,17 @@ def get_project_datasources(project: str) -> list: return list([to_camel(e.to_dict()) for e in sources]) +@router.get("/projects/{project}/datasources/{datasource}") +def get_datasource(project: str, datasource: str) -> dict: + p = registry.get_entity(project,True) + for s in p.attributes.sources: + if str(s.id) == datasource: + return s + # If datasource is not found, raise 404 error + raise HTTPException( + status_code=404, detail=f"Data Source {datasource} not found") + + @router.get("/projects/{project}/features",tags=["Project"]) def get_project_features(project: str, keyword: Optional[str] = None) -> list: atlasEntities = registry.get_project_features(project, keywords=keyword) From a8ab48140e8c6afe5da8d0ad63a200b7226ed635 Mon Sep 17 00:00:00 2001 From: changyonglik Date: Thu, 15 Sep 2022 07:34:19 +0800 Subject: [PATCH 13/20] Added project tag Signed-off-by: changyonglik --- registry/purview-registry/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registry/purview-registry/main.py b/registry/purview-registry/main.py index ccc7b99d5..a2e1ecc8d 100644 --- a/registry/purview-registry/main.py +++ b/registry/purview-registry/main.py @@ -62,7 +62,7 @@ def get_project_datasources(project: str) -> list: return list([to_camel(e.to_dict()) for e in sources]) -@router.get("/projects/{project}/datasources/{datasource}") +@router.get("/projects/{project}/datasources/{datasource}",tags=["Project"]) def get_datasource(project: str, datasource: str) -> dict: p = registry.get_entity(project,True) for s in p.attributes.sources: From 6e58b8569d1f4e0f88c1e7967a72feb4f98f8206 Mon Sep 17 00:00:00 2001 From: changyonglik Date: Thu, 15 Sep 2022 07:38:23 +0800 Subject: [PATCH 14/20] Fixed indent Signed-off-by: changyonglik --- registry/sql-registry/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/registry/sql-registry/main.py b/registry/sql-registry/main.py index da4c52306..7e9a0ebb4 100644 --- a/registry/sql-registry/main.py +++ b/registry/sql-registry/main.py @@ -57,6 +57,7 @@ def get_datasource(project: str, datasource: str) -> dict: raise HTTPException( status_code=404, detail=f"Data Source {datasource} not found") + @router.get("/projects/{project}/features") def get_project_features(project: str, keyword: Optional[str] = None, page: Optional[int] = None, limit: Optional[int] = None) -> list: if keyword: From d9605bcd64ef0650fb359bdbd157f9b21d29a7cc Mon Sep 17 00:00:00 2001 From: changyonglik Date: Thu, 15 Sep 2022 12:56:52 +0800 Subject: [PATCH 15/20] Linted Signed-off-by: changyonglik --- ui/src/api/api.tsx | 14 ++- ui/src/components/dataSourceList.tsx | 12 +- ui/src/components/userRoles.tsx | 12 +- ui/src/pages/dataSource/dataSourceDetails.tsx | 114 ++++++++---------- 4 files changed, 72 insertions(+), 80 deletions(-) diff --git a/ui/src/api/api.tsx b/ui/src/api/api.tsx index 53b704d32..a95ab2bd5 100644 --- a/ui/src/api/api.tsx +++ b/ui/src/api/api.tsx @@ -32,12 +32,18 @@ export const fetchDataSources = async (project: string) => { }); }; -export const fetchDataSource = async (project: string, dataSourceId: string) => { +export const fetchDataSource = async ( + project: string, + dataSourceId: string +) => { const axios = await authAxios(msalInstance); return axios - .get(`${getApiBaseUrl()}/projects/${project}/datasources/${dataSourceId}`, { - params: { project: project, datasource: dataSourceId }, - }) + .get( + `${getApiBaseUrl()}/projects/${project}/datasources/${dataSourceId}`, + { + params: { project: project, datasource: dataSourceId }, + } + ) .then((response) => { return response.data; }); diff --git a/ui/src/components/dataSourceList.tsx b/ui/src/components/dataSourceList.tsx index b84a5d561..9d7daa623 100644 --- a/ui/src/components/dataSourceList.tsx +++ b/ui/src/components/dataSourceList.tsx @@ -1,14 +1,6 @@ import React, { useCallback, useEffect, useState } from "react"; import { useNavigate, Link } from "react-router-dom"; -import { - Form, - Select, - Table, - Button, - Menu, - Dropdown, - Tooltip -} from "antd"; +import { Form, Select, Table, Button, Menu, Dropdown, Tooltip } from "antd"; import { DownOutlined } from "@ant-design/icons"; import { DataSource } from "../models/model"; import { fetchDataSources, fetchProjects } from "../api"; @@ -36,7 +28,7 @@ const DataSourceList = ({ projectProp, keywordProp }: Props) => { > {row.displayText} - ) + ); }, onCell: () => { return { diff --git a/ui/src/components/userRoles.tsx b/ui/src/components/userRoles.tsx index 3d5d287f7..e4d9e7dea 100644 --- a/ui/src/components/userRoles.tsx +++ b/ui/src/components/userRoles.tsx @@ -39,7 +39,7 @@ const UserRoles = () => { sorter: { compare: (a: UserRole, b: UserRole) => a.scope.localeCompare(b.scope), multiple: 3, - } + }, }, { title:
Role
, @@ -53,9 +53,10 @@ const UserRoles = () => { key: "userName", align: "center" as "center", sorter: { - compare: (a: UserRole, b: UserRole) => a.userName.localeCompare(b.userName), + compare: (a: UserRole, b: UserRole) => + a.userName.localeCompare(b.userName), multiple: 1, - } + }, }, { title:
Permissions
, @@ -93,9 +94,10 @@ const UserRoles = () => { key: "createTime", align: "center" as "center", sorter: { - compare: (a: UserRole, b: UserRole) => a.createTime.localeCompare(b.createTime), + compare: (a: UserRole, b: UserRole) => + a.createTime.localeCompare(b.createTime), multiple: 2, - } + }, }, { title: "Action", diff --git a/ui/src/pages/dataSource/dataSourceDetails.tsx b/ui/src/pages/dataSource/dataSourceDetails.tsx index 9efa4725c..2548644b2 100644 --- a/ui/src/pages/dataSource/dataSourceDetails.tsx +++ b/ui/src/pages/dataSource/dataSourceDetails.tsx @@ -1,15 +1,7 @@ import React from "react"; import { LoadingOutlined } from "@ant-design/icons"; import { useNavigate, useParams } from "react-router-dom"; -import { - Alert, - Button, - Card, - Col, - Row, - Spin, - Typography -} from "antd"; +import { Alert, Button, Card, Col, Row, Spin, Typography } from "antd"; import { QueryStatus, useQuery } from "react-query"; import { AxiosError } from "axios"; import { fetchDataSource } from "../../api"; @@ -49,72 +41,72 @@ type Params = { }; const DataSourceDetails = () => { - const { project, dataSourceId } = useParams() as Params; - const navigate = useNavigate(); - const loadingIcon = ; - const { status, error, data } = useQuery( - ["dataSourceId", dataSourceId], - () => fetchDataSource(project, dataSourceId) - ); + const { project, dataSourceId } = useParams() as Params; + const navigate = useNavigate(); + const loadingIcon = ; + const { status, error, data } = useQuery( + ["dataSourceId", dataSourceId], + () => fetchDataSource(project, dataSourceId) + ); - const render = (status: QueryStatus): JSX.Element => { - switch (status) { - case "error": + const render = (status: QueryStatus): JSX.Element => { + switch (status) { + case "error": + return ( + + + + ); + case "idle": + return ( + + + + ); + case "loading": + return ( + + + + ); + case "success": + if (data === undefined) { return ( ); - case "idle": - return ( - - - - ); - case "loading": + } else { return ( - - - - ); - case "success": - if (data === undefined) { - return ( + <> + - + {data.attributes.name} +
+ + + +
- ); - } else { - return ( - <> - - - {data.attributes.name} -
- - - -
-
- - ); - } - } - }; + + ); + } + } + }; - return
{render(status)}
; + return
{render(status)}
; }; export default DataSourceDetails; From 21a5f6a863de2dcf6eb40aababf79e730f7d2115 Mon Sep 17 00:00:00 2001 From: changyonglik Date: Thu, 15 Sep 2022 13:49:53 +0800 Subject: [PATCH 16/20] Removed client id Signed-off-by: changyonglik --- ui/.env.development | 1 - 1 file changed, 1 deletion(-) diff --git a/ui/.env.development b/ui/.env.development index 50e5c488b..0c6c0e061 100644 --- a/ui/.env.development +++ b/ui/.env.development @@ -1,4 +1,3 @@ -REACT_APP_AZURE_CLIENT_ID=db8dc4b0-202e-450c-b38d-7396ad9631a5 REACT_APP_AZURE_TENANT_ID=common REACT_APP_API_ENDPOINT=http://127.0.0.1:8000 REACT_APP_ENABLE_RBAC=false From e8c94b54c19fb20b94bc8973b3bd23b005b7deee Mon Sep 17 00:00:00 2001 From: changyonglik Date: Thu, 15 Sep 2022 17:16:47 +0800 Subject: [PATCH 17/20] Added RBAC datasource api Signed-off-by: changyonglik --- registry/access_control/api.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/registry/access_control/api.py b/registry/access_control/api.py index 3e7343e47..c6f56ac01 100644 --- a/registry/access_control/api.py +++ b/registry/access_control/api.py @@ -33,6 +33,18 @@ def get_project_datasources(project: str, requestor: User = Depends(project_read return json.loads(response) +@router.get("/projects/{project}/datasources/{datasource}", name="Get a single data source by datasource Id [Read Access Required]") +def get_project_datasource(project: str, requestor: User = Depends(project_read_access)) -> list: + response = requests.get(url=f"{registry_url}/projects/{project}/datasources/{datasource}", + headers=get_api_header(requestor)).content.decode('utf-8') + print(response) + datasource_qualifiedName = ret['attributes']['qualifiedName'] + print(datasource_qualifiedName) + validate_project_access_for_feature( + datasource_qualifiedName, requestor, AccessType.READ) + return ret + + @router.get("/projects/{project}/features", name="Get features under my project [Read Access Required]") def get_project_features(project: str, keyword: Optional[str] = None, requestor: User = Depends(project_read_access)) -> list: response = requests.get(url=f"{registry_url}/projects/{project}/features", From 3d3e3d7c902d3b205d5b4f365021c51cc20bccfc Mon Sep 17 00:00:00 2001 From: changyonglik Date: Thu, 15 Sep 2022 17:25:44 +0800 Subject: [PATCH 18/20] Added RBAC datasource api Signed-off-by: changyonglik --- registry/access_control/api.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/registry/access_control/api.py b/registry/access_control/api.py index c6f56ac01..07bdd8ddb 100644 --- a/registry/access_control/api.py +++ b/registry/access_control/api.py @@ -37,9 +37,8 @@ def get_project_datasources(project: str, requestor: User = Depends(project_read def get_project_datasource(project: str, requestor: User = Depends(project_read_access)) -> list: response = requests.get(url=f"{registry_url}/projects/{project}/datasources/{datasource}", headers=get_api_header(requestor)).content.decode('utf-8') - print(response) + datasource_qualifiedName = ret['attributes']['qualifiedName'] - print(datasource_qualifiedName) validate_project_access_for_feature( datasource_qualifiedName, requestor, AccessType.READ) return ret From d19ba40f6139a95ccbe0856c54ea49a26da58809 Mon Sep 17 00:00:00 2001 From: changyonglik Date: Thu, 15 Sep 2022 17:28:19 +0800 Subject: [PATCH 19/20] Fixed arguments Signed-off-by: changyonglik --- registry/access_control/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registry/access_control/api.py b/registry/access_control/api.py index 07bdd8ddb..d27059926 100644 --- a/registry/access_control/api.py +++ b/registry/access_control/api.py @@ -34,7 +34,7 @@ def get_project_datasources(project: str, requestor: User = Depends(project_read @router.get("/projects/{project}/datasources/{datasource}", name="Get a single data source by datasource Id [Read Access Required]") -def get_project_datasource(project: str, requestor: User = Depends(project_read_access)) -> list: +def get_project_datasource(project: str, datasource: str, requestor: User = Depends(project_read_access)) -> list: response = requests.get(url=f"{registry_url}/projects/{project}/datasources/{datasource}", headers=get_api_header(requestor)).content.decode('utf-8') From 65d48795007721ade61f34df5b5d63b9a776d2d3 Mon Sep 17 00:00:00 2001 From: changyonglik Date: Thu, 15 Sep 2022 17:34:50 +0800 Subject: [PATCH 20/20] Fixed json Signed-off-by: changyonglik --- registry/access_control/api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/registry/access_control/api.py b/registry/access_control/api.py index d27059926..11f018e23 100644 --- a/registry/access_control/api.py +++ b/registry/access_control/api.py @@ -37,7 +37,8 @@ def get_project_datasources(project: str, requestor: User = Depends(project_read def get_project_datasource(project: str, datasource: str, requestor: User = Depends(project_read_access)) -> list: response = requests.get(url=f"{registry_url}/projects/{project}/datasources/{datasource}", headers=get_api_header(requestor)).content.decode('utf-8') - + ret = json.loads(response) + datasource_qualifiedName = ret['attributes']['qualifiedName'] validate_project_access_for_feature( datasource_qualifiedName, requestor, AccessType.READ)