Skip to content

Commit 0ed3745

Browse files
committed
ui: stop animation when not running
1 parent 7bb57b5 commit 0ed3745

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

ui/src/components/molecules/Graph.tsx

+30-10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type Props = {
1212
steps?: Step[] | Node[];
1313
onClickNode?: onClickNode;
1414
showIcons?: boolean;
15+
animate?: boolean;
1516
};
1617

1718
declare global {
@@ -26,6 +27,7 @@ const Graph: React.FC<Props> = ({
2627
type = 'status',
2728
onClickNode,
2829
showIcons = true,
30+
animate = true,
2931
}) => {
3032
// Calculate width based on flowchart type and graph breadth
3133
const width = React.useMemo(() => {
@@ -58,11 +60,11 @@ const Graph: React.FC<Props> = ({
5860
};
5961

6062
// Define FontAwesome icons for each status with colors and animations
61-
const statusIcons = {
63+
const statusIcons: { [key: number]: string } = {
6264
[NodeStatus.None]:
63-
"<i class='fas fa-circle-notch fa-spin' style='color: #3b82f6; animation: spin 2s linear infinite'></i>",
65+
"<i class='fas fa-circle-notch' style='color: #3b82f6; animation: spin 2s linear infinite;'></i>",
6466
[NodeStatus.Running]:
65-
"<i class='fas fa-spinner fa-spin' style='color: #22c55e; animation: spin 1s linear infinite'></i>",
67+
"<i class='fas fa-spinner' style='color: #22c55e; animation: spin 1s linear infinite;'></i>",
6668
[NodeStatus.Error]:
6769
"<i class='fas fa-exclamation-circle' style='color: #ef4444'></i>",
6870
[NodeStatus.Cancel]: "<i class='fas fa-ban' style='color: #ec4899'></i>",
@@ -71,6 +73,12 @@ const Graph: React.FC<Props> = ({
7173
[NodeStatus.Skipped]:
7274
"<i class='fas fa-forward' style='color: #64748b'></i>",
7375
};
76+
if (!animate) {
77+
// Remove animations if disabled
78+
Object.keys(statusIcons).forEach((key: string) => {
79+
statusIcons[+key] = statusIcons[+key].replace(/animation:.*?;/g, '');
80+
});
81+
}
7482

7583
const graph = React.useMemo(() => {
7684
if (!steps) return '';
@@ -138,12 +146,24 @@ const Graph: React.FC<Props> = ({
138146
}
139147

140148
// Define node styles for different states with refined colors
141-
dat.push('classDef none fill:#f0f9ff,stroke:#93c5fd,color:#1e40af,stroke-width:1.2px,white-space:nowrap');
142-
dat.push('classDef running fill:#f0fdf4,stroke:#86efac,color:#166534,stroke-width:1.2px,white-space:nowrap');
143-
dat.push('classDef error fill:#fef2f2,stroke:#fca5a5,color:#aa1010,stroke-width:1.2px,white-space:nowrap');
144-
dat.push('classDef cancel fill:#fdf2f8,stroke:#f9a8d4,color:#9d174d,stroke-width:1.2px,white-space:nowrap');
145-
dat.push('classDef done fill:#f0fdf4,stroke:#86efac,color:#166534,stroke-width:1.2px,white-space:nowrap');
146-
dat.push('classDef skipped fill:#f8fafc,stroke:#cbd5e1,color:#475569,stroke-width:1.2px,white-space:nowrap');
149+
dat.push(
150+
'classDef none fill:#f0f9ff,stroke:#93c5fd,color:#1e40af,stroke-width:1.2px,white-space:nowrap'
151+
);
152+
dat.push(
153+
'classDef running fill:#f0fdf4,stroke:#86efac,color:#166534,stroke-width:1.2px,white-space:nowrap'
154+
);
155+
dat.push(
156+
'classDef error fill:#fef2f2,stroke:#fca5a5,color:#aa1010,stroke-width:1.2px,white-space:nowrap'
157+
);
158+
dat.push(
159+
'classDef cancel fill:#fdf2f8,stroke:#f9a8d4,color:#9d174d,stroke-width:1.2px,white-space:nowrap'
160+
);
161+
dat.push(
162+
'classDef done fill:#f0fdf4,stroke:#86efac,color:#166534,stroke-width:1.2px,white-space:nowrap'
163+
);
164+
dat.push(
165+
'classDef skipped fill:#f8fafc,stroke:#cbd5e1,color:#475569,stroke-width:1.2px,white-space:nowrap'
166+
);
147167

148168
// Add custom link styles
149169
dat.push(...linkStyles);
@@ -220,4 +240,4 @@ const graphStatusMap = {
220240
[NodeStatus.Cancel]: ':::cancel',
221241
[NodeStatus.Success]: ':::done',
222242
[NodeStatus.Skipped]: ':::skipped',
223-
};
243+
};

ui/src/components/organizations/DAGStatus.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ function DAGStatus({ DAG, name, refresh }: Props) {
128128
flowchart={flowchart}
129129
onClickNode={onSelectStepOnGraph}
130130
showIcons={DAG.Status.Status != SchedulerStatus.None}
131+
animate={DAG.Status.Status == SchedulerStatus.Running}
131132
></Graph>
132133
) : (
133134
<TimelineChart status={DAG.Status}></TimelineChart>

0 commit comments

Comments
 (0)