X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=catalog-ui%2Fsrc%2Fapp%2Fng2%2Fpages%2Finterface-definition%2Finterface-definition.page.component.ts;h=82afb0a3e7b1a732edfb89e70dfe36c3bfee925e;hb=db333a620e4b8dec6c58009162561b32c83d6bd9;hp=5372fc919d56f17481f46f46495acb9bc15a4361;hpb=1a1676fbf411f3cc675752828724a6a95d7e5971;p=sdc.git diff --git a/catalog-ui/src/app/ng2/pages/interface-definition/interface-definition.page.component.ts b/catalog-ui/src/app/ng2/pages/interface-definition/interface-definition.page.component.ts index 5372fc919d..82afb0a3e7 100644 --- a/catalog-ui/src/app/ng2/pages/interface-definition/interface-definition.page.component.ts +++ b/catalog-ui/src/app/ng2/pages/interface-definition/interface-definition.page.component.ts @@ -21,7 +21,7 @@ import {Component, ComponentRef, Inject, Input} from '@angular/core'; import {Component as IComponent} from 'app/models/components/component'; import {WorkflowServiceNg2} from 'app/ng2/services/workflow.service'; - +import {HierarchyDisplayOptions} from "../../components/logic/hierarchy-navigtion/hierarchy-display-options"; import {ISdcConfig, SdcConfigToken} from "app/ng2/config/sdc-config.config"; import {TranslateService} from "app/ng2/shared/translator/translate.service"; import {IModalButtonComponent, SdcUiServices} from 'onap-ui-angular'; @@ -34,6 +34,7 @@ import { CapabilitiesGroup, InputBEModel, InterfaceModel, + ComponentInstance, ModalModel, OperationModel, WORKFLOW_ASSOCIATION_OPTIONS @@ -42,19 +43,14 @@ import { import {ComponentServiceNg2} from 'app/ng2/services/component-services/component.service'; import {TopologyTemplateService} from "../../services/component-services/topology-template.service"; import {InterfaceOperationModel} from "../../../models/interfaceOperation"; -import { - InterfaceOperationHandlerComponent -} from "../composition/interface-operatons/operation-creator/interface-operation-handler.component"; -import { - DropdownValue -} from "../../components/ui/form-components/dropdown/ui-element-dropdown.component"; +import {InterfaceOperationHandlerComponent} from "../composition/interface-operatons/operation-creator/interface-operation-handler.component"; +import {DropdownValue} from "../../components/ui/form-components/dropdown/ui-element-dropdown.component"; import {ToscaArtifactModel} from "../../../models/toscaArtifact"; import {ToscaArtifactService} from "../../services/tosca-artifact.service"; -import { - InterfaceOperationComponent -} from "../interface-operation/interface-operation.page.component"; +import {InterfaceOperationComponent} from "../interface-operation/interface-operation.page.component"; import {Observable} from "rxjs/Observable"; import {PluginsService} from 'app/ng2/services/plugins.service'; +import { InstanceFeDetails } from 'app/models/instance-fe-details'; export class UIOperationModel extends OperationModel { isCollapsed: boolean = true; @@ -87,7 +83,6 @@ export class UIOperationModel extends OperationModel { } } -// tslint:disable-next-line:max-classes-per-file class ModalTranslation { CREATE_TITLE: string; EDIT_TITLE: string; @@ -127,7 +122,6 @@ export class UIInterfaceModel extends InterfaceModel { } } -// tslint:disable-next-line:max-classes-per-file @Component({ selector: 'interface-definition', templateUrl: './interface-definition.page.component.html', @@ -140,6 +134,13 @@ export class InterfaceDefinitionComponent { interfaces: UIInterfaceModel[]; inputs: InputBEModel[]; + instancesNavigationData = []; + instances: any = []; + loadingInstances: boolean = false; + selectedInstanceData: any = null; + hierarchyInstancesDisplayOptions: HierarchyDisplayOptions = new HierarchyDisplayOptions('uniqueId', 'name', 'archived', null, 'iconClass'); + disableFlag : boolean = true; + deploymentArtifactsFilePath: Array = []; toscaArtifactTypes: Array = []; @@ -151,11 +152,14 @@ export class InterfaceDefinitionComponent { modalTranslation: ModalTranslation; workflows: any[]; capabilities: CapabilitiesGroup; - isViewOnly: boolean; openOperation: OperationModel; enableWorkflowAssociation: boolean; workflowIsOnline: boolean; + validImplementationProps: boolean = true; + validMilestoneActivities: boolean = true; + validMilestoneFilters: boolean = true; + serviceInterfaces: InterfaceModel[]; @Input() component: IComponent; @Input() readonly: boolean; @@ -189,16 +193,33 @@ export class InterfaceDefinitionComponent { this.ComponentServiceNg2.getInterfaceOperations(this.component), this.ComponentServiceNg2.getComponentInputs(this.component), this.ComponentServiceNg2.getInterfaceTypes(this.component), - this.ComponentServiceNg2.getCapabilitiesAndRequirements(this.component.componentType, this.component.uniqueId) + this.ComponentServiceNg2.getCapabilitiesAndRequirements(this.component.componentType, this.component.uniqueId), + this.componentServiceNg2.getComponentResourcePropertiesData(this.component) ).subscribe((response: any[]) => { const callback = (workflows) => { this.isLoading = false; + this.serviceInterfaces = response[0].interfaces; this.initInterfaces(response[0].interfaces); this.sortInterfaces(); this.inputs = response[1].inputs; this.interfaceTypes = response[2]; this.workflows = (workflows.items) ? workflows.items : workflows; this.capabilities = response[3].capabilities; + this.instances = response[4].componentInstances; + const serviceInstance = new ComponentInstance(); + serviceInstance.name = "SELF"; + serviceInstance.uniqueId = this.component.uniqueId; + if (this.instances != null) { + this.instances.unshift(serviceInstance); + } else { + this.instances = [serviceInstance]; + } + _.forEach(this.instances, (instance) => { + this.instancesNavigationData.push(instance); + }); + this.onInstanceSelectedUpdate(this.instancesNavigationData[0]); + this.loadingInstances = false; + }; if (this.enableWorkflowAssociation && this.workflowIsOnline) { this.WorkflowServiceNg2.getWorkflows().subscribe( @@ -212,9 +233,54 @@ export class InterfaceDefinitionComponent { callback([]); } }); + this.loadToscaArtifacts(); } + onInstanceSelectedUpdate = (instance: any) => { + this.selectedInstanceData = instance; + if (instance.name != "SELF") { + this.disableFlag = true; + let newInterfaces : InterfaceModel[] = []; + if (instance.interfaces instanceof Array) { + instance.interfaces.forEach(result => { + let interfaceObj = new InterfaceModel(); + interfaceObj.type = result.type; + interfaceObj.uniqueId = result.uniqueId; + if (result.operations instanceof Array) { + interfaceObj.operations = result.operations; + } else if (!_.isEmpty(result.operations)) { + interfaceObj.operations = []; + Object.keys(result.operations).forEach(name => { + interfaceObj.operations.push(result.operations[name]); + }); + } + newInterfaces.push(interfaceObj); + }); + } else { + Object.keys(instance.interfaces).forEach(key => { + let obj = instance.interfaces[key]; + let interfaceObj = new InterfaceModel(); + interfaceObj.type = obj.type; + interfaceObj.uniqueId = obj.uniqueId; + if (obj.operations instanceof Array) { + interfaceObj.operations = obj.operations; + } else if (!_.isEmpty(obj.operations)) { + interfaceObj.operations = []; + Object.keys(obj.operations).forEach(name => { + interfaceObj.operations.push(obj.operations[name]); + }); + } + newInterfaces.push(interfaceObj); + }); + } + this.interfaces = newInterfaces.map((interf) => new UIInterfaceModel(interf)); + } else { + this.interfaces = this.serviceInterfaces.map((interf) => new UIInterfaceModel(interf)); + } + this.sortInterfaces(); + } + initInterfaces(interfaces: InterfaceModel[]): void { if (interfaces) { this.interfaces = interfaces.map((interf) => new UIInterfaceModel(interf)); @@ -226,22 +292,50 @@ export class InterfaceDefinitionComponent { } private disableSaveButton = (): boolean => { - return this.isViewOnly || - (this.isEnableAddArtifactImplementation() - && (!this.modalInstance.instance.dynamicContent.toscaArtifactTypeSelected || - !this.modalInstance.instance.dynamicContent.artifactName) - ); + let disable:boolean = true; + if(this.readonly) { + return disable; + } + if (this.component.isService()) { + return disable; + } + const validMilestoneActivities = this.modalInstance.instance.dynamicContent.instance.validMilestoneActivities; + const validMilestoneFilters = this.modalInstance.instance.dynamicContent.instance.validMilestoneFilters; + if (!validMilestoneActivities || !validMilestoneFilters) { + return disable; + } + + let selectedInterfaceOperation = this.modalInstance.instance.dynamicContent.instance.selectedInterfaceOperation; + let isInterfaceOperation:boolean = !(typeof selectedInterfaceOperation == 'undefined' || _.isEmpty(selectedInterfaceOperation)); + let selectedInterfaceType = this.modalInstance.instance.dynamicContent.instance.selectedInterfaceType; + let isInterfaceType:boolean = !(typeof selectedInterfaceType == 'undefined' || _.isEmpty(selectedInterfaceType)); + let bothSet: boolean = isInterfaceOperation && isInterfaceType; + + let enableAddArtifactImplementation = this.modalInstance.instance.dynamicContent.instance.enableAddArtifactImplementation; + if(enableAddArtifactImplementation) { + let validImplementationProps = this.modalInstance.instance.dynamicContent.instance.validImplementationProps; + let toscaArtifactTypeSelected = this.modalInstance.instance.dynamicContent.instance.toscaArtifactTypeSelected; + let isToscaArtifactType:boolean = !(typeof toscaArtifactTypeSelected == 'undefined' || _.isEmpty(toscaArtifactTypeSelected)); + disable = !bothSet || !isToscaArtifactType || !validImplementationProps; + return disable; + } + disable = !bothSet; + return disable; } onSelectInterfaceOperation(interfaceModel: UIInterfaceModel, operation: InterfaceOperationModel) { const isEdit = operation !== undefined; - const cancelButton: ButtonModel = new ButtonModel(this.modalTranslation.CANCEL_BUTTON, 'outline white', this.cancelAndCloseModal); - const saveButton: ButtonModel = new ButtonModel(this.modalTranslation.SAVE_BUTTON, 'blue', - () => isEdit ? this.updateOperation() : this.createOperationCallback(), - this.disableSaveButton - ); + const modalButtons = []; + if (!this.readonly) { + const saveButton: ButtonModel = new ButtonModel(this.modalTranslation.SAVE_BUTTON, 'blue', + () => isEdit ? this.updateOperation() : this.createOperationCallback(), + this.disableSaveButton + ); + modalButtons.push(saveButton); + } + modalButtons.push(new ButtonModel(this.modalTranslation.CANCEL_BUTTON, 'outline white', this.cancelAndCloseModal)); const interfaceDataModal: ModalModel = - new ModalModel('l', this.modalTranslation.EDIT_TITLE, '', [saveButton, cancelButton], 'custom'); + new ModalModel('l', this.modalTranslation.EDIT_TITLE, '', modalButtons, 'custom'); this.modalInstance = this.modalServiceNg2.createCustomModal(interfaceDataModal); this.modalServiceNg2.addDynamicContentToModal( @@ -253,8 +347,11 @@ export class InterfaceDefinitionComponent { selectedInterface: interfaceModel ? interfaceModel : new UIInterfaceModel(), selectedInterfaceOperation: operation ? operation : new InterfaceOperationModel(), validityChangedCallback: this.disableSaveButton, - isViewOnly: this.isViewOnly, - isEdit: isEdit, + isViewOnly: this.readonly, + validImplementationProps: this.validImplementationProps, + validMilestoneActivities: this.validMilestoneActivities, + validMilestoneFilters: this.validMilestoneFilters, + 'isEdit': isEdit, interfaceTypesMap: this.interfaceTypesMap, modelName: this.component.model } @@ -266,12 +363,19 @@ export class InterfaceDefinitionComponent { this.modalServiceNg2.currentModal.instance.dynamicContent.instance.isLoading = true; const interfaceOperationHandlerComponentInstance: InterfaceOperationHandlerComponent = this.modalInstance.instance.dynamicContent.instance; const operationToUpdate = this.modalInstance.instance.dynamicContent.instance.operationToUpdate; + let timeout = null; + if (operationToUpdate.implementation && operationToUpdate.implementation.timeout != null) { + timeout = operationToUpdate.implementation.timeout; + } const isArtifactChecked = interfaceOperationHandlerComponentInstance.enableAddArtifactImplementation; if (!isArtifactChecked) { const artifactName = interfaceOperationHandlerComponentInstance.artifactName ? interfaceOperationHandlerComponentInstance.artifactName : ''; operationToUpdate.implementation = new ArtifactModel({'artifactName': artifactName, 'artifactVersion': ''} as ArtifactModel); } + if (timeout != null) { + operationToUpdate.implementation.timeout = timeout; + } this.componentServiceNg2.updateComponentInterfaceOperation(this.component.uniqueId, operationToUpdate) .subscribe((newOperation: InterfaceOperationModel) => { let oldOpIndex; @@ -398,8 +502,10 @@ export class InterfaceDefinitionComponent { return this.interfaces.filter((interfaceData) => interfaceData.operations && interfaceData.operations.length > 0).length > 0; } - onRemoveOperation = (event: Event, operation: OperationModel): void => { - event.stopPropagation(); + onRemoveOperation(operation: OperationModel): void { + if (this.readonly) { + return; + } const deleteButton: IModalButtonComponent = { id: 'deleteButton',