[AAE-6811] Load custom theme (#2402)

This commit is contained in:
Bartosz Sekuła 2022-01-18 10:15:42 +01:00 committed by GitHub
parent 652cf1762b
commit 37acccd6d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 1 deletions

View File

@ -30,6 +30,7 @@
"sharedLinkDateTimePickerType": "date", "sharedLinkDateTimePickerType": "date",
"headerColor": "#ffffff", "headerColor": "#ffffff",
"headerTextColor": "#000000", "headerTextColor": "#000000",
"customCssPath": "",
"pagination": { "pagination": {
"size": 25, "size": 25,
"supportedPageSizes": [25, 50, 100] "supportedPageSizes": [25, 50, 100]

View File

@ -44,7 +44,8 @@ import {
SetUserProfileAction, SetUserProfileAction,
SnackbarErrorAction, SnackbarErrorAction,
CloseModalDialogsAction, CloseModalDialogsAction,
SetRepositoryInfoAction SetRepositoryInfoAction,
getCustomCssPath
} from '@alfresco/aca-shared/store'; } from '@alfresco/aca-shared/store';
import { filter, takeUntil } from 'rxjs/operators'; import { filter, takeUntil } from 'rxjs/operators';
import { RouterExtensionService, AppService, ContentApiService } from '@alfresco/aca-shared'; import { RouterExtensionService, AppService, ContentApiService } from '@alfresco/aca-shared';
@ -97,6 +98,8 @@ export class AppComponent implements OnInit, OnDestroy {
this.loadAppSettings(); this.loadAppSettings();
this.loadCustomCss();
const { router, pageTitle } = this; const { router, pageTitle } = this;
this.router.events this.router.events
@ -164,6 +167,7 @@ export class AppComponent implements OnInit, OnDestroy {
headerTextColor: this.config.get<string>('headerTextColor', '#000000'), headerTextColor: this.config.get<string>('headerTextColor', '#000000'),
logoPath: this.config.get<string>('application.logo'), logoPath: this.config.get<string>('application.logo'),
headerImagePath: this.config.get<string>('application.headerImagePath'), headerImagePath: this.config.get<string>('application.headerImagePath'),
customCssPath: this.config.get<string>('customCssPath'),
sharedUrl: baseShareUrl sharedUrl: baseShareUrl
}; };
@ -195,4 +199,16 @@ export class AppComponent implements OnInit, OnDestroy {
this.store.dispatch(new SnackbarErrorAction(message)); this.store.dispatch(new SnackbarErrorAction(message));
} }
private loadCustomCss(): void {
this.store.select(getCustomCssPath).subscribe((cssPath) => {
if (cssPath) {
const cssLinkElement = document.createElement('link');
cssLinkElement.setAttribute('rel', 'stylesheet');
cssLinkElement.setAttribute('type', 'text/css');
cssLinkElement.setAttribute('href', cssPath);
document.head.appendChild(cssLinkElement);
}
});
}
} }

View File

@ -31,6 +31,7 @@ export const INITIAL_APP_STATE: AppState = {
headerTextColor: '#000000', headerTextColor: '#000000',
logoPath: 'assets/images/alfresco-logo-white.svg', logoPath: 'assets/images/alfresco-logo-white.svg',
headerImagePath: 'assets/images/mastHead-bg-shapesPattern.svg', headerImagePath: 'assets/images/mastHead-bg-shapesPattern.svg',
customCssPath: '',
sharedUrl: '', sharedUrl: '',
user: { user: {
isAdmin: null, isAdmin: null,

View File

@ -32,6 +32,7 @@ export const getHeaderColor = createSelector(selectApp, (state) => state.headerC
export const getHeaderTextColor = createSelector(selectApp, (state) => state.headerTextColor); export const getHeaderTextColor = createSelector(selectApp, (state) => state.headerTextColor);
export const getAppName = createSelector(selectApp, (state) => state.appName); export const getAppName = createSelector(selectApp, (state) => state.appName);
export const getLogoPath = createSelector(selectApp, (state) => state.logoPath); export const getLogoPath = createSelector(selectApp, (state) => state.logoPath);
export const getCustomCssPath = createSelector(selectApp, (state) => state.customCssPath);
export const getHeaderImagePath = createSelector(selectApp, (state) => state.headerImagePath); export const getHeaderImagePath = createSelector(selectApp, (state) => state.headerImagePath);
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);

View File

@ -31,6 +31,7 @@ export interface AppState {
headerColor: string; headerColor: string;
headerTextColor: string; headerTextColor: string;
logoPath: string; logoPath: string;
customCssPath: string;
headerImagePath: string; headerImagePath: string;
sharedUrl: string; sharedUrl: string;
currentNodeVersion: VersionEntry; currentNodeVersion: VersionEntry;