Custom branding

This commit is contained in:
Mononaut
2024-04-25 20:39:57 +00:00
parent 4f4215577a
commit b9b3c8f78a
5 changed files with 30 additions and 11 deletions

View File

@@ -23,7 +23,7 @@ export class EnterpriseService {
private stateService: StateService,
private activatedRoute: ActivatedRoute,
) {
const subdomain = this.stateService.env.customize.enterprise || this.document.location.hostname.indexOf(this.exclusiveHostName) > -1
const subdomain = this.stateService.env.customize?.enterprise || this.document.location.hostname.indexOf(this.exclusiveHostName) > -1
&& this.document.location.hostname.split(this.exclusiveHostName)[0] || false;
if (subdomain && subdomain.match(/^[A-z0-9-_]+$/)) {
this.subdomain = subdomain;
@@ -47,16 +47,23 @@ export class EnterpriseService {
}
fetchSubdomainInfo(): void {
this.apiService.getEnterpriseInfo$(this.subdomain).subscribe((info) => {
if (this.stateService.env.customize?.branding) {
const info = this.stateService.env.customize?.branding;
this.insertMatomo(info.site_id);
this.seoService.setEnterpriseTitle(info.title);
this.info$.next(info);
},
(error) => {
if (error.status === 404) {
window.location.href = 'https://mempool.space' + window.location.pathname;
}
});
} else {
this.apiService.getEnterpriseInfo$(this.subdomain).subscribe((info) => {
this.insertMatomo(info.site_id);
this.seoService.setEnterpriseTitle(info.title);
this.info$.next(info);
},
(error) => {
if (error.status === 404) {
window.location.href = 'https://mempool.space' + window.location.pathname;
}
});
}
}
insertMatomo(siteId?: number): void {

View File

@@ -23,6 +23,13 @@ export interface ILoadingIndicators { [name: string]: number; }
export interface Customization {
theme: string;
enterprise?: string;
branding: {
name: string;
site_id?: number;
title: string;
img: string;
rounded_corner: boolean;
},
dashboard: {
widgets: {
component: string;