update code to latest

update code to latest

Change-Id: I6ed427434b0da47e0d33507a0992b09fe48f9c52
Issue-ID: DCAEGEN2-821
Signed-off-by: Manor, Yanir (ym903w) <ym903w@intl.att.com>
diff --git a/public/src/app/home/home.component.ts b/public/src/app/home/home.component.ts
index 349a031..aa783d4 100644
--- a/public/src/app/home/home.component.ts
+++ b/public/src/app/home/home.component.ts
@@ -5,7 +5,8 @@
 import { RestApiService } from '../api/rest-api.service';
 import { HostService } from '../host/host.service';
 import { ConfirmPopupComponent } from '../rule-engine/confirm-popup/confirm-popup.component';
-import { PluginPubSub } from '../sdc/plugin-pubsub';
+// import { PluginPubSub } from '../sdc/plugin-pubsub';
+import { PluginPubSub } from 'sdc-pubsub';
 import { Store } from '../store/store';
 import { NgxDatatableModule } from '@swimlane/ngx-datatable';
 
@@ -120,33 +121,25 @@
   }
 
   checkCanCreate() {
-    if (
+    return (
       JSON.parse(this.store.sdcParmas.isOwner) &&
       this.store.sdcParmas.lifecycleState === 'NOT_CERTIFIED_CHECKOUT'
-    ) {
-      return false;
-    } else {
-      return true;
-    }
+    );
   }
 
   // Monitoring Table logic
 
   checkTableItemHoverCondition(item: any): boolean {
-    if (
-      this.store.sdcParmas !== undefined &&
-      this.store.sdcParmas.userId === item.lastUpdaterUserId &&
-      this.store.sdcParmas.lifecycleState === 'NOT_CERTIFIED_CHECKOUT'
-    ) {
-      return false;
-    } else {
-      return true;
-    }
+    return (
+      this.checkCanCreate() &&
+      (this.store.sdcParmas.userId === item.lastUpdaterUserId ||
+        item['lifecycleState'] !== 'NOT_CERTIFIED_CHECKOUT')
+    );
   }
 
   onTableActivate(event: any): void {
     this.hoveredIndex = this.monitoringComponents.findIndex(
-      s => s == event.row
+      s => s === event.row
     );
     console.log('selected : ');
   }
@@ -161,18 +154,6 @@
     console.log('selected : ', item);
   }
 
-  deleteEnable(item: any): boolean {
-    console.log(
-      'delete enable: ',
-      item.isOwner && item.Lifecycle === 'NOT_CERTIFIED_CHECKOUT'
-    );
-    const { userId, lifecycleState } = this.store.sdcParmas;
-    return (
-      item.lastUpdaterUserId === userId &&
-      lifecycleState === 'NOT_CERTIFIED_CHECKOUT'
-    );
-  }
-
   deleteTableItem(item: any, index: any): void {
     this.deleteRow = index;
     this.dialogRef = this.dialog.open(ConfirmPopupComponent, {
@@ -183,6 +164,7 @@
       // if the user want to delete
       if (result) {
         if (item.status === 'Submitted') {
+          this.store.loader = true;
           this._restApi
             .deleteMonitoringComponentWithBlueprint(
               this.store.sdcParmas,
@@ -192,18 +174,24 @@
             )
             .subscribe(
               response => {
-                this.itemDeletedRemoveAndNotify(this.deleteRow);
+                this.itemDeletedRemoveAndNotify(item.uuid, this.deleteRow);
+                this.store.loader = false;
               },
               error => {
-                if (error.messageId === 'SVC6118') {
-                  this.monitoringComponents.splice(this.deleteRow, 1);
-                  this.changeDetectorRef.detectChanges();
-                }
                 const errorMsg = Object.values(error.requestError) as any;
+                if (errorMsg[0].messageId === 'SVC6118') {
+                  this.monitoringComponents = this.monitoringComponents.filter(
+                    comp => {
+                      return comp.uuid !== item.uuid;
+                    }
+                  );
+                }
+                this.store.loader = false;
                 this.toastr.error('', errorMsg[0].formattedErrorMessage);
               }
             );
         } else {
+          this.store.loader = true;
           this._restApi
             .deleteMonitoringComponent(
               this.store.sdcParmas,
@@ -212,10 +200,12 @@
             )
             .subscribe(
               response => {
-                this.itemDeletedRemoveAndNotify(this.deleteRow);
+                this.itemDeletedRemoveAndNotify(item.uuid, this.deleteRow);
+                this.store.loader = false;
               },
               error => {
                 const errorMsg = Object.values(error.requestError) as any;
+                this.store.loader = false;
                 this.toastr.error('', errorMsg[0]);
               }
             );
@@ -224,9 +214,10 @@
     });
   }
 
-  itemDeletedRemoveAndNotify(deletedRow: number): void {
-    this.monitoringComponents.splice(deletedRow, 1);
-    this.changeDetectorRef.detectChanges();
+  itemDeletedRemoveAndNotify(uuid, deletedRow: number): void {
+    this.monitoringComponents = this.monitoringComponents.filter(comp => {
+      return comp.uuid !== uuid;
+    });
     this.toastr.success(
       '',
       'Monitoring Configuration was successfully deleted'