diff options
author | KAPIL SINGAL <ks220y@att.com> | 2020-11-09 00:06:56 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-11-09 00:06:56 +0000 |
commit | 3b653f855c95d9ebfb88e537f0f2fcc5c96ac164 (patch) | |
tree | 8f19cd7794f0013ed9a0040443467cd10bc6c767 /cds-ui/designer-client/src/app | |
parent | 01d15fc40570a5ff64dfe6a77ee0458889780a6d (diff) | |
parent | 4f7d5991694ecd8533877f90c16aeeecd7b5acd9 (diff) |
Merge "adding import inputs and outputs from functions into actions Refactor."
Diffstat (limited to 'cds-ui/designer-client/src/app')
-rw-r--r-- | cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/action-attributes/action-attributes.component.ts | 79 |
1 files changed, 21 insertions, 58 deletions
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/action-attributes/action-attributes.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/action-attributes/action-attributes.component.ts index 56c1d0e64..b0b6ae56d 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/action-attributes/action-attributes.component.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/action-attributes/action-attributes.component.ts @@ -46,24 +46,16 @@ export class ActionAttributesComponent implements OnInit { this.designerState = designerState; if (this.designerState && this.designerState.actionName) { this.actionName = this.designerState.actionName; + console.log(this.actionName); const action = this.designerState.template.workflows[this.actionName] as Action; if (action.steps) { const steps = Object.keys(action.steps); - if (steps && steps.length > 0) { - this.isFunctionAttributeActive = true; - } else { - this.isFunctionAttributeActive = false; - } + this.isFunctionAttributeActive = steps && steps.length > 0; this.steps = steps; this.suggestedOutputs = []; this.suggestedInputs = []; - /*steps.forEach(step => { - const target = action.steps[step].target; - this.getInputs(target); - });*/ } - this.inputs = []; if (action.inputs) { const namesOfInput = Object.keys(action.inputs); @@ -268,67 +260,38 @@ export class ActionAttributesComponent implements OnInit { submitTempAttributes() { - this.writeSelectedAttributeInputs(); - this.writeSelectedAttributeOutputs(); + this.writeSelectedAttribute(this.functionAndAttributesInput, 'inputs'); + this.writeSelectedAttribute(this.functionAndAttributesOutput, 'outputs'); } - private writeSelectedAttributeOutputs() { - this.functionAndAttributesOutput.forEach((key, value) => { - const nodeTemplate = this.getNodeTemplate(value); + private writeSelectedAttribute(map: Map<string, string[]>, attributeType: string) { + map.forEach((value, key) => { + const nodeTemplate = this.getNodeTemplate(key); this.functions.serverFunctions /* tslint:disable:no-string-literal */ .filter(currentFunction => currentFunction.modelName.includes(nodeTemplate['type'])) .forEach(currentFunction => { - if (currentFunction['definition'] && currentFunction['definition']['interfaces'] - [Object.keys(currentFunction['definition'] && currentFunction['definition']['interfaces'])] - ['operations']['process']['outputs']) { - let newOutputs = ''; - const outputs = currentFunction['definition'] && currentFunction['definition']['interfaces'] - [Object.keys(currentFunction['definition'] && currentFunction['definition']['interfaces'])] - ['operations']['process']['outputs']; - key.forEach(attribute => { - newOutputs += '"' + attribute + '": ' + this.convertToString(outputs[attribute]) + ','; - }); - if (key.length > 0) { - newOutputs = this.removeTheLastComma(newOutputs); - const originalOutputs = this.convertToString(this.designerState.template.workflows[this.actionName]['outputs']); - console.log(originalOutputs.substr(0, originalOutputs.length - 1) + ',' + newOutputs + '}'); - this.designerState.template.workflows[this.actionName]['outputs'] = - this.convertToObject(originalOutputs.substr(0, originalOutputs.length - 1) + ',' + newOutputs + '}'); - } - } - }); - }); - } - - private writeSelectedAttributeInputs() { - this.functionAndAttributesInput.forEach((key, value) => { - const nodeTemplate = this.getNodeTemplate(value); - this.functions.serverFunctions - /* tslint:disable:no-string-literal */ - .filter(currentFunction => currentFunction.modelName.includes(nodeTemplate['type'])) - .forEach(currentFunction => { if (currentFunction['definition'] && currentFunction['definition']['interfaces'] [Object.keys(currentFunction['definition'] && currentFunction['definition']['interfaces'])] - ['operations']['process']['inputs']) { - let newInputs = ''; - const inputs = currentFunction['definition'] && currentFunction['definition']['interfaces'] + ['operations']['process'][attributeType]) { + let newAttributes = ''; + const attributes = currentFunction['definition'] && currentFunction['definition']['interfaces'] [Object.keys(currentFunction['definition'] && currentFunction['definition']['interfaces'])] - ['operations']['process']['inputs']; - key.forEach(attribute => { - newInputs += '"' + attribute + '": ' + this.convertToString(inputs[attribute]) + ','; + ['operations']['process'][attributeType]; + value.forEach(attribute => { + newAttributes += '"' + attribute + '": ' + this.convertToString(attributes[attribute]) + ','; }); - if (key.length > 0) { - newInputs = this.removeTheLastComma(newInputs); - const originalInputs = this.convertToString(this.designerState.template.workflows[this.actionName]['inputs']); - console.log(originalInputs.substr(0, originalInputs.length - 1) + ',' + newInputs + '}'); - this.designerState.template.workflows[this.actionName]['inputs'] = - this.convertToObject(originalInputs.substr(0, originalInputs.length - 1) + ',' + newInputs + '}'); + if (value.length > 0) { + newAttributes = this.removeTheLastComma(newAttributes); + const originalAttributes = this.convertToString(this.designerState.template.workflows[this.actionName] + [attributeType]); + console.log(originalAttributes.substr(0, originalAttributes.length - 1) + ',' + newAttributes + '}'); + this.designerState.template.workflows[this.actionName][attributeType] = + this.convertToObject(originalAttributes.substr(0, originalAttributes.length - 1) + + ',' + newAttributes + '}'); } } - - }); }); } |