|
5 | 5 |
|
6 | 6 | import type { RootNode } from '$lib/services/workflow-service';
|
7 | 7 | import type { WorkflowExecution } from '$lib/types/workflows';
|
| 8 | + import { |
| 9 | + routeForRelationships, |
| 10 | + routeForSchedule, |
| 11 | + } from '$lib/utilities/route-for'; |
8 | 12 |
|
| 13 | + export let fullTree = false; |
9 | 14 | export let root: RootNode;
|
10 | 15 | export let width: number;
|
11 | 16 | export let height: number;
|
|
17 | 22 | export let expandAll: boolean;
|
18 | 23 | export let onNodeClick: (node: RootNode, generation: number) => void;
|
19 | 24 | export let activeWorkflow: WorkflowExecution | undefined = undefined;
|
| 25 | + export let first: string | undefined; |
| 26 | + export let previous: string | undefined; |
| 27 | + export let next: string | undefined; |
20 | 28 |
|
21 |
| - $: ({ workflow, run } = $page.params); |
| 29 | + $: ({ workflow, run, namespace } = $page.params); |
22 | 30 |
|
23 | 31 | const getPositions = (
|
24 | 32 | width: number,
|
|
128 | 136 | {openRuns}
|
129 | 137 | {onNodeClick}
|
130 | 138 | {activeWorkflow}
|
| 139 | + {fullTree} |
131 | 140 | />
|
132 | 141 | {/if}
|
133 | 142 | <line
|
|
196 | 205 | font-weight="500">{child.children.length}</text
|
197 | 206 | >
|
198 | 207 | {/if}
|
| 208 | + {#if !fullTree} |
| 209 | + <text |
| 210 | + x={childX} |
| 211 | + y={!child?.children?.length ? childY + radius : childY - radius} |
| 212 | + class="text-center text-lg {!child?.children?.length && |
| 213 | + '[writing-mode:vertical-lr]'}" |
| 214 | + fill="currentColor" |
| 215 | + text-anchor={!child?.children?.length ? 'start' : 'middle'} |
| 216 | + font-weight="500">{child.workflow.id}</text |
| 217 | + > |
| 218 | + {/if} |
199 | 219 | </g>
|
200 | 220 | {/each}
|
201 | 221 |
|
|
207 | 227 | on:click={(e) => nodeClick(e, root)}
|
208 | 228 | on:keypress={(e) => nodeClick(e, root)}
|
209 | 229 | >
|
| 230 | + {#if root?.scheduleId} |
| 231 | + <line |
| 232 | + x1={x} |
| 233 | + y1={y} |
| 234 | + x2={x} |
| 235 | + y2={y - 2.5 * radius} |
| 236 | + stroke-dasharray="3 2" |
| 237 | + class="stroke-slate-100 stroke-2 transition-all duration-300 ease-in-out dark:stroke-slate-800" |
| 238 | + /> |
| 239 | + <line |
| 240 | + x1={x - 5 * radius} |
| 241 | + y1={y - 2.5 * radius} |
| 242 | + x2={x} |
| 243 | + y2={y - 2.5 * radius} |
| 244 | + stroke-dasharray="3 2" |
| 245 | + class="stroke-slate-100 stroke-2 transition-all duration-300 ease-in-out dark:stroke-slate-800" |
| 246 | + /> |
| 247 | + <a href={routeForSchedule({ namespace, scheduleId: root.scheduleId })}> |
| 248 | + <text |
| 249 | + x={x - 5.25 * radius} |
| 250 | + y={y - 2.5 * radius} |
| 251 | + fill="currentColor" |
| 252 | + text-decoration="underline" |
| 253 | + text-anchor="end" |
| 254 | + font-weight="500">{root.scheduleId}</text |
| 255 | + > |
| 256 | + </a> |
| 257 | + {/if} |
| 258 | + {#if next} |
| 259 | + <line |
| 260 | + x1={x} |
| 261 | + y1={y} |
| 262 | + x2={x + 4 * radius} |
| 263 | + y2={y} |
| 264 | + class="stroke-slate-100 stroke-2 transition-all duration-300 ease-in-out dark:stroke-slate-800" |
| 265 | + /> |
| 266 | + <text |
| 267 | + x={x + 4.25 * radius} |
| 268 | + y={y - 4} |
| 269 | + fill="currentColor" |
| 270 | + text-anchor="start" |
| 271 | + font-weight="500">Next Execution</text |
| 272 | + > |
| 273 | + <a href={routeForRelationships({ namespace, workflow, run: next })}> |
| 274 | + <text |
| 275 | + x={x + 4.25 * radius} |
| 276 | + y={y + radius - 4} |
| 277 | + fill="currentColor" |
| 278 | + text-decoration="underline" |
| 279 | + text-anchor="start" |
| 280 | + font-weight="500">{next}</text |
| 281 | + > |
| 282 | + </a> |
| 283 | + {/if} |
| 284 | + {#if previous} |
| 285 | + <line |
| 286 | + x1={x} |
| 287 | + y1={y} |
| 288 | + x2={x - 4 * radius} |
| 289 | + y2={y} |
| 290 | + class="stroke-slate-100 stroke-2 transition-all duration-300 ease-in-out dark:stroke-slate-800" |
| 291 | + /> |
| 292 | + <text |
| 293 | + x={x - 4.25 * radius} |
| 294 | + y={y - 4} |
| 295 | + fill="currentColor" |
| 296 | + text-anchor="end" |
| 297 | + font-weight="500" |
| 298 | + >{previous === first ? 'First' : 'Previous'} Execution</text |
| 299 | + > |
| 300 | + <a href={routeForRelationships({ namespace, workflow, run: previous })}> |
| 301 | + <text |
| 302 | + href={routeForRelationships({ namespace, workflow, run: previous })} |
| 303 | + x={x - 4.25 * radius} |
| 304 | + y={y + radius - 4} |
| 305 | + fill="currentColor" |
| 306 | + text-decoration="underline" |
| 307 | + text-anchor="end" |
| 308 | + font-weight="500">{previous}</text |
| 309 | + > |
| 310 | + </a> |
| 311 | + {/if} |
| 312 | + {#if first && previous !== first} |
| 313 | + <line |
| 314 | + x1={x - 4 * radius} |
| 315 | + y1={y} |
| 316 | + x2={radius} |
| 317 | + y2={y} |
| 318 | + stroke-dasharray="3 2" |
| 319 | + class="stroke-slate-100 stroke-2 transition-all duration-300 ease-in-out dark:stroke-slate-800" |
| 320 | + /> |
| 321 | + <text |
| 322 | + x={radius} |
| 323 | + y={y - 4} |
| 324 | + fill="currentColor" |
| 325 | + text-anchor="start" |
| 326 | + font-weight="500">First Execution</text |
| 327 | + > |
| 328 | + <a href={routeForRelationships({ namespace, workflow, run: first })}> |
| 329 | + <text |
| 330 | + x={radius} |
| 331 | + y={y + radius - 4} |
| 332 | + fill="currentColor" |
| 333 | + text-decoration="underline" |
| 334 | + text-anchor="start" |
| 335 | + font-weight="500">{first}</text |
| 336 | + > |
| 337 | + </a> |
| 338 | + {/if} |
210 | 339 | {#if root?.children?.length}
|
211 | 340 | <line
|
212 | 341 | x1={x}
|
|
248 | 377 | {#if root?.children?.length}
|
249 | 378 | <text
|
250 | 379 | {x}
|
251 |
| - y={y - radius * 1.5} |
252 |
| - class="text-center font-mono text-lg" |
| 380 | + y={y - radius} |
| 381 | + class="text-center {fullTree && 'font-mono'} text-lg" |
253 | 382 | fill="currentColor"
|
254 | 383 | text-anchor="middle"
|
255 |
| - font-weight="500">{root.children.length}</text |
| 384 | + font-weight="500" |
| 385 | + >{fullTree ? root.children.length : root.workflow.id}</text |
256 | 386 | >
|
257 | 387 | {/if}
|
258 | 388 | </g>
|
|
0 commit comments