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 Props = {
type: 'error' | 'noData'; type: 'error' | 'noData';
errorMessage?: string;
}; };
const ErrorPlaceHolderES = ({ type }: Props) => { const ErrorPlaceHolderES = ({ type, errorMessage }: Props) => {
const noRecordForES = () => { const noRecordForES = () => {
return ( 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 ( return (
<> <>
<div className="tw-flex tw-flex-col tw-mt-24 tw-place-items-center"> <div className="tw-flex tw-flex-col tw-mt-24 tw-place-items-center">
@ -49,16 +74,7 @@ const ErrorPlaceHolderES = ({ type }: Props) => {
}!`} }!`}
</p> </p>
{type === 'noData' && noRecordForES()} {type === 'noData' && noRecordForES()}
{type === 'error' && ( {type === 'error' && elasticSearchError()}
<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>
)}
</div> </div>
</> </>
); );

View File

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

View File

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