From 8ff86a76b3747941ff9cfdfc008150741554a673 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Thu, 28 Feb 2019 11:48:52 +0000 Subject: [PATCH 1/6] fix baseShareUrl defaults --- src/app.config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app.config.json b/src/app.config.json index ae20341516..220018546d 100644 --- a/src/app.config.json +++ b/src/app.config.json @@ -1,7 +1,7 @@ { "ecmHost": "{protocol}//{hostname}{:port}", "aosHost": "{protocol}//{hostname}{:port}/alfresco/aos", - "baseShareUrl": null, + "baseShareUrl": "{protocol}//{hostname}{:port}", "providers": "ECM", "authType": "BASIC", "oauth2": { From 6d7f8dfdc220543b68e531ee738db83b94f1d7cf Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Thu, 28 Feb 2019 11:58:16 +0000 Subject: [PATCH 2/6] allow controlling full path --- src/app.config.json | 2 +- src/app/app.component.ts | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/app.config.json b/src/app.config.json index 220018546d..d1c7c9f7ce 100644 --- a/src/app.config.json +++ b/src/app.config.json @@ -1,7 +1,7 @@ { "ecmHost": "{protocol}//{hostname}{:port}", "aosHost": "{protocol}//{hostname}{:port}/alfresco/aos", - "baseShareUrl": "{protocol}//{hostname}{:port}", + "baseShareUrl": "{protocol}//{hostname}{:port}/#/preview/s", "providers": "ECM", "authType": "BASIC", "oauth2": { diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 074cb5b995..f87ebe7a0c 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -148,9 +148,10 @@ export class AppComponent implements OnInit, OnDestroy { } private loadAppSettings() { - const baseShareUrl = - this.config.get('baseShareUrl') || - this.config.get('ecmHost'); + let baseShareUrl = this.config.get('baseShareUrl'); + if (!baseShareUrl.endsWith('/')) { + baseShareUrl += '/'; + } const state: AppState = { ...INITIAL_APP_STATE, @@ -158,7 +159,7 @@ export class AppComponent implements OnInit, OnDestroy { appName: this.config.get('application.name'), headerColor: this.config.get('headerColor'), logoPath: this.config.get('application.logo'), - sharedUrl: `${baseShareUrl}/#/preview/s/` + sharedUrl: baseShareUrl }; this.store.dispatch(new SetInitialStateAction(state)); From 379fa68d32be3bfc5175b36b1c90f8309497bb41 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Thu, 28 Feb 2019 12:29:22 +0000 Subject: [PATCH 3/6] unit test --- src/app/app.component.spec.ts | 46 ++++++++++++++++++++++++++--------- src/app/app.component.ts | 2 +- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index a99d54b51c..de211cebb6 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -24,20 +24,31 @@ */ import { AppComponent } from './app.component'; +import { SetInitialStateAction } from './store/actions'; describe('AppComponent', () => { - let component; - const storeMock = { + let component: AppComponent; + + const storeMock: any = { dispatch: jasmine.createSpy('dispatch') }; + const configMock: any = { + get: (key: string) => { + if (key === 'baseShareUrl') { + return 'http://localhost:4200//#/preview/s'; + } + return null; + } + }; + beforeAll(() => { component = new AppComponent( null, null, null, storeMock, - null, + configMock, null, null, null, @@ -47,48 +58,59 @@ describe('AppComponent', () => { ); }); - describe('onFileUploadedError', () => { - afterEach(() => { - storeMock.dispatch['calls'].reset(); + beforeEach(() => { + storeMock.dispatch = jasmine.createSpy('dispatch'); + }); + + it('should setup baseShareUrl as per config', done => { + storeMock.dispatch.and.callFake((action: SetInitialStateAction) => { + expect(action.payload.sharedUrl).toBe( + 'http://localhost:4200//#/preview/s/' + ); + done(); }); + component.loadAppSettings(); + }); + + describe('onFileUploadedError', () => { it('should dispatch 403 error message', () => { - component.onFileUploadedError({ error: { status: 403 } }); + component.onFileUploadedError({ error: { status: 403 } }); expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe( 'APP.MESSAGES.UPLOAD.ERROR.403' ); }); it('should dispatch 404 error message', () => { - component.onFileUploadedError({ error: { status: 404 } }); + component.onFileUploadedError({ error: { status: 404 } }); expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe( 'APP.MESSAGES.UPLOAD.ERROR.404' ); }); it('should dispatch 409 error message', () => { - component.onFileUploadedError({ error: { status: 409 } }); + component.onFileUploadedError({ error: { status: 409 } }); expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe( 'APP.MESSAGES.UPLOAD.ERROR.CONFLICT' ); }); it('should dispatch 500 error message', () => { - component.onFileUploadedError({ error: { status: 500 } }); + component.onFileUploadedError({ error: { status: 500 } }); expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe( 'APP.MESSAGES.UPLOAD.ERROR.500' ); }); it('should dispatch 504 error message', () => { - component.onFileUploadedError({ error: { status: 504 } }); + component.onFileUploadedError({ error: { status: 504 } }); expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe( 'APP.MESSAGES.UPLOAD.ERROR.504' ); }); it('should dispatch generic error message', () => { - component.onFileUploadedError({ error: { status: 999 } }); + component.onFileUploadedError({ error: { status: 999 } }); expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe( 'APP.MESSAGES.UPLOAD.ERROR.GENERIC' ); diff --git a/src/app/app.component.ts b/src/app/app.component.ts index f87ebe7a0c..46fb743185 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -147,7 +147,7 @@ export class AppComponent implements OnInit, OnDestroy { }); } - private loadAppSettings() { + loadAppSettings() { let baseShareUrl = this.config.get('baseShareUrl'); if (!baseShareUrl.endsWith('/')) { baseShareUrl += '/'; From 7aba335d5866d27ef1ad58249169f8b05794993f Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Thu, 28 Feb 2019 15:24:09 +0000 Subject: [PATCH 4/6] update tomcat settings --- build-tomcat-e2e.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-tomcat-e2e.sh b/build-tomcat-e2e.sh index 10ac86f0f0..72d2f9d753 100755 --- a/build-tomcat-e2e.sh +++ b/build-tomcat-e2e.sh @@ -3,7 +3,7 @@ npm run build.e2e -- --base-href ./ node -e " const fs = require('fs'); const config = require('./dist/app/app.config.json'); -config.baseShareUrl = 'http://localhost:4000/content-app'; +config.baseShareUrl = 'http://localhost:4000/content-app/#/preview/s/'; fs.writeFileSync( './dist/app/app.config.json', JSON.stringify(config, null, 2) From 2f1f0016e3455af6c8a3c060e3448519647100ae Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Thu, 28 Feb 2019 15:44:38 +0000 Subject: [PATCH 5/6] use single slash --- src/app/app.component.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index de211cebb6..601a631884 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -36,7 +36,7 @@ describe('AppComponent', () => { const configMock: any = { get: (key: string) => { if (key === 'baseShareUrl') { - return 'http://localhost:4200//#/preview/s'; + return 'http://localhost:4200/#/preview/s'; } return null; } @@ -65,7 +65,7 @@ describe('AppComponent', () => { it('should setup baseShareUrl as per config', done => { storeMock.dispatch.and.callFake((action: SetInitialStateAction) => { expect(action.payload.sharedUrl).toBe( - 'http://localhost:4200//#/preview/s/' + 'http://localhost:4200/#/preview/s/' ); done(); }); From e2b5fb899843443ac8eff802ea5edf402aca887b Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Thu, 28 Feb 2019 15:55:10 +0000 Subject: [PATCH 6/6] simplify documentation --- docs/getting-started/configuration.md | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/docs/getting-started/configuration.md b/docs/getting-started/configuration.md index fe039187f0..75204baa05 100644 --- a/docs/getting-started/configuration.md +++ b/docs/getting-started/configuration.md @@ -49,32 +49,12 @@ Alternatively, you can provide a static address for the ACS server if necessary: The "baseShareUrl" property tells the application how to construct the address where users will access shared files. -#### Default - -When the default value is set the application will construct the File Share URL from the "ecmHost" property: - ```json { - ... - "baseShareUrl": null, - ... + "baseShareUrl": "{protocol}//{hostname}{:port}/#/preview/s" } ``` -#### Configuration - -If you run the application from a different server than the Content Services server the "baseShareUrl" property should must be configured correctly, for example: - -```json -{ - ... - "baseShareUrl": "http://{serveraddress}{:port}", - ... -} -``` - -**Note:** If you run the application as part of Tomcat and not in the root (subfolder), then "baseShareUrl" value should contain full address to the app, for example: "baseShareUrl": "http://{serveraddress}{:port}/{folder}". - ## Application settings There are many settings you can change to alter the default behavior of the application. @@ -104,7 +84,6 @@ The default logo displayed in the top left corner of the Alfresco Content Applic 2. In the app.config.json file, set the value of the application.logo to contain the name of the custom logo image: "logo": "/assets/images/[image-name].[extension]" - ```json { ...,