added pie chart as per new mock

This commit is contained in:
Shailesh Parmar 2025-06-16 19:22:54 +05:30
parent b424f0f594
commit 2375c40e37
4 changed files with 475 additions and 232 deletions

View File

@ -0,0 +1,208 @@
import { Card, Col, Row } from 'antd';
import React, { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { Cell, Pie, PieChart } from 'recharts';
import { SummaryPanelProps } from './SummaryPanel.interface';
const renderCenterText = (value: number) => (
<text
dominantBaseline="middle"
fill="#222"
fontSize="28"
fontWeight="bold"
textAnchor="middle"
x="50%"
y="50%">
{value.toLocaleString()}
</text>
);
const PieChartSummaryPanel = ({
testSummary,
isLoading = false,
showAdditionalSummary = false,
}: SummaryPanelProps) => {
const { t } = useTranslation();
console.log('testSummary', testSummary);
// {
// "success": 4,
// "failed": 3,
// "aborted": 1,
// "total": 8,
// "unhealthy": 1,
// "healthy": 1,
// "totalDQEntities": 2,
// "totalEntityCount": 36
// }
const success = useMemo(
() => [
{
name: 'success',
value: testSummary?.success,
color: '#22C55E',
},
{
name: 'total',
value: testSummary?.total,
color: '#E5E7EB',
},
],
[testSummary]
);
return (
<Card loading={isLoading}>
<div style={{ marginBottom: 16 }}>
<div style={{ fontWeight: 600, fontSize: 20 }}>
{t('test-cases-status', 'Test Cases Status')}
</div>
<div style={{ color: '#6B7280' }}>
{t(
'test-cases-status-desc',
'Understand the metadata available in your service and keep track of the main KPIs coverage'
)}
</div>
</div>
<Row gutter={[32, 16]} justify="center">
{/* Total Tests */}
<Col md={8} xs={24}>
<Card style={{ textAlign: 'center', minHeight: 320 }}>
<div style={{ fontWeight: 600, fontSize: 20, marginBottom: 8 }}>
{t('total-tests', 'Total Tests')}
</div>
<div
style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
position: 'relative',
height: 180,
}}>
<PieChart height={200} width={200}>
<Pie
cx="50%"
cy="50%"
data={success}
dataKey="value"
innerRadius={85}
outerRadius={100}>
{success?.map((entry) => (
<Cell fill={entry.color} key={`cell-${entry.name}`} />
))}
</Pie>
{/* {renderCenterText(testSummary?.totalTests || 0)} */}
</PieChart>
</div>
<div
style={{
display: 'flex',
justifyContent: 'center',
gap: 16,
marginTop: 8,
}}>
{testSummary?.totalTests?.map((item: any) => (
<div
key={item.name}
style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
<span
style={{
width: 10,
height: 10,
borderRadius: '50%',
background: item.color,
display: 'inline-block',
}}
/>
<span style={{ color: '#222', fontWeight: 500 }}>
{t(item.name)}
</span>
<span style={{ color: '#6B7280', fontWeight: 500 }}>
{item.value}
</span>
</div>
))}
</div>
</Card>
</Col>
{/* Healthy Data Assets */}
<Col md={8} xs={24}>
<Card style={{ textAlign: 'center', minHeight: 320 }}>
<div style={{ fontWeight: 600, fontSize: 20, marginBottom: 8 }}>
{t('healthy-data-asset-plural')}
</div>
<div
style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
position: 'relative',
height: 180,
}}>
<PieChart height={180} width={180}>
<Pie
cx="50%"
cy="50%"
data={testSummary?.healthyDataAssets}
dataKey="value"
endAngle={-30}
innerRadius={60}
nameKey="name"
outerRadius={80}
startAngle={210}
stroke="none">
{testSummary?.healthyDataAssets?.map(
(entry: any, idx: number) => (
<Cell fill={entry.color} key={`cell-healthy-${idx}`} />
)
)}
</Pie>
{renderCenterText(1000)}
</PieChart>
</div>
</Card>
</Col>
{/* Data Assets Coverage */}
<Col md={8} xs={24}>
<Card style={{ textAlign: 'center', minHeight: 320 }}>
<div style={{ fontWeight: 600, fontSize: 20, marginBottom: 8 }}>
{t('data-asset-plural-coverage')}
</div>
<div
style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
position: 'relative',
height: 180,
}}>
<PieChart height={180} width={180}>
<Pie
cx="50%"
cy="50%"
data={testSummary?.dataAssetsCoverage}
dataKey="value"
endAngle={-30}
innerRadius={60}
nameKey="name"
outerRadius={80}
startAngle={210}
stroke="none">
{testSummary?.dataAssetsCoverage?.map(
(entry: any, idx: number) => (
<Cell fill={entry.color} key={`cell-coverage-${idx}`} />
)
)}
</Pie>
{renderCenterText(1000)}
</PieChart>
</div>
</Card>
</Col>
</Row>
</Card>
);
};
export default PieChartSummaryPanel;

View File

@ -13,6 +13,7 @@
import { RightOutlined } from '@ant-design/icons';
import {
Button,
Card,
Col,
Dropdown,
Form,
@ -81,6 +82,7 @@ import { PagingHandlerParams } from '../../common/NextPrevious/NextPrevious.inte
import Searchbar from '../../common/SearchBarComponent/SearchBar.component';
import DataQualityTab from '../../Database/Profiler/DataQualityTab/DataQualityTab';
import { TestCaseSearchParams } from '../DataQuality.interface';
import PieChartSummaryPanel from '../SummaryPannel/PieChartSummaryPanel.component';
import { SummaryPanel } from '../SummaryPannel/SummaryPanel.component';
export const TestCases = () => {
@ -482,6 +484,7 @@ export const TestCases = () => {
}
return (
<Card>
<Row data-testid="test-case-container" gutter={[16, 16]}>
<Col span={24}>
<Form<TestCaseSearchParams>
@ -654,6 +657,12 @@ export const TestCases = () => {
testSummary={testCaseSummary}
/>
</Col>
<Col span={24}>
<PieChartSummaryPanel
isLoading={isTestCaseSummaryLoading}
testSummary={testCaseSummary}
/>
</Col>
<Col span={24}>
<DataQualityTab
afterDeleteAction={fetchTestCases}
@ -673,5 +682,6 @@ export const TestCases = () => {
/>
</Col>
</Row>
</Card>
);
};

View File

@ -11,13 +11,15 @@
* limitations under the License.
*/
import { Card, Col, Row, Tabs, Typography } from 'antd';
import { Button, Card, Col, Row, Tabs, Typography } from 'antd';
import { isEmpty } from 'lodash';
import React, { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useHistory, useParams } from 'react-router-dom';
import { Link, useHistory, useParams } from 'react-router-dom';
import ManageButton from '../../components/common/EntityPageInfos/ManageButton/ManageButton';
import TabsLabel from '../../components/common/TabsLabel/TabsLabel.component';
import { ROUTES } from '../../constants/constants';
import { usePermissionProvider } from '../../context/PermissionProvider/PermissionProvider';
import { EntityType } from '../../enums/entity.enum';
import { withPageLayout } from '../../hoc/withPageLayout';
import i18n from '../../utils/i18next/LocalUtil';
@ -32,6 +34,8 @@ const DataQualityPage = () => {
useParams<{ tab: DataQualityPageTabs }>();
const history = useHistory();
const { t } = useTranslation();
const { permissions } = usePermissionProvider();
const { testSuite: testSuitePermission } = permissions;
const menuItems = useMemo(() => {
const data = DataQualityClassBase.getDataQualityTab();
@ -58,11 +62,12 @@ const DataQualityPage = () => {
};
return (
<div>
<Card className="h-full overflow-y-auto">
<DataQualityProvider>
<Row data-testid="data-insight-container" gutter={[0, 16]}>
<Col span={isEmpty(extraDropdownContent) ? 24 : 23}>
<Col span={24}>
<Card>
<Row>
<Col span={isEmpty(extraDropdownContent) ? 16 : 23}>
<Typography.Title
className="m-b-md"
data-testid="page-title"
@ -70,24 +75,47 @@ const DataQualityPage = () => {
{t('label.data-quality')}
</Typography.Title>
<Typography.Paragraph
className="text-grey-muted"
className="text-grey-muted m-b-0"
data-testid="page-sub-title">
{t('message.page-sub-header-for-data-quality')}
</Typography.Paragraph>
</Col>
<Col className="d-flex justify-end" span={8}>
{activeTab === DataQualityPageTabs.TEST_SUITES &&
testSuitePermission?.Create && (
<Link
data-testid="add-test-suite-btn"
to={ROUTES.ADD_TEST_SUITES}>
<Button type="primary">
{t('label.add-entity', {
entity: t('label.bundle-suite-plural'),
})}
</Button>
</Link>
)}
{activeTab === DataQualityPageTabs.TEST_CASES &&
testSuitePermission?.Create && (
<Button data-testid="add-test-case-btn" type="primary">
{t('label.add-entity', {
entity: t('label.test-case'),
})}
</Button>
)}
{isEmpty(extraDropdownContent) ? null : (
<Col className="d-flex justify-end" span={1}>
<ManageButton
entityName={EntityType.TEST_CASE}
entityType={EntityType.TEST_CASE}
extraDropdownContent={extraDropdownContent}
/>
</Col>
)}
</Col>
</Row>
</Card>
</Col>
<Col span={24}>
<Tabs
activeKey={activeTab}
className="tabs-new"
className="tabs-new data-quality-page-tabs"
data-testid="tabs"
items={menuItems}
onChange={handleTabChange}
@ -95,8 +123,6 @@ const DataQualityPage = () => {
</Col>
</Row>
</DataQualityProvider>
</Card>
</div>
);
};

View File

@ -13,9 +13,8 @@
@import (reference) '../../styles/variables.less';
.data-quality-page-left-panel-menu {
&.ant-menu-root.ant-menu-inline {
padding-top: @size-md;
border-radius: @border-radius-sm;
.data-quality-page-tabs {
.ant-tabs-tabpane {
margin-top: @size-md;
}
}