From d34092c0153b9c0a352ded6921e624e0760d342f Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Thu, 24 Jan 2013 16:02:53 -0800 Subject: [PATCH] added root dir management. delete doesn't work for some reason. --- .../QualityProfiles/RootFolderModule.cs | 6 +-- .../AddNewSeries/AddNewSeriesView.js | 2 + .../RootDir/RootDirItemTemplate.html | 10 ++-- .../AddSeries/RootDir/RootDirModel.js | 2 +- .../AddSeries/RootDir/RootDirTemplate.html | 5 +- .../AddSeries/RootDir/RootDirView.js | 53 +++++++++++++++---- .../_backboneApp/AddSeries/addSeries.css | 7 +++ NzbDrone.Web/_backboneApp/app.js | 4 +- 8 files changed, 65 insertions(+), 24 deletions(-) diff --git a/NzbDrone.Api/QualityProfiles/RootFolderModule.cs b/NzbDrone.Api/QualityProfiles/RootFolderModule.cs index ba23eb90a..d6b2bb088 100644 --- a/NzbDrone.Api/QualityProfiles/RootFolderModule.cs +++ b/NzbDrone.Api/QualityProfiles/RootFolderModule.cs @@ -5,12 +5,12 @@ using NzbDrone.Core.Repository; namespace NzbDrone.Api.QualityProfiles { - public class RootFolderModule : NzbDroneApiModule + public class RootDirModule : NzbDroneApiModule { private readonly RootDirProvider _rootDirProvider; - public RootFolderModule(RootDirProvider rootDirProvider) - : base("//rootfolders") + public RootDirModule(RootDirProvider rootDirProvider) + : base("//rootdir") { _rootDirProvider = rootDirProvider; diff --git a/NzbDrone.Web/_backboneApp/AddSeries/AddNewSeries/AddNewSeriesView.js b/NzbDrone.Web/_backboneApp/AddSeries/AddNewSeries/AddNewSeriesView.js index 0d75c560f..7537329b3 100644 --- a/NzbDrone.Web/_backboneApp/AddSeries/AddNewSeries/AddNewSeriesView.js +++ b/NzbDrone.Web/_backboneApp/AddSeries/AddNewSeries/AddNewSeriesView.js @@ -26,6 +26,7 @@ NzbDrone.AddSeries.SearchResultView = Backbone.Marionette.CollectionView.extend( NzbDrone.AddSeries.AddNewSeriesView = Backbone.Marionette.Layout.extend({ template: "AddSeries/AddNewSeries/AddNewSeriesTemplate", + route : "Series/add/new", ui: { seriesSearch: '.search input' @@ -39,6 +40,7 @@ NzbDrone.AddSeries.AddNewSeriesView = Backbone.Marionette.Layout.extend({ onRender: function () { + //NzbDrone.Router.navigate(this.route, { trigger: true }); console.log('binding auto complete'); var self = this; diff --git a/NzbDrone.Web/_backboneApp/AddSeries/RootDir/RootDirItemTemplate.html b/NzbDrone.Web/_backboneApp/AddSeries/RootDir/RootDirItemTemplate.html index 5b6cb73e8..4eeaf664a 100644 --- a/NzbDrone.Web/_backboneApp/AddSeries/RootDir/RootDirItemTemplate.html +++ b/NzbDrone.Web/_backboneApp/AddSeries/RootDir/RootDirItemTemplate.html @@ -1,4 +1,6 @@ -
-
-
-
+ + + +
+
+ diff --git a/NzbDrone.Web/_backboneApp/AddSeries/RootDir/RootDirModel.js b/NzbDrone.Web/_backboneApp/AddSeries/RootDir/RootDirModel.js index 326aff18c..68316ceae 100644 --- a/NzbDrone.Web/_backboneApp/AddSeries/RootDir/RootDirModel.js +++ b/NzbDrone.Web/_backboneApp/AddSeries/RootDir/RootDirModel.js @@ -1,4 +1,4 @@ /// NzbDrone.AddSeries.RootDirModel = Backbone.Model.extend({ - + url: NzbDrone.Constants.ApiRoot + 'rootdir/', }); diff --git a/NzbDrone.Web/_backboneApp/AddSeries/RootDir/RootDirTemplate.html b/NzbDrone.Web/_backboneApp/AddSeries/RootDir/RootDirTemplate.html index 4068d94f6..ae2092199 100644 --- a/NzbDrone.Web/_backboneApp/AddSeries/RootDir/RootDirTemplate.html +++ b/NzbDrone.Web/_backboneApp/AddSeries/RootDir/RootDirTemplate.html @@ -2,8 +2,7 @@
-
-
-
+
+
diff --git a/NzbDrone.Web/_backboneApp/AddSeries/RootDir/RootDirView.js b/NzbDrone.Web/_backboneApp/AddSeries/RootDir/RootDirView.js index c0dee1c01..64725897a 100644 --- a/NzbDrone.Web/_backboneApp/AddSeries/RootDir/RootDirView.js +++ b/NzbDrone.Web/_backboneApp/AddSeries/RootDir/RootDirView.js @@ -5,21 +5,32 @@ NzbDrone.AddSeries.RootDirItemView = Backbone.Marionette.ItemView.extend({ template: "AddSeries/RootDir/RootDirItemTemplate", - className: 'row', + tagName: 'tr', + + events: { + 'click #remove-dir': 'removeDir', + }, onRender: function () { NzbDrone.ModelBinder.bind(this.model, this.el); - } + }, + + removeDir: function () { + this.model.destroy({ wait: true }); + }, }); NzbDrone.AddSeries.RootDirListView = Backbone.Marionette.CollectionView.extend({ - className: 'result', itemView: NzbDrone.AddSeries.RootDirItemView, + + tagName: 'table', + className: 'table table-hover', }); NzbDrone.AddSeries.RootDirView = Backbone.Marionette.Layout.extend({ template: "AddSeries/RootDir/RootDirTemplate", + route: "series/add/rootdir", ui: { pathInput: '.path input' @@ -29,21 +40,41 @@ NzbDrone.AddSeries.RootDirView = Backbone.Marionette.Layout.extend({ currentDirs: "#current-dirs", }, + events: { + 'click #add-dir': 'addDir', + }, + + collection: new NzbDrone.AddSeries.RootDirCollection(), onRender: function () { var self = this; -/* - this.ui.seriesSearch - .data('timeout', null) - .keyup(function () { - clearTimeout(self.$el.data('timeout')); - self.$el.data('timeout', setTimeout(self.search, 500, self)); - }); -*/ + //NzbDrone.Router.navigate(this.route, { trigger: true }); + + /* + this.ui.seriesSearch + .data('timeout', null) + .keyup(function () { + clearTimeout(self.$el.data('timeout')); + self.$el.data('timeout', setTimeout(self.search, 500, self)); + }); + */ this.currentDirs.show(new NzbDrone.AddSeries.RootDirListView({ collection: this.collection })); + + this.collection.fetch(); + }, + + + addDir: function () { + var newDir = new NzbDrone.AddSeries.RootDirModel( + { + Path: this.ui.pathInput.val() + }); + + this.collection.create(newDir, { wait: true }); + this.fetch(); }, search: function (context) { diff --git a/NzbDrone.Web/_backboneApp/AddSeries/addSeries.css b/NzbDrone.Web/_backboneApp/AddSeries/addSeries.css index a8825a855..827dde132 100644 --- a/NzbDrone.Web/_backboneApp/AddSeries/addSeries.css +++ b/NzbDrone.Web/_backboneApp/AddSeries/addSeries.css @@ -1,5 +1,6 @@ .nz-input-large { margin-top: 20px; + margin-bottom: 40px; } .nz-input-large input { @@ -14,5 +15,11 @@ padding-left: 10px; } +.result-list { + font-size: 18px; + text-align: left; + +} + diff --git a/NzbDrone.Web/_backboneApp/app.js b/NzbDrone.Web/_backboneApp/app.js index 24de3d2c4..fd2090c94 100644 --- a/NzbDrone.Web/_backboneApp/app.js +++ b/NzbDrone.Web/_backboneApp/app.js @@ -47,7 +47,7 @@ NzbDrone.Controller = Backbone.Marionette.Controller.extend({ }); -NzbDrone.MyRouter = Backbone.Marionette.AppRouter.extend({ +NzbDrone.Router = Backbone.Marionette.AppRouter.extend({ controller: new NzbDrone.Controller(), // "someMethod" must exist at controller.someMethod @@ -68,7 +68,7 @@ NzbDrone.addInitializer(function (options) { mainRegion: "#main-region", }); - NzbDrone.Router = new NzbDrone.MyRouter(); + NzbDrone.Router = new NzbDrone.Router(); Backbone.history.start();