Browse Source
* [Feature][UI Next] Dag backfill * [Feature][UI Next] Add license header3.0.0/version-upgrade
wangyizhi
3 years ago
committed by
GitHub
25 changed files with 687 additions and 281 deletions
@ -0,0 +1,95 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
export interface ProcessDefinition { |
||||||
|
id: number |
||||||
|
code: number |
||||||
|
name: string |
||||||
|
version: number |
||||||
|
releaseState: string |
||||||
|
projectCode: number |
||||||
|
description: string |
||||||
|
globalParams: string |
||||||
|
globalParamList: any[] |
||||||
|
globalParamMap: any |
||||||
|
createTime: string |
||||||
|
updateTime: string |
||||||
|
flag: string |
||||||
|
userId: number |
||||||
|
userName?: any |
||||||
|
projectName?: any |
||||||
|
locations: string |
||||||
|
scheduleReleaseState?: any |
||||||
|
timeout: number |
||||||
|
tenantId: number |
||||||
|
tenantCode: string |
||||||
|
modifyBy?: any |
||||||
|
warningGroupId: number |
||||||
|
} |
||||||
|
|
||||||
|
export interface ProcessTaskRelationList { |
||||||
|
id: number |
||||||
|
name: string |
||||||
|
processDefinitionVersion: number |
||||||
|
projectCode: any |
||||||
|
processDefinitionCode: any |
||||||
|
preTaskCode: number |
||||||
|
preTaskVersion: number |
||||||
|
postTaskCode: any |
||||||
|
postTaskVersion: number |
||||||
|
conditionType: string |
||||||
|
conditionParams: any |
||||||
|
createTime: string |
||||||
|
updateTime: string |
||||||
|
} |
||||||
|
|
||||||
|
export interface TaskDefinitionList { |
||||||
|
id: number |
||||||
|
code: any |
||||||
|
name: string |
||||||
|
version: number |
||||||
|
description: string |
||||||
|
projectCode: any |
||||||
|
userId: number |
||||||
|
taskType: string |
||||||
|
taskParams: any |
||||||
|
taskParamList: any[] |
||||||
|
taskParamMap: any |
||||||
|
flag: string |
||||||
|
taskPriority: string |
||||||
|
userName?: any |
||||||
|
projectName?: any |
||||||
|
workerGroup: string |
||||||
|
environmentCode: number |
||||||
|
failRetryTimes: number |
||||||
|
failRetryInterval: number |
||||||
|
timeoutFlag: string |
||||||
|
timeoutNotifyStrategy: string |
||||||
|
timeout: number |
||||||
|
delayTime: number |
||||||
|
resourceIds: string |
||||||
|
createTime: string |
||||||
|
updateTime: string |
||||||
|
modifyBy?: any |
||||||
|
dependence: string |
||||||
|
} |
||||||
|
|
||||||
|
export interface WorkflowDefinition { |
||||||
|
processDefinition: ProcessDefinition |
||||||
|
processTaskRelationList: ProcessTaskRelationList[] |
||||||
|
taskDefinitionList: TaskDefinitionList[] |
||||||
|
} |
@ -0,0 +1,54 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
import type { Ref } from 'vue' |
||||||
|
import type { Graph } from '@antv/x6' |
||||||
|
import { TaskType } from '../../../task/constants/task-type' |
||||||
|
|
||||||
|
interface Options { |
||||||
|
graph: Ref<Graph | undefined> |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Expose some cell-related query methods and refs |
||||||
|
* @param {Options} options |
||||||
|
*/ |
||||||
|
export function useCellQuery(options: Options) { |
||||||
|
const { graph } = options |
||||||
|
|
||||||
|
/** |
||||||
|
* Get all nodes |
||||||
|
*/ |
||||||
|
function getNodes() { |
||||||
|
const nodes = graph.value?.getNodes() |
||||||
|
if (!nodes) return [] |
||||||
|
return nodes.map((node) => { |
||||||
|
const position = node.getPosition() |
||||||
|
const data = node.getData() |
||||||
|
return { |
||||||
|
code: node.id, |
||||||
|
position: position, |
||||||
|
name: data.taskName as string, |
||||||
|
type: data.taskType as TaskType |
||||||
|
} |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
return { |
||||||
|
getNodes |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,76 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
import type { Ref } from 'vue' |
||||||
|
import type { Graph } from '@antv/x6' |
||||||
|
import type { TaskType } from '@/views/projects/task/constants/task-type' |
||||||
|
import { TASK_TYPES_MAP } from '@/views/projects/task/constants/task-type' |
||||||
|
import { useCustomCellBuilder } from './dag-hooks' |
||||||
|
import type { Coordinate } from './use-custom-cell-builder' |
||||||
|
import utils from '@/utils' |
||||||
|
|
||||||
|
interface Options { |
||||||
|
graph: Ref<Graph | undefined> |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Expose some cell query |
||||||
|
* @param {Options} options |
||||||
|
*/ |
||||||
|
export function useCellUpdate(options: Options) { |
||||||
|
const { graph } = options |
||||||
|
|
||||||
|
const { buildNode } = useCustomCellBuilder() |
||||||
|
|
||||||
|
/** |
||||||
|
* Set node name by id |
||||||
|
* @param {string} id |
||||||
|
* @param {string} name |
||||||
|
*/ |
||||||
|
function setNodeName(id: string, newName: string) { |
||||||
|
const node = graph.value?.getCellById(id) |
||||||
|
if (node) { |
||||||
|
const truncation = utils.truncateText(newName, 18) |
||||||
|
node.attr('title/text', truncation) |
||||||
|
node.setData({ taskName: newName }) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Add a node to the graph |
||||||
|
* @param {string} id |
||||||
|
* @param {string} taskType |
||||||
|
* @param {Coordinate} coordinate Default is { x: 100, y: 100 } |
||||||
|
*/ |
||||||
|
function addNode( |
||||||
|
id: string, |
||||||
|
type: string, |
||||||
|
coordinate: Coordinate = { x: 100, y: 100 } |
||||||
|
) { |
||||||
|
if (!TASK_TYPES_MAP[type as TaskType]) { |
||||||
|
console.warn(`taskType:${type} is invalid!`) |
||||||
|
return |
||||||
|
} |
||||||
|
const node = buildNode(id, type, '', coordinate) |
||||||
|
graph.value?.addNode(node) |
||||||
|
} |
||||||
|
|
||||||
|
return { |
||||||
|
setNodeName, |
||||||
|
addNode |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,43 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
import { Ref, watch } from 'vue' |
||||||
|
import { useCustomCellBuilder } from './dag-hooks' |
||||||
|
import type { Graph } from '@antv/x6' |
||||||
|
import { WorkflowDefinition } from './types' |
||||||
|
|
||||||
|
interface Options { |
||||||
|
graph: Ref<Graph | undefined> |
||||||
|
definition: Ref<WorkflowDefinition | undefined> |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Backfill workflow into graph |
||||||
|
*/ |
||||||
|
export function useGraphBackfill(options: Options) { |
||||||
|
const { graph, definition } = options |
||||||
|
|
||||||
|
const { buildGraph } = useCustomCellBuilder() |
||||||
|
|
||||||
|
watch([graph, definition], () => { |
||||||
|
if (graph.value && definition.value) { |
||||||
|
graph.value.fromJSON(buildGraph(definition.value)) |
||||||
|
} |
||||||
|
}) |
||||||
|
|
||||||
|
return {} |
||||||
|
} |
@ -0,0 +1,41 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
$borderDark: rgba(255, 255, 255, 0.09); |
||||||
|
$borderLight: rgb(239, 239, 245); |
||||||
|
$bgDark: rgb(24, 24, 28); |
||||||
|
$bgLight: #ffffff; |
||||||
|
|
||||||
|
.container { |
||||||
|
width: 100%; |
||||||
|
padding: 20px; |
||||||
|
box-sizing: border-box; |
||||||
|
height: calc(100vh - 100px); |
||||||
|
overflow: hidden; |
||||||
|
display: block; |
||||||
|
} |
||||||
|
|
||||||
|
.dark { |
||||||
|
border: solid 1px $borderDark; |
||||||
|
background-color: $bgDark; |
||||||
|
} |
||||||
|
|
||||||
|
.light { |
||||||
|
border: solid 1px $borderLight; |
||||||
|
background-color: $bgLight; |
||||||
|
} |
||||||
|
|
Loading…
Reference in new issue