Browse Source

feat: dynamic-dag-sidebar-change (#14244)

3.2.1-prepare
pppppjcc 1 year ago committed by GitHub
parent
commit
906353bbaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-k8s.ts
  2. 172
      dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-node-selectors.ts
  3. 39
      dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/dag-sidebar.module.scss
  4. 38
      dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/dag-sidebar.tsx

19
dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-k8s.ts

@ -14,7 +14,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { useCustomParams, useNamespace, useCustomLabels, useNodeSelectors } from '.' import {
useCustomParams,
useNamespace,
useCustomLabels,
useNodeSelectors
} from '.'
import type { IJsonItem } from '../types' import type { IJsonItem } from '../types'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
@ -75,8 +80,16 @@ export function useK8s(model: { [field: string]: any }): IJsonItem[] {
placeholder: t('project.node.args_tips') placeholder: t('project.node.args_tips')
} }
}, },
...useCustomLabels({ model, field: 'customizedLabels', name: 'custom_labels' }), ...useCustomLabels({
...useNodeSelectors( { model, field: 'nodeSelectors', name: 'node_selectors' }), model,
field: 'customizedLabels',
name: 'custom_labels'
}),
...useNodeSelectors({
model,
field: 'nodeSelectors',
name: 'node_selectors'
}),
...useCustomParams({ model, field: 'localParams', isSimple: true }) ...useCustomParams({ model, field: 'localParams', isSimple: true })
] ]
} }

172
dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-node-selectors.ts

@ -19,99 +19,99 @@ import { useI18n } from 'vue-i18n'
import type { IJsonItem } from '../types' import type { IJsonItem } from '../types'
export function useNodeSelectors({ export function useNodeSelectors({
model, model,
field, field,
name, name,
span = 24 span = 24
}: { }: {
model: { [field: string]: any } model: { [field: string]: any }
field: string field: string
name?: string name?: string
span?: Ref | number span?: Ref | number
}): IJsonItem[] { }): IJsonItem[] {
const { t } = useI18n() const { t } = useI18n()
return [ return [
{
type: 'custom-parameters',
field: field,
name: t(`project.node.${name}`),
class: 'btn-custom-parameters',
span,
children: [
{ {
type: 'custom-parameters', type: 'input',
field: field, field: 'key',
name: t(`project.node.${name}`), span: 8,
class: 'btn-custom-parameters', class: 'node-selector-label-name',
span, props: {
children: [ placeholder: t('project.node.expression_name_tips'),
{ maxLength: 256
type: 'input', },
field: 'key', validate: {
span: 8, trigger: ['input', 'blur'],
class: 'node-selector-label-name', required: true,
props: { validator(validate: any, value: string) {
placeholder: t('project.node.expression_name_tips'), if (!value) {
maxLength: 256 return new Error(t('project.node.expression_name_tips'))
}, }
validate: {
trigger: ['input', 'blur'],
required: true,
validator(validate: any, value: string) {
if (!value) {
return new Error(t('project.node.expression_name_tips'))
}
const sameItems = model[field].filter( const sameItems = model[field].filter(
(item: { label: string }) => item.label === value (item: { label: string }) => item.label === value
) )
if (sameItems.length > 1) { if (sameItems.length > 1) {
return new Error(t('project.node.label_repeat')) return new Error(t('project.node.label_repeat'))
} }
} }
} }
}, },
{ {
type: 'select', type: 'select',
field: 'operator', field: 'operator',
span: 4, span: 4,
options: OPERATOR_LIST, options: OPERATOR_LIST,
value: 'In', value: 'In'
}, },
{ {
type: 'input', type: 'input',
field: 'values', field: 'values',
span: 10, span: 10,
class: 'node-selector-label-value', class: 'node-selector-label-value',
props: { props: {
placeholder: t('project.node.expression_value_tips'), placeholder: t('project.node.expression_value_tips'),
maxLength: 256, maxLength: 256,
disabled: false disabled: false
} }
}
]
} }
] ]
}
]
} }
export const OPERATOR_LIST = [ export const OPERATOR_LIST = [
{ {
value: 'In', value: 'In',
label: 'In' label: 'In'
}, },
{ {
value: 'NotIn', value: 'NotIn',
label: 'NotIn' label: 'NotIn'
}, },
{ {
value: 'Exists', value: 'Exists',
label: 'Exists' label: 'Exists'
}, },
{ {
value: 'DoesNotExist', value: 'DoesNotExist',
label: 'DoesNotExist' label: 'DoesNotExist'
}, },
{ {
value: 'Gt', value: 'Gt',
label: 'Gt' label: 'Gt'
}, },
{ {
value: 'Lt', value: 'Lt',
label: 'Lt' label: 'Lt'
} }
] ]

39
dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/dag-sidebar.module.scss

@ -15,9 +15,38 @@
* limitations under the License. * limitations under the License.
*/ */
.task-item { .sidebar {
cursor: pointer; }
height: 20px;
width: 100px; .draggable {
border: 1px solid #1890ff; color: #000;
border: 1px solid #00000040;
display: flex;
align-items: center;
width: 130px;
justify-content: space-around;
border-radius: 5px;
height: 30px;
margin-bottom: 10px;
margin-right: 20px;
}
.fav {
width: 18px;
height: 18px;
}
.draggable {
&:hover {
color: blue;
border: 1px dashed blue;
background-color: #fff;
}
}
.sidebar-icon {
display: block;
width: 18px;
height: 18px;
background-size: 100% 100%;
background-color: #fafafa;
} }

38
dolphinscheduler-ui/src/views/projects/workflow/components/dynamic-dag/dag-sidebar.tsx

@ -18,6 +18,8 @@
import { defineComponent, onMounted, toRefs } from 'vue' import { defineComponent, onMounted, toRefs } from 'vue'
import { useSidebar } from './use-sidebar' import { useSidebar } from './use-sidebar'
import styles from './dag-sidebar.module.scss' import styles from './dag-sidebar.module.scss'
import { NEllipsis, NIcon } from 'naive-ui'
import { StarFilled, StarOutlined } from '@vicons/antd'
const DagSidebar = defineComponent({ const DagSidebar = defineComponent({
name: 'DagSidebar', name: 'DagSidebar',
@ -29,26 +31,54 @@ const DagSidebar = defineComponent({
context.emit('Dragstart', task) context.emit('Dragstart', task)
} }
const handleCollection = () => {}
onMounted(() => { onMounted(() => {
getTaskList() getTaskList()
}) })
return { return {
...toRefs(variables), ...toRefs(variables),
handleDragstart handleDragstart,
handleCollection
} }
}, },
render() { render() {
return ( return (
<div> <div class={styles.sidebar}>
{this.taskList.map((task: any) => { {this.taskList.map((task: any) => {
return ( return (
<div <div
class={styles['task-item']} class={styles['draggable']}
draggable='true' draggable='true'
onDragstart={() => this.handleDragstart(task)} onDragstart={() => this.handleDragstart(task)}
> >
{task.name} <em
class={styles['sidebar-icon']}
style={{ backgroundImage: task.icon }}
></em>
<NEllipsis style={{ width: '60px' }}>{task.name}</NEllipsis>
<div
class={styles.stars}
onMouseenter={() => {
task.starHover = true
}}
onMouseleave={() => {
task.starHover = false
}}
onClick={() => this.handleCollection()}
>
<div class={styles.fav}>
<NIcon
size='18'
color={
task.collection || task.starHover ? '#288FFF' : '#ccc'
}
>
{task.collection ? <StarFilled /> : <StarOutlined />}
</NIcon>
</div>
</div>
</div> </div>
) )
})} })}

Loading…
Cancel
Save