New: Optionally disable notifications for upgraded episode files

This commit is contained in:
Mark McDowall 2014-02-10 17:09:31 -08:00
parent bc908e0440
commit 3d3390187e
10 changed files with 86 additions and 13 deletions

View File

@ -7,6 +7,7 @@ namespace NzbDrone.Api.Notifications
public String Link { get; set; }
public Boolean OnGrab { get; set; }
public Boolean OnDownload { get; set; }
public Boolean OnUpgrade { get; set; }
public String TestCommand { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Migration(38)]
public class add_on_upgrade_to_notifications : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Alter.Table("Notifications").AddColumn("OnUpgrade").AsBoolean().Nullable();
Execute.Sql("UPDATE Notifications SET OnUpgrade = OnDownload");
}
}
}

View File

@ -7,5 +7,6 @@ namespace NzbDrone.Core.Notifications
{
public Boolean OnGrab { get; set; }
public Boolean OnDownload { get; set; }
public Boolean OnUpgrade { get; set; }
}
}

View File

@ -10,6 +10,7 @@ namespace NzbDrone.Core.Notifications
{
List<INotification> OnGrabEnabled();
List<INotification> OnDownloadEnabled();
List<INotification> OnUpgradeEnabled();
}
public class NotificationFactory : ProviderFactory<INotification, NotificationDefinition>, INotificationFactory
@ -28,5 +29,10 @@ namespace NzbDrone.Core.Notifications
{
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnDownload).ToList();
}
public List<INotification> OnUpgradeEnabled()
{
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnUpgrade).ToList();
}
}
}

View File

@ -80,6 +80,11 @@ namespace NzbDrone.Core.Notifications
{
try
{
if (downloadMessage.OldFiles.Any() && !((NotificationDefinition) notification.Definition).OnUpgrade)
{
continue;
}
notification.OnDownload(downloadMessage);
}

View File

@ -194,6 +194,7 @@
<Compile Include="Datastore\Migration\035_add_series_folder_format_to_naming_config.cs" />
<Compile Include="Datastore\Migration\036_update_with_quality_converters.cs" />
<Compile Include="Datastore\Migration\037_add_configurable_qualities.cs" />
<Compile Include="Datastore\Migration\038_add_on_upgrade_to_notifications.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationContext.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationController.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationExtension.cs" />

View File

@ -24,10 +24,11 @@ define([
}
this.model.set({
id: undefined,
name: this.model.get('implementationName'),
onGrab: true,
onDownload: true
id : undefined,
name : this.model.get('implementationName'),
onGrab : true,
onDownload : true,
onUpgrade : true
});
var editView = new EditView({ model: this.model, notificationCollection: this.notificationCollection });

View File

@ -16,18 +16,28 @@ define(
var model = Marionette.ItemView.extend({
template: 'Settings/Notifications/NotificationEditViewTemplate',
ui: {
onDownloadToggle: '.x-on-download',
onUpgradeSection: '.x-on-upgrade'
},
events: {
'click .x-save' : '_saveNotification',
'click .x-save-and-add': '_saveAndAddNotification',
'click .x-delete' : '_deleteNotification',
'click .x-back' : '_back',
'click .x-test' : '_test'
'click .x-test' : '_test',
'change .x-on-download': '_onDownloadChanged'
},
initialize: function (options) {
this.notificationCollection = options.notificationCollection;
},
onRender: function () {
this._onDownloadChanged();
},
_saveNotification: function () {
var self = this;
var promise = this.model.saveSettings();
@ -71,6 +81,18 @@ define(
});
CommandController.Execute(testCommand, properties);
},
_onDownloadChanged: function () {
var checked = this.ui.onDownloadToggle.prop('checked');
if (checked) {
this.ui.onUpgradeSection.show();
}
else {
this.ui.onUpgradeSection.hide();
}
}
});

View File

@ -30,9 +30,9 @@
<div class="btn btn-primary slide-button"/>
</label>
<span class="help-inline-checkbox">
<i class="icon-nd-form-info" title="Do you want to get notifications when episodes are grabbed?"/>
</span>
<span class="help-inline-checkbox">
<i class="icon-nd-form-info" title="Do you want to get notifications when episodes are grabbed?"/>
</span>
</div>
</div>
@ -41,7 +41,7 @@
<div class="controls">
<label class="checkbox toggle well">
<input type="checkbox" name="onDownload"/>
<input type="checkbox" name="onDownload" class="x-on-download"/>
<p>
<span>Yes</span>
<span>No</span>
@ -50,9 +50,29 @@
<div class="btn btn-primary slide-button"/>
</label>
<span class="help-inline-checkbox">
<i class="icon-nd-form-info" title="Do you want to get notifications when episodes are downloaded?"/>
</span>
<span class="help-inline-checkbox">
<i class="icon-nd-form-info" title="Do you want to get notifications when episodes are downloaded?"/>
</span>
</div>
</div>
<div class="control-group x-on-upgrade">
<label class="control-label">On Upgrade</label>
<div class="controls">
<label class="checkbox toggle well">
<input type="checkbox" name="onUpgrade"/>
<p>
<span>Yes</span>
<span>No</span>
</p>
<div class="btn btn-primary slide-button"/>
</label>
<span class="help-inline-checkbox">
<i class="icon-nd-form-info" title="Do you want to get notifications when episodes are upgraded to a better quality?"/>
</span>
</div>
</div>

View File

@ -66,7 +66,7 @@ define(
'click .x-notifications-tab' : '_showNotifications',
'click .x-general-tab' : '_showGeneral',
'click .x-save-settings' : '_save',
'change .x-advanced-settings' : '_toggleAdvancedSettings'
'change .x-advanced-settings' : '_toggleAdvancedSettings'
},
initialize: function (options) {