issue 390:- updated asstes count in my-data page (#409)

This commit is contained in:
Shailesh Parmar 2021-09-06 18:46:37 +05:30 committed by GitHub
parent 1fa033798a
commit c02b384c27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 20 deletions

View File

@ -4,9 +4,10 @@ import NoDataFoundPlaceHolder from '../../../assets/img/no-data-placeholder.png'
type Props = {
type: 'error' | 'noData';
errorMessage?: string;
};
const ErrorPlaceHolderES = ({ type }: Props) => {
const ErrorPlaceHolderES = ({ type, errorMessage }: Props) => {
const noRecordForES = () => {
return (
<>
@ -36,6 +37,30 @@ const ErrorPlaceHolderES = ({ type }: Props) => {
);
};
const elasticSearchError = () => {
const index = errorMessage?.split('[')[3]?.split(']')[0];
return errorMessage && index ? (
<p className="tw-max-w-sm tw-text-center">
OpenMetadata requires index
<span className="tw-text-primary tw-font-medium tw-mx-1">
{index}
</span>{' '}
to exist while running Elasticsearch. Please check your Elasticsearch
indexes
</p>
) : (
<p className="tw-max-w-sm tw-text-center">
OpenMetadata requires Elasticsearch 7+ running and configured in
<span className="tw-text-primary tw-font-medium tw-mx-1">
openmetadata.yaml.
</span>
Please check the configuration and make sure the Elasticsearch is
running.
</p>
);
};
return (
<>
<div className="tw-flex tw-flex-col tw-mt-24 tw-place-items-center">
@ -49,16 +74,7 @@ const ErrorPlaceHolderES = ({ type }: Props) => {
}!`}
</p>
{type === 'noData' && noRecordForES()}
{type === 'error' && (
<p className="tw-max-w-sm tw-text-center">
OpenMetadata requires Elasticsearch 7+ running and configured in
<span className="tw-text-primary tw-font-medium tw-mx-1">
openmetadata.yaml.
</span>
Please check the configuration and make sure the Elasticsearch is
running.
</p>
)}
{type === 'error' && elasticSearchError()}
</div>
</>
);

View File

@ -33,7 +33,6 @@ import FacetFilter from '../../components/common/facetfilter/FacetFilter';
import DropDownList from '../../components/dropdown/DropDownList';
import SearchedData from '../../components/searched-data/SearchedData';
import {
ERROR404,
ERROR500,
PAGE_SIZE,
tableSortingFields,
@ -214,7 +213,7 @@ const ExplorePage: React.FC = (): React.ReactElement => {
setDashboardCount(dashboard.data.hits.total.value);
})
.catch((err: AxiosError) => {
setError(ERROR404);
setError(err.response?.data?.responseMessage);
showToast({
variant: 'error',
body: err.response?.data?.responseMessage ?? ERROR500,
@ -297,7 +296,7 @@ const ExplorePage: React.FC = (): React.ReactElement => {
}
)
.catch((err: AxiosError) => {
setError(ERROR404);
setError(err.response?.data?.responseMessage);
showToast({
variant: 'error',
body: err.response?.data?.responseMessage ?? ERROR500,
@ -478,7 +477,7 @@ const ExplorePage: React.FC = (): React.ReactElement => {
return (
<>
{error ? (
<ErrorPlaceHolderES type="error" />
<ErrorPlaceHolderES errorMessage={error} type="error" />
) : (
<SearchedData
showResultCount

View File

@ -26,7 +26,7 @@ import ErrorPlaceHolderES from '../../components/common/error-with-placeholder/E
import Loader from '../../components/Loader/Loader';
import MyDataHeader from '../../components/my-data/MyDataHeader';
import SearchedData from '../../components/searched-data/SearchedData';
import { ERROR404, ERROR500, PAGE_SIZE } from '../../constants/constants';
import { ERROR500, PAGE_SIZE } from '../../constants/constants';
import { Ownership } from '../../enums/mydata.enum';
import useToastContext from '../../hooks/useToastContext';
import { formatDataResponse } from '../../utils/APIUtils';
@ -42,6 +42,9 @@ const MyDataPage: React.FC = (): React.ReactElement => {
const [currentTab, setCurrentTab] = useState<number>(1);
const [error, setError] = useState<string>('');
const [filter, setFilter] = useState<string>('');
const [searchIndex] = useState<string>(
'dashboard_search_index,topic_search_index,table_search_index'
);
const [countServices, setCountServices] = useState<number>(0);
const [countAssets, setCountAssets] = useState<number>(0);
const isMounted = useRef<boolean>(false);
@ -65,7 +68,15 @@ const MyDataPage: React.FC = (): React.ReactElement => {
const fetchTableData = (setAssetCount = false) => {
setIsLoading(true);
searchData('', currentPage, PAGE_SIZE, filter ? getFilters() : '')
searchData(
'',
currentPage,
PAGE_SIZE,
filter ? getFilters() : '',
'',
'',
searchIndex
)
.then((res: SearchResponse) => {
const hits = res.data.hits.hits;
const total = res.data.hits.total.value;
@ -83,12 +94,11 @@ const MyDataPage: React.FC = (): React.ReactElement => {
}
})
.catch((err: AxiosError) => {
setError(ERROR404);
setError(err.response?.data?.responseMessage);
showToast({
variant: 'error',
body: err.response?.data?.responseMessage ?? ERROR500,
});
setIsLoading(false);
});
};
@ -151,7 +161,7 @@ const MyDataPage: React.FC = (): React.ReactElement => {
) : (
<>
{error ? (
<ErrorPlaceHolderES type="error" />
<ErrorPlaceHolderES errorMessage={error} type="error" />
) : (
<SearchedData
showOnboardingTemplate