diff options
Diffstat (limited to 'portal-FE-common')
7 files changed, 83 insertions, 7 deletions
diff --git a/portal-FE-common/src/app/layout/components/tabbar/tabbar.component.html b/portal-FE-common/src/app/layout/components/tabbar/tabbar.component.html index 93dd3450..8d3d876e 100644 --- a/portal-FE-common/src/app/layout/components/tabbar/tabbar.component.html +++ b/portal-FE-common/src/app/layout/components/tabbar/tabbar.component.html @@ -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"> @@ -68,10 +68,10 @@ </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}} - <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> diff --git a/portal-FE-common/src/app/layout/components/tabbar/tabbar.component.spec.ts b/portal-FE-common/src/app/layout/components/tabbar/tabbar.component.spec.ts index 76aaa3e7..066d73ff 100644 --- a/portal-FE-common/src/app/layout/components/tabbar/tabbar.component.spec.ts +++ b/portal-FE-common/src/app/layout/components/tabbar/tabbar.component.spec.ts @@ -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(); })); diff --git a/portal-FE-common/src/app/layout/components/tabbar/tabbar.component.ts b/portal-FE-common/src/app/layout/components/tabbar/tabbar.component.ts index b0b882d3..b157abbc 100644 --- a/portal-FE-common/src/app/layout/components/tabbar/tabbar.component.ts +++ b/portal-FE-common/src/app/layout/components/tabbar/tabbar.component.ts @@ -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); + }); + } } diff --git a/portal-FE-common/src/app/pages/dashboard-application-catalog/dashboard-application-catalog.component.html b/portal-FE-common/src/app/pages/dashboard-application-catalog/dashboard-application-catalog.component.html index 3169fa01..4c02d0cc 100644 --- a/portal-FE-common/src/app/pages/dashboard-application-catalog/dashboard-application-catalog.component.html +++ b/portal-FE-common/src/app/pages/dashboard-application-catalog/dashboard-application-catalog.component.html @@ -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> diff --git a/portal-FE-common/src/app/pages/dashboard-application-catalog/dashboard-application-catalog.component.ts b/portal-FE-common/src/app/pages/dashboard-application-catalog/dashboard-application-catalog.component.ts index f8a80bb0..bd6500bd 100644 --- a/portal-FE-common/src/app/pages/dashboard-application-catalog/dashboard-application-catalog.component.ts +++ b/portal-FE-common/src/app/pages/dashboard-application-catalog/dashboard-application-catalog.component.ts @@ -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 index 00000000..1295915d --- /dev/null +++ b/portal-FE-common/src/app/shared/services/auditLog/audit-log.service.spec.ts @@ -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 index 00000000..0504fb9f --- /dev/null +++ b/portal-FE-common/src/app/shared/services/auditLog/audit-log.service.ts @@ -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); + } +} |