@ -15,18 +15,29 @@
* limitations under the License .
* limitations under the License .
* /
* /
import { DependentTaskReq } from "@/service/modules/lineages/types" ;
import { DependentTaskReq } from '@/service/modules/lineages/types'
import { queryDependentTasks } from "@/service/modules/lineages" ;
import { queryDependentTasks } from '@/service/modules/lineages'
import { TASK_TYPES_MAP } from "@/store/project" ;
import { TASK_TYPES_MAP } from '@/store/project'
export function useDependencies() {
export function useDependencies() {
const getDependentTasksBySingleTask = async (
const getDependentTasksBySingleTask = async ( projectCode : any , workflowCode : any , taskCode : any ) = > {
projectCode : any ,
let tasks = [ ] as any
workflowCode : any ,
taskCode : any
) = > {
const tasks = [ ] as any
if ( workflowCode && taskCode ) {
if ( workflowCode && taskCode ) {
let dependentTaskReq = { workFlowCode : workflowCode , taskCode : taskCode } as DependentTaskReq
const dependentTaskReq = {
workFlowCode : workflowCode ,
taskCode : taskCode
} as DependentTaskReq
const res = await queryDependentTasks ( projectCode , dependentTaskReq )
const res = await queryDependentTasks ( projectCode , dependentTaskReq )
res . filter ( ( item : any ) = > item . processDefinitionCode !== workflowCode && item . taskType === TASK_TYPES_MAP . DEPENDENT . alias )
res
. filter (
( item : any ) = >
item . processDefinitionCode !== workflowCode &&
item . taskType === TASK_TYPES_MAP . DEPENDENT . alias
)
. forEach ( ( item : any ) = > {
. forEach ( ( item : any ) = > {
tasks . push ( item . processDefinitionName + '->' + item . taskName )
tasks . push ( item . processDefinitionName + '->' + item . taskName )
} )
} )
@ -34,12 +45,22 @@ export function useDependencies() {
return tasks
return tasks
}
}
const getDependentTasksByWorkflow = async ( projectCode : any , workflowCode : any ) = > {
const getDependentTasksByWorkflow = async (
let tasks = [ ] as any
projectCode : any ,
workflowCode : any
) = > {
const tasks = [ ] as any
if ( workflowCode ) {
if ( workflowCode ) {
let dependentTaskReq = { workFlowCode : workflowCode } as DependentTaskReq
const dependentTaskReq = {
workFlowCode : workflowCode
} as DependentTaskReq
const res = await queryDependentTasks ( projectCode , dependentTaskReq )
const res = await queryDependentTasks ( projectCode , dependentTaskReq )
res . filter ( ( item : any ) = > item . processDefinitionCode !== workflowCode && item . taskType === TASK_TYPES_MAP . DEPENDENT . alias )
res
. filter (
( item : any ) = >
item . processDefinitionCode !== workflowCode &&
item . taskType === TASK_TYPES_MAP . DEPENDENT . alias
)
. forEach ( ( item : any ) = > {
. forEach ( ( item : any ) = > {
tasks . push ( item . processDefinitionName + '->' + item . taskName )
tasks . push ( item . processDefinitionName + '->' + item . taskName )
} )
} )
@ -47,12 +68,20 @@ export function useDependencies() {
return tasks
return tasks
}
}
const getDependentTasksByMultipleTasks = async ( projectCode : any , workflowCode : any , taskCodes : any [ ] ) = > {
const getDependentTasksByMultipleTasks = async (
projectCode : any ,
workflowCode : any ,
taskCodes : any [ ]
) = > {
let tasks = [ ] as any
let tasks = [ ] as any
if ( workflowCode && taskCodes ? . length > 0 ) {
if ( workflowCode && taskCodes ? . length > 0 ) {
for ( const taskCode of taskCodes ) {
for ( const taskCode of taskCodes ) {
const res = await getDependentTasksBySingleTask ( projectCode , workflowCode , taskCode )
const res = await getDependentTasksBySingleTask (
if ( res ? . length > 0 ) {
projectCode ,
workflowCode ,
taskCode
)
if ( res ? . length > 0 ) {
tasks = tasks . concat ( res )
tasks = tasks . concat ( res )
}
}
}
}
@ -60,11 +89,19 @@ export function useDependencies() {
return tasks
return tasks
}
}
const getDependentTaskLinksByMultipleTasks = async ( projectCode : any , workflowCode : any , taskCodes : any [ ] ) = > {
const getDependentTaskLinksByMultipleTasks = async (
projectCode : any ,
workflowCode : any ,
taskCodes : any [ ]
) = > {
let dependentTaskLinks = [ ] as any
let dependentTaskLinks = [ ] as any
if ( workflowCode && projectCode ) {
if ( workflowCode && projectCode ) {
for ( const taskCode of taskCodes ) {
for ( const taskCode of taskCodes ) {
await getDependentTaskLinksByTask ( projectCode , workflowCode , taskCode ) . then ( ( res : any ) = > {
await getDependentTaskLinksByTask (
projectCode ,
workflowCode ,
taskCode
) . then ( ( res : any ) = > {
dependentTaskLinks = dependentTaskLinks . concat ( res )
dependentTaskLinks = dependentTaskLinks . concat ( res )
} )
} )
}
}
@ -73,50 +110,74 @@ export function useDependencies() {
}
}
const getDependentTaskLinks = async ( projectCode : any , workflowCode : any ) = > {
const getDependentTaskLinks = async ( projectCode : any , workflowCode : any ) = > {
le t dependentTaskReq = { workFlowCode : workflowCode } as DependentTaskReq
cons t dependentTaskReq = { workFlowCode : workflowCode } as DependentTaskReq
le t dependentTaskLinks = [ ] as any
cons t dependentTaskLinks = [ ] as any
if ( workflowCode && projectCode ) {
if ( workflowCode && projectCode ) {
await queryDependentTasks ( projectCode , dependentTaskReq ) . then ( ( res : any ) = > {
await queryDependentTasks ( projectCode , dependentTaskReq ) . then (
res . filter ( ( item : any ) = > item . processDefinitionCode !== workflowCode && item . taskType === TASK_TYPES_MAP . DEPENDENT . alias )
( res : any ) = > {
res
. filter (
( item : any ) = >
item . processDefinitionCode !== workflowCode &&
item . taskType === TASK_TYPES_MAP . DEPENDENT . alias
)
. forEach ( ( item : any ) = > {
. forEach ( ( item : any ) = > {
dependentTaskLinks . push (
dependentTaskLinks . push ( {
{
text : item.processDefinitionName + '->' + item . taskName ,
text : item.processDefinitionName + '->' + item . taskName ,
show : true ,
show : true ,
action : ( ) = > {
action : ( ) = > {
const url = ` /projects/ ${ item . projectCode } /workflow/definitions/ ${ item . processDefinitionCode } `
const url = ` /projects/ ${ item . projectCode } /workflow/definitions/ ${ item . processDefinitionCode } `
window . open ( url , '_blank' )
window . open ( url , '_blank' )
} ,
}
}
)
} )
} )
} )
} )
}
}
)
}
return dependentTaskLinks
return dependentTaskLinks
}
}
const getDependentTaskLinksByTask = async ( projectCode : any , workflowCode : any , taskCode : any ) = > {
const getDependentTaskLinksByTask = async (
let dependentTaskReq = { workFlowCode : workflowCode , taskCode : taskCode } as DependentTaskReq
projectCode : any ,
let dependentTaskLinks = [ ] as any
workflowCode : any ,
taskCode : any
) = > {
const dependentTaskReq = {
workFlowCode : workflowCode ,
taskCode : taskCode
} as DependentTaskReq
const dependentTaskLinks = [ ] as any
if ( workflowCode && projectCode ) {
if ( workflowCode && projectCode ) {
await queryDependentTasks ( projectCode , dependentTaskReq ) . then ( ( res : any ) = > {
await queryDependentTasks ( projectCode , dependentTaskReq ) . then (
res . filter ( ( item : any ) = > item . processDefinitionCode !== workflowCode && item . taskType === TASK_TYPES_MAP . DEPENDENT . alias )
( res : any ) = > {
res
. filter (
( item : any ) = >
item . processDefinitionCode !== workflowCode &&
item . taskType === TASK_TYPES_MAP . DEPENDENT . alias
)
. forEach ( ( item : any ) = > {
. forEach ( ( item : any ) = > {
dependentTaskLinks . push (
dependentTaskLinks . push ( {
{
text : item.processDefinitionName + '->' + item . taskName ,
text : item.processDefinitionName + '->' + item . taskName ,
show : true ,
show : true ,
action : ( ) = > {
action : ( ) = > {
const url = ` /projects/ ${ item . projectCode } /workflow/definitions/ ${ item . processDefinitionCode } `
const url = ` /projects/ ${ item . projectCode } /workflow/definitions/ ${ item . processDefinitionCode } `
window . open ( url , '_blank' )
window . open ( url , '_blank' )
} ,
}
}
)
} )
} )
} )
} )
}
}
)
}
return dependentTaskLinks
return dependentTaskLinks
}
}
return { getDependentTasksBySingleTask , getDependentTasksByMultipleTasks , getDependentTaskLinks , getDependentTasksByWorkflow , getDependentTaskLinksByTask , getDependentTaskLinksByMultipleTasks }
return {
getDependentTasksBySingleTask ,
getDependentTasksByMultipleTasks ,
getDependentTaskLinks ,
getDependentTasksByWorkflow ,
getDependentTaskLinksByTask ,
getDependentTaskLinksByMultipleTasks
}
}
}