Audit log,resolved merge conflict 07/109907/3
authorjz385p <jegadeesh.babu@att.com>
Tue, 7 Jul 2020 13:54:27 +0000 (19:24 +0530)
committerJegadeesh Babu <jegadeesh.babu@att.com>
Tue, 7 Jul 2020 14:22:26 +0000 (14:22 +0000)
Audit log code merge conflict resolved

Issue-ID: PORTAL-941
Change-Id: I1dbe87cee9b471aa0b7319bd8a568826de927c8b
Signed-off-by: jz385p <jegadeesh.babu@att.com>
portal-FE-common/src/app/layout/components/tabbar/tabbar.component.html
portal-FE-common/src/app/layout/components/tabbar/tabbar.component.spec.ts
portal-FE-common/src/app/layout/components/tabbar/tabbar.component.ts
portal-FE-common/src/app/pages/dashboard-application-catalog/dashboard-application-catalog.component.html
portal-FE-common/src/app/pages/dashboard-application-catalog/dashboard-application-catalog.component.ts
portal-FE-common/src/app/shared/services/auditLog/audit-log.service.spec.ts [new file with mode: 0644]
portal-FE-common/src/app/shared/services/auditLog/audit-log.service.ts [new file with mode: 0644]

index 93dd345..8d3d876 100644 (file)
@@ -38,7 +38,7 @@
   <div style="display: flex; flex-direction:column">
 
       <mat-tab-group [selectedIndex]="selected.value" (selectedIndexChange)="selected.setValue($event)"
-        (selectedTabChange)="tabChanged($event)">
+        (selectedTabChange)="tabChanged($event);auditLog($event)" >
         <mat-tab [label]="mainTab">
           <!--
             <mat-grid-list cols="5">
 
         </mat-tab>
 
-        <mat-tab *ngFor="let tab of tabs; let index = index">
+        <mat-tab *ngFor="let tab of tabs; let index = index" >
           <ng-template mat-tab-label>
             {{tab.label | elipsis: 13}} &nbsp;
-            <i class="icon ion-md-close-circle" (click)="removeTab(index)"></i>
+            <i class="icon ion-md-close-circle" (click)="removeTab(index);removeAppObject(index)"></i>
           </ng-template>
 
 
index 76aaa3e..066d73f 100644 (file)
@@ -43,6 +43,7 @@ import { NgMaterialModule } from 'src/app/ng-material-module';
 import { Component } from '@angular/core';
 import { ElipsisPipe } from 'src/app/shared/pipes/elipsis/elipsis.pipe';
 import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
+import { HttpClientTestingModule} from '@angular/common/http/testing';
 
 describe('TabbarComponent', () => {
   let component: TabbarComponent;
@@ -51,7 +52,7 @@ describe('TabbarComponent', () => {
   beforeEach(async(() => {
     TestBed.configureTestingModule({
       declarations: [ TabbarComponent, AppSideBarStubComponent, AppUserBarStubComponent,RouterOutletStubComponent,AppFooterBarStubComponent,ElipsisPipe],
-      imports: [NgMaterialModule,BrowserAnimationsModule]
+      imports: [NgMaterialModule,BrowserAnimationsModule,HttpClientTestingModule]
     })
     .compileComponents();
   }));
index b0b882d..b157abb 100644 (file)
@@ -40,6 +40,7 @@ import { FormControl } from '@angular/forms';
 import { DomSanitizer } from '@angular/platform-browser';
 import { Tab } from './tab';
 import { AddTabFunctionService } from 'src/app/shared/services/tab/add-tab-function.service';
+import { AuditLogService } from 'src/app/shared/services/auditLog/audit-log.service';
 
 @Component({
   selector: 'app-tabbar',
@@ -49,11 +50,12 @@ import { AddTabFunctionService } from 'src/app/shared/services/tab/add-tab-funct
 export class TabbarComponent implements OnInit {
 
   tabs = [];
+  tabsInfoObject = [];
   mainTab = 'Home';
   selected = new FormControl(0);
   collapedSideBar: boolean;
 
-  constructor(private sanitizer: DomSanitizer, private addTabFuntionService: AddTabFunctionService) {
+  constructor(private sanitizer: DomSanitizer, private addTabFuntionService: AddTabFunctionService, private auditLogService: AuditLogService) {
 
   }
 
@@ -61,7 +63,9 @@ export class TabbarComponent implements OnInit {
 
     this.addTabFuntionService.listen().subscribe((m: any) => {
       console.log(m);
+      this.createAppObject(m);
       this.addTab(true, m.title, m.url);
+      
     })
   }
 
@@ -76,6 +80,15 @@ export class TabbarComponent implements OnInit {
     }
   }
 
+  createAppObject(app:any) {
+    this.tabsInfoObject.push(app);
+  }
+
+  removeAppObject(index:number) {
+    this.tabsInfoObject.splice(index, 1);
+
+  }
+
   removeTab(index: number) {
     this.tabs.splice(index, 1);
   }
@@ -85,6 +98,7 @@ export class TabbarComponent implements OnInit {
   }
 
   tabChanged($event) {
+    console.log("$event.index "+$event.value);
 
     for (const ttab of this.tabs) {
       ttab.active = false;
@@ -99,4 +113,20 @@ export class TabbarComponent implements OnInit {
     };
     return style;
   }
+
+  auditLog($event) {
+    var app = this.tabsInfoObject[$event.index - 1];
+    var comment = '';
+    if(app.content==null || app.content==''){
+       comment= app.title;
+    }
+    else{
+       comment = app.content;
+    }
+    this.auditLogService.storeAudit(app.appId, 'tab', comment).subscribe(data => {
+      console.log('Tab action Saved');
+    }, error => {
+      console.log('auditLog Save Error' + error);
+    });
+  }
 }
index 3169fa0..4c02d0c 100644 (file)
@@ -70,7 +70,7 @@
                   'background-color':'white',
                   'background-repeat': 'no-repeat',
                   'background-size': '168px 118px',
-                   'height': '80%'}" (click)="openAddRoleModal(item)">
+                   'height': '80%'}" (click)="openAddRoleModal(item);auditLog(item)">
             </div>
 
           </div>
index f8a80bb..bd6500b 100644 (file)
@@ -46,6 +46,7 @@ import { CatalogModalComponent } from '../catalog-modal/catalog-modal.component'
 import { ExternalRequestAccessService } from 'src/app/shared/services/external-request-access-service/external-request-access.service';
 import { UsersService } from 'src/app/shared/services/users/users.service';
 import { AddTabFunctionService } from 'src/app/shared/services/tab/add-tab-function.service';
+import { AuditLogService } from 'src/app/shared/services/auditLog/audit-log.service';
 
 @Component({
   selector: 'app-dashboard-application-catalog',
@@ -67,7 +68,7 @@ export class DashboardApplicationCatalogComponent implements OnInit {
     return this.applicationCatalogService.options;
   } get layout(): GridsterItem[] {
     return this.applicationCatalogService.layout;
-  } constructor(private applicationCatalogService: ApplicationCatalogService, private externalRequestAccessService: ExternalRequestAccessService, private userService: UsersService,private addTabFuntionService: AddTabFunctionService) {
+  } constructor(private applicationCatalogService: ApplicationCatalogService, private externalRequestAccessService: ExternalRequestAccessService, private userService: UsersService,private addTabFuntionService: AddTabFunctionService, private auditLogService: AuditLogService) {
     this.sortOptions = [{
       index: 0,
       value: 'N',
@@ -214,4 +215,12 @@ export class DashboardApplicationCatalogComponent implements OnInit {
       this.addTabFuntionService.filter(tabContent);
     }
   }
+
+  auditLog(app:any) {
+    this.auditLogService.storeAudit(app.appId, 'app', app.url).subscribe(data => {
+      console.log('App action Saved');
+    }, error => {
+      console.log('auditLog Save Error' + error);
+    });
+  }
 }
\ No newline at end of file
diff --git a/portal-FE-common/src/app/shared/services/auditLog/audit-log.service.spec.ts b/portal-FE-common/src/app/shared/services/auditLog/audit-log.service.spec.ts
new file mode 100644 (file)
index 0000000..1295915
--- /dev/null
@@ -0,0 +1,13 @@
+import { TestBed } from '@angular/core/testing';
+
+import { AuditLogService } from './audit-log.service';
+import { HttpClientTestingModule} from '@angular/common/http/testing';
+
+describe('AuditLogService', () => {
+  beforeEach(() => TestBed.configureTestingModule({imports: [HttpClientTestingModule]}));
+
+  it('should be created', () => {
+    const service: AuditLogService = TestBed.get(AuditLogService);
+    expect(service).toBeTruthy();
+  });
+});
diff --git a/portal-FE-common/src/app/shared/services/auditLog/audit-log.service.ts b/portal-FE-common/src/app/shared/services/auditLog/audit-log.service.ts
new file mode 100644 (file)
index 0000000..0504fb9
--- /dev/null
@@ -0,0 +1,23 @@
+import { Injectable } from '@angular/core';
+import { Observable } from 'rxjs';
+import { environment } from 'src/environments/environment';
+import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
+
+@Injectable({
+  providedIn: 'root'
+})
+export class AuditLogService {
+
+  constructor(private api: HttpClient) { }
+
+  storeAudit(affectedAppId:any,type:any,comment:any): Observable<any> {
+    var url = environment.api.storeAuditLog+'?affectedAppId=' + affectedAppId;
+               if(type!=''){
+                       url= url+'&type='+type;
+               }
+               if(comment!=''){
+                       url= url+'&comment='+comment;
+               }
+    return this.api.get(url);
+  }
+}