From 76d5422b4cbb347cc44247a767e60722f2bf5dcd Mon Sep 17 00:00:00 2001 From: Berend-Jan Lange Date: Wed, 8 Apr 2020 11:22:53 +0200 Subject: [PATCH 1/2] tree added download multiple files --- notebook/static/tree/js/notebooklist.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/notebook/static/tree/js/notebooklist.js b/notebook/static/tree/js/notebooklist.js index c35f3d9f83..546fbf52f0 100644 --- a/notebook/static/tree/js/notebooklist.js +++ b/notebook/static/tree/js/notebooklist.js @@ -729,10 +729,10 @@ define([ $('.move-button').css('display', 'none'); } - // Download is only visible when one item is selected, and it is not a + // Download is only visible when items is selected, and it is not a // running notebook or a directory - // TODO(nhdaly): Add support for download multiple items at once. - if (selected.length === 1 && !has_running_notebook && !has_directory) { + // Added support for downloading multiple items + if (selected.length > 0 && !has_running_notebook && !has_directory) { $('.download-button').css('display', 'inline-block'); } else { $('.download-button').css('display', 'none'); @@ -1150,15 +1150,15 @@ define([ NotebookList.prototype.download_selected = function() { var that = this; + + that.selected.forEach(function(item) { + var item_path = utils.encode_uri_components(item.path); + window.open(utils.url_path_join(that.base_url, 'files', utils.encode_uri_components(item_path)) + '?download=1', IPython._target); + }); - // TODO(nhdaly): Support download multiple items at once. - if (that.selected.length !== 1){ - return; - } - - var item_path = that.selected[0].path; + // var item_path = that.selected[0].path; - window.open(utils.url_path_join(that.base_url, 'files', utils.encode_uri_components(item_path)) + '?download=1', IPython._target); + // window.open(utils.url_path_join(that.base_url, 'files', utils.encode_uri_components(item_path)) + '?download=1', IPython._target); }; NotebookList.prototype.delete_selected = function() { From feba9751a419a9a596bd52a0b87cecb7e9858bc8 Mon Sep 17 00:00:00 2001 From: Berend-Jan Lange Date: Wed, 8 Apr 2020 11:45:21 +0200 Subject: [PATCH 2/2] changed comments --- notebook/static/tree/js/notebooklist.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/notebook/static/tree/js/notebooklist.js b/notebook/static/tree/js/notebooklist.js index 546fbf52f0..010a95a569 100644 --- a/notebook/static/tree/js/notebooklist.js +++ b/notebook/static/tree/js/notebooklist.js @@ -729,9 +729,8 @@ define([ $('.move-button').css('display', 'none'); } - // Download is only visible when items is selected, and it is not a - // running notebook or a directory - // Added support for downloading multiple items + // Download is only visible when items are selected, and none are + // running notebooks or a directories if (selected.length > 0 && !has_running_notebook && !has_directory) { $('.download-button').css('display', 'inline-block'); } else { @@ -1155,10 +1154,6 @@ define([ var item_path = utils.encode_uri_components(item.path); window.open(utils.url_path_join(that.base_url, 'files', utils.encode_uri_components(item_path)) + '?download=1', IPython._target); }); - - // var item_path = that.selected[0].path; - - // window.open(utils.url_path_join(that.base_url, 'files', utils.encode_uri_components(item_path)) + '?download=1', IPython._target); }; NotebookList.prototype.delete_selected = function() {