last used quality profile is now used as default

This commit is contained in:
kay.one 2013-05-27 22:40:58 -07:00
parent 465dc725c8
commit e4e6bcae1d
16 changed files with 70 additions and 66 deletions

View File

@ -30,7 +30,6 @@ namespace NzbDrone.Api.Series
Get["/{slug}"] = o => GetSeries((string)o.slug.ToString());
SharedValidator.RuleFor(s => s.QualityProfileId).ValidId();
SharedValidator.RuleFor(s => s.Path).NotEmpty().When(s => String.IsNullOrEmpty(s.RootFolderPath));
SharedValidator.RuleFor(s => s.RootFolderPath).NotEmpty().When(s => String.IsNullOrEmpty(s.Path));

View File

@ -136,13 +136,6 @@ namespace NzbDrone.Core.Configuration
set { SetValue("Sorting_SeasonFolderFormat", value); }
}
public int DefaultQualityProfile
{
get { return GetValueInt("DefaultQualityProfile", 1); }
set { SetValue("DefaultQualityProfile", value); }
}
public string UpdateUrl
{
get { return GetValue("UpdateUrl", "http://update.nzbdrone.com/vnext/"); }

View File

@ -22,7 +22,6 @@ namespace NzbDrone.Core.Configuration
String DownloadedEpisodesFolder { get; set; }
bool UseSeasonFolder { get; set; }
string SortingSeasonFolderFormat { get; set; }
int DefaultQualityProfile { get; set; }
bool EnableBacklogSearching { get; set; }
bool AutoIgnorePreviouslyDownloadedEpisodes { get; set; }
int Retention { get; set; }

View File

@ -108,17 +108,12 @@ namespace NzbDrone.Core.Tv
_diskProvider.CreateFolder(newSeries.Path);
}
_logger.Info("Adding Series [{0}] Path: [{1}]", newSeries.Title, newSeries.Path);
newSeries.Monitored = true;
newSeries.CleanTitle = Parser.Parser.NormalizeTitle(newSeries.Title);
if (newSeries.QualityProfileId == 0)
{
newSeries.QualityProfileId = _configService.DefaultQualityProfile;
}
newSeries.SeasonFolder = _configService.UseSeasonFolder;
newSeries.BacklogSetting = BacklogSettingType.Inherit;

View File

@ -1,13 +1,13 @@
"use strict";
define([
'app',
'AddSeries/RootFolders/RootFolderCollection',
'Quality/QualityProfileCollection',
'AddSeries/RootFolders/RootFolderCollection',
'AddSeries/RootFolders/RootFolderView',
'AddSeries/AddSeriesView',
'AddSeries/Existing/ImportSeriesView'
],
function (app, rootFolderCollection, qualityProfileCollection) {
function (app, qualityProfileCollection, rootFolderCollection) {
NzbDrone.AddSeries.AddSeriesLayout = Backbone.Marionette.Layout.extend({
template: 'AddSeries/addSeriesLayoutTemplate',

View File

@ -1,7 +1,6 @@
'use strict';
define([
'app', 'AddSeries/RootFolders/RootFolderCollection',
'Quality/QualityProfileCollection',
'AddSeries/Existing/UnmappedFolderModel',
'AddSeries/Collection',
'AddSeries/SearchResultView',
@ -22,7 +21,6 @@ define([
ui: {
searchButton: '.x-btn-search',
searchText : '.x-txt-search',
profileList : '.x-lst-quality-profile',
searchBar : '.x-search-bar',
loadMore : '.x-load-more'
},
@ -99,7 +97,6 @@ define([
itemViewOptions: function () {
return {
qualityProfile: this.ui.profileList,
rootFolder : this.model.get('rootFolder'),
folder : this.model.get('folder').path,
isExisting : true

View File

@ -1,13 +1,8 @@
'use strict';
define(['app', 'Quality/QualityProfileCollection'], function (app, qualityProfiles) {
define(['app'], function () {
NzbDrone.AddSeries.Existing.UnmappedFolderModel = Backbone.Model.extend({
defaults: {
quality: qualityProfiles
}
});
NzbDrone.AddSeries.Existing.UnmappedFolderCollection = Backbone.Collection.extend({

View File

@ -1,5 +1,4 @@
<select class="span6 x-root-folder">
{{debug}}
{{#each this}}
<option value="{{id}}">{{path}}</option>
{{/each}}

View File

@ -19,13 +19,11 @@
<icon class="icon-plus"></icon>
</div>
{{#unless isExisting}}
{{rootFolderSelection}}
{{rootFolderSelection}}
{{/unless}}
<select class="span2 x-quality-profile pull-right">
{{#each qualityProfiles.models}}
<option value="{{id}}">{{attributes.name}}</option>
{{/each}}
</select>
<div class='pull-right'>
{{qualityProfileSelection}}
</div>
</div>
</div>
</div>

View File

@ -1,5 +1,10 @@
'use strict';
define(['app', 'Series/SeriesCollection', 'AddSeries/RootFolders/RootFolderTemplateHelper'], function () {
define(['app',
'Quality/QualityProfileCollection',
'Config',
'Series/SeriesCollection',
'AddSeries/RootFolders/RootFolderTemplateHelper',
'Quality/QualityProfileTemplateHelper'], function (app, qualityProfiles) {
NzbDrone.AddSeries.SearchResultView = Backbone.Marionette.ItemView.extend({
@ -13,7 +18,8 @@ define(['app', 'Series/SeriesCollection', 'AddSeries/RootFolders/RootFolderTempl
},
events: {
'click .x-add': 'addSeries'
'click .x-add' : 'addSeries',
'change .x-quality-profile': '_qualityProfileChanged'
},
initialize: function () {
@ -24,12 +30,33 @@ define(['app', 'Series/SeriesCollection', 'AddSeries/RootFolders/RootFolderTempl
this.model.set('isExisting', this.options.isExisting);
this.model.set('path', this.options.folder);
NzbDrone.vent.on(NzbDrone.Config.Events.ConfigUpdatedEvent, this._onConfigUpdated, this);
},
_onConfigUpdated: function (options) {
if (options.key === NzbDrone.Config.Keys.DefaultQualityProfileId) {
this.$('.x-quality-profile').val(options.value);
}
},
_qualityProfileChanged: function () {
NzbDrone.Config.SetValue(NzbDrone.Config.Keys.DefaultQualityProfileId, this.ui.qualityProfile.val());
},
onRender: function () {
this.listenTo(this.model, 'change', this.render);
var defaultQuality = NzbDrone.Config.GetValue(NzbDrone.Config.Keys.DefaultQualityProfileId);
if (qualityProfiles.get(defaultQuality)) {
this.ui.qualityProfile.val(defaultQuality);
}
},
addSeries: function () {
var icon = this.ui.addButton.find('icon');
icon.removeClass('icon-plus').addClass('icon-spin icon-spinner disabled');

View File

@ -1,6 +1,15 @@
"use strict";
define(['app'], function () {
NzbDrone.Config = {
Events: {
ConfigUpdatedEvent: 'ConfigUpdatedEvent'
},
Keys : {
DefaultQualityProfileId: 'DefaultQualityProfileId'
}
};
NzbDrone.Config.GetValue = function (key, defaultValue) {
var storeValue = localStorage.getItem(key);
@ -9,12 +18,20 @@ define(['app'], function () {
return defaultValue;
}
return storeValue;
return storeValue.toString();
};
NzbDrone.Config.SetValue = function (key, value) {
console.log('Config: [{0}] => [{1}] '.format(key, value));
if (NzbDrone.Config.GetValue(key) === value.toString()) {
return;
}
localStorage.setItem(key, value);
NzbDrone.vent.trigger(NzbDrone.Config.Events.ConfigUpdatedEvent, {key: key, value: value});
};
});

View File

@ -0,0 +1,5 @@
<select class="span2 x-quality-profile">
{{#each this}}
<option value="{{id}}">{{name}}</option>
{{/each}}
</select>

View File

@ -0,0 +1,10 @@
'use strict';
define(['app', 'Quality/QualityProfileCollection'], function (app, qualityProfiles) {
Handlebars.registerHelper('qualityProfileSelection', function () {
var templateFunction = Marionette.TemplateCache.get('Quality/QualityProfileSelectionTemplate');
return new Handlebars.SafeString(templateFunction(qualityProfiles.toJSON()));
});
});

View File

@ -3,7 +3,6 @@ define([
'app',
'Quality/QualityProfileCollection',
'Quality/QualitySizeCollection',
'Settings/Quality/QualityView',
'Settings/Quality/Profile/QualityProfileCollectionView',
'Settings/Quality/Size/QualitySizeCollectionView'
],
@ -33,7 +32,6 @@ define([
},
onRender: function () {
this.qualityStandard.show(new NzbDrone.Settings.Quality.QualityView({model: this.settings, qualityProfiles: qualityProfileCollection}));
this.qualityProfile.show(new NzbDrone.Settings.Quality.Profile.QualityProfileCollectionView({collection: qualityProfileCollection}));
this.qualitySize.show(new NzbDrone.Settings.Quality.Size.QualitySizeCollectionView({collection: this.qualitySizeCollection}));
}

View File

@ -1,14 +0,0 @@
<div class="control-group">
<label class="control-label">Default Quality Profile</label>
<div class="controls">
<select class="x-quality-profile" name="qualityProfileId">
{{#each qualityProfiles.models}}
<option value="{{id}}">{{attributes.name}}</option>
{{/each}}
</select>
<span class="help-inline">
<i class="icon-question-sign" title="The default quality to use when adding series to NzbDrone "></i>
</span>
</div>
</div>

View File

@ -1,14 +0,0 @@
'use strict';
define([
'app', 'Settings/SettingsModel'
], function () {
NzbDrone.Settings.Quality.QualityView = Backbone.Marionette.ItemView.extend({
template : 'Settings/Quality/QualityTemplate',
className: 'form-horizontal',
initialize: function (options) {
this.qualityProfileCollection = options.qualityProfiles;
this.model.set({ qualityProfiles: this.qualityProfileCollection });
}
});
});