Skip to content

Commit 7a7ee23

Browse files
odeimaizmatusdrobuliak66
authored andcommitted
🎨 Frontend: favicons pointing to assets repo (#5755)
1 parent 2ac3032 commit 7a7ee23

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

services/static-webserver/client/source/class/osparc/Application.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,9 @@ qx.Class.define("osparc.Application", {
213213
link.rel = "icon";
214214
document.getElementsByTagName("head")[0].appendChild(link);
215215
}
216-
link.href = "/resource/osparc/favicon-"+qx.core.Environment.get("product.name")+".png";
216+
link.href = "";
217+
osparc.product.Utils.getFaviconUrl()
218+
.then(url => link.href = url);
217219
},
218220

219221
__startupChecks: function() {

services/static-webserver/client/source/class/osparc/product/Utils.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,33 @@ qx.Class.define("osparc.product.Utils", {
114114
return resourceType;
115115
},
116116

117+
__linkExists: function(url) {
118+
return new Promise((resolve, reject) => {
119+
const reqSvg = new XMLHttpRequest();
120+
reqSvg.open("GET", url, true);
121+
reqSvg.onreadystatechange = () => {
122+
if (reqSvg.readyState === 4) {
123+
if (reqSvg.status === 404) {
124+
reject();
125+
} else {
126+
resolve();
127+
}
128+
}
129+
};
130+
reqSvg.send();
131+
});
132+
},
133+
134+
getFaviconUrl: function() {
135+
const pngUrl = "https://raw.githubusercontent.com/ZurichMedTech/s4l-assets/main/app/favicons/favicon-"+this.getProductName()+".png";
136+
const fallbackIcon = "/resource/osparc/favicon-"+this.getProductName()+".png";
137+
return new Promise(resolve => {
138+
this.__linkExists(pngUrl)
139+
.then(() => resolve(pngUrl))
140+
.catch(() => resolve(fallbackIcon))
141+
});
142+
},
143+
117144
getLogoPath: function(longLogo = true) {
118145
let logosPath = null;
119146
const colorManager = qx.theme.manager.Color.getInstance();
Binary file not shown.

0 commit comments

Comments
 (0)