Skip to content

Commit a533818

Browse files
committed
metrics
1 parent 086c150 commit a533818

File tree

3 files changed

+95
-1
lines changed

3 files changed

+95
-1
lines changed

src/pages/scientificServices/pipelines/tabs/history/details/JobDetails.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { useCancellation } from 'src/libs/react-utils';
99
import { pipelinesTopBar } from 'src/pages/scientificServices/pipelines/common/scientific-services-common';
1010
import { JobBasics } from 'src/pages/scientificServices/pipelines/tabs/history/details/components/JobBasics';
1111
import { JobInputsOutputs } from 'src/pages/scientificServices/pipelines/tabs/history/details/components/JobInputsOutputs';
12+
import { JobMetrics } from 'src/pages/scientificServices/pipelines/tabs/history/details/components/JobMetrics';
1213
import { JobTimeline } from 'src/pages/scientificServices/pipelines/tabs/history/details/components/JobTimeline';
1314

1415
export interface JobDetailsProps {
@@ -116,6 +117,7 @@ export const JobDetails = ({ jobId }: JobDetailsProps) => {
116117
{/* Inputs & Outputs - 2/3 width */}
117118
<div style={{ flex: '0 0 calc(66.667% - 0.5rem)' }}>
118119
<JobInputsOutputs pipelineRunResult={pipelineRunResult} />
120+
<JobMetrics pipelineRunResult={pipelineRunResult} />
119121
</div>
120122
</div>
121123
</div>
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import { ButtonPrimary, Icon } from '@terra-ui-packages/components';
2+
import { TooltipTrigger } from '@terra-ui-packages/components';
3+
import React from 'react';
4+
import { PipelineRunResponse } from 'src/libs/ajax/teaspoons/teaspoons-models';
5+
import colors from 'src/libs/colors';
6+
import { usePipelineDetails } from 'src/pages/scientificServices/pipelines/hooks/usePipelineDetails';
7+
import { PipelineWidgetContainer } from 'src/pages/scientificServices/pipelines/tabs/run/widgets/PipelineWidgetContainer';
8+
9+
interface JobMetricsProps {
10+
pipelineRunResult: PipelineRunResponse;
11+
}
12+
13+
// Mock file sizes for demonstration
14+
const MOCK_METRICS: Record<string, string> = {
15+
'Total number of contigs processed': '2',
16+
'Total number of variants in raw input': '65234',
17+
'Total number of variants in filtered input': '64295',
18+
'Percent input variants passing filtering': '98.6%',
19+
'Total number of filtered variants matching reference panel': '63696',
20+
'Percent filtered variants matching reference panel': '99.1%',
21+
};
22+
23+
const InfoItem = ({ label, value }: { label: string; value: React.ReactNode }) => (
24+
<div>
25+
<div style={{ marginBottom: '0.5rem', fontWeight: 500 }}>
26+
<TooltipTrigger content='Here is a full description for the input'>
27+
<span>{label}</span>
28+
</TooltipTrigger>
29+
</div>
30+
<div style={{ color: colors.dark(), wordBreak: 'break-all' }}>{value}</div>
31+
</div>
32+
);
33+
34+
const OutputItem = ({ label, url, fileSize }: { label: string; url: string; fileSize: string }) => {
35+
return (
36+
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
37+
<div style={{ flex: 1 }}>
38+
<div style={{ marginBottom: '0.5rem', fontWeight: 500 }}>{label}</div>
39+
<div style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}>
40+
<span>{fileSize}</span>
41+
</div>
42+
</div>
43+
<ButtonPrimary
44+
onClick={() => {
45+
console.log(url);
46+
}}
47+
style={{
48+
display: 'flex',
49+
alignItems: 'center',
50+
padding: '0.75rem',
51+
gap: '0.25rem',
52+
borderRadius: '4px',
53+
cursor: 'pointer',
54+
marginLeft: '1rem',
55+
}}
56+
>
57+
<Icon icon='download' size={16} />
58+
</ButtonPrimary>
59+
</div>
60+
);
61+
};
62+
63+
export const JobMetrics = ({ pipelineRunResult }: JobMetricsProps) => {
64+
const { pipelineDetails, isLoading } = usePipelineDetails(
65+
pipelineRunResult.pipelineRunReport.pipelineName,
66+
pipelineRunResult.pipelineRunReport.pipelineVersion
67+
);
68+
69+
const hasOutputs =
70+
pipelineRunResult.pipelineRunReport.outputs && Object.keys(pipelineRunResult.pipelineRunReport.outputs).length > 0;
71+
72+
return (
73+
<PipelineWidgetContainer title='Metrics' border='1px solid #d7d9dc' showIcon={false}>
74+
{isLoading ? (
75+
<div style={{ color: colors.dark(0.6) }}>Loading...</div>
76+
) : (
77+
<div style={{ display: 'flex', gap: '2rem', alignItems: 'center' }}>
78+
{/* Metrics Column */}
79+
<div style={{ flex: 1 }}>
80+
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: '1.5rem' }}>
81+
{Object.entries(MOCK_METRICS).map(([label, value]) => (
82+
<InfoItem key={label} label={label} value={value} />
83+
))}
84+
</div>
85+
</div>
86+
</div>
87+
)}
88+
</PipelineWidgetContainer>
89+
);
90+
};

src/pages/scientificServices/pipelines/tabs/history/details/components/JobTimeline.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ export const JobTimeline = ({ pipelineRunResult }: JobTimelineProps) => {
130130
color: colors.dark(0.7),
131131
}}
132132
>
133-
<div style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}>
133+
<div
134+
style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: '0.5rem' }}
135+
>
134136
<div>524 samples </div>
135137
<div
136138
style={{

0 commit comments

Comments
 (0)