diff --git a/dashboard-ui/scripts/dashboardpage.js b/dashboard-ui/scripts/dashboardpage.js
index 04a79b096c..5c0f45b800 100644
--- a/dashboard-ui/scripts/dashboardpage.js
+++ b/dashboard-ui/scripts/dashboardpage.js
@@ -1,1321 +1,1325 @@
-var DashboardPage = {
+define(['datetime'], function (datetime) {
- newsStartIndex: 0,
+ window.DashboardPage = {
- onPageShow: function () {
+ newsStartIndex: 0,
- var page = this;
+ onPageShow: function () {
- var apiClient = ApiClient;
+ var page = this;
- if (!apiClient) {
- return;
- }
+ var apiClient = ApiClient;
- if (Dashboard.lastSystemInfo) {
- page.querySelector('.serverNameHeader').innerHTML = Dashboard.lastSystemInfo.ServerName;
- }
-
- DashboardPage.newsStartIndex = 0;
-
- Dashboard.showLoadingMsg();
- DashboardPage.pollForInfo(page);
- DashboardPage.startInterval(apiClient);
-
- Events.on(apiClient, 'websocketmessage', DashboardPage.onWebSocketMessage);
- Events.on(apiClient, 'websocketopen', DashboardPage.onWebSocketOpen);
-
- DashboardPage.lastAppUpdateCheck = null;
- DashboardPage.lastPluginUpdateCheck = null;
-
- Dashboard.getPluginSecurityInfo().then(function (pluginSecurityInfo) {
-
- DashboardPage.renderSupporterIcon(page, pluginSecurityInfo);
- });
-
- DashboardPage.reloadSystemInfo(page);
- DashboardPage.reloadNews(page);
- DashboardPage.sessionUpdateTimer = setInterval(DashboardPage.refreshSessionsLocally, 60000);
-
- $('.activityItems', page).activityLogList();
-
- $('.swaggerLink', page).attr('href', apiClient.getUrl('swagger-ui/index.html', {
- api_key: ApiClient.accessToken()
- }));
- },
-
- onPageHide: function () {
-
- var page = this;
-
- $('.activityItems', page).activityLogList('destroy');
-
- var apiClient = ApiClient;
-
- if (apiClient) {
- Events.off(apiClient, 'websocketmessage', DashboardPage.onWebSocketMessage);
- Events.off(apiClient, 'websocketopen', DashboardPage.onWebSocketOpen);
- DashboardPage.stopInterval(apiClient);
- }
-
- if (DashboardPage.sessionUpdateTimer) {
- clearInterval(DashboardPage.sessionUpdateTimer);
- }
- },
-
- renderPaths: function (page, systemInfo) {
-
- $('#cachePath', page).html(systemInfo.CachePath);
- $('#logPath', page).html(systemInfo.LogPath);
- $('#transcodingTemporaryPath', page).html(systemInfo.TranscodingTempPath);
- $('#metadataPath', page).html(systemInfo.InternalMetadataPath);
- },
-
- refreshSessionsLocally: function () {
-
- var list = DashboardPage.sessionsList;
-
- if (list) {
- DashboardPage.renderActiveConnections($.mobile.activePage, list);
- }
- },
-
- reloadSystemInfo: function (page) {
-
- ApiClient.getSystemInfo().then(function (systemInfo) {
-
- page.querySelector('.serverNameHeader').innerHTML = systemInfo.ServerName;
- Dashboard.updateSystemInfo(systemInfo);
-
- $('#appVersionNumber', page).html(Globalize.translate('LabelVersionNumber').replace('{0}', systemInfo.Version));
-
- if (systemInfo.SupportsHttps) {
- $('#ports', page).html(Globalize.translate('LabelRunningOnPorts', '' + systemInfo.HttpServerPortNumber + ' ', '' + systemInfo.HttpsPortNumber + ' '));
- } else {
- $('#ports', page).html(Globalize.translate('LabelRunningOnPort', '' + systemInfo.HttpServerPortNumber + ' '));
+ if (!apiClient) {
+ return;
}
- if (systemInfo.CanSelfRestart) {
- $('.btnRestartContainer', page).removeClass('hide');
- } else {
- $('.btnRestartContainer', page).addClass('hide');
+ if (Dashboard.lastSystemInfo) {
+ page.querySelector('.serverNameHeader').innerHTML = Dashboard.lastSystemInfo.ServerName;
}
- DashboardPage.renderUrls(page, systemInfo);
- DashboardPage.renderPendingInstallations(page, systemInfo);
+ DashboardPage.newsStartIndex = 0;
- if (systemInfo.CanSelfUpdate) {
- $('#btnUpdateApplicationContainer', page).show();
- $('#btnManualUpdateContainer', page).hide();
- } else {
- $('#btnUpdateApplicationContainer', page).hide();
- $('#btnManualUpdateContainer', page).show();
- }
+ Dashboard.showLoadingMsg();
+ DashboardPage.pollForInfo(page);
+ DashboardPage.startInterval(apiClient);
- DashboardPage.renderPaths(page, systemInfo);
- DashboardPage.renderHasPendingRestart(page, systemInfo.HasPendingRestart);
- });
- },
+ Events.on(apiClient, 'websocketmessage', DashboardPage.onWebSocketMessage);
+ Events.on(apiClient, 'websocketopen', DashboardPage.onWebSocketOpen);
- reloadNews: function (page) {
+ DashboardPage.lastAppUpdateCheck = null;
+ DashboardPage.lastPluginUpdateCheck = null;
- var query = {
- StartIndex: DashboardPage.newsStartIndex,
- Limit: 7
- };
+ Dashboard.getPluginSecurityInfo().then(function (pluginSecurityInfo) {
- ApiClient.getProductNews(query).then(function (result) {
-
- var html = result.Items.map(function (item) {
-
- var itemHtml = '';
-
- itemHtml += '';
- itemHtml += '';
-
- itemHtml += ' ';
-
- itemHtml += '';
-
- itemHtml += '';
- itemHtml += item.Title;
- itemHtml += '
';
-
- itemHtml += '';
- var date = parseISO8601Date(item.Date, { toLocal: true });
- itemHtml += date.toLocaleDateString();
- itemHtml += '
';
-
- itemHtml += '';
- itemHtml += item.Description;
- itemHtml += '
';
-
- itemHtml += ' ';
-
- itemHtml += ' ';
- itemHtml += ' ';
-
- return itemHtml;
+ DashboardPage.renderSupporterIcon(page, pluginSecurityInfo);
});
- var pagingHtml = '';
- pagingHtml += '
';
- pagingHtml += LibraryBrowser.getQueryPagingHtml({
- startIndex: query.StartIndex,
- limit: query.Limit,
- totalRecordCount: result.TotalRecordCount,
- showLimit: false,
- updatePageSizeSetting: false
- });
- pagingHtml += '
';
-
- html = html.join('') + pagingHtml;
-
- var elem = $('.latestNewsItems', page).html(html);
-
- $('.btnNextPage', elem).on('click', function () {
- DashboardPage.newsStartIndex += query.Limit;
- DashboardPage.reloadNews(page);
- });
-
- $('.btnPreviousPage', elem).on('click', function () {
- DashboardPage.newsStartIndex -= query.Limit;
- DashboardPage.reloadNews(page);
- });
- });
-
- },
-
- startInterval: function (apiClient) {
-
- if (apiClient.isWebSocketOpen()) {
- apiClient.sendWebSocketMessage("SessionsStart", "0,1500");
- apiClient.sendWebSocketMessage("ScheduledTasksInfoStart", "0,1000");
- }
- },
-
- stopInterval: function (apiClient) {
-
- if (apiClient.isWebSocketOpen()) {
- apiClient.sendWebSocketMessage("SessionsStop");
- apiClient.sendWebSocketMessage("ScheduledTasksInfoStop");
- }
- },
-
- onWebSocketMessage: function (e, msg) {
-
- var page = $.mobile.activePage;
-
- 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") {
-
- var tasks = msg.Data;
-
- DashboardPage.renderRunningTasks(page, tasks);
- }
- else if (msg.MessageType == "PackageInstalling" || msg.MessageType == "PackageInstallationCompleted") {
-
- DashboardPage.pollForInfo(page, true);
DashboardPage.reloadSystemInfo(page);
- }
- },
+ DashboardPage.reloadNews(page);
+ DashboardPage.sessionUpdateTimer = setInterval(DashboardPage.refreshSessionsLocally, 60000);
- onWebSocketOpen: function () {
+ $('.activityItems', page).activityLogList();
- var apiClient = this;
+ $('.swaggerLink', page).attr('href', apiClient.getUrl('swagger-ui/index.html', {
+ api_key: ApiClient.accessToken()
+ }));
+ },
- DashboardPage.startInterval(apiClient);
- },
+ onPageHide: function () {
- pollForInfo: function (page, forceUpdate) {
+ var page = this;
- var apiClient = window.ApiClient;
+ $('.activityItems', page).activityLogList('destroy');
- if (!apiClient) {
- return;
- }
+ var apiClient = ApiClient;
- apiClient.getSessions().then(function (sessions) {
-
- DashboardPage.renderInfo(page, sessions, forceUpdate);
- });
- apiClient.getScheduledTasks().then(function (tasks) {
-
- DashboardPage.renderRunningTasks(page, tasks);
- });
- },
-
- renderInfo: function (page, sessions, forceUpdate) {
-
- DashboardPage.renderActiveConnections(page, sessions);
- DashboardPage.renderPluginUpdateInfo(page, forceUpdate);
-
- Dashboard.hideLoadingMsg();
- },
-
- renderActiveConnections: function (page, sessions) {
-
- var html = '';
-
- DashboardPage.sessionsList = sessions;
-
- var parentElement = $('.activeDevices', page);
-
- $('.card', parentElement).addClass('deadSession');
-
- for (var i = 0, length = sessions.length; i < length; i++) {
-
- var session = sessions[i];
-
- var rowId = 'session' + session.Id;
-
- var elem = $('#' + rowId, page);
-
- if (elem.length) {
- DashboardPage.updateSession(elem, session);
- continue;
+ if (apiClient) {
+ Events.off(apiClient, 'websocketmessage', DashboardPage.onWebSocketMessage);
+ Events.off(apiClient, 'websocketopen', DashboardPage.onWebSocketOpen);
+ DashboardPage.stopInterval(apiClient);
}
+ if (DashboardPage.sessionUpdateTimer) {
+ clearInterval(DashboardPage.sessionUpdateTimer);
+ }
+ },
+
+ renderPaths: function (page, systemInfo) {
+
+ $('#cachePath', page).html(systemInfo.CachePath);
+ $('#logPath', page).html(systemInfo.LogPath);
+ $('#transcodingTemporaryPath', page).html(systemInfo.TranscodingTempPath);
+ $('#metadataPath', page).html(systemInfo.InternalMetadataPath);
+ },
+
+ refreshSessionsLocally: function () {
+
+ var list = DashboardPage.sessionsList;
+
+ if (list) {
+ DashboardPage.renderActiveConnections($.mobile.activePage, list);
+ }
+ },
+
+ reloadSystemInfo: function (page) {
+
+ ApiClient.getSystemInfo().then(function (systemInfo) {
+
+ page.querySelector('.serverNameHeader').innerHTML = systemInfo.ServerName;
+ Dashboard.updateSystemInfo(systemInfo);
+
+ $('#appVersionNumber', page).html(Globalize.translate('LabelVersionNumber').replace('{0}', systemInfo.Version));
+
+ if (systemInfo.SupportsHttps) {
+ $('#ports', page).html(Globalize.translate('LabelRunningOnPorts', '' + systemInfo.HttpServerPortNumber + ' ', '' + systemInfo.HttpsPortNumber + ' '));
+ } else {
+ $('#ports', page).html(Globalize.translate('LabelRunningOnPort', '' + systemInfo.HttpServerPortNumber + ' '));
+ }
+
+ if (systemInfo.CanSelfRestart) {
+ $('.btnRestartContainer', page).removeClass('hide');
+ } else {
+ $('.btnRestartContainer', page).addClass('hide');
+ }
+
+ DashboardPage.renderUrls(page, systemInfo);
+ DashboardPage.renderPendingInstallations(page, systemInfo);
+
+ if (systemInfo.CanSelfUpdate) {
+ $('#btnUpdateApplicationContainer', page).show();
+ $('#btnManualUpdateContainer', page).hide();
+ } else {
+ $('#btnUpdateApplicationContainer', page).hide();
+ $('#btnManualUpdateContainer', page).show();
+ }
+
+ DashboardPage.renderPaths(page, systemInfo);
+ DashboardPage.renderHasPendingRestart(page, systemInfo.HasPendingRestart);
+ });
+ },
+
+ reloadNews: function (page) {
+
+ var query = {
+ StartIndex: DashboardPage.newsStartIndex,
+ Limit: 7
+ };
+
+ ApiClient.getProductNews(query).then(function (result) {
+
+ var html = result.Items.map(function (item) {
+
+ var itemHtml = '';
+
+ itemHtml += '';
+ itemHtml += '';
+
+ itemHtml += ' ';
+
+ itemHtml += '';
+
+ itemHtml += '';
+ itemHtml += item.Title;
+ itemHtml += '
';
+
+ itemHtml += '';
+ var date = datetime.parseISO8601Date(item.Date, true);
+ itemHtml += date.toLocaleDateString();
+ itemHtml += '
';
+
+ itemHtml += '';
+ itemHtml += item.Description;
+ itemHtml += '
';
+
+ itemHtml += ' ';
+
+ itemHtml += ' ';
+ itemHtml += ' ';
+
+ return itemHtml;
+ });
+
+ var pagingHtml = '';
+ pagingHtml += '';
+ pagingHtml += LibraryBrowser.getQueryPagingHtml({
+ startIndex: query.StartIndex,
+ limit: query.Limit,
+ totalRecordCount: result.TotalRecordCount,
+ showLimit: false,
+ updatePageSizeSetting: false
+ });
+ pagingHtml += '
';
+
+ html = html.join('') + pagingHtml;
+
+ var elem = $('.latestNewsItems', page).html(html);
+
+ $('.btnNextPage', elem).on('click', function () {
+ DashboardPage.newsStartIndex += query.Limit;
+ DashboardPage.reloadNews(page);
+ });
+
+ $('.btnPreviousPage', elem).on('click', function () {
+ DashboardPage.newsStartIndex -= query.Limit;
+ DashboardPage.reloadNews(page);
+ });
+ });
+
+ },
+
+ startInterval: function (apiClient) {
+
+ if (apiClient.isWebSocketOpen()) {
+ apiClient.sendWebSocketMessage("SessionsStart", "0,1500");
+ apiClient.sendWebSocketMessage("ScheduledTasksInfoStart", "0,1000");
+ }
+ },
+
+ stopInterval: function (apiClient) {
+
+ if (apiClient.isWebSocketOpen()) {
+ apiClient.sendWebSocketMessage("SessionsStop");
+ apiClient.sendWebSocketMessage("ScheduledTasksInfoStop");
+ }
+ },
+
+ onWebSocketMessage: function (e, msg) {
+
+ var page = $.mobile.activePage;
+
+ 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") {
+
+ var tasks = msg.Data;
+
+ DashboardPage.renderRunningTasks(page, tasks);
+ }
+ else if (msg.MessageType == "PackageInstalling" || msg.MessageType == "PackageInstallationCompleted") {
+
+ DashboardPage.pollForInfo(page, true);
+ DashboardPage.reloadSystemInfo(page);
+ }
+ },
+
+ onWebSocketOpen: function () {
+
+ var apiClient = this;
+
+ DashboardPage.startInterval(apiClient);
+ },
+
+ pollForInfo: function (page, forceUpdate) {
+
+ var apiClient = window.ApiClient;
+
+ if (!apiClient) {
+ return;
+ }
+
+ apiClient.getSessions().then(function (sessions) {
+
+ DashboardPage.renderInfo(page, sessions, forceUpdate);
+ });
+ apiClient.getScheduledTasks().then(function (tasks) {
+
+ DashboardPage.renderRunningTasks(page, tasks);
+ });
+ },
+
+ renderInfo: function (page, sessions, forceUpdate) {
+
+ DashboardPage.renderActiveConnections(page, sessions);
+ DashboardPage.renderPluginUpdateInfo(page, forceUpdate);
+
+ Dashboard.hideLoadingMsg();
+ },
+
+ renderActiveConnections: function (page, sessions) {
+
+ var html = '';
+
+ DashboardPage.sessionsList = sessions;
+
+ var parentElement = $('.activeDevices', page);
+
+ $('.card', parentElement).addClass('deadSession');
+
+ for (var i = 0, length = sessions.length; i < length; i++) {
+
+ var session = sessions[i];
+
+ var rowId = 'session' + session.Id;
+
+ var elem = $('#' + rowId, page);
+
+ if (elem.length) {
+ DashboardPage.updateSession(elem, session);
+ continue;
+ }
+
+ var nowPlayingItem = session.NowPlayingItem;
+
+ var className = nowPlayingItem ? 'card activeSession' : 'card activeSession';
+
+ if (session.TranscodingInfo && session.TranscodingInfo.CompletionPercentage) {
+ className += ' transcodingSession';
+ }
+
+ html += '';
+
+ html += '
';
+ html += '
';
+
+ html += '
';
+ html += '
';
+
+ html += '
';
+
+ html += '
';
+
+ html += '
';
+
+ var clientImage = DashboardPage.getClientImage(session);
+
+ if (clientImage) {
+ html += clientImage;
+ }
+
+ html += '
';
+ html += '
' + session.DeviceName + '
';
+ html += '
' + DashboardPage.getAppSecondaryText(session) + '
';
+ html += '
';
+
+ html += '
';
+
+ html += '
' + DashboardPage.getSessionNowPlayingTime(session) + '
';
+
+ html += '
' + DashboardPage.getSessionNowPlayingStreamInfo(session) + '
';
+
+ //if (session.TranscodingInfo && session.TranscodingInfo.Framerate) {
+
+ // html += '
' + session.TranscodingInfo.Framerate + ' fps
';
+ //} else {
+ // html += '
';
+ //}
+
+ var nowPlayingName = DashboardPage.getNowPlayingName(session);
+
+ html += '
';
+ html += nowPlayingName.html;
+ html += '
';
+
+ if (nowPlayingItem && nowPlayingItem.RunTimeTicks) {
+
+ var position = session.PlayState.PositionTicks || 0;
+ var value = (100 * position) / nowPlayingItem.RunTimeTicks;
+
+ html += '
';
+ } else {
+ html += '
';
+ }
+
+ if (session.TranscodingInfo && session.TranscodingInfo.CompletionPercentage) {
+
+ html += '
';
+ } else {
+ html += '
';
+ }
+
+ html += '
';
+
+ html += '
';
+
+ // cardScalable
+ html += '
';
+
+ html += '
';
+
+ var userImage = DashboardPage.getUserImage(session);
+ if (userImage) {
+ html += '
';
+ } else {
+ html += '
';
+ }
+
+ html += '
';
+ html += DashboardPage.getUsersHtml(session) || ' ';
+ html += '
';
+ html += '
';
+
+ // cardBox
+ html += '
';
+
+ // card
+ html += '
';
+ }
+
+ parentElement.append(html);
+
+ $('.deadSession', parentElement).remove();
+ },
+
+ getSessionNowPlayingStreamInfo: function (session) {
+
+ var html = '';
+
+ //html += '';
+
+ if (session.TranscodingInfo && session.TranscodingInfo.IsAudioDirect && session.TranscodingInfo.IsVideoDirect) {
+ html += Globalize.translate('LabelPlayMethodDirectStream');
+ }
+ else if (session.PlayState.PlayMethod == 'Transcode') {
+ html += Globalize.translate('LabelPlayMethodTranscoding');
+
+ if (session.TranscodingInfo && session.TranscodingInfo.Framerate) {
+
+ html += ' - ' + session.TranscodingInfo.Framerate + ' fps';
+ }
+ }
+ else if (session.PlayState.PlayMethod == 'DirectStream') {
+ html += Globalize.translate('LabelPlayMethodDirectPlay');
+ }
+ else if (session.PlayState.PlayMethod == 'DirectPlay') {
+ html += Globalize.translate('LabelPlayMethodDirectPlay');
+ }
+
+ //html += '
';
+
+ //if (session.TranscodingInfo) {
+
+ // html += ' ';
+
+ // var line = [];
+
+ // if (session.TranscodingInfo.Container) {
+
+ // line.push(session.TranscodingInfo.Container);
+ // }
+ // if (session.TranscodingInfo.Bitrate) {
+
+ // if (session.TranscodingInfo.Bitrate > 1000000) {
+ // line.push((session.TranscodingInfo.Bitrate / 1000000).toFixed(1) + ' Mbps');
+ // } else {
+ // line.push(Math.floor(session.TranscodingInfo.Bitrate / 1000) + ' kbps');
+ // }
+ // }
+ // if (line.length) {
+
+ // html += '' + line.join(' ') + '
';
+ // }
+
+ // if (session.TranscodingInfo.VideoCodec) {
+
+ // html += '' + Globalize.translate('LabelVideoCodec').replace('{0}', session.TranscodingInfo.VideoCodec) + '
';
+ // }
+ // if (session.TranscodingInfo.AudioCodec && session.TranscodingInfo.AudioCodec != session.TranscodingInfo.Container) {
+
+ // html += '' + Globalize.translate('LabelAudioCodec').replace('{0}', session.TranscodingInfo.AudioCodec) + '
';
+ // }
+
+ //}
+
+ return html;
+ },
+
+ getSessionNowPlayingTime: function (session) {
+
+ var html = '';
+
+ if (session.PlayState.PositionTicks) {
+ html += datetime.getDisplayRunningTime(session.PlayState.PositionTicks);
+ } else {
+ html += '--:--:--';
+ }
+
+ html += ' / ';
+
var nowPlayingItem = session.NowPlayingItem;
- var className = nowPlayingItem ? 'card activeSession' : 'card activeSession';
-
- if (session.TranscodingInfo && session.TranscodingInfo.CompletionPercentage) {
- className += ' transcodingSession';
+ if (nowPlayingItem && nowPlayingItem.RunTimeTicks) {
+ html += datetime.getDisplayRunningTime(nowPlayingItem.RunTimeTicks);
+ } else {
+ html += '--:--:--';
}
- html += '';
+ return html;
+ },
- html += '
';
- html += '
';
+ getAppSecondaryText: function (session) {
- html += '
';
- html += '
';
+ return session.ApplicationVersion;
+ },
- html += '
';
+ var topText = nowPlayingItem.Name;
- html += '
';
+ var bottomText = '';
- html += '
';
-
- var clientImage = DashboardPage.getClientImage(session);
-
- if (clientImage) {
- html += clientImage;
+ 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;
}
- html += '
';
- html += '
' + session.DeviceName + '
';
- html += '
' + DashboardPage.getAppSecondaryText(session) + '
';
- html += '
';
+ if (nowPlayingItem.LogoItemId) {
- html += '
';
+ imgUrl = ApiClient.getScaledImageUrl(nowPlayingItem.LogoItemId, {
- html += '
' + DashboardPage.getSessionNowPlayingTime(session) + '
';
+ tag: session.LogoImageTag,
+ maxHeight: 24,
+ maxWidth: 130,
+ type: 'Logo'
- html += '
' + DashboardPage.getSessionNowPlayingStreamInfo(session) + '
';
+ });
- //if (session.TranscodingInfo && session.TranscodingInfo.Framerate) {
+ topText = '
';
+ }
- // html += '
' + session.TranscodingInfo.Framerate + ' fps
';
- //} else {
- // html += '
';
- //}
+ var text = bottomText ? topText + '
' + bottomText : topText;
+
+ return {
+ html: text,
+ image: imgUrl
+ };
+ },
+
+ getUsersHtml: function (session) {
+
+ var html = [];
+
+ if (session.UserId) {
+ html.push(session.UserName);
+ }
+
+ for (var i = 0, length = session.AdditionalUsers.length; i < length; i++) {
+
+ html.push(session.AdditionalUsers[i].UserName);
+ }
+
+ return html.join(', ');
+ },
+
+ getUserImage: function (session) {
+
+ if (session.UserId && session.UserPrimaryImageTag) {
+ return ApiClient.getUserImageUrl(session.UserId, {
+
+ tag: session.UserPrimaryImageTag,
+ height: 24,
+ type: 'Primary'
+
+ });
+ }
+
+ return null;
+ },
+
+ updateSession: function (row, session) {
+
+ row.removeClass('deadSession');
+
+ var nowPlayingItem = session.NowPlayingItem;
+
+ if (nowPlayingItem) {
+ row.addClass('playingSession');
+ } else {
+ row.removeClass('playingSession');
+ }
+
+ $('.sessionNowPlayingStreamInfo', row).html(DashboardPage.getSessionNowPlayingStreamInfo(session));
+ $('.sessionNowPlayingTime', row).html(DashboardPage.getSessionNowPlayingTime(session));
+
+ $('.sessionUserName', row).html(DashboardPage.getUsersHtml(session) || ' ');
+
+ $('.sessionAppSecondaryText', row).html(DashboardPage.getAppSecondaryText(session));
+
+ $('.sessionTranscodingFramerate', row).html((session.TranscodingInfo && session.TranscodingInfo.Framerate) ? session.TranscodingInfo.Framerate + ' fps' : '');
var nowPlayingName = DashboardPage.getNowPlayingName(session);
+ var nowPlayingInfoElem = $('.sessionNowPlayingInfo', row);
- html += '
';
- html += nowPlayingName.html;
- html += '
';
+ if (!nowPlayingName.image || nowPlayingName.image != nowPlayingInfoElem.attr('data-imgsrc')) {
+ nowPlayingInfoElem.html(nowPlayingName.html);
+ nowPlayingInfoElem.attr('data-imgsrc', nowPlayingName.image || '');
+ }
if (nowPlayingItem && nowPlayingItem.RunTimeTicks) {
var position = session.PlayState.PositionTicks || 0;
var value = (100 * position) / nowPlayingItem.RunTimeTicks;
- html += '
';
+ $('.playbackProgress', row).show().val(value);
} else {
- html += '
';
+ $('.playbackProgress', row).hide();
}
if (session.TranscodingInfo && session.TranscodingInfo.CompletionPercentage) {
- html += '
';
+ row.addClass('transcodingSession');
+ $('.transcodingProgress', row).show().val(session.TranscodingInfo.CompletionPercentage);
} else {
- html += '
';
+ $('.transcodingProgress', row).hide();
+ row.removeClass('transcodingSession');
}
- html += '
';
+ var imgUrl = DashboardPage.getNowPlayingImageUrl(nowPlayingItem) || '';
+ var imgElem = $('.sessionNowPlayingContent', row)[0];
- html += '
';
+ if (imgUrl != imgElem.getAttribute('data-src')) {
+ imgElem.style.backgroundImage = imgUrl ? 'url(\'' + imgUrl + '\')' : '';
+ imgElem.setAttribute('data-src', imgUrl);
+ }
+ },
- // cardScalable
- html += '
';
+ getClientImage: function (connection) {
- html += '
';
+ var clientLowered = connection.Client.toLowerCase();
+ var device = connection.DeviceName.toLowerCase();
- var userImage = DashboardPage.getUserImage(session);
- if (userImage) {
- html += '
';
- } else {
- html += '
';
+ if (connection.AppIconUrl) {
+ return "
";
}
- html += '
';
- html += DashboardPage.getUsersHtml(session) || ' ';
- html += '
';
- html += '
';
+ if (clientLowered == "dashboard" || clientLowered == "emby web client") {
- // cardBox
- html += '
';
+ var imgUrl;
- // card
- html += '
';
- }
-
- parentElement.append(html);
-
- $('.deadSession', parentElement).remove();
- },
-
- getSessionNowPlayingStreamInfo: function (session) {
-
- var html = '';
-
- //html += '';
-
- if (session.TranscodingInfo && session.TranscodingInfo.IsAudioDirect && session.TranscodingInfo.IsVideoDirect) {
- html += Globalize.translate('LabelPlayMethodDirectStream');
- }
- else if (session.PlayState.PlayMethod == 'Transcode') {
- html += Globalize.translate('LabelPlayMethodTranscoding');
-
- if (session.TranscodingInfo && session.TranscodingInfo.Framerate) {
-
- html += ' - ' + session.TranscodingInfo.Framerate + ' fps';
- }
- }
- else if (session.PlayState.PlayMethod == 'DirectStream') {
- html += Globalize.translate('LabelPlayMethodDirectPlay');
- }
- else if (session.PlayState.PlayMethod == 'DirectPlay') {
- html += Globalize.translate('LabelPlayMethodDirectPlay');
- }
-
- //html += '
';
-
- //if (session.TranscodingInfo) {
-
- // html += ' ';
-
- // var line = [];
-
- // if (session.TranscodingInfo.Container) {
-
- // line.push(session.TranscodingInfo.Container);
- // }
- // if (session.TranscodingInfo.Bitrate) {
-
- // if (session.TranscodingInfo.Bitrate > 1000000) {
- // line.push((session.TranscodingInfo.Bitrate / 1000000).toFixed(1) + ' Mbps');
- // } else {
- // line.push(Math.floor(session.TranscodingInfo.Bitrate / 1000) + ' kbps');
- // }
- // }
- // if (line.length) {
-
- // html += '' + line.join(' ') + '
';
- // }
-
- // if (session.TranscodingInfo.VideoCodec) {
-
- // html += '' + Globalize.translate('LabelVideoCodec').replace('{0}', session.TranscodingInfo.VideoCodec) + '
';
- // }
- // if (session.TranscodingInfo.AudioCodec && session.TranscodingInfo.AudioCodec != session.TranscodingInfo.Container) {
-
- // html += '' + Globalize.translate('LabelAudioCodec').replace('{0}', session.TranscodingInfo.AudioCodec) + '
';
- // }
-
- //}
-
- return html;
- },
-
- getSessionNowPlayingTime: function (session) {
-
- var html = '';
-
- if (session.PlayState.PositionTicks) {
- html += datetime.getDisplayRunningTime(session.PlayState.PositionTicks);
- } else {
- html += '--:--:--';
- }
-
- html += ' / ';
-
- var nowPlayingItem = session.NowPlayingItem;
-
- if (nowPlayingItem && nowPlayingItem.RunTimeTicks) {
- html += datetime.getDisplayRunningTime(nowPlayingItem.RunTimeTicks);
- } else {
- html += '--:--:--';
- }
-
- return html;
- },
-
- getAppSecondaryText: function (session) {
-
- return session.ApplicationVersion;
- },
-
- getNowPlayingName: function (session) {
-
- var imgUrl = '';
-
- var nowPlayingItem = session.NowPlayingItem;
-
- if (!nowPlayingItem) {
-
- return {
- html: 'Last seen ' + humane_date(session.LastActivityDate),
- image: imgUrl
- };
- }
-
- var topText = nowPlayingItem.Name;
-
- var bottomText = '';
-
- 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;
- }
-
- if (nowPlayingItem.LogoItemId) {
-
- imgUrl = ApiClient.getScaledImageUrl(nowPlayingItem.LogoItemId, {
-
- tag: session.LogoImageTag,
- maxHeight: 24,
- maxWidth: 130,
- type: 'Logo'
-
- });
-
- topText = ' ';
- }
-
- var text = bottomText ? topText + ' ' + bottomText : topText;
-
- return {
- html: text,
- image: imgUrl
- };
- },
-
- getUsersHtml: function (session) {
-
- var html = [];
-
- if (session.UserId) {
- html.push(session.UserName);
- }
-
- for (var i = 0, length = session.AdditionalUsers.length; i < length; i++) {
-
- html.push(session.AdditionalUsers[i].UserName);
- }
-
- return html.join(', ');
- },
-
- getUserImage: function (session) {
-
- if (session.UserId && session.UserPrimaryImageTag) {
- return ApiClient.getUserImageUrl(session.UserId, {
-
- tag: session.UserPrimaryImageTag,
- height: 24,
- type: 'Primary'
-
- });
- }
-
- return null;
- },
-
- updateSession: function (row, session) {
-
- row.removeClass('deadSession');
-
- var nowPlayingItem = session.NowPlayingItem;
-
- if (nowPlayingItem) {
- row.addClass('playingSession');
- } else {
- row.removeClass('playingSession');
- }
-
- $('.sessionNowPlayingStreamInfo', row).html(DashboardPage.getSessionNowPlayingStreamInfo(session));
- $('.sessionNowPlayingTime', row).html(DashboardPage.getSessionNowPlayingTime(session));
-
- $('.sessionUserName', row).html(DashboardPage.getUsersHtml(session) || ' ');
-
- $('.sessionAppSecondaryText', row).html(DashboardPage.getAppSecondaryText(session));
-
- $('.sessionTranscodingFramerate', row).html((session.TranscodingInfo && session.TranscodingInfo.Framerate) ? session.TranscodingInfo.Framerate + ' fps' : '');
-
- var nowPlayingName = DashboardPage.getNowPlayingName(session);
- var nowPlayingInfoElem = $('.sessionNowPlayingInfo', row);
-
- if (!nowPlayingName.image || nowPlayingName.image != nowPlayingInfoElem.attr('data-imgsrc')) {
- nowPlayingInfoElem.html(nowPlayingName.html);
- nowPlayingInfoElem.attr('data-imgsrc', nowPlayingName.image || '');
- }
-
- if (nowPlayingItem && nowPlayingItem.RunTimeTicks) {
-
- var position = session.PlayState.PositionTicks || 0;
- var value = (100 * position) / nowPlayingItem.RunTimeTicks;
-
- $('.playbackProgress', row).show().val(value);
- } else {
- $('.playbackProgress', row).hide();
- }
-
- if (session.TranscodingInfo && session.TranscodingInfo.CompletionPercentage) {
-
- row.addClass('transcodingSession');
- $('.transcodingProgress', row).show().val(session.TranscodingInfo.CompletionPercentage);
- } else {
- $('.transcodingProgress', row).hide();
- row.removeClass('transcodingSession');
- }
-
- var imgUrl = DashboardPage.getNowPlayingImageUrl(nowPlayingItem) || '';
- var imgElem = $('.sessionNowPlayingContent', row)[0];
-
- if (imgUrl != imgElem.getAttribute('data-src')) {
- imgElem.style.backgroundImage = imgUrl ? 'url(\'' + imgUrl + '\')' : '';
- imgElem.setAttribute('data-src', imgUrl);
- }
- },
-
- getClientImage: function (connection) {
-
- var clientLowered = connection.Client.toLowerCase();
- var device = connection.DeviceName.toLowerCase();
-
- if (connection.AppIconUrl) {
- return " ";
- }
-
- if (clientLowered == "dashboard" || clientLowered == "emby web client") {
-
- var imgUrl;
-
- if (device.indexOf('chrome') != -1) {
- imgUrl = 'css/images/clients/chrome.png';
- }
- else {
- imgUrl = 'css/images/clients/html5.png';
- }
-
- return " ";
- }
- if (clientLowered.indexOf('android') != -1) {
- return " ";
- }
- if (clientLowered.indexOf('ios') != -1) {
- return " ";
- }
- if (clientLowered == "mb-classic") {
-
- return " ";
- }
- if (clientLowered == "roku") {
-
- return " ";
- }
- if (clientLowered == "windows phone") {
-
- return " ";
- }
- if (clientLowered == "dlna") {
-
- return " ";
- }
- if (clientLowered == "kodi" || clientLowered == "xbmc") {
- return " ";
- }
- if (clientLowered == "chromecast") {
-
- return " ";
- }
-
- return null;
- },
-
- getNowPlayingImageUrl: function (item) {
-
- if (item && item.BackdropImageTag) {
-
- return ApiClient.getScaledImageUrl(item.BackdropItemId, {
- type: "Backdrop",
- width: 275,
- tag: item.BackdropImageTag
- });
- }
-
- if (item && item.ThumbImageTag) {
-
- return ApiClient.getScaledImageUrl(item.ThumbItemId, {
- type: "Thumb",
- width: 275,
- tag: item.ThumbImageTag
- });
- }
-
- if (item && item.PrimaryImageTag) {
-
- return ApiClient.getScaledImageUrl(item.PrimaryImageItemId, {
- type: "Primary",
- width: 275,
- tag: item.PrimaryImageTag
- });
- }
-
- return null;
- },
-
- systemUpdateTaskKey: "SystemUpdateTask",
-
- renderRunningTasks: function (page, tasks) {
-
- var html = '';
-
- tasks = tasks.filter(function (t) {
- return t.State != 'Idle' && !t.IsHidden;
- });
-
- if (tasks.filter(function (t) {
-
- return t.Key == DashboardPage.systemUpdateTaskKey;
-
- }).length) {
-
- $('#btnUpdateApplication', page).buttonEnabled(false);
- } else {
- $('#btnUpdateApplication', page).buttonEnabled(true);
- }
-
- if (!tasks.length) {
- $('#runningTasksCollapsible', page).hide();
- } else {
- $('#runningTasksCollapsible', page).show();
- }
-
- for (var i = 0, length = tasks.length; i < length; i++) {
-
- var task = tasks[i];
-
- html += '';
-
- html += task.Name + " ";
-
- if (task.State == "Running") {
- var progress = (task.CurrentProgressPercentage || 0).toFixed(1);
-
- html += '';
- html += '' + progress + '%';
- html += ' ';
-
- html += "" + progress + "% ";
-
- html += ' ';
- }
- else if (task.State == "Cancelling") {
- html += '' + Globalize.translate('LabelStopping') + ' ';
- }
-
- html += '
';
- }
-
-
- $('#divRunningTasks', page).html(html);
- },
-
- renderUrls: function (page, systemInfo) {
-
- if (systemInfo.LocalAddress) {
-
- var localAccessHtml = Globalize.translate('LabelLocalAccessUrl', '' + systemInfo.LocalAddress + ' ');
-
- //localAccessHtml += ' ';
-
- $('.localUrl', page).html(localAccessHtml).show().trigger('create');
- } else {
- $('.externalUrl', page).hide();
- }
-
- if (systemInfo.WanAddress) {
-
- var externalUrl = systemInfo.WanAddress;
-
- var remoteAccessHtml = Globalize.translate('LabelRemoteAccessUrl', '' + externalUrl + ' ');
-
- $('.externalUrl', page).html(remoteAccessHtml).show().trigger('create');
- } else {
- $('.externalUrl', page).hide();
- }
- },
-
- renderSupporterIcon: function (page, pluginSecurityInfo) {
-
- var imgUrl, text;
-
- if (!AppInfo.enableSupporterMembership) {
- $('.supporterIconContainer', page).remove();
- }
- else if (pluginSecurityInfo.IsMBSupporter) {
-
- imgUrl = "css/images/supporter/supporterbadge.png";
- text = Globalize.translate('MessageThankYouForSupporting');
-
- $('.supporterIconContainer', page).html('' + text + ' ');
- } else {
-
- imgUrl = "css/images/supporter/nonsupporterbadge.png";
- text = Globalize.translate('MessagePleaseSupportProject');
-
- $('.supporterIconContainer', page).html('' + text + ' ');
- }
- },
-
- renderHasPendingRestart: function (page, hasPendingRestart) {
-
- if (!hasPendingRestart) {
-
- // Only check once every 30 mins
- if (DashboardPage.lastAppUpdateCheck && (new Date().getTime() - DashboardPage.lastAppUpdateCheck) < 1800000) {
- return;
- }
-
- DashboardPage.lastAppUpdateCheck = new Date().getTime();
-
- ApiClient.getAvailableApplicationUpdate().then(function (packageInfo) {
-
- var version = packageInfo[0];
-
- if (!version) {
- page.querySelector('#pUpToDate').classList.remove('hide');
- $('#pUpdateNow', page).hide();
- } else {
- page.querySelector('#pUpToDate').classList.add('hide');
-
- $('#pUpdateNow', page).show();
-
- $('#newVersionNumber', page).html(Globalize.translate('VersionXIsAvailableForDownload').replace('{0}', version.versionStr));
+ if (device.indexOf('chrome') != -1) {
+ imgUrl = 'css/images/clients/chrome.png';
+ }
+ else {
+ imgUrl = 'css/images/clients/html5.png';
}
+ return " ";
+ }
+ if (clientLowered.indexOf('android') != -1) {
+ return " ";
+ }
+ if (clientLowered.indexOf('ios') != -1) {
+ return " ";
+ }
+ if (clientLowered == "mb-classic") {
+
+ return " ";
+ }
+ if (clientLowered == "roku") {
+
+ return " ";
+ }
+ if (clientLowered == "windows phone") {
+
+ return " ";
+ }
+ if (clientLowered == "dlna") {
+
+ return " ";
+ }
+ if (clientLowered == "kodi" || clientLowered == "xbmc") {
+ return " ";
+ }
+ if (clientLowered == "chromecast") {
+
+ return " ";
+ }
+
+ return null;
+ },
+
+ getNowPlayingImageUrl: function (item) {
+
+ if (item && item.BackdropImageTag) {
+
+ return ApiClient.getScaledImageUrl(item.BackdropItemId, {
+ type: "Backdrop",
+ width: 275,
+ tag: item.BackdropImageTag
+ });
+ }
+
+ if (item && item.ThumbImageTag) {
+
+ return ApiClient.getScaledImageUrl(item.ThumbItemId, {
+ type: "Thumb",
+ width: 275,
+ tag: item.ThumbImageTag
+ });
+ }
+
+ if (item && item.PrimaryImageTag) {
+
+ return ApiClient.getScaledImageUrl(item.PrimaryImageItemId, {
+ type: "Primary",
+ width: 275,
+ tag: item.PrimaryImageTag
+ });
+ }
+
+ return null;
+ },
+
+ systemUpdateTaskKey: "SystemUpdateTask",
+
+ renderRunningTasks: function (page, tasks) {
+
+ var html = '';
+
+ tasks = tasks.filter(function (t) {
+ return t.State != 'Idle' && !t.IsHidden;
});
- } else {
+ if (tasks.filter(function (t) {
- page.querySelector('#pUpToDate').classList.add('hide');
+ return t.Key == DashboardPage.systemUpdateTaskKey;
- $('#pUpdateNow', page).hide();
- }
- },
+ }).length) {
- renderPendingInstallations: function (page, systemInfo) {
+ $('#btnUpdateApplication', page).buttonEnabled(false);
+ } else {
+ $('#btnUpdateApplication', page).buttonEnabled(true);
+ }
- if (systemInfo.CompletedInstallations.length) {
+ if (!tasks.length) {
+ $('#runningTasksCollapsible', page).hide();
+ } else {
+ $('#runningTasksCollapsible', page).show();
+ }
- $('#collapsiblePendingInstallations', page).show();
+ for (var i = 0, length = tasks.length; i < length; i++) {
- } else {
- $('#collapsiblePendingInstallations', page).hide();
+ var task = tasks[i];
- return;
- }
+ html += '';
- var html = '';
+ html += task.Name + " ";
- for (var i = 0, length = systemInfo.CompletedInstallations.length; i < length; i++) {
+ if (task.State == "Running") {
+ var progress = (task.CurrentProgressPercentage || 0).toFixed(1);
- var update = systemInfo.CompletedInstallations[i];
+ html += '';
+ html += '' + progress + '%';
+ html += ' ';
- html += '
' + update.Name + ' (' + update.Version + ')
';
- }
+ html += "" + progress + "% ";
- $('#pendingInstallations', page).html(html);
- },
+ html += ' ';
+ }
+ else if (task.State == "Cancelling") {
+ html += '' + Globalize.translate('LabelStopping') + ' ';
+ }
- renderPluginUpdateInfo: function (page, forceUpdate) {
+ html += '';
+ }
- // Only check once every 30 mins
- if (!forceUpdate && DashboardPage.lastPluginUpdateCheck && (new Date().getTime() - DashboardPage.lastPluginUpdateCheck) < 1800000) {
- return;
- }
- DashboardPage.lastPluginUpdateCheck = new Date().getTime();
+ $('#divRunningTasks', page).html(html);
+ },
- ApiClient.getAvailablePluginUpdates().then(function (updates) {
+ renderUrls: function (page, systemInfo) {
- var elem = $('#pPluginUpdates', page);
+ if (systemInfo.LocalAddress) {
- if (updates.length) {
+ var localAccessHtml = Globalize.translate('LabelLocalAccessUrl', '' + systemInfo.LocalAddress + ' ');
- elem.show();
+ //localAccessHtml += ' ';
+
+ $('.localUrl', page).html(localAccessHtml).show().trigger('create');
+ } else {
+ $('.externalUrl', page).hide();
+ }
+
+ if (systemInfo.WanAddress) {
+
+ var externalUrl = systemInfo.WanAddress;
+
+ var remoteAccessHtml = Globalize.translate('LabelRemoteAccessUrl', '' + externalUrl + ' ');
+
+ $('.externalUrl', page).html(remoteAccessHtml).show().trigger('create');
+ } else {
+ $('.externalUrl', page).hide();
+ }
+ },
+
+ renderSupporterIcon: function (page, pluginSecurityInfo) {
+
+ var imgUrl, text;
+
+ if (!AppInfo.enableSupporterMembership) {
+ $('.supporterIconContainer', page).remove();
+ }
+ else if (pluginSecurityInfo.IsMBSupporter) {
+
+ imgUrl = "css/images/supporter/supporterbadge.png";
+ text = Globalize.translate('MessageThankYouForSupporting');
+
+ $('.supporterIconContainer', page).html('' + text + ' ');
+ } else {
+
+ imgUrl = "css/images/supporter/nonsupporterbadge.png";
+ text = Globalize.translate('MessagePleaseSupportProject');
+
+ $('.supporterIconContainer', page).html('' + text + ' ');
+ }
+ },
+
+ renderHasPendingRestart: function (page, hasPendingRestart) {
+
+ if (!hasPendingRestart) {
+
+ // Only check once every 30 mins
+ if (DashboardPage.lastAppUpdateCheck && (new Date().getTime() - DashboardPage.lastAppUpdateCheck) < 1800000) {
+ return;
+ }
+
+ DashboardPage.lastAppUpdateCheck = new Date().getTime();
+
+ ApiClient.getAvailableApplicationUpdate().then(function (packageInfo) {
+
+ var version = packageInfo[0];
+
+ if (!version) {
+ page.querySelector('#pUpToDate').classList.remove('hide');
+ $('#pUpdateNow', page).hide();
+ } else {
+ page.querySelector('#pUpToDate').classList.add('hide');
+
+ $('#pUpdateNow', page).show();
+
+ $('#newVersionNumber', page).html(Globalize.translate('VersionXIsAvailableForDownload').replace('{0}', version.versionStr));
+ }
+
+ });
} else {
- elem.hide();
+
+ page.querySelector('#pUpToDate').classList.add('hide');
+
+ $('#pUpdateNow', page).hide();
+ }
+ },
+
+ renderPendingInstallations: function (page, systemInfo) {
+
+ if (systemInfo.CompletedInstallations.length) {
+
+ $('#collapsiblePendingInstallations', page).show();
+
+ } else {
+ $('#collapsiblePendingInstallations', page).hide();
return;
}
+
var html = '';
- for (var i = 0, length = updates.length; i < length; i++) {
+ for (var i = 0, length = systemInfo.CompletedInstallations.length; i < length; i++) {
- var update = updates[i];
+ var update = systemInfo.CompletedInstallations[i];
- html += '' + Globalize.translate('NewVersionOfSomethingAvailable').replace('{0}', update.name) + '
';
-
- html += '' + Globalize.translate('ButtonUpdateNow') + ' ';
+ html += '' + update.Name + ' (' + update.Version + ')
';
}
- elem.html(html);
+ $('#pendingInstallations', page).html(html);
+ },
- });
- },
+ renderPluginUpdateInfo: function (page, forceUpdate) {
- installPluginUpdate: function (button) {
+ // Only check once every 30 mins
+ if (!forceUpdate && DashboardPage.lastPluginUpdateCheck && (new Date().getTime() - DashboardPage.lastPluginUpdateCheck) < 1800000) {
+ return;
+ }
- $(button).buttonEnabled(false);
+ DashboardPage.lastPluginUpdateCheck = new Date().getTime();
- var name = button.getAttribute('data-name');
- var guid = button.getAttribute('data-guid');
- var version = button.getAttribute('data-version');
- var classification = button.getAttribute('data-classification');
+ ApiClient.getAvailablePluginUpdates().then(function (updates) {
- Dashboard.showLoadingMsg();
+ var elem = $('#pPluginUpdates', page);
- ApiClient.installPlugin(name, guid, classification, version).then(function () {
+ if (updates.length) {
- Dashboard.hideLoadingMsg();
- });
- },
+ elem.show();
- updateApplication: function () {
+ } else {
+ elem.hide();
- var page = $.mobile.activePage;
- $('#btnUpdateApplication', page).buttonEnabled(false);
+ return;
+ }
+ var html = '';
- Dashboard.showLoadingMsg();
+ for (var i = 0, length = updates.length; i < length; i++) {
- ApiClient.getScheduledTasks().then(function (tasks) {
+ var update = updates[i];
- var task = tasks.filter(function (t) {
+ html += '' + Globalize.translate('NewVersionOfSomethingAvailable').replace('{0}', update.name) + '
';
- return t.Key == DashboardPage.systemUpdateTaskKey;
- })[0];
+ html += '' + Globalize.translate('ButtonUpdateNow') + ' ';
+ }
- ApiClient.startScheduledTask(task.Id).then(function () {
+ elem.html(html);
- DashboardPage.pollForInfo(page);
+ });
+ },
+
+ installPluginUpdate: function (button) {
+
+ $(button).buttonEnabled(false);
+
+ var name = button.getAttribute('data-name');
+ var guid = button.getAttribute('data-guid');
+ var version = button.getAttribute('data-version');
+ var classification = button.getAttribute('data-classification');
+
+ Dashboard.showLoadingMsg();
+
+ ApiClient.installPlugin(name, guid, classification, version).then(function () {
Dashboard.hideLoadingMsg();
});
- });
- },
+ },
- stopTask: function (id) {
+ updateApplication: function () {
- var page = $.mobile.activePage;
+ var page = $.mobile.activePage;
+ $('#btnUpdateApplication', page).buttonEnabled(false);
- ApiClient.stopScheduledTask(id).then(function () {
+ Dashboard.showLoadingMsg();
- DashboardPage.pollForInfo(page);
- });
+ ApiClient.getScheduledTasks().then(function (tasks) {
- },
+ var task = tasks.filter(function (t) {
- restart: function () {
+ return t.Key == DashboardPage.systemUpdateTaskKey;
+ })[0];
- require(['confirm'], function (confirm) {
+ ApiClient.startScheduledTask(task.Id).then(function () {
- confirm(Globalize.translate('MessageConfirmRestart'), Globalize.translate('HeaderRestart')).then(function () {
+ DashboardPage.pollForInfo(page);
- $('#btnRestartServer').buttonEnabled(false);
- $('#btnShutdown').buttonEnabled(false);
- Dashboard.restartServer();
+ Dashboard.hideLoadingMsg();
+ });
});
- });
- },
+ },
- shutdown: function () {
+ stopTask: function (id) {
- require(['confirm'], function (confirm) {
+ var page = $.mobile.activePage;
- confirm(Globalize.translate('MessageConfirmShutdown'), Globalize.translate('HeaderShutdown')).then(function () {
+ ApiClient.stopScheduledTask(id).then(function () {
- $('#btnRestartServer').buttonEnabled(false);
- $('#btnShutdown').buttonEnabled(false);
- ApiClient.shutdownServer();
- });
- });
- }
-};
-
-$(document).on('pageshow', "#dashboardPage", DashboardPage.onPageShow).on('pagebeforehide', "#dashboardPage", DashboardPage.onPageHide);
-
-(function ($, document, window) {
-
- function getEntryHtml(entry) {
-
- var html = '';
-
- html += '';
-
- var color = entry.Severity == 'Error' || entry.Severity == 'Fatal' || entry.Severity == 'Warn' ? '#cc0000' : '#52B54B';
-
- if (entry.UserId && entry.UserPrimaryImageTag) {
-
- var userImgUrl = ApiClient.getUserImageUrl(entry.UserId, {
- type: 'Primary',
- tag: entry.UserPrimaryImageTag,
- height: 40
+ DashboardPage.pollForInfo(page);
});
- html += ' ';
- }
- else {
- html += ' ';
- }
+ },
- html += '';
+ restart: function () {
- html += '';
- html += entry.Name;
- html += '
';
+ require(['confirm'], function (confirm) {
- html += '';
- var date = parseISO8601Date(entry.Date, { toLocal: true });
- html += date.toLocaleDateString() + ' ' + date.toLocaleTimeString().toLowerCase();
- html += '
';
+ confirm(Globalize.translate('MessageConfirmRestart'), Globalize.translate('HeaderRestart')).then(function () {
- html += '';
- html += entry.ShortOverview || '';
- html += '
';
+ $('#btnRestartServer').buttonEnabled(false);
+ $('#btnShutdown').buttonEnabled(false);
+ Dashboard.restartServer();
+ });
+ });
+ },
- html += ' ';
+ shutdown: function () {
- html += ' ';
+ require(['confirm'], function (confirm) {
- return html;
- }
+ confirm(Globalize.translate('MessageConfirmShutdown'), Globalize.translate('HeaderShutdown')).then(function () {
- function renderList(elem, result, startIndex, limit) {
-
- var html = result.Items.map(getEntryHtml).join('');
-
- if (result.TotalRecordCount > limit) {
-
- var query = { StartIndex: startIndex, Limit: limit };
-
- html += LibraryBrowser.getQueryPagingHtml({
- startIndex: query.StartIndex,
- limit: query.Limit,
- totalRecordCount: result.TotalRecordCount,
- showLimit: false,
- updatePageSizeSetting: false
+ $('#btnRestartServer').buttonEnabled(false);
+ $('#btnShutdown').buttonEnabled(false);
+ ApiClient.shutdownServer();
+ });
});
}
-
- $(elem).html(html);
-
- $('.btnNextPage', elem).on('click', function () {
- reloadData(elem, startIndex + limit, limit);
- });
-
- $('.btnPreviousPage', elem).on('click', function () {
- reloadData(elem, startIndex - limit, limit);
- });
-
- $('.btnShowOverview', elem).on('click', function () {
-
- var item = $(this).parents('.newsItem');
- var overview = $('.newsItemLongDescription', item).html();
- var name = $('.notificationName', item).html();
-
- Dashboard.alert({
- message: '' + overview + '
',
- title: name
- });
- });
- }
-
- function reloadData(elem, startIndex, limit) {
-
- if (startIndex == null) {
- startIndex = parseInt(elem.getAttribute('data-activitystartindex') || '0');
- }
-
- limit = limit || parseInt(elem.getAttribute('data-activitylimit') || '7');
-
- // Show last 24 hours
- var minDate = new Date();
- minDate.setTime(minDate.getTime() - 86400000);
-
- ApiClient.getJSON(ApiClient.getUrl('System/ActivityLog/Entries', {
-
- startIndex: startIndex,
- limit: limit,
- minDate: minDate.toISOString()
-
- })).then(function (result) {
-
- elem.setAttribute('data-activitystartindex', startIndex);
- elem.setAttribute('data-activitylimit', limit);
-
- renderList(elem, result, startIndex, limit);
- });
- }
-
- function createList(elem) {
-
- elem.each(function () {
-
- reloadData(this);
-
- }).addClass('activityLogListWidget');
-
- var apiClient = ApiClient;
-
- if (!apiClient) {
- return;
- }
-
- Events.on(apiClient, 'websocketopen', onSocketOpen);
- Events.on(apiClient, 'websocketmessage', onSocketMessage);
- }
-
- function startListening(apiClient) {
-
- if (apiClient.isWebSocketOpen()) {
- apiClient.sendWebSocketMessage("ActivityLogEntryStart", "0,1500");
- }
-
- }
-
- function stopListening(apiClient) {
-
- if (apiClient.isWebSocketOpen()) {
- apiClient.sendWebSocketMessage("ActivityLogEntryStop", "0,1500");
- }
-
- }
-
- function onSocketOpen() {
-
- var apiClient = ApiClient;
- if (apiClient) {
- startListening(apiClient);
- }
- }
-
- function onSocketMessage(e, data) {
-
- var msg = data;
-
- if (msg.MessageType === "ActivityLogEntry") {
- $('.activityLogListWidget').each(function () {
-
- reloadData(this);
- });
- }
- }
-
- function destroyList(elem) {
-
- var apiClient = ApiClient;
-
- if (apiClient) {
- Events.off(apiClient, 'websocketopen', onSocketOpen);
- Events.off(apiClient, 'websocketmessage', onSocketMessage);
-
- stopListening(apiClient);
- }
- }
-
- $.fn.activityLogList = function (action) {
-
- if (action == 'destroy') {
- this.removeClass('activityLogListWidget');
- destroyList(this);
- } else {
- createList(this);
- }
-
- var apiClient = ApiClient;
-
- if (apiClient) {
- startListening(apiClient);
- }
-
- return this;
};
-})(jQuery, document, window);
+ $(document).on('pageshow', "#dashboardPage", DashboardPage.onPageShow).on('pagebeforehide', "#dashboardPage", DashboardPage.onPageHide);
-(function ($, document, window) {
+ (function ($, document, window) {
- var welcomeDismissValue = '12';
- var welcomeTourKey = 'welcomeTour';
+ function getEntryHtml(entry) {
- function dismissWelcome(page, userId) {
+ var html = '';
- ApiClient.getDisplayPreferences('dashboard', userId, 'dashboard').then(function (result) {
+ html += '';
- result.CustomPrefs[welcomeTourKey] = welcomeDismissValue;
- ApiClient.updateDisplayPreferences('dashboard', result, userId, 'dashboard');
+ var color = entry.Severity == 'Error' || entry.Severity == 'Fatal' || entry.Severity == 'Warn' ? '#cc0000' : '#52B54B';
- $(page).off('pageshow', onPageShowCheckTour);
- });
- }
+ if (entry.UserId && entry.UserPrimaryImageTag) {
- function showWelcomeIfNeeded(page, apiClient) {
-
- var userId = Dashboard.getCurrentUserId();
-
- apiClient.getDisplayPreferences('dashboard', userId, 'dashboard').then(function (result) {
-
- if (result.CustomPrefs[welcomeTourKey] == welcomeDismissValue) {
- $('.welcomeMessage', page).hide();
- } else {
-
- var elem = $('.welcomeMessage', page).show();
-
- if (result.CustomPrefs[welcomeTourKey]) {
-
- $('.tourHeader', elem).html(Globalize.translate('HeaderWelcomeBack'));
- $('.tourButtonText', elem).html(Globalize.translate('ButtonTakeTheTourToSeeWhatsNew'));
-
- } else {
-
- $('.tourHeader', elem).html(Globalize.translate('HeaderWelcomeToProjectServerDashboard'));
- $('.tourButtonText', elem).html(Globalize.translate('ButtonTakeTheTour'));
- }
- }
- });
- }
-
- 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') }
- ];
-
- require(['slideshow'], function (slideshow) {
-
- var newSlideShow = new slideshow({
- slides: slides,
- interactive: true,
- loop: false
+ var userImgUrl = ApiClient.getUserImageUrl(entry.UserId, {
+ type: 'Primary',
+ tag: entry.UserPrimaryImageTag,
+ height: 40
});
- newSlideShow.show();
-
- dismissWelcome(page, userId);
- $('.welcomeMessage', page).hide();
- });
- });
- }
-
- function onPageShowCheckTour() {
- var page = this;
-
- var apiClient = ApiClient;
-
- if (apiClient && !AppInfo.isNativeApp) {
- showWelcomeIfNeeded(page, apiClient);
- }
- }
-
- $(document).on('pageinit', "#dashboardPage", function () {
-
- var page = this;
-
- $('.btnTakeTour', page).on('click', function () {
- takeTour(page, Dashboard.getCurrentUserId());
- });
-
- }).on('pageshow', "#dashboardPage", onPageShowCheckTour);
-
-})(jQuery, document, window);
-
-(function () {
-
- $(document).on('pageshow', ".type-interior", function () {
-
- var page = this;
-
- Dashboard.getPluginSecurityInfo().then(function (pluginSecurityInfo) {
-
- if (!$('.customSupporterPromotion', page).length) {
- $('.supporterPromotion', page).remove();
-
- if (!pluginSecurityInfo.IsMBSupporter && AppInfo.enableSupporterMembership) {
-
- var html = '';
-
- $('.content-primary', page).append(html);
- }
+ html += ' ';
+ }
+ else {
+ html += ' ';
}
+ html += '';
+
+ html += '';
+ html += entry.Name;
+ html += '
';
+
+ html += '';
+ var date = datetime.parseISO8601Date(entry.Date, true);
+ html += date.toLocaleDateString() + ' ' + date.toLocaleTimeString().toLowerCase();
+ html += '
';
+
+ html += '';
+ html += entry.ShortOverview || '';
+ html += '
';
+
+ html += ' ';
+
+ html += ' ';
+
+ return html;
+ }
+
+ function renderList(elem, result, startIndex, limit) {
+
+ var html = result.Items.map(getEntryHtml).join('');
+
+ if (result.TotalRecordCount > limit) {
+
+ var query = { StartIndex: startIndex, Limit: limit };
+
+ html += LibraryBrowser.getQueryPagingHtml({
+ startIndex: query.StartIndex,
+ limit: query.Limit,
+ totalRecordCount: result.TotalRecordCount,
+ showLimit: false,
+ updatePageSizeSetting: false
+ });
+ }
+
+ $(elem).html(html);
+
+ $('.btnNextPage', elem).on('click', function () {
+ reloadData(elem, startIndex + limit, limit);
+ });
+
+ $('.btnPreviousPage', elem).on('click', function () {
+ reloadData(elem, startIndex - limit, limit);
+ });
+
+ $('.btnShowOverview', elem).on('click', function () {
+
+ var item = $(this).parents('.newsItem');
+ var overview = $('.newsItemLongDescription', item).html();
+ var name = $('.notificationName', item).html();
+
+ Dashboard.alert({
+ message: '' + overview + '
',
+ title: name
+ });
+ });
+ }
+
+ function reloadData(elem, startIndex, limit) {
+
+ if (startIndex == null) {
+ startIndex = parseInt(elem.getAttribute('data-activitystartindex') || '0');
+ }
+
+ limit = limit || parseInt(elem.getAttribute('data-activitylimit') || '7');
+
+ // Show last 24 hours
+ var minDate = new Date();
+ minDate.setTime(minDate.getTime() - 86400000);
+
+ ApiClient.getJSON(ApiClient.getUrl('System/ActivityLog/Entries', {
+
+ startIndex: startIndex,
+ limit: limit,
+ minDate: minDate.toISOString()
+
+ })).then(function (result) {
+
+ elem.setAttribute('data-activitystartindex', startIndex);
+ elem.setAttribute('data-activitylimit', limit);
+
+ renderList(elem, result, startIndex, limit);
+ });
+ }
+
+ function createList(elem) {
+
+ elem.each(function () {
+
+ reloadData(this);
+
+ }).addClass('activityLogListWidget');
+
+ var apiClient = ApiClient;
+
+ if (!apiClient) {
+ return;
+ }
+
+ Events.on(apiClient, 'websocketopen', onSocketOpen);
+ Events.on(apiClient, 'websocketmessage', onSocketMessage);
+ }
+
+ function startListening(apiClient) {
+
+ if (apiClient.isWebSocketOpen()) {
+ apiClient.sendWebSocketMessage("ActivityLogEntryStart", "0,1500");
+ }
+
+ }
+
+ function stopListening(apiClient) {
+
+ if (apiClient.isWebSocketOpen()) {
+ apiClient.sendWebSocketMessage("ActivityLogEntryStop", "0,1500");
+ }
+
+ }
+
+ function onSocketOpen() {
+
+ var apiClient = ApiClient;
+ if (apiClient) {
+ startListening(apiClient);
+ }
+ }
+
+ function onSocketMessage(e, data) {
+
+ var msg = data;
+
+ if (msg.MessageType === "ActivityLogEntry") {
+ $('.activityLogListWidget').each(function () {
+
+ reloadData(this);
+ });
+ }
+ }
+
+ function destroyList(elem) {
+
+ var apiClient = ApiClient;
+
+ if (apiClient) {
+ Events.off(apiClient, 'websocketopen', onSocketOpen);
+ Events.off(apiClient, 'websocketmessage', onSocketMessage);
+
+ stopListening(apiClient);
+ }
+ }
+
+ $.fn.activityLogList = function (action) {
+
+ if (action == 'destroy') {
+ this.removeClass('activityLogListWidget');
+ destroyList(this);
+ } else {
+ createList(this);
+ }
+
+ var apiClient = ApiClient;
+
+ if (apiClient) {
+ startListening(apiClient);
+ }
+
+ return this;
+ };
+
+ })(jQuery, document, window);
+
+ (function ($, document, window) {
+
+ var welcomeDismissValue = '12';
+ var welcomeTourKey = 'welcomeTour';
+
+ function dismissWelcome(page, userId) {
+
+ ApiClient.getDisplayPreferences('dashboard', userId, 'dashboard').then(function (result) {
+
+ result.CustomPrefs[welcomeTourKey] = welcomeDismissValue;
+ ApiClient.updateDisplayPreferences('dashboard', result, userId, 'dashboard');
+
+ $(page).off('pageshow', onPageShowCheckTour);
+ });
+ }
+
+ function showWelcomeIfNeeded(page, apiClient) {
+
+ var userId = Dashboard.getCurrentUserId();
+
+ apiClient.getDisplayPreferences('dashboard', userId, 'dashboard').then(function (result) {
+
+ if (result.CustomPrefs[welcomeTourKey] == welcomeDismissValue) {
+ $('.welcomeMessage', page).hide();
+ } else {
+
+ var elem = $('.welcomeMessage', page).show();
+
+ if (result.CustomPrefs[welcomeTourKey]) {
+
+ $('.tourHeader', elem).html(Globalize.translate('HeaderWelcomeBack'));
+ $('.tourButtonText', elem).html(Globalize.translate('ButtonTakeTheTourToSeeWhatsNew'));
+
+ } else {
+
+ $('.tourHeader', elem).html(Globalize.translate('HeaderWelcomeToProjectServerDashboard'));
+ $('.tourButtonText', elem).html(Globalize.translate('ButtonTakeTheTour'));
+ }
+ }
+ });
+ }
+
+ 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') }
+ ];
+
+ require(['slideshow'], function (slideshow) {
+
+ var newSlideShow = new slideshow({
+ slides: slides,
+ interactive: true,
+ loop: false
+ });
+
+ newSlideShow.show();
+
+ dismissWelcome(page, userId);
+ $('.welcomeMessage', page).hide();
+ });
+ });
+ }
+
+ function onPageShowCheckTour() {
+ var page = this;
+
+ var apiClient = ApiClient;
+
+ if (apiClient && !AppInfo.isNativeApp) {
+ showWelcomeIfNeeded(page, apiClient);
+ }
+ }
+
+ $(document).on('pageinit', "#dashboardPage", function () {
+
+ var page = this;
+
+ $('.btnTakeTour', page).on('click', function () {
+ takeTour(page, Dashboard.getCurrentUserId());
+ });
+
+ }).on('pageshow', "#dashboardPage", onPageShowCheckTour);
+
+ })(jQuery, document, window);
+
+ (function () {
+
+ $(document).on('pageshow', ".type-interior", function () {
+
+ var page = this;
+
+ Dashboard.getPluginSecurityInfo().then(function (pluginSecurityInfo) {
+
+ if (!$('.customSupporterPromotion', page).length) {
+ $('.supporterPromotion', page).remove();
+
+ if (!pluginSecurityInfo.IsMBSupporter && AppInfo.enableSupporterMembership) {
+
+ var html = '';
+
+ $('.content-primary', page).append(html);
+ }
+ }
+
+ });
+
});
- });
+ })();
-})();
\ No newline at end of file
+});
\ No newline at end of file