Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Docker/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ ENV HOME /home/${USERNAME}
RUN useradd -ms /bin/bash ${USERNAME}

WORKDIR ${HOME}/time-tracker-ui
COPY package.json package-lock.json ./
RUN npm cache clean --force && npm install
COPY . .
RUN chown ${USERNAME}:${USERNAME} -R ${HOME}/time-tracker-ui \
&& chmod -R 777 ${HOME}/time-tracker-ui

USER ${USERNAME}
RUN npm cache clean --force && npm install
EXPOSE 4200
CMD ${HOME}/time-tracker-ui/node_modules/.bin/ng serve --host 0.0.0.0 --disableHostCheck
3 changes: 2 additions & 1 deletion Docker/Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ RUN mkdir -p /opt/selenium \
RUN useradd -ms /bin/bash ${USERNAME}

WORKDIR ${HOME}/time-tracker-ui
COPY package.json package-lock.json ./
RUN npm cache clean --force && npm install
COPY . .
RUN chown ${USERNAME}:${USERNAME} -R ${HOME}/time-tracker-ui
RUN chmod -R 777 ${HOME}/time-tracker-ui

USER ${USERNAME}
EXPOSE 4200
EXPOSE 9876
RUN npm cache clean --force && npm install
CMD npm run ci-test
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "time-tracker",
"version": "1.73.2",
"version": "1.74.0",
"scripts": {
"preinstall": "npx npm-force-resolutions",
"ng": "ng",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
Expand All @@ -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);
});
Expand All @@ -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);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}

Expand All @@ -34,7 +34,7 @@ export class ProjectService {

updateProject(projectData): Observable<any> {
const { id } = projectData;
if (this.isDevelopment) {
if (this.isDevelopmentOrProd) {
if (projectData.status === 'active') {
projectData.status = 1;
}
Expand All @@ -43,7 +43,7 @@ export class ProjectService {
}

deleteProject(projectId: string): Observable<any> {
return this.isDevelopment
return this.isDevelopmentOrProd
? this.http.put(`${this.url}/${projectId}`, { status: 0 })
: this.http.delete(`${this.url}/${projectId}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
(search)="onClearedComponent($event)"
(change)="onSelectedProject($event)"
ngDefaultControl="project_name">

<ng-template ng-option-tmp let-item="item">
<div class="flex flex-wrap flex-row justify-between">
<div class="p-2 text-xs">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,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 { get } from 'lodash';
import { get, isEmpty } from 'lodash';
import { DATE_FORMAT, DATE_FORMAT_YEAR } from 'src/environments/environment';
import { TechnologiesComponent } from '../technologies/technologies.component';
import { MatDatepicker } from '@angular/material/datepicker';
Expand Down Expand Up @@ -179,7 +179,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
this.goingToWorkOnThis = this.entryToEdit?.running ? true : false;
this.shouldRestartEntry = false;
this.getRecentProjects();
if (this.entryToEdit) {
if (this.entryToEdit && !isEmpty(this.entryToEdit)) {
this.isTechnologiesDisabled = false;
this.selectedTechnologies = this.entryToEdit.technologies;
const projectFound = this.listProjects.find((project) => project.id === this.entryToEdit.project_id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div id="sidebar-wrapper" class="table-row border-r border-grayTW-lighter shadow-sm bg-whiteTW dark:bg-grayTW-dark dark:border-grayTW">
<div class="table-cell">
<div class="relative flex items-center border-b border-grayTW-lighter dark:border-grayTW sidebar-heading">
<img src="assets/img/time-tracker-logo.png" alt="ioet-logo" width="200" height="auto"/>
<img [src]="urlLogo" alt="ioet-logo" width="200" height="auto"/>
</div>
<app-user></app-user>
<div class="list-group list-group-flush bg-whiteTW dark:bg-grayTW-darker">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class SidebarComponent implements OnInit, OnDestroy {
navStart;
sidebarItems$: Subscription;
isProduction = environment.production === EnvironmentType.TT_PROD_LEGACY;
urlLogo = this.isProduction ? 'assets/img/time-tracker-logo.png' : 'assets/img/time-tracker-logo-v2.png';

constructor(
private router: Router,
Expand Down
12 changes: 3 additions & 9 deletions src/app/modules/time-clock/services/entry.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]});
Expand Down Expand Up @@ -84,15 +85,15 @@ 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`);
expect(updateEntryRequest.request.method).toBe('POST');
});

it('stops an entry using PUT', () => {
service.urlInProduction = false;
service.urlInProductionLegacy = false;
service.stopEntryRunning('id').subscribe();

const updateEntryRequest = httpMock.expectOne(`${service.baseUrl}/stop`);
Expand All @@ -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);
Expand All @@ -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');
});
Expand All @@ -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);
});
Expand Down
6 changes: 3 additions & 3 deletions src/app/modules/time-clock/services/entry.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any> {
return this.http.get(`${this.baseUrl}/running`);
Expand All @@ -46,7 +46,7 @@ export class EntryService {
}

stopEntryRunning(idEntry: string): Observable<any> {
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<Entry> {
Expand All @@ -69,7 +69,7 @@ export class EntryService {

loadEntriesByTimeRange(range: TimeEntriesTimeRange, userId: string): Observable<any> {
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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class TimeEntriesComponent implements OnInit, OnDestroy, AfterViewInit {
editEntry(entryId: string) {
this.entryId = entryId;
this.store.pipe(select(getTimeEntriesDataSource)).subscribe(ds => {
this.entry = ds.data.find((entry) => entry.id === entryId);
this.entry = {... ds.data.find((entry) => entry.id === entryId)};
this.canMarkEntryAsWIP = this.isEntryRunningEqualsToEntryToEdit(this.getEntryRunning(ds.data), this.entry)
|| this.isTheEntryToEditTheLastOne(ds.data);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
<td class="col-3 text-center">
<ui-switch
size="small"
(change)="!isDevelopment?switchGroup('time-tracker-admin', user):null; updateRole(ROLES.admin, user, $event);"
(change)="!isDevelopmentOrProd?switchGroup('time-tracker-admin', user):null; updateRole(ROLES.admin, user, $event);"
[checked]="user.groups.includes('time-tracker-admin')"></ui-switch>
admin
<span *ngIf="!isDevelopment">
<span *ngIf="!isDevelopmentOrProd">
<ui-switch
size="small"
(change)="switchGroup('time-tracker-tester', user)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class UsersListComponent implements OnInit, OnDestroy, AfterViewInit {
columnDefs: [{ orderable: false, targets: [2]}]
};
switchGroupsSubscription: Subscription;
isDevelopment = true;
isDevelopmentOrProd = true;

public get ROLES() {
return ROLES;
Expand All @@ -38,7 +38,7 @@ export class UsersListComponent implements OnInit, OnDestroy, AfterViewInit {
}

ngOnInit(): void {
this.isDevelopment = environment.production === EnvironmentType.TT_DEV;
this.isDevelopmentOrProd = environment.production === EnvironmentType.TT_DEV || environment.production === EnvironmentType.TT_PROD;
this.store.dispatch(new LoadUsers());
this.loadUsersSubscription = this.actionsSubject$
.pipe(filter((action: any) => action.type === UserActionTypes.LOAD_USERS_SUCCESS))
Expand Down
8 changes: 4 additions & 4 deletions src/app/modules/users/services/users.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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();

Expand All @@ -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();

Expand All @@ -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();

Expand Down
6 changes: 3 additions & 3 deletions src/app/modules/users/services/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
Expand All @@ -19,13 +19,13 @@ export class UsersService {
}

grantRole(userId: string, roleId: string): Observable<any> {
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<any> {
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);
}
Expand Down
Binary file added src/assets/img/time-tracker-logo-v2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.