Skip to content

Commit d284f37

Browse files
author
Abigail Cabascango
committed
Merge branch 'master' into TTA-206-ui-creating-overlapping-entries
2 parents 472b09d + 0498d2e commit d284f37

15 files changed

+174
-81
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ testem.log
4242
/typings
4343
debug.log
4444
*.vscode
45+
.hintrc
4546

4647
# System Files
4748
.DS_Store

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "time-tracker",
3-
"version": "1.75.24",
3+
"version": "1.75.40",
44
"scripts": {
55
"preinstall": "npx npm-force-resolutions",
66
"ng": "ng",

src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ import { UserEffects } from './modules/user/store/user.effects';
7272
import { EntryEffects } from './modules/time-clock/store/entry.effects';
7373
import { InjectTokenInterceptor } from './modules/shared/interceptors/inject.token.interceptor';
7474
import { SubstractDatePipe } from './modules/shared/pipes/substract-date/substract-date.pipe';
75+
import { SubstractDatePipeDisplayAsFloat } from './modules/shared/pipes/substract-date-return-float/substract-date-return-float.pipe';
7576
import { TechnologiesComponent } from './modules/shared/components/technologies/technologies.component';
7677
import { TimeEntriesSummaryComponent } from './modules/time-clock/components/time-entries-summary/time-entries-summary.component';
7778
import { TimeDetailsPipe } from './modules/time-clock/pipes/time-details.pipe';
@@ -138,6 +139,7 @@ const maskConfig: Partial<IConfig> = {
138139
CreateProjectTypeComponent,
139140
EntryFieldsComponent,
140141
SubstractDatePipe,
142+
SubstractDatePipeDisplayAsFloat,
141143
TechnologiesComponent,
142144
SearchUserComponent,
143145
TimeEntriesSummaryComponent,

src/app/modules/login/login.component.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,12 @@ export class LoginComponent implements OnInit {
6464
ngOnInit() {
6565

6666
this.googleAuthSDK();
67-
if (this.isProduction && this.azureAdB2CService.isLogin()) {
68-
this.router.navigate(['']);
69-
} else {
7067
this.loginService.isLogin().subscribe(isLogin => {
7168
if (isLogin) {
7269
this.router.navigate(['']);
7370
}
7471
});
75-
}
72+
7673
window.handleCredentialResponse = (response) => {
7774
const {credential = ''} = response;
7875
this.featureToggleCookiesService.setCookies();

src/app/modules/reports/components/time-entries-table/time-entries-table.component.html

Lines changed: 69 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,74 @@
11
<div class="row scroll-table mt-5 ml-0">
2-
<app-search-user [users]="users" (selectedUserId)="user($event)"></app-search-user>
2+
<app-search-user [users]="users" (selectedUserId)="user($event)"></app-search-user>
33

4-
<table class="table table-striped mb-0" datatable [dtTrigger]="dtTrigger" [dtOptions]="dtOptions" *ngIf="(reportDataSource$ | async) as dataSource">
5-
<thead class="thead-blue">
6-
<tr class="d-flex">
7-
<th class="col md-col">Selected</th>
8-
<th class="hidden-col">ID</th>
9-
<th class="col md-col">User email</th>
10-
<th class="col sm-col">Date</th>
11-
<th class="col sm-col" title="Duration (hours)">Duration</th>
12-
<th class="col x-sm-col" title="Time in">Time in</th>
13-
<th class="col x-sm-col" title="Time out">Time out</th>
14-
<th class="col md-col">Project</th>
15-
<th class="hidden-col">Project ID</th>
16-
<th class="col md-col">Customer</th>
17-
<th class="hidden-col">Customer ID</th>
18-
<th class="col md-col">Activity</th>
19-
<th class="col lg-col">Ticket</th>
20-
<th class="col lg-col">Description</th>
21-
<th class="col lg-col">Technologies</th>
22-
</tr>
23-
</thead>
24-
<app-loading-bar *ngIf="dataSource.isLoading"></app-loading-bar>
25-
<tbody *ngIf="!dataSource.isLoading">
26-
<tr class="d-flex col-height" *ngFor="let entry of dataSource.data">
27-
<td class="col md-col"><mat-checkbox
28-
(change)="sumHoursEntriesSelected(entry, $event.checked)"></mat-checkbox></td>
29-
<td class="hidden-col">{{ entry.id }}</td>
30-
<td class="col md-col">{{ entry.owner_email }}</td>
31-
<td class="col sm-col">
32-
{{ entry.start_date | date: 'MM/dd/yyyy' }}
33-
</td>
34-
<td class="col sm-col">
35-
{{ entry.end_date | substractDate: entry.start_date }}
36-
</td>
37-
<td class="col x-sm-col">{{ dateTimeOffset.parseDateTimeOffset(entry.start_date,entry.timezone_offset) }}</td>
38-
<td class="col x-sm-col">{{ dateTimeOffset.parseDateTimeOffset(entry.end_date , entry.timezone_offset) }}</td>
39-
<td class="col md-col">{{ entry.project_name }}</td>
40-
<td class="hidden-col">{{ entry.project_id }}</td>
41-
<td class="col md-col">{{ entry.customer_name }}</td>
42-
<td class="hidden-col">{{ entry.customer_id }}</td>
43-
<td class="col md-col">{{ entry.activity_name }}</td>
44-
<td class="col lg-col">
45-
<ng-container *ngIf="entry.uri !== null">
46-
<a [class.is-url]="isURL(entry.uri)" (click)="openURLInNewTab(entry.uri)">
4+
<table
5+
class="table table-striped mb-0"
6+
datatable
7+
[dtTrigger]="dtTrigger"
8+
[dtOptions]="dtOptions"
9+
*ngIf="reportDataSource$ | async as dataSource"
10+
>
11+
<thead class="thead-blue">
12+
<tr class="d-flex">
13+
<th class="col md-col">Selected</th>
14+
<th class="hidden-col">ID</th>
15+
<th class="col md-col">User email</th>
16+
<th class="col sm-col">Date</th>
17+
<th class="col sm-col" title="Duration (hours)">Duration</th>
18+
<th class="col x-sm-col" title="Time in">Time in</th>
19+
<th class="col x-sm-col" title="Time out">Time out</th>
20+
<th class="col md-col">Project</th>
21+
<th class="hidden-col">Project ID</th>
22+
<th class="col md-col">Customer</th>
23+
<th class="hidden-col">Customer ID</th>
24+
<th class="col md-col">Activity</th>
25+
<th class="col lg-col">Ticket</th>
26+
<th class="col lg-col">Description</th>
27+
<th class="col lg-col">Technologies</th>
28+
</tr>
29+
</thead>
30+
<app-loading-bar *ngIf="dataSource.isLoading"></app-loading-bar>
31+
<tbody *ngIf="!dataSource.isLoading">
32+
<tr class="d-flex col-height" *ngFor="let entry of dataSource.data">
33+
<td class="col md-col">
34+
<mat-checkbox (change)="sumHoursEntriesSelected(entry, $event.checked)"></mat-checkbox>
35+
</td>
36+
<td class="hidden-col">{{ entry.id }}</td>
37+
<td class="col md-col">{{ entry.owner_email }}</td>
38+
<td class="col sm-col">
39+
{{ entry.start_date | date: 'MM/dd/yyyy' }}
40+
</td>
41+
<td class="col sm-col">
42+
{{ entry.end_date | substractDateDisplayAsFloat: entry.start_date }}
43+
</td>
44+
<td class="col x-sm-col">{{ dateTimeOffset.parseDateTimeOffset(entry.start_date, entry.timezone_offset) }}</td>
45+
<td class="col x-sm-col">{{ dateTimeOffset.parseDateTimeOffset(entry.end_date, entry.timezone_offset) }}</td>
46+
<td class="col md-col">{{ entry.project_name }}</td>
47+
<td class="hidden-col">{{ entry.project_id }}</td>
48+
<td class="col md-col">{{ entry.customer_name }}</td>
49+
<td class="hidden-col">{{ entry.customer_id }}</td>
50+
<td class="col md-col">{{ entry.activity_name }}</td>
51+
<td class="col lg-col">
52+
<ng-container *ngIf="entry.uri !== null">
53+
<a [class.is-url]="isURL(entry.uri)" (click)="openURLInNewTab(entry.uri)">
4754
{{ entry.uri }}
4855
</a>
49-
</ng-container>
50-
</td>
51-
<td class="col lg-scroll">{{ entry.description }}</td>
52-
<td class="col lg-scroll">
53-
<ng-container *ngIf="entry.technologies.length > 0">
54-
<div *ngFor="let technology of entry.technologies" class="badge bg-secondary text-wrap">
55-
{{ technology }}
56-
</div>
57-
</ng-container>
58-
</td>
59-
</tr>
60-
</tbody>
61-
</table>
56+
</ng-container>
57+
</td>
58+
<td class="col lg-scroll">{{ entry.description }}</td>
59+
<td class="col lg-scroll">
60+
<ng-container *ngIf="entry.technologies.length > 0">
61+
<div *ngFor="let technology of entry.technologies" class="badge bg-secondary text-wrap">
62+
{{ technology }}
63+
</div>
64+
</ng-container>
65+
</td>
66+
</tr>
67+
</tbody>
68+
</table>
69+
</div>
70+
<div class="alert alert-dark mt-3">
71+
Total: {{ this.resultSum.hours }} hours, {{ this.resultSum.minutes }} minutes, <br />
72+
Total hours entries selected: {{ resultSumEntriesSelected.hours }} hours,
73+
{{ resultSumEntriesSelected.minutes }} minutes
6274
</div>
63-
<div class="alert alert-dark mt-3">Total: {{this.resultSum.hours}} hours, {{this.resultSum.minutes}} minutes,
64-
<br/> Total hours entries selected: {{resultSumEntriesSelected.hours}} hours, {{resultSumEntriesSelected.minutes}} minutes</div>

src/app/modules/reports/components/time-entries-table/time-entries-table.component.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { DataTablesModule } from 'angular-datatables';
44
import { NgxPaginationModule } from 'ngx-pagination';
55
import { Entry } from 'src/app/modules/shared/models';
66
import { SubstractDatePipe } from 'src/app/modules/shared/pipes/substract-date/substract-date.pipe';
7+
import { SubstractDatePipeDisplayAsFloat } from 'src/app/modules/shared/pipes/substract-date-return-float/substract-date-return-float.pipe';
78
import { getReportDataSource, getResultSumEntriesSelected } from 'src/app/modules/time-clock/store/entry.selectors';
89
import { EntryState } from '../../../time-clock/store/entry.reducer';
910
import { TimeEntriesTableComponent } from './time-entries-table.component';
@@ -80,7 +81,7 @@ describe('Reports Page', () => {
8081
waitForAsync(() => {
8182
TestBed.configureTestingModule({
8283
imports: [NgxPaginationModule, DataTablesModule],
83-
declarations: [TimeEntriesTableComponent, SubstractDatePipe],
84+
declarations: [TimeEntriesTableComponent, SubstractDatePipe, SubstractDatePipeDisplayAsFloat],
8485
providers: [provideMockStore({ initialState: state }), { provide: ActionsSubject, useValue: actionSub }],
8586
}).compileComponents();
8687

src/app/modules/reports/components/time-entries-table/time-entries-table.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn
6868
filename: `time-entries-${formatDate(new Date(), 'MM_dd_yyyy-HH_mm', 'en')}`
6969
},
7070
],
71-
columnDefs: [{ type: 'date', targets: 2}, {orderable: false, targets: [0]}],
71+
columnDefs: [{ type: 'date', targets: 3}, {orderable: false, targets: [0]}],
7272
order: [[1, 'asc'], [2, 'desc'], [4, 'desc']]
7373
};
7474
dtTrigger: Subject<any> = new Subject();
@@ -183,4 +183,3 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn
183183
return this.resultSumEntriesSelected;
184184
}
185185
}
186-

src/app/modules/shared/interceptors/inject.token.interceptor.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,22 @@ import {
44
HttpInterceptor,
55
HttpHandler,
66
HttpRequest,
7+
HttpErrorResponse,
78
} from '@angular/common/http';
89
import { Observable } from 'rxjs';
10+
import { tap } from 'rxjs/operators';
911

1012
import { AzureAdB2CService } from 'src/app/modules/login/services/azure.ad.b2c.service';
1113
import { environment } from './../../../../environments/environment';
1214
import { EnvironmentType } from 'src/environments/enum';
1315
import { LoginService } from '../../login/services/login.service';
16+
import { catchError } from 'rxjs/operators';
17+
import { Router } from '@angular/router';
1418

1519
@Injectable()
1620
export class InjectTokenInterceptor implements HttpInterceptor {
1721
isProduction = environment.production === EnvironmentType.TT_PROD_LEGACY;
18-
constructor(private azureAdB2CService: AzureAdB2CService, private loginService: LoginService) { }
22+
constructor(private azureAdB2CService: AzureAdB2CService, private loginService: LoginService, private router: Router) { }
1923

2024
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
2125
if (request.url.startsWith(environment.timeTrackerApiUrl)) {
@@ -25,7 +29,17 @@ export class InjectTokenInterceptor implements HttpInterceptor {
2529
headers: request.headers.set('Authorization',
2630
'Bearer ' + token)
2731
});
28-
return next.handle(requestWithHeaders);
32+
return next.handle(requestWithHeaders)
33+
.pipe(
34+
tap(() => { }, (err: any) => {
35+
if (err instanceof HttpErrorResponse) {
36+
if (err.status === 401) {
37+
this.loginService.logout();
38+
window.open("/login", "_self")
39+
}
40+
}
41+
})
42+
);
2943
} else {
3044
return next.handle(request);
3145
}

src/app/modules/shared/interceptors/spinner.interceptor.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ describe('SpinnerInterceptorService test', () => {
1616
],
1717
});
1818

19-
class MockHttpHandler implements HttpHandler {
20-
handle(req: HttpRequest<any>): Observable<HttpEvent<any>> {
21-
return of(new HttpResponse());
22-
}
19+
class MockHttpHandler implements HttpHandler {
20+
handle(req: HttpRequest<any>): Observable<HttpEvent<any>> {
21+
return of(new HttpResponse());
2322
}
23+
}
2424

2525
let overlay: Overlay;
2626
let httpHandler: HttpHandler;

0 commit comments

Comments
 (0)