Custom branding

This commit is contained in:
Mononaut 2024-04-25 20:39:57 +00:00
parent 4f4215577a
commit b9b3c8f78a
No known key found for this signature in database
GPG Key ID: A3F058E41374C04E
5 changed files with 30 additions and 11 deletions

View File

@ -1,6 +1,12 @@
{ {
"theme": "contrast", "theme": "contrast",
"enterprise": "elsalvador", "enterprise": "onbtc",
"branding": {
"name": "onbtc",
"title": "Oficina Nacional del Bitcoin",
"img": "/resources/elsalvador.svg",
"rounded_corner": true
},
"dashboard": { "dashboard": {
"widgets": [ "widgets": [
{ {

View File

@ -66,7 +66,6 @@
.chart-widget { .chart-widget {
width: 100%; width: 100%;
height: 100%; height: 100%;
max-height: 270px;
} }
.disabled { .disabled {

View File

@ -19,7 +19,7 @@
<a class="navbar-brand d-none d-md-flex" [ngClass]="{'dual-logos': subdomain}" [routerLink]="['/' | relativeUrl]" (click)="brandClick($event)"> <a class="navbar-brand d-none d-md-flex" [ngClass]="{'dual-logos': subdomain}" [routerLink]="['/' | relativeUrl]" (click)="brandClick($event)">
<ng-template [ngIf]="subdomain && enterpriseInfo"> <ng-template [ngIf]="subdomain && enterpriseInfo">
<div class="subdomain_container"> <div class="subdomain_container">
<img [src]="'/api/v1/services/enterprise/images/' + subdomain + '/logo?imageMd5=' + enterpriseInfo.imageMd5" class="subdomain_logo" [class]="{'rounded': enterpriseInfo.rounded_corner}"> <img [src]="enterpriseInfo.img || '/api/v1/services/enterprise/images/' + subdomain + '/logo?imageMd5=' + enterpriseInfo.imageMd5" class="subdomain_logo" [class]="{'rounded': enterpriseInfo.rounded_corner}">
</div> </div>
<div class="vertical-line"></div> <div class="vertical-line"></div>
</ng-template> </ng-template>

View File

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

View File

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