diff options
Diffstat (limited to 'catalog-ui/src/app/ng2')
10 files changed, 59 insertions, 41 deletions
diff --git a/catalog-ui/src/app/ng2/pages/attributes-outputs/attribute-creator/attribute-creator.component.ts b/catalog-ui/src/app/ng2/pages/attributes-outputs/attribute-creator/attribute-creator.component.ts index 5fc3d5b5ac..96ec935202 100644 --- a/catalog-ui/src/app/ng2/pages/attributes-outputs/attribute-creator/attribute-creator.component.ts +++ b/catalog-ui/src/app/ng2/pages/attributes-outputs/attribute-creator/attribute-creator.component.ts @@ -27,6 +27,7 @@ import * as _ from 'lodash'; import {PROPERTY_TYPES} from '../../../../utils'; import {AttributeBEModel} from "../../../../models/attributes-outputs/attribute-be-model"; import {Validation} from "../../../../view-models/workspace/tabs/general/general-view-model"; +import {WorkspaceService} from "../../workspace/workspace.service"; @Component({ selector: 'attribute-creator', @@ -43,7 +44,7 @@ export class AttributeCreatorComponent { dataTypes: DataTypesMap; isLoading: boolean; - constructor(protected dataTypeService: DataTypeService) { + constructor(protected dataTypeService: DataTypeService, protected workspaceService: WorkspaceService) { } ngOnInit() { @@ -51,7 +52,7 @@ export class AttributeCreatorComponent { this.attributeModel.type = ''; this.attributeModel.schema.property.type = ''; const types: string[] = PROPERTY_DATA.TYPES; // All types - simple type + map + list - this.dataTypes = this.dataTypeService.getAllDataTypes(); // Get all data types in service + this.dataTypes = this.dataTypeService.getDataTypeByModel(this.workspaceService.metadata.model); // Get all data types in service const nonPrimitiveTypes: string[] = _.filter(Object.keys(this.dataTypes), (type: string) => { return types.indexOf(type) === -1; }); diff --git a/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/param-row/param-row.component.ts b/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/param-row/param-row.component.ts index 76cf73ff17..8227229c26 100644 --- a/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/param-row/param-row.component.ts +++ b/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/param-row/param-row.component.ts @@ -3,6 +3,7 @@ import {PROPERTY_DATA} from "app/utils"; import {DataTypeService} from "app/ng2/services/data-type.service"; import {OperationModel, OperationParameter, InputBEModel, DataTypeModel, Capability} from 'app/models'; import {DropdownValue} from "app/ng2/components/ui/form-components/dropdown/ui-element-dropdown.component"; +import {WorkspaceService} from "../../../workspace/workspace.service"; class DropdownValueType extends DropdownValue { type: String; @@ -37,7 +38,7 @@ export class ParamRowComponent { filteredInputProps: Array<DropdownValue> = []; filteredCapabilitiesProps: Array<{capabilityName: string, properties: Array<DropdownValueType>}> = []; - constructor(private dataTypeService:DataTypeService) {} + constructor(private dataTypeService:DataTypeService, protected workspaceService: WorkspaceService) {} ngOnInit() { if (this.isInputParam) { @@ -58,7 +59,7 @@ export class ParamRowComponent { ) ); } else { - const dataTypes: Array<DataTypeModel> = _.toArray(this.dataTypeService.getAllDataTypes()); + const dataTypes: Array<DataTypeModel> = _.toArray(this.dataTypeService.getDataTypeByModel(this.workspaceService.metadata.model)); this.propTypeEnum = _.concat( _.map( _.filter( @@ -170,7 +171,7 @@ export class ParamRowComponent { getPrimitiveSubtypes(): Array<InputBEModel> { const flattenedProps: Array<any> = []; - const dataTypes = this.dataTypeService.getAllDataTypes(); + const dataTypes = this.dataTypeService.getDataTypeByModel(this.workspaceService.metadata.model); _.forEach(this.inputProps, prop => { const type:DataTypeModel = _.find( diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/declare-list/declare-list.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/declare-list/declare-list.component.ts index 8ca4f44116..cb90b8b83e 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/declare-list/declare-list.component.ts +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/declare-list/declare-list.component.ts @@ -29,6 +29,7 @@ import { ModalService } from 'app/ng2/services/modal.service'; import { PROPERTY_DATA } from 'app/utils'; import * as _ from 'lodash'; import { PROPERTY_TYPES } from '../../../../utils'; +import {WorkspaceService} from "../../workspace/workspace.service"; @Component({ selector: 'declare-list', @@ -50,7 +51,7 @@ export class DeclareListComponent { propertiesListString: string; privateDataType: DataTypeModel; - constructor(protected dataTypeService: DataTypeService, private modalService: ModalService) {} + constructor(protected dataTypeService: DataTypeService, private modalService: ModalService, private workspaceService: WorkspaceService) {} ngOnInit() { console.log('DeclareListComponent.ngOnInit() - enter'); @@ -59,7 +60,7 @@ export class DeclareListComponent { this.propertyModel.schema.property.type = ''; this.propertyModel.required = false; const types: string[] = PROPERTY_DATA.TYPES; // All types - simple type + map + list - this.dataTypes = this.dataTypeService.getAllDataTypes(); // Get all data types in service + this.dataTypes = this.dataTypeService.getDataTypeByModel(this.workspaceService.metadata.model); // Get all data types in service const nonPrimitiveTypes: string[] = _.filter(Object.keys(this.dataTypes), (type: string) => { return types.indexOf(type) === -1; }); diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.module.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.module.ts index ae4aa57572..10273e2636 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.module.ts +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.module.ts @@ -36,12 +36,13 @@ import {ComponentModeService} from "../../services/component-services/component- import {SdcUiComponentsModule} from "onap-ui-angular"; import {ModalFormsModule} from "app/ng2/components/ui/forms/modal-forms.module"; import {HierarchyNavigationModule} from "../../components/logic/hierarchy-navigtion/hierarchy-navigation.module"; +import {PropertyCreatorComponent} from "./property-creator/property-creator.component"; @NgModule({ declarations: [ PropertiesAssignmentComponent, InputsTableComponent, - FilterPropertiesAssignmentComponent + FilterPropertiesAssignmentComponent, ], imports: [ BrowserModule, @@ -59,7 +60,7 @@ import {HierarchyNavigationModule} from "../../components/logic/hierarchy-navigt exports: [ PropertiesAssignmentComponent ], - providers: [PropertiesService, HierarchyNavService, PropertiesUtils, InputsUtils, DataTypeService, ComponentModeService] + providers: [PropertiesService, HierarchyNavService, PropertiesUtils, InputsUtils, DataTypeService, ComponentModeService, PropertyCreatorComponent] }) export class PropertiesAssignmentModule { diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html index 8847e96d18..b54cbc97c2 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html @@ -87,7 +87,7 @@ </div> <div class="right-column"> <div *ngIf="!isReadonly && !isInputsTabSelected" class="add-btn" - (click)="addProperty()" data-tests-id="properties-add-button" [ngClass]="{'disabled': !isSelf()}">Add Property</div> + (click)="addProperty(component.model)" data-tests-id="properties-add-button" [ngClass]="{'disabled': !isSelf()}">Add Property</div> <div *ngIf="!isReadonly && isInputsTabSelected" class="add-btn" (click)="addInput()" [ngClass]="{'disabled': !isSelf()}">Add Input</div> <tabs #hierarchyNavTabs tabStyle="simple-tabs" class="gray-border"> diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts index 6d009a8039..fbbc4d8b0e 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts @@ -67,6 +67,7 @@ import {ToscaPresentationData} from "../../../models/tosca-presentation"; import {Observable} from "rxjs"; import {ToscaGetFunctionType} from "../../../models/tosca-get-function-type.enum"; import {TranslateService} from "../../shared/translator/translate.service"; +import {Model} from '../../../models/model'; const SERVICE_SELF_TITLE = "SELF"; @Component({ @@ -130,6 +131,7 @@ export class PropertiesAssignmentComponent { private inputsUtils: InputsUtils, private componentServiceNg2: ComponentServiceNg2, private componentInstanceServiceNg2: ComponentInstanceServiceNg2, + private propertyCreatorComponent: PropertyCreatorComponent, @Inject("$stateParams") _stateParams, @Inject("$scope") private $scope: ng.IScope, @Inject("$state") private $state: ng.ui.IStateService, @@ -220,6 +222,8 @@ export class PropertiesAssignmentComponent { }); } }); + + this.loadDataTypesByComponentModel(this.component.model); }; ngOnDestroy() { @@ -1142,7 +1146,8 @@ export class PropertiesAssignmentComponent { } /*** addProperty ***/ - addProperty = () => { + addProperty = (model: Model) => { + this.loadDataTypesByComponentModel(model) let modalTitle = 'Add Property'; let modal = this.ModalService.createCustomModal(new ModalModel( 'sm', @@ -1172,8 +1177,8 @@ export class PropertiesAssignmentComponent { ], null )); - this.ModalService.addDynamicContentToModal(modal, PropertyCreatorComponent, {}); modal.instance.open(); + this.ModalService.addDynamicContentToModal(modal, PropertyCreatorComponent, {}); } /*** addInput ***/ @@ -1245,6 +1250,10 @@ export class PropertiesAssignmentComponent { private isInput = (instanceType:string):boolean =>{ return instanceType === ResourceType.VF || instanceType === ResourceType.PNF || instanceType === ResourceType.CVFC || instanceType === ResourceType.CR; } - + + loadDataTypesByComponentModel(model:Model) { + let modelName = new Model(model).name; + this.propertyCreatorComponent.filterDataTypesByModel(modelName); + } } diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/property-creator/property-creator.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/property-creator/property-creator.component.ts index 8167caa959..57c9f97387 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/property-creator/property-creator.component.ts +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/property-creator/property-creator.component.ts @@ -7,6 +7,7 @@ import { PROPERTY_DATA } from 'app/utils'; import * as _ from 'lodash'; import { PROPERTY_TYPES } from '../../../../utils'; import {Validation} from "../../../../view-models/workspace/tabs/general/general-view-model"; +import {WorkspaceService} from "../../workspace/workspace.service"; @Component({ selector: 'property-creator', @@ -23,14 +24,38 @@ export class PropertyCreatorComponent { dataTypes: DataTypesMap; isLoading: boolean; - constructor(protected dataTypeService: DataTypeService) {} + constructor(protected dataTypeService: DataTypeService, private workspaceService: WorkspaceService) { + this.filterDataTypesByModel(this.workspaceService.metadata.model); + } + + checkFormValidForSubmit() { + const showSchema: boolean = this.showSchema(); + const isSchemaValid: boolean = (showSchema && !this.propertyModel.schema.property.type) ? false : true; + if (!showSchema) { + this.propertyModel.schema.property.type = ''; + } + return this.propertyModel.name && this.propertyModel.type && isSchemaValid; + } + + showSchema(): boolean { + return [PROPERTY_TYPES.LIST, PROPERTY_TYPES.MAP].indexOf(this.propertyModel.type) > -1; + } + + onSchemaTypeChange(): void { + if (this.propertyModel.type === PROPERTY_TYPES.MAP) { + this.propertyModel.value = JSON.stringify({'': null}); + } else if (this.propertyModel.type === PROPERTY_TYPES.LIST) { + this.propertyModel.value = JSON.stringify([]); + } + } - ngOnInit() { + public filterDataTypesByModel = (modelName: string) => { + this.dataTypes = new DataTypesMap(null); + this.dataTypes = this.dataTypeService.getDataTypeByModel(modelName); this.propertyModel = new PropertyBEModel(); this.propertyModel.type = ''; this.propertyModel.schema.property.type = ''; const types: string[] = PROPERTY_DATA.TYPES; // All types - simple type + map + list - this.dataTypes = this.dataTypeService.getAllDataTypes(); // Get all data types in service const nonPrimitiveTypes: string[] = _.filter(Object.keys(this.dataTypes), (type: string) => { return types.indexOf(type) === -1; }); @@ -43,35 +68,13 @@ export class PropertyCreatorComponent { ); const nonPrimitiveTypesValues = _.map(nonPrimitiveTypes, (type: string) => new DropdownValue(type, - type.replace('org.openecomp.datatypes.heat.', '')) + type.replace('org.openecomp.datatypes.heat.', '')) ) .sort((a, b) => a.label.localeCompare(b.label)); this.typesProperties = _.concat(this.typesProperties, nonPrimitiveTypesValues); this.typesSchemaProperties = _.concat(typesSimpleProperties, nonPrimitiveTypesValues); this.typesProperties.unshift(new DropdownValue('', 'Select Type...')); this.typesSchemaProperties.unshift(new DropdownValue('', 'Select Schema Type...')); - - } - - checkFormValidForSubmit() { - const showSchema: boolean = this.showSchema(); - const isSchemaValid: boolean = (showSchema && !this.propertyModel.schema.property.type) ? false : true; - if (!showSchema) { - this.propertyModel.schema.property.type = ''; - } - return this.propertyModel.name && this.propertyModel.type && isSchemaValid; - } - - showSchema(): boolean { - return [PROPERTY_TYPES.LIST, PROPERTY_TYPES.MAP].indexOf(this.propertyModel.type) > -1; - } - - onSchemaTypeChange(): void { - if (this.propertyModel.type === PROPERTY_TYPES.MAP) { - this.propertyModel.value = JSON.stringify({'': null}); - } else if (this.propertyModel.type === PROPERTY_TYPES.LIST) { - this.propertyModel.value = JSON.stringify([]); - } } } diff --git a/catalog-ui/src/app/ng2/services/data-type.service.ts b/catalog-ui/src/app/ng2/services/data-type.service.ts index 30eb6f0c77..85c8b898aa 100644 --- a/catalog-ui/src/app/ng2/services/data-type.service.ts +++ b/catalog-ui/src/app/ng2/services/data-type.service.ts @@ -47,8 +47,8 @@ export class DataTypeService { return this.dataTypes[typeName]; } - public getAllDataTypes(): DataTypesMap { - return this.dataTypes; + public getDataTypeByModel(modelName: string): DataTypesMap { + return this.dataTypeService.getAllDataTypesFromModel(modelName); } public getConstraintsByParentTypeAndUniqueID(rootPropertyType, propertyName){ diff --git a/catalog-ui/src/app/ng2/services/model.service.ts b/catalog-ui/src/app/ng2/services/model.service.ts index 33d57295bf..10ad4142de 100644 --- a/catalog-ui/src/app/ng2/services/model.service.ts +++ b/catalog-ui/src/app/ng2/services/model.service.ts @@ -20,6 +20,7 @@ import { HttpClient } from '@angular/common/http'; import { Inject, Injectable } from '@angular/core'; import { Observable } from 'rxjs/Observable'; import { ISdcConfig, SdcConfigToken } from '../config/sdc-config.config'; +import {Model} from "../../models/model"; @Injectable() export class ModelService { diff --git a/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts b/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts index 96a21262e8..fa3de88c7b 100644 --- a/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts +++ b/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts @@ -31,6 +31,7 @@ import { GroupInstance } from "../../../models/graph/zones/group-instance"; import { InputsGroup } from "../../../models/inputs"; import { InterfaceModel } from "../../../models/operation"; import { OutputBEModel } from "app/models/attributes-outputs/output-be-model"; +import {Model} from "../../../models/model"; export class ComponentGenericResponse implements Serializable<ComponentGenericResponse> { |