From b9b3c8f78a4a9a65d762316f3a62688ebf5526f6 Mon Sep 17 00:00:00 2001 From: Mononaut Date: Thu, 25 Apr 2024 20:39:57 +0000 Subject: [PATCH] Custom branding --- frontend/custom-sv-config.json | 8 ++++++- .../address-graph.component.scss | 1 - .../master-page/master-page.component.html | 2 +- .../src/app/services/enterprise.service.ts | 23 ++++++++++++------- frontend/src/app/services/state.service.ts | 7 ++++++ 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/frontend/custom-sv-config.json b/frontend/custom-sv-config.json index 69048946c..ec676837c 100644 --- a/frontend/custom-sv-config.json +++ b/frontend/custom-sv-config.json @@ -1,6 +1,12 @@ { "theme": "contrast", - "enterprise": "elsalvador", + "enterprise": "onbtc", + "branding": { + "name": "onbtc", + "title": "Oficina Nacional del Bitcoin", + "img": "/resources/elsalvador.svg", + "rounded_corner": true + }, "dashboard": { "widgets": [ { diff --git a/frontend/src/app/components/address-graph/address-graph.component.scss b/frontend/src/app/components/address-graph/address-graph.component.scss index d23b95d8d..a118549fb 100644 --- a/frontend/src/app/components/address-graph/address-graph.component.scss +++ b/frontend/src/app/components/address-graph/address-graph.component.scss @@ -66,7 +66,6 @@ .chart-widget { width: 100%; height: 100%; - max-height: 270px; } .disabled { diff --git a/frontend/src/app/components/master-page/master-page.component.html b/frontend/src/app/components/master-page/master-page.component.html index f55a05fac..fa7e727a7 100644 --- a/frontend/src/app/components/master-page/master-page.component.html +++ b/frontend/src/app/components/master-page/master-page.component.html @@ -19,7 +19,7 @@
- +
diff --git a/frontend/src/app/services/enterprise.service.ts b/frontend/src/app/services/enterprise.service.ts index b1d042282..1201c0c75 100644 --- a/frontend/src/app/services/enterprise.service.ts +++ b/frontend/src/app/services/enterprise.service.ts @@ -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 { diff --git a/frontend/src/app/services/state.service.ts b/frontend/src/app/services/state.service.ts index f9e49648c..286ae5e48 100644 --- a/frontend/src/app/services/state.service.ts +++ b/frontend/src/app/services/state.service.ts @@ -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;