jellyfin-web/dashboard-ui/scripts/dashboardpage.js

1418 lines
49 KiB
JavaScript
Raw Normal View History

define(['datetime', 'jQuery', 'dom', 'humanedate', 'cardStyle', 'listViewStyle'], function (datetime, $, dom) {
2016-10-22 22:11:46 -07:00
'use strict';
2013-02-20 18:33:05 -07:00
2016-05-19 22:36:57 -07:00
function renderNoHealthAlertsMessage(page) {
var html = '<p style="padding:0 .5em;display:flex;align-items:center;">';
html += '<iron-icon icon="check" style="margin-right:.5em;background-color: #52B54B;border-radius:1em;color: #fff;"></iron-icon>';
html += Globalize.translate('HealthMonitorNoAlerts') + '</p>';
page.querySelector('.healthMonitor').innerHTML = html;
}
function refreshHealthMonitor(page) {
renderNoHealthAlertsMessage(page);
}
2016-08-25 11:24:54 -07:00
function onConnectionHelpClick(e) {
e.preventDefault();
return false;
}
2016-09-21 23:57:31 -07:00
function onEditServerNameClick(e) {
var page = dom.parentWithClass(this, 'page');
require(['prompt'], function (prompt) {
prompt({
label: Globalize.translate('LabelFriendlyServerName'),
description: Globalize.translate('LabelFriendlyServerNameHelp'),
2016-09-22 23:57:24 -07:00
value: page.querySelector('.serverNameHeader').innerHTML,
2016-10-05 00:15:29 -07:00
confirmText: Globalize.translate('ButtonSave')
2016-09-21 23:57:31 -07:00
}).then(function (value) {
Dashboard.showLoadingMsg();
ApiClient.getServerConfiguration().then(function (config) {
config.ServerName = value;
ApiClient.updateServerConfiguration(config).then(function () {
page.querySelector('.serverNameHeader').innerHTML = value;
Dashboard.hideLoadingMsg();
});
});
});
});
e.preventDefault();
return false;
}
2016-05-05 23:02:10 -07:00
window.DashboardPage = {
2014-01-22 13:46:01 -07:00
2016-05-05 23:02:10 -07:00
newsStartIndex: 0,
2013-02-20 18:33:05 -07:00
2016-08-25 11:24:54 -07:00
onPageInit: function () {
var page = this;
2016-08-26 10:24:04 -07:00
page.querySelector('.btnConnectionHelp').addEventListener('click', onConnectionHelpClick);
2016-09-21 23:57:31 -07:00
page.querySelector('.btnEditServerName').addEventListener('click', onEditServerNameClick);
2016-08-25 11:24:54 -07:00
},
2016-05-05 23:02:10 -07:00
onPageShow: function () {
2013-12-24 11:37:29 -07:00
2016-05-05 23:02:10 -07:00
var page = this;
2015-05-19 12:15:40 -07:00
2016-05-05 23:02:10 -07:00
var apiClient = ApiClient;
2015-05-19 12:15:40 -07:00
2016-05-05 23:02:10 -07:00
if (!apiClient) {
return;
}
2015-01-18 12:53:34 -07:00
2016-05-05 23:02:10 -07:00
DashboardPage.newsStartIndex = 0;
2014-04-07 21:17:18 -07:00
2016-05-05 23:02:10 -07:00
Dashboard.showLoadingMsg();
DashboardPage.pollForInfo(page);
DashboardPage.startInterval(apiClient);
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
Events.on(apiClient, 'websocketmessage', DashboardPage.onWebSocketMessage);
Events.on(apiClient, 'websocketopen', DashboardPage.onWebSocketOpen);
2013-07-07 08:53:26 -07:00
2016-05-05 23:02:10 -07:00
DashboardPage.lastAppUpdateCheck = null;
DashboardPage.lastPluginUpdateCheck = null;
2013-07-07 08:53:26 -07:00
2016-05-05 23:02:10 -07:00
Dashboard.getPluginSecurityInfo().then(function (pluginSecurityInfo) {
2014-01-18 14:52:01 -07:00
2016-05-05 23:02:10 -07:00
DashboardPage.renderSupporterIcon(page, pluginSecurityInfo);
});
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
DashboardPage.reloadSystemInfo(page);
DashboardPage.reloadNews(page);
DashboardPage.sessionUpdateTimer = setInterval(DashboardPage.refreshSessionsLocally, 60000);
2015-02-06 20:25:23 -07:00
2016-05-05 23:02:10 -07:00
$('.activityItems', page).activityLogList();
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
$('.swaggerLink', page).attr('href', apiClient.getUrl('swagger-ui/index.html', {
api_key: ApiClient.accessToken()
}));
2016-05-19 22:36:57 -07:00
refreshHealthMonitor(page);
2016-05-05 23:02:10 -07:00
},
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
onPageHide: function () {
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
var page = this;
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
$('.activityItems', page).activityLogList('destroy');
2015-05-19 12:15:40 -07:00
2016-05-05 23:02:10 -07:00
var apiClient = ApiClient;
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
if (apiClient) {
Events.off(apiClient, 'websocketmessage', DashboardPage.onWebSocketMessage);
Events.off(apiClient, 'websocketopen', DashboardPage.onWebSocketOpen);
DashboardPage.stopInterval(apiClient);
}
2014-05-13 17:46:45 -07:00
2016-05-05 23:02:10 -07:00
if (DashboardPage.sessionUpdateTimer) {
clearInterval(DashboardPage.sessionUpdateTimer);
}
},
2014-07-10 21:27:46 -07:00
2016-05-05 23:02:10 -07:00
renderPaths: function (page, systemInfo) {
2014-07-10 21:27:46 -07:00
2016-05-05 23:02:10 -07:00
$('#cachePath', page).html(systemInfo.CachePath);
$('#logPath', page).html(systemInfo.LogPath);
$('#transcodingTemporaryPath', page).html(systemInfo.TranscodingTempPath);
$('#metadataPath', page).html(systemInfo.InternalMetadataPath);
},
2014-05-13 17:46:45 -07:00
2016-05-05 23:02:10 -07:00
refreshSessionsLocally: function () {
2014-05-13 17:46:45 -07:00
2016-05-05 23:02:10 -07:00
var list = DashboardPage.sessionsList;
2014-01-18 14:52:01 -07:00
2016-05-05 23:02:10 -07:00
if (list) {
DashboardPage.renderActiveConnections($.mobile.activePage, list);
}
},
2014-03-25 14:13:55 -07:00
2016-05-05 23:02:10 -07:00
reloadSystemInfo: function (page) {
2014-03-25 14:13:55 -07:00
2016-05-05 23:02:10 -07:00
ApiClient.getSystemInfo().then(function (systemInfo) {
2014-03-25 14:13:55 -07:00
2016-05-05 23:02:10 -07:00
page.querySelector('.serverNameHeader').innerHTML = systemInfo.ServerName;
2014-03-25 14:13:55 -07:00
2016-09-04 22:39:14 -07:00
var localizedVersion = Globalize.translate('LabelVersionNumber', systemInfo.Version);
if (systemInfo.SystemUpdateLevel && systemInfo.SystemUpdateLevel != 'Release') {
localizedVersion += " " + Globalize.translate('Option' + systemInfo.SystemUpdateLevel).toLowerCase();
}
$('#appVersionNumber', page).html(localizedVersion);
2015-01-17 12:59:06 -07:00
2016-05-05 23:02:10 -07:00
if (systemInfo.SupportsHttps) {
2016-09-21 23:57:31 -07:00
$('#ports', page).html(Globalize.translate('LabelRunningOnPorts', systemInfo.HttpServerPortNumber, systemInfo.HttpsPortNumber));
2016-05-05 23:02:10 -07:00
} else {
2016-09-21 23:57:31 -07:00
$('#ports', page).html(Globalize.translate('LabelRunningOnPort', systemInfo.HttpServerPortNumber));
2016-05-05 23:02:10 -07:00
}
if (systemInfo.CanSelfRestart) {
$('.btnRestartContainer', page).removeClass('hide');
} else {
$('.btnRestartContainer', page).addClass('hide');
}
2014-03-25 14:13:55 -07:00
2016-05-05 23:02:10 -07:00
DashboardPage.renderUrls(page, systemInfo);
DashboardPage.renderPendingInstallations(page, systemInfo);
2014-03-25 14:13:55 -07:00
2016-05-05 23:02:10 -07:00
if (systemInfo.CanSelfUpdate) {
$('#btnUpdateApplicationContainer', page).show();
$('#btnManualUpdateContainer', page).hide();
} else {
$('#btnUpdateApplicationContainer', page).hide();
$('#btnManualUpdateContainer', page).show();
}
2014-03-25 14:13:55 -07:00
2016-10-06 11:55:01 -07:00
if (systemInfo.PackageName == 'synology') {
$('#btnManualUpdateContainer').html(Globalize.translate('SynologyUpdateInstructions'));
} else {
$('#btnManualUpdateContainer').html('<a href="http://emby.media/download" target="_blank">' + Globalize.translate('PleaseUpdateManually') + '</a>');
}
2016-05-05 23:02:10 -07:00
DashboardPage.renderPaths(page, systemInfo);
DashboardPage.renderHasPendingRestart(page, systemInfo.HasPendingRestart);
});
},
2014-03-25 14:13:55 -07:00
2016-05-05 23:02:10 -07:00
reloadNews: function (page) {
2014-01-18 14:52:01 -07:00
2016-05-05 23:02:10 -07:00
var query = {
StartIndex: DashboardPage.newsStartIndex,
Limit: 7
};
2014-01-18 14:52:01 -07:00
2016-05-05 23:02:10 -07:00
ApiClient.getProductNews(query).then(function (result) {
2014-01-18 14:52:01 -07:00
2016-05-05 23:02:10 -07:00
var html = result.Items.map(function (item) {
2014-01-18 14:52:01 -07:00
2016-05-05 23:02:10 -07:00
var itemHtml = '';
2014-01-18 14:52:01 -07:00
2016-05-05 23:02:10 -07:00
itemHtml += '<a class="clearLink" href="' + item.Link + '" target="_blank">';
2016-08-08 11:13:52 -07:00
itemHtml += '<div class="listItem listItem-noborder">';
2014-01-18 15:47:44 -07:00
2016-08-05 13:25:09 -07:00
itemHtml += '<i class="listItemIcon md-icon">dvr</i>';
2015-09-29 21:19:45 -07:00
2016-09-13 10:49:13 -07:00
itemHtml += '<div class="listItemBody two-line">';
2015-09-29 21:19:45 -07:00
2016-09-13 10:49:13 -07:00
itemHtml += '<div class="listItemBodyText">';
2016-05-05 23:02:10 -07:00
itemHtml += item.Title;
2016-09-13 10:49:13 -07:00
itemHtml += '</div>';
2015-09-29 21:19:45 -07:00
2016-08-05 13:25:09 -07:00
itemHtml += '<div class="listItemBodyText secondary">';
2016-05-05 23:02:10 -07:00
var date = datetime.parseISO8601Date(item.Date, true);
itemHtml += date.toLocaleDateString();
itemHtml += '</div>';
2014-01-18 15:47:44 -07:00
2016-09-13 10:49:13 -07:00
//itemHtml += '<div class="listItemBodyText secondary listItemBodyText-nowrap">';
//itemHtml += item.Description;
//itemHtml += '</div>';
2014-01-18 14:52:01 -07:00
2016-08-05 13:25:09 -07:00
itemHtml += '</div>';
2015-09-29 21:19:45 -07:00
2016-08-05 13:25:09 -07:00
itemHtml += '</div>';
2016-05-05 23:02:10 -07:00
itemHtml += '</a>';
2015-09-29 21:19:45 -07:00
2016-05-05 23:02:10 -07:00
return itemHtml;
});
2014-01-18 14:52:01 -07:00
2016-05-05 23:02:10 -07:00
var pagingHtml = '';
pagingHtml += '<div>';
pagingHtml += LibraryBrowser.getQueryPagingHtml({
startIndex: query.StartIndex,
limit: query.Limit,
totalRecordCount: result.TotalRecordCount,
showLimit: false,
updatePageSizeSetting: false
});
pagingHtml += '</div>';
2016-05-05 23:02:10 -07:00
html = html.join('') + pagingHtml;
2014-01-22 13:46:01 -07:00
2016-05-05 23:02:10 -07:00
var elem = $('.latestNewsItems', page).html(html);
2014-01-22 13:46:01 -07:00
2016-05-05 23:02:10 -07:00
$('.btnNextPage', elem).on('click', function () {
DashboardPage.newsStartIndex += query.Limit;
DashboardPage.reloadNews(page);
});
2014-01-22 13:46:01 -07:00
2016-05-05 23:02:10 -07:00
$('.btnPreviousPage', elem).on('click', function () {
DashboardPage.newsStartIndex -= query.Limit;
DashboardPage.reloadNews(page);
});
2014-01-22 13:46:01 -07:00
});
2014-01-18 14:52:01 -07:00
2016-05-05 23:02:10 -07:00
},
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
startInterval: function (apiClient) {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
if (apiClient.isWebSocketOpen()) {
apiClient.sendWebSocketMessage("SessionsStart", "0,1500");
apiClient.sendWebSocketMessage("ScheduledTasksInfoStart", "0,1000");
}
},
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
stopInterval: function (apiClient) {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
if (apiClient.isWebSocketOpen()) {
apiClient.sendWebSocketMessage("SessionsStop");
apiClient.sendWebSocketMessage("ScheduledTasksInfoStop");
}
},
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
onWebSocketMessage: function (e, msg) {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
var page = $.mobile.activePage;
2013-12-24 11:37:29 -07:00
2016-05-05 23:02:10 -07:00
if (msg.MessageType == "Sessions") {
DashboardPage.renderInfo(page, msg.Data);
}
else if (msg.MessageType == "RestartRequired") {
DashboardPage.renderHasPendingRestart(page, true);
}
else if (msg.MessageType == "ServerShuttingDown") {
DashboardPage.renderHasPendingRestart(page, true);
}
else if (msg.MessageType == "ServerRestarting") {
DashboardPage.renderHasPendingRestart(page, true);
}
else if (msg.MessageType == "ScheduledTasksInfo") {
2014-03-25 14:13:55 -07:00
2016-05-05 23:02:10 -07:00
var tasks = msg.Data;
2014-03-25 14:13:55 -07:00
2016-05-05 23:02:10 -07:00
DashboardPage.renderRunningTasks(page, tasks);
}
else if (msg.MessageType == "PackageInstalling" || msg.MessageType == "PackageInstallationCompleted") {
2014-06-07 14:06:01 -07:00
2016-05-05 23:02:10 -07:00
DashboardPage.pollForInfo(page, true);
DashboardPage.reloadSystemInfo(page);
}
},
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
onWebSocketOpen: function () {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
var apiClient = this;
2015-05-19 12:15:40 -07:00
2016-05-05 23:02:10 -07:00
DashboardPage.startInterval(apiClient);
},
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
pollForInfo: function (page, forceUpdate) {
2013-12-24 11:37:29 -07:00
2016-05-05 23:02:10 -07:00
var apiClient = window.ApiClient;
2015-05-19 12:15:40 -07:00
2016-05-05 23:02:10 -07:00
if (!apiClient) {
return;
}
2015-05-19 12:15:40 -07:00
2016-05-05 23:02:10 -07:00
apiClient.getSessions().then(function (sessions) {
2014-04-07 21:17:18 -07:00
2016-05-05 23:02:10 -07:00
DashboardPage.renderInfo(page, sessions, forceUpdate);
});
apiClient.getScheduledTasks().then(function (tasks) {
2014-05-31 07:30:59 -07:00
2016-05-05 23:02:10 -07:00
DashboardPage.renderRunningTasks(page, tasks);
});
},
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
renderInfo: function (page, sessions, forceUpdate) {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
DashboardPage.renderActiveConnections(page, sessions);
DashboardPage.renderPluginUpdateInfo(page, forceUpdate);
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
Dashboard.hideLoadingMsg();
},
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
renderActiveConnections: function (page, sessions) {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
var html = '';
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
DashboardPage.sessionsList = sessions;
2014-05-13 17:46:45 -07:00
2016-05-05 23:02:10 -07:00
var parentElement = $('.activeDevices', page);
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
$('.card', parentElement).addClass('deadSession');
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
for (var i = 0, length = sessions.length; i < length; i++) {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
var session = sessions[i];
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
var rowId = 'session' + session.Id;
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
var elem = $('#' + rowId, page);
2016-05-05 23:02:10 -07:00
if (elem.length) {
DashboardPage.updateSession(elem, session);
continue;
}
2016-05-05 23:02:10 -07:00
var nowPlayingItem = session.NowPlayingItem;
2016-08-26 10:24:04 -07:00
var className = nowPlayingItem ? 'scalableCard card activeSession backdropCard backdropCard-scalable' : 'scalableCard card activeSession backdropCard backdropCard-scalable';
2016-05-05 23:02:10 -07:00
if (session.TranscodingInfo && session.TranscodingInfo.CompletionPercentage) {
className += ' transcodingSession';
}
2016-05-05 23:02:10 -07:00
html += '<div class="' + className + '" id="' + rowId + '">';
2013-02-20 18:33:05 -07:00
2016-07-30 14:20:42 -07:00
html += '<div class="cardBox visualCardBox">';
2016-08-23 23:13:15 -07:00
html += '<div class="cardScalable visualCardBox-cardScalable">';
2014-07-26 10:30:15 -07:00
2016-08-11 13:28:49 -07:00
html += '<div class="cardPadder cardPadder-backdrop"></div>';
2016-05-05 23:02:10 -07:00
html += '<div class="cardContent">';
2014-07-26 10:30:15 -07:00
2016-05-05 23:02:10 -07:00
html += '<div class="sessionNowPlayingContent"';
2014-04-14 20:54:52 -07:00
2016-05-05 23:02:10 -07:00
var imgUrl = DashboardPage.getNowPlayingImageUrl(nowPlayingItem);
2014-04-14 20:54:52 -07:00
2016-05-05 23:02:10 -07:00
if (imgUrl) {
html += ' data-src="' + imgUrl + '" style="display:inline-block;background-image:url(\'' + imgUrl + '\');"';
}
2014-04-14 20:54:52 -07:00
2016-05-05 23:02:10 -07:00
html += '></div>';
2014-04-14 20:54:52 -07:00
2016-05-05 23:02:10 -07:00
html += '<div class="sessionNowPlayingInnerContent">';
2014-04-14 20:54:52 -07:00
2016-05-05 23:02:10 -07:00
html += '<div class="sessionAppInfo">';
2014-04-14 20:54:52 -07:00
2016-05-05 23:02:10 -07:00
var clientImage = DashboardPage.getClientImage(session);
2014-04-14 20:54:52 -07:00
2016-05-05 23:02:10 -07:00
if (clientImage) {
html += clientImage;
}
2014-04-14 20:54:52 -07:00
2016-05-05 23:02:10 -07:00
html += '<div class="sessionAppName" style="display:inline-block;">';
html += '<div class="sessionDeviceName">' + session.DeviceName + '</div>';
html += '<div class="sessionAppSecondaryText">' + DashboardPage.getAppSecondaryText(session) + '</div>';
html += '</div>';
2016-05-05 23:02:10 -07:00
html += '</div>';
2014-04-14 20:54:52 -07:00
2016-05-05 23:02:10 -07:00
html += '<div class="sessionNowPlayingTime">' + DashboardPage.getSessionNowPlayingTime(session) + '</div>';
2014-04-14 20:54:52 -07:00
2016-05-05 23:02:10 -07:00
//if (session.TranscodingInfo && session.TranscodingInfo.Framerate) {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
// html += '<div class="sessionTranscodingFramerate">' + session.TranscodingInfo.Framerate + ' fps</div>';
//} else {
// html += '<div class="sessionTranscodingFramerate"></div>';
//}
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
var nowPlayingName = DashboardPage.getNowPlayingName(session);
2014-04-17 22:03:01 -07:00
2016-05-05 23:02:10 -07:00
html += '<div class="sessionNowPlayingInfo" data-imgsrc="' + nowPlayingName.image + '">';
html += nowPlayingName.html;
html += '</div>';
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
if (nowPlayingItem && nowPlayingItem.RunTimeTicks) {
2016-05-05 23:02:10 -07:00
var position = session.PlayState.PositionTicks || 0;
var value = (100 * position) / nowPlayingItem.RunTimeTicks;
2014-04-14 20:54:52 -07:00
2016-08-03 11:26:19 -07:00
html += '<progress class="playbackProgress" min="0" max="100" value="' + value + '"></progress>';
2016-05-05 23:02:10 -07:00
} else {
2016-08-03 11:26:19 -07:00
html += '<progress class="playbackProgress" min="0" max="100" style="display:none;"></progress>';
2016-05-05 23:02:10 -07:00
}
2016-05-05 23:02:10 -07:00
if (session.TranscodingInfo && session.TranscodingInfo.CompletionPercentage) {
2016-08-03 11:26:19 -07:00
html += '<progress class="transcodingProgress" min="0" max="100" value="' + session.TranscodingInfo.CompletionPercentage.toFixed(1) + '"></progress>';
2016-05-05 23:02:10 -07:00
} else {
2016-08-03 11:26:19 -07:00
html += '<progress class="transcodingProgress" min="0" max="100" style="display:none;"></progress>';
2016-05-05 23:02:10 -07:00
}
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
html += '</div>';
2014-04-17 22:03:01 -07:00
2016-05-05 23:02:10 -07:00
html += '</div>';
2014-04-19 10:43:12 -07:00
2016-05-05 23:02:10 -07:00
// cardScalable
html += '</div>';
html += '<div style="padding:1em;border-top:1px solid #eee;background:#fff;text-align:center;">';
html += '<div class="sessionNowPlayingStreamInfo" style="padding:0 0 1em;">';
html += DashboardPage.getSessionNowPlayingStreamInfo(session);
html += '</div>';
html += '<div style="display:flex;align-items:center;justify-content:center;text-transform:uppercase;">';
2016-05-05 23:02:10 -07:00
var userImage = DashboardPage.getUserImage(session);
if (userImage) {
2016-10-15 15:12:16 -07:00
html += '<img style="height:24px;border-radius:50px;margin-right:.5em;" src="' + userImage + '" />';
2016-05-05 23:02:10 -07:00
} else {
html += '<div style="height:24px;"></div>';
}
2014-07-26 10:30:15 -07:00
2016-05-05 23:02:10 -07:00
html += '<div class="sessionUserName">';
html += DashboardPage.getUsersHtml(session) || '&nbsp;';
html += '</div>';
html += '</div>';
html += '</div>';
2016-05-05 23:02:10 -07:00
// cardBox
html += '</div>';
2014-04-17 22:03:01 -07:00
2016-05-05 23:02:10 -07:00
// card
html += '</div>';
}
2016-05-05 23:02:10 -07:00
parentElement.append(html);
2016-05-05 23:02:10 -07:00
$('.deadSession', parentElement).remove();
},
2016-05-05 23:02:10 -07:00
getSessionNowPlayingStreamInfo: function (session) {
2014-04-19 10:43:12 -07:00
2016-05-05 23:02:10 -07:00
var html = '';
2014-04-19 10:43:12 -07:00
2016-05-05 23:02:10 -07:00
//html += '<div>';
var showTranscodingInfo = false;
2016-08-06 12:56:35 -07:00
2016-05-05 23:02:10 -07:00
if (session.TranscodingInfo && session.TranscodingInfo.IsAudioDirect && session.TranscodingInfo.IsVideoDirect) {
html += Globalize.translate('LabelPlayMethodDirectStream');
}
else if (session.TranscodingInfo && session.TranscodingInfo.IsVideoDirect) {
html += Globalize.translate('LabelPlayMethodDirectStream');
}
2016-05-05 23:02:10 -07:00
else if (session.PlayState.PlayMethod == 'Transcode') {
html += Globalize.translate('LabelPlayMethodTranscoding');
2016-03-02 23:03:23 -07:00
2016-05-05 23:02:10 -07:00
if (session.TranscodingInfo && session.TranscodingInfo.Framerate) {
2016-03-02 23:03:23 -07:00
html += ' (' + session.TranscodingInfo.Framerate + ' fps' + ')';
2016-05-05 23:02:10 -07:00
}
showTranscodingInfo = true;
2016-05-05 23:02:10 -07:00
}
else if (session.PlayState.PlayMethod == 'DirectStream') {
html += Globalize.translate('LabelPlayMethodDirectPlay');
}
else if (session.PlayState.PlayMethod == 'DirectPlay') {
html += Globalize.translate('LabelPlayMethodDirectPlay');
2016-03-02 23:03:23 -07:00
}
2014-04-19 10:43:12 -07:00
2016-05-05 23:02:10 -07:00
//html += '</div>';
2014-04-19 10:43:12 -07:00
if (showTranscodingInfo) {
var line = [];
2016-08-06 12:56:35 -07:00
if (session.TranscodingInfo) {
if (session.TranscodingInfo.Bitrate) {
2016-08-06 12:56:35 -07:00
if (session.TranscodingInfo.Bitrate > 1000000) {
line.push((session.TranscodingInfo.Bitrate / 1000000).toFixed(1) + ' Mbps');
} else {
line.push(Math.floor(session.TranscodingInfo.Bitrate / 1000) + ' kbps');
}
}
2016-08-06 12:56:35 -07:00
if (session.TranscodingInfo.Container) {
2016-08-06 12:56:35 -07:00
line.push(session.TranscodingInfo.Container);
}
2016-08-06 12:56:35 -07:00
if (session.TranscodingInfo.VideoCodec) {
2016-08-06 12:56:35 -07:00
//line.push(Globalize.translate('LabelVideoCodec').replace('{0}', session.TranscodingInfo.VideoCodec));
line.push(session.TranscodingInfo.VideoCodec);
}
if (session.TranscodingInfo.AudioCodec && session.TranscodingInfo.AudioCodec != session.TranscodingInfo.Container) {
2016-08-06 12:56:35 -07:00
//line.push(Globalize.translate('LabelAudioCodec').replace('{0}', session.TranscodingInfo.AudioCodec));
line.push(session.TranscodingInfo.AudioCodec);
}
}
if (line.length) {
html += ' - ' + line.join(' ');
}
}
return html || '&nbsp;';
2016-05-05 23:02:10 -07:00
},
2014-04-19 10:43:12 -07:00
2016-05-05 23:02:10 -07:00
getSessionNowPlayingTime: function (session) {
2014-04-19 10:43:12 -07:00
2016-05-05 23:02:10 -07:00
var html = '';
2014-04-19 10:43:12 -07:00
2016-05-05 23:02:10 -07:00
if (session.PlayState.PositionTicks) {
html += datetime.getDisplayRunningTime(session.PlayState.PositionTicks);
} else {
html += '--:--:--';
}
2014-04-19 10:43:12 -07:00
2016-05-05 23:02:10 -07:00
html += ' / ';
2014-04-19 10:43:12 -07:00
2016-05-05 23:02:10 -07:00
var nowPlayingItem = session.NowPlayingItem;
2014-04-19 10:43:12 -07:00
2016-05-05 23:02:10 -07:00
if (nowPlayingItem && nowPlayingItem.RunTimeTicks) {
html += datetime.getDisplayRunningTime(nowPlayingItem.RunTimeTicks);
} else {
html += '--:--:--';
}
2014-04-19 10:43:12 -07:00
2016-05-05 23:02:10 -07:00
return html;
},
2014-04-19 10:43:12 -07:00
2016-05-05 23:02:10 -07:00
getAppSecondaryText: function (session) {
2014-04-17 22:03:01 -07:00
2016-05-05 23:02:10 -07:00
return session.ApplicationVersion;
},
2014-04-17 22:03:01 -07:00
2016-05-05 23:02:10 -07:00
getNowPlayingName: function (session) {
2014-04-14 20:54:52 -07:00
2016-05-05 23:02:10 -07:00
var imgUrl = '';
2014-04-17 22:03:01 -07:00
2016-05-05 23:02:10 -07:00
var nowPlayingItem = session.NowPlayingItem;
2014-04-15 19:17:48 -07:00
2016-05-05 23:02:10 -07:00
if (!nowPlayingItem) {
2014-04-14 20:54:52 -07:00
2016-05-05 23:02:10 -07:00
return {
html: 'Last seen ' + humane_date(session.LastActivityDate),
image: imgUrl
};
}
2014-04-15 19:17:48 -07:00
2016-05-05 23:02:10 -07:00
var topText = nowPlayingItem.Name;
2014-04-14 20:54:52 -07:00
2016-05-05 23:02:10 -07:00
var bottomText = '';
2014-04-14 20:54:52 -07:00
2016-05-05 23:02:10 -07:00
if (nowPlayingItem.Artists && nowPlayingItem.Artists.length) {
bottomText = topText;
topText = nowPlayingItem.Artists[0];
}
else if (nowPlayingItem.SeriesName || nowPlayingItem.Album) {
bottomText = topText;
topText = nowPlayingItem.SeriesName || nowPlayingItem.Album;
}
else if (nowPlayingItem.ProductionYear) {
bottomText = nowPlayingItem.ProductionYear;
}
2016-05-05 23:02:10 -07:00
if (nowPlayingItem.LogoItemId) {
2014-04-17 22:03:01 -07:00
2016-05-05 23:02:10 -07:00
imgUrl = ApiClient.getScaledImageUrl(nowPlayingItem.LogoItemId, {
2014-04-17 22:03:01 -07:00
2016-05-05 23:02:10 -07:00
tag: session.LogoImageTag,
maxHeight: 24,
maxWidth: 130,
type: 'Logo'
2014-04-17 22:03:01 -07:00
2016-05-05 23:02:10 -07:00
});
2014-04-17 22:03:01 -07:00
2016-05-05 23:02:10 -07:00
topText = '<img src="' + imgUrl + '" style="max-height:24px;max-width:130px;" />';
}
2014-04-17 22:03:01 -07:00
2016-05-05 23:02:10 -07:00
var text = bottomText ? topText + '<br/>' + bottomText : topText;
2014-03-14 21:14:07 -07:00
2016-05-05 23:02:10 -07:00
return {
html: text,
image: imgUrl
};
},
2016-05-05 23:02:10 -07:00
getUsersHtml: function (session) {
2016-05-05 23:02:10 -07:00
var html = [];
2016-05-05 23:02:10 -07:00
if (session.UserId) {
html.push(session.UserName);
}
2016-05-05 23:02:10 -07:00
for (var i = 0, length = session.AdditionalUsers.length; i < length; i++) {
2014-01-03 19:59:20 -07:00
2016-05-05 23:02:10 -07:00
html.push(session.AdditionalUsers[i].UserName);
}
2014-04-14 20:54:52 -07:00
2016-05-05 23:02:10 -07:00
return html.join(', ');
},
2014-04-14 20:54:52 -07:00
2016-05-05 23:02:10 -07:00
getUserImage: function (session) {
2014-04-14 20:54:52 -07:00
2016-05-05 23:02:10 -07:00
if (session.UserId && session.UserPrimaryImageTag) {
return ApiClient.getUserImageUrl(session.UserId, {
2014-04-15 19:17:48 -07:00
2016-05-05 23:02:10 -07:00
tag: session.UserPrimaryImageTag,
height: 24,
type: 'Primary'
2014-04-14 20:54:52 -07:00
2016-05-05 23:02:10 -07:00
});
}
2014-01-03 19:59:20 -07:00
2016-05-05 23:02:10 -07:00
return null;
},
2014-01-03 19:59:20 -07:00
2016-05-05 23:02:10 -07:00
updateSession: function (row, session) {
2014-01-03 19:59:20 -07:00
2016-05-05 23:02:10 -07:00
row.removeClass('deadSession');
2014-01-03 19:59:20 -07:00
2016-05-05 23:02:10 -07:00
var nowPlayingItem = session.NowPlayingItem;
2016-05-05 23:02:10 -07:00
if (nowPlayingItem) {
row.addClass('playingSession');
} else {
row.removeClass('playingSession');
}
2014-04-14 20:54:52 -07:00
2016-05-05 23:02:10 -07:00
$('.sessionNowPlayingStreamInfo', row).html(DashboardPage.getSessionNowPlayingStreamInfo(session));
$('.sessionNowPlayingTime', row).html(DashboardPage.getSessionNowPlayingTime(session));
2014-04-19 10:43:12 -07:00
2016-05-05 23:02:10 -07:00
$('.sessionUserName', row).html(DashboardPage.getUsersHtml(session) || '&nbsp;');
2016-05-05 23:02:10 -07:00
$('.sessionAppSecondaryText', row).html(DashboardPage.getAppSecondaryText(session));
2014-04-17 22:03:01 -07:00
2016-05-05 23:02:10 -07:00
$('.sessionTranscodingFramerate', row).html((session.TranscodingInfo && session.TranscodingInfo.Framerate) ? session.TranscodingInfo.Framerate + ' fps' : '');
2016-05-05 23:02:10 -07:00
var nowPlayingName = DashboardPage.getNowPlayingName(session);
var nowPlayingInfoElem = $('.sessionNowPlayingInfo', row);
2016-05-05 23:02:10 -07:00
if (!nowPlayingName.image || nowPlayingName.image != nowPlayingInfoElem.attr('data-imgsrc')) {
nowPlayingInfoElem.html(nowPlayingName.html);
nowPlayingInfoElem.attr('data-imgsrc', nowPlayingName.image || '');
}
2014-04-19 10:43:12 -07:00
2016-05-05 23:02:10 -07:00
if (nowPlayingItem && nowPlayingItem.RunTimeTicks) {
2016-05-05 23:02:10 -07:00
var position = session.PlayState.PositionTicks || 0;
var value = (100 * position) / nowPlayingItem.RunTimeTicks;
2016-05-05 23:02:10 -07:00
$('.playbackProgress', row).show().val(value);
} else {
$('.playbackProgress', row).hide();
}
2016-05-05 23:02:10 -07:00
if (session.TranscodingInfo && session.TranscodingInfo.CompletionPercentage) {
2016-05-05 23:02:10 -07:00
row.addClass('transcodingSession');
$('.transcodingProgress', row).show().val(session.TranscodingInfo.CompletionPercentage);
} else {
$('.transcodingProgress', row).hide();
row.removeClass('transcodingSession');
}
2014-04-14 20:54:52 -07:00
2016-05-05 23:02:10 -07:00
var imgUrl = DashboardPage.getNowPlayingImageUrl(nowPlayingItem) || '';
var imgElem = $('.sessionNowPlayingContent', row)[0];
2014-04-14 20:54:52 -07:00
2016-05-05 23:02:10 -07:00
if (imgUrl != imgElem.getAttribute('data-src')) {
imgElem.style.backgroundImage = imgUrl ? 'url(\'' + imgUrl + '\')' : '';
imgElem.setAttribute('data-src', imgUrl);
}
},
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
getClientImage: function (connection) {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
var clientLowered = connection.Client.toLowerCase();
var device = connection.DeviceName.toLowerCase();
2013-05-18 11:58:03 -07:00
2016-05-05 23:02:10 -07:00
if (connection.AppIconUrl) {
return "<img src='" + connection.AppIconUrl + "' />";
}
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
if (clientLowered == "dashboard" || clientLowered == "emby web client") {
2013-06-02 05:13:41 -07:00
2016-05-05 23:02:10 -07:00
var imgUrl;
2013-06-02 05:13:41 -07:00
2016-05-05 23:02:10 -07:00
if (device.indexOf('chrome') != -1) {
imgUrl = 'css/images/clients/chrome.png';
}
else {
imgUrl = 'css/images/clients/html5.png';
}
return "<img src='" + imgUrl + "' alt='Emby Web Client' />";
2013-06-02 05:13:41 -07:00
}
2016-05-05 23:02:10 -07:00
if (clientLowered.indexOf('android') != -1) {
return "<img src='css/images/clients/android.png' />";
}
if (clientLowered.indexOf('ios') != -1) {
return "<img src='css/images/clients/ios.png' />";
2013-06-02 05:13:41 -07:00
}
2016-05-05 23:02:10 -07:00
if (clientLowered == "mb-classic") {
2013-06-02 05:13:41 -07:00
2016-05-05 23:02:10 -07:00
return "<img src='css/images/clients/mbc.png' />";
}
if (clientLowered == "roku") {
2013-03-21 13:20:00 -07:00
2016-05-05 23:02:10 -07:00
return "<img src='css/images/clients/roku.jpg' />";
}
if (clientLowered == "windows phone") {
2013-05-22 12:31:27 -07:00
2016-05-05 23:02:10 -07:00
return "<img src='css/images/clients/windowsphone.png' />";
}
if (clientLowered == "dlna") {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
return "<img src='css/images/clients/dlna.png' />";
}
if (clientLowered == "kodi" || clientLowered == "xbmc") {
return "<img src='css/images/clients/kodi.png' />";
}
if (clientLowered == "chromecast") {
2013-03-04 19:32:14 -07:00
2016-05-05 23:02:10 -07:00
return "<img src='css/images/clients/chromecast.png' />";
}
2014-04-07 21:17:18 -07:00
2016-05-05 23:02:10 -07:00
return null;
},
2016-05-05 23:02:10 -07:00
getNowPlayingImageUrl: function (item) {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
if (item && item.BackdropImageTag) {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
return ApiClient.getScaledImageUrl(item.BackdropItemId, {
type: "Backdrop",
width: 275,
tag: item.BackdropImageTag
});
}
2014-03-14 21:14:07 -07:00
2016-05-05 23:02:10 -07:00
if (item && item.ThumbImageTag) {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
return ApiClient.getScaledImageUrl(item.ThumbItemId, {
type: "Thumb",
width: 275,
tag: item.ThumbImageTag
});
}
2014-03-14 21:14:07 -07:00
2016-05-05 23:02:10 -07:00
if (item && item.PrimaryImageTag) {
2014-03-14 21:14:07 -07:00
2016-05-05 23:02:10 -07:00
return ApiClient.getScaledImageUrl(item.PrimaryImageItemId, {
type: "Primary",
width: 275,
tag: item.PrimaryImageTag
});
}
2014-03-14 21:14:07 -07:00
2016-05-05 23:02:10 -07:00
return null;
},
2014-03-14 21:14:07 -07:00
2016-05-05 23:02:10 -07:00
systemUpdateTaskKey: "SystemUpdateTask",
2014-03-14 21:14:07 -07:00
2016-05-05 23:02:10 -07:00
renderRunningTasks: function (page, tasks) {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
var html = '';
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
tasks = tasks.filter(function (t) {
return t.State != 'Idle' && !t.IsHidden;
});
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
if (tasks.filter(function (t) {
2014-03-25 14:13:55 -07:00
2016-05-05 23:02:10 -07:00
return t.Key == DashboardPage.systemUpdateTaskKey;
2014-03-25 14:13:55 -07:00
2016-05-05 23:02:10 -07:00
}).length) {
2014-03-25 14:13:55 -07:00
2016-05-05 23:02:10 -07:00
$('#btnUpdateApplication', page).buttonEnabled(false);
} else {
$('#btnUpdateApplication', page).buttonEnabled(true);
}
2014-03-25 14:13:55 -07:00
2016-05-05 23:02:10 -07:00
if (!tasks.length) {
$('#runningTasksCollapsible', page).hide();
} else {
$('#runningTasksCollapsible', page).show();
}
2014-03-25 14:13:55 -07:00
2016-05-05 23:02:10 -07:00
for (var i = 0, length = tasks.length; i < length; i++) {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
var task = tasks[i];
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
html += '<p>';
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
html += task.Name + "<br/>";
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
if (task.State == "Running") {
var progress = (task.CurrentProgressPercentage || 0).toFixed(1);
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
html += '<progress max="100" value="' + progress + '" title="' + progress + '%">';
html += '' + progress + '%';
html += '</progress>';
2016-05-05 23:02:10 -07:00
html += "<span style='color:#009F00;margin-left:5px;margin-right:5px;'>" + progress + "%</span>";
2016-07-23 13:50:12 -07:00
html += '<button type="button" is="paper-icon-button-light" title="' + Globalize.translate('ButtonStop') + '" onclick="DashboardPage.stopTask(\'' + task.Id + '\');" class="autoSize"><i class="md-icon">cancel</i></button>';
2016-05-05 23:02:10 -07:00
}
else if (task.State == "Cancelling") {
html += '<span style="color:#cc0000;">' + Globalize.translate('LabelStopping') + '</span>';
}
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
html += '</p>';
2013-02-20 18:33:05 -07:00
}
2016-05-05 23:02:10 -07:00
$('#divRunningTasks', page).html(html);
},
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
renderUrls: function (page, systemInfo) {
2013-02-20 18:33:05 -07:00
2016-10-10 11:18:28 -07:00
var helpButton = '<a href="https://github.com/MediaBrowser/Wiki/wiki/Connectivity" target="_blank" style="margin-left:1em;color:#fff;background:#52B54B;padding:.25em 1em;border-radius:.5em;">' + Globalize.translate('ButtonHelp') + '</a>';
2016-05-05 23:02:10 -07:00
if (systemInfo.LocalAddress) {
2016-05-05 23:02:10 -07:00
var localAccessHtml = Globalize.translate('LabelLocalAccessUrl', '<a href="' + systemInfo.LocalAddress + '" target="_blank">' + systemInfo.LocalAddress + '</a>');
2015-01-18 21:29:57 -07:00
2016-10-10 11:18:28 -07:00
$('.localUrl', page).html(localAccessHtml + helpButton).show().trigger('create');
2016-05-05 23:02:10 -07:00
} else {
$('.externalUrl', page).hide();
}
2015-12-14 08:43:03 -07:00
2016-05-05 23:02:10 -07:00
if (systemInfo.WanAddress) {
2015-01-18 21:29:57 -07:00
2016-05-05 23:02:10 -07:00
var externalUrl = systemInfo.WanAddress;
2014-02-26 14:31:47 -07:00
2016-05-05 23:02:10 -07:00
var remoteAccessHtml = Globalize.translate('LabelRemoteAccessUrl', '<a href="' + externalUrl + '" target="_blank">' + externalUrl + '</a>');
2014-02-26 14:31:47 -07:00
2016-10-10 11:18:28 -07:00
$('.externalUrl', page).html(remoteAccessHtml + helpButton).show().trigger('create');
2016-05-05 23:02:10 -07:00
} else {
$('.externalUrl', page).hide();
}
},
2014-06-17 09:03:14 -07:00
2016-05-05 23:02:10 -07:00
renderSupporterIcon: function (page, pluginSecurityInfo) {
2014-02-26 14:31:47 -07:00
2016-05-05 23:02:10 -07:00
var imgUrl, text;
2014-06-21 22:52:31 -07:00
2016-06-29 19:38:20 -07:00
var supporterIconContainer = page.querySelector('.supporterIconContainer');
2016-05-05 23:02:10 -07:00
if (!AppInfo.enableSupporterMembership) {
2016-06-29 19:38:20 -07:00
supporterIconContainer.classList.add('hide');
2016-05-05 23:02:10 -07:00
}
else if (pluginSecurityInfo.IsMBSupporter) {
2014-06-21 22:52:31 -07:00
2016-06-29 19:38:20 -07:00
supporterIconContainer.classList.remove('hide');
2016-05-05 23:02:10 -07:00
imgUrl = "css/images/supporter/supporterbadge.png";
text = Globalize.translate('MessageThankYouForSupporting');
2014-06-21 22:52:31 -07:00
2016-06-29 19:38:20 -07:00
supporterIconContainer.innerHTML = '<a class="imageLink supporterIcon" href="http://emby.media/premiere" target="_blank" title="' + text + '"><img src="' + imgUrl + '" style="height:32px;vertical-align: middle; margin-right: .5em;" /></a><span style="position:relative;top:2px;text-decoration:none;">' + text + '</span>';
2016-05-05 23:02:10 -07:00
} else {
2014-06-21 22:52:31 -07:00
2016-06-29 19:38:20 -07:00
supporterIconContainer.classList.add('hide');
2016-05-05 23:02:10 -07:00
}
},
2014-07-10 21:27:46 -07:00
2016-05-05 23:02:10 -07:00
renderHasPendingRestart: function (page, hasPendingRestart) {
2014-06-21 22:52:31 -07:00
2016-05-05 23:02:10 -07:00
if (!hasPendingRestart) {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
// Only check once every 30 mins
if (DashboardPage.lastAppUpdateCheck && (new Date().getTime() - DashboardPage.lastAppUpdateCheck) < 1800000) {
return;
}
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
DashboardPage.lastAppUpdateCheck = new Date().getTime();
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
ApiClient.getAvailableApplicationUpdate().then(function (packageInfo) {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
var version = packageInfo[0];
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
if (!version) {
page.querySelector('#pUpToDate').classList.remove('hide');
$('#pUpdateNow', page).hide();
} else {
page.querySelector('#pUpToDate').classList.add('hide');
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
$('#pUpdateNow', page).show();
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
$('#newVersionNumber', page).html(Globalize.translate('VersionXIsAvailableForDownload').replace('{0}', version.versionStr));
}
2013-12-24 11:37:29 -07:00
2016-05-05 23:02:10 -07:00
});
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
} else {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
page.querySelector('#pUpToDate').classList.add('hide');
2016-05-05 23:02:10 -07:00
$('#pUpdateNow', page).hide();
}
},
2016-05-05 23:02:10 -07:00
renderPendingInstallations: function (page, systemInfo) {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
if (systemInfo.CompletedInstallations.length) {
2016-05-05 23:02:10 -07:00
$('#collapsiblePendingInstallations', page).show();
2016-05-05 23:02:10 -07:00
} else {
$('#collapsiblePendingInstallations', page).hide();
2016-05-05 23:02:10 -07:00
return;
}
2016-05-05 23:02:10 -07:00
var html = '';
2016-05-05 23:02:10 -07:00
for (var i = 0, length = systemInfo.CompletedInstallations.length; i < length; i++) {
2016-05-05 23:02:10 -07:00
var update = systemInfo.CompletedInstallations[i];
2016-05-05 23:02:10 -07:00
html += '<div><strong>' + update.Name + '</strong> (' + update.Version + ')</div>';
}
2016-05-05 23:02:10 -07:00
$('#pendingInstallations', page).html(html);
},
2016-05-05 23:02:10 -07:00
renderPluginUpdateInfo: function (page, forceUpdate) {
2016-05-05 23:02:10 -07:00
// Only check once every 30 mins
if (!forceUpdate && DashboardPage.lastPluginUpdateCheck && (new Date().getTime() - DashboardPage.lastPluginUpdateCheck) < 1800000) {
return;
}
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
DashboardPage.lastPluginUpdateCheck = new Date().getTime();
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
ApiClient.getAvailablePluginUpdates().then(function (updates) {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
var elem = $('#pPluginUpdates', page);
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
if (updates.length) {
2016-05-05 23:02:10 -07:00
elem.show();
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
} else {
elem.hide();
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
return;
}
var html = '';
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
for (var i = 0, length = updates.length; i < length; i++) {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
var update = updates[i];
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
html += '<p><strong>' + Globalize.translate('NewVersionOfSomethingAvailable').replace('{0}', update.name) + '</strong></p>';
2013-02-20 18:33:05 -07:00
2016-09-23 23:22:03 -07:00
html += '<button type="button" is="emby-button" class="raised block" onclick="DashboardPage.installPluginUpdate(this);" data-name="' + update.name + '" data-guid="' + update.guid + '" data-version="' + update.versionStr + '" data-classification="' + update.classification + '">' + Globalize.translate('ButtonUpdateNow') + '</button>';
2016-05-05 23:02:10 -07:00
}
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
elem.html(html);
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
});
},
2016-05-05 23:02:10 -07:00
installPluginUpdate: function (button) {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
$(button).buttonEnabled(false);
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
var name = button.getAttribute('data-name');
var guid = button.getAttribute('data-guid');
var version = button.getAttribute('data-version');
var classification = button.getAttribute('data-classification');
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
Dashboard.showLoadingMsg();
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
ApiClient.installPlugin(name, guid, classification, version).then(function () {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
Dashboard.hideLoadingMsg();
});
},
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
updateApplication: function () {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
var page = $.mobile.activePage;
$('#btnUpdateApplication', page).buttonEnabled(false);
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
Dashboard.showLoadingMsg();
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
ApiClient.getScheduledTasks().then(function (tasks) {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
var task = tasks.filter(function (t) {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
return t.Key == DashboardPage.systemUpdateTaskKey;
})[0];
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
ApiClient.startScheduledTask(task.Id).then(function () {
2014-03-25 14:13:55 -07:00
2016-05-05 23:02:10 -07:00
DashboardPage.pollForInfo(page);
2014-03-25 14:13:55 -07:00
2016-05-05 23:02:10 -07:00
Dashboard.hideLoadingMsg();
});
2014-03-25 14:13:55 -07:00
});
2016-05-05 23:02:10 -07:00
},
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
stopTask: function (id) {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
var page = $.mobile.activePage;
2013-12-24 11:37:29 -07:00
2016-05-05 23:02:10 -07:00
ApiClient.stopScheduledTask(id).then(function () {
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
DashboardPage.pollForInfo(page);
});
2013-02-20 18:33:05 -07:00
2016-05-05 23:02:10 -07:00
},
2016-05-05 23:02:10 -07:00
restart: function () {
2016-05-05 23:02:10 -07:00
require(['confirm'], function (confirm) {
2016-02-22 12:12:06 -07:00
2016-09-17 22:52:10 -07:00
confirm({
2016-09-21 23:57:31 -07:00
2016-09-17 22:52:10 -07:00
title: Globalize.translate('HeaderRestart'),
text: Globalize.translate('MessageConfirmRestart'),
confirmText: Globalize.translate('ButtonRestart'),
primary: 'cancel'
}).then(function () {
2016-05-05 23:02:10 -07:00
$('#btnRestartServer').buttonEnabled(false);
$('#btnShutdown').buttonEnabled(false);
Dashboard.restartServer();
});
2016-02-22 12:12:06 -07:00
});
2016-05-05 23:02:10 -07:00
},
2013-10-01 08:16:38 -07:00
2016-05-05 23:02:10 -07:00
shutdown: function () {
2013-10-01 08:16:38 -07:00
2016-05-05 23:02:10 -07:00
require(['confirm'], function (confirm) {
2016-02-22 12:12:06 -07:00
2016-09-17 22:52:10 -07:00
confirm({
title: Globalize.translate('HeaderShutdown'),
text: Globalize.translate('MessageConfirmShutdown'),
confirmText: Globalize.translate('ButtonShutdown'),
primary: 'cancel'
}).then(function () {
2013-10-01 08:16:38 -07:00
2016-05-05 23:02:10 -07:00
$('#btnRestartServer').buttonEnabled(false);
$('#btnShutdown').buttonEnabled(false);
ApiClient.shutdownServer();
});
2016-02-22 12:12:06 -07:00
});
2016-05-05 23:02:10 -07:00
}
};
2013-02-20 18:33:05 -07:00
2016-08-25 11:24:54 -07:00
$(document).on('pageinit', "#dashboardPage", DashboardPage.onPageInit).on('pageshow', "#dashboardPage", DashboardPage.onPageShow).on('pagebeforehide', "#dashboardPage", DashboardPage.onPageHide);
2014-04-17 22:03:01 -07:00
2016-05-05 23:02:10 -07:00
(function ($, document, window) {
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
function getEntryHtml(entry) {
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
var html = '';
2014-08-10 15:13:17 -07:00
2016-08-08 11:13:52 -07:00
html += '<div class="listItem listItem-noborder">';
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
var color = entry.Severity == 'Error' || entry.Severity == 'Fatal' || entry.Severity == 'Warn' ? '#cc0000' : '#52B54B';
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
if (entry.UserId && entry.UserPrimaryImageTag) {
2014-10-01 17:28:16 -07:00
2016-05-05 23:02:10 -07:00
var userImgUrl = ApiClient.getUserImageUrl(entry.UserId, {
type: 'Primary',
tag: entry.UserPrimaryImageTag,
height: 40
});
2015-09-29 21:19:45 -07:00
2016-08-05 13:25:09 -07:00
html += '<i class="listItemIcon md-icon" style="width:2em!important;height:2em!important;padding:0;color:transparent;background-color:' + color + ';background-image:url(\'' + userImgUrl + '\');background-repeat:no-repeat;background-position:center center;background-size: cover;">dvr</i>';
2016-05-05 23:02:10 -07:00
}
else {
2016-08-05 13:25:09 -07:00
html += '<i class="listItemIcon md-icon" style="background-color:' + color + '">dvr</i>';
2016-05-05 23:02:10 -07:00
}
2014-10-01 17:28:16 -07:00
2016-08-05 13:25:09 -07:00
html += '<div class="listItemBody three-line">';
2014-10-04 11:05:24 -07:00
2016-09-13 10:49:13 -07:00
html += '<div class="listItemBodyText">';
2016-05-05 23:02:10 -07:00
html += entry.Name;
2016-09-13 10:49:13 -07:00
html += '</div>';
2014-08-10 15:13:17 -07:00
2016-08-05 13:25:09 -07:00
html += '<div class="listItemBodyText secondary">';
2016-05-05 23:02:10 -07:00
var date = datetime.parseISO8601Date(entry.Date, true);
html += date.toLocaleDateString() + ' ' + date.toLocaleTimeString().toLowerCase();
html += '</div>';
2015-09-29 21:13:48 -07:00
2016-08-05 13:25:09 -07:00
html += '<div class="listItemBodyText secondary listItemBodyText-nowrap">';
2016-05-05 23:02:10 -07:00
html += entry.ShortOverview || '';
html += '</div>';
2015-09-21 18:05:33 -07:00
2016-08-05 13:25:09 -07:00
html += '</div>';
2015-09-29 21:19:45 -07:00
2016-08-05 13:25:09 -07:00
html += '</div>';
2015-09-29 21:19:45 -07:00
2016-05-05 23:02:10 -07:00
return html;
}
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
function renderList(elem, result, startIndex, limit) {
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
var html = result.Items.map(getEntryHtml).join('');
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
if (result.TotalRecordCount > limit) {
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
var query = { StartIndex: startIndex, Limit: limit };
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
html += LibraryBrowser.getQueryPagingHtml({
startIndex: query.StartIndex,
limit: query.Limit,
totalRecordCount: result.TotalRecordCount,
showLimit: false,
updatePageSizeSetting: false
});
}
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
$(elem).html(html);
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
$('.btnNextPage', elem).on('click', function () {
reloadData(elem, startIndex + limit, limit);
});
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
$('.btnPreviousPage', elem).on('click', function () {
reloadData(elem, startIndex - limit, limit);
});
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
$('.btnShowOverview', elem).on('click', function () {
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
var item = $(this).parents('.newsItem');
var overview = $('.newsItemLongDescription', item).html();
var name = $('.notificationName', item).html();
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
Dashboard.alert({
message: '<div style="max-height:300px; overflow: auto;">' + overview + '</div>',
title: name
});
2014-08-10 15:13:17 -07:00
});
2016-05-05 23:02:10 -07:00
}
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
function reloadData(elem, startIndex, limit) {
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
if (startIndex == null) {
startIndex = parseInt(elem.getAttribute('data-activitystartindex') || '0');
}
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
limit = limit || parseInt(elem.getAttribute('data-activitylimit') || '7');
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
// Show last 24 hours
var minDate = new Date();
minDate.setTime(minDate.getTime() - 86400000);
2014-08-14 06:24:30 -07:00
2016-05-05 23:02:10 -07:00
ApiClient.getJSON(ApiClient.getUrl('System/ActivityLog/Entries', {
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
startIndex: startIndex,
limit: limit,
minDate: minDate.toISOString()
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
})).then(function (result) {
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
elem.setAttribute('data-activitystartindex', startIndex);
elem.setAttribute('data-activitylimit', limit);
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
renderList(elem, result, startIndex, limit);
});
}
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
function createList(elem) {
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
elem.each(function () {
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
reloadData(this);
}).addClass('activityLogListWidget');
2015-06-29 11:45:42 -07:00
2016-05-05 23:02:10 -07:00
var apiClient = ApiClient;
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
if (!apiClient) {
return;
}
2015-05-19 12:15:40 -07:00
2016-05-05 23:02:10 -07:00
Events.on(apiClient, 'websocketopen', onSocketOpen);
Events.on(apiClient, 'websocketmessage', onSocketMessage);
2015-05-19 12:15:40 -07:00
}
2016-05-05 23:02:10 -07:00
function startListening(apiClient) {
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
if (apiClient.isWebSocketOpen()) {
apiClient.sendWebSocketMessage("ActivityLogEntryStart", "0,1500");
}
2014-10-04 11:05:24 -07:00
2014-08-11 07:15:53 -07:00
}
2016-05-05 23:02:10 -07:00
function stopListening(apiClient) {
2014-08-11 07:15:53 -07:00
2016-05-05 23:02:10 -07:00
if (apiClient.isWebSocketOpen()) {
apiClient.sendWebSocketMessage("ActivityLogEntryStop", "0,1500");
}
2014-08-11 07:15:53 -07:00
}
2016-05-05 23:02:10 -07:00
function onSocketOpen() {
2014-08-11 07:15:53 -07:00
2016-05-05 23:02:10 -07:00
var apiClient = ApiClient;
if (apiClient) {
startListening(apiClient);
}
2015-06-29 11:45:42 -07:00
}
2016-05-05 23:02:10 -07:00
function onSocketMessage(e, data) {
2015-06-29 11:45:42 -07:00
2016-05-05 23:02:10 -07:00
var msg = data;
2015-06-29 11:45:42 -07:00
2016-05-05 23:02:10 -07:00
if (msg.MessageType === "ActivityLogEntry") {
$('.activityLogListWidget').each(function () {
2015-06-29 11:45:42 -07:00
2016-05-05 23:02:10 -07:00
reloadData(this);
});
}
2015-06-29 11:45:42 -07:00
}
2016-05-05 23:02:10 -07:00
function destroyList(elem) {
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
var apiClient = ApiClient;
2015-05-19 12:15:40 -07:00
2016-05-05 23:02:10 -07:00
if (apiClient) {
Events.off(apiClient, 'websocketopen', onSocketOpen);
Events.off(apiClient, 'websocketmessage', onSocketMessage);
2014-08-11 07:15:53 -07:00
2016-05-05 23:02:10 -07:00
stopListening(apiClient);
}
2015-05-19 12:15:40 -07:00
}
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
$.fn.activityLogList = function (action) {
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
if (action == 'destroy') {
this.removeClass('activityLogListWidget');
destroyList(this);
} else {
createList(this);
}
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
var apiClient = ApiClient;
2015-05-20 09:28:55 -07:00
2016-05-05 23:02:10 -07:00
if (apiClient) {
startListening(apiClient);
}
2014-08-11 07:15:53 -07:00
2016-05-05 23:02:10 -07:00
return this;
};
2014-08-10 15:13:17 -07:00
2016-05-05 23:02:10 -07:00
})(jQuery, document, window);
2014-10-04 11:05:24 -07:00
2016-05-05 23:02:10 -07:00
(function ($, document, window) {
2014-10-04 11:05:24 -07:00
2016-05-05 23:02:10 -07:00
var welcomeDismissValue = '12';
var welcomeTourKey = 'welcomeTour';
2014-10-04 11:05:24 -07:00
2016-05-05 23:02:10 -07:00
function dismissWelcome(page, userId) {
2014-10-04 11:05:24 -07:00
2016-05-05 23:02:10 -07:00
ApiClient.getDisplayPreferences('dashboard', userId, 'dashboard').then(function (result) {
2014-10-04 11:05:24 -07:00
2016-05-05 23:02:10 -07:00
result.CustomPrefs[welcomeTourKey] = welcomeDismissValue;
ApiClient.updateDisplayPreferences('dashboard', result, userId, 'dashboard');
2014-10-04 11:05:24 -07:00
2016-05-05 23:02:10 -07:00
$(page).off('pageshow', onPageShowCheckTour);
});
}
2014-10-04 11:05:24 -07:00
2016-05-05 23:02:10 -07:00
function showWelcomeIfNeeded(page, apiClient) {
2014-10-04 11:05:24 -07:00
2016-05-05 23:02:10 -07:00
var userId = Dashboard.getCurrentUserId();
2014-10-04 11:05:24 -07:00
2016-05-05 23:02:10 -07:00
apiClient.getDisplayPreferences('dashboard', userId, 'dashboard').then(function (result) {
2014-10-04 11:05:24 -07:00
2016-05-05 23:02:10 -07:00
if (result.CustomPrefs[welcomeTourKey] == welcomeDismissValue) {
$('.welcomeMessage', page).hide();
} else {
2015-01-11 11:36:26 -07:00
2016-05-05 23:02:10 -07:00
var elem = $('.welcomeMessage', page).show();
2015-01-11 11:36:26 -07:00
2016-05-05 23:02:10 -07:00
if (result.CustomPrefs[welcomeTourKey]) {
2015-01-11 11:36:26 -07:00
2016-05-05 23:02:10 -07:00
$('.tourHeader', elem).html(Globalize.translate('HeaderWelcomeBack'));
$('.tourButtonText', elem).html(Globalize.translate('ButtonTakeTheTourToSeeWhatsNew'));
2015-01-11 11:36:26 -07:00
2016-05-05 23:02:10 -07:00
} else {
2015-04-03 08:52:49 -07:00
2016-05-05 23:02:10 -07:00
$('.tourHeader', elem).html(Globalize.translate('HeaderWelcomeToProjectServerDashboard'));
$('.tourButtonText', elem).html(Globalize.translate('ButtonTakeTheTour'));
}
2015-01-11 11:36:26 -07:00
}
2016-05-05 23:02:10 -07:00
});
}
function takeTour(page, userId) {
require(['slideshow'], function () {
var slides = [
{ imageUrl: 'css/images/tour/admin/dashboard.png', title: Globalize.translate('DashboardTourDashboard') },
{ imageUrl: 'css/images/tour/admin/help.png', title: Globalize.translate('DashboardTourHelp') },
{ imageUrl: 'css/images/tour/admin/users.png', title: Globalize.translate('DashboardTourUsers') },
{ imageUrl: 'css/images/tour/admin/sync.png', title: Globalize.translate('DashboardTourSync') },
{ imageUrl: 'css/images/tour/admin/cinemamode.png', title: Globalize.translate('DashboardTourCinemaMode') },
{ imageUrl: 'css/images/tour/admin/chapters.png', title: Globalize.translate('DashboardTourChapters') },
{ imageUrl: 'css/images/tour/admin/subtitles.png', title: Globalize.translate('DashboardTourSubtitles') },
{ imageUrl: 'css/images/tour/admin/plugins.png', title: Globalize.translate('DashboardTourPlugins') },
{ imageUrl: 'css/images/tour/admin/notifications.png', title: Globalize.translate('DashboardTourNotifications') },
{ imageUrl: 'css/images/tour/admin/scheduledtasks.png', title: Globalize.translate('DashboardTourScheduledTasks') },
{ imageUrl: 'css/images/tour/admin/mobile.png', title: Globalize.translate('DashboardTourMobile') },
{ imageUrl: 'css/images/tour/enjoy.jpg', title: Globalize.translate('MessageEnjoyYourStay') }
];
2016-01-30 23:03:40 -07:00
2016-05-05 23:02:10 -07:00
require(['slideshow'], function (slideshow) {
2016-01-30 23:03:40 -07:00
2016-05-05 23:02:10 -07:00
var newSlideShow = new slideshow({
slides: slides,
interactive: true,
loop: false
});
newSlideShow.show();
dismissWelcome(page, userId);
$('.welcomeMessage', page).hide();
});
2015-05-08 20:48:43 -07:00
});
2016-05-05 23:02:10 -07:00
}
2014-10-04 11:05:24 -07:00
2016-05-05 23:02:10 -07:00
function onPageShowCheckTour() {
var page = this;
2014-10-04 11:05:24 -07:00
2016-05-05 23:02:10 -07:00
var apiClient = ApiClient;
2015-05-19 12:15:40 -07:00
2016-05-05 23:02:10 -07:00
if (apiClient && !AppInfo.isNativeApp) {
showWelcomeIfNeeded(page, apiClient);
}
2015-05-19 12:15:40 -07:00
}
2014-10-04 11:05:24 -07:00
2016-05-05 23:02:10 -07:00
$(document).on('pageinit', "#dashboardPage", function () {
2015-06-29 11:45:42 -07:00
2016-05-05 23:02:10 -07:00
var page = this;
2015-06-29 11:45:42 -07:00
2016-05-05 23:02:10 -07:00
$('.btnTakeTour', page).on('click', function () {
takeTour(page, Dashboard.getCurrentUserId());
});
2015-06-29 11:45:42 -07:00
2016-05-05 23:02:10 -07:00
}).on('pageshow', "#dashboardPage", onPageShowCheckTour);
2014-10-04 11:05:24 -07:00
2016-05-05 23:02:10 -07:00
})(jQuery, document, window);
2015-04-03 08:52:49 -07:00
2016-06-07 22:24:25 -07:00
pageClassOn('pageshow', "type-interior", function () {
2015-04-03 08:52:49 -07:00
2016-06-07 22:24:25 -07:00
var page = this;
2015-04-03 08:52:49 -07:00
2016-06-07 22:24:25 -07:00
Dashboard.getPluginSecurityInfo().then(function (pluginSecurityInfo) {
2015-04-03 08:52:49 -07:00
2016-06-07 22:24:25 -07:00
if (!page.querySelector('.customSupporterPromotion')) {
2015-04-03 08:52:49 -07:00
2016-06-07 22:24:25 -07:00
$('.supporterPromotion', page).remove();
2015-04-03 08:52:49 -07:00
2016-06-07 22:24:25 -07:00
if (!pluginSecurityInfo.IsMBSupporter && AppInfo.enableSupporterMembership) {
2015-12-14 08:43:03 -07:00
2016-06-07 22:24:25 -07:00
var html = '<div class="supporterPromotionContainer"><div class="supporterPromotion"><a class="clearLink" href="http://emby.media/premiere" target="_blank"><button is="emby-button" type="button" class="raised block" style="text-transform:none;background-color:#52B54B;color:#fff;"><div>' + Globalize.translate('HeaderSupportTheTeam') + '</div><div style="font-weight:normal;margin-top:5px;">' + Globalize.translate('TextEnjoyBonusFeatures') + '</div></button></a></div></div>';
2015-12-14 08:43:03 -07:00
2016-06-07 22:24:25 -07:00
page.querySelector('.content-primary').insertAdjacentHTML('afterbegin', html);
2015-04-03 08:52:49 -07:00
}
2016-06-07 22:24:25 -07:00
}
2015-04-03 08:52:49 -07:00
});
2016-06-07 22:24:25 -07:00
});
2016-05-05 23:02:10 -07:00
});