Compare commits

...

2 Commits

Author SHA1 Message Date
Diamantis Tziotzios 466141ff56 Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring 2024-06-20 11:21:15 +03:00
Diamantis Tziotzios 47911286a0 added css colors to onfig.json 2024-06-20 11:21:00 +03:00
4 changed files with 29 additions and 8 deletions

View File

@ -255,6 +255,11 @@ export class AppComponent implements OnInit, AfterViewInit {
} }
initializeServices() { initializeServices() {
if (!this.authentication.currentAccountIsAuthenticated() && this.configurationService.cssColorsTenantConfiguration) {
this.tenantHandlingService.applyTenantCssColors(this.configurationService.cssColorsTenantConfiguration);
}
this.translate.setDefaultLang(this.language.getDefaultLanguagesCode()); this.translate.setDefaultLang(this.language.getDefaultLanguagesCode());
this.authentication.currentAccountIsAuthenticated() && this.authentication.getUserProfileCulture() ? this.cultureService.cultureSelected(this.authentication.getUserProfileCulture()) : this.cultureService.cultureSelected(this.configurationService.defaultCulture); this.authentication.currentAccountIsAuthenticated() && this.authentication.getUserProfileCulture() ? this.cultureService.cultureSelected(this.authentication.getUserProfileCulture()) : this.cultureService.cultureSelected(this.configurationService.defaultCulture);
this.authentication.currentAccountIsAuthenticated() && this.authentication.getUserProfileTimezone() ? this.timezoneService.timezoneSelected(this.authentication.getUserProfileTimezone()) : this.timezoneService.timezoneSelected(this.configurationService.defaultTimezone); this.authentication.currentAccountIsAuthenticated() && this.authentication.getUserProfileTimezone() ? this.timezoneService.timezoneSelected(this.authentication.getUserProfileTimezone()) : this.timezoneService.timezoneSelected(this.configurationService.defaultTimezone);

View File

@ -177,7 +177,7 @@ export class AuthService extends BaseService {
])), ])),
map((item) => { map((item) => {
this.currentAccount(item[1]); this.currentAccount(item[1]);
this.tenantHandlingService.applyTenantCssColors(item[2]); this.tenantHandlingService.applyTenantCssColors(item[2]?.cssColors);
return true; return true;
}) })
); );

View File

@ -11,6 +11,7 @@ import { KeycloakConfiguration } from '@app/core/model/configuration-models/keyc
import { Guid } from '@common/types/guid'; import { Guid } from '@common/types/guid';
import { AuthProviders } from '@app/core/model/configuration-models/auth-providers.model'; import { AuthProviders } from '@app/core/model/configuration-models/auth-providers.model';
import { AnalyticsProviders } from '@app/core/model/configuration-models/analytics-providers.model'; import { AnalyticsProviders } from '@app/core/model/configuration-models/analytics-providers.model';
import { CssColorsTenantConfiguration } from '@app/core/model/tenant-configuaration/tenant-configuration';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
@ -175,6 +176,13 @@ export class ConfigurationService extends BaseComponent {
return this._depositRecordUrlIdPlaceholder; return this._depositRecordUrlIdPlaceholder;
} }
private _cssColorsTenantConfiguration: CssColorsTenantConfiguration;
get cssColorsTenantConfiguration(): CssColorsTenantConfiguration {
return this._cssColorsTenantConfiguration;
}
public loadConfiguration(): Promise<any> { public loadConfiguration(): Promise<any> {
return new Promise((r, e) => { return new Promise((r, e) => {
// We need to exclude all interceptors here, for the initial configuration request. // We need to exclude all interceptors here, for the initial configuration request.
@ -250,6 +258,14 @@ export class ConfigurationService extends BaseComponent {
this._organizationId = config.referenceTypes.organizationId; this._organizationId = config.referenceTypes.organizationId;
this._depositRecordUrlIdPlaceholder = config.deposit.recordUrlIdPlaceholder; this._depositRecordUrlIdPlaceholder = config.deposit.recordUrlIdPlaceholder;
if (config.defaultCssColors) {
this._cssColorsTenantConfiguration = {
primaryColor: config.defaultCssColors.primaryColor,
primaryColor2: config.defaultCssColors.primaryColor2,
primaryColor3: config.defaultCssColors.primaryColor3,
secondaryColor: config.defaultCssColors.secondaryColor,
}
}
} }
} }

View File

@ -67,7 +67,7 @@ export class TenantHandlingService extends BaseService {
public loadAndApplyTenantCssColors() { public loadAndApplyTenantCssColors() {
this.loadTenantCssColors().pipe(takeUntil(this._destroyed)).subscribe(x => this.applyTenantCssColors(x)) this.loadTenantCssColors().pipe(takeUntil(this._destroyed)).subscribe(x => this.applyTenantCssColors(x.cssColors))
} }
public loadTenantCssColors(): Observable<TenantConfiguration> { public loadTenantCssColors(): Observable<TenantConfiguration> {
@ -80,13 +80,13 @@ export class TenantHandlingService extends BaseService {
]); ]);
} }
public applyTenantCssColors(data: TenantConfiguration) { public applyTenantCssColors(cssColors: CssColorsTenantConfiguration) {
if (data?.cssColors) { if (cssColors) {
if (data.cssColors.primaryColor) document.documentElement.style.setProperty(`--primary-color`, data.cssColors.primaryColor); if (cssColors.primaryColor) document.documentElement.style.setProperty(`--primary-color`, cssColors.primaryColor);
if (data.cssColors.primaryColor2) document.documentElement.style.setProperty(`--primary-color-2`, data.cssColors.primaryColor2); if (cssColors.primaryColor2) document.documentElement.style.setProperty(`--primary-color-2`, cssColors.primaryColor2);
if (data.cssColors.primaryColor3) document.documentElement.style.setProperty(`--primary-color-3`, data.cssColors.primaryColor3); if (cssColors.primaryColor3) document.documentElement.style.setProperty(`--primary-color-3`, cssColors.primaryColor3);
if (data.cssColors.secondaryColor) document.documentElement.style.setProperty(`--secondary-color`, data.cssColors.secondaryColor); if (cssColors.secondaryColor) document.documentElement.style.setProperty(`--secondary-color`, cssColors.secondaryColor);
} }
} }
} }