diff --git a/src/components/homesections/homesections.js b/src/components/homesections/homesections.js index af574200f3..c6d0652ecc 100644 --- a/src/components/homesections/homesections.js +++ b/src/components/homesections/homesections.js @@ -40,26 +40,48 @@ define(['connectionManager', 'cardBuilder', 'appSettings', 'dom', 'apphost', 'la return getUserViews(apiClient, user.Id).then(function (userViews) { var html = ''; - var sectionCount = 7; - for (var i = 0; i < sectionCount; i++) { - html += '
'; - } + if (userViews.length) { + var sectionCount = 7; + for (var i = 0; i < sectionCount; i++) { + html += '
'; + } - elem.innerHTML = html; - elem.classList.add('homeSectionsContainer'); + elem.innerHTML = html; + elem.classList.add('homeSectionsContainer'); - var promises = []; - var sections = getAllSectionsToShow(userSettings, sectionCount); - for (var i = 0; i < sections.length; i++) { - promises.push(loadSection(elem, apiClient, user, userSettings, userViews, sections, i)); - } + var promises = []; + var sections = getAllSectionsToShow(userSettings, sectionCount); + for (var i = 0; i < sections.length; i++) { + promises.push(loadSection(elem, apiClient, user, userSettings, userViews, sections, i)); + } - return Promise.all(promises).then(function () { - return resume(elem, { - refresh: true, - returnPromise: false + return Promise.all(promises).then(function () { + return resume(elem, { + refresh: true, + returnPromise: false + }); }); - }); + } else { + var noLibDescription; + if (user['Policy'] && user['Policy']['IsAdministrator']) { + noLibDescription = Globalize.translate("NoCreatedLibraries", '', '') + } else { + noLibDescription = Globalize.translate("AskAdminToCreateLibrary"); + } + + html += '
'; + html += '

' + Globalize.translate("MessageNothingHere") + '

'; + html += '

' + noLibDescription + '

' + html += '
'; + elem.innerHTML = html; + + var createNowLink = elem.querySelector("#button-createLibrary") + if (createNowLink) { + createNowLink.addEventListener("click", () => { + Dashboard.navigate("library.html"); + }); + } + } }); } diff --git a/src/strings/en-us.json b/src/strings/en-us.json index 84f78079a5..d7e404eba6 100644 --- a/src/strings/en-us.json +++ b/src/strings/en-us.json @@ -36,6 +36,7 @@ "Artists": "Artists", "AsManyAsPossible": "As many as possible", "Ascending": "Ascending", + "AskAdminToCreateLibrary": "Ask an administrator to create a library.", "AspectRatio": "Aspect Ratio", "AttributeNew": "New", "Audio": "Audio", @@ -1032,6 +1033,7 @@ "Next": "Next", "NextUp": "Next Up", "No": "No", + "NoCreatedLibraries": "Seems like you haven't created any libraries yet. {0}Would you like to create one now?{1}", "NoNewDevicesFound": "No new devices found. To add a new tuner, close this dialog and enter the device information manually.", "NoNextUpItemsMessage": "None found. Start watching your shows!", "NoPluginConfigurationMessage": "This plugin has no settings to configure.",