added ui structure for rootdirs.

This commit is contained in:
Keivan Beigi 2013-01-24 12:48:44 -08:00 committed by kay.one
parent ae61150b84
commit 157b559ed2
12 changed files with 133 additions and 8 deletions

View File

@ -89,6 +89,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="QualityProfiles\RootFolderModule.cs" />
<Compile Include="Series\SeriesModule.cs" />
<Compile Include="ErrorManagment\ApiException.cs" />
<Compile Include="Bootstrapper.cs" />

View File

@ -0,0 +1,32 @@
using Nancy;
using NzbDrone.Core.Providers;
using NzbDrone.Api.QualityType;
using NzbDrone.Core.Repository;
namespace NzbDrone.Api.QualityProfiles
{
public class RootFolderModule : NzbDroneApiModule
{
private readonly RootDirProvider _rootDirProvider;
public RootFolderModule(RootDirProvider rootDirProvider)
: base("//rootfolders")
{
_rootDirProvider = rootDirProvider;
Get["/"] = x => GetRootFolders();
Post["/"] = x => AddRootFolder();
}
private Response AddRootFolder()
{
_rootDirProvider.Add(Request.Body.FromJson<RootDir>());
return new Response { StatusCode = HttpStatusCode.Created };
}
private Response GetRootFolders()
{
return _rootDirProvider.AllWithFreeSpace().AsResponse();
}
}
}

View File

@ -182,6 +182,11 @@
<ItemGroup>
<Compile Include="App_Start\DataTablesMvc.cs" />
<Compile Include="App_Start\MiniProfiler.cs" />
<Content Include="_backboneApp\AddSeries\RootDir\RootDirTemplate.html" />
<Content Include="_backboneApp\AddSeries\RootDir\RootDirView.js" />
<Content Include="_backboneApp\AddSeries\RootDir\RootDirItemTemplate.html" />
<Content Include="_backboneApp\AddSeries\RootDir\RootDirModel.js" />
<Content Include="_backboneApp\AddSeries\RootDir\RootDirCollection.js" />
<Content Include="_backboneApp\JsLibraries\backbone.modelbinder.js" />
<Content Include="_backboneApp\AddSeries\AddNewSeries\AddNewSeriesTemplate.html" />
<Content Include="_backboneApp\AddSeries\AddNewSeries\AddNewSeriesView.js" />

View File

@ -1,5 +1,5 @@
<div class="tab-pane" id="add-new">
<div class="input-prepend search">
<div class="input-prepend nz-input-large search">
<i class="add-on icon-search"></i>
<input type="text" class="span10" placeholder="Start typing the name of series you want to add ...">
</div>

View File

@ -6,9 +6,6 @@ NzbDrone.AddSeries.SearchItemView = Backbone.Marionette.ItemView.extend({
template: "AddSeries/AddNewSeries/SearchResultTemplate",
className: 'row',
initialize: function () {
this.listenTo(this.model, 'reset', function () { alert('model'); });
},
onRender: function () {
NzbDrone.ModelBinder.bind(this.model, this.el);

View File

@ -1,5 +1,6 @@
/// <reference path="../app.js" />
/// <reference path="AddNewSeries/AddNewSeriesView.js" />
/// <reference path="RootDir/RootDirView.js" />
NzbDrone.AddSeries.AddSeriesLayout = Backbone.Marionette.Layout.extend({
template: "AddSeries/addSeriesLayoutTemplate",
@ -18,7 +19,7 @@ NzbDrone.AddSeries.AddSeriesLayout = Backbone.Marionette.Layout.extend({
this.addNew.show(new NzbDrone.AddSeries.AddNewSeriesView());
//this.importExisting.show(new NzbDrone.ImportExistingView());
//this.rootFolders.show(new NzbDrone.RootFoldersView());
this.rootFolders.show(new NzbDrone.AddSeries.RootDirView());
},
});

View File

@ -0,0 +1,7 @@
/// <reference path="../../app.js" />
NzbDrone.AddSeries.RootDirCollection = Backbone.Collection.extend({
url: NzbDrone.Constants.ApiRoot + 'rootdir/',
model: NzbDrone.AddSeries.RootDirModel,
});

View File

@ -0,0 +1,4 @@
<div>
<div name="Path"/>
<div name="FreeSpace"/>
</div>

View File

@ -0,0 +1,4 @@
/// <reference path="../../app.js" />
NzbDrone.AddSeries.RootDirModel = Backbone.Model.extend({
});

View File

@ -0,0 +1,9 @@
<div class="tab-pane" id="root-dir">
<div class="input-prepend input-append nz-input-large path">
<i class="add-on icon-folder-open"></i>
<input type="text" class="span10" placeholder="Path of the root folder you would like to add">
<div class="btn icon-plus btn-success"/>
</div>
<div id="current-dirs">
</div>
</div>

View File

@ -0,0 +1,62 @@
/// <reference path="../../app.js" />
/// <reference path="RootDirModel.js" />
/// <reference path="RootDirCollection.js" />
NzbDrone.AddSeries.RootDirItemView = Backbone.Marionette.ItemView.extend({
template: "AddSeries/RootDir/RootDirItemTemplate",
className: 'row',
onRender: function () {
NzbDrone.ModelBinder.bind(this.model, this.el);
}
});
NzbDrone.AddSeries.RootDirListView = Backbone.Marionette.CollectionView.extend({
className: 'result',
itemView: NzbDrone.AddSeries.RootDirItemView,
});
NzbDrone.AddSeries.RootDirView = Backbone.Marionette.Layout.extend({
template: "AddSeries/RootDir/RootDirTemplate",
ui: {
pathInput: '.path input'
},
regions: {
currentDirs: "#current-dirs",
},
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));
});
*/
this.currentDirs.show(new NzbDrone.AddSeries.RootDirListView({ collection: this.collection }));
},
search: function (context) {
var term = context.ui.seriesSearch.val();
if (term == "") {
context.collection.reset();
} else {
console.log(term);
context.collection.fetch({ data: $.param({ term: term }) });
}
},
});

View File

@ -1,15 +1,18 @@
.search {
.nz-input-large {
margin-top: 20px;
}
.search input {
.nz-input-large input {
height: 40px;
}
.search .add-on {
.nz-input-large *[class*='icon-'] {
font-size: 30px;
height: 30px;
width: 40px;
padding-top: 14px;
padding-left: 10px;
}