diff --git a/src/app/modules/customer-management/components/projects/components/services/project.service.spec.ts b/src/app/modules/customer-management/components/projects/components/services/project.service.spec.ts index f1fd70831..83cb39475 100644 --- a/src/app/modules/customer-management/components/projects/components/services/project.service.spec.ts +++ b/src/app/modules/customer-management/components/projects/components/services/project.service.spec.ts @@ -104,7 +104,7 @@ describe('ProjectService', () => { it('update project using PUT from url locally', () => { const project: Project = { id: '1', name: 'new name', description: 'description', project_type_id: '123', status: 'active'}; service.url = 'projects'; - service.isDevelopment = true; + service.isDevelopmentOrProd = true; service.updateProject(project).subscribe((response) => { expect(response.name).toBe('new name'); }); @@ -115,7 +115,7 @@ describe('ProjectService', () => { it('delete project using DELETE from baseUrl', () => { const url = `${service.url}/1`; - service.isDevelopment = false; + service.isDevelopmentOrProd = false; service.deleteProject(projectsList[0].id).subscribe((projectsInResponse) => { expect(projectsInResponse.filter((project) => project.id !== projectsList[0].id).length).toEqual(2); }); @@ -126,7 +126,7 @@ describe('ProjectService', () => { it('update status project using PUT from baseUrl locally', () => { const url = `${service.url}/1`; - service.isDevelopment = true; + service.isDevelopmentOrProd = true; service.deleteProject(projectsList[0].id).subscribe((projectsInResponse) => { expect(projectsInResponse.filter((project) => project.id !== projectsList[0].id).length).toEqual(2); }); diff --git a/src/app/modules/customer-management/components/projects/components/services/project.service.ts b/src/app/modules/customer-management/components/projects/components/services/project.service.ts index 3362dea24..c5b431b1a 100644 --- a/src/app/modules/customer-management/components/projects/components/services/project.service.ts +++ b/src/app/modules/customer-management/components/projects/components/services/project.service.ts @@ -11,7 +11,7 @@ import { Project } from '../../../../../shared/models'; export class ProjectService { projects: Project[] = []; url = `${environment.timeTrackerApiUrl}/projects`; - isDevelopment = environment.production === EnvironmentType.TT_DEV; + isDevelopmentOrProd = environment.production === EnvironmentType.TT_DEV || environment.production === EnvironmentType.TT_PROD; constructor(private http: HttpClient) {} @@ -34,7 +34,7 @@ export class ProjectService { updateProject(projectData): Observable { const { id } = projectData; - if (this.isDevelopment) { + if (this.isDevelopmentOrProd) { if (projectData.status === 'active') { projectData.status = 1; } @@ -43,7 +43,7 @@ export class ProjectService { } deleteProject(projectId: string): Observable { - return this.isDevelopment + return this.isDevelopmentOrProd ? this.http.put(`${this.url}/${projectId}`, { status: 0 }) : this.http.delete(`${this.url}/${projectId}`); } 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 91c39a42a..f54abebe4 100644 --- a/src/app/modules/time-clock/services/entry.service.spec.ts +++ b/src/app/modules/time-clock/services/entry.service.spec.ts @@ -10,6 +10,7 @@ import * as moment from 'moment'; describe('EntryService', () => { let service: EntryService; let httpMock: HttpTestingController; + var reportsUrl = service.urlInProductionLegacy ? service.baseUrl : service.baseUrl + '/report'; beforeEach(() => { TestBed.configureTestingModule({imports: [HttpClientTestingModule], providers: [DatePipe]}); @@ -84,7 +85,7 @@ describe('EntryService', () => { }); it('stops an entry using POST', () => { - service.urlInProduction = true; + service.urlInProductionLegacy = true; service.stopEntryRunning('id').subscribe(); const updateEntryRequest = httpMock.expectOne(`${service.baseUrl}/id/stop`); @@ -92,7 +93,7 @@ describe('EntryService', () => { }); it('stops an entry using PUT', () => { - service.urlInProduction = false; + service.urlInProductionLegacy = false; service.stopEntryRunning('id').subscribe(); const updateEntryRequest = httpMock.expectOne(`${service.baseUrl}/stop`); @@ -105,7 +106,6 @@ describe('EntryService', () => { const pipe: DatePipe = new DatePipe('en'); const timeRange: TimeEntriesTimeRange = {start_date: yesterday, end_date: today}; const userId = '123'; - const reportsUrl = service.urlInProduction ? service.baseUrl : service.baseUrl + '/report'; service.loadEntriesByTimeRange(timeRange, userId).subscribe(); const loadEntryRequest = httpMock.expectOne(req => req.method === 'GET' && req.url === reportsUrl); @@ -120,9 +120,7 @@ describe('EntryService', () => { const today = moment(new Date()); const timeRange: TimeEntriesTimeRange = { start_date: yesterday, end_date: today }; const userId = '123'; - const reportsUrl = service.urlInProduction ? service.baseUrl : service.baseUrl + '/report'; service.loadEntriesByTimeRange(timeRange, userId).subscribe(); - const loadEntryRequest = httpMock.expectOne(req => req.method === 'GET' && req.url === reportsUrl); expect(loadEntryRequest.request.params.get('limit')).toEqual('9999'); }); @@ -132,12 +130,8 @@ describe('EntryService', () => { const today = moment(new Date()); const timeRange: TimeEntriesTimeRange = { start_date: yesterday, end_date: today }; const userId = '123'; - const reportsUrl = service.urlInProduction ? service.baseUrl : service.baseUrl + '/report'; - service.loadEntriesByTimeRange(timeRange, userId).subscribe(); - const loadEntryRequest = httpMock.expectOne(req => req.method === 'GET' && req.url === reportsUrl); - const timezoneOffset = new Date().getTimezoneOffset().toString(); expect(loadEntryRequest.request.params.get('timezone_offset')).toEqual(timezoneOffset); }); diff --git a/src/app/modules/time-clock/services/entry.service.ts b/src/app/modules/time-clock/services/entry.service.ts index 0899a2e2b..125041202 100644 --- a/src/app/modules/time-clock/services/entry.service.ts +++ b/src/app/modules/time-clock/services/entry.service.ts @@ -20,7 +20,7 @@ export class EntryService { static TIME_ENTRIES_DATE_TIME_FORMAT = 'yyyy-MM-ddTHH:mm:ssZZZZZ'; baseUrl = `${environment.timeTrackerApiUrl}/time-entries`; - urlInProduction = environment.production === EnvironmentType.TT_PROD || environment.production === EnvironmentType.TT_PROD_LEGACY; + urlInProductionLegacy = environment.production === EnvironmentType.TT_PROD_LEGACY; loadActiveEntry(): Observable { return this.http.get(`${this.baseUrl}/running`); @@ -46,7 +46,7 @@ export class EntryService { } stopEntryRunning(idEntry: string): Observable { - return (this.urlInProduction ? this.http.post(`${this.baseUrl}/${idEntry}/stop`, null) : this.http.put(`${this.baseUrl}/stop`, null) ); + return (this.urlInProductionLegacy ? this.http.post(`${this.baseUrl}/${idEntry}/stop`, null) : this.http.put(`${this.baseUrl}/stop`, null) ); } restartEntry(idEntry: string): Observable { @@ -69,7 +69,7 @@ export class EntryService { loadEntriesByTimeRange(range: TimeEntriesTimeRange, userId: string): Observable { const MAX_NUMBER_OF_ENTRIES_FOR_REPORTS = 9999; - const loadEntriesByTimeRangeURL = this.urlInProduction ? this.baseUrl : this.baseUrl + '/report'; + const loadEntriesByTimeRangeURL = this.urlInProductionLegacy ? this.baseUrl : this.baseUrl + '/report'; return this.http.get(loadEntriesByTimeRangeURL, { params: { diff --git a/src/app/modules/users/components/users-list/users-list.component.html b/src/app/modules/users/components/users-list/users-list.component.html index 5e45975ae..ecc05e543 100644 --- a/src/app/modules/users/components/users-list/users-list.component.html +++ b/src/app/modules/users/components/users-list/users-list.component.html @@ -20,10 +20,10 @@ admin - + action.type === UserActionTypes.LOAD_USERS_SUCCESS)) diff --git a/src/app/modules/users/services/users.service.spec.ts b/src/app/modules/users/services/users.service.spec.ts index 70e78c2f0..99a35f80e 100644 --- a/src/app/modules/users/services/users.service.spec.ts +++ b/src/app/modules/users/services/users.service.spec.ts @@ -35,7 +35,7 @@ describe('UsersService', () => { it('grant role to a User', () => { const userId = 'userId'; const roleId = 'admin'; - service.isProduction = true; + service.isProductionLegacy = true; service.grantRole(userId, roleId).subscribe(); @@ -46,7 +46,7 @@ describe('UsersService', () => { it('grant role to a User locally', () => { const userId = 'userId'; const roleId = 'admin'; - service.isProduction = false; + service.isProductionLegacy = false; service.grantRole(userId, roleId).subscribe(); @@ -57,7 +57,7 @@ describe('UsersService', () => { it('revoke role to a User', () => { const userId = 'userId'; const roleId = 'admin'; - service.isProduction = true; + service.isProductionLegacy = true; service.revokeRole(userId, roleId).subscribe(); @@ -68,7 +68,7 @@ describe('UsersService', () => { it('revoke role to a User locally', () => { const userId = 'userId'; const roleId = 'admin'; - service.isProduction = false; + service.isProductionLegacy = false; service.revokeRole(userId, roleId).subscribe(); diff --git a/src/app/modules/users/services/users.service.ts b/src/app/modules/users/services/users.service.ts index d232631bf..5f6ba6ea6 100644 --- a/src/app/modules/users/services/users.service.ts +++ b/src/app/modules/users/services/users.service.ts @@ -9,7 +9,7 @@ import { EnvironmentType } from './../../../../environments/enum'; providedIn: 'root', }) export class UsersService { - isProduction = environment.production === EnvironmentType.TT_PROD || environment.production === EnvironmentType.TT_PROD_LEGACY; + isProductionLegacy = environment.production === EnvironmentType.TT_PROD_LEGACY; constructor(private http: HttpClient) {} baseUrl = `${environment.timeTrackerApiUrl}/users`; @@ -19,13 +19,13 @@ export class UsersService { } grantRole(userId: string, roleId: string): Observable { - const url = this.isProduction ? `${this.baseUrl}/${userId}/roles/${roleId}/grant` + const url = this.isProductionLegacy ? `${this.baseUrl}/${userId}/roles/${roleId}/grant` : `${this.baseUrl}/${userId}/${roleId}/grant`; return this.http.post(url, null); } revokeRole(userId: string, roleId: string): Observable { - const url = this.isProduction ? `${this.baseUrl}/${userId}/roles/${roleId}/revoke` + const url = this.isProductionLegacy ? `${this.baseUrl}/${userId}/roles/${roleId}/revoke` : `${this.baseUrl}/${userId}/${roleId}/revoke`; return this.http.post(url, null); }