|
|
@ -18,19 +18,26 @@ |
|
|
|
import { defineComponent, ref, inject } from 'vue' |
|
|
|
import { defineComponent, ref, inject } from 'vue' |
|
|
|
import { useI18n } from 'vue-i18n' |
|
|
|
import { useI18n } from 'vue-i18n' |
|
|
|
import Styles from './dag.module.scss' |
|
|
|
import Styles from './dag.module.scss' |
|
|
|
import { NTooltip, NIcon, NButton, NSelect } from 'naive-ui'; |
|
|
|
import { NTooltip, NIcon, NButton, NSelect } from 'naive-ui' |
|
|
|
import { SearchOutlined, DownloadOutlined, FullscreenOutlined, FullscreenExitOutlined, InfoCircleOutlined, FormatPainterOutlined } from '@vicons/antd'; |
|
|
|
import { |
|
|
|
import { useNodeSearch } from './dag-hooks'; |
|
|
|
SearchOutlined, |
|
|
|
|
|
|
|
DownloadOutlined, |
|
|
|
|
|
|
|
FullscreenOutlined, |
|
|
|
|
|
|
|
FullscreenExitOutlined, |
|
|
|
|
|
|
|
InfoCircleOutlined, |
|
|
|
|
|
|
|
FormatPainterOutlined |
|
|
|
|
|
|
|
} from '@vicons/antd' |
|
|
|
|
|
|
|
import { useNodeSearch } from './dag-hooks' |
|
|
|
import { DataUri } from '@antv/x6' |
|
|
|
import { DataUri } from '@antv/x6' |
|
|
|
import { useFullscreen } from '@vueuse/core'; |
|
|
|
import { useFullscreen } from '@vueuse/core' |
|
|
|
import { useRouter } from 'vue-router'; |
|
|
|
import { useRouter } from 'vue-router' |
|
|
|
|
|
|
|
|
|
|
|
export default defineComponent({ |
|
|
|
export default defineComponent({ |
|
|
|
name: "workflow-dag-toolbar", |
|
|
|
name: 'workflow-dag-toolbar', |
|
|
|
setup(props, context) { |
|
|
|
setup(props, context) { |
|
|
|
const { t } = useI18n(); |
|
|
|
const { t } = useI18n() |
|
|
|
const graph = inject('graph', ref()); |
|
|
|
const graph = inject('graph', ref()) |
|
|
|
const router = useRouter(); |
|
|
|
const router = useRouter() |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Node search and navigate |
|
|
|
* Node search and navigate |
|
|
@ -41,15 +48,15 @@ export default defineComponent({ |
|
|
|
allNodes, |
|
|
|
allNodes, |
|
|
|
toggleSearchInput, |
|
|
|
toggleSearchInput, |
|
|
|
searchInputVisible |
|
|
|
searchInputVisible |
|
|
|
} = useNodeSearch({ graph }); |
|
|
|
} = useNodeSearch({ graph }) |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Download Workflow Image |
|
|
|
* Download Workflow Image |
|
|
|
* @param {string} fileName |
|
|
|
* @param {string} fileName |
|
|
|
* @param {string} bgColor
|
|
|
|
* @param {string} bgColor |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
const downloadPNG = (options = { fileName: 'dag', bgColor: '#f2f3f7' }) => { |
|
|
|
const downloadPNG = (options = { fileName: 'dag', bgColor: '#f2f3f7' }) => { |
|
|
|
const { fileName, bgColor } = options; |
|
|
|
const { fileName, bgColor } = options |
|
|
|
graph.value?.toPNG( |
|
|
|
graph.value?.toPNG( |
|
|
|
(dataUri: string) => { |
|
|
|
(dataUri: string) => { |
|
|
|
DataUri.downloadDataUri(dataUri, `${fileName}.png`) |
|
|
|
DataUri.downloadDataUri(dataUri, `${fileName}.png`) |
|
|
@ -69,8 +76,7 @@ export default defineComponent({ |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Toggle fullscreen |
|
|
|
* Toggle fullscreen |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
const { isFullscreen, toggle } = useFullscreen(); |
|
|
|
const { isFullscreen, toggle } = useFullscreen() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Open workflow version modal |
|
|
|
* Open workflow version modal |
|
|
@ -82,9 +88,7 @@ export default defineComponent({ |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Open DAG format modal |
|
|
|
* Open DAG format modal |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
const openDagFormatModal = () => { |
|
|
|
const openDagFormatModal = () => {} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const onClose = () => { |
|
|
|
const onClose = () => { |
|
|
|
router.go(-1) |
|
|
|
router.go(-1) |
|
|
@ -92,89 +96,160 @@ export default defineComponent({ |
|
|
|
|
|
|
|
|
|
|
|
return () => ( |
|
|
|
return () => ( |
|
|
|
<div class={Styles.toolbar}> |
|
|
|
<div class={Styles.toolbar}> |
|
|
|
<span class={Styles['workflow-name']}>{t("project.dag.createWorkflow")}</span> |
|
|
|
<span class={Styles['workflow-name']}> |
|
|
|
|
|
|
|
{t('project.dag.createWorkflow')} |
|
|
|
|
|
|
|
</span> |
|
|
|
<div class={Styles['toolbar-right-part']}> |
|
|
|
<div class={Styles['toolbar-right-part']}> |
|
|
|
{/* Search node */} |
|
|
|
{/* Search node */} |
|
|
|
<NTooltip v-slots={{ |
|
|
|
<NTooltip |
|
|
|
trigger: () => ( |
|
|
|
v-slots={{ |
|
|
|
<NButton class={Styles['toolbar-right-item']} strong secondary circle type="info" onClick={toggleSearchInput} v-slots={{ |
|
|
|
trigger: () => ( |
|
|
|
icon: () => ( |
|
|
|
<NButton |
|
|
|
<NIcon> |
|
|
|
class={Styles['toolbar-right-item']} |
|
|
|
<SearchOutlined /> |
|
|
|
strong |
|
|
|
</NIcon> |
|
|
|
secondary |
|
|
|
) |
|
|
|
circle |
|
|
|
}} /> |
|
|
|
type='info' |
|
|
|
), |
|
|
|
onClick={toggleSearchInput} |
|
|
|
default: () => t('project.dag.search') |
|
|
|
v-slots={{ |
|
|
|
}}> |
|
|
|
icon: () => ( |
|
|
|
</NTooltip> |
|
|
|
<NIcon> |
|
|
|
|
|
|
|
<SearchOutlined /> |
|
|
|
|
|
|
|
</NIcon> |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
default: () => t('project.dag.search') |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
></NTooltip> |
|
|
|
<div |
|
|
|
<div |
|
|
|
class={`${Styles['toolbar-right-item']} ${Styles['node-selector']} ${searchInputVisible.value ? Styles['visible'] : ''}`} |
|
|
|
class={`${Styles['toolbar-right-item']} ${ |
|
|
|
|
|
|
|
Styles['node-selector'] |
|
|
|
|
|
|
|
} ${searchInputVisible.value ? Styles['visible'] : ''}`}
|
|
|
|
> |
|
|
|
> |
|
|
|
<NSelect size="small" options={allNodes.value} onFocus={getAllNodes} onUpdateValue={searchNode} filterable /> |
|
|
|
<NSelect |
|
|
|
|
|
|
|
size='small' |
|
|
|
|
|
|
|
options={allNodes.value} |
|
|
|
|
|
|
|
onFocus={getAllNodes} |
|
|
|
|
|
|
|
onUpdateValue={searchNode} |
|
|
|
|
|
|
|
filterable |
|
|
|
|
|
|
|
/> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
{/* Download workflow PNG */} |
|
|
|
{/* Download workflow PNG */} |
|
|
|
<NTooltip v-slots={{ |
|
|
|
<NTooltip |
|
|
|
trigger: () => ( |
|
|
|
v-slots={{ |
|
|
|
<NButton class={Styles['toolbar-right-item']} strong secondary circle type="info" onClick={() => downloadPNG()} v-slots={{ |
|
|
|
trigger: () => ( |
|
|
|
icon: () => ( |
|
|
|
<NButton |
|
|
|
<NIcon> |
|
|
|
class={Styles['toolbar-right-item']} |
|
|
|
<DownloadOutlined /> |
|
|
|
strong |
|
|
|
</NIcon> |
|
|
|
secondary |
|
|
|
) |
|
|
|
circle |
|
|
|
}} /> |
|
|
|
type='info' |
|
|
|
), |
|
|
|
onClick={() => downloadPNG()} |
|
|
|
default: () => t('project.dag.download_png') |
|
|
|
v-slots={{ |
|
|
|
}}> |
|
|
|
icon: () => ( |
|
|
|
</NTooltip> |
|
|
|
<NIcon> |
|
|
|
|
|
|
|
<DownloadOutlined /> |
|
|
|
|
|
|
|
</NIcon> |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
default: () => t('project.dag.download_png') |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
></NTooltip> |
|
|
|
{/* Toggle fullscreen */} |
|
|
|
{/* Toggle fullscreen */} |
|
|
|
<NTooltip v-slots={{ |
|
|
|
<NTooltip |
|
|
|
trigger: () => ( |
|
|
|
v-slots={{ |
|
|
|
<NButton class={Styles['toolbar-right-item']} strong secondary circle type="info" onClick={toggle} v-slots={{ |
|
|
|
trigger: () => ( |
|
|
|
icon: () => ( |
|
|
|
<NButton |
|
|
|
<NIcon> |
|
|
|
class={Styles['toolbar-right-item']} |
|
|
|
{isFullscreen.value ? <FullscreenExitOutlined /> : <FullscreenOutlined />} |
|
|
|
strong |
|
|
|
</NIcon> |
|
|
|
secondary |
|
|
|
) |
|
|
|
circle |
|
|
|
}} /> |
|
|
|
type='info' |
|
|
|
), |
|
|
|
onClick={toggle} |
|
|
|
default: () => isFullscreen.value ? t('project.dag.fullscreen_close') : t('project.dag.fullscreen_open') |
|
|
|
v-slots={{ |
|
|
|
}}> |
|
|
|
icon: () => ( |
|
|
|
</NTooltip> |
|
|
|
<NIcon> |
|
|
|
|
|
|
|
{isFullscreen.value ? ( |
|
|
|
|
|
|
|
<FullscreenExitOutlined /> |
|
|
|
|
|
|
|
) : ( |
|
|
|
|
|
|
|
<FullscreenOutlined /> |
|
|
|
|
|
|
|
)} |
|
|
|
|
|
|
|
</NIcon> |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
default: () => |
|
|
|
|
|
|
|
isFullscreen.value |
|
|
|
|
|
|
|
? t('project.dag.fullscreen_close') |
|
|
|
|
|
|
|
: t('project.dag.fullscreen_open') |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
></NTooltip> |
|
|
|
{/* DAG Format */} |
|
|
|
{/* DAG Format */} |
|
|
|
<NTooltip v-slots={{ |
|
|
|
<NTooltip |
|
|
|
trigger: () => ( |
|
|
|
v-slots={{ |
|
|
|
<NButton class={Styles['toolbar-right-item']} strong secondary circle type="info" onClick={openDagFormatModal} v-slots={{ |
|
|
|
trigger: () => ( |
|
|
|
icon: () => ( |
|
|
|
<NButton |
|
|
|
<NIcon> |
|
|
|
class={Styles['toolbar-right-item']} |
|
|
|
<FormatPainterOutlined /> |
|
|
|
strong |
|
|
|
</NIcon> |
|
|
|
secondary |
|
|
|
) |
|
|
|
circle |
|
|
|
}} /> |
|
|
|
type='info' |
|
|
|
), |
|
|
|
onClick={openDagFormatModal} |
|
|
|
default: () => t('project.dag.format') |
|
|
|
v-slots={{ |
|
|
|
}}> |
|
|
|
icon: () => ( |
|
|
|
</NTooltip> |
|
|
|
<NIcon> |
|
|
|
|
|
|
|
<FormatPainterOutlined /> |
|
|
|
|
|
|
|
</NIcon> |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
default: () => t('project.dag.format') |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
></NTooltip> |
|
|
|
{/* Version info */} |
|
|
|
{/* Version info */} |
|
|
|
<NTooltip v-slots={{ |
|
|
|
<NTooltip |
|
|
|
trigger: () => ( |
|
|
|
v-slots={{ |
|
|
|
<NButton class={Styles['toolbar-right-item']} strong secondary circle type="info" onClick={openVersionModal} v-slots={{ |
|
|
|
trigger: () => ( |
|
|
|
icon: () => ( |
|
|
|
<NButton |
|
|
|
<NIcon> |
|
|
|
class={Styles['toolbar-right-item']} |
|
|
|
<InfoCircleOutlined /> |
|
|
|
strong |
|
|
|
</NIcon> |
|
|
|
secondary |
|
|
|
) |
|
|
|
circle |
|
|
|
}} /> |
|
|
|
type='info' |
|
|
|
), |
|
|
|
onClick={openVersionModal} |
|
|
|
default: () => t('project.dag.workflow_version') |
|
|
|
v-slots={{ |
|
|
|
}}> |
|
|
|
icon: () => ( |
|
|
|
</NTooltip> |
|
|
|
<NIcon> |
|
|
|
|
|
|
|
<InfoCircleOutlined /> |
|
|
|
|
|
|
|
</NIcon> |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
default: () => t('project.dag.workflow_version') |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
></NTooltip> |
|
|
|
{/* Save workflow */} |
|
|
|
{/* Save workflow */} |
|
|
|
<NButton class={Styles['toolbar-right-item']} type="info" secondary round>{t('project.dag.save')}</NButton> |
|
|
|
<NButton |
|
|
|
|
|
|
|
class={Styles['toolbar-right-item']} |
|
|
|
|
|
|
|
type='info' |
|
|
|
|
|
|
|
secondary |
|
|
|
|
|
|
|
round |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{t('project.dag.save')} |
|
|
|
|
|
|
|
</NButton> |
|
|
|
{/* Return to previous page */} |
|
|
|
{/* Return to previous page */} |
|
|
|
<NButton secondary round onClick={onClose}>{t('project.dag.close')}</NButton> |
|
|
|
<NButton secondary round onClick={onClose}> |
|
|
|
|
|
|
|
{t('project.dag.close')} |
|
|
|
|
|
|
|
</NButton> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|