diff --git a/dolphinscheduler-ui/src/views/projects/workflow/components/dag/index.tsx b/dolphinscheduler-ui/src/views/projects/workflow/components/dag/index.tsx index 9d419f2657e2824ce4942f380e88882227f817b8..b573ed3f380daa6e5bf61fabba75066001b99123 100644 --- a/dolphinscheduler-ui/src/views/projects/workflow/components/dag/index.tsx +++ b/dolphinscheduler-ui/src/views/projects/workflow/components/dag/index.tsx @@ -89,6 +89,7 @@ export default defineComponent({ const graph = ref() provide('graph', graph) + context.expose(graph) // Auto layout modal const { diff --git a/dolphinscheduler-ui/src/views/projects/workflow/components/dag/use-graph-auto-layout.ts b/dolphinscheduler-ui/src/views/projects/workflow/components/dag/use-graph-auto-layout.ts index de3301829c140b5c17288a941f2b6fbb8e41c2d6..853e7adc636af44f0b838bda1670453d7c30da02 100644 --- a/dolphinscheduler-ui/src/views/projects/workflow/components/dag/use-graph-auto-layout.ts +++ b/dolphinscheduler-ui/src/views/projects/workflow/components/dag/use-graph-auto-layout.ts @@ -80,7 +80,7 @@ export function useGraphAutoLayout(options: Options) { * @returns */ function format(layoutConfig: LayoutConfig) { - if (!layoutConfig) { + if (Object.keys(layoutConfig).length === 0) { layoutConfig = DEFAULT_LAYOUT_CONFIG } const graph = graphRef?.value diff --git a/dolphinscheduler-ui/src/views/projects/workflow/definition/detail/index.tsx b/dolphinscheduler-ui/src/views/projects/workflow/definition/detail/index.tsx index 1da1c34774b151770f2677c21cd232547f9a452c..8a090f5b0957db696f5e8a5f713fa1822f284af9 100644 --- a/dolphinscheduler-ui/src/views/projects/workflow/definition/detail/index.tsx +++ b/dolphinscheduler-ui/src/views/projects/workflow/definition/detail/index.tsx @@ -33,6 +33,7 @@ import { Location } from '../../components/dag/types' import Styles from './index.module.scss' +import { useGraphAutoLayout } from '../../components/dag/use-graph-auto-layout' interface SaveData { saveForm: SaveForm @@ -55,6 +56,7 @@ export default defineComponent({ const definition = ref() const readonly = ref(false) const isLoading = ref(true) + const dagRef = ref() const refresh = () => { isLoading.value = true @@ -62,6 +64,13 @@ export default defineComponent({ readonly.value = res.processDefinition.releaseState === 'ONLINE' definition.value = res isLoading.value = false + if (!res.processDefinition.locations) { + setTimeout(() => { + const graph = dagRef.value + const { submit } = useGraphAutoLayout({ graph }) + submit() + }, 1000) + } }) } @@ -115,6 +124,7 @@ export default defineComponent({ > {!isLoading.value && (