summaryrefslogtreecommitdiffstats
path: root/catalog-ui
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
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')
-rw-r--r--catalog-ui/src/app/ng2/pages/type-workspace/type-workspace-properties/type-workspace-properties.component.html9
-rw-r--r--catalog-ui/src/app/ng2/pages/type-workspace/type-workspace-properties/type-workspace-properties.component.ts26
-rw-r--r--catalog-ui/src/app/ng2/services/data-type.service.ts33
3 files changed, 56 insertions, 12 deletions
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 @@
<div class="table-header head-row hand flex-item" *ngFor="let header of tableHeadersList" (click)="onUpdateSort(header.property)">{{header.title}}
<span *ngIf="tableSortBy === header.property" class="table-header-sort-arrow" [ngClass]="{'down': tableColumnReverse, 'up': !tableColumnReverse}"></span>
</div>
+ <div class="table-no-text-header head-row flex-item" *ngIf="!isViewOnly"><span class="delete-col-header"></span></div>
</div>
<div class="body">
<div *ngIf="filteredProperties.length === 0" class="no-row-text">
{{'PROPERTY_LIST_EMPTY_MESSAGE' | translate}}
</div>
- <div *ngFor="let property of filteredProperties" [attr.data-tests-id]="'property-row-' + property.name" class="flex-container data-row" (click)="onNameClick(property)">
- <div class="table-col-general flex-item text" [title]="property.name">
+ <div *ngFor="let property of filteredProperties" [attr.data-tests-id]="'property-row-' + property.name" class="flex-container data-row">
+ <div class="table-col-general flex-item text" [title]="property.name" (click)="onNameClick(property)">
<a [attr.data-tests-id]="'property-name-' + property.name" [ngClass]="{'disabled': false}">{{property.name}}</a>
</div>
<div class="table-col-general flex-item text" [title]="property.type">
@@ -54,6 +55,10 @@
<div class="table-col-general flex-item text" [title]="property.description || ''">
<span [attr.data-tests-id]="'property-description-' + property.name" [title]="property.description">{{property.description}}</span>
</div>
+ <div class="table-btn-col flex-item" *ngIf="!isViewOnly">
+ <button class="table-delete-btn" data-ng-if="!property.ownerId || property.ownerId==component.uniqueId"
+ (click)="delete(property); $event.stopPropagation();" data-ng-class="{'disabled': isViewOnly}"></button>
+ </div>
</div>
</div>
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<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
}
span class="na">name="p_exc" value="%replace(%replace(%rootException){'\t', '\\\\t'}){'\n','\\\\n'}" /> <property name="p_mak" value="%replace(%replace(%marker){'\t', '\\\\t'}){'\n','\\\\n'}" /> <property name="p_thr" value="%thread" /> <property name="defaultPattern" value="%nopexception${p_tim}\t${p_thr}\t${p_lvl}\t${p_log}\t${p_mdc}\t${p_msg}\t${p_exc}\t${p_mak}\t%n" /> <property name="debugPattern" value="%nopexception${p_tim}|${p_lvl}|${p_mdc}|${p_exc}|%msg%n" /> <!-- Example evaluator filter applied against console appender --> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> <level>INFO</level> </filter> <encoder> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n </pattern> </encoder> </appender> <appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender"> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> <level>INFO</level> </filter> <file>${logDirectory}/error.log</file> <append>true</append> <encoder> <pattern>${defaultPattern}</pattern> </encoder> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${logDirectory}/error.%d{yyyy-MM-dd}.%i.log.zip </fileNamePattern> <maxFileSize>50MB</maxFileSize> <maxHistory>20</maxHistory> <totalSizeCap>1GB</totalSizeCap> </rollingPolicy> </appender> <appender name="DEBUG" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${logDirectory}/debug.log</file> <append>true</append> <encoder> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n </pattern> </encoder> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${logDirectory}/debug.%d{yyyy-MM-dd}.%i.log.zip </fileNamePattern> <maxFileSize>50MB</maxFileSize> <maxHistory>20</maxHistory> <totalSizeCap>1GB</totalSizeCap> </rollingPolicy> </appender> <appender name="AUDIT" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${logDirectory}/audit.log</file> <append>true</append> <encoder> <pattern>%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%.20thread|%X{VirtualServerName}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}|%X{Unused}|%X{ProcessKey}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n </pattern> </encoder> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <FileNamePattern>${logDirectory}/audit.%d{yyyy-MM-dd}.%i.log.zip </FileNamePattern> <maxFileSize>50MB</maxFileSize> <maxHistory>20</maxHistory> <totalSizeCap>1GB</totalSizeCap> </rollingPolicy> </appender> <appender name="asyncEELFAudit" class="ch.qos.logback.classic.AsyncAppender"> <queueSize>256</queueSize> <appender-ref ref="AUDIT" /> </appender> <appender name="METRIC" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${logDirectory}/metric.log</file> <append>true</append> <encoder> <pattern>%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%.20thread|%X{VirtualServerName}|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}|%X{Unused}|%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}| %msg%n</pattern> </encoder> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <FileNamePattern>${logDirectory}/metric.%d{yyyy-MM-dd}.%i.log.zip </FileNamePattern> <maxFileSize>50MB</maxFileSize> <maxHistory>20</maxHistory> <totalSizeCap>1GB</totalSizeCap> </rollingPolicy> </appender> <appender name="asyncEELFMetrics" class="ch.qos.logback.classic.AsyncAppender"> <queueSize>256</queueSize> <appender-ref ref="METRIC" /> </appender> <!-- SECURITY related loggers --> <appender name="SECURITY" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${logDirectory}/security.log</file> <append>true</append> <encoder> <pattern>%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%.20thread|%X{VirtualServerName}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}|%X{Unused}|%X{ProcessKey}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n </pattern> </encoder> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <FileNamePattern>${logDirectory}/security.%d{yyyy-MM-dd}.%i.log.zip </FileNamePattern> <maxFileSize>50MB</maxFileSize> <maxHistory>20</maxHistory> <totalSizeCap>1GB</totalSizeCap> </rollingPolicy> </appender> <appender name="asyncEELFSecurity" class="ch.qos.logback.classic.AsyncAppender"> <queueSize>256</queueSize> <appender-ref ref="SECURITY" /> </appender> <!-- logback jms appenders & loggers definition starts here --> <appender name="auditLogs" class="ch.qos.logback.core.rolling.RollingFileAppender"> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> </filter> <file>${logDirectory}/Audits.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${logDirectory}/Audits-%d{yyyy-MM-dd}.%i.log.zip </fileNamePattern> <maxFileSize>50MB</maxFileSize> <maxHistory>20</maxHistory> <totalSizeCap>1GB</totalSizeCap> </rollingPolicy> <encoder> <pattern>"%d [%thread] %-5level %logger{1024} - %msg%n"</pattern> </encoder> </appender> <appender name="perfLogs" class="ch.qos.logback.core.rolling.RollingFileAppender"> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> </filter> <file>${logDirectory}/Perform.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${logDirectory}/Perform--%d{yyyy-MM-dd}.%i.log.zip </fileNamePattern> <maxFileSize>50MB</maxFileSize> <maxHistory>20</maxHistory> <totalSizeCap>1GB</totalSizeCap> </rollingPolicy> <encoder> <pattern>"%d [%thread] %-5level %logger{1024} - %msg%n"</pattern> </encoder> </appender> <logger name="org.onap.aaf" level="DEBUG"> <appender-ref ref="DEBUG" /> </logger> <logger name="org.hibernate" level="INFO"> <appender-ref ref="DEBUG" /> </logger> <logger name="org.apache.camel.Tracing" level="INFO"> <appender-ref ref="DEBUG" /> </logger> <logger name="org.apache" level="INFO"> <appender-ref ref="DEBUG" /> </logger> <!-- Spring related loggers --> <logger name="org.springframework" level="INFO"> <appender-ref ref="DEBUG" /> </logger> <!-- CLAMP related loggers --> <logger name="org.onap.clamp" level="DEBUG"> <appender-ref ref="ERROR" /> <appender-ref ref="DEBUG" /> </logger> <logger name="com.att.eelf.error" level="OFF"> <appender-ref ref="ERROR" /> </logger> <!-- EELF related loggers --> <logger name="com.att.eelf.audit" level="INFO" additivity="false"> <appender-ref ref="asyncEELFAudit" /> </logger> <logger name="com.att.eelf.metrics" level="DEBUG" additivity="false"> <appender-ref ref="asyncEELFMetrics" /> </logger> <logger name="com.att.eelf.security" level="DEBUG" additivity="false"> <appender-ref ref="asyncEELFSecurity" /> </logger> <!-- logback internals logging --> <logger name="ch.qos.logback.classic" level="INFO" /> <logger name="ch.qos.logback.core" level="INFO" /> <logger name="AuditRecord" level="INFO" additivity="false"> <appender-ref ref="auditLogs" /> </logger> <logger name="AuditRecord_DirectCall" level="INFO" additivity="false"> <appender-ref ref="auditLogs" /> </logger> <logger name="PerfTrackerRecord" level="INFO" additivity="false"> <appender-ref ref="perfLogs" /> </logger> <!-- logback jms appenders & loggers definition ends here --> <root level="DEBUG"> <appender-ref ref="DEBUG" /> <appender-ref ref="STDOUT" /> </root> </included>