Skip to content

Commit

Permalink
feat(Queries): new progress graph [YTFRONT-4112]
Browse files Browse the repository at this point in the history
  • Loading branch information
SimbiozizV committed Dec 17, 2024
1 parent b0c18e8 commit a445c06
Show file tree
Hide file tree
Showing 49 changed files with 1,668 additions and 27 deletions.
89 changes: 81 additions & 8 deletions packages/ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
"@gravity-ui/date-utils": "^2.5.3",
"@gravity-ui/dialog-fields": "^5.0.9",
"@gravity-ui/eslint-config": "^3.2.0",
"@gravity-ui/graph": "^0.0.6",
"@gravity-ui/icons": "^2.0.0",
"@gravity-ui/navigation": "^2.15.3",
"@gravity-ui/prettier-config": "^1.1.0",
Expand Down Expand Up @@ -135,6 +136,7 @@
"d3-scale": "4",
"d3-selection": "3",
"d3-shape": "3",
"elkjs": "^0.9.3",
"eslint": "^8.48.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-lodash": "^7.4.0",
Expand Down Expand Up @@ -183,7 +185,8 @@
"typescript": "^5.2.2",
"vis-data": "^7.1.7",
"vis-network": "^9.1.2",
"wc-react": "^0.5.1"
"wc-react": "^0.5.1",
"web-worker": "^1.3.0"
},
"engines": {
"node": ">=18"
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/shared/constants/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export const SettingName = {
STAGE: 'queryTrackerStage',
YQL_AGENT_STAGE: 'yqlAgentStage',
QUERIES_LIST_SIDEBAR_VISIBILITY_MODE: 'queriesListSidebarVisibilityMode',
NEW_GRAPH_TYPE: 'queryTrackerNewGraphType',
},
CHYT: {
LIST_COLUMNS: 'list_columns',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,16 @@ function useSettings(cluster: string, isAdmin: boolean): Array<SettingsPage> {
settingNS={NAMESPACES.QUERY_TRACKER}
/>,
),
makeItem(
'Query tracker graph',
'top',
<SettingsMenuItem
label="New graph type"
annotation="Shows the new graph type in the Progress tab for query tracker"
settingName={SettingName.QUERY_TRACKER.NEW_GRAPH_TYPE}
settingNS={NAMESPACES.QUERY_TRACKER}
/>,
),
]),
),

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
.yt-detail-block {
color: #000;
padding: 10px 12px;
min-height: 70px;
min-width: 240px;
box-sizing: border-box;
background: #fff;
border: 1px solid #ccc;
border-radius: 8px;
box-shadow: 0 1px 5px 0 #00000026;

&__header {
display: flex;
align-items: center;
gap: 0 8px;
font-weight: 500;
}

&__content {
margin-top: 8px;
}

&__details {
font-size: 11px;
height: auto;
padding-bottom: 0;

&_without-padding {
padding-top: 0;
}

.node-details-info{
grid-gap: 10px;
}

.data-table__row {
height: auto;
}

.g-text_variant_body-1 {
font-size: 11px;
}
}

.graph-block-wrapper{
border: none;
}

.data-table__foot {
background: none;

td {
background: none;
}
}

.data-table__head th:before {
display: none;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import React, {CSSProperties, FC, useMemo} from 'react';
import './DetailBlock.scss';
import cn from 'bem-cn-lite';
import {NodeTBlock} from '../canvas/NodeBlock';
import {GRAPH_COLORS} from '../constants';
import OperationNodeInfo from '../../OperationNodeInfo';
import {hasDetailsInfo, hasJobsInfo, hasStagesInfo} from '../../utils';
import {DetailBlockHeader} from './DetailBlockHeader';

const b = cn('yt-detail-block');

type Props = {
block: NodeTBlock;
showHeader?: boolean;
showInfo?: boolean;
className?: string;
};

export const DetailBlock: FC<Props> = ({block, showHeader, showInfo, className}) => {
const {meta} = block;
const {nodeProgress, details, schemas} = meta;

const style = useMemo((): CSSProperties | undefined => {
if (!nodeProgress || !nodeProgress.state) return undefined;

const percent =
nodeProgress.state === 'Finished'
? 100 // node may not have a job
: ((nodeProgress.completed || 0) / (nodeProgress.total || 1)) * 100;

return {
background: `linear-gradient(to right, ${GRAPH_COLORS.progressColor} ${percent}%, #fff ${percent}%)`,
};
}, [nodeProgress]);

const showNodeInfo = useMemo(() => {
return (
showInfo &&
(schemas ||
hasStagesInfo(nodeProgress) ||
hasJobsInfo(nodeProgress) ||
hasDetailsInfo(details))
);
}, [details, nodeProgress, schemas, showInfo]);

if (!showNodeInfo && !showHeader) return null;

return (
<div className={b(null, className)} style={style}>
{showHeader && <DetailBlockHeader block={block} />}
{showNodeInfo && (
<OperationNodeInfo
progress={nodeProgress || undefined}
schemas={schemas}
details={details}
radioWidth="max"
className={b('details', {'without-padding': !showHeader})}
/>
)}
</div>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React, {FC, useMemo} from 'react';
import {Flex, Text} from '@gravity-ui/uikit';
import {OperationContent} from './OperationContent';
import {NodeTBlock} from '../canvas/NodeBlock';
import {GraphBlockType} from '../enums';
import {DetailBlockTitle} from './DetailBlockTitle';

type Props = {
block: NodeTBlock;
};

export const DetailBlockHeader: FC<Props> = ({
block: {
meta: {icon, bottomText, nodeProgress},
name,
is,
},
}) => {
const isTable = is === GraphBlockType.Table;

const showContent = useMemo(() => {
if (isTable) return Boolean(bottomText);
return nodeProgress && nodeProgress.total;
}, [bottomText, isTable, nodeProgress]);

return (
<Flex gap={2} direction="column">
<DetailBlockTitle icon={icon} name={name} />
{showContent && (
<>
{isTable ? (
<Text variant="caption-2">{bottomText || ''}</Text>
) : (
<OperationContent nodeProgress={nodeProgress} />
)}
</>
)}
</Flex>
);
};
Loading

0 comments on commit a445c06

Please sign in to comment.