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..aa54dafb0 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", + "targetAddress": ".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", + "targetAddress": "." } } }, diff --git a/example/docker-compose.yaml b/example/docker-compose.yaml index 1aaa23183..88e96426a 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: @@ -55,16 +56,16 @@ services: ports: - '5001:5000' - # db-ui: - # image: mongo-express:1.0.0-alpha - # restart: unless-stopped - # ports: - # - "8082:8081" - # environment: - # ME_CONFIG_MONGODB_SERVER: db - # ME_CONFIG_MONGODB_ADMINUSERNAME: maf - # ME_CONFIG_MONGODB_ADMINPASSWORD: maf - # ME_CONFIG_MONGODB_ENABLE_ADMIN: "true" +# db-ui: +# image: mongo-express:1.0.0-alpha +# restart: unless-stopped +# ports: +# - "8082:8081" +# environment: +# ME_CONFIG_MONGODB_SERVER: db +# ME_CONFIG_MONGODB_ADMINUSERNAME: root +# ME_CONFIG_MONGODB_ADMINPASSWORD: xd7wCEhEx4kszsecYFfC +# ME_CONFIG_MONGODB_ENABLE_ADMIN: "true" job-store: image: redis:6.2.5-alpine 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 65% rename from packages/dm-core-plugins/blueprints/job/JobTargetAddress.json rename to packages/dm-core-plugins/blueprints/job/TargetAddress.json index bdb3f360c..d535777e1 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": "targetAddress", "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..525e29b6c 100644 --- a/packages/dm-core-plugins/src/job/JobPlugin.tsx +++ b/packages/dm-core-plugins/src/job/JobPlugin.tsx @@ -4,8 +4,8 @@ import { GetJobResultResponse, IUIPlugin, JobStatus, - splitAddress, TJob, + TJobHandler, useDMSS, useJob, } from '@development-framework/dm-core' @@ -24,49 +24,45 @@ const JobButtonWrapper = styled.div` gap: 8px; ` +interface ITargetAddress { + targetAddress: 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.targetAddress + } + if (['self', '.'].includes(config?.jobTargetAddress.targetAddress)) { + return idReference } - return config?.jobTargetAddress.jobAddress ?? '' + return idReference + config.jobTargetAddress.targetAddress } - 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.targetAddress } - return config?.jobInput.jobInputAddress + if (['self', '.'].includes(config.jobInput.targetAddress)) { + return idReference + } + return idReference + config.jobInput.targetAddress } - console.log(jobInputAddress()) const { tokenData } = useContext(AuthContext) const username = tokenData?.preferred_username @@ -90,19 +86,16 @@ 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, } - const jobEntityFormData = { - ...jobEntity, - outputTarget: defaultTargetOutput, - } + if (config?.outputTarget) jobEntity.outputTarget = config.outputTarget const updateDocument = async ( jobAddress: string, @@ -154,9 +147,9 @@ export const JobPlugin = (props: IUIPlugin) => { function createNewJob(): Promise { setAllowJobStart(true) if (jobExists) { - return updateDocument(jobTargetAddress(), jobEntityFormData) + return updateDocument(jobTargetAddress(), jobEntity) } else { - return addDocument(jobTargetAddress(), jobEntityFormData) + return addDocument(jobTargetAddress(), jobEntity) } }