summaryrefslogtreecommitdiffstats
path: root/catalog-ui
diff options
context:
space:
mode:
authorJvD_Ericsson <jeff.van.dam@est.tech>2023-02-21 14:07:50 +0000
committerMichael Morris <michael.morris@est.tech>2023-02-22 14:16:42 +0000
commit9b8d90c9cdc012ca444d35465dc2e77662e4becf (patch)
treeef9f5f6d99a5bcc5eb40d965829d9a5c0128ea76 /catalog-ui
parent8aa94a97ebfff1205e85470d78202f598632dbd6 (diff)
Support delete non-normative data types
Issue-ID: SDC-4411 Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech> Change-Id: I246e50d848a17178369bfb643989d5447a887017
Diffstat (limited to 'catalog-ui')
-rw-r--r--catalog-ui/src/app/ng2/pages/type-workspace/type-workspace.component.html13
-rw-r--r--catalog-ui/src/app/ng2/pages/type-workspace/type-workspace.component.less6
-rw-r--r--catalog-ui/src/app/ng2/pages/type-workspace/type-workspace.component.ts58
-rw-r--r--catalog-ui/src/app/ng2/pages/type-workspace/type-workspace.module.ts2
-rw-r--r--catalog-ui/src/app/ng2/services/data-type.service.ts9
-rw-r--r--catalog-ui/src/assets/languages/en_US.json4
6 files changed, 87 insertions, 5 deletions
diff --git a/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace.component.html b/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace.component.html
index cdd8e41503..8986142fd9 100644
--- a/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace.component.html
+++ b/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace.component.html
@@ -20,7 +20,8 @@
-->
<div class="sdc-workspace-container">
- <loader [display]="isLoading"></loader>
+
+ <loader class="loader" [display]="isLoading"></loader>
<div class="w-sdc-main-container">
<app-workspace-menu [menuHeader]="dataType.name"
(onMenuUpdate)="onMenuUpdate($event)"
@@ -33,7 +34,15 @@
</div>
<div class="sdc-workspace-top-bar-buttons">
<button *ngIf="!isViewOnly" data-ng-disabled="!isValidForm || isDisableMode() || isLoading || unsavedChanges" (click)="createImportType()" class="tlv-btn outline green" data-tests-id="create/save">Create</button>
- <span *ngIf="!isViewOnly" class="delimiter"></span>
+
+ <span *ngIf="!dataType.normative && isViewOnly"
+ class="sprite-new delete-btn"
+ data-tests-id="delete"
+ sdc-smart-tooltip="Delete Type"
+ (click)="deleteDataType()"
+ [title]="'DELETE_LABEL' | translate"></span>
+
+ <span class="delimiter"></span>
<span class="sprite-new x-btn" (click)="goToBreadcrumbHome()" sdc-smart-tooltip="Close" [title]="'CLOSE_LABEL' | translate"></span>
</div>
</div>
diff --git a/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace.component.less b/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace.component.less
index a12642d271..91ac8d46ca 100644
--- a/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace.component.less
+++ b/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace.component.less
@@ -27,6 +27,12 @@
.sdc-workspace-container {
.bg_p;
+ .loader {
+ z-index: 2;
+ display: flex;
+ position: relative;
+ }
+
.w-sdc-main-right-container {
padding: 0;
diff --git a/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace.component.ts b/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace.component.ts
index e0f7ac77a0..11a11747ff 100644
--- a/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace.component.ts
+++ b/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace.component.ts
@@ -20,6 +20,7 @@
*/
import {Component, Inject, Injector, OnInit} from '@angular/core';
+import {SdcMenuToken, IAppMenu} from "../../config/sdc-menu.config";
import {MenuItem, MenuItemGroup} from "../../../utils/menu-handler";
import {CacheService} from "../../services/cache.service";
import {DataTypeModel} from "../../../models/data-types";
@@ -29,7 +30,7 @@ import {TranslateService} from "../../shared/translator/translate.service";
import {HttpErrorResponse} from "@angular/common/http";
import {ServerErrorResponse} from "../../../models/server-error-response";
import {Observable} from "rxjs/Observable";
-import {SdcUiServices} from "onap-ui-angular/dist";
+import {SdcUiCommon, SdcUiComponents, SdcUiServices} from "onap-ui-angular/dist";
@Component({
selector: 'app-type-workspace',
@@ -54,7 +55,9 @@ export class TypeWorkspaceComponent implements OnInit {
private translateService: TranslateService,
@Inject('$state') private $state: ng.ui.IStateService,
@Inject('$stateParams') private stateParams,
- private injector: Injector) { }
+ private injector: Injector,
+ private modalServiceSdcUI: SdcUiServices.ModalService,
+ @Inject(SdcMenuToken) public sdcMenu: IAppMenu) { }
ngOnInit(): void {
this.sdcVersion = this.cacheService.get('version');
@@ -115,6 +118,57 @@ export class TypeWorkspaceComponent implements OnInit {
}
}
+ private deleteDataType() {
+ const modalTitle: string = this.translateService.translate('DELETE_DATA_TYPE_TITLE_CONFIRMATION_TEXT');
+ const modalMessage: string = this.translateService.translate('DELETE_DATA_TYPE_MESSAGE_CONFIRMATION_TEXT');;
+ const modalButton = {
+ testId: 'ok-button',
+ text: this.sdcMenu.alertMessages.okButton,
+ type: SdcUiCommon.ButtonType.warning,
+ callback: this.handleDeleteDataType(),
+ closeModal: true
+ } as SdcUiComponents.ModalButtonComponent;
+ this.modalServiceSdcUI.openWarningModal(modalTitle, modalMessage, 'alert-modal', [modalButton]);
+ }
+
+ private handleDeleteDataType():Function {
+ return () => {
+ this.isLoading = true;
+ this.dataTypeService.deleteDataType(this.dataType.uniqueId).subscribe(()=> {
+ this.Notification.success({
+ message: this.dataType.model + ' ' + this.dataType.name + ' ' + this.translateService.translate('DELETE_SUCCESS_MESSAGE_TEXT'),
+ title: this.translateService.translate("DELETE_SUCCESS_MESSAGE_TITLE")
+ });
+ if (this.$state.params.previousState) {
+ switch (this.$state.params.previousState) {
+ case 'catalog':
+ case 'dashboard':
+ this.$state.go(this.$state.params.previousState);
+ break;
+ default:
+ this.$state.go('dashboard');
+ break;
+ }
+ }
+ }, (error) => {
+ this.isLoading = false;
+ this.Notification.error({
+ message: this.dataType.model + ' ' + this.dataType.name + ' ' + this.translateService.translate('DELETE_FAILURE_MESSAGE_TEXT'),
+ title: this.translateService.translate('DELETE_FAILURE_MESSAGE_TITLE')
+ });
+ if (error instanceof HttpErrorResponse) {
+ const errorResponse: ServerErrorResponse = new ServerErrorResponse(error);
+ const modalService = this.injector.get(SdcUiServices.ModalService);
+ const errorDetails = {
+ 'Error Code': errorResponse.messageId,
+ 'Status Code': errorResponse.status
+ };
+ modalService.openErrorDetailModal('Error', errorResponse.message, 'error-modal', errorDetails);
+ }
+ });
+ }
+ }
+
private updateTypeBreadcrumb(): void {
this.typeMenuItemGroup.updateSelectedMenuItemText(`Data Type: ${this.dataType.name}`);
}
diff --git a/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace.module.ts b/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace.module.ts
index c517dd22c8..8cd3d89d6f 100644
--- a/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace.module.ts
+++ b/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace.module.ts
@@ -54,7 +54,7 @@ import {ConstraintsModule} from "../properties-assignment/constraints/constraint
NgxDatatableModule,
SvgIconModule,
AutoCompleteModule,
- ConstraintsModule
+ ConstraintsModule
],
declarations: [
TypeWorkspaceComponent,
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 636217fb68..d4af634cec 100644
--- a/catalog-ui/src/app/ng2/services/data-type.service.ts
+++ b/catalog-ui/src/app/ng2/services/data-type.service.ts
@@ -112,6 +112,15 @@ export class DataTypeService {
});
}
+ public deleteDataType(dataTypeId: string): Observable<Object> {
+ const url = `${this.dataTypeUrl}/${dataTypeId}`;
+ let headers = new HttpHeaders({'USER_ID': this.authService.getLoggedinUser().userId});
+ let options = {headers: headers};
+ return this.httpClient.delete(url, options).map((res: Response) => {
+ return dataTypeId;
+ });
+ }
+
public createImportedType(model: string, importingFile: File): Observable<any> {
const url = `${this.dataTypeUploadUrl}/datatypesyaml`;
const formData = new FormData();
diff --git a/catalog-ui/src/assets/languages/en_US.json b/catalog-ui/src/assets/languages/en_US.json
index a98bf4c8c1..58288840d6 100644
--- a/catalog-ui/src/assets/languages/en_US.json
+++ b/catalog-ui/src/assets/languages/en_US.json
@@ -581,6 +581,7 @@
"CREATED_LABEL": "Created",
"CREATE_LABEL": "Create",
"CLOSE_LABEL": "Close",
+ "DELETE_LABEL": "Delete",
"MODIFIED_LABEL": "Modified",
"UNIQUE_ID_LABEL": "Unique Id",
"=========== SERVICE IMPORT ===========": "",
@@ -590,6 +591,9 @@
"IMPORT_DATA_TYPE_FAILURE_PROCESSING_MESSAGE_TEXT": "Import Failure - error importing data type",
"IMPORT_DATA_TYPE_SUCCESS_MESSAGE_TEXT": "Successfully imported",
"IMPORT_DATA_TYPE_TITLE_TEXT": "Import Data Type",
+ "=========== DATA TYPE DELETE ===========": "",
+ "DELETE_DATA_TYPE_TITLE_CONFIRMATION_TEXT": "Delete Data Type Confirmation",
+ "DELETE_DATA_TYPE_MESSAGE_CONFIRMATION_TEXT": "This data type should only be deleted if it is not in use in any resources or services. Are you sure you want to proceed?",
"=========== PROPERTIES ===========": "",
"PROPERTY_LIST_EMPTY_MESSAGE": "There are no properties to display",
"PROPERTY_SHOWING_LABEL": "Showing Properties",