From d5b177c009f0199ac50e4aaaec862b87b611fe91 Mon Sep 17 00:00:00 2001 From: PaulRC-ioet Date: Tue, 10 Nov 2020 12:05:27 -0500 Subject: [PATCH 01/13] fix: #563 fix bug cannot creat project --- .../customer-list.component.spec.ts | 13 ++++- .../customer-list/customer-list.component.ts | 52 +++++++++++-------- .../create-project-type.component.spec.ts | 13 +++-- .../create-project-type.component.ts | 4 +- .../create-project.component.spec.ts | 13 +++-- .../create-project.component.ts | 1 + 6 files changed, 62 insertions(+), 34 deletions(-) diff --git a/src/app/modules/customer-management/components/customer-info/components/customer-list/customer-list.component.spec.ts b/src/app/modules/customer-management/components/customer-info/components/customer-list/customer-list.component.spec.ts index 7f073ad7b..88851ae6b 100644 --- a/src/app/modules/customer-management/components/customer-info/components/customer-list/customer-list.component.spec.ts +++ b/src/app/modules/customer-management/components/customer-info/components/customer-list/customer-list.component.spec.ts @@ -12,6 +12,8 @@ import { } from 'src/app/modules/customer-management/store'; import { DataTablesModule } from 'angular-datatables'; import { ActionsSubject } from '@ngrx/store'; +import { ResetProjectToEdit } from '../../../projects/components/store/project.actions'; +import { ResetProjectTypeToEdit } from '../../../projects-type/store'; describe('CustomerTableListComponent', () => { let component: CustomerListComponent; @@ -65,6 +67,15 @@ describe('CustomerTableListComponent', () => { expect(component.showCustomerForm).toBeTruthy(); }); + it('onClick edit, dispatch clean Forms in project and project type', () => { + spyOn(store, 'dispatch'); + + component.editCustomer('1'); + + expect(store.dispatch).toHaveBeenCalledWith(new ResetProjectToEdit()); + expect(store.dispatch).toHaveBeenCalledWith(new ResetProjectTypeToEdit()); + }); + it('onClick delete, dispatch DeleteCustomer', () => { spyOn(store, 'dispatch'); component.idToDelete = '1'; @@ -121,7 +132,7 @@ describe('CustomerTableListComponent', () => { const actionSubject = TestBed.inject(ActionsSubject); const action = { type: CustomerManagementActionTypes.LOAD_CUSTOMERS_SUCCESS, - payload: state.data + payload: state.data, }; spyOn(component.dtElement.dtInstance, 'then'); diff --git a/src/app/modules/customer-management/components/customer-info/components/customer-list/customer-list.component.ts b/src/app/modules/customer-management/components/customer-info/components/customer-list/customer-list.component.ts index 1430da445..ed46b8b94 100644 --- a/src/app/modules/customer-management/components/customer-info/components/customer-list/customer-list.component.ts +++ b/src/app/modules/customer-management/components/customer-info/components/customer-list/customer-list.component.ts @@ -9,22 +9,23 @@ import { CustomerManagementActionTypes, DeleteCustomer, LoadCustomers, - SetCustomerToEdit + SetCustomerToEdit, } from './../../../../store/customer-management.actions'; +import { ResetProjectToEdit } from '../../../projects/components/store/project.actions'; +import { ResetProjectTypeToEdit } from '../../../projects-type/store'; @Component({ selector: 'app-customer-list', templateUrl: './customer-list.component.html', styleUrls: ['./customer-list.component.scss'], }) export class CustomerListComponent implements OnInit, OnDestroy, AfterViewInit { - @Input() showCustomerForm: boolean; @Output() changeValueShowCustomerForm = new EventEmitter(); @Input() customers: Customer[] = []; dtOptions: any = {}; dtTrigger: Subject = new Subject(); - @ViewChild(DataTableDirective, {static: false}) + @ViewChild(DataTableDirective, { static: false }) dtElement: DataTableDirective; loadCustomersSubscription: Subscription; changeCustomerSubscription: Subscription; @@ -40,33 +41,32 @@ export class CustomerListComponent implements OnInit, OnDestroy, AfterViewInit { ngOnInit(): void { this.dtOptions = { scrollY: '290px', - paging: false + paging: false, }; - this.loadCustomersSubscription = this.actionsSubject$.pipe( - filter((action: any) => ( - action.type === CustomerManagementActionTypes.LOAD_CUSTOMERS_SUCCESS - ) - ) - ).subscribe((action) => { - this.customers = action.payload; - this.rerenderDataTable(); - }); + this.loadCustomersSubscription = this.actionsSubject$ + .pipe(filter((action: any) => action.type === CustomerManagementActionTypes.LOAD_CUSTOMERS_SUCCESS)) + .subscribe((action) => { + this.customers = action.payload; + this.rerenderDataTable(); + }); - this.changeCustomerSubscription = this.actionsSubject$.pipe( - filter((action: any) => ( - action.type === CustomerManagementActionTypes.DELETE_CUSTOMER_SUCCESS || - action.type === CustomerManagementActionTypes.UPDATE_CUSTOMER_SUCCESS || - action.type === CustomerManagementActionTypes.CREATE_CUSTOMER_SUCCESS + this.changeCustomerSubscription = this.actionsSubject$ + .pipe( + filter( + (action: any) => + action.type === CustomerManagementActionTypes.DELETE_CUSTOMER_SUCCESS || + action.type === CustomerManagementActionTypes.UPDATE_CUSTOMER_SUCCESS || + action.type === CustomerManagementActionTypes.CREATE_CUSTOMER_SUCCESS ) ) - ).subscribe((action) => { - this.store.dispatch(new LoadCustomers()); - this.showCustomerForm = false; - }); + .subscribe((action) => { + this.store.dispatch(new LoadCustomers()); + this.showCustomerForm = false; + }); this.store.dispatch(new LoadCustomers()); } - ngAfterViewInit(): void { + ngAfterViewInit(): void { this.rerenderDataTable(); } @@ -80,6 +80,12 @@ export class CustomerListComponent implements OnInit, OnDestroy, AfterViewInit { this.showCustomerForm = true; this.changeValueShowCustomerForm.emit(this.showCustomerForm); this.store.dispatch(new SetCustomerToEdit(customerId)); + this.resetProjectFieldsToEdit(); + } + + private resetProjectFieldsToEdit() { + this.store.dispatch(new ResetProjectToEdit()); + this.store.dispatch(new ResetProjectTypeToEdit()); } deleteCustomer() { diff --git a/src/app/modules/customer-management/components/projects-type/components/create-project-type/create-project-type.component.spec.ts b/src/app/modules/customer-management/components/projects-type/components/create-project-type/create-project-type.component.spec.ts index b85058f16..d504ee667 100644 --- a/src/app/modules/customer-management/components/projects-type/components/create-project-type/create-project-type.component.spec.ts +++ b/src/app/modules/customer-management/components/projects-type/components/create-project-type/create-project-type.component.spec.ts @@ -41,10 +41,7 @@ describe('InputProjectTypeComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [CreateProjectTypeComponent], - providers: [ - FormBuilder, - provideMockStore({ initialState: state }) - ], + providers: [FormBuilder, provideMockStore({ initialState: state })], }).compileComponents(); })); @@ -153,6 +150,14 @@ describe('InputProjectTypeComponent', () => { expect(component.projectTypeForm.setValue).toHaveBeenCalledWith(projectTypeDataForm); }); + it('shoud reset Project Type Form before set the data to Edit', () => { + spyOn(component.projectTypeForm, 'reset'); + + component.setDataToUpdate(projectType); + + expect(component.projectTypeForm.reset).toHaveBeenCalled(); + }); + it('should dispatch a ResetProjectTypeToEdit action', () => { spyOn(store, 'dispatch'); diff --git a/src/app/modules/customer-management/components/projects-type/components/create-project-type/create-project-type.component.ts b/src/app/modules/customer-management/components/projects-type/components/create-project-type/create-project-type.component.ts index b5e3221c8..21b6b18c2 100644 --- a/src/app/modules/customer-management/components/projects-type/components/create-project-type/create-project-type.component.ts +++ b/src/app/modules/customer-management/components/projects-type/components/create-project-type/create-project-type.component.ts @@ -19,8 +19,7 @@ export class CreateProjectTypeComponent implements OnInit, OnDestroy { customerId: string; getCustomerIdSubscription: Subscription; - constructor(private formBuilder: FormBuilder, - private store: Store) { + constructor(private formBuilder: FormBuilder, private store: Store) { this.projectTypeForm = this.formBuilder.group({ name: ['', Validators.required], description: [''], @@ -47,6 +46,7 @@ export class CreateProjectTypeComponent implements OnInit, OnDestroy { } setDataToUpdate(projectTypeData: ProjectType) { + this.projectTypeForm.reset(); if (projectTypeData) { this.projectTypeForm.setValue({ name: projectTypeData.name, diff --git a/src/app/modules/customer-management/components/projects/components/create-project/create-project.component.spec.ts b/src/app/modules/customer-management/components/projects/components/create-project/create-project.component.spec.ts index 6e8880c4c..fa7325496 100644 --- a/src/app/modules/customer-management/components/projects/components/create-project/create-project.component.spec.ts +++ b/src/app/modules/customer-management/components/projects/components/create-project/create-project.component.spec.ts @@ -38,10 +38,7 @@ describe('InputProjectComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [CreateProjectComponent], - providers: [ - FormBuilder, - provideMockStore({ initialState: state }) - ], + providers: [FormBuilder, provideMockStore({ initialState: state })], }).compileComponents(); })); @@ -233,6 +230,14 @@ describe('InputProjectComponent', () => { expect(component.projectForm.setValue).toHaveBeenCalledWith(projectForm); }); + it('shoud reset Project Form before set the data to Edit', () => { + spyOn(component.projectForm, 'reset'); + + component.setDataToUpdate(project); + + expect(component.projectForm.reset).toHaveBeenCalled(); + }); + it('should dispatch a ResetActivityToEdit action', () => { spyOn(store, 'dispatch'); diff --git a/src/app/modules/customer-management/components/projects/components/create-project/create-project.component.ts b/src/app/modules/customer-management/components/projects/components/create-project/create-project.component.ts index fa303e86d..57a07574b 100644 --- a/src/app/modules/customer-management/components/projects/components/create-project/create-project.component.ts +++ b/src/app/modules/customer-management/components/projects/components/create-project/create-project.component.ts @@ -86,6 +86,7 @@ export class CreateProjectComponent implements OnInit, OnDestroy { } setDataToUpdate(projectData: Project) { + this.projectForm.reset(); if (projectData) { this.projectForm.setValue({ name: projectData.name, From fd525f83e4bb9b9903e83aa9b7b78e7f275f8661 Mon Sep 17 00:00:00 2001 From: Sandro Castillo Date: Fri, 13 Nov 2020 16:39:20 -0500 Subject: [PATCH 02/13] Update issue templates issue ui template --- .github/ISSUE_TEMPLATE/bug_report.md | 38 ++++++++++++++++++++++++++++ .github/ISSUE_TEMPLATE/ui-task.md | 26 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/ui-task.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000..f3d5c415e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,38 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: bug +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/ui-task.md b/.github/ISSUE_TEMPLATE/ui-task.md new file mode 100644 index 000000000..4d9647698 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/ui-task.md @@ -0,0 +1,26 @@ +--- +name: UI task +about: new tasks of UI +title: UI TASK +labels: '' +assignees: '' + +--- + +** Purpose** +A clear and concise description of this new task or feature + +** Purpose** +A clear and concise description of what you want to happen. + +**Design link** +Links of design in invisionApp, mockflow, zeiplin, etc + +**Criteria of acceptance** +List the parameters that the task must meet to be approved. +- parameter one +- parameter two +- ... + +**Note** +Information adicional, for example links of documentation to work in xz task. From 62a79bc3a17f1d91a774b3a468bed0dffcc25ce5 Mon Sep 17 00:00:00 2001 From: Sandro Castillo Date: Fri, 13 Nov 2020 17:27:08 -0500 Subject: [PATCH 03/13] fix: #573 format document --- .github/ISSUE_TEMPLATE/ui-task.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/ui-task.md b/.github/ISSUE_TEMPLATE/ui-task.md index 4d9647698..9d89aacad 100644 --- a/.github/ISSUE_TEMPLATE/ui-task.md +++ b/.github/ISSUE_TEMPLATE/ui-task.md @@ -4,7 +4,6 @@ about: new tasks of UI title: UI TASK labels: '' assignees: '' - --- ** Purpose** @@ -18,9 +17,10 @@ Links of design in invisionApp, mockflow, zeiplin, etc **Criteria of acceptance** List the parameters that the task must meet to be approved. + - parameter one - parameter two - ... **Note** -Information adicional, for example links of documentation to work in xz task. +Information adicional, for example links of documentation to work in xz task. From 6648ce22b4366675581db7b97d4ff58b5001f4f1 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Sat, 14 Nov 2020 14:17:18 +0000 Subject: [PATCH 04/13] chore(release): 1.29.1 [skip ci]nn --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index e74f1322e..e694d77ef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "time-tracker", - "version": "1.29.0", + "version": "1.29.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 4ae72601b..56a02b53e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "time-tracker", - "version": "1.29.0", + "version": "1.29.1", "scripts": { "preinstall": "npx npm-force-resolutions", "ng": "ng", From 1b8bfd19493ddcc241de35db26a2beebe2f0c1a7 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Sat, 14 Nov 2020 14:24:01 +0000 Subject: [PATCH 05/13] chore(release): 1.29.2 [skip ci]nn --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index e694d77ef..3f18b97ee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "time-tracker", - "version": "1.29.1", + "version": "1.29.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 56a02b53e..9f2e6faa2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "time-tracker", - "version": "1.29.1", + "version": "1.29.2", "scripts": { "preinstall": "npx npm-force-resolutions", "ng": "ng", From c64bd3417f32437a04fb69a344f2d93149ad69bc Mon Sep 17 00:00:00 2001 From: Sandro Castillo Date: Mon, 16 Nov 2020 13:41:14 -0500 Subject: [PATCH 06/13] feat: #571 technology report --- src/app/app-routing.module.ts | 2 + src/app/app.module.ts | 7 +- .../components/sidebar/sidebar.component.ts | 1 + .../technology-report/components/.gitkeep | 0 .../technology-report-table.component.html | 34 +++++ .../technology-report-table.component.scss | 28 ++++ .../technology-report-table.component.spec.ts | 83 ++++++++++++ .../technology-report-table.component.ts | 94 ++++++++++++++ .../time-range-form.component.html | 26 ++++ .../time-range-form.component.ts | 49 +++++++ .../time-range.component.spec.ts | 121 ++++++++++++++++++ .../pages/technology-report.component.html | 1 + .../technology-report.component.spect.ts | 0 .../pages/technology-report.component.ts | 9 ++ .../technology-report.component.scss | 0 15 files changed, 454 insertions(+), 1 deletion(-) create mode 100644 src/app/modules/technology-report/components/.gitkeep create mode 100644 src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.html create mode 100644 src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.scss create mode 100644 src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.spec.ts create mode 100644 src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.ts create mode 100644 src/app/modules/technology-report/components/time-range-form/time-range-form.component.html create mode 100644 src/app/modules/technology-report/components/time-range-form/time-range-form.component.ts create mode 100644 src/app/modules/technology-report/components/time-range-form/time-range.component.spec.ts create mode 100644 src/app/modules/technology-report/pages/technology-report.component.html create mode 100644 src/app/modules/technology-report/pages/technology-report.component.spect.ts create mode 100644 src/app/modules/technology-report/pages/technology-report.component.ts create mode 100644 src/app/modules/technology-report/technology-report.component.scss diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index b14250d03..5a6cc4cf1 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -10,6 +10,7 @@ import { ActivitiesManagementComponent } from './modules/activities-management/p import { HomeComponent } from './modules/home/home.component'; import { LoginComponent } from './modules/login/login.component'; import { CustomerComponent } from './modules/customer-management/pages/customer.component'; +import { TechnologyReportComponent } from './modules/technology-report/pages/technology-report.component'; const routes: Routes = [ { @@ -22,6 +23,7 @@ const routes: Routes = [ { path: 'time-entries', component: TimeEntriesComponent }, { path: 'activities-management', component: ActivitiesManagementComponent }, { path: 'customers-management', canActivate: [AdminGuard], component: CustomerComponent }, + { path: 'technology-report', canActivate: [AdminGuard], component: TechnologyReportComponent}, { path: '', pathMatch: 'full', redirectTo: 'time-clock' }, ], }, diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 881f80186..8b3c24b2f 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -68,6 +68,9 @@ import { TimeRangeFormComponent } from './modules/reports/components/time-range- import { TimeEntriesTableComponent } from './modules/reports/components/time-entries-table/time-entries-table.component'; import { DialogComponent } from './modules/shared/components/dialog/dialog.component'; import { LoadingBarComponent } from './modules/shared/components/loading-bar/loading-bar.component'; +// tslint:disable-next-line: max-line-length +import { TechnologyReportTableComponent } from './modules/technology-report/components/technology-report-table/technology-report-table.component'; +import { TechnologyReportComponent } from './modules/technology-report/pages/technology-report.component'; const maskConfig: Partial = { validation: false, @@ -115,7 +118,9 @@ const maskConfig: Partial = { TimeRangeFormComponent, TimeEntriesTableComponent, DialogComponent, - LoadingBarComponent + LoadingBarComponent, + TechnologyReportComponent, + TechnologyReportTableComponent ], imports: [ NgxMaskModule.forRoot(maskConfig), diff --git a/src/app/modules/shared/components/sidebar/sidebar.component.ts b/src/app/modules/shared/components/sidebar/sidebar.component.ts index f95a3215f..4076b27a2 100644 --- a/src/app/modules/shared/components/sidebar/sidebar.component.ts +++ b/src/app/modules/shared/components/sidebar/sidebar.component.ts @@ -45,6 +45,7 @@ export class SidebarComponent implements OnInit { {route: '/reports', icon: 'fas fa-chart-pie', text: 'Reports', active: false}, {route: '/activities-management', icon: 'fas fa-file-alt', text: 'Activities', active: false}, {route: '/customers-management', icon: 'fas fa-user', text: 'Customers', active: false}, + {route: '/technology-report', icon: 'fas fa-user', text: 'Technology Report', active: false}, ]; } else { this.itemsSidebar = [ diff --git a/src/app/modules/technology-report/components/.gitkeep b/src/app/modules/technology-report/components/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.html b/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.html new file mode 100644 index 000000000..3aeeb3841 --- /dev/null +++ b/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.html @@ -0,0 +1,34 @@ +
+
+ + + + + + + + + + + + + + + + +
User emailTechnologyTime spend
{{ entry.owner_email }}{{ entry.technologies }} + {{ entry.start_date | date: 'MM/dd/yyyy' }} +
+
+
diff --git a/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.scss b/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.scss new file mode 100644 index 000000000..8246f2e3b --- /dev/null +++ b/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.scss @@ -0,0 +1,28 @@ +.col{ + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + font-size: small; +} +.x-sm-col{ + width: 5em; + max-width: 7em; +} + +.sm-col{ + width: 6em; + max-width: 8em; +} + +.md-col{ + width: 9em; +} + +.lg-col{ + width: 12em; + overflow: hidden; + white-space: normal; +} +.hidden-col{ + display: none; +} diff --git a/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.spec.ts b/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.spec.ts new file mode 100644 index 000000000..0b1f8c57e --- /dev/null +++ b/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.spec.ts @@ -0,0 +1,83 @@ +// import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +// import { MockStore, provideMockStore } from '@ngrx/store/testing'; +// import { Entry } from 'src/app/modules/shared/models'; +// import { SubstractDatePipe } from 'src/app/modules/shared/pipes/substract-date/substract-date.pipe'; +// import { getReportDataSource } from 'src/app/modules/time-clock/store/entry.selectors'; +// import { EntryState } from '../../../time-clock/store/entry.reducer'; +// import { TimeEntriesTableComponent } from './time-entries-table.component'; + +// describe('Reports Page', () => { +// describe('TimeEntriesTableComponent', () => { +// let component: TimeEntriesTableComponent; +// let fixture: ComponentFixture; +// let store: MockStore; +// let getReportDataSourceSelectorMock; +// const timeEntry: Entry = { +// id: '123', +// start_date: new Date(), +// end_date: new Date(), +// activity_id: '123', +// technologies: ['react', 'redux'], +// description: 'any comment', +// uri: 'custom uri', +// project_id: '123', +// project_name: 'Time-Tracker' +// }; + +// const state: EntryState = { +// active: timeEntry, +// isLoading: false, +// message: '', +// createError: false, +// updateError: false, +// timeEntriesSummary: null, +// timeEntriesDataSource: { +// data: [timeEntry], +// isLoading: false +// }, +// reportDataSource: { +// data: [timeEntry], +// isLoading: false +// } +// }; + +// beforeEach(async(() => { +// TestBed.configureTestingModule({ +// imports: [], +// declarations: [TimeEntriesTableComponent, SubstractDatePipe], +// providers: [provideMockStore({ initialState: state })], +// }).compileComponents(); +// store = TestBed.inject(MockStore); + +// })); + +// beforeEach(async(() => { +// fixture = TestBed.createComponent(TimeEntriesTableComponent); +// component = fixture.componentInstance; +// store.setState(state); +// getReportDataSourceSelectorMock = store.overrideSelector(getReportDataSource, state.reportDataSource); +// fixture.detectChanges(); +// })); + +// it('component should be created', async () => { +// expect(component).toBeTruthy(); +// }); + +// it('on success load time entries, the report should be populated', () => { +// component.reportDataSource$.subscribe(ds => { +// expect(ds.data).toEqual(state.reportDataSource.data); +// }); +// }); + +// it('after the component is initialized it should initialize the table', () => { +// spyOn(component.dtTrigger, 'next'); +// component.ngAfterViewInit(); + +// expect(component.dtTrigger.next).toHaveBeenCalled(); +// }); + +// afterEach(() => { +// fixture.destroy(); +// }); +// }); +// }); diff --git a/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.ts b/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.ts new file mode 100644 index 000000000..fd7b4b0e5 --- /dev/null +++ b/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.ts @@ -0,0 +1,94 @@ +import { formatDate } from '@angular/common'; +import { AfterViewInit, Component, OnDestroy, OnInit, ViewChild } from '@angular/core'; +import { select, Store } from '@ngrx/store'; +import { DataTableDirective } from 'angular-datatables'; +import * as moment from 'moment'; +import { Observable, Subject } from 'rxjs'; +import { Entry } from 'src/app/modules/shared/models'; +import { DataSource } from 'src/app/modules/shared/models/data-source.model'; + +import { EntryState } from '../../../time-clock/store/entry.reducer'; +import { getReportDataSource } from '../../../time-clock/store/entry.selectors'; + +@Component({ + selector: 'app-technology-report-table', + templateUrl: './technology-report-table.component.html', + styleUrls: ['./technology-report-table.component.scss'] +}) +export class TechnologyReportTableComponent implements OnInit, OnDestroy, AfterViewInit { + dtOptions: any = { + scrollY: '600px', + paging: false, + dom: 'Bfrtip', + buttons: [ + { + extend: 'colvis', + columns: ':not(.hidden-col)', + + }, + 'print', + { + extend: 'excel', + exportOptions: { + format: { + body: (data, row, column, node) => { + return column === 3 ? + moment.duration(data).asHours().toFixed(4).slice(0, -1) : + data; + } + } + }, + text: 'Excel', + filename: `time-entries-${formatDate(new Date(), 'MM_dd_yyyy-HH_mm', 'en')}` + }, + { + extend: 'csv', + exportOptions: { + format: { + body: (data, row, column, node) => { + return column === 3 ? + moment.duration(data).asHours().toFixed(4).slice(0, -1) : + data; + } + } + }, + text: 'CSV', + filename: `time-entries-${formatDate(new Date(), 'MM_dd_yyyy-HH_mm', 'en')}` + } + ] + }; + dtTrigger: Subject = new Subject(); + @ViewChild(DataTableDirective, { static: false }) + dtElement: DataTableDirective; + isLoading$: Observable; + reportDataSource$: Observable>; + + constructor(private store: Store) { + this.reportDataSource$ = this.store.pipe(select(getReportDataSource)); + } + + ngOnInit(): void { + this.reportDataSource$.subscribe((ds) => { + this.rerenderDataTable(); + }); + } + + ngAfterViewInit(): void { + this.rerenderDataTable(); + } + + ngOnDestroy(): void { + this.dtTrigger.unsubscribe(); + } + + private rerenderDataTable(): void { + if (this.dtElement && this.dtElement.dtInstance) { + this.dtElement.dtInstance.then((dtInstance: DataTables.Api) => { + dtInstance.destroy(); + this.dtTrigger.next(); + }); + } else { + this.dtTrigger.next(); + } + } +} diff --git a/src/app/modules/technology-report/components/time-range-form/time-range-form.component.html b/src/app/modules/technology-report/components/time-range-form/time-range-form.component.html new file mode 100644 index 000000000..83a8ab8fe --- /dev/null +++ b/src/app/modules/technology-report/components/time-range-form/time-range-form.component.html @@ -0,0 +1,26 @@ +
+ +
+ +
+ +
+ + +
+ +
+ +
+ +
+
+
diff --git a/src/app/modules/technology-report/components/time-range-form/time-range-form.component.ts b/src/app/modules/technology-report/components/time-range-form/time-range-form.component.ts new file mode 100644 index 000000000..2785b7e19 --- /dev/null +++ b/src/app/modules/technology-report/components/time-range-form/time-range-form.component.ts @@ -0,0 +1,49 @@ +import { ToastrService } from 'ngx-toastr'; +import { formatDate } from '@angular/common'; +import { Component, OnInit } from '@angular/core'; +import { FormControl, FormGroup } from '@angular/forms'; +import * as entryActions from '../../../time-clock/store/entry.actions'; +import {Store} from '@ngrx/store'; +import {EntryState} from '../../../time-clock/store/entry.reducer'; +import * as moment from 'moment'; + +@Component({ + selector: 'app-time-range-form', + templateUrl: './time-range-form.component.html', +}) +export class TimeRangeFormComponent implements OnInit { + public reportForm: FormGroup; + private startDate = new FormControl(''); + private endDate = new FormControl(''); + + constructor(private store: Store, private toastrService: ToastrService) { + this.reportForm = new FormGroup({ + startDate: this.startDate, + endDate: this.endDate + }); + } + ngOnInit(): void { + this.setInitialDataOnScreen(); + } + + setInitialDataOnScreen() { + this.reportForm.setValue({ + startDate: formatDate(moment().startOf('week').toString(), 'yyyy-MM-dd', 'en'), + endDate: formatDate(moment().endOf('week').toString(), 'yyyy-MM-dd', 'en') + }); + this.onSubmit(); + } + + onSubmit() { + const endDate = moment(this.endDate.value).endOf('day'); + const startDate = moment(this.startDate.value).startOf('day'); + if (endDate.isBefore(startDate)) { + this.toastrService.error('The end date should be after the start date'); + } else { + this.store.dispatch(new entryActions.LoadEntriesByTimeRange({ + start_date: moment(this.startDate.value).startOf('day'), + end_date: moment(this.endDate.value).endOf('day'), + })); + } + } +} diff --git a/src/app/modules/technology-report/components/time-range-form/time-range.component.spec.ts b/src/app/modules/technology-report/components/time-range-form/time-range.component.spec.ts new file mode 100644 index 000000000..42c708e0b --- /dev/null +++ b/src/app/modules/technology-report/components/time-range-form/time-range.component.spec.ts @@ -0,0 +1,121 @@ +import { ToastrService, IndividualConfig } from 'ngx-toastr'; +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { MockStore, provideMockStore } from '@ngrx/store/testing'; +import { TimeRangeFormComponent } from './time-range-form.component'; +import { EntryState } from '../../../time-clock/store/entry.reducer'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { InputDateComponent } from '../../../shared/components/input-date/input-date.component'; +import * as entryActions from '../../../time-clock/store/entry.actions'; +import * as moment from 'moment'; + +describe('Reports Page', () => { + describe('TimeRangeFormComponent', () => { + let component: TimeRangeFormComponent; + let fixture: ComponentFixture; + let store: MockStore; + const toastrServiceStub = { + error: (message?: string, title?: string, override?: Partial) => { } + }; + + const timeEntry = { + id: '123', + start_date: new Date(), + end_date: new Date(), + activity_id: '123', + technologies: ['react', 'redux'], + comments: 'any comment', + uri: 'custom uri', + project_id: '123' + }; + + const state = { + active: timeEntry, + entryList: [timeEntry], + isLoading: false, + message: '', + createError: false, + updateError: false, + timeEntriesSummary: null, + entriesForReport: [timeEntry], + }; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [FormsModule, ReactiveFormsModule], + declarations: [TimeRangeFormComponent, InputDateComponent], + providers: [ + provideMockStore({ initialState: state }), + { provide: ToastrService, useValue: toastrServiceStub } + ], + }).compileComponents(); + store = TestBed.inject(MockStore); + + })); + + beforeEach(() => { + fixture = TestBed.createComponent(TimeRangeFormComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('component should be created', () => { + expect(component).toBeTruthy(); + }); + + it('LoadEntriesByTimeRange action is triggered when start date is before end date', () => { + const yesterday = moment(new Date()).subtract(1, 'days'); + const today = moment(new Date()); + spyOn(store, 'dispatch'); + component.reportForm.controls.startDate.setValue(yesterday); + component.reportForm.controls.endDate.setValue(today); + + component.onSubmit(); + + expect(store.dispatch).toHaveBeenCalledWith(new entryActions.LoadEntriesByTimeRange({ + start_date: yesterday.startOf('day'), + end_date: today.endOf('day') + })); + }); + + it('setInitialDataOnScreen on ngOnInit', () => { + spyOn(component, 'setInitialDataOnScreen'); + + component.ngOnInit(); + + expect(component.setInitialDataOnScreen).toHaveBeenCalled(); + }); + + it('shows an error when the end date is before the start date', () => { + spyOn(toastrServiceStub, 'error'); + const yesterday = moment(new Date()).subtract(1, 'days'); + const today = moment(new Date()); + spyOn(store, 'dispatch'); + component.reportForm.controls.startDate.setValue(today); + component.reportForm.controls.endDate.setValue(yesterday); + + component.onSubmit(); + + expect(toastrServiceStub.error).toHaveBeenCalled(); + }); + + it('setInitialDataOnScreen sets dates in form', () => { + spyOn(component.reportForm, 'setValue'); + + component.setInitialDataOnScreen(); + + expect(component.reportForm.setValue).toHaveBeenCalled(); + }); + + it('triggers onSubmit to set initial data', () => { + spyOn(component, 'onSubmit'); + + component.setInitialDataOnScreen(); + + expect(component.onSubmit).toHaveBeenCalled(); + }); + + afterEach(() => { + fixture.destroy(); + }); + }); +}); diff --git a/src/app/modules/technology-report/pages/technology-report.component.html b/src/app/modules/technology-report/pages/technology-report.component.html new file mode 100644 index 000000000..8469e66b2 --- /dev/null +++ b/src/app/modules/technology-report/pages/technology-report.component.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/app/modules/technology-report/pages/technology-report.component.spect.ts b/src/app/modules/technology-report/pages/technology-report.component.spect.ts new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/modules/technology-report/pages/technology-report.component.ts b/src/app/modules/technology-report/pages/technology-report.component.ts new file mode 100644 index 000000000..21e6f0183 --- /dev/null +++ b/src/app/modules/technology-report/pages/technology-report.component.ts @@ -0,0 +1,9 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-technology-report', + templateUrl: './technology-report.component.html', +// styleUrls: ['./technology-report.component.scss'] +}) +export class TechnologyReportComponent { +} diff --git a/src/app/modules/technology-report/technology-report.component.scss b/src/app/modules/technology-report/technology-report.component.scss new file mode 100644 index 000000000..e69de29bb From 1c648dc7bcb3303c5b34f54baef38a3c7df70974 Mon Sep 17 00:00:00 2001 From: Sandro Castillo Date: Mon, 16 Nov 2020 16:20:36 -0500 Subject: [PATCH 07/13] feat: #571 technology report - move componente TimeTange to shared --- .../time-range-form/time-range-form.component.html | 0 .../time-range-form/time-range-form.component.ts | 5 +++-- .../time-range-form/time-range.component.spec.ts | 6 +++--- .../pages/technology-report.component.html | 1 + 4 files changed, 7 insertions(+), 5 deletions(-) rename src/app/modules/{technology-report/components => shared}/time-range-form/time-range-form.component.html (100%) rename src/app/modules/{technology-report/components => shared}/time-range-form/time-range-form.component.ts (91%) rename src/app/modules/{technology-report/components => shared}/time-range-form/time-range.component.spec.ts (93%) diff --git a/src/app/modules/technology-report/components/time-range-form/time-range-form.component.html b/src/app/modules/shared/time-range-form/time-range-form.component.html similarity index 100% rename from src/app/modules/technology-report/components/time-range-form/time-range-form.component.html rename to src/app/modules/shared/time-range-form/time-range-form.component.html diff --git a/src/app/modules/technology-report/components/time-range-form/time-range-form.component.ts b/src/app/modules/shared/time-range-form/time-range-form.component.ts similarity index 91% rename from src/app/modules/technology-report/components/time-range-form/time-range-form.component.ts rename to src/app/modules/shared/time-range-form/time-range-form.component.ts index 2785b7e19..870f862f4 100644 --- a/src/app/modules/technology-report/components/time-range-form/time-range-form.component.ts +++ b/src/app/modules/shared/time-range-form/time-range-form.component.ts @@ -2,9 +2,10 @@ import { ToastrService } from 'ngx-toastr'; import { formatDate } from '@angular/common'; import { Component, OnInit } from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; -import * as entryActions from '../../../time-clock/store/entry.actions'; +import * as entryActions from '../../time-clock/store/entry.actions'; + import {Store} from '@ngrx/store'; -import {EntryState} from '../../../time-clock/store/entry.reducer'; +import {EntryState} from '../../time-clock/store/entry.reducer'; import * as moment from 'moment'; @Component({ diff --git a/src/app/modules/technology-report/components/time-range-form/time-range.component.spec.ts b/src/app/modules/shared/time-range-form/time-range.component.spec.ts similarity index 93% rename from src/app/modules/technology-report/components/time-range-form/time-range.component.spec.ts rename to src/app/modules/shared/time-range-form/time-range.component.spec.ts index 42c708e0b..9d51c11e4 100644 --- a/src/app/modules/technology-report/components/time-range-form/time-range.component.spec.ts +++ b/src/app/modules/shared/time-range-form/time-range.component.spec.ts @@ -2,10 +2,10 @@ import { ToastrService, IndividualConfig } from 'ngx-toastr'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { MockStore, provideMockStore } from '@ngrx/store/testing'; import { TimeRangeFormComponent } from './time-range-form.component'; -import { EntryState } from '../../../time-clock/store/entry.reducer'; +import { EntryState } from '../../time-clock/store/entry.reducer'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { InputDateComponent } from '../../../shared/components/input-date/input-date.component'; -import * as entryActions from '../../../time-clock/store/entry.actions'; +import { InputDateComponent } from '../../shared/components/input-date/input-date.component'; +import * as entryActions from '../../time-clock/store/entry.actions'; import * as moment from 'moment'; describe('Reports Page', () => { diff --git a/src/app/modules/technology-report/pages/technology-report.component.html b/src/app/modules/technology-report/pages/technology-report.component.html index 8469e66b2..e3531671d 100644 --- a/src/app/modules/technology-report/pages/technology-report.component.html +++ b/src/app/modules/technology-report/pages/technology-report.component.html @@ -1 +1,2 @@ + \ No newline at end of file From 2d3a6efcdfd4e2e0023df4024a9674067a162ac0 Mon Sep 17 00:00:00 2001 From: Sandro Castillo Date: Mon, 16 Nov 2020 17:27:21 -0500 Subject: [PATCH 08/13] feat: #571 technology report - test create component --- src/app/app.module.ts | 4 +- .../sidebar/sidebar.component.spec.ts | 2 +- .../technology-report-table.component.spec.ts | 140 +++++++++--------- 3 files changed, 70 insertions(+), 76 deletions(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 8b3c24b2f..65f5bf76b 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -3,7 +3,7 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { ToastrModule } from 'ngx-toastr'; import { CommonModule, DatePipe } from '@angular/common'; import { BrowserModule } from '@angular/platform-browser'; -import { NgModule } from '@angular/core'; +import { NgModule, Component } from '@angular/core'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http'; import { DataTablesModule } from 'angular-datatables'; @@ -120,7 +120,7 @@ const maskConfig: Partial = { DialogComponent, LoadingBarComponent, TechnologyReportComponent, - TechnologyReportTableComponent + TechnologyReportTableComponent, ], imports: [ NgxMaskModule.forRoot(maskConfig), diff --git a/src/app/modules/shared/components/sidebar/sidebar.component.spec.ts b/src/app/modules/shared/components/sidebar/sidebar.component.spec.ts index e53196ded..d6303868c 100644 --- a/src/app/modules/shared/components/sidebar/sidebar.component.spec.ts +++ b/src/app/modules/shared/components/sidebar/sidebar.component.spec.ts @@ -56,7 +56,7 @@ describe('SidebarComponent', () => { component.getSidebarItems(); const menuItems = component.itemsSidebar; - expect(menuItems.length).toBe(5); + expect(menuItems.length).toBe(6); }); it('non admin users have two menu items', () => { diff --git a/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.spec.ts b/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.spec.ts index 0b1f8c57e..11b44d441 100644 --- a/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.spec.ts +++ b/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.spec.ts @@ -1,83 +1,77 @@ -// import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -// import { MockStore, provideMockStore } from '@ngrx/store/testing'; -// import { Entry } from 'src/app/modules/shared/models'; -// import { SubstractDatePipe } from 'src/app/modules/shared/pipes/substract-date/substract-date.pipe'; -// import { getReportDataSource } from 'src/app/modules/time-clock/store/entry.selectors'; -// import { EntryState } from '../../../time-clock/store/entry.reducer'; -// import { TimeEntriesTableComponent } from './time-entries-table.component'; +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { MockStore, provideMockStore } from '@ngrx/store/testing'; +import { Entry } from 'src/app/modules/shared/models'; +import { SubstractDatePipe } from 'src/app/modules/shared/pipes/substract-date/substract-date.pipe'; +import { getReportDataSource } from 'src/app/modules/time-clock/store/entry.selectors'; +import { EntryState } from '../../../time-clock/store/entry.reducer'; +import { TechnologyReportTableComponent } from './technology-report-table.component'; -// describe('Reports Page', () => { -// describe('TimeEntriesTableComponent', () => { -// let component: TimeEntriesTableComponent; -// let fixture: ComponentFixture; -// let store: MockStore; -// let getReportDataSourceSelectorMock; -// const timeEntry: Entry = { -// id: '123', -// start_date: new Date(), -// end_date: new Date(), -// activity_id: '123', -// technologies: ['react', 'redux'], -// description: 'any comment', -// uri: 'custom uri', -// project_id: '123', -// project_name: 'Time-Tracker' -// }; +describe('Reports Page', () => { + describe('TimeEntriesTableComponent', () => { + let component: TechnologyReportTableComponent; + let fixture: ComponentFixture; + let store: MockStore; + let getReportDataSourceSelectorMock; + const timeEntry: Entry = { + start_date: new Date(), + end_date: new Date(), + technologies: ['react', 'redux'], + }; -// const state: EntryState = { -// active: timeEntry, -// isLoading: false, -// message: '', -// createError: false, -// updateError: false, -// timeEntriesSummary: null, -// timeEntriesDataSource: { -// data: [timeEntry], -// isLoading: false -// }, -// reportDataSource: { -// data: [timeEntry], -// isLoading: false -// } -// }; + const state: EntryState = { + active: timeEntry, + isLoading: false, + message: '', + createError: false, + updateError: false, + timeEntriesSummary: null, + timeEntriesDataSource: { + data: [timeEntry], + isLoading: false + }, + reportDataSource: { + data: [timeEntry], + isLoading: false + } + }; -// beforeEach(async(() => { -// TestBed.configureTestingModule({ -// imports: [], -// declarations: [TimeEntriesTableComponent, SubstractDatePipe], -// providers: [provideMockStore({ initialState: state })], -// }).compileComponents(); -// store = TestBed.inject(MockStore); + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [], + declarations: [TechnologyReportTableComponent, SubstractDatePipe], + providers: [provideMockStore({ initialState: state })], + }).compileComponents(); + store = TestBed.inject(MockStore); -// })); + })); -// beforeEach(async(() => { -// fixture = TestBed.createComponent(TimeEntriesTableComponent); -// component = fixture.componentInstance; -// store.setState(state); -// getReportDataSourceSelectorMock = store.overrideSelector(getReportDataSource, state.reportDataSource); -// fixture.detectChanges(); -// })); + beforeEach(async(() => { + fixture = TestBed.createComponent(TechnologyReportTableComponent); + component = fixture.componentInstance; + store.setState(state); + getReportDataSourceSelectorMock = store.overrideSelector(getReportDataSource, state.reportDataSource); + fixture.detectChanges(); + })); -// it('component should be created', async () => { -// expect(component).toBeTruthy(); -// }); + fit('component should be created', async () => { + expect(component).toBeTruthy(); + }); -// it('on success load time entries, the report should be populated', () => { -// component.reportDataSource$.subscribe(ds => { -// expect(ds.data).toEqual(state.reportDataSource.data); -// }); -// }); + // it('on success load time entries, the report should be populated', () => { + // component.reportDataSource$.subscribe(ds => { + // expect(ds.data).toEqual(state.reportDataSource.data); + // }); + // }); -// it('after the component is initialized it should initialize the table', () => { -// spyOn(component.dtTrigger, 'next'); -// component.ngAfterViewInit(); + // it('after the component is initialized it should initialize the table', () => { + // spyOn(component.dtTrigger, 'next'); + // component.ngAfterViewInit(); -// expect(component.dtTrigger.next).toHaveBeenCalled(); -// }); + // expect(component.dtTrigger.next).toHaveBeenCalled(); + // }); -// afterEach(() => { -// fixture.destroy(); -// }); -// }); -// }); + afterEach(() => { + fixture.destroy(); + }); + }); +}); From 1e3ceeacd6f5f93382c5b4acc433cc0445af8fd7 Mon Sep 17 00:00:00 2001 From: Sandro Castillo Date: Tue, 17 Nov 2020 17:45:08 -0500 Subject: [PATCH 09/13] feat: #571 mock data --- angular.json | 4 +- package-lock.json | 82 +++++++++++++------ package.json | 6 +- .../technology-report-table/data.json | 27 ++++++ .../technology-report-table.component.html | 4 +- .../technology-report-table.component.ts | 3 +- 6 files changed, 97 insertions(+), 29 deletions(-) create mode 100644 src/app/modules/technology-report/components/technology-report-table/data.json diff --git a/angular.json b/angular.json index 592152e88..5add0a5ba 100644 --- a/angular.json +++ b/angular.json @@ -25,6 +25,7 @@ ], "styles": [ "node_modules/datatables.net-dt/css/jquery.dataTables.css", + "node_modules/datatables.net-responsive-dt/css/responsive.dataTables.css", "./node_modules/bootstrap/dist/css/bootstrap.min.css", "src/styles.scss", "node_modules/ngx-toastr/toastr.css", @@ -39,7 +40,8 @@ "node_modules/datatables.net-buttons/js/buttons.colVis.js", "node_modules/datatables.net-buttons/js/buttons.flash.js", "node_modules/datatables.net-buttons/js/buttons.html5.js", - "node_modules/datatables.net-buttons/js/buttons.print.js" + "node_modules/datatables.net-buttons/js/buttons.print.js", + "node_modules/datatables.net-responsive/js/dataTables.responsive.js" ] }, "configurations": { diff --git a/package-lock.json b/package-lock.json index 3f18b97ee..f760ca3c0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4605,6 +4605,16 @@ "integrity": "sha512-1Yj8h9Q+QDF5FzhMs/c9+6UntbD5MkRfRwac8DoEm9ZfUBZ7tZ55YcGVAzEe4bXsdQHEk+s9S5wsOKVdZrw0tQ==", "dev": true }, + "bindings": { + "version": "1.5.0", + "resolved": "https://registry.npm.taobao.org/bindings/download/bindings-1.5.0.tgz", + "integrity": "sha1-EDU8npRTNLwFEabZCzj7x8nFBN8=", + "dev": true, + "optional": true, + "requires": { + "file-uri-to-path": "1.0.0" + } + }, "bl": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/bl/-/bl-4.0.3.tgz", @@ -5944,15 +5954,6 @@ "p-try": "^2.0.0" } }, - "serialize-javascript": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-3.1.0.tgz", - "integrity": "sha512-JIJT1DGiWmIKhzRsG91aS6Ze4sFUrYbltlkg2onR5OrnNM02Kl/hnY/T4FN2omvyeBbQmMJv+K4cPOpGzOTFBg==", - "dev": true, - "requires": { - "randombytes": "^2.1.0" - } - }, "ssri": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/ssri/-/ssri-8.0.0.tgz", @@ -6448,6 +6449,25 @@ "jquery": ">=1.7" } }, + "datatables.net-responsive": { + "version": "2.2.6", + "resolved": "https://registry.npm.taobao.org/datatables.net-responsive/download/datatables.net-responsive-2.2.6.tgz", + "integrity": "sha1-dKSsDadoHrQnO401nxmO8t7ylx4=", + "requires": { + "datatables.net": "^1.10.15", + "jquery": ">=1.7" + } + }, + "datatables.net-responsive-dt": { + "version": "2.2.6", + "resolved": "https://registry.npm.taobao.org/datatables.net-responsive-dt/download/datatables.net-responsive-dt-2.2.6.tgz", + "integrity": "sha1-kbkI3w+AWg59s5vPokXMD+uP9I8=", + "requires": { + "datatables.net-dt": "^1.10.15", + "datatables.net-responsive": "2.2.6", + "jquery": ">=1.7" + } + }, "date-format": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/date-format/-/date-format-3.0.0.tgz", @@ -7702,6 +7722,13 @@ "schema-utils": "^2.6.5" } }, + "file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npm.taobao.org/file-uri-to-path/download/file-uri-to-path-1.0.0.tgz", + "integrity": "sha1-VTp7hEb/b2hDWcRF8eN6BdrMM90=", + "dev": true, + "optional": true + }, "file-url": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/file-url/-/file-url-3.0.0.tgz", @@ -18370,6 +18397,15 @@ } } }, + "serialize-javascript": { + "version": "4.0.0", + "resolved": "https://registry.npm.taobao.org/serialize-javascript/download/serialize-javascript-4.0.0.tgz?cache=0&sync_timestamp=1599742605902&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fserialize-javascript%2Fdownload%2Fserialize-javascript-4.0.0.tgz", + "integrity": "sha1-tSXhI4SJpez8Qq+sw/6Z5mb0sao=", + "dev": true, + "requires": { + "randombytes": "^2.1.0" + } + }, "serve-index": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.9.1.tgz", @@ -19844,9 +19880,9 @@ } }, "serialize-javascript": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-3.1.0.tgz", - "integrity": "sha512-JIJT1DGiWmIKhzRsG91aS6Ze4sFUrYbltlkg2onR5OrnNM02Kl/hnY/T4FN2omvyeBbQmMJv+K4cPOpGzOTFBg==", + "version": "4.0.0", + "resolved": "https://registry.npm.taobao.org/serialize-javascript/download/serialize-javascript-4.0.0.tgz?cache=0&sync_timestamp=1599742605902&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fserialize-javascript%2Fdownload%2Fserialize-javascript-4.0.0.tgz", + "integrity": "sha1-tSXhI4SJpez8Qq+sw/6Z5mb0sao=", "dev": true, "requires": { "randombytes": "^2.1.0" @@ -20719,6 +20755,7 @@ "dev": true, "optional": true, "requires": { + "bindings": "^1.5.0", "nan": "^2.12.1" } }, @@ -21039,6 +21076,15 @@ "ajv-keywords": "^3.1.0" } }, + "serialize-javascript": { + "version": "4.0.0", + "resolved": "https://registry.npm.taobao.org/serialize-javascript/download/serialize-javascript-4.0.0.tgz?cache=0&sync_timestamp=1599742605902&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fserialize-javascript%2Fdownload%2Fserialize-javascript-4.0.0.tgz", + "integrity": "sha1-tSXhI4SJpez8Qq+sw/6Z5mb0sao=", + "dev": true, + "requires": { + "randombytes": "^2.1.0" + } + }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -21071,17 +21117,6 @@ "terser": "^4.1.2", "webpack-sources": "^1.4.0", "worker-farm": "^1.7.0" - }, - "dependencies": { - "serialize-javascript": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-3.1.0.tgz", - "integrity": "sha512-JIJT1DGiWmIKhzRsG91aS6Ze4sFUrYbltlkg2onR5OrnNM02Kl/hnY/T4FN2omvyeBbQmMJv+K4cPOpGzOTFBg==", - "dev": true, - "requires": { - "randombytes": "^2.1.0" - } - } } }, "to-regex-range": { @@ -21280,6 +21315,7 @@ "dev": true, "optional": true, "requires": { + "bindings": "^1.5.0", "nan": "^2.12.1" } }, diff --git a/package.json b/package.json index 9f2e6faa2..64bb4bccb 100644 --- a/package.json +++ b/package.json @@ -21,18 +21,20 @@ "@angular/platform-browser": "~10.2.2", "@angular/platform-browser-dynamic": "~10.2.2", "@angular/router": "~10.2.2", + "@azure/app-configuration": "^1.1.0", + "@azure/identity": "^1.1.0", "@ngrx/effects": "^10.0.1", "@ngrx/store": "^10.0.1", "@ngrx/store-devtools": "^10.0.1", "@types/datatables.net-buttons": "^1.4.3", "angular-datatables": "^9.0.2", - "@azure/app-configuration": "^1.1.0", - "@azure/identity": "^1.1.0", "bootstrap": "^4.4.1", "datatables.net": "^1.10.21", "datatables.net-buttons": "^1.6.2", "datatables.net-buttons-dt": "^1.6.2", "datatables.net-dt": "^1.10.21", + "datatables.net-responsive": "^2.2.6", + "datatables.net-responsive-dt": "^2.2.6", "jquery": "^3.5.1", "jszip": "^3.4.0", "minimist": "^1.2.5", diff --git a/src/app/modules/technology-report/components/technology-report-table/data.json b/src/app/modules/technology-report/components/technology-report-table/data.json new file mode 100644 index 000000000..db47b3297 --- /dev/null +++ b/src/app/modules/technology-report/components/technology-report-table/data.json @@ -0,0 +1,27 @@ +{ + "data": [ + { + "technology": [ + { + "id": 1, + "name_technology": "Superman", + "users": [ + { + "id": 1, + "email_user": "junito@gmail.com", + "time_spent": 10, + "project": [ + { + "id": "1", + "project_name": "Time tracker", + "time_spent": "8" + } + ] + } + ], + "time_spent": 10 + } + ] + } + ] + } \ No newline at end of file diff --git a/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.html b/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.html index 3aeeb3841..bf2a50f58 100644 --- a/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.html +++ b/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.html @@ -10,8 +10,8 @@ User email - Technology - Time spend + Time spend + Technology = new Subject(); @ViewChild(DataTableDirective, { static: false }) From 8679b0144a2a965925229921c2887a48a4f0e90f Mon Sep 17 00:00:00 2001 From: Sandro Castillo Date: Tue, 17 Nov 2020 22:21:42 -0500 Subject: [PATCH 10/13] fix: #571 update async for waitForAsync --- src/app/app.component.spec.ts | 4 +- .../activity-list.component.spec.ts | 4 +- .../create-activity.component.spec.ts | 4 +- .../activities-management.component.spec.ts | 4 +- .../create-customer/create-customer.spec.ts | 4 +- .../customer-list.component.spec.ts | 4 +- ...gement-customer-projects.component.spec.ts | 4 +- .../create-project-type.component.spec.ts | 4 +- .../project-type-list.component.spec.ts | 4 +- .../create-project.component.spec.ts | 4 +- .../pages/customer.component.spec.ts | 4 +- src/app/modules/home/home.component.spec.ts | 4 +- src/app/modules/login/login.component.spec.ts | 4 +- .../time-entries-table.component.spec.ts | 6 +- .../time-range.component.spec.ts | 4 +- .../reports/pages/reports.component.spec.ts | 4 +- .../components/clock/clock.component.spec.ts | 4 +- .../details-fields.component.spec.ts | 4 +- .../dialog/dialog.component.spec.ts | 4 +- .../empty-state/empty-state.component.spec.ts | 4 +- .../input-date/input-date.component.spec.ts | 2 +- .../input-label/input-label.component.spec.ts | 6 +- .../loading-bar/loading-bar.component.spec.ts | 4 +- .../month-picker.component.spec.ts | 4 +- .../navbar/navbar.component.spec.ts | 4 +- .../search/search.component.spec.ts | 4 +- .../sidebar/sidebar.component.spec.ts | 2 +- .../technologies.component.spec.ts | 2 +- .../components/user/user.component.spec.ts | 4 +- .../time-range.component.spec.ts | 4 +- .../technology-report-table/data.json | 55 ++++++++++++------- .../technology-report-table.component.html | 14 ++--- .../technology-report-table.component.spec.ts | 6 +- .../technology-report-table.component.ts | 7 ++- .../entry-fields.component.spec.ts | 4 +- .../project-list-hover.component.spec.ts | 4 +- .../time-entries-summary.component.spec.ts | 4 +- .../pages/time-clock.component.spec.ts | 4 +- .../pages/time-entries.component.spec.ts | 12 ++-- tsconfig.json | 1 + 40 files changed, 122 insertions(+), 107 deletions(-) diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index 9b475cd88..701bf65b4 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -1,9 +1,9 @@ -import { TestBed, async } from '@angular/core/testing'; +import { TestBed, waitForAsync } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { AppComponent } from './app.component'; describe('AppComponent', () => { - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule diff --git a/src/app/modules/activities-management/components/activity-list/activity-list.component.spec.ts b/src/app/modules/activities-management/components/activity-list/activity-list.component.spec.ts index 1006dd9e6..0ebe48512 100644 --- a/src/app/modules/activities-management/components/activity-list/activity-list.component.spec.ts +++ b/src/app/modules/activities-management/components/activity-list/activity-list.component.spec.ts @@ -1,5 +1,5 @@ import { provideMockStore, MockStore } from '@ngrx/store/testing'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { allActivities } from './../../store/activity-management.selectors'; import { ActivityState } from './../../store/activity-management.reducers'; @@ -19,7 +19,7 @@ describe('ActivityListComponent', () => { activityIdToEdit: '', }; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [ActivityListComponent], providers: [provideMockStore({ initialState: state })], diff --git a/src/app/modules/activities-management/components/create-activity/create-activity.component.spec.ts b/src/app/modules/activities-management/components/create-activity/create-activity.component.spec.ts index 38f1fe8ce..7629e0c67 100644 --- a/src/app/modules/activities-management/components/create-activity/create-activity.component.spec.ts +++ b/src/app/modules/activities-management/components/create-activity/create-activity.component.spec.ts @@ -1,5 +1,5 @@ import { FormBuilder } from '@angular/forms'; -import { async, TestBed, ComponentFixture } from '@angular/core/testing'; +import { waitForAsync, TestBed, ComponentFixture } from '@angular/core/testing'; import { provideMockStore, MockStore } from '@ngrx/store/testing'; import { CreateActivityComponent } from './create-activity.component'; @@ -36,7 +36,7 @@ describe('CreateActivityComponent', () => { description: 'It is good for learning', }; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [CreateActivityComponent], providers: [FormBuilder, provideMockStore({ initialState: state })], diff --git a/src/app/modules/activities-management/pages/activities-management.component.spec.ts b/src/app/modules/activities-management/pages/activities-management.component.spec.ts index 223e7999b..92f8a918a 100644 --- a/src/app/modules/activities-management/pages/activities-management.component.spec.ts +++ b/src/app/modules/activities-management/pages/activities-management.component.spec.ts @@ -1,11 +1,11 @@ -import { async, TestBed, ComponentFixture } from '@angular/core/testing'; +import { waitForAsync, TestBed, ComponentFixture } from '@angular/core/testing'; import { ActivitiesManagementComponent } from './activities-management.component'; describe('ActivitiesManagementComponent', () => { let component: ActivitiesManagementComponent; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ imports: [], declarations: [ActivitiesManagementComponent] diff --git a/src/app/modules/customer-management/components/customer-info/components/create-customer/create-customer.spec.ts b/src/app/modules/customer-management/components/customer-info/components/create-customer/create-customer.spec.ts index 7f003f092..df28e9d44 100644 --- a/src/app/modules/customer-management/components/customer-info/components/create-customer/create-customer.spec.ts +++ b/src/app/modules/customer-management/components/customer-info/components/create-customer/create-customer.spec.ts @@ -1,6 +1,6 @@ import { LoadCustomerProjects, CleanCustomerProjects } from './../../../projects/components/store/project.actions'; import { LoadProjectTypes, CleanProjectTypes } from './../../../projects-type/store/project-type.actions'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { FormBuilder } from '@angular/forms'; import { MockStore, provideMockStore } from '@ngrx/store/testing'; @@ -27,7 +27,7 @@ describe('CreateCustomerComponent', () => { description: 'bb', }; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [CreateCustomerComponent], providers: [ diff --git a/src/app/modules/customer-management/components/customer-info/components/customer-list/customer-list.component.spec.ts b/src/app/modules/customer-management/components/customer-info/components/customer-list/customer-list.component.spec.ts index 88851ae6b..ce7548086 100644 --- a/src/app/modules/customer-management/components/customer-info/components/customer-list/customer-list.component.spec.ts +++ b/src/app/modules/customer-management/components/customer-info/components/customer-list/customer-list.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { MockStore, provideMockStore } from '@ngrx/store/testing'; import { NgxPaginationModule } from 'ngx-pagination'; @@ -29,7 +29,7 @@ describe('CustomerTableListComponent', () => { customerId: '', }; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ imports: [NgxPaginationModule, DataTablesModule], declarations: [CustomerListComponent], diff --git a/src/app/modules/customer-management/components/management-customer-projects/management-customer-projects.component.spec.ts b/src/app/modules/customer-management/components/management-customer-projects/management-customer-projects.component.spec.ts index 3a730721d..697901557 100644 --- a/src/app/modules/customer-management/components/management-customer-projects/management-customer-projects.component.spec.ts +++ b/src/app/modules/customer-management/components/management-customer-projects/management-customer-projects.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { ManagementCustomerProjectsComponent } from './management-customer-projects.component'; import { MockStore, provideMockStore } from '@ngrx/store/testing'; @@ -17,7 +17,7 @@ describe('ManagmentCustomerProjectsComponent', () => { customerId: '', }; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [ManagementCustomerProjectsComponent], providers: [ diff --git a/src/app/modules/customer-management/components/projects-type/components/create-project-type/create-project-type.component.spec.ts b/src/app/modules/customer-management/components/projects-type/components/create-project-type/create-project-type.component.spec.ts index d504ee667..10aca04b2 100644 --- a/src/app/modules/customer-management/components/projects-type/components/create-project-type/create-project-type.component.spec.ts +++ b/src/app/modules/customer-management/components/projects-type/components/create-project-type/create-project-type.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { FormBuilder } from '@angular/forms'; import { provideMockStore, MockStore } from '@ngrx/store/testing'; @@ -38,7 +38,7 @@ describe('InputProjectTypeComponent', () => { description: 'It is good for learning', }; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [CreateProjectTypeComponent], providers: [FormBuilder, provideMockStore({ initialState: state })], diff --git a/src/app/modules/customer-management/components/projects-type/components/project-type-list/project-type-list.component.spec.ts b/src/app/modules/customer-management/components/projects-type/components/project-type-list/project-type-list.component.spec.ts index dcc82f0c3..e6b23b93f 100644 --- a/src/app/modules/customer-management/components/projects-type/components/project-type-list/project-type-list.component.spec.ts +++ b/src/app/modules/customer-management/components/projects-type/components/project-type-list/project-type-list.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { provideMockStore, MockStore } from '@ngrx/store/testing'; import { NgxPaginationModule } from 'ngx-pagination'; @@ -19,7 +19,7 @@ describe('ProjectTypeTableListComponent', () => { projectTypeIdToEdit: '', }; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ imports: [NgxPaginationModule], declarations: [ProjectTypeListComponent], diff --git a/src/app/modules/customer-management/components/projects/components/create-project/create-project.component.spec.ts b/src/app/modules/customer-management/components/projects/components/create-project/create-project.component.spec.ts index fa7325496..d4789cc79 100644 --- a/src/app/modules/customer-management/components/projects/components/create-project/create-project.component.spec.ts +++ b/src/app/modules/customer-management/components/projects/components/create-project/create-project.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { MockStore, provideMockStore } from '@ngrx/store/testing'; import { FormBuilder } from '@angular/forms'; import { Subscription } from 'rxjs'; @@ -35,7 +35,7 @@ describe('InputProjectComponent', () => { project_type_id: '123', }; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [CreateProjectComponent], providers: [FormBuilder, provideMockStore({ initialState: state })], diff --git a/src/app/modules/customer-management/pages/customer.component.spec.ts b/src/app/modules/customer-management/pages/customer.component.spec.ts index 7cddc30c2..4e37ac34c 100644 --- a/src/app/modules/customer-management/pages/customer.component.spec.ts +++ b/src/app/modules/customer-management/pages/customer.component.spec.ts @@ -1,7 +1,7 @@ import { SetCustomerToEdit } from 'src/app/modules/customer-management/store'; import { provideMockStore, MockStore } from '@ngrx/store/testing'; import { Customer } from 'src/app/modules/shared/models'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { CustomerComponent } from './customer.component'; @@ -10,7 +10,7 @@ describe('CustomerComponent', () => { let fixture: ComponentFixture; let store: MockStore; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [CustomerComponent], providers: [provideMockStore({ initialState: {} })], diff --git a/src/app/modules/home/home.component.spec.ts b/src/app/modules/home/home.component.spec.ts index 86774ae21..a0ad3bf0b 100644 --- a/src/app/modules/home/home.component.spec.ts +++ b/src/app/modules/home/home.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { HomeComponent } from './home.component'; @@ -6,7 +6,7 @@ describe('HomeComponent', () => { let component: HomeComponent; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [ HomeComponent ] }) diff --git a/src/app/modules/login/login.component.spec.ts b/src/app/modules/login/login.component.spec.ts index 725dae4ce..fe41b9c44 100644 --- a/src/app/modules/login/login.component.spec.ts +++ b/src/app/modules/login/login.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed, inject } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, TestBed, inject } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { AzureAdB2CService } from '../../modules/login/services/azure.ad.b2c.service'; import { of } from 'rxjs'; @@ -20,7 +20,7 @@ describe('LoginComponent', () => { } }; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule ], declarations: [ LoginComponent ], diff --git a/src/app/modules/reports/components/time-entries-table/time-entries-table.component.spec.ts b/src/app/modules/reports/components/time-entries-table/time-entries-table.component.spec.ts index 0c516befc..b58b13050 100644 --- a/src/app/modules/reports/components/time-entries-table/time-entries-table.component.spec.ts +++ b/src/app/modules/reports/components/time-entries-table/time-entries-table.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { MockStore, provideMockStore } from '@ngrx/store/testing'; import { Entry } from 'src/app/modules/shared/models'; import { SubstractDatePipe } from 'src/app/modules/shared/pipes/substract-date/substract-date.pipe'; @@ -41,7 +41,7 @@ describe('Reports Page', () => { } }; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ imports: [], declarations: [TimeEntriesTableComponent, SubstractDatePipe], @@ -51,7 +51,7 @@ describe('Reports Page', () => { })); - beforeEach(async(() => { + beforeEach(waitForAsync(() => { fixture = TestBed.createComponent(TimeEntriesTableComponent); component = fixture.componentInstance; store.setState(state); diff --git a/src/app/modules/reports/components/time-range-form/time-range.component.spec.ts b/src/app/modules/reports/components/time-range-form/time-range.component.spec.ts index 42c708e0b..8e78d3a00 100644 --- a/src/app/modules/reports/components/time-range-form/time-range.component.spec.ts +++ b/src/app/modules/reports/components/time-range-form/time-range.component.spec.ts @@ -1,5 +1,5 @@ import { ToastrService, IndividualConfig } from 'ngx-toastr'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { MockStore, provideMockStore } from '@ngrx/store/testing'; import { TimeRangeFormComponent } from './time-range-form.component'; import { EntryState } from '../../../time-clock/store/entry.reducer'; @@ -39,7 +39,7 @@ describe('Reports Page', () => { entriesForReport: [timeEntry], }; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ imports: [FormsModule, ReactiveFormsModule], declarations: [TimeRangeFormComponent, InputDateComponent], diff --git a/src/app/modules/reports/pages/reports.component.spec.ts b/src/app/modules/reports/pages/reports.component.spec.ts index e60f52ad4..0c2da9019 100644 --- a/src/app/modules/reports/pages/reports.component.spec.ts +++ b/src/app/modules/reports/pages/reports.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { ReportsComponent } from './reports.component'; @@ -6,7 +6,7 @@ describe('ReportsComponent', () => { let component: ReportsComponent; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [ReportsComponent], }).compileComponents(); diff --git a/src/app/modules/shared/components/clock/clock.component.spec.ts b/src/app/modules/shared/components/clock/clock.component.spec.ts index 47455782f..a2ef16f41 100644 --- a/src/app/modules/shared/components/clock/clock.component.spec.ts +++ b/src/app/modules/shared/components/clock/clock.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { ClockComponent } from './clock.component'; @@ -6,7 +6,7 @@ describe('ClockComponent', () => { let component: ClockComponent; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [ ClockComponent ] }) diff --git a/src/app/modules/shared/components/details-fields/details-fields.component.spec.ts b/src/app/modules/shared/components/details-fields/details-fields.component.spec.ts index 1f343cc70..8fb37bee3 100644 --- a/src/app/modules/shared/components/details-fields/details-fields.component.spec.ts +++ b/src/app/modules/shared/components/details-fields/details-fields.component.spec.ts @@ -1,5 +1,5 @@ import { formatDate } from '@angular/common'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { ActionsSubject } from '@ngrx/store'; import { MockStore, provideMockStore } from '@ngrx/store/testing'; @@ -73,7 +73,7 @@ describe('DetailsFieldsComponent', () => { technology: '', }; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [DetailsFieldsComponent, TechnologiesComponent], providers: [ diff --git a/src/app/modules/shared/components/dialog/dialog.component.spec.ts b/src/app/modules/shared/components/dialog/dialog.component.spec.ts index c18602ec5..4a622c8f3 100644 --- a/src/app/modules/shared/components/dialog/dialog.component.spec.ts +++ b/src/app/modules/shared/components/dialog/dialog.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { DialogComponent } from './dialog.component'; @@ -6,7 +6,7 @@ describe('DialogComponent', () => { let component: DialogComponent; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [ DialogComponent ] }) diff --git a/src/app/modules/shared/components/empty-state/empty-state.component.spec.ts b/src/app/modules/shared/components/empty-state/empty-state.component.spec.ts index c5cd9ed4e..f3a00de92 100644 --- a/src/app/modules/shared/components/empty-state/empty-state.component.spec.ts +++ b/src/app/modules/shared/components/empty-state/empty-state.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { EmptyStateComponent } from './empty-state.component'; @@ -6,7 +6,7 @@ describe('EmptyStateComponent', () => { let component: EmptyStateComponent; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [ EmptyStateComponent ] }) diff --git a/src/app/modules/shared/components/input-date/input-date.component.spec.ts b/src/app/modules/shared/components/input-date/input-date.component.spec.ts index f9af5f1bc..ad08a01fb 100644 --- a/src/app/modules/shared/components/input-date/input-date.component.spec.ts +++ b/src/app/modules/shared/components/input-date/input-date.component.spec.ts @@ -6,7 +6,7 @@ describe('InputDateComponent', () => { let fixture: ComponentFixture; let input; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [InputDateComponent] }).compileComponents(); diff --git a/src/app/modules/shared/components/input-label/input-label.component.spec.ts b/src/app/modules/shared/components/input-label/input-label.component.spec.ts index 7582ed692..374587057 100644 --- a/src/app/modules/shared/components/input-label/input-label.component.spec.ts +++ b/src/app/modules/shared/components/input-label/input-label.component.spec.ts @@ -1,4 +1,4 @@ -import {async, ComponentFixture, TestBed} from '@angular/core/testing'; +import {waitForAsync, ComponentFixture, TestBed} from '@angular/core/testing'; import {InputLabelComponent} from './input-label.component'; @@ -6,7 +6,7 @@ describe('InputLabelComponent', () => { let component: InputLabelComponent; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [InputLabelComponent] }).compileComponents(); @@ -22,7 +22,7 @@ describe('InputLabelComponent', () => { expect(component).toBeTruthy(); }); - it('should insert the provided text into the component', async(() => { + it('should insert the provided text into the component', waitForAsync(() => { const anyLabelText = 'Any random label'; component.text = anyLabelText; diff --git a/src/app/modules/shared/components/loading-bar/loading-bar.component.spec.ts b/src/app/modules/shared/components/loading-bar/loading-bar.component.spec.ts index 9ee4f6d0e..1dc3c0156 100644 --- a/src/app/modules/shared/components/loading-bar/loading-bar.component.spec.ts +++ b/src/app/modules/shared/components/loading-bar/loading-bar.component.spec.ts @@ -1,11 +1,11 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { LoadingBarComponent } from './loading-bar.component'; describe('LoadingBarComponent', () => { let component: LoadingBarComponent; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [LoadingBarComponent] }).compileComponents(); diff --git a/src/app/modules/shared/components/month-picker/month-picker.component.spec.ts b/src/app/modules/shared/components/month-picker/month-picker.component.spec.ts index a81dc612c..c8d29053e 100644 --- a/src/app/modules/shared/components/month-picker/month-picker.component.spec.ts +++ b/src/app/modules/shared/components/month-picker/month-picker.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { MonthPickerComponent } from './month-picker.component'; @@ -6,7 +6,7 @@ describe('MonthPickerComponent', () => { let component: MonthPickerComponent; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [ MonthPickerComponent ] }) diff --git a/src/app/modules/shared/components/navbar/navbar.component.spec.ts b/src/app/modules/shared/components/navbar/navbar.component.spec.ts index 4e5f590eb..ca8f116c8 100644 --- a/src/app/modules/shared/components/navbar/navbar.component.spec.ts +++ b/src/app/modules/shared/components/navbar/navbar.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { NavbarComponent } from './navbar.component'; @@ -6,7 +6,7 @@ describe('NavbarComponent', () => { let component: NavbarComponent; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [ NavbarComponent ] }) diff --git a/src/app/modules/shared/components/search/search.component.spec.ts b/src/app/modules/shared/components/search/search.component.spec.ts index 6e93ca539..8c1298424 100644 --- a/src/app/modules/shared/components/search/search.component.spec.ts +++ b/src/app/modules/shared/components/search/search.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { SearchComponent } from './search.component'; @@ -6,7 +6,7 @@ describe('SearchComponent', () => { let component: SearchComponent; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [SearchComponent], }).compileComponents(); diff --git a/src/app/modules/shared/components/sidebar/sidebar.component.spec.ts b/src/app/modules/shared/components/sidebar/sidebar.component.spec.ts index d6303868c..884ef0529 100644 --- a/src/app/modules/shared/components/sidebar/sidebar.component.spec.ts +++ b/src/app/modules/shared/components/sidebar/sidebar.component.spec.ts @@ -25,7 +25,7 @@ describe('SidebarComponent', () => { } }; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [SidebarComponent], providers: [ diff --git a/src/app/modules/shared/components/technologies/technologies.component.spec.ts b/src/app/modules/shared/components/technologies/technologies.component.spec.ts index 8f9cf0de4..d4fc12835 100644 --- a/src/app/modules/shared/components/technologies/technologies.component.spec.ts +++ b/src/app/modules/shared/components/technologies/technologies.component.spec.ts @@ -20,7 +20,7 @@ describe('Technologies component', () => { } }; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [TechnologiesComponent], providers: [provideMockStore({initialState: state})], diff --git a/src/app/modules/shared/components/user/user.component.spec.ts b/src/app/modules/shared/components/user/user.component.spec.ts index 8a0bd0435..2d82a8c36 100644 --- a/src/app/modules/shared/components/user/user.component.spec.ts +++ b/src/app/modules/shared/components/user/user.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { of } from 'rxjs'; import { UserComponent } from './user.component'; import { AzureAdB2CService } from '../../../login/services/azure.ad.b2c.service'; @@ -18,7 +18,7 @@ describe('UserComponent', () => { }, }; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [UserComponent], imports: [AppRoutingModule], diff --git a/src/app/modules/shared/time-range-form/time-range.component.spec.ts b/src/app/modules/shared/time-range-form/time-range.component.spec.ts index 9d51c11e4..64e1491a7 100644 --- a/src/app/modules/shared/time-range-form/time-range.component.spec.ts +++ b/src/app/modules/shared/time-range-form/time-range.component.spec.ts @@ -1,5 +1,5 @@ import { ToastrService, IndividualConfig } from 'ngx-toastr'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { MockStore, provideMockStore } from '@ngrx/store/testing'; import { TimeRangeFormComponent } from './time-range-form.component'; import { EntryState } from '../../time-clock/store/entry.reducer'; @@ -39,7 +39,7 @@ describe('Reports Page', () => { entriesForReport: [timeEntry], }; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ imports: [FormsModule, ReactiveFormsModule], declarations: [TimeRangeFormComponent, InputDateComponent], diff --git a/src/app/modules/technology-report/components/technology-report-table/data.json b/src/app/modules/technology-report/components/technology-report-table/data.json index db47b3297..2149bfea4 100644 --- a/src/app/modules/technology-report/components/technology-report-table/data.json +++ b/src/app/modules/technology-report/components/technology-report-table/data.json @@ -1,27 +1,40 @@ -{ - "data": [ +[ + { + "id": 1, + "name_technology": "Superman", + "users": [ { - "technology": [ + "id": 1, + "email_user": "junito@gmail.com", + "time_spent": 10, + "project": [ { "id": 1, - "name_technology": "Superman", - "users": [ - { - "id": 1, - "email_user": "junito@gmail.com", - "time_spent": 10, - "project": [ - { - "id": "1", - "project_name": "Time tracker", - "time_spent": "8" - } - ] - } - ], - "time_spent": 10 + "project_name": "Time tracker", + "time_spent": 8 } ] } - ] - } \ No newline at end of file + ], + "time_spent": 10 + }, + { + "id": 2, + "name_technology": "Tor", + "users": [ + { + "id": 1, + "email_user": "junito@gmail.com", + "time_spent": 10, + "project": [ + { + "id": 1, + "project_name": "Time tracker", + "time_spent": 8 + } + ] + } + ], + "time_spent": 10 + } +] \ No newline at end of file diff --git a/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.html b/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.html index bf2a50f58..51c8f60f1 100644 --- a/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.html +++ b/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.html @@ -9,24 +9,20 @@ > - User email - Time spend Technology + Time spend - + - {{ entry.owner_email }} - {{ entry.technologies }} - - {{ entry.start_date | date: 'MM/dd/yyyy' }} - + {{ data.name_technology || '' }} + {{ data.time_spent || ''}} diff --git a/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.spec.ts b/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.spec.ts index 11b44d441..311e460fb 100644 --- a/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.spec.ts +++ b/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { MockStore, provideMockStore } from '@ngrx/store/testing'; import { Entry } from 'src/app/modules/shared/models'; import { SubstractDatePipe } from 'src/app/modules/shared/pipes/substract-date/substract-date.pipe'; @@ -35,7 +35,7 @@ describe('Reports Page', () => { } }; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ imports: [], declarations: [TechnologyReportTableComponent, SubstractDatePipe], @@ -45,7 +45,7 @@ describe('Reports Page', () => { })); - beforeEach(async(() => { + beforeEach(waitForAsync(() => { fixture = TestBed.createComponent(TechnologyReportTableComponent); component = fixture.componentInstance; store.setState(state); diff --git a/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.ts b/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.ts index 8bf78f6f4..1b5325a98 100644 --- a/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.ts +++ b/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.ts @@ -6,16 +6,18 @@ import * as moment from 'moment'; import { Observable, Subject } from 'rxjs'; import { Entry } from 'src/app/modules/shared/models'; import { DataSource } from 'src/app/modules/shared/models/data-source.model'; - import { EntryState } from '../../../time-clock/store/entry.reducer'; import { getReportDataSource } from '../../../time-clock/store/entry.selectors'; +import * as dataMock from './data.json'; @Component({ selector: 'app-technology-report-table', templateUrl: './technology-report-table.component.html', styleUrls: ['./technology-report-table.component.scss'] }) + export class TechnologyReportTableComponent implements OnInit, OnDestroy, AfterViewInit { + dtOptions: any = { scrollY: '600px', paging: false, @@ -64,14 +66,17 @@ export class TechnologyReportTableComponent implements OnInit, OnDestroy, AfterV isLoading$: Observable; reportDataSource$: Observable>; + technologies: any = (dataMock as any).default; constructor(private store: Store) { this.reportDataSource$ = this.store.pipe(select(getReportDataSource)); } + ngOnInit(): void { this.reportDataSource$.subscribe((ds) => { this.rerenderDataTable(); }); + console.log('data', dataMock); } ngAfterViewInit(): void { diff --git a/src/app/modules/time-clock/components/entry-fields/entry-fields.component.spec.ts b/src/app/modules/time-clock/components/entry-fields/entry-fields.component.spec.ts index b17db891e..f6b78b742 100644 --- a/src/app/modules/time-clock/components/entry-fields/entry-fields.component.spec.ts +++ b/src/app/modules/time-clock/components/entry-fields/entry-fields.component.spec.ts @@ -1,6 +1,6 @@ import { LoadActiveEntry, EntryActionTypes } from './../../store/entry.actions'; import { ActivityManagementActionTypes } from './../../../activities-management/store/activity-management.actions'; -import {async, ComponentFixture, TestBed} from '@angular/core/testing'; +import {waitForAsync, ComponentFixture, TestBed} from '@angular/core/testing'; import {MockStore, provideMockStore} from '@ngrx/store/testing'; import { FormsModule, ReactiveFormsModule, FormBuilder } from '@angular/forms'; @@ -70,7 +70,7 @@ describe('EntryFieldsComponent', () => { start_hour : moment().format('HH:mm:ss'), }; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [EntryFieldsComponent], providers: [ diff --git a/src/app/modules/time-clock/components/project-list-hover/project-list-hover.component.spec.ts b/src/app/modules/time-clock/components/project-list-hover/project-list-hover.component.spec.ts index 16f0ab1eb..c7dd88ef4 100644 --- a/src/app/modules/time-clock/components/project-list-hover/project-list-hover.component.spec.ts +++ b/src/app/modules/time-clock/components/project-list-hover/project-list-hover.component.spec.ts @@ -1,7 +1,7 @@ import { ToastrService, IndividualConfig } from 'ngx-toastr'; import { SwitchTimeEntry, ClockIn } from './../../store/entry.actions'; import { FormBuilder } from '@angular/forms'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { provideMockStore, MockStore } from '@ngrx/store/testing'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { AutocompleteLibModule } from 'angular-ng-autocomplete'; @@ -41,7 +41,7 @@ describe('ProjectListHoverComponent', () => { }, }; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [ProjectListHoverComponent, FilterProjectPipe], providers: [FormBuilder, provideMockStore({ initialState: state }), diff --git a/src/app/modules/time-clock/components/time-entries-summary/time-entries-summary.component.spec.ts b/src/app/modules/time-clock/components/time-entries-summary/time-entries-summary.component.spec.ts index 6b54036ed..00b5c9fab 100644 --- a/src/app/modules/time-clock/components/time-entries-summary/time-entries-summary.component.spec.ts +++ b/src/app/modules/time-clock/components/time-entries-summary/time-entries-summary.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, discardPeriodicTasks, fakeAsync, TestBed, tick } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, discardPeriodicTasks, fakeAsync, TestBed, tick } from '@angular/core/testing'; import { ActionsSubject } from '@ngrx/store'; import { MockStore, provideMockStore } from '@ngrx/store/testing'; import { interval } from 'rxjs'; @@ -50,7 +50,7 @@ describe('TimeEntriesSummaryComponent', () => { } }; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [ TimeEntriesSummaryComponent, TimeDetailsPipe ], providers: [provideMockStore({ initialState: state }), { provide: ActionsSubject, useValue: actionSub }], diff --git a/src/app/modules/time-clock/pages/time-clock.component.spec.ts b/src/app/modules/time-clock/pages/time-clock.component.spec.ts index 218d1eea1..1fa2476ee 100644 --- a/src/app/modules/time-clock/pages/time-clock.component.spec.ts +++ b/src/app/modules/time-clock/pages/time-clock.component.spec.ts @@ -1,6 +1,6 @@ import { FormBuilder } from '@angular/forms'; import { StopTimeEntryRunning, EntryActionTypes, LoadEntriesSummary } from './../store/entry.actions'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { provideMockStore, MockStore } from '@ngrx/store/testing'; import { TimeClockComponent } from './time-clock.component'; @@ -48,7 +48,7 @@ describe('TimeClockComponent', () => { }, }; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ imports: [HttpClientTestingModule], declarations: [TimeClockComponent, ProjectListHoverComponent, FilterProjectPipe, EntryFieldsComponent], diff --git a/src/app/modules/time-entries/pages/time-entries.component.spec.ts b/src/app/modules/time-entries/pages/time-entries.component.spec.ts index de526154b..a0fbce75d 100644 --- a/src/app/modules/time-entries/pages/time-entries.component.spec.ts +++ b/src/app/modules/time-entries/pages/time-entries.component.spec.ts @@ -1,5 +1,5 @@ import { AutocompleteLibModule } from 'angular-ng-autocomplete'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { MockStore, provideMockStore } from '@ngrx/store/testing'; import { ToastrService } from 'ngx-toastr'; @@ -33,7 +33,7 @@ describe('TimeEntriesComponent', () => { }, }; - beforeEach(async(() => { + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [ EmptyStateComponent, @@ -108,13 +108,13 @@ describe('TimeEntriesComponent', () => { expect(component).toBeTruthy(); }); - it('on loading the component the time entries should be loaded', async(() => { + it('on loading the component the time entries should be loaded', waitForAsync(() => { component.timeEntriesDataSource$.subscribe(ds => { expect(ds.data.length).toEqual(1); }); })); - it('Time entries data should be populated on ngOnInit()', async(() => { + it('Time entries data should be populated on ngOnInit()', waitForAsync(() => { mockEntriesSelector = store.overrideSelector(getTimeEntriesDataSource, state.timeEntriesDataSource); component.ngOnInit(); @@ -307,7 +307,7 @@ describe('TimeEntriesComponent', () => { expect(store.dispatch).toHaveBeenCalledWith(new entryActions.LoadEntries(month)); }); - it('doSave when activeTimeEntry === null', async(() => { + it('doSave when activeTimeEntry === null', waitForAsync(() => { const entryToSave = { entry: { project_id: 'project-id', @@ -347,7 +347,7 @@ describe('TimeEntriesComponent', () => { expect(store.dispatch).toHaveBeenCalledWith(new entryActions.RestartEntry(entryToSave.entry)); }); - it('should preload data of last entry when a project is selected while creating new entry ', async(() => { + it('should preload data of last entry when a project is selected while creating new entry ', waitForAsync(() => { component.entry = null; component.entryId = null; const lastEntry = { diff --git a/tsconfig.json b/tsconfig.json index 80a8e1cb8..8cc284df1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,6 +11,7 @@ "moduleResolution": "node", "importHelpers": true, "target": "es2015", + "resolveJsonModule": true, "allowSyntheticDefaultImports": false, "typeRoots": [ "node_modules/@types" From a7c8f59cf60ca1eeca53d2386293228b909923c9 Mon Sep 17 00:00:00 2001 From: Sandro Castillo Date: Thu, 19 Nov 2020 15:27:31 -0500 Subject: [PATCH 11/13] fix: #571 test coverage --- src/app/modules/reports/pages/reports.component.spec.ts | 2 +- .../shared/components/input-date/input-date.component.spec.ts | 2 +- .../modules/shared/components/sidebar/sidebar.component.spec.ts | 2 +- .../components/technologies/technologies.component.spec.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/modules/reports/pages/reports.component.spec.ts b/src/app/modules/reports/pages/reports.component.spec.ts index 0c2da9019..4a131f56e 100644 --- a/src/app/modules/reports/pages/reports.component.spec.ts +++ b/src/app/modules/reports/pages/reports.component.spec.ts @@ -23,7 +23,7 @@ describe('ReportsComponent', () => { expect(component).toBeTruthy(); }); - it('should have form and datatable components', async(() => { + it('should have form and datatable components', waitForAsync(() => { fixture.detectChanges(); const compile = fixture.debugElement.nativeElement; diff --git a/src/app/modules/shared/components/input-date/input-date.component.spec.ts b/src/app/modules/shared/components/input-date/input-date.component.spec.ts index ad08a01fb..fe0662d49 100644 --- a/src/app/modules/shared/components/input-date/input-date.component.spec.ts +++ b/src/app/modules/shared/components/input-date/input-date.component.spec.ts @@ -1,4 +1,4 @@ -import {async, ComponentFixture, fakeAsync, TestBed, tick} from '@angular/core/testing'; +import {waitForAsync, ComponentFixture, fakeAsync, TestBed, tick} from '@angular/core/testing'; import {InputDateComponent} from './input-date.component'; describe('InputDateComponent', () => { diff --git a/src/app/modules/shared/components/sidebar/sidebar.component.spec.ts b/src/app/modules/shared/components/sidebar/sidebar.component.spec.ts index 884ef0529..65c0bff28 100644 --- a/src/app/modules/shared/components/sidebar/sidebar.component.spec.ts +++ b/src/app/modules/shared/components/sidebar/sidebar.component.spec.ts @@ -1,5 +1,5 @@ import {AzureAdB2CService} from 'src/app/modules/login/services/azure.ad.b2c.service'; -import {async, ComponentFixture, TestBed} from '@angular/core/testing'; +import {waitForAsync, ComponentFixture, TestBed} from '@angular/core/testing'; import {SidebarComponent} from './sidebar.component'; import {RouterTestingModule} from '@angular/router/testing'; diff --git a/src/app/modules/shared/components/technologies/technologies.component.spec.ts b/src/app/modules/shared/components/technologies/technologies.component.spec.ts index d4fc12835..22abff7cf 100644 --- a/src/app/modules/shared/components/technologies/technologies.component.spec.ts +++ b/src/app/modules/shared/components/technologies/technologies.component.spec.ts @@ -1,4 +1,4 @@ -import {async, ComponentFixture, TestBed} from '@angular/core/testing'; +import {waitForAsync, ComponentFixture, TestBed} from '@angular/core/testing'; import {MockStore, provideMockStore} from '@ngrx/store/testing'; import {FormsModule, ReactiveFormsModule} from '@angular/forms'; From 14be74bd2d98511a33fbbc02c6512b96c2e710ea Mon Sep 17 00:00:00 2001 From: Guido Quezada Date: Thu, 19 Nov 2020 15:44:53 -0500 Subject: [PATCH 12/13] feat: #571 technology report - custom excel export --- .../technology-report-table/data.json | 54 +++++++++++++++---- .../technology-report-table.component.html | 26 +++++++-- ...echnology-report-table.component.spect.ts} | 19 +------ .../technology-report-table.component.ts | 53 +++++++++++++++++- 4 files changed, 117 insertions(+), 35 deletions(-) rename src/app/modules/technology-report/components/technology-report-table/{technology-report-table.component.spec.ts => technology-report-table.component.spect.ts} (77%) diff --git a/src/app/modules/technology-report/components/technology-report-table/data.json b/src/app/modules/technology-report/components/technology-report-table/data.json index 2149bfea4..c0504290a 100644 --- a/src/app/modules/technology-report/components/technology-report-table/data.json +++ b/src/app/modules/technology-report/components/technology-report-table/data.json @@ -1,40 +1,74 @@ [ { "id": 1, - "name_technology": "Superman", + "name_technology": "Pascal", "users": [ { "id": 1, - "email_user": "junito@gmail.com", + "email_user": "dogman@gmail.com", + "time_spent": 30, + "projects": [ + { + "id": 1, + "project_name": "Time tracker", + "time_spent": 15 + }, + { + "id": 2, + "project_name": "New Project", + "time_spent": 10 + }, + { + "id": 3, + "project_name": "Old Project", + "time_spent": 5 + } + ] + }, + { + "id": 2, + "email_user": "duckman@gmail.com", + "time_spent": 20, + "projects": [ + { + "id": 1, + "project_name": "Time tracker", + "time_spent": 20 + } + ] + }, + { + "id": 3, + "email_user": "plantgirl@gmail.com", "time_spent": 10, - "project": [ + "projects": [ { "id": 1, "project_name": "Time tracker", - "time_spent": 8 + "time_spent": 10 } ] } ], - "time_spent": 10 + "time_spent": 60 }, { "id": 2, - "name_technology": "Tor", + "name_technology": "Pascual", "users": [ { "id": 1, - "email_user": "junito@gmail.com", + "email_user": "catgirl@gmail.com", "time_spent": 10, - "project": [ + "projects": [ { "id": 1, "project_name": "Time tracker", - "time_spent": 8 + "time_spent": 10 } ] } ], "time_spent": 10 } -] \ No newline at end of file +] diff --git a/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.html b/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.html index 51c8f60f1..9956c7f05 100644 --- a/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.html +++ b/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.html @@ -9,8 +9,9 @@ > - Technology - Time spend + Technology + Time spend + - {{ data.name_technology || '' }} - {{ data.time_spent || ''}} + {{ tech.name_technology || '' }} + {{ tech.time_spent || ''}} + + +
+
+ + + + + + + + +
{{ user.email_user }}{{ user.time_spent || '' }}
{{ project.project_name }}{{ project.time_spent || '' }}
+ diff --git a/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.spec.ts b/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.spect.ts similarity index 77% rename from src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.spec.ts rename to src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.spect.ts index 311e460fb..a501aef9d 100644 --- a/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.spec.ts +++ b/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.spect.ts @@ -53,25 +53,8 @@ describe('Reports Page', () => { fixture.detectChanges(); })); - fit('component should be created', async () => { + it('component should be created', async () => { expect(component).toBeTruthy(); }); - - // it('on success load time entries, the report should be populated', () => { - // component.reportDataSource$.subscribe(ds => { - // expect(ds.data).toEqual(state.reportDataSource.data); - // }); - // }); - - // it('after the component is initialized it should initialize the table', () => { - // spyOn(component.dtTrigger, 'next'); - // component.ngAfterViewInit(); - - // expect(component.dtTrigger.next).toHaveBeenCalled(); - // }); - - afterEach(() => { - fixture.destroy(); - }); }); }); diff --git a/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.ts b/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.ts index 1b5325a98..7606196ef 100644 --- a/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.ts +++ b/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.ts @@ -40,8 +40,57 @@ export class TechnologyReportTableComponent implements OnInit, OnDestroy, AfterV } } }, + customize: (xlsx) => { + const sheet = xlsx.xl.worksheets['sheet1.xml']; + const sheetData = $('sheetData', sheet).clone(); + + $('sheetData', sheet).empty(); + let rowCount = 1; + + sheetData.children().each(function(index) { + if (index > 0) { + const row = $(this.outerHTML); + + row.attr('r', rowCount); + let colCount = 1; + + row.children().each(function() { + const cell = $(this); + let rc = cell.attr('r'); + rc = rc.replace(/\d+$/, '') + rowCount; + + cell.attr('r', rc); + if (colCount === 3) { + cell.html(''); + } + colCount++; + + }); + const rowa = row[0].outerHTML; + $('sheetData', sheet).append(rowa); + rowCount++; + + } else { + const row = $(this.outerHTML); + let colCount = 1; + + row.children().each(function() { + const cell = $(this); + if (colCount === 3) { + cell.html(''); + } + colCount++; + + }); + const rowa = row[0].outerHTML; + $('sheetData', sheet).append(rowa); + rowCount++; + + } + }); + }, text: 'Excel', - filename: `time-entries-${formatDate(new Date(), 'MM_dd_yyyy-HH_mm', 'en')}` + filename: `technologies-${formatDate(new Date(), 'MM_dd_yyyy-HH_mm', 'en')}` }, { extend: 'csv', @@ -55,7 +104,7 @@ export class TechnologyReportTableComponent implements OnInit, OnDestroy, AfterV } }, text: 'CSV', - filename: `time-entries-${formatDate(new Date(), 'MM_dd_yyyy-HH_mm', 'en')}` + filename: `technologies-${formatDate(new Date(), 'MM_dd_yyyy-HH_mm', 'en')}` } ], responsive: true From 6ef25789837702d0c4319abb31ab714c67a7167b Mon Sep 17 00:00:00 2001 From: Sandro Castillo Date: Fri, 20 Nov 2020 15:37:27 -0500 Subject: [PATCH 13/13] fix: #571 resolving comments --- .../time-range-form/time-range-form.component.ts | 5 +++-- .../details-fields/details-fields.component.spec.ts | 9 +++++---- .../details-fields/details-fields.component.ts | 5 +++-- src/app/modules/shared/models/entry.model.ts | 2 ++ .../pipes/substract-date/substract-date.pipe.ts | 6 ++++-- ...t.ts => technology-report-table.component.spec.ts} | 0 .../technology-report-table.component.ts | 2 -- .../time-range-form/time-range-form.component.html | 0 .../time-range-form/time-range-form.component.ts | 10 +++++----- .../time-range-form/time-range.component.spec.ts | 11 ++++++----- ...t.spect.ts => technology-report.component.spec.ts} | 0 .../entry-fields/entry-fields.component.spec.ts | 5 +++-- .../components/entry-fields/entry-fields.component.ts | 3 ++- src/app/modules/time-clock/store/entry.reducer.ts | 7 ++++--- src/environments/environment.ts | 2 ++ 15 files changed, 39 insertions(+), 28 deletions(-) rename src/app/modules/technology-report/components/technology-report-table/{technology-report-table.component.spect.ts => technology-report-table.component.spec.ts} (100%) rename src/app/modules/{shared => technology-report/components}/time-range-form/time-range-form.component.html (100%) rename src/app/modules/{shared => technology-report/components}/time-range-form/time-range-form.component.ts (82%) rename src/app/modules/{shared => technology-report/components}/time-range-form/time-range.component.spec.ts (91%) rename src/app/modules/technology-report/pages/{technology-report.component.spect.ts => technology-report.component.spec.ts} (100%) diff --git a/src/app/modules/reports/components/time-range-form/time-range-form.component.ts b/src/app/modules/reports/components/time-range-form/time-range-form.component.ts index 2785b7e19..87be577e0 100644 --- a/src/app/modules/reports/components/time-range-form/time-range-form.component.ts +++ b/src/app/modules/reports/components/time-range-form/time-range-form.component.ts @@ -2,6 +2,7 @@ import { ToastrService } from 'ngx-toastr'; import { formatDate } from '@angular/common'; import { Component, OnInit } from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; +import { DATE_FORMAT } from 'src/environments/environment'; import * as entryActions from '../../../time-clock/store/entry.actions'; import {Store} from '@ngrx/store'; import {EntryState} from '../../../time-clock/store/entry.reducer'; @@ -28,8 +29,8 @@ export class TimeRangeFormComponent implements OnInit { setInitialDataOnScreen() { this.reportForm.setValue({ - startDate: formatDate(moment().startOf('week').toString(), 'yyyy-MM-dd', 'en'), - endDate: formatDate(moment().endOf('week').toString(), 'yyyy-MM-dd', 'en') + startDate: formatDate(moment().startOf('week').toString(), DATE_FORMAT, 'en'), + endDate: formatDate(moment().endOf('week').toString(), DATE_FORMAT, 'en') }); this.onSubmit(); } diff --git a/src/app/modules/shared/components/details-fields/details-fields.component.spec.ts b/src/app/modules/shared/components/details-fields/details-fields.component.spec.ts index 8fb37bee3..6e60e84c0 100644 --- a/src/app/modules/shared/components/details-fields/details-fields.component.spec.ts +++ b/src/app/modules/shared/components/details-fields/details-fields.component.spec.ts @@ -18,7 +18,8 @@ import { TechnologiesComponent } from './../technologies/technologies.component' import { DetailsFieldsComponent } from './details-fields.component'; import { ProjectSelectedEvent } from './project-selected-event'; import { SaveEntryEvent } from './save-entry-event'; - +import { DATE_FORMAT } from 'src/environments/environment'; +import { DATE_FORMAT_YEAR } from 'src/environments/environment'; describe('DetailsFieldsComponent', () => { type Merged = TechnologyState & ProjectState & EntryState; @@ -66,7 +67,7 @@ describe('DetailsFieldsComponent', () => { project_name: '', activity_id: '', uri: '', - entry_date: formatDate(new Date(), 'yyyy-MM-dd', 'en'), + entry_date: formatDate(new Date(), DATE_FORMAT, 'en'), start_hour: '00:00:00', end_hour: '00:00:00', description: '', @@ -176,7 +177,7 @@ describe('DetailsFieldsComponent', () => { project_name: '', activity_id: '', uri: '', - entry_date: formatDate(new Date(), 'yyyy-MM-dd', 'en'), + entry_date: formatDate(new Date(), DATE_FORMAT, 'en'), start_hour: '00:00:00', end_hour: '00:00:00', description: '', @@ -310,7 +311,7 @@ describe('DetailsFieldsComponent', () => { it('displays error message when the date selected is in the future', () => { spyOn(toastrServiceStub, 'error'); - const futureDate = moment().add(1, 'days').format('YYYY-MM-DD'); + const futureDate = moment().add(1, 'days').format(DATE_FORMAT_YEAR); component.entryForm.setValue({ ...formValues, entry_date: futureDate }); component.onSubmit(); diff --git a/src/app/modules/shared/components/details-fields/details-fields.component.ts b/src/app/modules/shared/components/details-fields/details-fields.component.ts index 1c8e37711..1bd68ef33 100644 --- a/src/app/modules/shared/components/details-fields/details-fields.component.ts +++ b/src/app/modules/shared/components/details-fields/details-fields.component.ts @@ -17,6 +17,7 @@ import { TechnologyState } from '../../store/technology.reducers'; import { EntryActionTypes } from './../../../time-clock/store/entry.actions'; import { SaveEntryEvent } from './save-entry-event'; import { ProjectSelectedEvent } from './project-selected-event'; +import { DATE_FORMAT } from 'src/environments/environment'; type Merged = TechnologyState & ProjectState & ActivityState & EntryState; @@ -129,7 +130,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit { project_id: this.entryToEdit.project_id, activity_id: this.entryToEdit.activity_id, description: this.entryToEdit.description, - entry_date: this.entryToEdit.start_date ? formatDate(this.entryToEdit.start_date, 'yyyy-MM-dd', 'en') : '', + entry_date: this.entryToEdit.start_date ? formatDate(this.entryToEdit.start_date, DATE_FORMAT, 'en') : '', start_hour: this.entryToEdit.start_date ? formatDate(this.entryToEdit.start_date, 'HH:mm:ss', 'en') : '00:00:00', end_hour: this.entryToEdit.end_date ? formatDate(this.entryToEdit.end_date, 'HH:mm:ss', 'en') : '00:00:00', uri: this.entryToEdit.uri, @@ -147,7 +148,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit { project_id: '', activity_id: '', description: '', - entry_date: formatDate(new Date(), 'yyyy-MM-dd', 'en'), + entry_date: formatDate(new Date(), DATE_FORMAT, 'en'), start_hour: '00:00:00', end_hour: '00:00:00', uri: '', diff --git a/src/app/modules/shared/models/entry.model.ts b/src/app/modules/shared/models/entry.model.ts index 65737d410..903dee4ba 100644 --- a/src/app/modules/shared/models/entry.model.ts +++ b/src/app/modules/shared/models/entry.model.ts @@ -15,6 +15,7 @@ export interface Entry { customer_id?: string; customer_name?: string; + comments?: string; } export interface NewEntry { @@ -26,3 +27,4 @@ export interface NewEntry { activity_id?: string; timezone_offset?: number; } + diff --git a/src/app/modules/shared/pipes/substract-date/substract-date.pipe.ts b/src/app/modules/shared/pipes/substract-date/substract-date.pipe.ts index 6ca03db08..75efd50c2 100644 --- a/src/app/modules/shared/pipes/substract-date/substract-date.pipe.ts +++ b/src/app/modules/shared/pipes/substract-date/substract-date.pipe.ts @@ -1,6 +1,8 @@ import { NumberFormatter } from './../../formatters/number.formatter'; import { Pipe, PipeTransform } from '@angular/core'; import * as moment from 'moment'; +import { DATE_FORMAT_YEAR } from 'src/environments/environment'; + @Pipe({ name: 'substractDate' }) @@ -12,8 +14,8 @@ export class SubstractDatePipe implements PipeTransform { return '--:--'; } - const startDate = moment(substractDate, 'YYYY-MM-DD HH:mm:ss'); - let endDate = moment(fromDate, 'YYYY-MM-DD HH:mm:ss'); + const startDate = moment(substractDate, `${DATE_FORMAT_YEAR} HH:mm:ss`); + let endDate = moment(fromDate, `${DATE_FORMAT_YEAR} HH:mm:ss`); let duration: moment.Duration = moment.duration(endDate.diff(startDate)); if (duration.asSeconds() > 60 && !displaySeconds) { diff --git a/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.spect.ts b/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.spec.ts similarity index 100% rename from src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.spect.ts rename to src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.spec.ts diff --git a/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.ts b/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.ts index 7606196ef..eaee01258 100644 --- a/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.ts +++ b/src/app/modules/technology-report/components/technology-report-table/technology-report-table.component.ts @@ -120,12 +120,10 @@ export class TechnologyReportTableComponent implements OnInit, OnDestroy, AfterV this.reportDataSource$ = this.store.pipe(select(getReportDataSource)); } - ngOnInit(): void { this.reportDataSource$.subscribe((ds) => { this.rerenderDataTable(); }); - console.log('data', dataMock); } ngAfterViewInit(): void { diff --git a/src/app/modules/shared/time-range-form/time-range-form.component.html b/src/app/modules/technology-report/components/time-range-form/time-range-form.component.html similarity index 100% rename from src/app/modules/shared/time-range-form/time-range-form.component.html rename to src/app/modules/technology-report/components/time-range-form/time-range-form.component.html diff --git a/src/app/modules/shared/time-range-form/time-range-form.component.ts b/src/app/modules/technology-report/components/time-range-form/time-range-form.component.ts similarity index 82% rename from src/app/modules/shared/time-range-form/time-range-form.component.ts rename to src/app/modules/technology-report/components/time-range-form/time-range-form.component.ts index 870f862f4..bb954b8d1 100644 --- a/src/app/modules/shared/time-range-form/time-range-form.component.ts +++ b/src/app/modules/technology-report/components/time-range-form/time-range-form.component.ts @@ -2,10 +2,10 @@ import { ToastrService } from 'ngx-toastr'; import { formatDate } from '@angular/common'; import { Component, OnInit } from '@angular/core'; import { FormControl, FormGroup } from '@angular/forms'; -import * as entryActions from '../../time-clock/store/entry.actions'; - +import * as entryActions from '../../../time-clock/store/entry.actions'; +import { DATE_FORMAT } from 'src/environments/environment'; import {Store} from '@ngrx/store'; -import {EntryState} from '../../time-clock/store/entry.reducer'; +import {EntryState} from '../../../time-clock/store/entry.reducer'; import * as moment from 'moment'; @Component({ @@ -29,8 +29,8 @@ export class TimeRangeFormComponent implements OnInit { setInitialDataOnScreen() { this.reportForm.setValue({ - startDate: formatDate(moment().startOf('week').toString(), 'yyyy-MM-dd', 'en'), - endDate: formatDate(moment().endOf('week').toString(), 'yyyy-MM-dd', 'en') + startDate: formatDate(moment().startOf('week').toString(), DATE_FORMAT, 'en'), + endDate: formatDate(moment().endOf('week').toString(), DATE_FORMAT, 'en') }); this.onSubmit(); } diff --git a/src/app/modules/shared/time-range-form/time-range.component.spec.ts b/src/app/modules/technology-report/components/time-range-form/time-range.component.spec.ts similarity index 91% rename from src/app/modules/shared/time-range-form/time-range.component.spec.ts rename to src/app/modules/technology-report/components/time-range-form/time-range.component.spec.ts index 64e1491a7..5c887fb14 100644 --- a/src/app/modules/shared/time-range-form/time-range.component.spec.ts +++ b/src/app/modules/technology-report/components/time-range-form/time-range.component.spec.ts @@ -1,11 +1,12 @@ +import { Entry } from 'src/app/modules/shared/models'; import { ToastrService, IndividualConfig } from 'ngx-toastr'; import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { MockStore, provideMockStore } from '@ngrx/store/testing'; import { TimeRangeFormComponent } from './time-range-form.component'; -import { EntryState } from '../../time-clock/store/entry.reducer'; +import { EntryState } from '../../../time-clock/store/entry.reducer'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { InputDateComponent } from '../../shared/components/input-date/input-date.component'; -import * as entryActions from '../../time-clock/store/entry.actions'; +import { InputDateComponent } from '../../../shared/components/input-date/input-date.component'; +import * as entryActions from '../../../time-clock/store/entry.actions'; import * as moment from 'moment'; describe('Reports Page', () => { @@ -17,7 +18,7 @@ describe('Reports Page', () => { error: (message?: string, title?: string, override?: Partial) => { } }; - const timeEntry = { + const timeEntry: Entry = { id: '123', start_date: new Date(), end_date: new Date(), @@ -28,7 +29,7 @@ describe('Reports Page', () => { project_id: '123' }; - const state = { + const state: EntryState = { active: timeEntry, entryList: [timeEntry], isLoading: false, diff --git a/src/app/modules/technology-report/pages/technology-report.component.spect.ts b/src/app/modules/technology-report/pages/technology-report.component.spec.ts similarity index 100% rename from src/app/modules/technology-report/pages/technology-report.component.spect.ts rename to src/app/modules/technology-report/pages/technology-report.component.spec.ts diff --git a/src/app/modules/time-clock/components/entry-fields/entry-fields.component.spec.ts b/src/app/modules/time-clock/components/entry-fields/entry-fields.component.spec.ts index f6b78b742..f2d29ee96 100644 --- a/src/app/modules/time-clock/components/entry-fields/entry-fields.component.spec.ts +++ b/src/app/modules/time-clock/components/entry-fields/entry-fields.component.spec.ts @@ -13,6 +13,7 @@ import { ActionsSubject } from '@ngrx/store'; import { IndividualConfig, ToastrService } from 'ngx-toastr'; import { formatDate } from '@angular/common'; import * as moment from 'moment'; +import { DATE_FORMAT_YEAR } from 'src/environments/environment'; describe('EntryFieldsComponent', () => { type Merged = TechnologyState & ProjectState; @@ -66,7 +67,7 @@ describe('EntryFieldsComponent', () => { project_id: 'project-id-15', description: 'description for active entry', uri: 'abc', - start_date : moment().format('YYYY-MM-DD'), + start_date : moment().format(DATE_FORMAT_YEAR), start_hour : moment().format('HH:mm:ss'), }; @@ -115,7 +116,7 @@ describe('EntryFieldsComponent', () => { uri: entryDataForm.uri, activity_id: entryDataForm.activity_id, start_hour: formatDate(entry.start_date, 'HH:mm:ss', 'en'), - start_date : moment().format('YYYY-MM-DD'), + start_date : moment().format(DATE_FORMAT_YEAR), } ); expect(component.selectedTechnologies).toEqual([]); diff --git a/src/app/modules/time-clock/components/entry-fields/entry-fields.component.ts b/src/app/modules/time-clock/components/entry-fields/entry-fields.component.ts index 5f52bc794..0b3762375 100644 --- a/src/app/modules/time-clock/components/entry-fields/entry-fields.component.ts +++ b/src/app/modules/time-clock/components/entry-fields/entry-fields.component.ts @@ -15,6 +15,7 @@ import * as entryActions from '../../store/entry.actions'; import * as moment from 'moment'; import { ToastrService } from 'ngx-toastr'; import { formatDate } from '@angular/common'; +import { DATE_FORMAT } from 'src/environments/environment'; type Merged = TechnologyState & ProjectState & ActivityState; @@ -118,7 +119,7 @@ export class EntryFieldsComponent implements OnInit { } onUpdateStartHour() { - const startDate = formatDate(this.activeEntry.start_date, 'yyyy-MM-dd', 'en'); + const startDate = formatDate(this.activeEntry.start_date, DATE_FORMAT, 'en'); const newHourEntered = new Date(`${startDate}T${this.entryForm.value.start_hour.trim()}`).toISOString(); const isEntryDateInTheFuture = moment(newHourEntered).isAfter(moment()); if (isEntryDateInTheFuture) { diff --git a/src/app/modules/time-clock/store/entry.reducer.ts b/src/app/modules/time-clock/store/entry.reducer.ts index a7ee85a47..5d06d078c 100644 --- a/src/app/modules/time-clock/store/entry.reducer.ts +++ b/src/app/modules/time-clock/store/entry.reducer.ts @@ -2,16 +2,17 @@ import { Entry } from '../../shared/models'; import { DataSource } from '../../shared/models/data-source.model'; import { TimeDetails, TimeEntriesSummary } from '../models/time.entry.summary'; import { EntryActions, EntryActionTypes } from './entry.actions'; - export interface EntryState { active: Entry; + entryList?: Entry[]; isLoading: boolean; message: string; createError: boolean; updateError: boolean; timeEntriesSummary: TimeEntriesSummary; - reportDataSource: DataSource; - timeEntriesDataSource: DataSource; + reportDataSource?: DataSource; + timeEntriesDataSource?: DataSource; + entriesForReport?: Entry[]; } const emptyTimeDetails: TimeDetails = { hours: '--:--', minutes: '--:--', seconds: '--:--' }; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 3c7b4716d..208e0a880 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -16,6 +16,8 @@ export const ITEMS_PER_PAGE = 5; export const STACK_EXCHANGE_ID = keys.STACK_EXCHANGE_ID; export const STACK_EXCHANGE_ACCESS_TOKEN = keys.STACK_EXCHANGE_ACCESS_TOKEN; export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = keys.AZURE_APP_CONFIGURATION_CONNECTION_STRING; +export const DATE_FORMAT = 'yyyy-MM-dd'; +export const DATE_FORMAT_YEAR = 'YYYY-MM-DD'; /* * For easier debugging in development mode, you can import the following file