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: 3 additions & 0 deletions .github/workflows/CI-time-tracker-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ jobs:
AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.AZURE_APP_CONFIGURATION_CONNECTION_STRING }}
run: |
chmod +x ./scripts/populate-keys.sh
chmod +x ./scripts/create-keys.sh
sh ./scripts/populate-keys.sh
sh ./scripts/create-keys.sh


- name: Running tests
run: npm run ci-test --if-present
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ cleanup: ## Delete image timetracker_ui

.PHONY: run
run: ## Execute timetracker_ui docker containe.
docker-compose --env-file ./.env up -d
docker-compose up -d

.PHONY: logs
logs: ## Show logs of timetracker_ui.
Expand All @@ -40,12 +40,12 @@ remove: ## Delete container timetracker_ui.

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

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

.PHONY: publish
Expand Down
8 changes: 8 additions & 0 deletions scripts/create-keys.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
> ./src/environments/keys.ts
echo "export const AUTHORITY = '${AUTHORITY}'" >> ./src/environments/keys.ts
echo "export const CLIENT_ID = '${CLIENT_ID}'" >> ./src/environments/keys.ts
echo "export const SCOPES = ['${SCOPES}']" >> ./src/environments/keys.ts
echo "export const STACK_EXCHANGE_ID = '${STACK_EXCHANGE_ID}'" >> ./src/environments/keys.ts
echo "export const STACK_EXCHANGE_ACCESS_TOKEN = '${STACK_EXCHANGE_ACCESS_TOKEN}'" >> ./src/environments/keys.ts
echo "export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = '${AZURE_APP_CONFIGURATION_CONNECTION_STRING}'" >> ./src/environments/keys.ts
cat ./src/environments/keys.ts
Empty file modified scripts/populate-keys.sh
100644 → 100755
Empty file.
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ import { NgSelectModule } from '@ng-select/ng-select';
import { DarkModeComponent } from './modules/shared/components/dark-mode/dark-mode.component';
import { SocialLoginModule, SocialAuthServiceConfig } from 'angularx-social-login';
import { GoogleLoginProvider } from 'angularx-social-login';
import { SearchUserComponent } from './modules/shared/components/search-user/search-user.component';

const maskConfig: Partial<IConfig> = {
validation: false,
Expand Down Expand Up @@ -128,6 +129,7 @@ const maskConfig: Partial<IConfig> = {
EntryFieldsComponent,
SubstractDatePipe,
TechnologiesComponent,
SearchUserComponent,
TimeEntriesSummaryComponent,
TimeDetailsPipe,
InputLabelComponent,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<div class="row scroll-table mt-5 ml-0">
<app-search-user [users]="users" (selectedUserId)="user($event)"></app-search-user>
<table
class="table table-striped mb-0"
datatable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
import { formatDate } from '@angular/common';
import { AfterViewInit, Component, OnDestroy, OnInit, ViewChild} from '@angular/core';
import { select, Store } from '@ngrx/store';
import { AfterViewInit, Component, EventEmitter, OnDestroy, Output, OnInit, ViewChild } from '@angular/core';
import { select, Store, ActionsSubject } from '@ngrx/store';
import { DataTableDirective } from 'angular-datatables';
import * as moment from 'moment';
import { Observable, Subject, Subscription } from 'rxjs';
import { filter } from 'rxjs/operators';
import { Entry } from 'src/app/modules/shared/models';
import { DataSource } from 'src/app/modules/shared/models/data-source.model';
import { EntryState } from '../../../time-clock/store/entry.reducer';
import { getReportDataSource } from '../../../time-clock/store/entry.selectors';
import { User } from 'src/app/modules/users/models/users';
import { LoadUsers, UserActionTypes } from 'src/app/modules/users/store/user.actions';

@Component({
selector: 'app-time-entries-table',
templateUrl: './time-entries-table.component.html',
styleUrls: ['./time-entries-table.component.scss'],
})
export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewInit {
@Output() selectedUserId = new EventEmitter<string>();

selectOptionValues = [15, 30, 50, 100, -1];
selectOptionNames = [15, 30, 50, 100, 'All'];
users: User[] = [];
dtOptions: any = {
scrollY: '590px',
dom: '<"d-flex justify-content-between"B<"d-flex"<"mr-5"l>f>>rtip',
Expand Down Expand Up @@ -61,14 +67,24 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn
reportDataSource$: Observable<DataSource<Entry>>;
rerenderTableSubscription: Subscription;

constructor(private store: Store<EntryState>) {
constructor(private store: Store<EntryState>, private actionsSubject$: ActionsSubject, private storeUser: Store<User> ) {
this.reportDataSource$ = this.store.pipe(select(getReportDataSource));
}

uploadUsers(): void {
this.storeUser.dispatch(new LoadUsers());
this.actionsSubject$
.pipe(filter((action: any) => action.type === UserActionTypes.LOAD_USERS_SUCCESS))
.subscribe((action) => {
this.users = action.payload;
});
}

ngOnInit(): void {
this.rerenderTableSubscription = this.reportDataSource$.subscribe((ds) => {
this.rerenderDataTable();
});
this.uploadUsers();
}

ngAfterViewInit(): void {
Expand All @@ -83,11 +99,11 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn
private rerenderDataTable(): void {
if (this.dtElement && this.dtElement.dtInstance) {
this.dtElement.dtInstance.then((dtInstance: DataTables.Api) => {
dtInstance.destroy();
this.dtTrigger.next();
dtInstance.destroy();
this.dtTrigger.next();
});
} else {
this.dtTrigger.next();
this.dtTrigger.next();
}
}

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

bodyExportOptions(data, row, column, node){
bodyExportOptions(data, row, column, node) {
const dataFormated = data.toString().replace(/<((.|\n){0,200}?)>/gi, '');
const durationColumnIndex = 3;
return column === durationColumnIndex ? moment.duration(dataFormated).asHours().toFixed(2) : dataFormated;
}

user(userId: string){
this.selectedUserId.emit(userId);
}

}

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ToastrService } from 'ngx-toastr';
import { formatDate } from '@angular/common';
import { Component, OnInit } from '@angular/core';
import { OnChanges, SimpleChanges, Component, Input, OnInit } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { DATE_FORMAT } from 'src/environments/environment';
import * as entryActions from '../../../time-clock/store/entry.actions';
Expand All @@ -12,7 +12,10 @@ import * as moment from 'moment';
selector: 'app-time-range-form',
templateUrl: './time-range-form.component.html',
})
export class TimeRangeFormComponent implements OnInit {
export class TimeRangeFormComponent implements OnInit, OnChanges {

@Input() userId: string;

public reportForm: FormGroup;
private startDate = new FormControl('');
private endDate = new FormControl('');
Expand All @@ -27,6 +30,12 @@ export class TimeRangeFormComponent implements OnInit {
this.setInitialDataOnScreen();
}

ngOnChanges(changes: SimpleChanges){
if (!changes.userId.firstChange){
this.onSubmit();
}
}

setInitialDataOnScreen() {
this.reportForm.setValue({
startDate: formatDate(moment().startOf('week').format('l'), DATE_FORMAT, 'en'),
Expand All @@ -43,7 +52,7 @@ export class TimeRangeFormComponent implements OnInit {
this.store.dispatch(new entryActions.LoadEntriesByTimeRange({
start_date: moment(this.startDate.value).startOf('day'),
end_date: moment(this.endDate.value).endOf('day'),
}));
}, this.userId));
}
}
}
5 changes: 2 additions & 3 deletions src/app/modules/reports/pages/reports.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
<app-time-range-form></app-time-range-form>
<app-time-entries-table></app-time-entries-table>

<app-time-range-form [userId]="userId"></app-time-range-form>
<app-time-entries-table (selectedUserId)="user($event)"></app-time-entries-table>
6 changes: 6 additions & 0 deletions src/app/modules/reports/pages/reports.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@ import { Component } from '@angular/core';
styleUrls: ['./reports.component.scss']
})
export class ReportsComponent {

userId: string;

user(userId: string){
this.userId = userId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="form-group" >
<label>Users: </label>

<ng-select [(ngModel)]="selectedUser" placeholder="Select user" (change)="updateUser()" class="selectUser">
<ng-option *ngFor="let user of users" value={{user.id}}>👤{{user.name}}📨{{ user.email}}</ng-option >
</ng-select>

</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
label {
width: 225px;
}
.selectUser {
display: inline-block;
width: 350px;
padding: 0 12px 20px 12px;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Component, EventEmitter, Input, Output } from '@angular/core';

@Component({
selector: 'app-search-user',
templateUrl: './search-user.component.html',
styleUrls: ['./search-user.component.scss'],
})

export class SearchUserComponent {

readonly ALLOW_SELECT_MULTIPLE = true;
selectedUser: string;

@Input() users: string[] = [];

@Output() selectedUserId = new EventEmitter<string>();

updateUser() {
this.selectedUserId.emit(this.selectedUser || '*');
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class UsersListComponent implements OnInit, OnDestroy, AfterViewInit {
});

this.switchGroupsSubscription = this.filterUserGroup().subscribe((action) => {
this.store.dispatch(new LoadUsers());
this.store.dispatch(new LoadUsers());
});
}

Expand Down