aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/services
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2023-02-09 17:57:56 +0000
committerVasyl Razinkov <vasyl.razinkov@est.tech>2023-02-10 09:45:37 +0000
commitf7dee08d8e56fc023aeb6f12aa2f688978545e01 (patch)
tree06e6c3a764def525bab0f32514fa397ed23db6e5 /catalog-ui/src/app/ng2/services
parent9c057c26f14de77dff432403941322edaca7ea4e (diff)
Add support for delete property from non-normative data type
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Change-Id: I668b1e7f7d00e97b7827d759766e105fdd53ed53 Issue-ID: SDC-4378
Diffstat (limited to 'catalog-ui/src/app/ng2/services')
-rw-r--r--catalog-ui/src/app/ng2/services/data-type.service.ts33
1 files changed, 24 insertions, 9 deletions
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<PropertyBEModel>(url, property);
}
+ public deleteProperty(dataTypeId: string, propertyId: string): Observable<Object> {
+ 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<any> {
const url = `${this.dataTypeUploadUrl}/datatypesyaml`;
const formData = new FormData();
@@ -109,7 +124,7 @@ export class DataTypeService {
return this.httpClient.post<any>(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
}