Save and add, notif settings cleanup

pull/4/head
Mark McDowall 12 years ago
parent 7f59062215
commit f7c340d795

@ -8,13 +8,13 @@ namespace NzbDrone.Core.Notifications.Growl
{
public class GrowlSettings : INotifcationSettings
{
[FieldDefinition(0, Label = "Host", HelpText = "Growl Host (IP or Hostname)")]
[FieldDefinition(0, Label = "Host")]
public String Host { get; set; }
[FieldDefinition(1, Label = "Port", HelpText = "Growl Port")]
[FieldDefinition(1, Label = "Port")]
public Int32 Port { get; set; }
[FieldDefinition(2, Label = "Password", HelpText = "Password for Growl")]
[FieldDefinition(2, Label = "Password")]
public String Password { get; set; }
public bool IsValid

@ -8,16 +8,16 @@ namespace NzbDrone.Core.Notifications.Plex
{
public class PlexClientSettings : INotifcationSettings
{
[FieldDefinition(0, Label = "Host", HelpText = "Plex Client Host (IP or Hostname)")]
[FieldDefinition(0, Label = "Host")]
public String Host { get; set; }
[FieldDefinition(1, Label = "Port", HelpText = "Plex Client Port")]
[FieldDefinition(1, Label = "Port")]
public Int32 Port { get; set; }
[FieldDefinition(2, Label = "Username", HelpText = "Username for Plex")]
[FieldDefinition(2, Label = "Username")]
public String Username { get; set; }
[FieldDefinition(3, Label = "Password", HelpText = "Password for Plex")]
[FieldDefinition(3, Label = "Password")]
public String Password { get; set; }
public bool IsValid

@ -8,13 +8,13 @@ namespace NzbDrone.Core.Notifications.Plex
{
public class PlexServerSettings : INotifcationSettings
{
[FieldDefinition(0, Label = "Host", HelpText = "Plex Server Host (IP or Hostname)")]
[FieldDefinition(0, Label = "Host")]
public String Host { get; set; }
[FieldDefinition(1, Label = "Port")]
public Int32 Port { get; set; }
[FieldDefinition(2, Label = "Update Library")]
[FieldDefinition(2, Label = "Update Library", Type = FieldType.Checkbox)]
public Boolean UpdateLibrary { get; set; }
public bool IsValid

@ -8,10 +8,10 @@ namespace NzbDrone.Core.Notifications.Prowl
{
public class ProwlSettings : INotifcationSettings
{
[FieldDefinition(0, Label = "API Key", HelpText = "API Key for Prowl")]
[FieldDefinition(0, Label = "API Key")]
public String ApiKey { get; set; }
[FieldDefinition(1, Label = "Priority", HelpText = "Priority to send messages at", Type = FieldType.Select, SelectOptions= typeof(ProwlPriority) )]
[FieldDefinition(1, Label = "Priority", Type = FieldType.Select, SelectOptions= typeof(ProwlPriority) )]
public Int32 Priority { get; set; }
public bool IsValid

@ -11,7 +11,7 @@ define(
tagName : 'tr',
events: {
'click .x-remove': 'removeFolder',
'click .x-delete': 'removeFolder',
'click .x-folder': 'folderSelected'
},

@ -40,5 +40,16 @@
<button class="btn btn-danger pull-left x-remove">delete</button>
{{/if}}
<button class="btn" data-dismiss="modal">cancel</button>
<button class="btn btn-primary x-save">save</button>
<div class="btn-group">
<button class="btn btn-primary x-save">save</button>
<button class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li class="save-and-add x-save-and-add">
save and add
</li>
</ul>
</div>
</div>

@ -2,23 +2,54 @@
define(
[
'app',
'marionette',
'Mixins/AsModelBoundView'
], function (Marionette, AsModelBoundView) {
], function (App, Marionette, AsModelBoundView) {
var view = Marionette.ItemView.extend({
template: 'Settings/Indexers/EditTemplate',
events: {
'click .x-save': 'save'
'click .x-save': '_save',
'click .x-save-and-add': '_saveAndAdd'
},
initialize: function (options) {
this.indexerCollection = options.indexerCollection;
},
save: function () {
this.model.saveSettings();
_save: function () {
var self = this;
var promise = this.model.saveSettings();
if (promise) {
promise.done(function () {
self.indexerCollection.add(self.model, { merge: true });
App.modalRegion.closeModal();
});
}
},
_saveAndAdd: function () {
var self = this;
var promise = this.model.saveSettings();
if (promise) {
promise.done(function () {
self.indexerCollection.add(self.model, { merge: true });
self.model.set({
id: undefined,
name: '',
enable: false
});
_.each(self.model.get('fields'), function (value, key, list) {
self.model.set('fields.' + key +'.value', '');
});
});
}
}
});

@ -2,10 +2,9 @@
define([
'app',
'marionette',
'Settings/Notifications/Collection',
'Settings/Notifications/ItemView',
'Settings/Notifications/AddView'
], function (App, Marionette, NotificationCollection, NotificationItemView, AddSelectionNotificationView) {
'Settings/Notifications/SchemaModal'
], function (App, Marionette, NotificationItemView, SchemaModal) {
return Marionette.CompositeView.extend({
itemView : NotificationItemView,
itemViewContainer: '.notifications',
@ -16,13 +15,7 @@ define([
},
_openSchemaModal: function () {
var schemaCollection = new NotificationCollection();
schemaCollection.url = '/api/notification/schema';
schemaCollection.fetch();
schemaCollection.url = '/api/notification';
var view = new AddSelectionNotificationView({ collection: schemaCollection, notificationCollection: this.collection});
App.modalRegion.show(view);
SchemaModal.open(this.collection);
}
});
});

@ -61,10 +61,23 @@
</div>
<div class="modal-footer">
{{#if id}}
<button class="btn btn-danger pull-left x-remove">delete</button>
<button class="btn btn-danger pull-left x-delete">delete</button>
{{else}}
<button class="btn pull-left x-back">back</button>
{{/if}}
<button class="btn x-test">test <i class="x-test-icon"/></button>
<button class="btn x-test">test <i class="x-test-icon"/></button>
<button class="btn" data-dismiss="modal">cancel</button>
<button class="btn btn-primary x-save">save</button>
<div class="btn-group">
<button class="btn btn-primary x-save">save</button>
<button class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li class="save-and-add x-save-and-add">
save and add
</li>
</ul>
</div>
</div>

@ -15,9 +15,11 @@ define([
template: 'Settings/Notifications/EditTemplate',
events: {
'click .x-save' : '_saveNotification',
'click .x-remove': '_deleteNotification',
'click .x-test' : '_test'
'click .x-save' : '_saveNotification',
'click .x-save-and-add' : '_saveAndAddNotification',
'click .x-delete' : '_deleteNotification',
'click .x-back' : '_back',
'click .x-test' : '_test'
},
ui: {
@ -41,14 +43,26 @@ define([
}
},
_saveAndAddNotification: function () {
var self = this;
var promise = this.model.saveSettings();
if (promise) {
promise.done(function () {
self.notificationCollection.add(self.model, { merge: true });
require('Settings/Notifications/SchemaModal').open(self.notificationCollection);
});
}
},
_deleteNotification: function () {
var view = new DeleteView({ model: this.model });
App.modalRegion.show(view);
},
_saveSuccess: function () {
this.notificationCollection.add(this.model, { merge: true });
App.modalRegion.closeModal();
_back: function () {
require('Settings/Notifications/SchemaModal').open(this.notificationCollection);
},
_test: function () {

@ -7,7 +7,7 @@
</span>
</div>
<div>
<div class="settings">
{{#if onGrab}}
<span class="label label-success">On Grab</span>
{{else}}

@ -0,0 +1,19 @@
'use strict';
define([
'app',
'Settings/Notifications/Collection',
'Settings/Notifications/AddView'
], function (App, NotificationCollection, AddSelectionNotificationView) {
return ({
open: function (collection) {
var schemaCollection = new NotificationCollection();
schemaCollection.url = '/api/notification/schema';
schemaCollection.fetch();
schemaCollection.url = '/api/notification';
var view = new AddSelectionNotificationView({ collection: schemaCollection, notificationCollection: collection});
App.modalRegion.show(view);
}
});
});

@ -23,24 +23,27 @@
}
.notifications {
width: -webkit-fit-content;
width: -moz-fit-content;
width: fit-content;
li {
display: inline-block;
vertical-align: top;
}
}
.notification-item {
.card;
width: 250px;
height: 80px;
padding: 10px 15px;
width: 290px;
height: 90px;
padding: 20px 20px;
h3 {
margin-top: 0px;
display: inline-block;
width: 200px;
width: 230px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
@ -49,4 +52,8 @@
.btn-group {
margin-top: 8px;
}
.settings {
margin-top: 5px;
}
}

@ -52,7 +52,7 @@
</div>
<div class="modal-footer">
{{#if id}}
<button class="btn btn-danger pull-left x-remove">delete</button>
<button class="btn btn-danger pull-left x-delete">delete</button>
{{/if}}
<button class="btn" data-dismiss="modal">cancel</button>
<button class="btn btn-primary x-save">save</button>

@ -1,3 +1,23 @@
@import "../Shared/Styles/clickable.less";
@import "Indexers/indexers";
@import "Quality/quality";
@import "Notifications/notifications";
li.save-and-add {
.clickable;
display: block;
padding: 3px 20px;
clear: both;
font-weight: normal;
line-height: 20px;
color: rgb(51, 51, 51);
white-space: nowrap;
}
li.save-and-add:hover {
text-decoration: none;
color: rgb(255, 255, 255);
background-color: rgb(0, 129, 194);
}
Loading…
Cancel
Save