From 7a7ee23bea6fba1aca6cd59a2ba51578584184fb Mon Sep 17 00:00:00 2001 From: Odei Maiz <33152403+odeimaiz@users.noreply.github.com> Date: Mon, 29 Apr 2024 17:36:57 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Frontend:=20favicons=20pointing?= =?UTF-8?q?=20to=20assets=20repo=20(#5755)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/source/class/osparc/Application.js | 4 ++- .../source/class/osparc/product/Utils.js | 27 ++++++++++++++++++ .../client/source/resource/osparc/favicon.png | Bin 2158 -> 0 bytes 3 files changed, 30 insertions(+), 1 deletion(-) delete mode 100644 services/static-webserver/client/source/resource/osparc/favicon.png diff --git a/services/static-webserver/client/source/class/osparc/Application.js b/services/static-webserver/client/source/class/osparc/Application.js index f00f4e12c93..026a8a19f82 100644 --- a/services/static-webserver/client/source/class/osparc/Application.js +++ b/services/static-webserver/client/source/class/osparc/Application.js @@ -213,7 +213,9 @@ qx.Class.define("osparc.Application", { link.rel = "icon"; document.getElementsByTagName("head")[0].appendChild(link); } - link.href = "/resource/osparc/favicon-"+qx.core.Environment.get("product.name")+".png"; + link.href = ""; + osparc.product.Utils.getFaviconUrl() + .then(url => link.href = url); }, __startupChecks: function() { diff --git a/services/static-webserver/client/source/class/osparc/product/Utils.js b/services/static-webserver/client/source/class/osparc/product/Utils.js index c57003f7b70..4b3799a51ef 100644 --- a/services/static-webserver/client/source/class/osparc/product/Utils.js +++ b/services/static-webserver/client/source/class/osparc/product/Utils.js @@ -114,6 +114,33 @@ qx.Class.define("osparc.product.Utils", { return resourceType; }, + __linkExists: function(url) { + return new Promise((resolve, reject) => { + const reqSvg = new XMLHttpRequest(); + reqSvg.open("GET", url, true); + reqSvg.onreadystatechange = () => { + if (reqSvg.readyState === 4) { + if (reqSvg.status === 404) { + reject(); + } else { + resolve(); + } + } + }; + reqSvg.send(); + }); + }, + + getFaviconUrl: function() { + const pngUrl = "https://raw.githubusercontent.com/ZurichMedTech/s4l-assets/main/app/favicons/favicon-"+this.getProductName()+".png"; + const fallbackIcon = "/resource/osparc/favicon-"+this.getProductName()+".png"; + return new Promise(resolve => { + this.__linkExists(pngUrl) + .then(() => resolve(pngUrl)) + .catch(() => resolve(fallbackIcon)) + }); + }, + getLogoPath: function(longLogo = true) { let logosPath = null; const colorManager = qx.theme.manager.Color.getInstance(); diff --git a/services/static-webserver/client/source/resource/osparc/favicon.png b/services/static-webserver/client/source/resource/osparc/favicon.png deleted file mode 100644 index 2ac77a3c21545712d741006cab609249145d6cd0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2158 zcmY*adpy%^8~?F64cnZuLd~e;uu1b4&BBc3Y|iq@W=6wUHijfyiZnSU)Po#S&m)pN zDalw?o{)r2Dym03p^{^vcdOps_q{)#>%Oo1y1&==dtcZ6$9=-n-ANU)0RjMk>Ryrq zS+XLfrYJ9&*~!Usk_8-L=Vk{0jb&6suN7yIqLW+fFi-Utl5%5tF z05;#CmC`B}Dpq3N^LsiA?<%*D$tMeVbDNNT?r0-pDuvPmTs?i?1!6n35xLKBn@-Pu zAXHmMPcbZ3rty*flm^8TzMyxdG#43x{0hqLJp&Hk!JB&Rl5s`OHu_>45;;+vUtah- zFxz(gd`-=G!ClR6GQS`PDW&#I`jlW|@OoxYGs@WbQJc{{j<=fj%!uMmj^)WdM{RUX6YI@jiv}lU)E@3Il9_Xi zpO7N<`?Q+6*=n`@+qk&+**d}$kNqKOy5|T+5-;! z-NkZTMOisx6O)pIxcS9JZx0WcmX_AT<)>D5O3of0{#{*NSNM^Ukz^Ma7t;s#uMG|P z4h;`)xdl;H_H}eTUb(W85_qxUTi}fs&pS(+ee0OE5JCAPkishHoSYl>&$>t^Q>!c~ zDJjb}%qu%PJ2F0=i2s<}Hk*1PL;ud}*OiL7XV3nDC2kDh?QeH4tVn}pi|r>;Gd>vf zt6?fi3JV>kr>Ez>p22iF_xAK;cA5`;8xo5hyC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