Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
2a85d69
refactor: TTA-180 change Client URL for Auth URL
Oct 5, 2022
3c9764b
TTA-180: fixing endpoints to send credentials
reihtw Oct 6, 2022
2e694fb
refactor: TTA-115 refactor backend URL for dev
Oct 6, 2022
a78dbf4
refactor: TTA-115 pass the environment auth variable link to the a tag
Oct 7, 2022
12c9efd
fix: TTA-115 fix error Type 'string' is not assignable to type 'void …
Oct 7, 2022
0d6d4ab
feat: TTA-180 creating logout
reihtw Oct 11, 2022
6c09fce
fix: TTA-180 fixing tests
Oct 13, 2022
7e680fb
fix: TTA-180 fixing environment variables
Oct 14, 2022
7e358e2
fix: TTA-180 fixing environment variables
Oct 14, 2022
7c5b242
fix: TTA-180 fixing environment variables
Oct 14, 2022
1dc6a4a
fix: TTA-180 fixing environment variables
Oct 14, 2022
fa24348
fix: TTA-180 fixing environment variables
Oct 14, 2022
88c5313
fix: TTA-180 fixing environment variables
Oct 14, 2022
97cffc0
feat: TTA-180 updating README.md
Oct 14, 2022
ed0056b
fix: TTA-180 removing unused variables
Oct 19, 2022
17e5932
fix: TTA-180 increasing test coveragew
Oct 19, 2022
342aa8a
fix: TTA-180 increasing test coveragew
Oct 19, 2022
8f50329
fix: TTA-180 CR fixes
Oct 20, 2022
033eb86
config: TTA-180 added secrets for stage and prod
andresacg30 Oct 24, 2022
8d1bd76
fix: TTA-181 change husky hint when commit message is wrong (#937)
mmaquina Oct 5, 2022
c37c815
chore(release): 1.75.21 [skip ci]nn
semantic-release-bot Oct 5, 2022
faff696
fix: TTA 183 get summary returns 404 at begginning of the month (#938)
nicolsss Oct 6, 2022
26722ef
chore(release): 1.75.22 [skip ci]nn
semantic-release-bot Oct 6, 2022
ef0e2be
Update README.md
mmaquina Oct 7, 2022
d702df0
Update README.md
mmaquina Oct 7, 2022
21c261b
fix: Tta 193 add loading page to new ip check load time (#939)
andresacg30 Oct 17, 2022
b3d2e44
chore(release): 1.75.24 [skip ci]nn
semantic-release-bot Oct 21, 2022
cbef44b
adding Andres Cabrera ppk to STAGE secrets
rodolfoIOET Oct 21, 2022
26e53ab
adding Andres Cabrera ppk to PROD secrets
rodolfoIOET Oct 21, 2022
11a8950
Added secrets for auth app on stage and prod
andresacg30 Oct 24, 2022
ddd131b
Revert "Tta 180 integrate time tracker with auth app (#940)" (#942)
andresacg30 Oct 24, 2022
14c2fde
revert adding stage and prod envs
andresacg30 Oct 24, 2022
1fc5b78
config: TTA-180 added secrets for stage and prod
andresacg30 Oct 24, 2022
7193ce1
Tta 180 integrate time tracker with auth app (#940)
Oct 21, 2022
5cf09eb
Added secrets for auth app on stage and prod
andresacg30 Oct 24, 2022
337e2e1
update env variables
andresacg30 Oct 24, 2022
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
Prev Previous commit
Next Next commit
fix: Tta 193 add loading page to new ip check load time (#939)
* feat: TTA-193 add preload page

* fix: TTA-181 change husky hint when commit message is wrong (#937)

Co-authored-by: mmaquina <[email protected]>

* chore(release): 1.75.21 [skip ci]nn

* feat: TTA-193 add service and interceptor for spinner loading

* feat: TTA-193 add spinner overlay and style it

* test: TTA-193 make test

* update package-lock.json version

* test: add test for interceptor and service

* test: TTA-193 increase code coverage

* test: TTA-193 increase code coverage

* fix: spinner test

* fix: spinner test

* fix: load spinner when route is recent

Co-authored-by: mmaquina <[email protected]>
Co-authored-by: mmaquina <[email protected]>
Co-authored-by: semantic-release-bot <[email protected]>
Co-authored-by: Andres Cabrera <andres@MSI>
Co-authored-by: Nicole Garcia <nicolsss>
  • Loading branch information
5 people committed Oct 24, 2022
commit 21c261b4d509fbe8f79424a29ca08d311454ebca
33,037 changes: 32,881 additions & 156 deletions package-lock.json

Large diffs are not rendered by default.

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.75.22",
"version": "1.75.24",
"scripts": {
"preinstall": "npx npm-force-resolutions",
"ng": "ng",
Expand Down
2 changes: 1 addition & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<router-outlet></router-outlet>
<router-outlet></router-outlet>
13 changes: 12 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ToastrModule } from 'ngx-toastr';
import { CommonModule, DatePipe } from '@angular/common';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule, Component } from '@angular/core';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { DataTablesModule } from 'angular-datatables';
Expand All @@ -14,6 +14,8 @@ import { DragDropModule } from '@angular/cdk/drag-drop';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { MatInputModule } from '@angular/material/input';
import { MatButtonModule } from '@angular/material/button';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MatIconModule } from '@angular/material/icon';
import { MatListModule } from '@angular/material/list';
import { MatMomentDateModule } from '@angular/material-moment-adapter';
Expand Down Expand Up @@ -95,6 +97,8 @@ import { SearchUserComponent } from './modules/shared/components/search-user/sea
import { TimeRangeCustomComponent } from './modules/reports/components/time-range-custom/time-range-custom.component';
import { TimeRangeHeaderComponent } from './modules/reports/components/time-range-custom/time-range-header/time-range-header.component';
import { TimeRangeOptionsComponent } from './modules/reports/components/time-range-custom/time-range-options/time-range-options.component';
import { SpinnerOverlayComponent } from './modules/shared/components/spinner-overlay/spinner-overlay.component';
import { SpinnerInterceptor } from './modules/shared/interceptors/spinner.interceptor';

const maskConfig: Partial<IConfig> = {
validation: false,
Expand Down Expand Up @@ -154,6 +158,7 @@ const maskConfig: Partial<IConfig> = {
TimeRangeCustomComponent,
TimeRangeHeaderComponent,
TimeRangeOptionsComponent,
SpinnerOverlayComponent,
],
imports: [
NgxMaskModule.forRoot(maskConfig),
Expand All @@ -172,6 +177,7 @@ const maskConfig: Partial<IConfig> = {
DataTablesModule,
AutocompleteLibModule,
NgxMaterialTimepickerModule,
MatProgressSpinnerModule,
UiSwitchModule,
DragDropModule,
MatIconModule,
Expand Down Expand Up @@ -206,6 +212,11 @@ const maskConfig: Partial<IConfig> = {
useClass: InjectTokenInterceptor,
multi: true,
},
{
provide: HTTP_INTERCEPTORS,
useClass: SpinnerInterceptor,
multi: true,
},
DatePipe,
CookieService,
{provide: Window, useValue: window}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@use "../../../../../styles/colors.scss" as colors;

:host ::ng-deep .mat-progress-spinner circle, .mat-spinner circle {
stroke: colors.$warning;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { SpinnerOverlayComponent } from './spinner-overlay.component';

describe('SpinnerOverlayComponent', () => {
let component: SpinnerOverlayComponent;
let fixture: ComponentFixture<SpinnerOverlayComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ SpinnerOverlayComponent ]
})
.compileComponents();

fixture = TestBed.createComponent(SpinnerOverlayComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Component } from '@angular/core';

@Component({
selector: 'app-spinner-overlay',
template: '<mat-spinner diameter="80"></mat-spinner>',
styleUrls: ['./spinner-overlay.component.scss'],
})

export class SpinnerOverlayComponent {
constructor() {}
}
49 changes: 49 additions & 0 deletions src/app/modules/shared/interceptors/spinner.interceptor.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@


import { Overlay } from '@angular/cdk/overlay';
import { TestBed } from '@angular/core/testing';
import { SpinnerInterceptor } from './spinner.interceptor';
import { HttpHandler, HttpRequest, HttpResponse, HttpEvent } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { SpinnerOverlayService } from '../services/spinner-overlay.service';


describe('SpinnerInterceptorService test', () => {
TestBed.configureTestingModule({
providers: [
SpinnerInterceptor,
Overlay
],
});

class MockHttpHandler implements HttpHandler {
handle(req: HttpRequest<any>): Observable<HttpEvent<any>> {
return of(new HttpResponse());
}
}

let overlay: Overlay;
let httpHandler: HttpHandler;
let spinnerInterceptor: SpinnerInterceptor;

beforeEach(() => {
overlay = jasmine.createSpyObj('Overlay', ['create']);
httpHandler = new MockHttpHandler();
spinnerInterceptor = new SpinnerInterceptor(new SpinnerOverlayService(overlay));
});

it('should be created', () => {
expect(spinnerInterceptor).toBeTruthy();
});

it('if request is made then spinnerInterceptor is called', () => {
const request = new HttpRequest('GET', '/recent');
spyOn(spinnerInterceptor, 'intercept');

spinnerInterceptor.intercept(request, httpHandler);

expect(spinnerInterceptor.intercept).toHaveBeenCalledWith(request, httpHandler);

});

});
30 changes: 30 additions & 0 deletions src/app/modules/shared/interceptors/spinner.interceptor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {
HttpEvent,
HttpHandler,
HttpInterceptor,
HttpRequest,
} from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable, Subscription } from 'rxjs';
import { finalize } from 'rxjs/operators';
import { SpinnerOverlayService } from '../services/spinner-overlay.service';

@Injectable()
export class SpinnerInterceptor implements HttpInterceptor {
constructor(private readonly spinnerOverlayService: SpinnerOverlayService) {}

intercept(
req: HttpRequest<any>,
next: HttpHandler
): Observable<HttpEvent<any>> {
if(req.url.endsWith('recent')){
const spinnerSubscription: Subscription = this.spinnerOverlayService.spinner$.subscribe();
return next
.handle(req)
.pipe(finalize(() => spinnerSubscription.unsubscribe()));
}else{
return next.handle(req);
}

}
}
66 changes: 66 additions & 0 deletions src/app/modules/shared/services/spinner-overlay.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { TestBed } from '@angular/core/testing';
import { Overlay } from '@angular/cdk/overlay';

import { SpinnerOverlayService } from './spinner-overlay.service';
import { SpinnerInterceptor } from '../interceptors/spinner.interceptor';
import { HttpEvent, HttpHandler, HttpRequest, HttpResponse, HTTP_INTERCEPTORS } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { ComponentPortal } from 'ngx-toastr';


describe('SpinnerOverlayService test', () => {

class MockHttpHandler extends HttpHandler {
handle(req: HttpRequest<any>): Observable<HttpEvent<any>> {
return of(new HttpResponse());
}
}

let spinnerService: SpinnerOverlayService;
let spinnerInterceptor: SpinnerInterceptor;
let mockHttpHandler: HttpHandler;
let overlayRef: any;

beforeEach(() => {
TestBed.configureTestingModule({
providers: [
Overlay,
SpinnerInterceptor,
{
provide: HTTP_INTERCEPTORS,
useClass: SpinnerInterceptor,
multi: true,
},
],
});
spinnerService = TestBed.inject(SpinnerOverlayService);
spinnerInterceptor = TestBed.inject(SpinnerInterceptor);
mockHttpHandler = new MockHttpHandler();
overlayRef = spinnerService.overlayRef;
});

it('should be created', () => {
expect(spinnerService).toBeTruthy();
});

it('if request is made then spinnerService is show', () => {
const request = new HttpRequest('GET', '/recent');
spyOn(spinnerService, 'show');

spinnerInterceptor.intercept(request, mockHttpHandler);

expect(spinnerService.show).toHaveBeenCalled();
expect(ComponentPortal).toBeTruthy();
});


it('if hide calls detach method of overlayRef and then sets it to undefined', () => {
spyOn(spinnerService, 'hide');

spinnerService.hide();

expect(spinnerService.hide).toHaveBeenCalled();
expect(overlayRef).toBeUndefined();
});

});
44 changes: 44 additions & 0 deletions src/app/modules/shared/services/spinner-overlay.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Overlay, OverlayRef } from '@angular/cdk/overlay';
import { ComponentPortal } from '@angular/cdk/portal';
import { Injectable } from '@angular/core';
import { defer, NEVER } from 'rxjs';
import { finalize, share } from 'rxjs/operators';
import { SpinnerOverlayComponent } from './../components/spinner-overlay/spinner-overlay.component';

@Injectable({
providedIn: 'root',
})
export class SpinnerOverlayService {
public overlayRef: OverlayRef = undefined;
static spinner$: any;

constructor(private readonly overlay: Overlay) {}

public readonly spinner$ = defer(() => {
this.show();
return NEVER.pipe(
finalize(() => {
this.hide();
})
);
}).pipe(share());

public show(): void {
Promise.resolve(null).then(() => {
this.overlayRef = this.overlay.create({
positionStrategy: this.overlay
.position()
.global()
.centerHorizontally()
.centerVertically(),
hasBackdrop: true,
});
this.overlayRef.attach(new ComponentPortal(SpinnerOverlayComponent));
});
}

public hide(): void {
this.overlayRef.detach();
this.overlayRef = undefined;
}
}