Skip to content

Commit

Permalink
feat: set a customisable favicon for datahub
Browse files Browse the repository at this point in the history
  • Loading branch information
f-necas committed Jan 8, 2024
1 parent 61ed24d commit 739b2fa
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
20 changes: 18 additions & 2 deletions apps/datahub/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
import { Component } from '@angular/core'
import { Component, OnInit } from '@angular/core'
import { getGlobalConfig } from '@geonetwork-ui/util/app-config'

@Component({
selector: 'datahub-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent {}
export class AppComponent implements OnInit {
ngOnInit(): void {
const favicon = getGlobalConfig().FAVICON
if (favicon) this.setFavicon(favicon)
}

private setFavicon(faviconPath: string): void {
const link =
document.querySelector("link[rel*='icon']") ||
document.createElement('link')
link['type'] = 'image/x-icon'
link['rel'] = 'icon'
link['href'] = faviconPath
document.getElementsByTagName('head')[0].appendChild(link)
}
}
3 changes: 3 additions & 0 deletions conf/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ proxy_path = ""
# More information about the translation can be found in the docs (https://geonetwork.github.io/geonetwork-ui/main/docs/reference/i18n.html)
# languages = ['en', 'fr', 'de']

# Use it to set custom location for favicon
# favicon = "assets/favicon.ico"

### VISUAL THEME

# All parameters are expressed in CSS format, see:
Expand Down
2 changes: 2 additions & 0 deletions libs/util/app-config/src/lib/app-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export function loadAppConfig() {
'login_url',
'web_component_embedder_url',
'languages',
'favicon',
],
warnings,
errors
Expand All @@ -126,6 +127,7 @@ export function loadAppConfig() {
WEB_COMPONENT_EMBEDDER_URL:
parsedGlobalSection.web_component_embedder_url,
LANGUAGES: parsedGlobalSection.languages,
FAVICON: parsedGlobalSection.favicon,
} as GlobalConfig)

const parsedLayersSections = parseMultiConfigSection(
Expand Down
1 change: 1 addition & 0 deletions libs/util/app-config/src/lib/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface GlobalConfig {
LOGIN_URL?: string
WEB_COMPONENT_EMBEDDER_URL?: string
LANGUAGES?: string[]
FAVICON?: string
}

export interface LayerConfig {
Expand Down

0 comments on commit 739b2fa

Please sign in to comment.