diff --git a/ApiClient.js b/ApiClient.js index e9679c3f04..af785eb3e8 100644 --- a/ApiClient.js +++ b/ApiClient.js @@ -496,6 +496,20 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { }); }; + /** + * Gets a list of network devices from the server + */ + self.getNetworkDevices = function () { + + var url = self.getUrl("Environment/NetworkDevices"); + + return self.ajax({ + type: "GET", + url: url, + dataType: "json" + }); + }; + /** * Cancels a package installation */ diff --git a/dashboard-ui/scripts/directorybrowser.js b/dashboard-ui/scripts/directorybrowser.js index 5715c62013..d08f2e6555 100644 --- a/dashboard-ui/scripts/directorybrowser.js +++ b/dashboard-ui/scripts/directorybrowser.js @@ -1,12 +1,21 @@ (function (window, document, $) { function refreshDirectoryBrowser(page, path) { - + Dashboard.showLoadingMsg(); + if (path) { + $('.networkHeadline').hide(); + } else { + $('.networkHeadline').show(); + } + var promise; - if (path) { + if (path === "Network") { + promise = ApiClient.getNetworkDevices(); + } + else if (path) { promise = ApiClient.getDirectoryContents(path, { includeDirectories: true }); } else { promise = ApiClient.getDrives(); @@ -32,9 +41,9 @@ if (parentPath.endsWith(':')) { parentPath += "\\"; } - + if (parentPath == '\\') { - parentPath = ""; + parentPath = "Network"; } html += '
  • ..
  • '; @@ -47,6 +56,10 @@ html += '
  • ' + folder.Name + '
  • '; } + if (!path) { + html += '
  • Network
  • '; + } + $('#ulDirectoryPickerList', page).html(html).listview('refresh'); Dashboard.hideLoadingMsg(); @@ -59,8 +72,8 @@ Dashboard.hideLoadingMsg(); }); } - - window.DirectoryBrowser = function(page) { + + window.DirectoryBrowser = function (page) { var self = this; @@ -84,12 +97,15 @@ html += '
    '; html += ''; html += ''; - html += '
    Network paths can be entered manually, e.g. \\\\my-server
    '; html += '
    '; html += '
    '; html += ''; + + html += '
    Network paths can be entered manually in the event the Network button fails to locate your devices. For example, \\\\my-server.
    '; + html += '
    '; + html += '

    '; html += ''; @@ -102,13 +118,13 @@ $(page).append(html); var popup = $('#popupDirectoryPicker').popup().trigger('create').on("popupafteropen", function () { - + $('#popupDirectoryPicker input:first', this).focus(); - + }).popup("open").on("popupafterclose", function () { $('form', this).off("submit"); - + $(this).off("click").off("change").off("popupafterclose").remove(); }).on("click", ".lnkDirectory", function () { @@ -116,7 +132,7 @@ var path = this.getAttribute('data-path'); refreshDirectoryBrowser(page, path); - + }).on("change", "#txtDirectoryPickerPath", function () { refreshDirectoryBrowser(page, this.value); @@ -141,7 +157,7 @@ }; - self.close = function() { + self.close = function () { $('#popupDirectoryPicker', page).popup("close"); }; }; diff --git a/packages.config b/packages.config index 2e19e0a123..395c46b566 100644 --- a/packages.config +++ b/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file