mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
ACS-8404: consolidate application settings (#3952)
This commit is contained in:
@@ -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