web: improve loading of custom favicon
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
2f64b76eba
commit
974ddc07f7
|
@ -8,7 +8,6 @@
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||||
<title>{% block title %}{% trans title|default:tenant.branding_title %}{% endblock %}</title>
|
<title>{% block title %}{% trans title|default:tenant.branding_title %}{% endblock %}</title>
|
||||||
<link rel="icon" type="image/png" href="{% static 'dist/assets/icons/icon.png' %}?v={{ ak_version }}">
|
|
||||||
<link rel="shortcut icon" type="image/png" href="{% static 'dist/assets/icons/icon.png' %}?v={{ ak_version }}">
|
<link rel="shortcut icon" type="image/png" href="{% static 'dist/assets/icons/icon.png' %}?v={{ ak_version }}">
|
||||||
<link rel="stylesheet" type="text/css" href="{% static 'dist/patternfly-base.css' %}?v={{ ak_version }}">
|
<link rel="stylesheet" type="text/css" href="{% static 'dist/patternfly-base.css' %}?v={{ ak_version }}">
|
||||||
<link rel="stylesheet" type="text/css" href="{% static 'dist/page.css' %}?v={{ ak_version }}">
|
<link rel="stylesheet" type="text/css" href="{% static 'dist/page.css' %}?v={{ ak_version }}">
|
||||||
|
|
|
@ -26,10 +26,20 @@ let globalTenantPromise: Promise<CurrentTenant>;
|
||||||
export function tenant(): Promise<CurrentTenant> {
|
export function tenant(): Promise<CurrentTenant> {
|
||||||
if (!globalTenantPromise) {
|
if (!globalTenantPromise) {
|
||||||
globalTenantPromise = new CoreApi(DEFAULT_CONFIG).coreTenantsCurrentRetrieve().then(tenant => {
|
globalTenantPromise = new CoreApi(DEFAULT_CONFIG).coreTenantsCurrentRetrieve().then(tenant => {
|
||||||
const relIcon = document.head.querySelector<HTMLLinkElement>("link[rel=icon]");
|
/**
|
||||||
if (relIcon) {
|
* <link rel="icon" href="/static/dist/assets/icons/icon.png">
|
||||||
relIcon.href = tenant.brandingLogo;
|
* <link rel="shortcut icon" href="/static/dist/assets/icons/icon.png">
|
||||||
|
*/
|
||||||
|
const rels = ["icon", "shortcut icon"];
|
||||||
|
rels.forEach(rel => {
|
||||||
|
let relIcon = document.head.querySelector<HTMLLinkElement>("link[rel=icon]");
|
||||||
|
if (!relIcon) {
|
||||||
|
relIcon = document.createElement('link');
|
||||||
|
relIcon.rel = rel;
|
||||||
|
document.getElementsByTagName('head')[0].appendChild(relIcon);
|
||||||
}
|
}
|
||||||
|
relIcon.href = tenant.brandingLogo;
|
||||||
|
})
|
||||||
return tenant;
|
return tenant;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||||
<link rel="icon" type="image/png" href="/static/dist/assets/icons/icon.png">
|
|
||||||
<link rel="shortcut icon" type="image/png" href="/static/dist/assets/icons/icon.png">
|
|
||||||
<link rel="stylesheet" type="text/css" href="/static/dist/patternfly-base.css">
|
<link rel="stylesheet" type="text/css" href="/static/dist/patternfly-base.css">
|
||||||
<link rel="stylesheet" type="text/css" href="/static/dist/page.css">
|
<link rel="stylesheet" type="text/css" href="/static/dist/page.css">
|
||||||
<link rel="stylesheet" type="text/css" href="/static/dist/empty-state.css">
|
<link rel="stylesheet" type="text/css" href="/static/dist/empty-state.css">
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||||
<link rel="icon" type="image/png" href="/static/dist/assets/icons/icon.png">
|
|
||||||
<link rel="shortcut icon" type="image/png" href="/static/dist/assets/icons/icon.png">
|
|
||||||
<link rel="stylesheet" type="text/css" href="/static/dist/patternfly-base.css">
|
<link rel="stylesheet" type="text/css" href="/static/dist/patternfly-base.css">
|
||||||
<link rel="stylesheet" type="text/css" href="/static/dist/page.css">
|
<link rel="stylesheet" type="text/css" href="/static/dist/page.css">
|
||||||
<link rel="stylesheet" type="text/css" href="/static/dist/empty-state.css">
|
<link rel="stylesheet" type="text/css" href="/static/dist/empty-state.css">
|
||||||
|
|
Reference in New Issue