Enter the path that contains some or all of your TV series, you will be able to choose which series you want to import
-
-
diff --git a/src/UI/Settings/MediaManagement/Permissions/PermissionsView.js b/src/UI/Settings/MediaManagement/Permissions/PermissionsView.js
index f4ef2d225..ba2c8697a 100644
--- a/src/UI/Settings/MediaManagement/Permissions/PermissionsView.js
+++ b/src/UI/Settings/MediaManagement/Permissions/PermissionsView.js
@@ -3,37 +3,11 @@ define(
[
'marionette',
'Mixins/AsModelBoundView',
- 'Mixins/AsValidatedView',
- 'Mixins/AutoComplete'
+ 'Mixins/AsValidatedView'
], function (Marionette, AsModelBoundView, AsValidatedView) {
var view = Marionette.ItemView.extend({
- template: 'Settings/MediaManagement/Permissions/PermissionsViewTemplate',
-
- ui: {
- recyclingBin : '.x-path',
- failedDownloadHandlingCheckbox: '.x-failed-download-handling',
- failedDownloadOptions : '.x-failed-download-options'
- },
-
- events: {
- 'change .x-failed-download-handling': '_setFailedDownloadOptionsVisibility'
- },
-
- onShow: function () {
- this.ui.recyclingBin.autoComplete('/directories');
- },
-
- _setFailedDownloadOptionsVisibility: function () {
- var checked = this.ui.failedDownloadHandlingCheckbox.prop('checked');
- if (checked) {
- this.ui.failedDownloadOptions.slideDown();
- }
-
- else {
- this.ui.failedDownloadOptions.slideUp();
- }
- }
+ template: 'Settings/MediaManagement/Permissions/PermissionsViewTemplate'
});
AsModelBoundView.call(view);
diff --git a/src/UI/Shared/FileBrowser/EmptyView.js b/src/UI/Shared/FileBrowser/EmptyView.js
new file mode 100644
index 000000000..6ffda684d
--- /dev/null
+++ b/src/UI/Shared/FileBrowser/EmptyView.js
@@ -0,0 +1,11 @@
+'use strict';
+
+define(
+ [
+ 'marionette'
+ ], function (Marionette) {
+
+ return Marionette.CompositeView.extend({
+ template: 'Shared/FileBrowser/EmptyViewTemplate'
+ });
+ });
diff --git a/src/UI/Shared/FileBrowser/EmptyViewTemplate.hbs b/src/UI/Shared/FileBrowser/EmptyViewTemplate.hbs
new file mode 100644
index 000000000..cc3053509
--- /dev/null
+++ b/src/UI/Shared/FileBrowser/EmptyViewTemplate.hbs
@@ -0,0 +1,3 @@
+
+ No files/folders were found, edit the path above, or clear to start again
+
diff --git a/src/UI/Shared/FileBrowser/FileBrowserCollection.js b/src/UI/Shared/FileBrowser/FileBrowserCollection.js
new file mode 100644
index 000000000..78e7ad06d
--- /dev/null
+++ b/src/UI/Shared/FileBrowser/FileBrowserCollection.js
@@ -0,0 +1,39 @@
+'use strict';
+define(
+ [
+ 'jquery',
+ 'backbone',
+ 'Shared/FileBrowser/FileBrowserModel'
+ ], function ($, Backbone, FileBrowserModel) {
+
+ return Backbone.Collection.extend({
+ model: FileBrowserModel,
+ url : window.NzbDrone.ApiRoot + '/filesystem',
+
+ parse: function(response) {
+ var contents = [];
+
+ if (response.parent || response.parent === '') {
+
+ var type = 'parent';
+ var name = '...';
+
+ if (response.parent === '') {
+ type = 'computer';
+ name = 'My Computer';
+ }
+
+ contents.push({
+ type : type,
+ name : name,
+ path : response.parent
+ });
+ }
+
+ $.merge(contents, response.directories);
+ $.merge(contents, response.files);
+
+ return contents;
+ }
+ });
+ });
diff --git a/src/UI/Shared/FileBrowser/FileBrowserLayout.js b/src/UI/Shared/FileBrowser/FileBrowserLayout.js
new file mode 100644
index 000000000..0eb9813b0
--- /dev/null
+++ b/src/UI/Shared/FileBrowser/FileBrowserLayout.js
@@ -0,0 +1,169 @@
+'use strict';
+define(
+ [
+ 'underscore',
+ 'vent',
+ 'marionette',
+ 'backgrid',
+ 'Shared/FileBrowser/FileBrowserCollection',
+ 'Shared/FileBrowser/EmptyView',
+ 'Shared/FileBrowser/FileBrowserRow',
+ 'Shared/FileBrowser/FileBrowserTypeCell',
+ 'Shared/FileBrowser/FileBrowserNameCell',
+ 'Cells/RelativeDateCell',
+ 'Cells/FileSizeCell',
+ 'Shared/LoadingView',
+ 'Mixins/DirectoryAutoComplete'
+ ], function (_,
+ vent,
+ Marionette,
+ Backgrid,
+ FileBrowserCollection,
+ EmptyView,
+ FileBrowserRow,
+ FileBrowserTypeCell,
+ FileBrowserNameCell,
+ RelativeDateCell,
+ FileSizeCell,
+ LoadingView) {
+
+ return Marionette.Layout.extend({
+ template: 'Shared/FileBrowser/FileBrowserLayoutTemplate',
+
+ regions: {
+ browser : '#x-browser'
+ },
+
+ ui: {
+ path: '.x-path'
+ },
+
+ events: {
+ 'typeahead:selected .x-path' : '_pathChanged',
+ 'typeahead:autocompleted .x-path' : '_pathChanged',
+ 'keyup .x-path' : '_inputChanged',
+ 'click .x-ok' : '_selectPath'
+ },
+
+ initialize: function (options) {
+ this.collection = new FileBrowserCollection();
+ this.collection.showFiles = options.showFiles || false;
+ this.collection.showLastModified = options.showLastModified || false;
+
+ this.input = options.input;
+
+ this._setColumns();
+ this._fetchCollection(this.input.val());
+ this.listenTo(this.collection, 'sync', this._showGrid);
+ this.listenTo(this.collection, 'filebrowser:folderselected', this._rowSelected);
+ },
+
+ onRender: function () {
+ this.browser.show(new LoadingView());
+ },
+
+ onShow: function () {
+ this.ui.path.directoryAutoComplete();
+ this._updatePath(this.input.val());
+ },
+
+ _setColumns: function () {
+ this.columns = [
+ {
+ name : 'type',
+ label : '',
+ sortable : false,
+ cell : FileBrowserTypeCell
+ },
+ {
+ name : 'name',
+ label : 'Name',
+ sortable : false,
+ cell : FileBrowserNameCell
+ }
+ ];
+
+ if (this.collection.showLastModified) {
+ this.columns.push({
+ name : 'lastModified',
+ label : 'Last Modified',
+ sortable : false,
+ cell : RelativeDateCell
+ });
+ }
+
+ if (this.collection.showFiles) {
+ this.columns.push({
+ name : 'size',
+ label : 'Size',
+ sortable : false,
+ cell : FileSizeCell
+ });
+ }
+ },
+
+ _fetchCollection: function (path) {
+ var data = {
+ includeFiles : this.collection.showFiles
+ };
+
+ if (path) {
+ data.path = path;
+ }
+
+ this.collection.fetch({
+ data: data
+ });
+ },
+
+ _showGrid: function () {
+
+ if (this.collection.models.length === 0) {
+ this.browser.show(new EmptyView());
+ return;
+ }
+
+ var grid = new Backgrid.Grid({
+ row : FileBrowserRow,
+ collection : this.collection,
+ columns : this.columns,
+ className : 'table table-hover'
+ });
+
+ this.browser.show(grid);
+ },
+
+ _rowSelected: function (model) {
+ var path = model.get('path');
+
+ this._updatePath(path);
+ this._fetchCollection(path);
+ },
+
+ _pathChanged: function (e, path) {
+ this._fetchCollection(path.value);
+ this._updatePath(path.value);
+ },
+
+ _inputChanged: function () {
+ var path = this.ui.path.val();
+
+ if (path === '' || path.endsWith('\\') || path.endsWith('/')) {
+ this._fetchCollection(path);
+ }
+ },
+
+ _updatePath: function (path) {
+ if (path !== undefined || path !== null) {
+ this.ui.path.val(path);
+ }
+ },
+
+ _selectPath: function () {
+ this.input.val(this.ui.path.val());
+ this.input.trigger('change');
+
+ vent.trigger(vent.Commands.CloseFileBrowser);
+ }
+ });
+ });
diff --git a/src/UI/Shared/FileBrowser/FileBrowserLayoutTemplate.hbs b/src/UI/Shared/FileBrowser/FileBrowserLayoutTemplate.hbs
new file mode 100644
index 000000000..b225d7135
--- /dev/null
+++ b/src/UI/Shared/FileBrowser/FileBrowserLayoutTemplate.hbs
@@ -0,0 +1,26 @@
+
diff --git a/src/UI/Shared/FileBrowser/FileBrowserModalRegion.js b/src/UI/Shared/FileBrowser/FileBrowserModalRegion.js
new file mode 100644
index 000000000..c0c7037e5
--- /dev/null
+++ b/src/UI/Shared/FileBrowser/FileBrowserModalRegion.js
@@ -0,0 +1,63 @@
+'use strict';
+define(
+ [
+ 'jquery',
+ 'backbone',
+ 'marionette',
+ 'bootstrap'
+ ], function ($, Backbone, Marionette) {
+ var region = Marionette.Region.extend({
+ el: '#file-browser-modal-region',
+
+ constructor: function () {
+ Backbone.Marionette.Region.prototype.constructor.apply(this, arguments);
+ this.on('show', this.showModal, this);
+ },
+
+ getEl: function (selector) {
+ var $el = $(selector);
+ $el.on('hidden', this.close);
+ return $el;
+ },
+
+ showModal: function () {
+ this.$el.addClass('modal fade');
+
+ //need tab index so close on escape works
+ //https://github.com/twitter/bootstrap/issues/4663
+ this.$el.attr('tabindex', '-1');
+ this.$el.css('z-index', '1060');
+
+ this.$el.modal({
+ show : true,
+ keyboard : true,
+ backdrop : true
+ });
+
+ this.$el.on('hide.bs.modal', $.proxy(this._closing, this));
+
+ this.$el.on('shown.bs.modal', function () {
+ $('.modal-backdrop:last').css('z-index', 1059);
+ });
+
+ this.currentView.$el.addClass('modal-dialog');
+ },
+
+ closeModal: function () {
+ $(this.el).modal('hide');
+ this.reset();
+ },
+
+ _closing: function () {
+
+ if (this.$el) {
+ this.$el.off('hide.bs.modal');
+ this.$el.off('shown.bs.modal');
+ }
+
+ this.reset();
+ }
+ });
+
+ return region;
+ });
diff --git a/src/UI/Shared/FileBrowser/FileBrowserModel.js b/src/UI/Shared/FileBrowser/FileBrowserModel.js
new file mode 100644
index 000000000..c426f5dbe
--- /dev/null
+++ b/src/UI/Shared/FileBrowser/FileBrowserModel.js
@@ -0,0 +1,10 @@
+'use strict';
+define(
+ [
+ 'backbone'
+ ], function (Backbone) {
+ return Backbone.Model.extend({
+
+ });
+ });
+
diff --git a/src/UI/Shared/FileBrowser/FileBrowserNameCell.js b/src/UI/Shared/FileBrowser/FileBrowserNameCell.js
new file mode 100644
index 000000000..5e1bb38c1
--- /dev/null
+++ b/src/UI/Shared/FileBrowser/FileBrowserNameCell.js
@@ -0,0 +1,23 @@
+'use strict';
+
+define(
+ [
+ 'vent',
+ 'Cells/NzbDroneCell'
+ ], function (vent, NzbDroneCell) {
+ return NzbDroneCell.extend({
+
+ className: 'file-browser-name-cell',
+
+ render: function () {
+ this.$el.empty();
+
+ var name = this.model.get(this.column.get('name'));
+
+ this.$el.html(name);
+
+ this.delegateEvents();
+ return this;
+ }
+ });
+ });
\ No newline at end of file
diff --git a/src/UI/Shared/FileBrowser/FileBrowserRow.js b/src/UI/Shared/FileBrowser/FileBrowserRow.js
new file mode 100644
index 000000000..fceeb30ae
--- /dev/null
+++ b/src/UI/Shared/FileBrowser/FileBrowserRow.js
@@ -0,0 +1,31 @@
+'use strict';
+define(
+ [
+ 'underscore',
+ 'backgrid'
+ ], function (_, Backgrid) {
+
+ return Backgrid.Row.extend({
+ className: 'file-browser-row',
+
+ events: {
+ 'click': '_selectRow'
+ },
+
+ _originalInit: Backgrid.Row.prototype.initialize,
+
+ initialize: function () {
+ this._originalInit.apply(this, arguments);
+ },
+
+ _selectRow: function () {
+ if (this.model.get('type') === 'file') {
+ this.model.collection.trigger('filebrowser:fileselected', this.model);
+ }
+
+ else {
+ this.model.collection.trigger('filebrowser:folderselected', this.model);
+ }
+ }
+ });
+ });
\ No newline at end of file
diff --git a/src/UI/Shared/FileBrowser/FileBrowserTypeCell.js b/src/UI/Shared/FileBrowser/FileBrowserTypeCell.js
new file mode 100644
index 000000000..de90dd2d1
--- /dev/null
+++ b/src/UI/Shared/FileBrowser/FileBrowserTypeCell.js
@@ -0,0 +1,40 @@
+'use strict';
+
+define(
+ [
+ 'vent',
+ 'Cells/NzbDroneCell'
+ ], function (vent, NzbDroneCell) {
+ return NzbDroneCell.extend({
+
+ className: 'file-browser-type-cell',
+
+ render: function () {
+ this.$el.empty();
+
+ var type = this.model.get(this.column.get('name'));
+ var icon = 'icon-hdd';
+
+ if (type === 'computer') {
+ icon = 'icon-desktop';
+ }
+
+ else if (type === 'parent') {
+ icon = 'icon-level-up';
+ }
+
+ else if (type === 'folder') {
+ icon = 'icon-folder-close';
+ }
+
+ else if (type === 'file') {
+ icon = 'icon-file';
+ }
+
+ this.$el.html('
'.format(icon));
+
+ this.delegateEvents();
+ return this;
+ }
+ });
+ });
\ No newline at end of file
diff --git a/src/UI/Shared/FileBrowser/filebrowser.less b/src/UI/Shared/FileBrowser/filebrowser.less
new file mode 100644
index 000000000..c8810147b
--- /dev/null
+++ b/src/UI/Shared/FileBrowser/filebrowser.less
@@ -0,0 +1,24 @@
+.file-browser-row {
+ cursor : pointer;
+
+ .file-size-cell {
+ white-space : nowrap;
+ }
+
+ .relative-date-cell {
+ width : 120px;
+ white-space : nowrap;
+ }
+}
+
+.file-browser-type-cell {
+ width : 16px;
+}
+
+.file-browser-name-cell {
+ word-break : break-all;
+}
+
+.file-browser-empty {
+ margin-top : 20px;
+}
\ No newline at end of file
diff --git a/src/UI/Shared/Modal/ModalController.js b/src/UI/Shared/Modal/ModalController.js
index d435d56b9..daea74c8f 100644
--- a/src/UI/Shared/Modal/ModalController.js
+++ b/src/UI/Shared/Modal/ModalController.js
@@ -9,8 +9,18 @@ define(
'Episode/EpisodeDetailsLayout',
'Activity/History/Details/HistoryDetailsLayout',
'System/Logs/Table/Details/LogDetailsView',
- 'Rename/RenamePreviewLayout'
- ], function (vent, AppLayout, Marionette, EditSeriesView, DeleteSeriesView, EpisodeDetailsLayout, HistoryDetailsLayout, LogDetailsView, RenamePreviewLayout) {
+ 'Rename/RenamePreviewLayout',
+ 'Shared/FileBrowser/FileBrowserLayout'
+ ], function (vent,
+ AppLayout,
+ Marionette,
+ EditSeriesView,
+ DeleteSeriesView,
+ EpisodeDetailsLayout,
+ HistoryDetailsLayout,
+ LogDetailsView,
+ RenamePreviewLayout,
+ FileBrowserLayout) {
return Marionette.AppRouter.extend({
@@ -23,6 +33,8 @@ define(
vent.on(vent.Commands.ShowHistoryDetails, this._showHistory, this);
vent.on(vent.Commands.ShowLogDetails, this._showLogDetails, this);
vent.on(vent.Commands.ShowRenamePreview, this._showRenamePreview, this);
+ vent.on(vent.Commands.ShowFileBrowser, this._showFileBrowser, this);
+ vent.on(vent.Commands.CloseFileBrowser, this._closeFileBrowser, this);
},
_openModal: function (view) {
@@ -61,6 +73,15 @@ define(
_showRenamePreview: function (options) {
var view = new RenamePreviewLayout(options);
AppLayout.modalRegion.show(view);
+ },
+
+ _showFileBrowser: function (options) {
+ var view = new FileBrowserLayout(options);
+ AppLayout.fileBrowserModalRegion.show(view);
+ },
+
+ _closeFileBrowser: function () {
+ AppLayout.fileBrowserModalRegion.closeModal();
}
});
});
diff --git a/src/UI/index.html b/src/UI/index.html
index 5a0970c2d..ab88a6668 100644
--- a/src/UI/index.html
+++ b/src/UI/index.html
@@ -52,6 +52,7 @@