-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
112 additions
and
312 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
packages/ui/src/ui/components/StatisticTable/get-min-width.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import {LEVEL_OFFSET} from './StatisticTable'; | ||
|
||
export function createCanvasContext(font: string) { | ||
const canvas = document.createElement('canvas'); | ||
const ctx = canvas.getContext('2d'); | ||
ctx!.font = font; | ||
return ctx!; | ||
} | ||
|
||
export function mesureRowWidth(ctx: CanvasRenderingContext2D, text = '') { | ||
const {width} = ctx.measureText(text); | ||
return Math.max(1, Math.ceil(width)); | ||
} | ||
|
||
export const getMinWidth = (items: any[], fontFamilies: {regular: string; monospace: string}) => { | ||
let res = 300; | ||
const ctx = createCanvasContext( | ||
`14px / 20.02px "${fontFamilies.regular}", "Helvetica Neue", Arial, Helvetica, sans-serif`, | ||
); | ||
|
||
for (const item of items) { | ||
const iconsWidth = item.isLeafNode ? 20 : 20 * 2; | ||
const width = mesureRowWidth(ctx, item.attributes.name); | ||
res = Math.max(res, width + iconsWidth + item.level * LEVEL_OFFSET); | ||
} | ||
return Math.round(res * 1.05); | ||
}; |
29 changes: 29 additions & 0 deletions
29
packages/ui/src/ui/components/StatisticTable/prepare-job-statistic.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import hammer from '../../common/hammer'; | ||
import {JobStatistic, JobTree, MetricsEntry} from '../../types/job'; | ||
import {prepareMetricsTree} from '../../utils/job/tabs/statistics'; | ||
|
||
export function filterJobStatisticTree(tree: JobTree, currentFilter = '') { | ||
const filteredTree = hammer.treeList.filterTree( | ||
tree, | ||
(entry: MetricsEntry) => entry.name.indexOf(currentFilter) !== -1, | ||
true, | ||
); | ||
|
||
const sortedTree = hammer.treeList.sortTree( | ||
filteredTree, | ||
{field: 'name', asc: true}, | ||
{ | ||
name: { | ||
get: function (entry: MetricsEntry) { | ||
return entry.name; | ||
}, | ||
}, | ||
}, | ||
); | ||
|
||
return hammer.treeList.flattenTree(sortedTree); | ||
} | ||
|
||
export const prepareJobStatistic = (statistic: JobStatistic) => { | ||
return prepareMetricsTree(statistic); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 3 additions & 11 deletions
14
packages/ui/src/ui/pages/job/tabs/Statistics/Statistics.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 3 additions & 5 deletions
8
packages/ui/src/ui/pages/query-tracker/QueryResultsView/YQLStatistics/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
import {useSelector} from 'react-redux'; | ||
import React from 'react'; | ||
|
||
import {getProgressYQLStatisticsFiltered} from '../../module/query/selectors'; | ||
import {changeProgressYQLStatisticsFilter} from '../../module/query/actions'; | ||
import {getProgressYQLStatistics} from '../../module/query/selectors'; | ||
import {StatisticTable} from '../../../../components/StatisticTable/StatisticTable'; | ||
|
||
import './index.scss'; | ||
|
||
export function YQLStatisticsTable() { | ||
const items = useSelector(getProgressYQLStatisticsFiltered); | ||
const statistics = useSelector(getProgressYQLStatistics); | ||
|
||
return ( | ||
<StatisticTable | ||
fixedHeader | ||
virtual={false} | ||
items={items} | ||
statistic={statistics} | ||
visibleColumns={['min', 'max', 'avg', 'sum', 'count']} | ||
onFilterChange={changeProgressYQLStatisticsFilter} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.