From a04dc4d3bc12cdc77e04fad89fc369c869cdd61f Mon Sep 17 00:00:00 2001 From: Arielk Date: Tue, 14 May 2019 12:43:35 +0300 Subject: operation artifact optional and fixes operation artifact optional and fixes Change-Id: Id32dff70dc967ce5e49e429b3b0ca274d671ee3e Issue-ID: SDC-2249 Signed-off-by: Arielk Signed-off-by: avigaffa --- .../interface-operation.page.component.ts | 19 ++++++++++++------- .../operation-creator.component.html | 7 ++++--- .../operation-creator/operation-creator.component.ts | 18 +++++++++--------- 3 files changed, 25 insertions(+), 19 deletions(-) (limited to 'catalog-ui/src/app/ng2/pages/interface-operation') diff --git a/catalog-ui/src/app/ng2/pages/interface-operation/interface-operation.page.component.ts b/catalog-ui/src/app/ng2/pages/interface-operation/interface-operation.page.component.ts index b30cf237b9..c2a9582ed4 100644 --- a/catalog-ui/src/app/ng2/pages/interface-operation/interface-operation.page.component.ts +++ b/catalog-ui/src/app/ng2/pages/interface-operation/interface-operation.page.component.ts @@ -325,10 +325,12 @@ export class InterfaceOperationComponent { private createOperation = (operation: OperationModel): void => { this.ComponentServiceNg2.createInterfaceOperation(this.component, operation).subscribe((response: OperationModel) => { this.openOperation = null; + let curInterf = _.find( this.interfaces, interf => interf.type === operation.interfaceType ); + if (!curInterf) { curInterf = new UIInterfaceModel({ type: response.interfaceType, @@ -337,11 +339,13 @@ export class InterfaceOperationComponent { }); this.interfaces.push(curInterf); } - curInterf.operations.push(new UIOperationModel(response)); + + const newOpModel = new UIOperationModel(response); + curInterf.operations.push(newOpModel); this.sortInterfaces(); - if (operation.workflowAssociationType === WORKFLOW_ASSOCIATION_OPTIONS.EXTERNAL) { - this.ComponentServiceNg2.uploadInterfaceOperationArtifact(this.component, response, operation).subscribe(); + if (operation.workflowAssociationType === WORKFLOW_ASSOCIATION_OPTIONS.EXTERNAL && operation.artifactData) { + this.ComponentServiceNg2.uploadInterfaceOperationArtifact(this.component, newOpModel, operation).subscribe(); } else if (response.workflowId && operation.workflowAssociationType === WORKFLOW_ASSOCIATION_OPTIONS.EXISTING) { this.WorkflowServiceNg2.associateWorkflowArtifact(this.component, response).subscribe(); } else if (operation.workflowAssociationType === WORKFLOW_ASSOCIATION_OPTIONS.NEW) { @@ -351,7 +355,7 @@ export class InterfaceOperationComponent { } private updateOperation = (operation: OperationModel): void => { - this.ComponentServiceNg2.updateInterfaceOperation(this.component, operation).subscribe(newOperation => { + this.ComponentServiceNg2.updateInterfaceOperation(this.component, operation).subscribe((newOperation: OperationModel) => { this.openOperation = null; let oldOpIndex, oldInterf; @@ -366,11 +370,12 @@ export class InterfaceOperationComponent { oldInterf.operations.splice(oldOpIndex, 1); const newInterf = _.find(this.interfaces, interf => interf.type === operation.interfaceType); - newInterf.operations.push(new UIOperationModel(newOperation)); + const newOpModel = new UIOperationModel(newOperation); + newInterf.operations.push(newOpModel); this.sortInterfaces(); - if (operation.workflowAssociationType === WORKFLOW_ASSOCIATION_OPTIONS.EXTERNAL) { - this.ComponentServiceNg2.uploadInterfaceOperationArtifact(this.component, newOperation, operation).subscribe(); + if (operation.workflowAssociationType === WORKFLOW_ASSOCIATION_OPTIONS.EXTERNAL && operation.artifactData) { + this.ComponentServiceNg2.uploadInterfaceOperationArtifact(this.component, newOpModel, operation).subscribe(); } else if (newOperation.workflowId && operation.workflowAssociationType === WORKFLOW_ASSOCIATION_OPTIONS.EXISTING) { this.WorkflowServiceNg2.associateWorkflowArtifact(this.component, newOperation).subscribe(); } diff --git a/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/operation-creator.component.html b/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/operation-creator.component.html index 63730948b6..ec056ad6f2 100644 --- a/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/operation-creator.component.html +++ b/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/operation-creator.component.html @@ -86,15 +86,15 @@
- +
- {{ operation.artifactFile && operation.artifactFile.name }} + {{ operation.artifactFileName }}
@@ -107,6 +107,7 @@ maxsize="10240" data-tests-id="artifactUpload" (change)="onChangeArtifactFile($event)" + (click)="$event.target.value = ''" />
Browse
diff --git a/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/operation-creator.component.ts b/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/operation-creator.component.ts index a1dccce21b..e12905654b 100644 --- a/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/operation-creator.component.ts +++ b/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/operation-creator.component.ts @@ -198,6 +198,8 @@ export class OperationCreatorComponent implements OperationCreatorInput { if (inputOperation) { this.onSelectInterface(new DropDownOption(this.operation.interfaceType)); + this.operation.artifactFileName = this.operation.artifactFileName || this.operation.implementation.artifactName; + if (this.enableWorkflowAssociation && inputOperation.workflowVersionId && this.isUsingExistingWF(inputOperation)) { this.assignInputParameters[this.operation.workflowId] = {[inputOperation.workflowVersionId]: []}; this.assignOutputParameters[this.operation.workflowId] = {[inputOperation.workflowVersionId]: []}; @@ -333,13 +335,13 @@ export class OperationCreatorComponent implements OperationCreatorInput { ).sort((a, b) => a.name.localeCompare(b.name)), (version: any) => { if (!this.assignInputParameters[this.operation.workflowId][version.id] && version.id !== selectedVersionId) { - this.assignInputParameters[this.operation.workflowId][version.id] = _.map(version.inputs, (input: OperationParameter) => { - return new OperationParameter({...input, type: input.type.toLowerCase(), required: Boolean(input.required)}); + this.assignInputParameters[this.operation.workflowId][version.id] = _.map(version.inputs, (input: any) => { + return new OperationParameter({...input, type: input.type.toLowerCase(), required: Boolean(input.mandatory)}); }) .sort((a, b) => a.name.localeCompare(b.name)); - this.assignOutputParameters[this.operation.workflowId][version.id] = _.map(version.outputs, (output: OperationParameter) => { - return new OperationParameter({...output, type: output.type.toLowerCase(), required: Boolean(output.required)}); + this.assignOutputParameters[this.operation.workflowId][version.id] = _.map(version.outputs, (output: any) => { + return new OperationParameter({...output, type: output.type.toLowerCase(), required: Boolean(output.mandatory)}); }) .sort((a, b) => a.name.localeCompare(b.name)); } @@ -399,9 +401,9 @@ export class OperationCreatorComponent implements OperationCreatorInput { onChangeArtifactFile(e: any) { const file = e.target.files && e.target.files[0]; - this.operation.artifactFile = file; + this.operation.artifactFileName = file && file.name; - if (!this.operation.artifactFile) { + if (!this.operation.artifactFileName) { this.operation.artifactData = null; this.validityChanged(); return; @@ -511,9 +513,7 @@ export class OperationCreatorComponent implements OperationCreatorInput { checkFormValidForSubmit = (): boolean => { return this.operation.name && - (this.isUsingExternalWF() ? - (this.operation.artifactFile && this.operation.artifactFile.name) : - (!this.isUsingExistingWF() || this.operation.workflowVersionId)) && + (!this.isUsingExistingWF() || this.operation.workflowVersionId) && this.isParamsValid(); } -- cgit 1.2.3-korg