From b4a5794573b1d677b10025b4f4b88cc081a2fb36 Mon Sep 17 00:00:00 2001 From: dkanada Date: Thu, 5 Sep 2019 11:42:38 -0700 Subject: [PATCH] minor changes to dashboard controller --- src/controllers/dashboardpage.js | 45 ++++++++++++-------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/src/controllers/dashboardpage.js b/src/controllers/dashboardpage.js index be3ee9e08..1f6893ff6 100644 --- a/src/controllers/dashboardpage.js +++ b/src/controllers/dashboardpage.js @@ -12,27 +12,23 @@ define(["datetime", "events", "itemHelper", "serverNotifications", "dom", "globa function showPlaybackInfo(btn, session) { require(["alert"], function (alert) { - var showTranscodeReasons; var title; var text = []; - var displayPlayMethod = playMethodHelper.getDisplayPlayMethod(session); - var isDirectStream = "DirectStream" === displayPlayMethod; - var isTranscode = "Transcode" === displayPlayMethod; - if (isDirectStream) { + var displayPlayMethod = playMethodHelper.getDisplayPlayMethod(session); + if (displayPlayMethod === "DirectStream") { title = globalize.translate("DirectStreaming"); text.push(globalize.translate("DirectStreamHelp1")); text.push("
"); text.push(globalize.translate("DirectStreamHelp2")); - } else if (isTranscode) { + } else if (displayPlayMethod === "Transcode") { title = globalize.translate("Transcoding"); text.push(globalize.translate("MediaIsBeingConverted")); - if (session.TranscodingInfo && session.TranscodingInfo.TranscodeReasons && session.TranscodingInfo.TranscodeReasons.length) { text.push("
"); text.push(globalize.translate("LabelReasonForTranscoding")); session.TranscodingInfo.TranscodeReasons.forEach(function (transcodeReason) { - text.push(globalize.translate("" + transcodeReason)); + text.push(globalize.translate(transcodeReason)); }); } } @@ -316,8 +312,8 @@ define(["datetime", "events", "itemHelper", "serverNotifications", "dom", "globa html += '
'; var userImage = DashboardPage.getUserImage(session); html += userImage ? '' : '
'; - html += '
'; - html += DashboardPage.getUsersHtml(session) || " "; + html += '
'; + html += DashboardPage.getUsersHtml(session); html += "
"; html += "
"; html += "
"; @@ -398,13 +394,12 @@ define(["datetime", "events", "itemHelper", "serverNotifications", "dom", "globa } if (showTranscodingInfo) { var line = []; - if (session.TranscodingInfo) { if (session.TranscodingInfo.Bitrate) { if (session.TranscodingInfo.Bitrate > 1e6) { line.push((session.TranscodingInfo.Bitrate / 1e6).toFixed(1) + " Mbps"); } else { - line.push(Math.floor(session.TranscodingInfo.Bitrate / 1e3) + " kbps"); + line.push(Math.floor(session.TranscodingInfo.Bitrate / 1e3) + " Kbps"); } } @@ -426,7 +421,7 @@ define(["datetime", "events", "itemHelper", "serverNotifications", "dom", "globa } } - return html || " "; + return html; }, getSessionNowPlayingTime: function (session) { var nowPlayingItem = session.NowPlayingItem; @@ -436,7 +431,7 @@ define(["datetime", "events", "itemHelper", "serverNotifications", "dom", "globa if (session.PlayState.PositionTicks) { html += datetime.getDisplayRunningTime(session.PlayState.PositionTicks); } else { - html += "--:--:--"; + html += "0:00"; } html += " / "; @@ -444,10 +439,8 @@ define(["datetime", "events", "itemHelper", "serverNotifications", "dom", "globa if (nowPlayingItem && nowPlayingItem.RunTimeTicks) { html += datetime.getDisplayRunningTime(nowPlayingItem.RunTimeTicks); } else { - html += "--:--:--"; + html += "0:00"; } - - return html; } return html; @@ -488,15 +481,13 @@ define(["datetime", "events", "itemHelper", "serverNotifications", "dom", "globa maxWidth: 130, type: "Logo" }); - } else { - if (nowPlayingItem.ParentLogoImageTag) { - imgUrl = ApiClient.getScaledImageUrl(nowPlayingItem.ParentLogoItemId, { - tag: nowPlayingItem.ParentLogoImageTag, - maxHeight: 24, - maxWidth: 130, - type: "Logo" - }); - } + } else if (nowPlayingItem.ParentLogoImageTag) { + imgUrl = ApiClient.getScaledImageUrl(nowPlayingItem.ParentLogoItemId, { + tag: nowPlayingItem.ParentLogoImageTag, + maxHeight: 24, + maxWidth: 130, + type: "Logo" + }); } if (imgUrl) { @@ -510,7 +501,6 @@ define(["datetime", "events", "itemHelper", "serverNotifications", "dom", "globa }, getUsersHtml: function (session) { var html = []; - if (session.UserId) { html.push(session.UserName); } @@ -787,7 +777,6 @@ define(["datetime", "events", "itemHelper", "serverNotifications", "dom", "globa loading.show(); pollForInfo(page, apiClient); DashboardPage.startInterval(apiClient); - // TODO we currently don't support packages and thus these events are useless events.on(serverNotifications, "RestartRequired", onRestartRequired); events.on(serverNotifications, "ServerShuttingDown", onServerShuttingDown); events.on(serverNotifications, "ServerRestarting", onServerRestarting);