mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
ACS-8404: consolidate application settings (#3952)
This commit is contained in:
@@ -37,7 +37,6 @@ import {
|
||||
getCurrentFolder,
|
||||
getAppSelection,
|
||||
isInfoDrawerOpened,
|
||||
getSharedUrl,
|
||||
ViewNodeAction,
|
||||
ViewNodeExtras,
|
||||
SetSelectedNodesAction
|
||||
@@ -60,7 +59,6 @@ export abstract class PageComponent implements OnInit, OnDestroy, OnChanges {
|
||||
infoDrawerOpened$: Observable<boolean>;
|
||||
node: Node;
|
||||
selection: SelectionState;
|
||||
sharedPreviewUrl$: Observable<string>;
|
||||
actions: Array<ContentActionRef> = [];
|
||||
viewerToolbarActions: Array<ContentActionRef> = [];
|
||||
canUpdateNode = false;
|
||||
@@ -89,7 +87,6 @@ export abstract class PageComponent implements OnInit, OnDestroy, OnChanges {
|
||||
this.createActions = actions;
|
||||
});
|
||||
|
||||
this.sharedPreviewUrl$ = this.store.select(getSharedUrl);
|
||||
this.infoDrawerOpened$ = this.store.select(isInfoDrawerOpened);
|
||||
|
||||
this.store
|
||||
|
@@ -51,4 +51,50 @@ export class AppSettingsService {
|
||||
get mimeTypes(): AlfrescoMimeType[] {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@@ -45,7 +45,6 @@ import {
|
||||
UploadService
|
||||
} from '@alfresco/adf-content-services';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { STORE_INITIAL_APP_DATA } from '../../../store/src/states/app.state';
|
||||
import { provideMockStore } from '@ngrx/store/testing';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
@@ -53,9 +52,9 @@ import { RepositoryInfo, VersionInfo } from '@alfresco/js-api';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { SnackbarErrorAction } from '../../../store/src/actions/snackbar.actions';
|
||||
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', () => {
|
||||
let service: AppService;
|
||||
@@ -68,6 +67,7 @@ describe('AppService', () => {
|
||||
let contentApi: ContentApiService;
|
||||
let groupService: GroupService;
|
||||
let preferencesService: UserPreferencesService;
|
||||
let appSettingsService: AppSettingsService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
@@ -99,10 +99,6 @@ describe('AppService', () => {
|
||||
snapshot: {}
|
||||
}
|
||||
},
|
||||
{
|
||||
provide: STORE_INITIAL_APP_DATA,
|
||||
useValue: {}
|
||||
},
|
||||
{
|
||||
provide: AlfrescoApiService,
|
||||
useClass: AlfrescoApiServiceMock
|
||||
@@ -121,6 +117,7 @@ describe('AppService', () => {
|
||||
]
|
||||
});
|
||||
|
||||
appSettingsService = TestBed.inject(AppSettingsService);
|
||||
appConfig = TestBed.inject(AppConfigService);
|
||||
auth = TestBed.inject(AuthenticationService);
|
||||
searchQueryBuilderService = TestBed.inject(SearchQueryBuilderService);
|
||||
@@ -172,7 +169,7 @@ describe('AppService', () => {
|
||||
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(''));
|
||||
service.init();
|
||||
const dispatch = spyOn(store, 'dispatch');
|
||||
@@ -216,7 +213,7 @@ describe('AppService', () => {
|
||||
|
||||
it('should load custom css', () => {
|
||||
const appendChild = spyOn(document.head, 'appendChild');
|
||||
spyOn(store, 'select').and.returnValue(of('/custom.css'));
|
||||
spyOnProperty(appSettingsService, 'customCssPath').and.returnValue('/custom.css');
|
||||
service.init();
|
||||
|
||||
const cssLinkElement = document.createElement('link');
|
||||
|
@@ -22,7 +22,7 @@
|
||||
* 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 { Observable, BehaviorSubject, Subject } from 'rxjs';
|
||||
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 { filter, map, tap } from 'rxjs/operators';
|
||||
import {
|
||||
AppState,
|
||||
AppStore,
|
||||
CloseModalDialogsAction,
|
||||
getCustomCssPath,
|
||||
getCustomWebFontPath,
|
||||
STORE_INITIAL_APP_DATA,
|
||||
SetCurrentUrlAction,
|
||||
SetInitialStateAction,
|
||||
SetRepositoryInfoAction,
|
||||
SetUserProfileAction,
|
||||
SnackbarErrorAction,
|
||||
@@ -48,12 +43,14 @@ import { RouterExtensionService } from './router.extension.service';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { DiscoveryEntry, GroupEntry, Group } from '@alfresco/js-api';
|
||||
import { AcaMobileAppSwitcherService } from './aca-mobile-app-switcher.service';
|
||||
import { ShellAppService } from '@alfresco/adf-core/shell';
|
||||
import { AppSettingsService } from './app-settings.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
// 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>;
|
||||
|
||||
ready$: Observable<boolean>;
|
||||
@@ -89,9 +86,9 @@ export class AppService implements OnDestroy {
|
||||
private sharedLinksApiService: SharedLinksApiService,
|
||||
private groupService: GroupService,
|
||||
private overlayContainer: OverlayContainer,
|
||||
@Inject(STORE_INITIAL_APP_DATA) private initialAppState: AppState,
|
||||
searchQueryBuilderService: SearchQueryBuilderService,
|
||||
private acaMobileAppSwitcherService: AcaMobileAppSwitcherService
|
||||
private acaMobileAppSwitcherService: AcaMobileAppSwitcherService,
|
||||
private appSettingsService: AppSettingsService
|
||||
) {
|
||||
this.ready = new BehaviorSubject(this.authenticationService.isLoggedIn() || this.withCredentials);
|
||||
this.ready$ = this.ready.asObservable();
|
||||
@@ -137,8 +134,6 @@ export class AppService implements OnDestroy {
|
||||
}
|
||||
});
|
||||
|
||||
this.loadAppSettings();
|
||||
|
||||
this.loadCustomCss();
|
||||
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) {
|
||||
let message = 'APP.MESSAGES.UPLOAD.ERROR.GENERIC';
|
||||
|
||||
@@ -247,19 +224,17 @@ export class AppService implements OnDestroy {
|
||||
}
|
||||
|
||||
private loadCustomCss(): void {
|
||||
this.store.select(getCustomCssPath).subscribe((cssPath) => {
|
||||
if (cssPath) {
|
||||
this.createLink(cssPath);
|
||||
}
|
||||
});
|
||||
const customCssPath = this.appSettingsService.customCssPath;
|
||||
if (customCssPath) {
|
||||
this.createLink(customCssPath);
|
||||
}
|
||||
}
|
||||
|
||||
private loadCustomWebFont(): void {
|
||||
this.store.select(getCustomWebFontPath).subscribe((fontUrl) => {
|
||||
if (fontUrl) {
|
||||
this.createLink(fontUrl);
|
||||
}
|
||||
});
|
||||
const webFontPath = this.appSettingsService.webFontPath;
|
||||
if (webFontPath) {
|
||||
this.createLink(webFontPath);
|
||||
}
|
||||
}
|
||||
|
||||
private createLink(url: string): void {
|
||||
|
Reference in New Issue
Block a user