[enterprise] implement subdomain logo cache buster
This commit is contained in:
		
							parent
							
								
									1d877a746f
								
							
						
					
					
						commit
						f5e1e5f1a2
					
				| @ -16,9 +16,9 @@ | |||||||
|   </ng-container> |   </ng-container> | ||||||
| 
 | 
 | ||||||
|   <a class="navbar-brand" [ngClass]="{'dual-logos': subdomain}" [routerLink]="['/' | relativeUrl]" (click)="brandClick($event)"> |   <a class="navbar-brand" [ngClass]="{'dual-logos': subdomain}" [routerLink]="['/' | relativeUrl]" (click)="brandClick($event)"> | ||||||
|   <ng-template [ngIf]="subdomain"> |   <ng-template [ngIf]="subdomain && enterpriseInfo"> | ||||||
|     <div class="subdomain_container"> |     <div class="subdomain_container"> | ||||||
|       <img [src]="'/api/v1/services/enterprise/images/' + subdomain + '/logo'" class="subdomain_logo"> |       <img [src]="'/api/v1/services/enterprise/images/' + subdomain + '/logo?imageMd5=' + enterpriseInfo.imageMd5" class="subdomain_logo"> | ||||||
|     </div> |     </div> | ||||||
|   </ng-template> |   </ng-template> | ||||||
|     <ng-container *ngIf="{ val: connectionState$ | async } as connectionState"> |     <ng-container *ngIf="{ val: connectionState$ | async } as connectionState"> | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| import { Component, OnInit, Input, ViewChild } from '@angular/core'; | import { Component, OnInit, OnDestroy, Input, ViewChild } from '@angular/core'; | ||||||
| import { Router } from '@angular/router'; | import { Router } from '@angular/router'; | ||||||
| import { Env, StateService } from '../../services/state.service'; | import { Env, StateService } from '../../services/state.service'; | ||||||
| import { Observable, merge, of } from 'rxjs'; | import { Observable, merge, of, Subscription } from 'rxjs'; | ||||||
| import { LanguageService } from '../../services/language.service'; | import { LanguageService } from '../../services/language.service'; | ||||||
| import { EnterpriseService } from '../../services/enterprise.service'; | import { EnterpriseService } from '../../services/enterprise.service'; | ||||||
| import { NavigationService } from '../../services/navigation.service'; | import { NavigationService } from '../../services/navigation.service'; | ||||||
| @ -14,7 +14,7 @@ import { ApiService } from '../../services/api.service'; | |||||||
|   templateUrl: './master-page.component.html', |   templateUrl: './master-page.component.html', | ||||||
|   styleUrls: ['./master-page.component.scss'], |   styleUrls: ['./master-page.component.scss'], | ||||||
| }) | }) | ||||||
| export class MasterPageComponent implements OnInit { | export class MasterPageComponent implements OnInit, OnDestroy { | ||||||
|   @Input() headerVisible = true; |   @Input() headerVisible = true; | ||||||
|   @Input() footerVisibleOverride: boolean | null = null; |   @Input() footerVisibleOverride: boolean | null = null; | ||||||
| 
 | 
 | ||||||
| @ -33,6 +33,9 @@ export class MasterPageComponent implements OnInit { | |||||||
|   servicesEnabled = false; |   servicesEnabled = false; | ||||||
|   menuOpen = false; |   menuOpen = false; | ||||||
|    |    | ||||||
|  |   enterpriseInfo: any; | ||||||
|  |   enterpriseInfo$: Subscription; | ||||||
|  | 
 | ||||||
|   @ViewChild(MenuComponent) |   @ViewChild(MenuComponent) | ||||||
|   public menuComponent!: MenuComponent; |   public menuComponent!: MenuComponent; | ||||||
| 
 | 
 | ||||||
| @ -64,6 +67,9 @@ export class MasterPageComponent implements OnInit { | |||||||
|         this.footerVisible = this.footerVisibleOverride; |         this.footerVisible = this.footerVisibleOverride; | ||||||
|       } |       } | ||||||
|     }); |     }); | ||||||
|  |     this.enterpriseInfo$ = this.enterpriseService.info$.subscribe(info => { | ||||||
|  |       this.enterpriseInfo = info; | ||||||
|  |     }); | ||||||
|      |      | ||||||
|     this.servicesEnabled = this.officialMempoolSpace && this.stateService.env.ACCELERATOR === true && this.stateService.network === ''; |     this.servicesEnabled = this.officialMempoolSpace && this.stateService.env.ACCELERATOR === true && this.stateService.network === ''; | ||||||
|     this.refreshAuth(); |     this.refreshAuth(); | ||||||
| @ -72,6 +78,12 @@ export class MasterPageComponent implements OnInit { | |||||||
|     this.menuOpen = isServicesPage && !this.isSmallScreen(); |     this.menuOpen = isServicesPage && !this.isSmallScreen(); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   ngOnDestroy() { | ||||||
|  |     if (this.enterpriseInfo$) { | ||||||
|  |       this.enterpriseInfo$.unsubscribe(); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   collapse(): void { |   collapse(): void { | ||||||
|     this.navCollapsed = !this.navCollapsed; |     this.navCollapsed = !this.navCollapsed; | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -4,6 +4,7 @@ import { ApiService } from './api.service'; | |||||||
| import { SeoService } from './seo.service'; | import { SeoService } from './seo.service'; | ||||||
| import { StateService } from './state.service'; | import { StateService } from './state.service'; | ||||||
| import { ActivatedRoute } from '@angular/router'; | import { ActivatedRoute } from '@angular/router'; | ||||||
|  | import { BehaviorSubject } from 'rxjs'; | ||||||
| 
 | 
 | ||||||
| @Injectable({ | @Injectable({ | ||||||
|   providedIn: 'root' |   providedIn: 'root' | ||||||
| @ -11,9 +12,9 @@ import { ActivatedRoute } from '@angular/router'; | |||||||
| export class EnterpriseService { | export class EnterpriseService { | ||||||
|   exclusiveHostName = '.mempool.space'; |   exclusiveHostName = '.mempool.space'; | ||||||
|   subdomain: string | null = null; |   subdomain: string | null = null; | ||||||
|   info: object = {}; |  | ||||||
|   statsUrl: string; |   statsUrl: string; | ||||||
|   siteId: number; |   siteId: number; | ||||||
|  |   info$: BehaviorSubject<object> = new BehaviorSubject(null); | ||||||
| 
 | 
 | ||||||
|   constructor( |   constructor( | ||||||
|     @Inject(DOCUMENT) private document: Document, |     @Inject(DOCUMENT) private document: Document, | ||||||
| @ -47,9 +48,9 @@ export class EnterpriseService { | |||||||
| 
 | 
 | ||||||
|   fetchSubdomainInfo(): void { |   fetchSubdomainInfo(): void { | ||||||
|     this.apiService.getEnterpriseInfo$(this.subdomain).subscribe((info) => { |     this.apiService.getEnterpriseInfo$(this.subdomain).subscribe((info) => { | ||||||
|       this.info = info; |  | ||||||
|       this.insertMatomo(info.site_id); |       this.insertMatomo(info.site_id); | ||||||
|       this.seoService.setEnterpriseTitle(info.title); |       this.seoService.setEnterpriseTitle(info.title); | ||||||
|  |       this.info$.next(info); | ||||||
|     }, |     }, | ||||||
|     (error) => { |     (error) => { | ||||||
|       if (error.status === 404) { |       if (error.status === 404) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user