diff --git a/dashboard-ui/css/card.css b/dashboard-ui/css/card.css index 6d5fb5b8d1..b4525de5f6 100644 --- a/dashboard-ui/css/card.css +++ b/dashboard-ui/css/card.css @@ -338,15 +338,17 @@ } @media all and (min-width: 700px) { - .backdropCard { - width: 33.3%; - } - .bannerCard { width: 50%; } } +@media all and (min-width: 770px) { + .backdropCard { + width: 33.3%; + } +} + @media all and (min-width: 800px) { .squareCard { diff --git a/dashboard-ui/scripts/librarymenu.js b/dashboard-ui/scripts/librarymenu.js index 25b8a34dbd..715e3d9c80 100644 --- a/dashboard-ui/scripts/librarymenu.js +++ b/dashboard-ui/scripts/librarymenu.js @@ -1,6 +1,6 @@ (function (window, document, $, devicePixelRatio) { - function renderHeader(user) { + function renderHeader() { var html = '
'; @@ -22,29 +22,61 @@ html += '
'; - var btnCastVisible = user.localUser ? '' : 'visibility:hidden;'; - if (!AppInfo.enableHeaderImages) { - html += ''; } else { - html += ''; + html += ''; } + html += ''; + + html += '
'; + html += ''; + html += ''; + html += ''; + html += '
'; + + html += ''; + + html += ''; + + html += '
'; + + html += '
'; + + $(document.body).prepend(html); + $('.viewMenuBar').trigger('create').lazyChildren(); + + $(document).trigger('headercreated'); + bindMenuEvents(); + } + + function addUserToHeader(user) { + + var header = $('.viewMenuBar'); + if (user.localUser) { - html += ''; - - html += '
'; - html += ''; - html += ''; - html += ''; - html += '
'; + $('.btnCast', header).show(); + $('.headerSearchButton', header).show(); + } else { + $('.btnCast', header).hide(); + $('.headerSearchButton', header).hide(); } - if (user.name) { + if (user.canManageServer) { + $('.dashboardEntryHeaderButton', header).show(); + } else { + $('.dashboardEntryHeaderButton', header).hide(); + } - html += ''; + $('.headerUserButton', header).html(userButtonHtml).lazyChildren(); } - - if (user.canManageServer) { - html += '
'; - } - - html += ''; - - html += ''; - - $(document.body).prepend(html); - $('.viewMenuBar').trigger('create').lazyChildren(); - - $(document).trigger('headercreated'); - bindMenuEvents(); } function bindMenuEvents() { @@ -505,17 +522,17 @@ var viewMenuBar = $('.viewMenuBar'); if (!$('.viewMenuBar').length) { - ConnectionManager.user(window.ApiClient).done(function (user) { + renderHeader(); + updateViewMenuBarHeadroom(page, $('.viewMenuBar')); - renderHeader(user); - updateViewMenuBarHeadroom(page, $('.viewMenuBar')); + updateCastIcon(); - updateCastIcon(); + updateLibraryNavLinks(page); + updateContextText(page); + requiresViewMenuRefresh = false; + + ConnectionManager.user(window.ApiClient).done(addUserToHeader); - updateLibraryNavLinks(page); - updateContextText(page); - requiresViewMenuRefresh = false; - }); } else { updateContextText(page); updateLibraryNavLinks(page); diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index 72df535014..46a5659b73 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -633,50 +633,62 @@ var Dashboard = { showUserFlyout: function (context) { - ConnectionManager.user(window.ApiClient).done(function (user) { + var html = '
'; - var html = '
'; + html += '

'; - html += '

'; + html += '

'; - var imgWidth = 48; + html += '
'; - if (user.imageUrl && AppInfo.enableUserImage) { - var url = user.imageUrl; + html += '

'; - if (user.supportsImageParams) { - url += "&width=" + (imgWidth * Math.max(window.devicePixelRatio || 1, 2)); - } + if (Dashboard.isConnectMode()) { + html += '

' + Globalize.translate('ButtonSelectServer') + ''; + } - html += '

'; - } - html += user.name; - html += ''; + html += '

'; - html += ''; + html += '
'; + html += '
'; - var isConnectMode = Dashboard.isConnectMode(); + $(document.body).append(html); - if (user.localUser && user.localUser.Policy.EnableUserPreferenceAccess) { - html += '

' + Globalize.translate('ButtonMyPreferences') + ''; - } + var elem = $('#userFlyout').panel({}).lazyChildren().trigger('create').panel("open").on("panelclose", function () { - if (isConnectMode) { - html += '

' + Globalize.translate('ButtonSelectServer') + ''; - } - - html += '

'; - - html += ''; - html += '
'; - - $(document.body).append(html); - - var elem = $('#userFlyout').panel({}).lazyChildren().trigger('create').panel("open").on("panelclose", function () { - - $(this).off("panelclose").remove(); - }); + $(this).off("panelclose").remove(); }); + + ConnectionManager.user(window.ApiClient).done(function (user) { + Dashboard.updateUserFlyout(elem, user); + }); + }, + + updateUserFlyout: function (elem, user) { + + var html = ''; + var imgWidth = 48; + + if (user.imageUrl && AppInfo.enableUserImage) { + var url = user.imageUrl; + + if (user.supportsImageParams) { + url += "&width=" + (imgWidth * Math.max(window.devicePixelRatio || 1, 2)); + } + + html += '
'; + } + html += user.name; + + $('.userHeader', elem).html(html).lazyChildren(); + + html = ''; + + if (user.localUser && user.localUser.Policy.EnableUserPreferenceAccess) { + html += '

' + Globalize.translate('ButtonMyPreferences') + ''; + } + + $('.preferencesContainer', elem).html(html).trigger('create'); }, getPluginSecurityInfo: function () { @@ -1568,38 +1580,33 @@ var AppInfo = {}; window.ConnectionManager = new MediaBrowser.ConnectionManager(Logger, credentialProvider, appInfo.appName, appInfo.appVersion, appInfo.deviceName, appInfo.deviceId, capabilities); - $(ConnectionManager).on('apiclientcreated', function (e, apiClient) { + $(ConnectionManager).on('apiclientcreated', function (e, newApiClient) { - initializeApiClient(apiClient); + initializeApiClient(newApiClient); }); - var lastApiClient = ConnectionManager.getLastUsedApiClient(); + var apiClient; if (Dashboard.isConnectMode()) { + apiClient = ConnectionManager.getLastUsedApiClient(); + if (!Dashboard.isServerlessPage()) { - if (lastApiClient && lastApiClient.serverAddress() && lastApiClient.getCurrentUserId() && lastApiClient.accessToken()) { - - window.ApiClient = lastApiClient; - - initializeApiClient(lastApiClient); - - //ConnectionManager.addApiClient(lastApiClient, true).fail(Dashboard.logout); + if (apiClient && apiClient.serverAddress() && apiClient.getCurrentUserId() && apiClient.accessToken()) { + initializeApiClient(apiClient); } } } else { - if (!lastApiClient) { - lastApiClient = new MediaBrowser.ApiClient(Logger, Dashboard.serverAddress(), appInfo.appName, appInfo.appVersion, appInfo.deviceName, appInfo.deviceId); - ConnectionManager.addApiClient(lastApiClient); - } - - window.ApiClient = lastApiClient; + apiClient = new MediaBrowser.ApiClient(Logger, Dashboard.serverAddress(), appInfo.appName, appInfo.appVersion, appInfo.deviceName, appInfo.deviceId); + ConnectionManager.addApiClient(apiClient); } + window.ApiClient = apiClient; + if (window.ApiClient) { ApiClient.getDefaultImageQuality = Dashboard.getDefaultImageQuality; ApiClient.normalizeImageOptions = Dashboard.normalizeImageOptions; diff --git a/dashboard-ui/scripts/sync.js b/dashboard-ui/scripts/sync.js index 2a7a4f7416..1a988b6a13 100644 --- a/dashboard-ui/scripts/sync.js +++ b/dashboard-ui/scripts/sync.js @@ -365,7 +365,7 @@ var apiClient = window.ApiClient; - if (!apiClient) { + if (!apiClient || !apiClient.getCurrentUserId()) { return; } @@ -400,7 +400,7 @@ onCategorySyncButtonClick(page, this); }); - }).on('pagebeforeshowready', ".libraryPage", function () { + }).on('pageshowready', ".libraryPage", function () { var page = this; diff --git a/dashboard-ui/thirdparty/apiclient/connectionmanager.js b/dashboard-ui/thirdparty/apiclient/connectionmanager.js index 88aa267a71..041859ab42 100644 --- a/dashboard-ui/thirdparty/apiclient/connectionmanager.js +++ b/dashboard-ui/thirdparty/apiclient/connectionmanager.js @@ -122,6 +122,19 @@ apiClients.push(apiClient); + var existingServer = credentialProvider.credentials().servers.filter(function (s) { + + return stringEqualsIgnoreCase(s.ManualAddress, apiClient.serverAddress()); + + })[0]; + + if (existingServer) { + + existingServer.DateLastAccessed = new Date().getTime(); + existingServer.LastConnectionMode = MediaBrowser.ConnectionMode.Manual; + apiClient.serverInfo(existingServer); + } + Events.on(apiClient, 'authenticated', function (e, result) { onAuthenticated(this, result, {}, true); }); @@ -130,7 +143,9 @@ return apiClient.getPublicSystemInfo().done(function (systemInfo) { - var server = credentialProvider.credentials().servers.filter(function (s) { + var credentials = credentialProvider.credentials(); + + var server = credentials.servers.filter(function (s) { return s.Id == systemInfo.Id; @@ -138,7 +153,14 @@ updateServerInfo(server, systemInfo); + server.DateLastAccessed = new Date().getTime(); + server.LastConnectionMode = MediaBrowser.ConnectionMode.Manual; + server.ManualAddress = apiClient.serverAddress(); + apiClient.serverInfo(server); + + credentialProvider.addOrUpdateServer(credentials.servers, server); + credentialProvider.credentials(credentials); }); };