1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-10-30 07:22:35 +01:00

Existing series view loads again

This commit is contained in:
Mark McDowall 2013-05-12 21:24:04 -07:00
parent 687f8d9384
commit 525963f2a6
6 changed files with 45 additions and 21 deletions

View File

@ -23,7 +23,7 @@ namespace NzbDrone.Api.RootFolders
private List<RootFolderResource> GetRootFolders()
{
return ApplyToList(_rootFolderService.All);
return ApplyToList(_rootFolderService.AllWithUnmappedFolders);
}
private void DeleteFolder(int id)

View File

@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using NzbDrone.Api.REST;
using NzbDrone.Core.RootFolders;
namespace NzbDrone.Api.RootFolders
{
@ -7,5 +9,7 @@ namespace NzbDrone.Api.RootFolders
{
public String Path { get; set; }
public Int64 FreeSpace { get; set; }
public List<UnmappedFolder> UnmappedFolders { get; set; }
}
}

View File

@ -12,6 +12,7 @@ namespace NzbDrone.Core.RootFolders
public interface IRootFolderService
{
List<RootFolder> All();
List<RootFolder> AllWithUnmappedFolders();
RootFolder Add(RootFolder rootDir);
void Remove(int id);
List<UnmappedFolder> GetUnmappedFolders(string path);
@ -37,14 +38,21 @@ namespace NzbDrone.Core.RootFolders
{
var rootFolders = _rootFolderRepository.All().ToList();
return rootFolders;
}
public virtual List<RootFolder> AllWithUnmappedFolders()
{
var rootFolders = _rootFolderRepository.All().ToList();
rootFolders.ForEach(folder =>
{
if (_diskProvider.FolderExists(folder.Path))
{
if (_diskProvider.FolderExists(folder.Path))
{
folder.FreeSpace = _diskProvider.GetAvilableSpace(folder.Path);
folder.UnmappedFolders = GetUnmappedFolders(folder.Path);
}
});
folder.FreeSpace = _diskProvider.GetAvilableSpace(folder.Path);
folder.UnmappedFolders = GetUnmappedFolders(folder.Path);
}
});
return rootFolders;
}

View File

@ -0,0 +1,15 @@
"use strict";
define(['app', 'Series/SeriesModel'], function () {
NzbDrone.AddSeries.Collection = Backbone.Collection.extend({
url : NzbDrone.Constants.ApiRoot + '/series/lookup',
model: NzbDrone.Series.SeriesModel,
parse: function (response) {
_.each(response, function (model) {
model.id = undefined;
});
return response;
}
});
});

View File

@ -1,6 +1,11 @@
'use strict';
define([
'app', 'AddSeries/RootFolders/RootFolderCollection', 'Quality/QualityProfileCollection', 'Shared/NotificationCollection', 'AddSeries/Existing/UnmappedFolderModel', 'Series/SeriesModel'], function (app, rootFolders, qualityProfileCollection, notificationCollection) {
'app', 'AddSeries/RootFolders/RootFolderCollection',
'Quality/QualityProfileCollection',
'Shared/NotificationCollection',
'AddSeries/Existing/UnmappedFolderModel',
'AddSeries/Collection',
'Series/SeriesModel'], function (app, rootFolders, qualityProfileCollection, notificationCollection) {
NzbDrone.AddSeries.Existing.FolderMatchResultView = Backbone.Marionette.ItemView.extend({
template: 'AddSeries/SearchResultTemplate',
@ -29,7 +34,7 @@ define([
this.model.set('rootFolderId', rootFolderId);
this.model.set('folder', folder);
var seriesCollection = new NzbDrone.Series.SeriesCollection();
var seriesCollection = new NzbDrone.AddSeries.Collection();
seriesCollection.add(this.model);
this.model.save(undefined, {
@ -68,7 +73,7 @@ define([
},
initialize: function () {
this.collection = new NzbDrone.Series.SeriesCollection();
this.collection = new NzbDrone.AddSeries.Collection();
this.collection.bind('reset', this.collectionReset, this);
this.on("itemview:seriesAdded", function(){
@ -77,7 +82,6 @@ define([
},
onRender: function () {
this.collection.url = NzbDrone.Constants.ApiRoot + '/series/lookup';
this.resultView = new NzbDrone.AddSeries.SearchResultView({ collection: this.collection });
},

View File

@ -1,5 +1,6 @@
"use strict";
define(['app', 'AddSeries/RootFolders/RootFolderCollection', 'AddSeries/New/SearchResultView', 'Shared/SpinnerView'], function () {
define(['app', 'AddSeries/RootFolders/RootFolderCollection', 'AddSeries/New/SearchResultView', 'Shared/SpinnerView',
'AddSeries/Collection'], function () {
NzbDrone.AddSeries.New.AddNewSeriesView = Backbone.Marionette.Layout.extend({
template: 'AddSeries/New/AddNewSeriesTemplate',
route : 'Series/add/new',
@ -14,16 +15,9 @@ define(['app', 'AddSeries/RootFolders/RootFolderCollection', 'AddSeries/New/Sear
initialize: function () {
this.collection = new NzbDrone.Series.SeriesCollection();
this.collection = new NzbDrone.AddSeries.Collection();
this.collection.parse = function (response) {
_.each(response, function (model) {
model.id = undefined;
});
return response;
};
NzbDrone.AddSeries.New.AddNewSeriesContext = this;
NzbDrone.vent.on(NzbDrone.Events.SeriesAdded, function (options) {
@ -46,7 +40,6 @@ define(['app', 'AddSeries/RootFolders/RootFolderCollection', 'AddSeries/New/Sear
self.$el.data('timeout', window.setTimeout(self.search, 500, self));
});
this.collection.url = NzbDrone.Constants.ApiRoot + '/series/lookup';
this.resultView = new NzbDrone.AddSeries.SearchResultView({ collection: this.collection });
},