diff --git a/example/app/data/DemoDataSource/recipes/apps/signal_app/recipe_links/signals_simple/case.recipe.json b/example/app/data/DemoDataSource/recipes/apps/signal_app/recipe_links/signals_simple/case.recipe.json index ce39ce48f..810d23e4d 100644 --- a/example/app/data/DemoDataSource/recipes/apps/signal_app/recipe_links/signals_simple/case.recipe.json +++ b/example/app/data/DemoDataSource/recipes/apps/signal_app/recipe_links/signals_simple/case.recipe.json @@ -104,9 +104,9 @@ "config": { "type": "PLUGINS:dm-core-plugins/job/JobConfig", "jobTargetAddress": { - "type": "PLUGINS:dm-core-plugins/job/JobTargetAddress", - "jobAddress": ".job", - "jobAddressScope": "local" + "type": "PLUGINS:dm-core-plugins/job/TargetAddress", + "address": ".job", + "addressScope": "local" }, "label": "signal job", "runner": { @@ -114,11 +114,8 @@ }, "outputTarget": ".signal", "jobInput": { - "type": "PLUGINS:dm-core-plugins/job/JobInput", - "_type": "dmss://system/SIMOS/Reference", - "referenceType": "link", - "jobInputAddress": ".study.cases[0]", - "jobInputAddressScope": "local" + "type": "PLUGINS:dm-core-plugins/job/TargetAddress", + "address": "." } } }, diff --git a/example/docker-compose.yaml b/example/docker-compose.yaml index 1aaa23183..a75df4002 100644 --- a/example/docker-compose.yaml +++ b/example/docker-compose.yaml @@ -12,6 +12,7 @@ services: MONGO_INITDB_ROOT_PASSWORD: xd7wCEhEx4kszsecYFfC SECRET_KEY: sg9aeUM5i1JO4gNN8fQadokJa3_gXQMLBjSGGYcfscs= # Don't reuse this in production... DATA_SOURCE_FILES: '{ "name": "system", "repositories": { "db": { "type": "mongo-db", "host": "db", "port": 27017, "username": "root", "password": "xd7wCEhEx4kszsecYFfC", "tls": false, "database": "DMSS-core", "collection": "DMSS-core" } }}' + RESET_DATA_SOURCE: off # volumes: # - ../../data-modelling-storage-service/src:/code/src ports: diff --git a/packages/dm-core-plugins/blueprints/job/JobConfig.json b/packages/dm-core-plugins/blueprints/job/JobConfig.json index d1131a6f7..a4eda5189 100644 --- a/packages/dm-core-plugins/blueprints/job/JobConfig.json +++ b/packages/dm-core-plugins/blueprints/job/JobConfig.json @@ -6,7 +6,8 @@ { "name": "outputTarget", "type": "CORE:BlueprintAttribute", - "attributeType": "string" + "attributeType": "string", + "optional": true }, { "name": "label", @@ -26,12 +27,12 @@ { "name": "jobTargetAddress", "type": "CORE:BlueprintAttribute", - "attributeType": "PLUGINS:dm-core-plugins/job/JobTargetAddress" + "attributeType": "PLUGINS:dm-core-plugins/job/TargetAddress" }, { "name": "jobInput", "type": "CORE:BlueprintAttribute", - "attributeType": "PLUGINS:dm-core-plugins/job/JobInput" + "attributeType": "PLUGINS:dm-core-plugins/job/TargetAddress" } ] } diff --git a/packages/dm-core-plugins/blueprints/job/JobInput.json b/packages/dm-core-plugins/blueprints/job/JobInput.json deleted file mode 100644 index 770071cec..000000000 --- a/packages/dm-core-plugins/blueprints/job/JobInput.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "JobInput", - "type": "CORE:Blueprint", - "description": "", - "attributes": [ - { - "name": "type", - "type": "CORE:BlueprintAttribute", - "description": "Required field", - "attributeType": "string" - }, - { - "name": "_type", - "type": "CORE:BlueprintAttribute", - "description": "The type of the job input", - "attributeType": "string" - }, - { - "name": "referenceType", - "type": "CORE:BlueprintAttribute", - "attributeType": "string" - }, - { - "name": "jobInputAddress", - "type": "CORE:BlueprintAttribute", - "attributeType": "string" - }, - { - "name": "jobInputAddressScope", - "type": "CORE:BlueprintAttribute", - "attributeType": "string" - } - ] -} diff --git a/packages/dm-core-plugins/blueprints/job/JobTargetAddress.json b/packages/dm-core-plugins/blueprints/job/TargetAddress.json similarity index 66% rename from packages/dm-core-plugins/blueprints/job/JobTargetAddress.json rename to packages/dm-core-plugins/blueprints/job/TargetAddress.json index bdb3f360c..e9ac22c2b 100644 --- a/packages/dm-core-plugins/blueprints/job/JobTargetAddress.json +++ b/packages/dm-core-plugins/blueprints/job/TargetAddress.json @@ -1,5 +1,5 @@ { - "name": "JobTargetAddress", + "name": "TargetAddress", "type": "CORE:Blueprint", "description": "", "attributes": [ @@ -9,12 +9,14 @@ "attributeType": "string" }, { - "name": "jobAddressScope", + "name": "addressScope", "type": "CORE:BlueprintAttribute", - "attributeType": "string" + "attributeType": "string", + "optional": true, + "default": "local" }, { - "name": "jobAddress", + "name": "address", "type": "CORE:BlueprintAttribute", "attributeType": "string" } diff --git a/packages/dm-core-plugins/src/job/JobPlugin.tsx b/packages/dm-core-plugins/src/job/JobPlugin.tsx index 8643b9906..0263ad0af 100644 --- a/packages/dm-core-plugins/src/job/JobPlugin.tsx +++ b/packages/dm-core-plugins/src/job/JobPlugin.tsx @@ -5,7 +5,9 @@ import { IUIPlugin, JobStatus, splitAddress, + TGenericObject, TJob, + TJobHandler, useDMSS, useJob, } from '@development-framework/dm-core' @@ -24,49 +26,45 @@ const JobButtonWrapper = styled.div` gap: 8px; ` +interface ITargetAddress { + address: string + addressScope?: 'local' | 'global' +} + interface JobPluginConfig { - jobTargetAddress: { - type: string - jobAddress: string - jobAddressScope: string - } + jobTargetAddress: ITargetAddress label: string - runner: { - type: string - } + runner: TJobHandler outputTarget: string - jobInput: { - type: string - _type: string - referenceType: string - jobInputAddress: string - jobInputAddressScope: string - } + jobInput: ITargetAddress } -export const JobPlugin = (props: IUIPlugin) => { +export const JobPlugin = (props: IUIPlugin & { config: JobPluginConfig }) => { const { config, idReference, - }: { config?: JobPluginConfig; idReference: string } = props + }: { config: JobPluginConfig; idReference: string } = props const DmssApi = useDMSS() - const defaultTargetOutput = idReference + config?.outputTarget const jobTargetAddress = (): string => { - if (config?.jobTargetAddress.jobAddressScope === 'local') { - return idReference + config?.jobTargetAddress.jobAddress + if (config.jobTargetAddress.addressScope !== 'local') { + return config.jobTargetAddress.address + } + if (['self', '.'].includes(config?.jobTargetAddress.address)) { + return idReference } - return config?.jobTargetAddress.jobAddress ?? '' + return idReference + config.jobTargetAddress.address } - const jobInputAddress = (): string | undefined => { - if (config?.jobInput.jobInputAddressScope === 'local') { - const { dataSource, documentPath } = splitAddress(idReference) - return `dmss://${dataSource}/${documentPath}${config?.jobInput.jobInputAddress}` + const jobInputAddress = (): string => { + if (config.jobInput.addressScope !== 'local') { + return config.jobInput.address + } + if (['self', '.'].includes(config.jobInput.address)) { + return idReference } - return config?.jobInput.jobInputAddress + return idReference + config.jobInput.address } - console.log(jobInputAddress()) const { tokenData } = useContext(AuthContext) const username = tokenData?.preferred_username @@ -90,10 +88,10 @@ export const JobPlugin = (props: IUIPlugin) => { label: config?.label, type: EBlueprint.JOB, status: JobStatus.NotStarted, - triggeredBy: username ?? 'unknown user', // TODO: Add propper fallback + triggeredBy: username ?? 'unknown user', // TODO: Add proper fallback applicationInput: { - type: config?.jobInput._type, - referenceType: config?.jobInput.referenceType, + type: EBlueprint.REFERENCE, + referenceType: 'link', address: jobInputAddress(), }, runner: config?.runner, @@ -101,7 +99,7 @@ export const JobPlugin = (props: IUIPlugin) => { const jobEntityFormData = { ...jobEntity, - outputTarget: defaultTargetOutput, + outputTarget: config?.outputTarget, } const updateDocument = async (