From 3309bc33da4789cec2fcfc4882d13a33b942cf65 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 23 Jul 2016 02:49:46 -0400 Subject: [PATCH] set default directory picker path for qnap --- .../directorybrowser/directorybrowser.js | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/dashboard-ui/components/directorybrowser/directorybrowser.js b/dashboard-ui/components/directorybrowser/directorybrowser.js index 1084841e78..7b9e110d0b 100644 --- a/dashboard-ui/components/directorybrowser/directorybrowser.js +++ b/dashboard-ui/components/directorybrowser/directorybrowser.js @@ -19,13 +19,12 @@ function onDialogClosed() { - $(this).remove(); Dashboard.hideLoadingMsg(); } function refreshDirectoryBrowser(page, path, fileOptions) { - if (path && typeof(path) !== 'string') { + if (path && typeof (path) !== 'string') { throw new Error('invalid path'); } Dashboard.showLoadingMsg(); @@ -185,6 +184,20 @@ }); } + function getDefaultPath(options) { + if (options.path) { + return Promise.resolve(options.path); + } + + return ApiClient.getJSON(ApiClient.getUrl("Environment/DefaultDirectoryBrowser")).then(function (result) { + + return result.Path || ''; + + }, function () { + return ''; + }); + } + function directoryBrowser() { var self = this; @@ -206,10 +219,14 @@ fileOptions.includeFiles = options.includeFiles; } - getSystemInfo().then(function (systemInfo) { + Promise.all([getSystemInfo(), getDefaultPath(options)]).then(function (responses) { + + var systemInfo = responses[0]; + var initialPath = responses[1]; var dlg = dialogHelper.createDialog({ - size: 'medium' + size: 'medium', + removeOnClose: true }); dlg.classList.add('ui-body-a'); @@ -249,13 +266,9 @@ currentDialog = dlg; - var txtCurrentPath = $('#txtDirectoryPickerPath', editorContent); - - if (options.path) { - txtCurrentPath.val(options.path); - } - - refreshDirectoryBrowser(editorContent, txtCurrentPath.val()); + var txtCurrentPath = editorContent.querySelector('#txtDirectoryPickerPath'); + txtCurrentPath.value = initialPath; + refreshDirectoryBrowser(editorContent, txtCurrentPath.value); }); };