ACS-8404: consolidate application settings (#3952)

This commit is contained in:
Denys Vuika 2024-07-18 09:01:46 -04:00 committed by GitHub
parent 74384f09f8
commit 2ff54affb2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 132 additions and 182 deletions

View File

@ -39,8 +39,6 @@
"copyright": "APP.COPYRIGHT" "copyright": "APP.COPYRIGHT"
}, },
"viewer.maxRetries": 1, "viewer.maxRetries": 1,
"customCssPath": "",
"webFontPath": "",
"pagination": { "pagination": {
"size": 25, "size": 25,
"supportedPageSizes": [25, 50, 100] "supportedPageSizes": [25, 50, 100]

View File

@ -51,15 +51,8 @@ import localeSv from '@angular/common/locales/sv';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { AppComponent } from './app.components'; import { AppComponent } from './app.components';
import { import { ContentUrlService, CONTENT_LAYOUT_ROUTES, ContentServiceExtensionModule, CoreExtensionsModule } from '@alfresco/aca-content';
ContentUrlService,
INITIAL_APP_STATE,
CONTENT_LAYOUT_ROUTES,
ContentServiceExtensionModule,
CoreExtensionsModule
} from '@alfresco/aca-content';
import { ContentVersionService } from '@alfresco/adf-content-services'; import { ContentVersionService } from '@alfresco/adf-content-services';
import { STORE_INITIAL_APP_DATA } from '@alfresco/aca-shared/store';
import { ShellModule, SHELL_APP_SERVICE, SHELL_AUTH_TOKEN } from '@alfresco/adf-core/shell'; import { ShellModule, SHELL_APP_SERVICE, SHELL_AUTH_TOKEN } from '@alfresco/adf-core/shell';
import { StoreDevtoolsModule } from '@ngrx/store-devtools'; import { StoreDevtoolsModule } from '@ngrx/store-devtools';
import { APP_ROUTES } from './app.routes'; import { APP_ROUTES } from './app.routes';
@ -112,10 +105,6 @@ registerLocaleData(localeSv);
provide: SHELL_AUTH_TOKEN, provide: SHELL_AUTH_TOKEN,
useClass: AuthGuard useClass: AuthGuard
}, },
{
provide: STORE_INITIAL_APP_DATA,
useValue: INITIAL_APP_STATE
},
{ {
provide: TRANSLATION_PROVIDER, provide: TRANSLATION_PROVIDER,
multi: true, multi: true,

View File

@ -59,7 +59,7 @@ module.exports = () => {
global: { global: {
statements: 75, statements: 75,
branches: 67, branches: 67,
functions: 72, functions: 71,
lines: 74 lines: 74
} }
} }

View File

@ -30,14 +30,7 @@ import { BehaviorSubject, of, Subject } from 'rxjs';
import { NO_ERRORS_SCHEMA } from '@angular/core'; import { NO_ERRORS_SCHEMA } from '@angular/core';
import { DefaultProjectorFn, MemoizedSelector, Store } from '@ngrx/store'; import { DefaultProjectorFn, MemoizedSelector, Store } from '@ngrx/store';
import { ContentApiService } from '@alfresco/aca-shared'; import { ContentApiService } from '@alfresco/aca-shared';
import { import { AppStore, isInfoDrawerOpened, NavigateToFolder, NavigateToPreviousPage, SetSelectedNodesAction } from '@alfresco/aca-shared/store';
AppStore,
isInfoDrawerOpened,
NavigateToFolder,
NavigateToPreviousPage,
SetSelectedNodesAction,
STORE_INITIAL_APP_DATA
} from '@alfresco/aca-shared/store';
import { NodeEntry, PathElement } from '@alfresco/js-api'; import { NodeEntry, PathElement } from '@alfresco/js-api';
import { RouterTestingModule } from '@angular/router/testing'; import { RouterTestingModule } from '@angular/router/testing';
import { AuthenticationService, PageTitleService } from '@alfresco/adf-core'; import { AuthenticationService, PageTitleService } from '@alfresco/adf-core';
@ -86,10 +79,6 @@ describe('DetailsComponent', () => {
provide: PageTitleService, provide: PageTitleService,
useValue: {} useValue: {}
}, },
{
provide: STORE_INITIAL_APP_DATA,
useValue: {}
},
{ {
provide: AuthenticationService, provide: AuthenticationService,
useValue: { useValue: {

View File

@ -31,7 +31,6 @@ import {
NavigateToFolder, NavigateToFolder,
SetInfoDrawerPreviewStateAction, SetInfoDrawerPreviewStateAction,
SetInfoDrawerStateAction, SetInfoDrawerStateAction,
showFacetFilter,
ShowInfoDrawerPreviewAction, ShowInfoDrawerPreviewAction,
SnackbarErrorAction SnackbarErrorAction
} from '@alfresco/aca-shared/store'; } from '@alfresco/aca-shared/store';
@ -95,7 +94,6 @@ import { DocumentListPresetRef, DynamicColumnComponent } from '@alfresco/adf-ext
styleUrls: ['./search-results.component.scss'] styleUrls: ['./search-results.component.scss']
}) })
export class SearchResultsComponent extends PageComponent implements OnInit { export class SearchResultsComponent extends PageComponent implements OnInit {
showFacetFilter$ = this.store.select(showFacetFilter);
infoDrawerPreview$ = this.store.select(infoDrawerPreview); infoDrawerPreview$ = this.store.select(infoDrawerPreview);
searchedWord: string; searchedWord: string;

View File

@ -6,7 +6,7 @@
(click)="toggleNavBar.emit()" (click)="toggleNavBar.emit()"
(keypress)="toggleNavBar.emit()"> (keypress)="toggleNavBar.emit()">
<img <img
src="{{ logo$ | async }}" src="{{ logoUrl }}"
title="{{'APP.TOOLTIPS.COLLAPSE_NAVIGATION' | translate}}" title="{{'APP.TOOLTIPS.COLLAPSE_NAVIGATION' | translate}}"
alt="{{ 'CORE.HEADER.LOGO_ARIA' | translate }}" /> alt="{{ 'CORE.HEADER.LOGO_ARIA' | translate }}" />
</div> </div>
@ -15,7 +15,7 @@
class="aca-sidenav-header-title-text" class="aca-sidenav-header-title-text"
data-automation-id="app-sidenav-header-title-text" data-automation-id="app-sidenav-header-title-text"
[routerLink]="landingPage"> [routerLink]="landingPage">
{{ appName$ | async | translate }} {{ appName | translate }}
</div> </div>
<aca-toolbar [items]="actions"></aca-toolbar> <aca-toolbar [items]="actions"></aca-toolbar>

View File

@ -23,9 +23,7 @@
*/ */
import { Component, EventEmitter, inject, OnDestroy, OnInit, Output, ViewEncapsulation } from '@angular/core'; import { Component, EventEmitter, inject, OnDestroy, OnInit, Output, ViewEncapsulation } from '@angular/core';
import { Store } from '@ngrx/store';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { AppStore, getAppName, getLogoPath } from '@alfresco/aca-shared/store';
import { ContentActionRef } from '@alfresco/adf-extensions'; import { ContentActionRef } from '@alfresco/adf-extensions';
import { AppExtensionService, AppSettingsService, ToolbarComponent } from '@alfresco/aca-shared'; import { AppExtensionService, AppSettingsService, ToolbarComponent } from '@alfresco/aca-shared';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
@ -43,12 +41,11 @@ import { RouterModule } from '@angular/router';
}) })
export class SidenavHeaderComponent implements OnInit, OnDestroy { export class SidenavHeaderComponent implements OnInit, OnDestroy {
private onDestroy$ = new Subject<boolean>(); private onDestroy$ = new Subject<boolean>();
private store = inject<Store<AppStore>>(Store);
private appSettings = inject(AppSettingsService); private appSettings = inject(AppSettingsService);
private appExtensions = inject(AppExtensionService); private appExtensions = inject(AppExtensionService);
appName$ = this.store.select(getAppName); appName = this.appSettings.appName;
logo$ = this.store.select(getLogoPath); logoUrl = this.appSettings.appLogoUrl;
landingPage = this.appSettings.landingPage; landingPage = this.appSettings.landingPage;
actions: Array<ContentActionRef> = []; actions: Array<ContentActionRef> = [];

View File

@ -22,13 +22,12 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>. * from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { AppHookService, ContentApiService, NodePermissionService } from '@alfresco/aca-shared'; import { AppHookService, AppSettingsService, ContentApiService, NodePermissionService } from '@alfresco/aca-shared';
import { import {
AppStore, AppStore,
DeletedNodeInfo, DeletedNodeInfo,
DeleteStatus, DeleteStatus,
getAppSelection, getAppSelection,
getSharedUrl,
NavigateRouteAction, NavigateRouteAction,
NavigateToParentFolder, NavigateToParentFolder,
NodeInfo, NodeInfo,
@ -91,7 +90,8 @@ export class ContentManagementService {
private nodeAspectService: NodeAspectService, private nodeAspectService: NodeAspectService,
private appHookService: AppHookService, private appHookService: AppHookService,
private newVersionUploaderService: NewVersionUploaderService, private newVersionUploaderService: NewVersionUploaderService,
private router: Router private router: Router,
private appSettingsService: AppSettingsService
) {} ) {}
addFavorite(nodes: Array<NodeEntry>) { addFavorite(nodes: Array<NodeEntry>) {
@ -189,27 +189,24 @@ export class ContentManagementService {
} }
} }
openShareLinkDialog(node, focusedElementOnCloseSelector?: string) { openShareLinkDialog(node: any, focusedElementOnCloseSelector?: string) {
this.store const baseShareUrl = this.appSettingsService.baseShareUrl;
.select(getSharedUrl)
.pipe(take(1)) this.dialogRef
.subscribe((baseShareUrl) => { .open(ShareDialogComponent, {
this.dialogRef restoreFocus: true,
.open(ShareDialogComponent, { width: '600px',
restoreFocus: true, panelClass: 'adf-share-link-dialog',
width: '600px', data: {
panelClass: 'adf-share-link-dialog', node,
data: { baseShareUrl
node, }
baseShareUrl })
} .afterClosed()
}) .subscribe(() => {
.afterClosed() this.store.dispatch(new SetSelectedNodesAction([node]));
.subscribe(() => { this.appHookService.linksUnshared.next();
this.store.dispatch(new SetSelectedNodesAction([node])); this.focusAfterClose(focusedElementOnCloseSelector);
this.appHookService.linksUnshared.next();
this.focusAfterClose(focusedElementOnCloseSelector);
});
}); });
} }

View File

@ -22,43 +22,4 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>. * from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { AppState, AppStore } from '@alfresco/aca-shared/store'; export { INITIAL_STATE, INITIAL_APP_STATE } from '@alfresco/aca-shared/store';
export const INITIAL_APP_STATE: AppState = {
appName: 'Alfresco Content Application',
logoPath: 'assets/images/alfresco-logo-white.svg',
customCssPath: '',
webFontPath: '',
sharedUrl: '',
user: {
isAdmin: null,
id: null,
firstName: '',
lastName: ''
},
selection: {
nodes: [],
libraries: [],
isEmpty: true,
count: 0
},
navigation: {
currentFolder: null
},
currentNodeVersion: null,
infoDrawerOpened: false,
infoDrawerPreview: false,
infoDrawerMetadataAspect: '',
showFacetFilter: true,
fileUploadingDialog: true,
showLoader: false,
repository: {
status: {
isQuickShareEnabled: true
}
} as any
};
export const INITIAL_STATE: AppStore = {
app: INITIAL_APP_STATE
};

View File

@ -29,7 +29,6 @@ import {
SetUserProfileAction, SetUserProfileAction,
SetCurrentFolderAction, SetCurrentFolderAction,
SetCurrentUrlAction, SetCurrentUrlAction,
SetInitialStateAction,
SetSelectedNodesAction, SetSelectedNodesAction,
SetRepositoryInfoAction, SetRepositoryInfoAction,
SetInfoDrawerStateAction, SetInfoDrawerStateAction,
@ -38,17 +37,14 @@ import {
SetFileUploadingDialogAction, SetFileUploadingDialogAction,
SetInfoDrawerPreviewStateAction, SetInfoDrawerPreviewStateAction,
AppActionTypes, AppActionTypes,
ShowLoaderAction ShowLoaderAction,
INITIAL_APP_STATE
} from '@alfresco/aca-shared/store'; } from '@alfresco/aca-shared/store';
import { INITIAL_APP_STATE } from '../initial-state';
export function appReducer(state: AppState = INITIAL_APP_STATE, action: Action): AppState { export function appReducer(state: AppState = INITIAL_APP_STATE, action: Action): AppState {
let newState: AppState; let newState: AppState;
switch (action.type) { switch (action.type) {
case AppActionTypes.SetInitialState:
newState = { ...(action as SetInitialStateAction).payload };
break;
case NodeActionTypes.SetSelection: case NodeActionTypes.SetSelection:
newState = updateSelectedNodes(state, action as SetSelectedNodesAction); newState = updateSelectedNodes(state, action as SetSelectedNodesAction);
break; break;

View File

@ -44,7 +44,6 @@ import { INITIAL_STATE } from '../store/initial-state';
import { BehaviorSubject, Observable, Subject, of } from 'rxjs'; import { BehaviorSubject, Observable, Subject, of } from 'rxjs';
import { ContentManagementService } from '../services/content-management.service'; import { ContentManagementService } from '../services/content-management.service';
import { DocumentBasePageService } from '@alfresco/aca-shared'; import { DocumentBasePageService } from '@alfresco/aca-shared';
import { STORE_INITIAL_APP_DATA } from '@alfresco/aca-shared/store';
@NgModule({ @NgModule({
imports: [ imports: [
@ -100,10 +99,6 @@ import { STORE_INITIAL_APP_DATA } from '@alfresco/aca-shared/store';
{ {
provide: PageTitleService, provide: PageTitleService,
useValue: {} useValue: {}
},
{
provide: STORE_INITIAL_APP_DATA,
useValue: {}
} }
] ]
}) })

View File

@ -37,7 +37,6 @@ import {
getCurrentFolder, getCurrentFolder,
getAppSelection, getAppSelection,
isInfoDrawerOpened, isInfoDrawerOpened,
getSharedUrl,
ViewNodeAction, ViewNodeAction,
ViewNodeExtras, ViewNodeExtras,
SetSelectedNodesAction SetSelectedNodesAction
@ -60,7 +59,6 @@ export abstract class PageComponent implements OnInit, OnDestroy, OnChanges {
infoDrawerOpened$: Observable<boolean>; infoDrawerOpened$: Observable<boolean>;
node: Node; node: Node;
selection: SelectionState; selection: SelectionState;
sharedPreviewUrl$: Observable<string>;
actions: Array<ContentActionRef> = []; actions: Array<ContentActionRef> = [];
viewerToolbarActions: Array<ContentActionRef> = []; viewerToolbarActions: Array<ContentActionRef> = [];
canUpdateNode = false; canUpdateNode = false;
@ -89,7 +87,6 @@ export abstract class PageComponent implements OnInit, OnDestroy, OnChanges {
this.createActions = actions; this.createActions = actions;
}); });
this.sharedPreviewUrl$ = this.store.select(getSharedUrl);
this.infoDrawerOpened$ = this.store.select(isInfoDrawerOpened); this.infoDrawerOpened$ = this.store.select(isInfoDrawerOpened);
this.store this.store

View File

@ -51,4 +51,50 @@ export class AppSettingsService {
get mimeTypes(): AlfrescoMimeType[] { get mimeTypes(): AlfrescoMimeType[] {
return this.appConfig.get<AlfrescoMimeType[]>('mimeTypes', DefaultMimeTypes); return this.appConfig.get<AlfrescoMimeType[]>('mimeTypes', DefaultMimeTypes);
} }
/**
* Get the application name from the app settings.
*/
get appName(): string {
return this.appConfig.get<string>('application.name', 'Alfresco Content Application');
}
/**
* Get the application version from the app settings.
*/
get appVersion(): string {
return this.appConfig.get<string>('application.version', '1.0.0');
}
/**
* Get the application logo URL from the app settings.
*/
get appLogoUrl(): string {
return this.appConfig.get<string>('application.logo', 'assets/images/app-logo.svg');
}
/**
* Get the custom CSS stylesheet path from the app settings.
*/
get customCssPath(): string {
return this.appConfig.get<string>('customCssPath', '');
}
/**
* Get the custom web font path from the app settings.
*/
get webFontPath(): string {
return this.appConfig.get<string>('webFontPath', '');
}
/**
* Get the base share URL from the app settings.
*/
get baseShareUrl(): string {
let result = this.appConfig.get<string>('baseShareUrl', '');
if (!result.endsWith('/')) {
result += '/';
}
return result;
}
} }

View File

@ -45,7 +45,6 @@ import {
UploadService UploadService
} from '@alfresco/adf-content-services'; } from '@alfresco/adf-content-services';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { STORE_INITIAL_APP_DATA } from '../../../store/src/states/app.state';
import { provideMockStore } from '@ngrx/store/testing'; import { provideMockStore } from '@ngrx/store/testing';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { RouterTestingModule } from '@angular/router/testing'; import { RouterTestingModule } from '@angular/router/testing';
@ -53,9 +52,9 @@ import { RepositoryInfo, VersionInfo } from '@alfresco/js-api';
import { MatDialogModule } from '@angular/material/dialog'; import { MatDialogModule } from '@angular/material/dialog';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { SnackbarErrorAction } from '../../../store/src/actions/snackbar.actions';
import { ContentApiService } from './content-api.service'; import { ContentApiService } from './content-api.service';
import { SetRepositoryInfoAction, SetUserProfileAction } from '../../../store/src/actions/app.actions'; import { SetRepositoryInfoAction, SetUserProfileAction, SnackbarErrorAction } from '@alfresco/aca-shared/store';
import { AppSettingsService } from '@alfresco/aca-shared';
describe('AppService', () => { describe('AppService', () => {
let service: AppService; let service: AppService;
@ -68,6 +67,7 @@ describe('AppService', () => {
let contentApi: ContentApiService; let contentApi: ContentApiService;
let groupService: GroupService; let groupService: GroupService;
let preferencesService: UserPreferencesService; let preferencesService: UserPreferencesService;
let appSettingsService: AppSettingsService;
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
@ -99,10 +99,6 @@ describe('AppService', () => {
snapshot: {} snapshot: {}
} }
}, },
{
provide: STORE_INITIAL_APP_DATA,
useValue: {}
},
{ {
provide: AlfrescoApiService, provide: AlfrescoApiService,
useClass: AlfrescoApiServiceMock useClass: AlfrescoApiServiceMock
@ -121,6 +117,7 @@ describe('AppService', () => {
] ]
}); });
appSettingsService = TestBed.inject(AppSettingsService);
appConfig = TestBed.inject(AppConfigService); appConfig = TestBed.inject(AppConfigService);
auth = TestBed.inject(AuthenticationService); auth = TestBed.inject(AuthenticationService);
searchQueryBuilderService = TestBed.inject(SearchQueryBuilderService); searchQueryBuilderService = TestBed.inject(SearchQueryBuilderService);
@ -172,7 +169,7 @@ describe('AppService', () => {
await expect(resetToDefaults).toHaveBeenCalled(); await expect(resetToDefaults).toHaveBeenCalled();
}); });
it('should rase notification on share link error', () => { it('should raise notification on share link error', () => {
spyOn(store, 'select').and.returnValue(of('')); spyOn(store, 'select').and.returnValue(of(''));
service.init(); service.init();
const dispatch = spyOn(store, 'dispatch'); const dispatch = spyOn(store, 'dispatch');
@ -216,7 +213,7 @@ describe('AppService', () => {
it('should load custom css', () => { it('should load custom css', () => {
const appendChild = spyOn(document.head, 'appendChild'); const appendChild = spyOn(document.head, 'appendChild');
spyOn(store, 'select').and.returnValue(of('/custom.css')); spyOnProperty(appSettingsService, 'customCssPath').and.returnValue('/custom.css');
service.init(); service.init();
const cssLinkElement = document.createElement('link'); const cssLinkElement = document.createElement('link');

View File

@ -22,7 +22,7 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>. * from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { Inject, Injectable, OnDestroy } from '@angular/core'; import { Injectable, OnDestroy } from '@angular/core';
import { AuthenticationService, AppConfigService, AlfrescoApiService, PageTitleService, UserPreferencesService } from '@alfresco/adf-core'; import { AuthenticationService, AppConfigService, AlfrescoApiService, PageTitleService, UserPreferencesService } from '@alfresco/adf-core';
import { Observable, BehaviorSubject, Subject } from 'rxjs'; import { Observable, BehaviorSubject, Subject } from 'rxjs';
import { GroupService, SearchQueryBuilderService, SharedLinksApiService, UploadService, FileUploadErrorEvent } from '@alfresco/adf-content-services'; import { GroupService, SearchQueryBuilderService, SharedLinksApiService, UploadService, FileUploadErrorEvent } from '@alfresco/adf-content-services';
@ -30,14 +30,9 @@ import { OverlayContainer } from '@angular/cdk/overlay';
import { ActivatedRoute, ActivationEnd, NavigationStart, Router } from '@angular/router'; import { ActivatedRoute, ActivationEnd, NavigationStart, Router } from '@angular/router';
import { filter, map, tap } from 'rxjs/operators'; import { filter, map, tap } from 'rxjs/operators';
import { import {
AppState,
AppStore, AppStore,
CloseModalDialogsAction, CloseModalDialogsAction,
getCustomCssPath,
getCustomWebFontPath,
STORE_INITIAL_APP_DATA,
SetCurrentUrlAction, SetCurrentUrlAction,
SetInitialStateAction,
SetRepositoryInfoAction, SetRepositoryInfoAction,
SetUserProfileAction, SetUserProfileAction,
SnackbarErrorAction, SnackbarErrorAction,
@ -48,12 +43,14 @@ import { RouterExtensionService } from './router.extension.service';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { DiscoveryEntry, GroupEntry, Group } from '@alfresco/js-api'; import { DiscoveryEntry, GroupEntry, Group } from '@alfresco/js-api';
import { AcaMobileAppSwitcherService } from './aca-mobile-app-switcher.service'; import { AcaMobileAppSwitcherService } from './aca-mobile-app-switcher.service';
import { ShellAppService } from '@alfresco/adf-core/shell';
import { AppSettingsService } from './app-settings.service';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
// After moving shell to ADF to core, AppService will implement ShellAppService // After moving shell to ADF to core, AppService will implement ShellAppService
export class AppService implements OnDestroy { export class AppService implements ShellAppService, OnDestroy {
private ready: BehaviorSubject<boolean>; private ready: BehaviorSubject<boolean>;
ready$: Observable<boolean>; ready$: Observable<boolean>;
@ -89,9 +86,9 @@ export class AppService implements OnDestroy {
private sharedLinksApiService: SharedLinksApiService, private sharedLinksApiService: SharedLinksApiService,
private groupService: GroupService, private groupService: GroupService,
private overlayContainer: OverlayContainer, private overlayContainer: OverlayContainer,
@Inject(STORE_INITIAL_APP_DATA) private initialAppState: AppState,
searchQueryBuilderService: SearchQueryBuilderService, searchQueryBuilderService: SearchQueryBuilderService,
private acaMobileAppSwitcherService: AcaMobileAppSwitcherService private acaMobileAppSwitcherService: AcaMobileAppSwitcherService,
private appSettingsService: AppSettingsService
) { ) {
this.ready = new BehaviorSubject(this.authenticationService.isLoggedIn() || this.withCredentials); this.ready = new BehaviorSubject(this.authenticationService.isLoggedIn() || this.withCredentials);
this.ready$ = this.ready.asObservable(); this.ready$ = this.ready.asObservable();
@ -137,8 +134,6 @@ export class AppService implements OnDestroy {
} }
}); });
this.loadAppSettings();
this.loadCustomCss(); this.loadCustomCss();
this.loadCustomWebFont(); this.loadCustomWebFont();
@ -202,24 +197,6 @@ export class AppService implements OnDestroy {
}); });
} }
loadAppSettings() {
let baseShareUrl = this.config.get<string>('baseShareUrl', '');
if (!baseShareUrl.endsWith('/')) {
baseShareUrl += '/';
}
const state: AppState = {
...this.initialAppState,
appName: this.config.get<string>('application.name'),
logoPath: this.config.get<string>('application.logo'),
customCssPath: this.config.get<string>('customCssPath'),
webFontPath: this.config.get<string>('webFontPath'),
sharedUrl: baseShareUrl
};
this.store.dispatch(new SetInitialStateAction(state));
}
onFileUploadedError(error: FileUploadErrorEvent) { onFileUploadedError(error: FileUploadErrorEvent) {
let message = 'APP.MESSAGES.UPLOAD.ERROR.GENERIC'; let message = 'APP.MESSAGES.UPLOAD.ERROR.GENERIC';
@ -247,19 +224,17 @@ export class AppService implements OnDestroy {
} }
private loadCustomCss(): void { private loadCustomCss(): void {
this.store.select(getCustomCssPath).subscribe((cssPath) => { const customCssPath = this.appSettingsService.customCssPath;
if (cssPath) { if (customCssPath) {
this.createLink(cssPath); this.createLink(customCssPath);
} }
});
} }
private loadCustomWebFont(): void { private loadCustomWebFont(): void {
this.store.select(getCustomWebFontPath).subscribe((fontUrl) => { const webFontPath = this.appSettingsService.webFontPath;
if (fontUrl) { if (webFontPath) {
this.createLink(fontUrl); this.createLink(webFontPath);
} }
});
} }
private createLink(url: string): void { private createLink(url: string): void {

View File

@ -23,7 +23,6 @@
*/ */
export enum AppActionTypes { export enum AppActionTypes {
SetInitialState = 'SET_INITIAL_STATE',
SetCurrentFolder = 'SET_CURRENT_FOLDER', SetCurrentFolder = 'SET_CURRENT_FOLDER',
SetCurrentVersion = 'SET_CURRENT_VERSION', SetCurrentVersion = 'SET_CURRENT_VERSION',
SetCurrentUrl = 'SET_CURRENT_URL', SetCurrentUrl = 'SET_CURRENT_URL',

View File

@ -24,15 +24,8 @@
import { Action } from '@ngrx/store'; import { Action } from '@ngrx/store';
import { Node, Person, Group, RepositoryInfo, VersionEntry } from '@alfresco/js-api'; import { Node, Person, Group, RepositoryInfo, VersionEntry } from '@alfresco/js-api';
import { AppState } from '../states/app.state';
import { AppActionTypes } from './app-action-types'; import { AppActionTypes } from './app-action-types';
export class SetInitialStateAction implements Action {
readonly type = AppActionTypes.SetInitialState;
constructor(public payload: AppState) {}
}
export class SetCurrentFolderAction implements Action { export class SetCurrentFolderAction implements Action {
readonly type = AppActionTypes.SetCurrentFolder; readonly type = AppActionTypes.SetCurrentFolder;

View File

@ -28,19 +28,13 @@ import { createSelector } from '@ngrx/store';
const HXI_CONNECTOR = 'alfresco-hxinsight-connector-prediction-applier-extension'; const HXI_CONNECTOR = 'alfresco-hxinsight-connector-prediction-applier-extension';
export const selectApp = (state: AppStore) => state.app; export const selectApp = (state: AppStore) => state.app;
export const getAppName = createSelector(selectApp, (state) => state.appName);
export const getLogoPath = createSelector(selectApp, (state) => state.logoPath);
export const getCustomCssPath = createSelector(selectApp, (state) => state.customCssPath);
export const getCustomWebFontPath = createSelector(selectApp, (state) => state.webFontPath);
export const getUserProfile = createSelector(selectApp, (state) => state.user); export const getUserProfile = createSelector(selectApp, (state) => state.user);
export const getCurrentFolder = createSelector(selectApp, (state) => state.navigation.currentFolder); export const getCurrentFolder = createSelector(selectApp, (state) => state.navigation.currentFolder);
export const getCurrentVersion = createSelector(selectApp, (state) => state.currentNodeVersion); export const getCurrentVersion = createSelector(selectApp, (state) => state.currentNodeVersion);
export const getAppSelection = createSelector(selectApp, (state) => state.selection); export const getAppSelection = createSelector(selectApp, (state) => state.selection);
export const getSharedUrl = createSelector(selectApp, (state) => state.sharedUrl);
export const getNavigationState = createSelector(selectApp, (state) => state.navigation); export const getNavigationState = createSelector(selectApp, (state) => state.navigation);
export const isInfoDrawerOpened = createSelector(selectApp, (state) => state.infoDrawerOpened); export const isInfoDrawerOpened = createSelector(selectApp, (state) => state.infoDrawerOpened);
export const infoDrawerPreview = createSelector(selectApp, (state) => state.infoDrawerPreview); export const infoDrawerPreview = createSelector(selectApp, (state) => state.infoDrawerPreview);
export const showFacetFilter = createSelector(selectApp, (state) => state.showFacetFilter);
export const getRepositoryStatus = createSelector(selectApp, (state) => state.repository); export const getRepositoryStatus = createSelector(selectApp, (state) => state.repository);
export const isQuickShareEnabled = createSelector(getRepositoryStatus, (info) => info.status.isQuickShareEnabled); export const isQuickShareEnabled = createSelector(getRepositoryStatus, (info) => info.status.isQuickShareEnabled);
export const isHXIConnectorEnabled = createSelector(getRepositoryStatus, (info) => !!info?.modules?.find((module) => module.id === HXI_CONNECTOR)); export const isHXIConnectorEnabled = createSelector(getRepositoryStatus, (info) => !!info?.modules?.find((module) => module.id === HXI_CONNECTOR));

View File

@ -26,14 +26,44 @@ import { SelectionState, ProfileState, NavigationState } from '@alfresco/adf-ext
import { RepositoryInfo, VersionEntry } from '@alfresco/js-api'; import { RepositoryInfo, VersionEntry } from '@alfresco/js-api';
import { InjectionToken } from '@angular/core'; import { InjectionToken } from '@angular/core';
/** @deprecated no longer used */
export const STORE_INITIAL_APP_DATA = new InjectionToken<AppState>('STORE_INITIAL_APP_DATA'); export const STORE_INITIAL_APP_DATA = new InjectionToken<AppState>('STORE_INITIAL_APP_DATA');
export const INITIAL_APP_STATE: AppState = {
user: {
isAdmin: null,
id: null,
firstName: '',
lastName: ''
},
selection: {
nodes: [],
libraries: [],
isEmpty: true,
count: 0
},
navigation: {
currentFolder: null
},
currentNodeVersion: null,
infoDrawerOpened: false,
infoDrawerPreview: false,
infoDrawerMetadataAspect: '',
fileUploadingDialog: true,
showLoader: false,
repository: {
status: {
isQuickShareEnabled: true
}
} as any
};
/** @deprecated no longer used */
export const INITIAL_STATE: AppStore = {
app: INITIAL_APP_STATE
};
export interface AppState { export interface AppState {
appName: string;
logoPath: string;
customCssPath: string;
webFontPath: string;
sharedUrl: string;
currentNodeVersion: VersionEntry; currentNodeVersion: VersionEntry;
selection: SelectionState; selection: SelectionState;
user: ProfileState; user: ProfileState;
@ -41,7 +71,6 @@ export interface AppState {
infoDrawerOpened: boolean; infoDrawerOpened: boolean;
infoDrawerPreview: boolean; infoDrawerPreview: boolean;
infoDrawerMetadataAspect: string; infoDrawerMetadataAspect: string;
showFacetFilter: boolean;
repository: RepositoryInfo; repository: RepositoryInfo;
fileUploadingDialog: boolean; fileUploadingDialog: boolean;
showLoader: boolean; showLoader: boolean;