From 5a1ed1d2fc5cd82dd6cdb912feaeb84274c479b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Cobe=C3=B1a?= Date: Thu, 23 Dec 2021 11:51:17 -0500 Subject: [PATCH 1/3] feat: TT-466 First commit for clockout frontend --- .../time-clock/services/entry.service.spec.ts | 18 ++++++++--------- .../time-clock/services/entry.service.ts | 20 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/app/modules/time-clock/services/entry.service.spec.ts b/src/app/modules/time-clock/services/entry.service.spec.ts index ed4191c0b..3bfe37681 100644 --- a/src/app/modules/time-clock/services/entry.service.spec.ts +++ b/src/app/modules/time-clock/services/entry.service.spec.ts @@ -40,21 +40,12 @@ describe('EntryService', () => { }); it('loads an activeEntry with /running', () => { - service.urlInProduction = true; service.loadActiveEntry().subscribe(); const loadEntryRequest = httpMock.expectOne(`${service.baseUrl}/running`); expect(loadEntryRequest.request.method).toBe('GET'); }); - it('loads an activeEntry with /active/{userId}', () => { - service.urlInProduction = false; - service.loadActiveEntry().subscribe(); - - const loadEntryRequest = httpMock.expectOne(`${service.baseUrl}/active/2`); - expect(loadEntryRequest.request.method).toBe('GET'); - }); - it('loads summary with get /summary?time_offset=', () => { service.summary().subscribe(); const timeOffset = new Date().getTimezoneOffset(); @@ -93,12 +84,21 @@ describe('EntryService', () => { }); it('stops an entry using POST', () => { + service.urlInProduction = true; service.stopEntryRunning('id').subscribe(); const updateEntryRequest = httpMock.expectOne(`${service.baseUrl}/id/stop`); expect(updateEntryRequest.request.method).toBe('POST'); }); + it('stops an entry using PUT', () => { + service.urlInProduction = false; + service.stopEntryRunning('id').subscribe(); + + const updateEntryRequest = httpMock.expectOne(`${service.baseUrl}/stop`); + expect(updateEntryRequest.request.method).toBe('PUT'); + }); + it('when getting time entries for report, time range should be sent', () => { const yesterday = moment(new Date()).subtract(1, 'day'); const today = moment(new Date()); diff --git a/src/app/modules/time-clock/services/entry.service.ts b/src/app/modules/time-clock/services/entry.service.ts index 12915e192..7a060efa1 100644 --- a/src/app/modules/time-clock/services/entry.service.ts +++ b/src/app/modules/time-clock/services/entry.service.ts @@ -22,14 +22,7 @@ export class EntryService { urlInProduction = environment.production; loadActiveEntry(): Observable { - let path = ''; - - if (this.urlInProduction){ - path = `${this.baseUrl}/running`; - }else{ - path = `${this.baseUrl}/active/2`; - } - return this.http.get(path); + return this.http.get(`${this.baseUrl}/running`); } loadEntries(date): Observable { @@ -52,8 +45,15 @@ export class EntryService { } stopEntryRunning(idEntry: string): Observable { - const url = `${this.baseUrl}/${idEntry}/stop`; - return this.http.post(url, null); + let path = ''; + + if (this.urlInProduction){ + path = `${this.baseUrl}/${idEntry}/stop`; + return this.http.post(path, null); + }else{ + path = `${this.baseUrl}/stop`; + return this.http.put(path, null); + } } restartEntry(idEntry: string): Observable { From eeb43b3f39290bd95eaef146798a917ae5037827 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Cobe=C3=B1a?= Date: Mon, 27 Dec 2021 15:03:47 -0500 Subject: [PATCH 2/3] fix: TT-466 fix comments --- src/app/modules/time-clock/services/entry.service.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/app/modules/time-clock/services/entry.service.ts b/src/app/modules/time-clock/services/entry.service.ts index 7a060efa1..fa3e5bd24 100644 --- a/src/app/modules/time-clock/services/entry.service.ts +++ b/src/app/modules/time-clock/services/entry.service.ts @@ -45,15 +45,7 @@ export class EntryService { } stopEntryRunning(idEntry: string): Observable { - let path = ''; - - if (this.urlInProduction){ - path = `${this.baseUrl}/${idEntry}/stop`; - return this.http.post(path, null); - }else{ - path = `${this.baseUrl}/stop`; - return this.http.put(path, null); - } + return (this.urlInProduction ? this.http.post(`${this.baseUrl}/${idEntry}/stop`, null) : this.http.put(`${this.baseUrl}/stop`, null) ); } restartEntry(idEntry: string): Observable { From 293fe82bb0378f2031a8473a82983c258691a66f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Cobe=C3=B1a?= Date: Tue, 28 Dec 2021 22:37:58 -0500 Subject: [PATCH 3/3] fix: TT-485 switch time entry to new project --- src/app/modules/time-clock/store/entry.effects.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/modules/time-clock/store/entry.effects.ts b/src/app/modules/time-clock/store/entry.effects.ts index 73dcc8dfe..98527cc58 100644 --- a/src/app/modules/time-clock/store/entry.effects.ts +++ b/src/app/modules/time-clock/store/entry.effects.ts @@ -23,6 +23,7 @@ export class EntryEffects { const stopDateForEntry = new Date(response.end_date); stopDateForEntry.setSeconds(stopDateForEntry.getSeconds() + 1); const entry = { + activity_id: response.activity_id, project_id: action.idProjectSwitching, start_date: stopDateForEntry.toISOString(), timezone_offset: new Date().getTimezoneOffset(),