1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

minor changes to dashboard controller

This commit is contained in:
dkanada 2019-09-05 11:42:38 -07:00
parent df2ae88a72
commit b4a5794573

View file

@ -12,27 +12,23 @@ define(["datetime", "events", "itemHelper", "serverNotifications", "dom", "globa
function showPlaybackInfo(btn, session) { function showPlaybackInfo(btn, session) {
require(["alert"], function (alert) { require(["alert"], function (alert) {
var showTranscodeReasons;
var title; var title;
var text = []; 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"); title = globalize.translate("DirectStreaming");
text.push(globalize.translate("DirectStreamHelp1")); text.push(globalize.translate("DirectStreamHelp1"));
text.push("<br/>"); text.push("<br/>");
text.push(globalize.translate("DirectStreamHelp2")); text.push(globalize.translate("DirectStreamHelp2"));
} else if (isTranscode) { } else if (displayPlayMethod === "Transcode") {
title = globalize.translate("Transcoding"); title = globalize.translate("Transcoding");
text.push(globalize.translate("MediaIsBeingConverted")); text.push(globalize.translate("MediaIsBeingConverted"));
if (session.TranscodingInfo && session.TranscodingInfo.TranscodeReasons && session.TranscodingInfo.TranscodeReasons.length) { if (session.TranscodingInfo && session.TranscodingInfo.TranscodeReasons && session.TranscodingInfo.TranscodeReasons.length) {
text.push("<br/>"); text.push("<br/>");
text.push(globalize.translate("LabelReasonForTranscoding")); text.push(globalize.translate("LabelReasonForTranscoding"));
session.TranscodingInfo.TranscodeReasons.forEach(function (transcodeReason) { 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 += '<div class="flex align-items-center justify-content-center">'; html += '<div class="flex align-items-center justify-content-center">';
var userImage = DashboardPage.getUserImage(session); var userImage = DashboardPage.getUserImage(session);
html += userImage ? '<img style="height:1.71em;border-radius:50px;margin-right:.5em;" src="' + userImage + '" />' : '<div style="height:1.71em;"></div>'; html += userImage ? '<img style="height:1.71em;border-radius:50px;margin-right:.5em;" src="' + userImage + '" />' : '<div style="height:1.71em;"></div>';
html += '<div class="sessionUserName" style="text-transform:uppercase;">'; html += '<div class="sessionUserName">';
html += DashboardPage.getUsersHtml(session) || "&nbsp;"; html += DashboardPage.getUsersHtml(session);
html += "</div>"; html += "</div>";
html += "</div>"; html += "</div>";
html += "</div>"; html += "</div>";
@ -398,13 +394,12 @@ define(["datetime", "events", "itemHelper", "serverNotifications", "dom", "globa
} }
if (showTranscodingInfo) { if (showTranscodingInfo) {
var line = []; var line = [];
if (session.TranscodingInfo) { if (session.TranscodingInfo) {
if (session.TranscodingInfo.Bitrate) { if (session.TranscodingInfo.Bitrate) {
if (session.TranscodingInfo.Bitrate > 1e6) { if (session.TranscodingInfo.Bitrate > 1e6) {
line.push((session.TranscodingInfo.Bitrate / 1e6).toFixed(1) + " Mbps"); line.push((session.TranscodingInfo.Bitrate / 1e6).toFixed(1) + " Mbps");
} else { } 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 || "&nbsp;"; return html;
}, },
getSessionNowPlayingTime: function (session) { getSessionNowPlayingTime: function (session) {
var nowPlayingItem = session.NowPlayingItem; var nowPlayingItem = session.NowPlayingItem;
@ -436,7 +431,7 @@ define(["datetime", "events", "itemHelper", "serverNotifications", "dom", "globa
if (session.PlayState.PositionTicks) { if (session.PlayState.PositionTicks) {
html += datetime.getDisplayRunningTime(session.PlayState.PositionTicks); html += datetime.getDisplayRunningTime(session.PlayState.PositionTicks);
} else { } else {
html += "--:--:--"; html += "0:00";
} }
html += " / "; html += " / ";
@ -444,10 +439,8 @@ define(["datetime", "events", "itemHelper", "serverNotifications", "dom", "globa
if (nowPlayingItem && nowPlayingItem.RunTimeTicks) { if (nowPlayingItem && nowPlayingItem.RunTimeTicks) {
html += datetime.getDisplayRunningTime(nowPlayingItem.RunTimeTicks); html += datetime.getDisplayRunningTime(nowPlayingItem.RunTimeTicks);
} else { } else {
html += "--:--:--"; html += "0:00";
} }
return html;
} }
return html; return html;
@ -488,15 +481,13 @@ define(["datetime", "events", "itemHelper", "serverNotifications", "dom", "globa
maxWidth: 130, maxWidth: 130,
type: "Logo" type: "Logo"
}); });
} else { } else if (nowPlayingItem.ParentLogoImageTag) {
if (nowPlayingItem.ParentLogoImageTag) { imgUrl = ApiClient.getScaledImageUrl(nowPlayingItem.ParentLogoItemId, {
imgUrl = ApiClient.getScaledImageUrl(nowPlayingItem.ParentLogoItemId, { tag: nowPlayingItem.ParentLogoImageTag,
tag: nowPlayingItem.ParentLogoImageTag, maxHeight: 24,
maxHeight: 24, maxWidth: 130,
maxWidth: 130, type: "Logo"
type: "Logo" });
});
}
} }
if (imgUrl) { if (imgUrl) {
@ -510,7 +501,6 @@ define(["datetime", "events", "itemHelper", "serverNotifications", "dom", "globa
}, },
getUsersHtml: function (session) { getUsersHtml: function (session) {
var html = []; var html = [];
if (session.UserId) { if (session.UserId) {
html.push(session.UserName); html.push(session.UserName);
} }
@ -787,7 +777,6 @@ define(["datetime", "events", "itemHelper", "serverNotifications", "dom", "globa
loading.show(); loading.show();
pollForInfo(page, apiClient); pollForInfo(page, apiClient);
DashboardPage.startInterval(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, "RestartRequired", onRestartRequired);
events.on(serverNotifications, "ServerShuttingDown", onServerShuttingDown); events.on(serverNotifications, "ServerShuttingDown", onServerShuttingDown);
events.on(serverNotifications, "ServerRestarting", onServerRestarting); events.on(serverNotifications, "ServerRestarting", onServerRestarting);