Skip to content

Commit fe235a9

Browse files
Merge e04b607 into da1792f
2 parents da1792f + e04b607 commit fe235a9

File tree

14 files changed

+105
-17
lines changed

14 files changed

+105
-17
lines changed

.github/workflows/CI-time-tracker-ui.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ jobs:
4949
AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.AZURE_APP_CONFIGURATION_CONNECTION_STRING }}
5050
run: |
5151
chmod +x ./scripts/populate-keys.sh
52+
chmod +x ./scripts/create-keys.sh
5253
sh ./scripts/populate-keys.sh
54+
sh ./scripts/create-keys.sh
55+
5356
5457
- name: Running tests
5558
run: npm run ci-test --if-present

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ cleanup: ## Delete image timetracker_ui
1919

2020
.PHONY: run
2121
run: ## Execute timetracker_ui docker containe.
22-
docker-compose --env-file ./.env up -d
22+
docker-compose up -d
2323

2424
.PHONY: logs
2525
logs: ## Show logs of timetracker_ui.
@@ -40,12 +40,12 @@ remove: ## Delete container timetracker_ui.
4040

4141
.PHONY: test
4242
test: ## Run all tests on docker container timetracker_ui at the CLI.
43-
docker-compose -f docker-compose.yml --env-file ./.env up -d
43+
docker-compose -f docker-compose.yml up -d
4444
docker exec timetracker_ui bash -c "npm run ci-test"
4545

4646
.PHONY: testdev
4747
testdev: ## Run all tests on docker container timetracker_ui at the Dev
48-
docker-compose -f docker-compose.yml -f docker-compose.dev.yml --env-file ./.env up -d
48+
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d
4949
docker exec timetracker_ui bash -c "npm run ci-test"
5050

5151
.PHONY: publish

scripts/create-keys.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
> ./src/environments/keys.ts
2+
echo "export const AUTHORITY = '${AUTHORITY}'" >> ./src/environments/keys.ts
3+
echo "export const CLIENT_ID = '${CLIENT_ID}'" >> ./src/environments/keys.ts
4+
echo "export const SCOPES = ['${SCOPES}']" >> ./src/environments/keys.ts
5+
echo "export const STACK_EXCHANGE_ID = '${STACK_EXCHANGE_ID}'" >> ./src/environments/keys.ts
6+
echo "export const STACK_EXCHANGE_ACCESS_TOKEN = '${STACK_EXCHANGE_ACCESS_TOKEN}'" >> ./src/environments/keys.ts
7+
echo "export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = '${AZURE_APP_CONFIGURATION_CONNECTION_STRING}'" >> ./src/environments/keys.ts
8+
cat ./src/environments/keys.ts

scripts/populate-keys.sh

100644100755
File mode changed.

src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ import { NgSelectModule } from '@ng-select/ng-select';
8989
import { DarkModeComponent } from './modules/shared/components/dark-mode/dark-mode.component';
9090
import { SocialLoginModule, SocialAuthServiceConfig } from 'angularx-social-login';
9191
import { GoogleLoginProvider } from 'angularx-social-login';
92+
import { SearchUserComponent } from './modules/shared/components/search-user/search-user.component';
9293

9394
const maskConfig: Partial<IConfig> = {
9495
validation: false,
@@ -128,6 +129,7 @@ const maskConfig: Partial<IConfig> = {
128129
EntryFieldsComponent,
129130
SubstractDatePipe,
130131
TechnologiesComponent,
132+
SearchUserComponent,
131133
TimeEntriesSummaryComponent,
132134
TimeDetailsPipe,
133135
InputLabelComponent,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<div class="row scroll-table mt-5 ml-0">
2+
<app-search-user [users]="users" (selectedUserId)="user($event)"></app-search-user>
23
<table
34
class="table table-striped mb-0"
45
datatable

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

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
import { formatDate } from '@angular/common';
2-
import { AfterViewInit, Component, OnDestroy, OnInit, ViewChild} from '@angular/core';
3-
import { select, Store } from '@ngrx/store';
2+
import { AfterViewInit, Component, EventEmitter, OnDestroy, Output, OnInit, ViewChild } from '@angular/core';
3+
import { select, Store, ActionsSubject } from '@ngrx/store';
44
import { DataTableDirective } from 'angular-datatables';
55
import * as moment from 'moment';
66
import { Observable, Subject, Subscription } from 'rxjs';
7+
import { filter } from 'rxjs/operators';
78
import { Entry } from 'src/app/modules/shared/models';
89
import { DataSource } from 'src/app/modules/shared/models/data-source.model';
910
import { EntryState } from '../../../time-clock/store/entry.reducer';
1011
import { getReportDataSource } from '../../../time-clock/store/entry.selectors';
12+
import { User } from 'src/app/modules/users/models/users';
13+
import { LoadUsers, UserActionTypes } from 'src/app/modules/users/store/user.actions';
1114

1215
@Component({
1316
selector: 'app-time-entries-table',
1417
templateUrl: './time-entries-table.component.html',
1518
styleUrls: ['./time-entries-table.component.scss'],
1619
})
1720
export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewInit {
21+
@Output() selectedUserId = new EventEmitter<string>();
22+
1823
selectOptionValues = [15, 30, 50, 100, -1];
1924
selectOptionNames = [15, 30, 50, 100, 'All'];
25+
users: User[] = [];
2026
dtOptions: any = {
2127
scrollY: '590px',
2228
dom: '<"d-flex justify-content-between"B<"d-flex"<"mr-5"l>f>>rtip',
@@ -61,14 +67,24 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn
6167
reportDataSource$: Observable<DataSource<Entry>>;
6268
rerenderTableSubscription: Subscription;
6369

64-
constructor(private store: Store<EntryState>) {
70+
constructor(private store: Store<EntryState>, private actionsSubject$: ActionsSubject, private storeUser: Store<User> ) {
6571
this.reportDataSource$ = this.store.pipe(select(getReportDataSource));
6672
}
6773

74+
uploadUsers(): void {
75+
this.storeUser.dispatch(new LoadUsers());
76+
this.actionsSubject$
77+
.pipe(filter((action: any) => action.type === UserActionTypes.LOAD_USERS_SUCCESS))
78+
.subscribe((action) => {
79+
this.users = action.payload;
80+
});
81+
}
82+
6883
ngOnInit(): void {
6984
this.rerenderTableSubscription = this.reportDataSource$.subscribe((ds) => {
7085
this.rerenderDataTable();
7186
});
87+
this.uploadUsers();
7288
}
7389

7490
ngAfterViewInit(): void {
@@ -83,11 +99,11 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn
8399
private rerenderDataTable(): void {
84100
if (this.dtElement && this.dtElement.dtInstance) {
85101
this.dtElement.dtInstance.then((dtInstance: DataTables.Api) => {
86-
dtInstance.destroy();
87-
this.dtTrigger.next();
102+
dtInstance.destroy();
103+
this.dtTrigger.next();
88104
});
89105
} else {
90-
this.dtTrigger.next();
106+
this.dtTrigger.next();
91107
}
92108
}
93109

@@ -100,10 +116,15 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn
100116
return regex.test(uri);
101117
}
102118

103-
bodyExportOptions(data, row, column, node){
119+
bodyExportOptions(data, row, column, node) {
104120
const dataFormated = data.toString().replace(/<((.|\n){0,200}?)>/gi, '');
105121
const durationColumnIndex = 3;
106122
return column === durationColumnIndex ? moment.duration(dataFormated).asHours().toFixed(2) : dataFormated;
107123
}
124+
125+
user(userId: string){
126+
this.selectedUserId.emit(userId);
127+
}
128+
108129
}
109130

src/app/modules/reports/components/time-range-form/time-range-form.component.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ToastrService } from 'ngx-toastr';
22
import { formatDate } from '@angular/common';
3-
import { Component, OnInit } from '@angular/core';
3+
import { OnChanges, SimpleChanges, Component, Input, OnInit } from '@angular/core';
44
import { FormControl, FormGroup } from '@angular/forms';
55
import { DATE_FORMAT } from 'src/environments/environment';
66
import * as entryActions from '../../../time-clock/store/entry.actions';
@@ -12,7 +12,10 @@ import * as moment from 'moment';
1212
selector: 'app-time-range-form',
1313
templateUrl: './time-range-form.component.html',
1414
})
15-
export class TimeRangeFormComponent implements OnInit {
15+
export class TimeRangeFormComponent implements OnInit, OnChanges {
16+
17+
@Input() userId: string;
18+
1619
public reportForm: FormGroup;
1720
private startDate = new FormControl('');
1821
private endDate = new FormControl('');
@@ -27,6 +30,12 @@ export class TimeRangeFormComponent implements OnInit {
2730
this.setInitialDataOnScreen();
2831
}
2932

33+
ngOnChanges(changes: SimpleChanges){
34+
if (!changes.userId.firstChange){
35+
this.onSubmit();
36+
}
37+
}
38+
3039
setInitialDataOnScreen() {
3140
this.reportForm.setValue({
3241
startDate: formatDate(moment().startOf('week').format('l'), DATE_FORMAT, 'en'),
@@ -43,7 +52,7 @@ export class TimeRangeFormComponent implements OnInit {
4352
this.store.dispatch(new entryActions.LoadEntriesByTimeRange({
4453
start_date: moment(this.startDate.value).startOf('day'),
4554
end_date: moment(this.endDate.value).endOf('day'),
46-
}));
55+
}, this.userId));
4756
}
4857
}
4958
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
<app-time-range-form></app-time-range-form>
2-
<app-time-entries-table></app-time-entries-table>
3-
1+
<app-time-range-form [userId]="userId"></app-time-range-form>
2+
<app-time-entries-table (selectedUserId)="user($event)"></app-time-entries-table>

src/app/modules/reports/pages/reports.component.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,10 @@ import { Component } from '@angular/core';
66
styleUrls: ['./reports.component.scss']
77
})
88
export class ReportsComponent {
9+
10+
userId: string;
11+
12+
user(userId: string){
13+
this.userId = userId;
14+
}
915
}

0 commit comments

Comments
 (0)