From 697be3c610647d0a96ba7ca2ae30454739ae98f4 Mon Sep 17 00:00:00 2001 From: Art Lowel Date: Wed, 27 May 2020 18:17:37 +0200 Subject: [PATCH 1/6] fix issue with polyfill order in safari and firefox --- src/polyfills.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/polyfills.ts b/src/polyfills.ts index ca40a803ba..7f2198117b 100644 --- a/src/polyfills.ts +++ b/src/polyfills.ts @@ -55,7 +55,6 @@ /*************************************************************************************************** * Zone JS is required by default for Angular itself. */ -import 'zone.js/dist/zone'; // Included with Angular CLI. /*************************************************************************************************** * APPLICATION IMPORTS @@ -64,4 +63,6 @@ import 'zone.js/dist/zone'; // Included with Angular CLI. import 'core-js/es'; import 'core-js/features/reflect'; +import 'zone.js/dist/zone'; // Included with Angular CLI. + import 'reflect-metadata'; From bcb77c8dcc73b2fc8137b4a41f9eb68307b031a6 Mon Sep 17 00:00:00 2001 From: Art Lowel Date: Tue, 2 Jun 2020 09:21:19 +0200 Subject: [PATCH 2/6] remove comment about zone polyfill --- src/polyfills.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/polyfills.ts b/src/polyfills.ts index 7f2198117b..151f4a4c45 100644 --- a/src/polyfills.ts +++ b/src/polyfills.ts @@ -52,10 +52,6 @@ * */ -/*************************************************************************************************** - * Zone JS is required by default for Angular itself. - */ - /*************************************************************************************************** * APPLICATION IMPORTS */ From f8f0e5f14910fa792850525f252d5a679e99a240 Mon Sep 17 00:00:00 2001 From: Kristof De Langhe Date: Wed, 3 Jun 2020 10:54:29 +0200 Subject: [PATCH 3/6] 71174: FileSizePipe using filesize.js --- package.json | 1 + src/app/shared/utils/file-size-pipe.ts | 26 ++------------------------ yarn.lock | 5 +++++ 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index 4c6bd31cac..6944ef23bd 100644 --- a/package.json +++ b/package.json @@ -88,6 +88,7 @@ "express": "4.16.2", "fast-json-patch": "^2.0.7", "file-saver": "^1.3.8", + "filesize": "^6.1.0", "font-awesome": "4.7.0", "https": "1.0.0", "js-cookie": "2.2.0", diff --git a/src/app/shared/utils/file-size-pipe.ts b/src/app/shared/utils/file-size-pipe.ts index a796edb073..b5bdfbe789 100644 --- a/src/app/shared/utils/file-size-pipe.ts +++ b/src/app/shared/utils/file-size-pipe.ts @@ -1,4 +1,5 @@ import { Pipe, PipeTransform } from '@angular/core'; +import * as fileSize from 'filesize'; /* * Convert bytes into largest possible unit. @@ -12,30 +13,7 @@ import { Pipe, PipeTransform } from '@angular/core'; @Pipe({ name: 'dsFileSize' }) export class FileSizePipe implements PipeTransform { - - private units: string[] = [ - 'bytes', - 'KiB', - 'MiB', - 'GiB', - 'TiB', - 'PiB' - ]; - transform(bytes: number = 0, precision: number = 2): string { - let result: string; - if (isNaN(parseFloat(String(bytes))) || !isFinite(bytes)) { - result = '?'; - } else { - let unit = 0; - - while (bytes >= 1024) { - bytes /= 1024; - unit++; - } - - result = bytes.toFixed(+ precision) + ' ' + this.units[unit]; - } - return result; + return fileSize(bytes, { standard: 'iec', round: precision }); } } diff --git a/yarn.lock b/yarn.lock index 7bac684f7d..9ed7515f28 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4283,6 +4283,11 @@ filesize@^3.6.1: resolved "https://registry.yarnpkg.com/filesize/-/filesize-3.6.1.tgz#090bb3ee01b6f801a8a8be99d31710b3422bb317" integrity sha512-7KjR1vv6qnicaPMi1iiTcI85CyYwRO/PSFCu6SvqL8jN2Wjt/NIYQTFtFs7fSDCYOstUkEWIQGFUg5YZQfjlcg== +filesize@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/filesize/-/filesize-6.1.0.tgz#e81bdaa780e2451d714d71c0d7a4f3238d37ad00" + integrity sha512-LpCHtPQ3sFx67z+uh2HnSyWSLLu5Jxo21795uRDuar/EOuYWXib5EmPaGIBuSnRqH2IODiKA2k5re/K9OnN/Yg== + fill-range@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" From ce04825c4a028274a31cd7a3d01a38330a8fdf8a Mon Sep 17 00:00:00 2001 From: Kristof De Langhe Date: Wed, 10 Jun 2020 10:32:58 +0200 Subject: [PATCH 4/6] 71174: FileSizePipe 'jedec' standard --- src/app/shared/utils/file-size-pipe.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/shared/utils/file-size-pipe.ts b/src/app/shared/utils/file-size-pipe.ts index b5bdfbe789..2d219cdaf4 100644 --- a/src/app/shared/utils/file-size-pipe.ts +++ b/src/app/shared/utils/file-size-pipe.ts @@ -14,6 +14,6 @@ import * as fileSize from 'filesize'; @Pipe({ name: 'dsFileSize' }) export class FileSizePipe implements PipeTransform { transform(bytes: number = 0, precision: number = 2): string { - return fileSize(bytes, { standard: 'iec', round: precision }); + return fileSize(bytes, { standard: 'jedec', round: precision }); } } From 6bd04c94ec0aab592896ca88ed91cfc95a5ca9a6 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Thu, 11 Jun 2020 14:15:19 +0200 Subject: [PATCH 5/6] store token on AUTHENTICATED_SUCCESS action --- src/app/core/auth/auth.effects.spec.ts | 9 ++++++++- src/app/core/auth/auth.effects.ts | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/app/core/auth/auth.effects.spec.ts b/src/app/core/auth/auth.effects.spec.ts index c08615ecc9..98210b7b27 100644 --- a/src/app/core/auth/auth.effects.spec.ts +++ b/src/app/core/auth/auth.effects.spec.ts @@ -150,7 +150,8 @@ describe('AuthEffects', () => { describe('authenticatedSuccess$', () => { - it('should return a RETRIEVE_AUTHENTICATED_EPERSON action in response to a AUTHENTICATED_SUCCESS action', () => { + it('should not call removeToken method', (done) => { + spyOn((authEffects as any).authService, 'storeToken'); actions = hot('--a-', { a: { type: AuthActionTypes.AUTHENTICATED_SUCCESS, payload: { @@ -163,8 +164,14 @@ describe('AuthEffects', () => { const expected = cold('--b-', { b: new RetrieveAuthenticatedEpersonAction(EPersonMock._links.self.href) }); + authEffects.authenticatedSuccess$.subscribe(() => { + expect(authServiceStub.storeToken).toHaveBeenCalledWith(token); + }); + expect(authEffects.authenticatedSuccess$).toBeObservable(expected); + done(); }); + }); describe('checkToken$', () => { diff --git a/src/app/core/auth/auth.effects.ts b/src/app/core/auth/auth.effects.ts index c6d447961a..5591ffbe39 100644 --- a/src/app/core/auth/auth.effects.ts +++ b/src/app/core/auth/auth.effects.ts @@ -65,7 +65,6 @@ export class AuthEffects { @Effect() public authenticateSuccess$: Observable = this.actions$.pipe( ofType(AuthActionTypes.AUTHENTICATE_SUCCESS), - tap((action: AuthenticationSuccessAction) => this.authService.storeToken(action.payload)), map((action: AuthenticationSuccessAction) => new AuthenticatedAction(action.payload)) ); @@ -82,6 +81,7 @@ export class AuthEffects { @Effect() public authenticatedSuccess$: Observable = this.actions$.pipe( ofType(AuthActionTypes.AUTHENTICATED_SUCCESS), + tap((action: AuthenticatedSuccessAction) => this.authService.storeToken(action.payload.authToken)), map((action: AuthenticatedSuccessAction) => new RetrieveAuthenticatedEpersonAction(action.payload.userHref)) ); From c835d9b9c71bf95e5134cb404e98cdafe069b6a9 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Thu, 11 Jun 2020 14:44:42 +0200 Subject: [PATCH 6/6] fixed test description --- src/app/core/auth/auth.effects.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/core/auth/auth.effects.spec.ts b/src/app/core/auth/auth.effects.spec.ts index 98210b7b27..79fe385c6d 100644 --- a/src/app/core/auth/auth.effects.spec.ts +++ b/src/app/core/auth/auth.effects.spec.ts @@ -150,7 +150,7 @@ describe('AuthEffects', () => { describe('authenticatedSuccess$', () => { - it('should not call removeToken method', (done) => { + it('should return a RETRIEVE_AUTHENTICATED_EPERSON action in response to a AUTHENTICATED_SUCCESS action', (done) => { spyOn((authEffects as any).authService, 'storeToken'); actions = hot('--a-', { a: {