From f7dee08d8e56fc023aeb6f12aa2f688978545e01 Mon Sep 17 00:00:00 2001 From: vasraz Date: Thu, 9 Feb 2023 17:57:56 +0000 Subject: Add support for delete property from non-normative data type Signed-off-by: Vasyl Razinkov Change-Id: I668b1e7f7d00e97b7827d759766e105fdd53ed53 Issue-ID: SDC-4378 --- .../type-workspace-properties.component.html | 9 ++++-- .../type-workspace-properties.component.ts | 26 ++++++++++++++++- .../src/app/ng2/services/data-type.service.ts | 33 ++++++++++++++++------ 3 files changed, 56 insertions(+), 12 deletions(-) (limited to 'catalog-ui/src/app/ng2') diff --git a/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace-properties/type-workspace-properties.component.html b/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace-properties/type-workspace-properties.component.html index e657520ee4..12b2d992a8 100644 --- a/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace-properties/type-workspace-properties.component.html +++ b/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace-properties/type-workspace-properties.component.html @@ -32,14 +32,15 @@
{{header.title}}
+
{{'PROPERTY_LIST_EMPTY_MESSAGE' | translate}}
-
-
+
+
@@ -54,6 +55,10 @@
{{property.description}}
+
+ +
diff --git a/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace-properties/type-workspace-properties.component.ts b/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace-properties/type-workspace-properties.component.ts index 60edd13c2d..f9eaa1332d 100644 --- a/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace-properties/type-workspace-properties.component.ts +++ b/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace-properties/type-workspace-properties.component.ts @@ -32,6 +32,8 @@ import {TranslateService} from "../../../shared/translator/translate.service"; import {AddPropertyComponent, PropertyValidationEvent} from "./add-property/add-property.component"; import {IWorkspaceViewModelScope} from "../../../../view-models/workspace/workspace-view-model"; import {SdcUiServices} from "onap-ui-angular/dist"; +import {PropertyModel} from "../../../../models/properties"; +import {SdcUiCommon, SdcUiComponents} from "onap-ui-angular"; import {ToscaTypeHelper} from "../../../../utils/tosca-type-helper"; @Component({ @@ -249,9 +251,31 @@ export class TypeWorkspacePropertiesComponent implements OnInit { } return null; } + + delete(property: PropertyModel) { + let onOk: Function = (): void => { + this.dataTypeService.deleteProperty(this.dataType.uniqueId, property.uniqueId).subscribe((response) => { + const props = this.properties; + props.splice(props.findIndex(p => p.uniqueId === response), 1); + this.filter(); + }, (error) => { + console.error(error); + }); + }; + let title: string = this.translateService.translate("PROPERTY_VIEW_DELETE_MODAL_TITLE"); + let message: string = this.translateService.translate("PROPERTY_VIEW_DELETE_MODAL_TEXT", {'name': property.name}); + const okButton = { + testId: "OK", + text: "OK", + type: SdcUiCommon.ButtonType.info, + callback: onOk, + closeModal: true + } as SdcUiComponents.ModalButtonComponent; + this.modalServiceSdcUI.openInfoModal(title, message, 'delete-modal', [okButton]); + }; } interface TableHeader { title: string; property: string; -} \ No newline at end of file +} 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 38714c96da..636217fb68 100644 --- a/catalog-ui/src/app/ng2/services/data-type.service.ts +++ b/catalog-ui/src/app/ng2/services/data-type.service.ts @@ -20,9 +20,15 @@ import * as _ from "lodash"; import {Inject, Injectable} from '@angular/core'; -import {DataTypeModel, DataTypesMap, PropertyFEModel, DerivedFEProperty, PropertyBEModel} from "app/models"; -import { DataTypesService } from "app/services/data-types-service"; -import { PROPERTY_DATA } from "app/utils"; +import { + DataTypeModel, + DataTypesMap, + DerivedFEProperty, + PropertyBEModel, + PropertyFEModel +} from "app/models"; +import {DataTypesService} from "app/services/data-types-service"; +import {PROPERTY_DATA} from "app/utils"; import {DerivedFEAttribute} from "../../models/attributes-outputs/derived-fe-attribute"; import {ISdcConfig} from "../config/sdc-config.config.factory"; import {SdcConfigToken} from "../config/sdc-config.config"; @@ -62,7 +68,7 @@ export class DataTypeService { } public getDataTypeByTypeName(typeName: string): DataTypeModel { - if(!this.dataTypes){ + if (!this.dataTypes) { this.dataTypes = this.dataTypeService.getAllDataTypes(); } if (!this.dataTypes[typeName]) console.log("MISSING Datatype: " + typeName); @@ -97,6 +103,15 @@ export class DataTypeService { return this.httpClient.put(url, property); } + public deleteProperty(dataTypeId: string, propertyId: string): Observable { + const url = `${this.dataTypeUrl}/${dataTypeId}/${propertyId}`; + let headers = new HttpHeaders({'USER_ID': this.authService.getLoggedinUser().userId}); + let options = {headers: headers}; + return this.httpClient.delete(url, options).map((res: Response) => { + return propertyId; + }); + } + public createImportedType(model: string, importingFile: File): Observable { const url = `${this.dataTypeUploadUrl}/datatypesyaml`; const formData = new FormData(); @@ -109,7 +124,7 @@ export class DataTypeService { return this.httpClient.post(url, formData, options); } - public getConstraintsByParentTypeAndUniqueID(rootPropertyType, propertyName){ + public getConstraintsByParentTypeAndUniqueID(rootPropertyType, propertyName) { // const property = this.dataTypes[rootPropertyType].properties.filter(property => // property.name == propertyName); // return property[0] && property[0].constraints ? property[0].constraints[0].validValues : null; @@ -121,7 +136,7 @@ export class DataTypeService { if (!dataTypeObj) return; if (dataTypeObj.properties) { dataTypeObj.properties.forEach((derivedProperty) => { - if(dataTypeObj.name !== PROPERTY_DATA.OPENECOMP_ROOT || derivedProperty.name !== PROPERTY_DATA.SUPPLEMENTAL_DATA){//The requirement is to not display the property supplemental_data + if (dataTypeObj.name !== PROPERTY_DATA.OPENECOMP_ROOT || derivedProperty.name !== PROPERTY_DATA.SUPPLEMENTAL_DATA) {//The requirement is to not display the property supplemental_data propertiesArray.push(new DerivedFEProperty(derivedProperty, parentName)); } let derivedDataTypeObj: DataTypeModel = this.getDataTypeByTypeName(derivedProperty.type); @@ -139,7 +154,7 @@ export class DataTypeService { if (!dataTypeObj) return; if (dataTypeObj.attributes) { dataTypeObj.attributes.forEach((derivedAttribute) => { - if(dataTypeObj.name !== PROPERTY_DATA.OPENECOMP_ROOT || derivedAttribute.name !== PROPERTY_DATA.SUPPLEMENTAL_DATA){//The requirement is to not display the property supplemental_data + if (dataTypeObj.name !== PROPERTY_DATA.OPENECOMP_ROOT || derivedAttribute.name !== PROPERTY_DATA.SUPPLEMENTAL_DATA) {//The requirement is to not display the property supplemental_data attributesArray.push(new DerivedFEAttribute(derivedAttribute, parentName)); } let derivedDataTypeObj: DataTypeModel = this.getDataTypeByTypeName(derivedAttribute.type); @@ -156,8 +171,8 @@ export class DataTypeService { * Checks for custom behavior for a given data type by checking if a function exists within data-type.service with that name * Additional custom behavior can be added by adding a function with the given dataType name */ - public checkForCustomBehavior = (property:PropertyFEModel) => { - let shortTypeName:string = property.type.split('.').pop(); + public checkForCustomBehavior = (property: PropertyFEModel) => { + let shortTypeName: string = property.type.split('.').pop(); if (this[shortTypeName]) { this[shortTypeName](property); //execute function for given type, pass property as param } -- cgit 1.2.3-korg lor: #f8f8f2 } /* Name.Variable.Class */ .highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ .highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ .highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ } @media (prefers-color-scheme: light) { .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
<!--
  ~ Copyright © 2016-2018 European Support Limited
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>org.openecomp.sdc.core</groupId>
  <name>openecomp-heat-lib</name>
  <artifactId>openecomp-heat-lib</artifactId>

  <parent>
    <artifactId>openecomp-sdc-lib</artifactId>
    <groupId>org.openecomp.sdc</groupId>
    <version>1.7.2-SNAPSHOT</version>
  </parent>

  <dependencies>
    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.onap.sdc.common</groupId>
      <artifactId>onap-configuration-management-core</artifactId>
      <version>${project.version}</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.onap.sdc.common</groupId>
      <artifactId>onap-tosca-datatype</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.openecomp.sdc.core</groupId>
      <artifactId>openecomp-utilities-lib</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.openecomp.sdc</groupId>
      <artifactId>openecomp-sdc-datatypes-lib</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.openecomp.sdc.core</groupId>
      <artifactId>openecomp-common-lib</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>${logback.version}</version>
    </dependency>
    <dependency>
      <groupId>org.openecomp.sdc</groupId>
      <artifactId>openecomp-sdc-validation-api</artifactId>
      <version>${project.version}</version>
    </dependency>
  </dependencies>
  <build>
    <testResources>
      <testResource>
        <directory>src/test/resources</directory>
        <filtering>true</filtering>
      </testResource>
    </testResources>
  </build>
</project>