diff --git a/dashboard-ui/dashboard.html b/dashboard-ui/dashboard.html index aa2af57902..da3c0baacf 100644 --- a/dashboard-ui/dashboard.html +++ b/dashboard-ui/dashboard.html @@ -44,7 +44,9 @@

Active Connections

-
+
+ +
diff --git a/dashboard-ui/scripts/dashboardpage.js b/dashboard-ui/scripts/dashboardpage.js index fb4ddf1b54..7f847666ca 100644 --- a/dashboard-ui/scripts/dashboardpage.js +++ b/dashboard-ui/scripts/dashboardpage.js @@ -75,21 +75,26 @@ var html = ''; - if (!dashboardInfo.ActiveConnections.length) { - html += '

There are no users currently connected.

'; - $('#divConnections', page).html(html).trigger('create'); - return; - } + var table = $('.tblConnections', page); - html += ''; + $('.trSession', table).addClass('deadSession'); for (var i = 0, length = dashboardInfo.ActiveConnections.length; i < length; i++) { var connection = dashboardInfo.ActiveConnections[i]; - html += ''; + var rowId = 'trSession' + connection.Id; - html += ''; + + html += ''; @@ -99,25 +104,40 @@ html += '
' + connection.DeviceName + '
'; html += ''; - html += ''; - html += ''; - html += ''; html += ''; } - html += '
'; + var elem = $('#' + rowId, page); + + if (elem.length) { + DashboardPage.updateSession(elem, connection); + continue; + } + + html += '
'; html += DashboardPage.getClientType(connection); html += ''; + html += ''; html += connection.UserName || ''; html += ''; - html += DashboardPage.getNowPlayingImage(connection.NowPlayingItem); + var nowPlayingItem = connection.NowPlayingItem; + + html += ''; + html += DashboardPage.getNowPlayingImage(nowPlayingItem); html += ''; - html += DashboardPage.getNowPlayingText(connection, connection.NowPlayingItem); + html += ''; + html += DashboardPage.getNowPlayingText(connection, nowPlayingItem); html += '
'; + table.append(html).trigger('create'); - $('#divConnections', page).html(html); + $('.deadSession', table).remove(); + }, + + updateSession: function(row, session) { + + row.removeClass('deadSession'); + + $('.username', row).html(session.UserName || ''); + + var nowPlayingItem = session.NowPlayingItem; + + $('.nowPlayingText', row).html(DashboardPage.getNowPlayingText(session, nowPlayingItem)).trigger('create'); + + $('.nowPlayingImage', row).html(DashboardPage.getNowPlayingImage(nowPlayingItem)); }, getClientType: function (connection) { @@ -190,18 +210,14 @@ getNowPlayingImage: function (item) { - if (item) { + if (item && item.PrimaryImageTag) { + var url = ApiClient.getImageUrl(item.Id, { + type: "Primary", + height: 100, + tag: item.PrimaryImageTag + }); - if (item.PrimaryImageTag) { - - var url = ApiClient.getImageUrl(item.Id, { - type: "Primary", - height: 100, - tag: item.PrimaryImageTag - }); - - return "" + item.Name + ""; - } + return "" + item.Name + ""; } return ""; @@ -213,7 +229,7 @@ if (item) { - html += "
" + item.Name + "
"; + html += "
" + item.Name + "
"; html += "
"; @@ -477,11 +493,11 @@ }); }, - + restart: function () { Dashboard.confirm("Are you sure you wish to restart Media Browser Server?", "Restart", function (result) { - + if (result) { $('#btnRestartServer').button('disable'); Dashboard.restartServer();