From cb9597679d8c9189e671e166de45c707c650bb2f Mon Sep 17 00:00:00 2001 From: Devaev Maxim Date: Tue, 2 Jun 2020 20:59:43 +0300 Subject: improved info handler --- web/share/js/index/main.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'web/share/js/index/main.js') diff --git a/web/share/js/index/main.js b/web/share/js/index/main.js index ba33b0aa..497a4d73 100644 --- a/web/share/js/index/main.js +++ b/web/share/js/index/main.js @@ -56,15 +56,20 @@ function __loadKvmdInfo() { if (http.status === 200) { let info = JSON.parse(http.responseText).result; - let apps = Object.values(info.extras).sort(function(a, b) { - if (a.place < b.place) { - return -1; - } else if (a.place > b.place) { - return 1; - } else { - return 0; - } - }); + let apps = []; + if (info.extras === null) { + wm.error("Not all applications in the menu can be displayed
due an error. See KVMD logs for details."); + } else { + apps = Object.values(info.extras).sort(function(a, b) { + if (a.place < b.place) { + return -1; + } else if (a.place > b.place) { + return 1; + } else { + return 0; + } + }); + } $("apps-box").innerHTML = ""; @@ -79,7 +84,7 @@ function __loadKvmdInfo() { $("apps").innerHTML += __makeApp("logout-button", "#", "share/svg/logout.svg", "Logout"); tools.setOnClick($("logout-button"), __logout); - if (info.meta && info.meta.server && info.meta.server.host) { + if (info.meta !== null && info.meta.server && info.meta.server.host) { $("kvmd-meta-server-host").innerHTML = info.meta.server.host; document.title = `Pi-KVM Index: ${info.meta.server.host}`; } else { -- cgit v1.2.3