fix(ui): support request stats to es dashboard (#7854)

* fix(ui): support request stat to es dashboard

* fix failing cypress tests

* minor updates
This commit is contained in:
Chirag Madlani 2022-10-02 21:33:33 +05:30 committed by GitHub
parent fdf216aadd
commit ddd0ca8217
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 148 additions and 37 deletions

View File

@ -29,6 +29,7 @@ const mockProps = {
allowSoftDelete: true,
entityName: 'string',
entityId: 'string-id',
canDelete: true,
entityType: 'table',
entityFQN: 'x.y.z',
isRecursiveDelete: true,

View File

@ -13,6 +13,7 @@
import { QuestionCircleOutlined, ReloadOutlined } from '@ant-design/icons';
import {
Badge,
Button,
Card,
Checkbox,
@ -25,6 +26,7 @@ import {
Typography,
} from 'antd';
import { AxiosError } from 'axios';
import { isEmpty, startCase } from 'lodash';
import React, { useEffect, useState } from 'react';
import {
getAllReIndexStatus,
@ -46,6 +48,7 @@ import {
import SVGIcons from '../../utils/SvgUtils';
import { getDateTimeByTimeStampWithZone } from '../../utils/TimeUtils';
import { showErrorToast, showSuccessToast } from '../../utils/ToastUtils';
import './elastic-search-index.style.less';
const ElasticSearchIndexPage = () => {
const [batchJobData, setBatchJobData] = useState<EventPublisherJob>();
@ -54,8 +57,9 @@ const ElasticSearchIndexPage = () => {
const { isAdminUser } = useAuth();
const [batchLoading, setBatchLoading] = useState(false);
const [streamLoading, setStreamLoading] = useState(false);
const [recreateIndex, setRecreateIndex] = useState(true);
const [recreateIndex, setRecreateIndex] = useState(false);
const [entities, setEntities] = useState<string[]>([
'table',
'topic',
'dashboard',
'pipeline',
@ -137,7 +141,7 @@ const ElasticSearchIndexPage = () => {
<div className="tw-flex">
<span className="tw-text-grey-muted">Mode</span> :
<span className="tw-ml-2">
{batchJobData?.runMode || '--'}
{startCase(batchJobData?.runMode) || '--'}
</span>
</div>
<div className="tw-flex">
@ -162,35 +166,84 @@ const ElasticSearchIndexPage = () => {
</span>
</div>
<div className="tw-flex">
<span className="tw-text-grey-muted">
Index stats
</span>{' '}
:
<span className="tw-ml-2">
{!isEmpty(batchJobData) ? (
<Space size={8}>
<Badge
className="request-badge running"
count={batchJobData?.stats?.total}
title={`Total index sent: ${batchJobData?.stats?.total}`}
/>
<Badge
className="request-badge success"
count={batchJobData?.stats?.success}
title={`Success index: ${batchJobData?.stats?.success}`}
/>
<Badge
showZero
className="request-badge failed"
count={batchJobData?.stats?.failed}
title={`Failed index: ${batchJobData?.stats?.failed}`}
/>
</Space>
) : (
'--'
)}
</span>
</div>
<div className="tw-flex">
<span className="tw-text-grey-muted">
Last Updated
</span>{' '}
:
<span className="tw-ml-2">
{batchJobData?.failureDetails?.lastFailedAt
{batchJobData?.timestamp
? getDateTimeByTimeStampWithZone(
batchJobData?.failureDetails?.lastFailedAt
batchJobData?.timestamp
)
: '--'}
</span>
</div>
</Space>
<div className="m-t-sm">
<span className="tw-text-grey-muted">Last error</span> :
<span className="tw-ml-2">
{batchJobData?.failureDetails?.lastFailedReason ? (
<RichTextEditorPreviewer
enableSeeMoreVariant={Boolean(batchJobData)}
markdown={
batchJobData?.failureDetails?.lastFailedReason
}
/>
) : (
'--'
)}
</span>
</div>
<Space className="m-t-sm" size={16}>
<div>
<span className="tw-text-grey-muted">
Last Failed At:
</span>
<p className="tw-ml-2">
{batchJobData?.failureDetails?.lastFailedAt
? getDateTimeByTimeStampWithZone(
batchJobData?.failureDetails?.lastFailedAt
)
: '--'}
</p>
</div>
<div>
<span className="tw-text-grey-muted">
Last error:
</span>
<span className="tw-ml-2">
{batchJobData?.failureDetails?.lastFailedReason ? (
<RichTextEditorPreviewer
enableSeeMoreVariant={Boolean(batchJobData)}
markdown={
batchJobData?.failureDetails?.lastFailedReason
}
/>
) : (
'--'
)}
</span>
</div>
</Space>
</Skeleton>
</div>
@ -270,7 +323,7 @@ const ElasticSearchIndexPage = () => {
<div className="tw-flex">
<span className="tw-text-grey-muted">Mode</span> :
<span className="tw-ml-2">
{streamJobData?.runMode || '--'}
{startCase(streamJobData?.runMode) || '--'}
</span>
</div>
<div className="tw-flex">
@ -298,28 +351,44 @@ const ElasticSearchIndexPage = () => {
<div className="tw-flex">
<span className="tw-text-grey-muted">Last Updated</span> :
<span className="tw-ml-2">
{streamJobData?.failureDetails?.lastFailedAt
{streamJobData?.timestamp
? getDateTimeByTimeStampWithZone(
streamJobData?.failureDetails?.lastFailedAt
streamJobData?.timestamp
)
: '--'}
</span>
</div>
</Space>
<div className="m-t-sm">
<span className="tw-text-grey-muted">Last error</span> :
<span className="tw-ml-2">
{streamJobData?.failureDetails?.lastFailedReason ? (
<RichTextEditorPreviewer
enableSeeMoreVariant={Boolean(streamJobData)}
markdown={
streamJobData?.failureDetails?.lastFailedReason
}
/>
) : (
'--'
)}
</span>
<div>
<Space className="m-t-sm" size={16}>
<div>
<span className="tw-text-grey-muted">
Last Failed At:
</span>
<p className="tw-ml-2">
{streamJobData?.failureDetails?.lastFailedAt
? getDateTimeByTimeStampWithZone(
streamJobData?.failureDetails?.lastFailedAt
)
: '--'}
</p>
</div>
<div>
<span className="tw-text-grey-muted">Last error</span> :
<span className="tw-ml-2">
{streamJobData?.failureDetails?.lastFailedReason ? (
<RichTextEditorPreviewer
enableSeeMoreVariant={Boolean(streamJobData)}
markdown={
streamJobData?.failureDetails?.lastFailedReason
}
/>
) : (
'--'
)}
</span>
</div>
</Space>
</div>
</Skeleton>
</Card>

View File

@ -0,0 +1,34 @@
/*
* Copyright 2022 Collate
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@primary-color: #7147e8;
@success-color: #008376;
@error-color: #ff4c3b;
.request-badge {
&.success {
.ant-badge-count {
background-color: @success-color;
}
}
&.failed {
.ant-badge-count {
background-color: @error-color;
}
}
&.running {
.ant-badge-count {
background-color: @primary-color;
}
}
}

View File

@ -79,7 +79,7 @@ const MsTeamsPage = withSuspenseFallback(
);
const ElasticSearchIndexPage = withSuspenseFallback(
React.lazy(
() => import('../pages/ElasticSearchIndexPage/elastic-search-index-page')
() => import('../pages/ElasticSearchIndexPage/elastic-search-index.page')
)
);

View File

@ -16,7 +16,10 @@ import { Icons } from './SvgUtils';
export const getStatusResultBadgeIcon = (status: string) => {
switch (status) {
case Status.Idle:
return Icons.TASK_OPEN;
case Status.Active:
case Status.Completed:
return Icons.SUCCESS_BADGE;
case Status.Activewitherror:
@ -32,6 +35,10 @@ export const getStatusResultBadgeIcon = (status: string) => {
export const getEventPublisherStatusText = (status?: string) => {
switch (status) {
case Status.Idle:
return 'Ideal';
case Status.Completed:
return 'Completed';
case Status.Active:
return 'Active';