diff options
23 files changed, 475 insertions, 140 deletions
diff --git a/ecomp-sdk/epsdk-app-os/ngapp/src/app/pages/pages-routing.module.ts b/ecomp-sdk/epsdk-app-os/ngapp/src/app/pages/pages-routing.module.ts index eff5a3d0..3439f8c9 100644 --- a/ecomp-sdk/epsdk-app-os/ngapp/src/app/pages/pages-routing.module.ts +++ b/ecomp-sdk/epsdk-app-os/ngapp/src/app/pages/pages-routing.module.ts @@ -29,7 +29,7 @@ const routes: Routes = [ { path: 'reports/:reportMode/:reportId', component: HeaderTabsWrapperComponent}, { path: 'run/:reportId', component: RunReportComponent}, { path: 'run/:reportId/:queryParameters', component: RunReportFormFieldsComponent}, - { path: 'welcome/welcome', component :WelcomeDashboardComponent} + { path: 'welcome', component :WelcomeDashboardComponent} ]; @NgModule({ diff --git a/ecomp-sdk/epsdk-app-os/ngappsrc/portalsdk-tag-lib-0.0.1.tgz b/ecomp-sdk/epsdk-app-os/ngappsrc/portalsdk-tag-lib-0.0.1.tgz Binary files differindex dccad51f..3b1c200f 100644 --- a/ecomp-sdk/epsdk-app-os/ngappsrc/portalsdk-tag-lib-0.0.1.tgz +++ b/ecomp-sdk/epsdk-app-os/ngappsrc/portalsdk-tag-lib-0.0.1.tgz diff --git a/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/pages-routing.module.ts b/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/pages-routing.module.ts index eff5a3d0..3439f8c9 100644 --- a/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/pages-routing.module.ts +++ b/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/pages-routing.module.ts @@ -29,7 +29,7 @@ const routes: Routes = [ { path: 'reports/:reportMode/:reportId', component: HeaderTabsWrapperComponent}, { path: 'run/:reportId', component: RunReportComponent}, { path: 'run/:reportId/:queryParameters', component: RunReportFormFieldsComponent}, - { path: 'welcome/welcome', component :WelcomeDashboardComponent} + { path: 'welcome', component :WelcomeDashboardComponent} ]; @NgModule({ diff --git a/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/pages.module.ts b/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/pages.module.ts index 47b86c24..041988ab 100644 --- a/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/pages.module.ts +++ b/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/pages.module.ts @@ -61,6 +61,7 @@ import { BarChartComponent } from './welcome-dashboard/bar-chart/bar-chart.compo import { PieChartComponent } from './welcome-dashboard/pie-chart/pie-chart.component'; import { NoteComponent } from './welcome-dashboard/note/note.component'; import { GridsterModule } from 'angular-gridster2'; +import { RdpModule } from 'portalsdk-tag-lib'; @@ -138,7 +139,8 @@ import { GridsterModule } from 'angular-gridster2'; MatPaginatorModule, MatSortModule, MatIconModule, - GridsterModule + GridsterModule, + RdpModule ], entryComponents: [InformationModalComponent, ConfirmationModalComponent, NewRoleComponent, NewRoleFunctionComponent, NewMenuComponent], providers: [] diff --git a/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/welcome-dashboard/note/note.component.ts b/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/welcome-dashboard/note/note.component.ts index 9b35bb0d..d8935f7c 100644 --- a/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/welcome-dashboard/note/note.component.ts +++ b/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/welcome-dashboard/note/note.component.ts @@ -53,12 +53,15 @@ export class NoteComponent { @Output() focusout = new EventEmitter(); constructor(private el:ElementRef) { const {webkitSpeechRecognition} : IWindow = <IWindow>window; - this.recognition = new webkitSpeechRecognition(); - this.recognition.onresult = (event)=> { - this.el.nativeElement.querySelector(".content").innerText += event.results[0][0].transcript - console.log(event.results[0][0].transcript) - document.getElementById('toolbar').focus(); - }; + + // Commented below code as it works only for chrome browser. + + // this.recognition = new webkitSpeechRecognition(); + // this.recognition.onresult = (event)=> { + // this.el.nativeElement.querySelector(".content").innerText += event.results[0][0].transcript + // console.log(event.results[0][0].transcript) + // document.getElementById('toolbar').focus(); + // }; } onDismiss(event){ diff --git a/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/welcome-dashboard/welcome-dashboard.component.spec.ts b/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/welcome-dashboard/welcome-dashboard.component.spec.ts index 83f67d5b..da27f7d1 100644 --- a/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/welcome-dashboard/welcome-dashboard.component.spec.ts +++ b/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/welcome-dashboard/welcome-dashboard.component.spec.ts @@ -81,4 +81,17 @@ describe('WelcomeDashboardComponent', () => { it('should compile', () => { expect(component).toBeTruthy(); }); + + it('should test record method', () => { + component.record(event); + }); + + it('should test updateNote method', () => { + component.updateNote(""); + }); + + it('should test addNote method', () => { + component.addNote(); + }); + });
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/welcome-dashboard/welcome-dashboard.component.ts b/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/welcome-dashboard/welcome-dashboard.component.ts index 99118e3a..47e83e90 100644 --- a/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/welcome-dashboard/welcome-dashboard.component.ts +++ b/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/welcome-dashboard/welcome-dashboard.component.ts @@ -250,14 +250,15 @@ export class WelcomeDashboardComponent { this.initilizeData(); this.notes = JSON.parse(localStorage.getItem('notes')) || [{ id: 0,content:'' }]; - - const {webkitSpeechRecognition} : IWindow = <IWindow>window; - this.recognition = new webkitSpeechRecognition(); - this.recognition.onresult = (event)=> { - console.log(this.el.nativeElement.querySelectorAll(".content")[0]); - this.el.nativeElement.querySelectorAll(".content")[0].innerText = event.results[0][0].transcript + + // Commented below code as it works only for chrome browser. + // const {webkitSpeechRecognition} : IWindow = <IWindow>window; + // this.recognition = new webkitSpeechRecognition(); + // this.recognition.onresult = (event)=> { + // console.log(this.el.nativeElement.querySelectorAll(".content")[0]); + // this.el.nativeElement.querySelectorAll(".content")[0].innerText = event.results[0][0].transcript - }; + // }; } updateAllNotes() { diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/layout.module.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/layout.module.ts index 4f136074..a6bc03f0 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/layout.module.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/layout.module.ts @@ -44,14 +44,18 @@ import { LayoutRoutingModule } from './layout-routing.module'; import { LayoutComponent } from './layout.component'; import { SidebarComponent } from './components/sidebar/sidebar.component'; import { HeaderComponent } from './components/header/header.component'; +import { MatDialogModule } from '@angular/material/dialog'; +import { CookieService } from 'ngx-cookie-service'; @NgModule({ imports: [ CommonModule, LayoutRoutingModule, TranslateModule, - NgbDropdownModule + NgbDropdownModule, + MatDialogModule ], - declarations: [LayoutComponent, SidebarComponent, HeaderComponent] + declarations: [LayoutComponent, SidebarComponent, HeaderComponent], + providers:[CookieService] }) export class LayoutModule {} diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/new-menu/new-menu.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/new-menu/new-menu.component.spec.ts index 97ddeaaa..dc0301a4 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/new-menu/new-menu.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/new-menu/new-menu.component.spec.ts @@ -4,7 +4,10 @@ * =================================================================== * Copyright © 2019 AT&T Intellectual Property. All rights reserved. * =================================================================== - * + * + * * Modification Copyright © 2020 IBM. + * =================================================================== + * Unless otherwise specified, all software contained herein is licensed * under the Apache License, Version 2.0 (the "License"); * you may not use this software except in compliance with the License. @@ -40,33 +43,101 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import {FormsModule} from '@angular/forms'; import { NewMenuComponent } from './new-menu.component'; import { HttpClientTestingModule } from '@angular/common/http/testing'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { RouterModule } from '@angular/router'; +import { NgbActiveModal, NgbModalModule } from '@ng-bootstrap/ng-bootstrap'; import { RouterTestingModule } from '@angular/router/testing'; import { CookieService } from 'ngx-cookie-service'; - +import { MockBackend } from '@angular/http/testing'; +import { BaseRequestOptions, Http } from '@angular/http'; +import { AdminService } from '../../admin.service'; +import 'rxjs/add/operator/toPromise'; +import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { MaterialModule } from 'portalsdk-tag-lib/material-module'; +import 'rxjs/add/observable/of'; +import { Observable } from 'rxjs/Observable'; describe('NewMenuComponent', () => { let component: NewMenuComponent; let fixture: ComponentFixture<NewMenuComponent>; + let adminService:AdminService; + // let entryComponents:any; beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ NewMenuComponent ], - imports:[FormsModule, HttpClientTestingModule,RouterTestingModule], - providers:[NgbActiveModal,CookieService] + imports:[FormsModule, HttpClientTestingModule,RouterTestingModule,NgbModalModule,BrowserAnimationsModule], + providers:[AdminService,NgbActiveModal,CookieService,MockBackend,BaseRequestOptions,{ + provide:Http, + useFactory:(backend:MockBackend,defaultOptions:BaseRequestOptions)=>{ + return new Http(backend,defaultOptions); + }, + deps:[MockBackend,BaseRequestOptions], + entryComponents:[ConfirmationModalComponent] + }], }) .compileComponents(); + })); beforeEach(() => { fixture = TestBed.createComponent(NewMenuComponent); component = fixture.componentInstance; fixture.detectChanges(); + adminService=TestBed.get(AdminService); }); it('should create', () => { expect(component).toBeTruthy(); }); + + it('testing ngOnInit method for if condition',()=>{ + component.selectedMenu=1; + component.ngOnInit(); + expect(component.menu).toEqual(component.selectedMenu); + }) + + it('testing ngOnInit method for else condition',()=>{ + component.selectedMenu=0; + component.ngOnInit(); + expect(component.menu.menuSetCode).toEqual('APP'); + }) + + it('testing sortItems method',()=>{ + let prop: any; + component.sortItems(prop); + + }) + + it('testing getParentLabel method',()=>{ + component.getParentLabel(1,"data"); + }) + + describe('should test getParentData',()=>{ + it('testing getParentData',()=>{ + let spy=spyOn(adminService,'getParentData').and.returnValue(Observable.of('you object')); + component.getParentData(); + expect(spy).toHaveBeenCalled(); + + }) + }) + + describe('should test getLeftMenuItems',()=>{ + it('testing getLeftMenuItems',()=>{ + component.getLeftMenuItems(); + }) + }) + + describe('should test getFunctionCDselectData',()=>{ + it('testing getFunctionCDselectData',()=>{ + let spy=spyOn(adminService,'getFunctionCdList').and.returnValue(Observable.of(1,1)); + component.getFunctionCDselectData(); + expect(spy).toHaveBeenCalled(); + }) + }) + + it('should test updateFnMenu method',()=>{ + //component.updateFnMenu(); + }) + }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/columns/column-list/column-list.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/columns/column-list/column-list.component.spec.ts index 6d6e9431..8442c873 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/columns/column-list/column-list.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/columns/column-list/column-list.component.spec.ts @@ -1,4 +1,3 @@ - import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { MatPaginatorModule } from '@angular/material/paginator'; @@ -8,14 +7,20 @@ import { ColumnListComponent } from './column-list.component'; import { FormsModule } from '@angular/forms'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { ColumnService } from '../column.service'; +import 'rxjs/add/observable/of'; +import { Observable } from 'rxjs/Observable'; + describe('ColumnListComponent', () => { let component: ColumnListComponent; let fixture: ComponentFixture<ColumnListComponent>; + let _columnService: ColumnService; + beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ ColumnListComponent ], + declarations: [ ColumnListComponent], imports: [ NoopAnimationsModule, MatPaginatorModule, @@ -32,10 +37,130 @@ describe('ColumnListComponent', () => { fixture = TestBed.createComponent(ColumnListComponent); component = fixture.componentInstance; fixture.detectChanges(); + _columnService=TestBed.get(ColumnService); }); it('should compile', () => { expect(component).toBeTruthy(); }); + it('should test editRecord method',()=>{ + component.editRecord("id"); + expect(component.showSpinner).toBe(true); + expect(component.columnId).toEqual("id"); + + }) + + it('should test subscribe in editRecord method',()=>{ + + let spy1=spyOn(_columnService,'getIndividualColumnData').and.returnValue(Observable.of('you object')); + let spy2=spyOn(_columnService,'getDrillDownReportList').and.returnValue(Observable.of('you object')); + let spy3=spyOn(_columnService,'getResponseTotalColsList').and.returnValue(Observable.of('you object')); + component.editRecord("id"); + + expect(component.columnId).toEqual("id"); + expect(spy1).toHaveBeenCalled(); + expect(spy2).toHaveBeenCalled(); + expect(spy3).toHaveBeenCalled(); + + }) + + it('should test ngOnChanges method',()=>{ + spyOn(console,'log'); + component.ngOnChanges(); + expect(console.log).toHaveBeenCalledWith("Hit"); + }) + + it('should test close method',()=>{ + let spy1=spyOn(_columnService,'getColumnList').and.returnValue(Observable.of('')); + component.close(); + expect(spy1).toHaveBeenCalled(); + expect(component.finalObjArr).toEqual([]); + expect(component.finalGetObj).toEqual(''); + expect(component.dataSource.data).toEqual(component.finalObjArr); + expect(component.dataSource.sort).toEqual(component.sort); + expect(component.dataSource.paginator).toEqual(component.paginator); + expect(component.table.dataSource).toEqual(component.dataSource) + expect(component.showSpinner).toEqual(false); + }) + + it('should test complete method',()=>{ + component.showEditDrillDownPage=true; + component.complete(); + expect(component.showEditDrillDownPage).toBe(false); + expect(component.showConfirmButton).toBe(false); + }) + +it('should test onCompleted method',()=>{ + component.onCompleted("drilldownParamsArr"); + expect(component.drilldownParams).toBeUndefined(); +}) + +it('should test save method',()=>{ + component.noWrap=true; + component.save(); + expect(component.showSpinner).toBe(true); + expect(component.finalPOSTObj["tabId"]).toEqual("ColEdit"); + expect(component.finalPOSTObj["tabName"]).toEqual("Column Edit"); + expect(component.finalPOSTObj["colId"]).toEqual(component.id); + expect(component.finalPOSTObj["colName"]).toEqual(component.name); + expect(component.finalPOSTObj["colType"]).toEqual(""); + expect(component.finalPOSTObj["colspan"]).toEqual(component.colspan); + expect(component.finalPOSTObj["dataType"]).toEqual(component.dataType); + expect(component.finalPOSTObj["depeondsOnForField"]).toEqual(component.dependsOnFormFields); + expect(component.finalPOSTObj["displayAlignment"]).toEqual(component.displayAlignment); + expect(component.finalPOSTObj["displayHeaderAlignment"]).toEqual(component.displayHeaderAlignment); + expect(component.finalPOSTObj["displayName"]).toEqual(component.displayName); + expect(component.finalPOSTObj["displayTotal"]).toEqual(component.displayTotal); + expect(component.finalPOSTObj["displayWidth"]).toEqual(10); + expect(component.finalPOSTObj["displayWidthInPixel"]).toEqual(component.displayWidthInPixel); + //expect(component.finalPOSTObj[""]).toEqual(); + expect(component.finalPOSTObj["drilldownParams"]).toEqual(component.drilldownParams); + expect(component.finalPOSTObj["drilldownType"]).toEqual(""); + expect(component.finalPOSTObj["drilldownURL"]).toEqual(component.drilldownURL); + expect(component.finalPOSTObj["errorMessage"]).toEqual(""); + expect(component.finalPOSTObj["errorStackTrace"]).toEqual(""); + expect(component.finalPOSTObj["groupByPos"]).toEqual(component.groupByPos); + expect(component.finalPOSTObj["hideRepeatedKey"]).toEqual(component.hideRepeatedValues); + expect(component.finalPOSTObj["indentation"]).toEqual(component.indentation); + expect(component.finalPOSTObj["level"]).toEqual(component.multiGroupColumnLevel); + expect(component.finalPOSTObj["noWrap"]).toEqual("Y"); + expect(component.finalPOSTObj["sortable"]).toEqual(component.sortable); + expect(component.finalPOSTObj["subTotalCustomText"]).toEqual(component.displayTotal); + expect(component.finalPOSTObj["visible"]).toEqual(component.visible); + + +}) + +it('should test if codition inside save method',()=>{ + component.showSaveColDialog=true; + let spy=spyOn(_columnService,'postColumnChanges').and.returnValue(Observable.of('you object')) + component.save(); + expect(spy).toHaveBeenCalled(); + expect(component.EditColstatus).toEqual("Success!"); + expect(component.EditColmessage).toEqual("Your change has been saved! Row definition is updated."); + expect(component.showSaveColDialog).toBe(false); + expect(component.Colclosable).toBe(true); +}) + +it('should test else codition inside save method',()=>{ + component.showSaveColDialog=true; + let spy=spyOn(_columnService,'postColumnChanges').and.returnValue(Observable.of('')) + component.save(); + expect(spy).toHaveBeenCalled(); + expect(component.EditColstatus).toEqual("Failure!"); + expect(component.EditColmessage).toEqual("Row definition could not be updated."); + expect(component.showSaveColDialog).toBe(false); + expect(component.Colclosable).toBe(true); +}) + +it('should be testing drillDownLinkPage method',()=>{ + component.showEditDrillDownPage=true + component.drillDownLinkPage(); + expect(component.showEditDrillDownPage).toEqual(false); + expect(component.showConfirmButton).toBe(true); +}) + + + }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/dashboard-report-grid/dashboard-report-grid.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/dashboard-report-grid/dashboard-report-grid.component.spec.ts index b9d63853..6d0c2946 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/dashboard-report-grid/dashboard-report-grid.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/dashboard-report-grid/dashboard-report-grid.component.spec.ts @@ -29,30 +29,22 @@ describe('DashboardReportGridComponent', () => { it('should test ngOnInit method', () => { component.ngOnInit(); - expect(component.showSpinner).toEqual(true); - expect(component.options.outerMargin).toEqual(true); - expect(component.options.outerMarginTop).toEqual(10); - expect(component.options.outerMarginRight).toEqual(10); - expect(component.options.outerMarginBottom).toEqual(700); - expect(component.options.outerMarginLeft).toEqual(10); - expect(component.options.scrollSensitivity).toEqual(10); - expect(component.options.scrollSpeed).toEqual(20); - expect(component.options.emptyCellDragMaxCols).toEqual(null); - expect(component.options.emptyCellDragMaxRows).toEqual(null); - expect(component.options.enableOccupiedCellDrop).toEqual(true); - expect(component.options.ignoreMarginInRow).toEqual(false); - expect(component.options.draggable.enabled).toEqual(true); - expect(component.options.resizable.enabled).toEqual(true); - expect(component.options.swap).toEqual(false); - expect(component.options.pushItems).toEqual(true); - expect(component.options.disablePushOnDrag).toEqual(false); - expect(component.options.disablePushOnResize).toEqual(false); - expect(component.options.pushResizeItems).toEqual(true); - expect(component.options.disableWindowResize).toEqual(true); - expect(component.options.disableWarnings).toEqual(false); - expect(component.options.scrollToNewItems).toEqual(true); - expect(component.options.enableEmptyCellDrop).toEqual(true); - expect(component.options.minCols).toEqual(2); - expect(component.options.minRows).toEqual(2); - }) + }); + + it('should test changedOption method', () => { + component.changedOptions(); + }); + + it('should test assignCopy method', () => { + component.assignCopy(); + }); + + it('should test filterItem method', () => { + component.filterItem(1); + }); + + it('should test addItem method', () => { + component.addItem(); + }); + });
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.spec.ts index 8d9003fc..88010f96 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.spec.ts @@ -7,10 +7,14 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { MatDialogModule, MatSnackBarModule } from '@angular/material'; import { CommonModule } from '@angular/common'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { FormFieldsService } from './form-fields.service'; +import 'rxjs/add/observable/of'; +import { Observable } from 'rxjs/Observable'; describe('FormFieldsComponent', () => { let component: FormFieldsComponent; let fixture: ComponentFixture<FormFieldsComponent>; + let _formfieldservice: FormFieldsService; beforeEach(async(() => { TestBed.configureTestingModule({ @@ -21,7 +25,7 @@ describe('FormFieldsComponent', () => { HttpClientTestingModule, MatDialogModule, MatSnackBarModule, - // BrowserAnimationsModule + BrowserAnimationsModule ] }) .compileComponents(); @@ -31,6 +35,7 @@ describe('FormFieldsComponent', () => { fixture = TestBed.createComponent(FormFieldsComponent); component = fixture.componentInstance; fixture.detectChanges(); + _formfieldservice=TestBed.get(FormFieldsService); }); it('should create', () => { @@ -42,28 +47,37 @@ describe('FormFieldsComponent', () => { expect(component.isFirst(2)).toBe(false); }); - it('should test isLast method', () =>{ + it('should test isLast method1 ', () =>{ component.formFieldsListObj.length = 12; expect(component.isLast(15)).toEqual(false); }); - it('should test ngDoCheck method',()=>{ + it('should test isLast method2 ', () =>{ + component.formFieldsListObj.length = 12; + expect(component.isLast(11)).toEqual(true); + }); + + it('should test ngDoCheck method for if condition',()=>{ component.sqlAsDefaultValue=true; - if(component.sqlAsDefaultValue==true){ - expect(component.showDefaultSQLOption).toBe(false); - } - else{ - expect(component.showDefaultSQLOption).toBe(true); - } + component.ngDoCheck(); + expect(component.showDefaultSQLOption).toBe(true); }); + it('should test ngDoCheck method for else condition',()=>{ + component.sqlAsDefaultValue!=true; + component.ngDoCheck(); + expect(component.showDefaultSQLOption).toBe(false); +}); + it('should test setDisplayMode method',()=>{ component.setDisplayMode("setDisplayMode"); }); it('should test edit method',()=>{ + component.fieldDefaultSQL!=null; + let spy=spyOn(_formfieldservice,'getFormFieldData').and.returnValue(Observable.of('you object')); component.edit("Id"); - + expect(spy).toHaveBeenCalled(); }) it('should test add method',()=>{ @@ -127,15 +141,15 @@ it('should test deleteFromList method',()=>{ component.deleteFromList("attrib"); }); -it('should test save method',()=>{ +it('should test save method1',()=>{ + + component.visible="YES"; + component.defaultValue=false; component.save(); expect(component.showSpinner).toBe(true); expect(component.showDialog).toBe(false); expect(component.finalPOSTObj["validationType"]).toEqual(component.validationType); - if(component.visible=="YES") expect(component.finalPOSTObj["visible"]).toBe(true); - else - expect(component.finalPOSTObj["visible"]).toBe(false); expect(component.finalPOSTObj["orderSeq"]).toEqual(component.orderSeq); expect(component.finalPOSTObj["message"]).toEqual(component.message); expect(component.finalPOSTObj["groupFormField"]).toEqual(component.groupFormField); @@ -146,13 +160,47 @@ it('should test save method',()=>{ expect(component.finalPOSTObj["errorStackTrace"]).toEqual(component.errorStackTrace); expect(component.finalPOSTObj["errorMessage"]).toEqual(component.errorMessage); expect(component.finalPOSTObj["defaultValue"]).toEqual(component.defaultValue); - if(component.defaultValue===false) - expect(component.finalPOSTObj["fieldDefaultSQL"]).toBe(null); - else - expect(component.finalPOSTObj["fieldDefalultSQL"]).toEqual(component.fieldDefaultSQL); + expect(component.finalPOSTObj["fieldDefaultSQL"]).toBe(null); expect(component.finalPOSTObj["predefinedValueList"]).toEqual(component.predefinedValueList); }); +it('should test save method for else part',()=>{ + component.visible!="YES"; + component.defaultValue!=false; + component.save(); + expect(component.finalPOSTObj["visible"]).toBe(false) + expect(component.finalPOSTObj["fieldDefalultSQL"]).toEqual(component.fieldDefaultSQL); +}) + +it('should test saveFormFieldGroups method',()=>{ + component.saveFormFieldGroups(); +}) + +it('should test openSnackBar method',()=>{ + component.openSnackBar('message','action'); +}) + +it('should test deleteGroup method',()=>{ + component.deleteGroup("string"); +}) + +it('should test deleteFormGroup method',()=>{ + component.deleteFromGroup("formgroup"); +}) + +it('should test delete method',()=>{ + component.delete("delete"); +}) + +it('should test verify method',()=>{ +component.verify("Default"); +component.verify("value"); + +}) + +// it('should test createGroup method',()=>{ +// component.openDialog() +// }) }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-report.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-report.component.spec.ts index 4d4fe269..509aa82e 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-report.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-report.component.spec.ts @@ -10,7 +10,8 @@ import { MatMenuModule } from '@angular/material'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { RunService } from '../run.service'; -import { GridsterConfig, GridsterItem, GridType } from 'angular-gridster2'; +import 'rxjs/add/observable/empty'; +import 'rxjs/add/observable/of'; describe('RunReportComponent', () => { let component: RunReportComponent; @@ -21,6 +22,9 @@ describe('RunReportComponent', () => { let change : SimpleChanges; let runService : RunService; let options1 = {}; + let dashboard; + let dashboard2; + let responseformfield = 1; beforeEach(async(() => { TestBed.configureTestingModule({ @@ -41,6 +45,7 @@ describe('RunReportComponent', () => { })); beforeEach(() => { + //dashboard = {"item":{"hasContent":{"name":"rupi","id":"check#check"}}}; fixture = TestBed.createComponent(RunReportComponent); runService = TestBed.get(RunService); component = fixture.componentInstance; @@ -48,58 +53,40 @@ describe('RunReportComponent', () => { component.displayedColumnsArr = displayedColumnsArr1; component.TriggerFFArr = trigger; component.options = options1; + component.dashboard = dashboard; + component.responseFormFieldListLength = responseformfield; fixture.detectChanges(); }); it('should compile', () => { - expect(component).toBeTruthy(); + expect(component).toBeTruthy(); }); + + it('should test the ngOnChanges second If condition', () => { + component.queryString = "test" + component.runButtonHitCnt = 1; + component.initialQueryString = "abc"; + component.initCounter = 4; + component.hitCnt = 2; + component.ngOnChanges(change); - it('should test the ngOnChanges method', () => { - fixture.detectChanges(); - component.reportMode !== "Regular"; - component.initCnt > 0; - component.TriggerFFArr.length == 0; - - component.ngOnChanges(change); - expect(component.showMoreVert).toEqual(false); - expect(component.initCnt).toEqual(1); - expect(component.showDashboardReport).toEqual(false); - expect(component.displayedRowObj).toEqual(new Array()); - expect(component.displayedColumns).toEqual(new Array()); - expect(component.formFieldList).toEqual(new Array()); - expect(component.showSpinner).toEqual(true); - expect(component.NEWdisplayedColumns).toEqual(new Array()); - expect(component.isReady).toEqual(false); - - runService.getReportDataWithFormFields("for", "test").subscribe((Response) => { - component.reportMode !== "FormField"; - expect(component.showMoreVert).toEqual(true); - expect(component.showDashboardReport).toEqual(true); - }); - - component.initialQueryString !== component.queryString; - component.initCounter > 0; - component.hitCnt !== component.runButtonHitCnt; - expect(component.runButtonHitCnt).toEqual(component.hitCnt); - expect(component.initialQueryString).toEqual(component.queryString); - }); + expect(component.runButtonHitCnt).toEqual(component.hitCnt); + expect(component.initialQueryString).toEqual("test"); + spyOn(component, 'initialProcesses'); + spyOn(component, 'afterViewInitialProcesses'); + component.initialProcesses(); + component.afterViewInitialProcesses(); - it('should test initialProcess method', () => { - component.initialProcesses(); - component.DashboardReportObj.length > 0; - expect(component.dashboard).toEqual(component.DashboardReportObj); - expect(component.hitCnt).toEqual(component.runButtonHitCnt); - expect(component.initialQueryString).toEqual(component.queryString); - expect(component.initCounter).toEqual(component.initCounter++); - }); + expect(component.initialProcesses).toHaveBeenCalled(); + expect(component.afterViewInitialProcesses).toHaveBeenCalled(); +}); it('should test afterViewInitialProcesses method', () => { + component.DashboardReportObj.length = 0; + component.reportMode = "Regular"; + component.initCnt = 0; component.afterViewInitialProcesses(); - component.DashboardReportObj.length === 0; - component.reportMode === "Regular"; - component.initCnt == 0; - + expect(component.showMoreVert).toEqual(false); expect(component.displayedColumnsArr).toEqual(new Array()); expect(component.displayedRowObj).toEqual(new Array()); @@ -118,18 +105,50 @@ describe('RunReportComponent', () => { expect(component.stackTrace).toEqual("test"[stcktrace]); expect(component.error).toEqual(true); expect(component.showSpinner).toEqual(false); - }); + it('should test linkToReport', () => { + component.linkToReport("test", "abc"); + }) + + it('should test linkToFeedback', () => { + component.linkToFeedback("test", "abc"); + }) + + it('should test linkToMail', () => { + component.linkToMail("test"); + }) + it('should test openOptions method', () => { component.openOptions(); expect(component.openOptionsFlag).toEqual(component.openOptionsFlag); }); + it('should test downloadReportExcel method', () => { + component.downloadReportExcel(); + }); + it('should test applyFilter method', () => { let filterValue = "test" component.applyFilter(filterValue); expect(component.dataSource.filter).toEqual(filterValue.trim().toLowerCase()); }); + + it('should test the ngOnChanges first If condition', () => { + change = {}; + component.reportMode !== "Regular" + component.initCnt = 1; + component.TriggerFFArr.length = 0; + component.ngOnChanges(change); + expect(component.showMoreVert).toEqual(false); + expect(component.initCnt).toEqual(1); + expect(component.showDashboardReport).toEqual(false); + expect(component.displayedRowObj).toEqual(new Array()); + expect(component.displayedColumns).toEqual(new Array()); + expect(component.formFieldList).toEqual(new Array()); + expect(component.showSpinner).toEqual(true); + expect(component.NEWdisplayedColumns).toEqual(new Array()); + expect(component.isReady).toEqual(false); + }); }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/header-tabs-component/header-tabs.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/header-tabs-component/header-tabs.component.spec.ts index da392424..d8166076 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/header-tabs-component/header-tabs.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/header-tabs-component/header-tabs.component.spec.ts @@ -4,10 +4,12 @@ import { HeaderTabsComponent } from './header-tabs.component'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { RouterTestingModule } from '@angular/router/testing'; +import { CommonModule } from '@angular/common'; describe('MainComponentComponent', () => { let component: HeaderTabsComponent; let fixture: ComponentFixture<HeaderTabsComponent>; + beforeEach(async(() => { TestBed.configureTestingModule({ @@ -22,9 +24,51 @@ describe('MainComponentComponent', () => { fixture = TestBed.createComponent(HeaderTabsComponent); component = fixture.componentInstance; fixture.detectChanges(); + }); it('should create', () => { expect(component).toBeTruthy(); }); + + + it('should test if condition in ngOnInit method',()=>{ + component.reportId = "" + component.reportMode="" + component.ngOnInit(); + expect(component.finalReportId).toEqual("-1"); + expect(component.repMode).toEqual("Create"); + expect(component.reportId).toEqual("-1"); + expect(component.reportMode).toEqual("Create"); + }); + + it('should test else condition in ngOnInit method',()=>{ + component.reportId="Indrijeet"; + component.reportMode="kumar"; + component.ngOnInit(); + expect(component.finalReportId).toEqual(component.reportId); + }); + + it('should test if condition in ngAfterViewInit method',()=>{ + component.reportId = ""; + component.reportMode=""; + component.ngAfterViewInit(); + expect(component.finalReportId).toEqual("-1"); + expect(component.repMode).toEqual("Create"); + expect(component.reportId).toEqual("-1"); + expect(component.reportMode).toEqual("Create"); + }); + + it('should test else condition in ngAfterViewInit method',()=>{ + component.reportId="indrijeet"; + component.reportMode="kumar"; + component.ngAfterViewInit(); + expect(component.finalReportId).toEqual(component.reportId) + expect(component.repMode).toEqual(component.reportMode) + }); + + it('should test ngDoCheck method',()=>{ + component.ngDoCheck(); + console.log(component.tabChanged); + }) }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.html index 1b3b37be..1629ac24 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.html +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.html @@ -63,12 +63,12 @@ <td mat-cell *matCellDef="let rowData" > {{rowData.email}} </td> </ng-container> - <ng-container matColumnDef="OrgUserId"> + <ng-container matColumnDef="orgUserId"> <th mat-header-cell *matHeaderCellDef id="heading4"> {{userHeaders[4]}} </th> <td mat-cell *matCellDef="let rowData" > {{rowData.orgUserId}} </td> </ng-container> - <ng-container matColumnDef="Manager OrgUserId"> + <ng-container matColumnDef="orgManagerUserId"> <th mat-header-cell *matHeaderCellDef id="heading4"> {{userHeaders[5]}} </th> <td mat-cell *matCellDef="let rowData" > {{rowData.orgManagerUserId}} </td> </ng-container> diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.ts index 7bebd04c..a02158b6 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.ts @@ -56,7 +56,7 @@ export class SearchComponent implements OnInit { response: any; result: any; profileList:any; - userHeaders = ["User ID","Last Name","First Name","Email","ORG ID","Manager ORG ID","Edit","Active?"]; + userHeaders = ["User ID","Last Name","First Name","Email","orgUserId","orgManagerUserId","Edit","Active?"]; constructor(public profileservice:ProfileService, public ngbModal: NgbModal) { } dataSource: MatTableDataSource<[]>; diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.html index 846dae52..ff319de4 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.html +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.html @@ -59,17 +59,12 @@ </div> </div> <div class="form-row"> - <label for="textinputID-3a">Organization User ID</label> <a style="cursor: hand;" target="_new" - href="http://webphone.att.com/cgi-bin/webphones.pl?id={{profile.orgUserId}}">wephone</a> - + <label for="textinputID-3a">Organization User ID</label> <input [(ngModel)]="profile.orgUserId" type="text" name="orgUserId" class="form-control" id="orgUserId" style="width: 100%;" disabled="true"> </div> <div class="form-row"> <label for="textinputID-3a">Organization Manager ID</label> - <a style="cursor: hand;" target="_new" - href="http://webphone.att.com/cgi-bin/webphones.pl?id={{profile.orgManagerUserId}}">wephone</a> - <input [(ngModel)]="profile.orgManagerUserId" type="text" name="orgManagerUserId" class="form-control" id="orgManagerUserId" style=" width: 59%;" disabled="true"> diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/user/user.service.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/user/user.service.ts index 4c4a01c3..44d9e5ef 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/user/user.service.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/user/user.service.ts @@ -20,7 +20,7 @@ data; observable; getFunctionalMenuStaticDetailSession2(){ - return this.http.get(environment.getFunctionalMenuStaticDetail,{ withCredentials: true }) + return this.http.get(environment.getTopMenu,{ withCredentials: true }) .subscribe((results: Object) => { this.user = new User(results); }); @@ -30,7 +30,7 @@ getFunctionalMenuStaticDetailSession2(){ public getFunctionalMenuStaticDetailSession(): Observable<User> { return this.http - .get(environment.getFunctionalMenuStaticDetail,{ withCredentials: true }) + .get(environment.getTopMenu,{ withCredentials: true }) .map(response => { return new User(response); }) @@ -43,7 +43,7 @@ getFunctionalMenuStaticDetailSession1() { } else if (this.observable) { return this.observable; } else { - this.observable = this.http.get(environment.getFunctionalMenuStaticDetail, { + this.observable = this.http.get(environment.getTopMenu, { withCredentials: true, observe: 'response' }) diff --git a/ecomp-sdk/epsdk-logger/src/main/java/org/onap/portalsdk/core/logging/logic/EELFLoggerDelegate.java b/ecomp-sdk/epsdk-logger/src/main/java/org/onap/portalsdk/core/logging/logic/EELFLoggerDelegate.java index a67b979b..5632534a 100644 --- a/ecomp-sdk/epsdk-logger/src/main/java/org/onap/portalsdk/core/logging/logic/EELFLoggerDelegate.java +++ b/ecomp-sdk/epsdk-logger/src/main/java/org/onap/portalsdk/core/logging/logic/EELFLoggerDelegate.java @@ -66,10 +66,13 @@ import com.att.eelf.configuration.SLF4jWrapper; public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { - public static final EELFLogger errorLogger = EELFManager.getInstance().getErrorLogger(); + //public static final EELFLogger errorLogger = EELFManager.getInstance().getErrorLogger(); + public static final EELFLogger errorLogger = EELFManager.getInstance().getLogger("EELFError"); + public static final EELFLogger metricsLogger = EELFManager.getInstance().getLogger("EELFMetrics"); + public static final EELFLogger auditLogger = EELFManager.getInstance().getLogger("EELFAudit"); public static final EELFLogger applicationLogger = EELFManager.getInstance().getApplicationLogger(); - public static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - public static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + //public static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + //public static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); public static final EELFLogger debugLogger = EELFManager.getInstance().getDebugLogger(); // DateTime Format according to the ECOMP Application Logging Guidelines. private static final SimpleDateFormat ecompLogDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); @@ -520,4 +523,4 @@ public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger { } return ""; } -}
\ No newline at end of file +} diff --git a/ecomp-sdk/portalsdk-tag-lib-test-app/package-lock.json b/ecomp-sdk/portalsdk-tag-lib-test-app/package-lock.json index 780e6580..60daa997 100644 --- a/ecomp-sdk/portalsdk-tag-lib-test-app/package-lock.json +++ b/ecomp-sdk/portalsdk-tag-lib-test-app/package-lock.json @@ -8235,7 +8235,7 @@ }, "portalsdk-tag-lib": { "version": "file:portalsdk-tag-lib-0.0.1.tgz", - "integrity": "sha512-iqr81BSaZSC+ids5jIxDwvspC/yEKMX2PlTMoFAy0mvI/tcAeKUvSKgsFadqPRHBPbTbtXFDDpn22ZxgTtyc9Q==", + "integrity": "sha512-V4X0GIkX63rPFDQjgVbj53GVoyahtyeQX2m3owcJYmYBCvB/e36ncX5/wluFpiR8mp4eD+b+HDSBBVkq7bYqsg==", "requires": { "tslib": "^1.9.0" } diff --git a/ecomp-sdk/portalsdk-tag-lib-test-app/portalsdk-tag-lib-0.0.1.tgz b/ecomp-sdk/portalsdk-tag-lib-test-app/portalsdk-tag-lib-0.0.1.tgz Binary files differindex 0bf78906..3b1c200f 100644 --- a/ecomp-sdk/portalsdk-tag-lib-test-app/portalsdk-tag-lib-0.0.1.tgz +++ b/ecomp-sdk/portalsdk-tag-lib-test-app/portalsdk-tag-lib-0.0.1.tgz diff --git a/ecomp-sdk/portalsdk-tag-library/projects/portalsdk-tag-lib/src/lib/rdp/rdp-data-table/rdp-data-table.component.html b/ecomp-sdk/portalsdk-tag-library/projects/portalsdk-tag-lib/src/lib/rdp/rdp-data-table/rdp-data-table.component.html index 4f98abd5..e5d08e51 100644 --- a/ecomp-sdk/portalsdk-tag-library/projects/portalsdk-tag-lib/src/lib/rdp/rdp-data-table/rdp-data-table.component.html +++ b/ecomp-sdk/portalsdk-tag-library/projects/portalsdk-tag-lib/src/lib/rdp/rdp-data-table/rdp-data-table.component.html @@ -51,8 +51,8 @@ <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> </table> <!-- </rdp-scroll-container> --> - <div *ngIf="isPaginationRequired"> + <div [hidden]="!isPaginationRequired"> <mat-paginator [length]="totalRowsCount" #paginator [pageSizeOptions]="[5, 10, 25, 100]" [pageSize]="pageSize" - (page)="pageEvent = $event; onPaginationChange($event)"></mat-paginator> + ></mat-paginator> </div> </div>
\ No newline at end of file diff --git a/ecomp-sdk/portalsdk-tag-library/projects/portalsdk-tag-lib/src/lib/rdp/rdp-data-table/rdp-data-table.component.ts b/ecomp-sdk/portalsdk-tag-library/projects/portalsdk-tag-lib/src/lib/rdp/rdp-data-table/rdp-data-table.component.ts index b833c6fb..954d0941 100644 --- a/ecomp-sdk/portalsdk-tag-library/projects/portalsdk-tag-lib/src/lib/rdp/rdp-data-table/rdp-data-table.component.ts +++ b/ecomp-sdk/portalsdk-tag-library/projects/portalsdk-tag-lib/src/lib/rdp/rdp-data-table/rdp-data-table.component.ts @@ -59,7 +59,14 @@ export class RdpDataTableComponent<T> implements OnChanges, AfterViewInit, OnIni @Input() settings: any; @ViewChild(MatSort) sort: MatSort; - @ViewChild(MatPaginator) paginator: MatPaginator; + //@ViewChild(MatPaginator) paginator: MatPaginator; + private paginator: MatPaginator; + + @ViewChild(MatPaginator) set matPaginator(mp: MatPaginator) { + this.paginator = mp; + this.setData(this.data); + } + @ViewChild(MatTable) table: MatTable<T>; @ViewChild('input') input: ElementRef; @@ -74,7 +81,7 @@ export class RdpDataTableComponent<T> implements OnChanges, AfterViewInit, OnIni isEditMode: boolean; isSearchEnabled: boolean; isServerSidePaginationEnabled: boolean = false; - showAddButton: boolean = true; + showAddButton: boolean = false; result : any; totalRowsCount: any; showSpinner: boolean; @@ -88,7 +95,7 @@ export class RdpDataTableComponent<T> implements OnChanges, AfterViewInit, OnIni } ngAfterViewInit() { - if(this.isServerSidePaginationEnabled){ + if(this.settings && this.settings.isServerSidePaginationEnabled && this.data){ this.sort.sortChange.subscribe(() => this.paginator.pageIndex = 0); @@ -108,12 +115,16 @@ export class RdpDataTableComponent<T> implements OnChanges, AfterViewInit, OnIni tap(() => this.loadData(this.paginator.pageIndex, this.paginator.pageSize)) ).subscribe(); } - - this.dataSource.paginator = this.paginator; - this.dataSource.sort = this.sort; + if(this.data) { + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; + } } ngOnChanges() { + if(this.data) { + this.setData(this.data); + } if (this.settings) { console.log("Table setting Objects >>>>", this.settings); @@ -134,6 +145,8 @@ export class RdpDataTableComponent<T> implements OnChanges, AfterViewInit, OnIni if (this.settings.isReadOnly) { this.showAddButton = false; + }else{ + this.showAddButton = true; } if (this.settings.isTableSearchEnabled) { @@ -159,7 +172,7 @@ export class RdpDataTableComponent<T> implements OnChanges, AfterViewInit, OnIni } setData(data) { - if(this.settings.isServerSidePaginationEnabled){ + if(this.settings && this.settings.isServerSidePaginationEnabled){ console.log("Server side pagination is enabled"); this.dataSource = new RDPDataSource(); this.dataSource.loadData(this.settings.applicationService,'', this.sort.active, this.sort.direction, 0, this.settings.paginationsSize); @@ -170,6 +183,8 @@ export class RdpDataTableComponent<T> implements OnChanges, AfterViewInit, OnIni console.log("Server side pagination is not enabled"); if (Array.isArray(data)) { this.dataSource.data = data; + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; this.totalRowsCount = data.length; } } |