Feature 11011: Multiple NS deletion in OSM
- Added multi option in smart table
- Added new terminate api for multi select deletion
Change-Id: Ia03d24e30c1c0a549ac1eda87264d58ab6d3bccd
Signed-off-by: SANDHYA.JS <sandhya.j@tataelxsi.co.in>
diff --git a/src/app/utilities/delete/DeleteComponent.html b/src/app/utilities/delete/DeleteComponent.html
index a39cb61..513bc21 100644
--- a/src/app/utilities/delete/DeleteComponent.html
+++ b/src/app/utilities/delete/DeleteComponent.html
@@ -28,6 +28,9 @@
</div>
<div class="modal-footer">
<button (click)="activeModal.close()" class="btn btn-danger">{{'CANCEL' | translate}}</button>
- <button (click)="deleteData();" class="btn btn-primary">{{'OK' | translate }}</button>
+ <button *ngIf="!isPage; else multiDelete" (click)="deleteData();" class="btn btn-primary">{{'OK' | translate}}</button>
+ <ng-template #multiDelete>
+ <button *ngIf="isPage" (click)="terminate();" class="btn btn-primary">{{'DELETE' | translate }}</button>
+ </ng-template>
</div>
<app-loader [waitingMessage]="message" *ngIf="isLoadingResults"></app-loader>
\ No newline at end of file
diff --git a/src/app/utilities/delete/DeleteComponent.ts b/src/app/utilities/delete/DeleteComponent.ts
index b403e9b..d79d4e4 100644
--- a/src/app/utilities/delete/DeleteComponent.ts
+++ b/src/app/utilities/delete/DeleteComponent.ts
@@ -23,10 +23,11 @@
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { TranslateService } from '@ngx-translate/core';
import { NotifierService } from 'angular-notifier';
-import { DELETEPARAMS, ERRORDATA, MODALCLOSERESPONSEDATA, URLPARAMS } from 'CommonModel';
+import { APIURLHEADER, DELETEPARAMS, ERRORDATA, MODALCLOSERESPONSEDATA, URLPARAMS } from 'CommonModel';
import { DataService } from 'DataService';
import { environment } from 'environment';
import { RestService } from 'RestService';
+import { isNullOrUndefined } from 'SharedService';
/**
* Creating component
@@ -54,6 +55,13 @@
/** Check the loading results @public */
public isLoadingResults: Boolean = false;
+ /** Check the page @public */
+ public isPage: Boolean = false;
+
+ /** Number of instances @public */
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
+ public noOfInstances: Number = 25;
+
/** Give the message for the loading @public */
public notifyMessage: string = 'DELETELOADERMESSAGE';
@@ -106,8 +114,20 @@
if (data.identifier !== undefined || data.identifier !== '' || data.identifier !== null) {
this.id = data.identifier;
}
- this.createTitleandID(data);
- this.createDeleteUrl(data);
+ if (!isNullOrUndefined(this.params)) {
+ if (this.params.page === 'instantiateNS') {
+ this.isPage = true;
+ this.title = '';
+ this.createDeleteUrl(data);
+ } else if (this.params.page === 'ns-instance') {
+ this.createDeleteUrl(data);
+ this.isPage = false;
+ }
+ } else {
+ this.createTitleandID(data);
+ this.createDeleteUrl(data);
+ this.isPage = false;
+ }
});
}
/** Generate Title and Id from data @public */
@@ -129,10 +149,18 @@
/** Generate Delete url from data @public */
public createDeleteUrl(data: DELETEPARAMS): void {
this.deleteURL = '';
- if (data.page === 'ns-instance') {
- this.deleteURL = environment.NSINSTANCESCONTENT_URL;
- this.forceDelete = this.params.forceDeleteType;
- } else if (data.page === 'ns-package') {
+ if (!isNullOrUndefined(this.params)) {
+ if (this.params.page === 'ns-instance') {
+ this.deleteURL = environment.NSINSTANCESCONTENT_URL;
+ this.forceDelete = this.params.forceDeleteType;
+ this.title = this.params.name;
+ this.id = this.params.id;
+ } else if (this.params.page === 'instantiateNS') {
+ this.deleteURL = environment.NSINSTANCESTERMINATE_URL;
+ this.notifyMessage = 'DELETEDSUCCESSFULLY';
+ }
+ }
+ if (data.page === 'ns-package') {
this.deleteURL = environment.NSDESCRIPTORSCONTENT_URL;
this.notifyMessage = 'DELETEDSUCCESSFULLY';
} else if (data.page === 'vnf-package') {
@@ -191,7 +219,7 @@
}
this.restService.deleteResource(deletingURl).subscribe((res: {}) => {
this.activeModal.close(modalData);
- this.notifierService.notify('success', this.translateService.instant(this.notifyMessage, { title: this.title}));
+ this.notifierService.notify('success', this.translateService.instant(this.notifyMessage, { title: this.title }));
}, (error: ERRORDATA) => {
this.isLoadingResults = false;
this.restService.handleError(error, 'delete');
@@ -199,4 +227,41 @@
this.isLoadingResults = false;
});
}
+
+ /** terminate multiple ns instances function @public */
+ public terminate(): void {
+ this.isLoadingResults = true;
+ const modalData: MODALCLOSERESPONSEDATA = {
+ message: 'Done'
+ };
+ const idData: string[] = [];
+ this.params.identifierList.forEach((data: DELETEPARAMS) => {
+ idData.push(data.identifier);
+ });
+ if (idData.length > this.noOfInstances) {
+ this.activeModal.close(modalData);
+ this.notifierService.notify('warning', this.translateService.instant('WARNINGMESSAGE'));
+ } else {
+ const postData: {} = {
+ ns_ids: idData
+ };
+ let deletingURl: string = '';
+ deletingURl = this.deleteURL;
+ this.notifyMessage = 'DELETELOADMESSAGE';
+ const apiURLHeader: APIURLHEADER = {
+ url: deletingURl,
+ httpOptions: { headers: this.headers }
+ };
+ this.restService.postResource(apiURLHeader, postData).subscribe(() => {
+ this.activeModal.close(modalData);
+ this.isLoadingResults = false;
+ this.notifierService.notify('success', this.translateService.instant(this.notifyMessage));
+ }, (error: ERRORDATA) => {
+ this.isLoadingResults = false;
+ this.restService.handleError(error, 'post');
+ }, () => {
+ this.isLoadingResults = false;
+ });
+ }
+ }
}