1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-09 04:22:30 +01:00

UI Cleanup - Updated Settings subtree.

This commit is contained in:
Taloth Saldono 2015-02-14 00:37:11 +01:00
parent b69ea349ce
commit 019525dd9d
72 changed files with 1458 additions and 1039 deletions

View File

@ -3,7 +3,7 @@ var ThingyHeaderGroupView = require('../../ThingyHeaderGroupView');
var AddItemView = require('./DownloadClientAddItemView'); var AddItemView = require('./DownloadClientAddItemView');
module.exports = ThingyAddCollectionView.extend({ module.exports = ThingyAddCollectionView.extend({
itemView : ThingyHeaderGroupView.extend({itemView : AddItemView}), itemView : ThingyHeaderGroupView.extend({ itemView : AddItemView }),
itemViewContainer : '.add-download-client .items', itemViewContainer : '.add-download-client .items',
template : 'Settings/DownloadClient/Add/DownloadClientAddCollectionViewTemplate' template : 'Settings/DownloadClient/Add/DownloadClientAddCollectionViewTemplate'
}); });

View File

@ -5,42 +5,54 @@ var Marionette = require('marionette');
var EditView = require('../Edit/DownloadClientEditView'); var EditView = require('../Edit/DownloadClientEditView');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/Add/DownloadClientAddItemViewTemplate', template : 'Settings/DownloadClient/Add/DownloadClientAddItemViewTemplate',
tagName : 'li', tagName : 'li',
className : 'add-thingy-item', className : 'add-thingy-item',
events : {
"click .x-preset" : '_addPreset', events : {
"click" : '_add' 'click .x-preset' : '_addPreset',
'click' : '_add'
}, },
initialize : function(options){
initialize : function(options) {
this.targetCollection = options.targetCollection; this.targetCollection = options.targetCollection;
}, },
_addPreset : function(e){
_addPreset : function(e) {
var presetName = $(e.target).closest('.x-preset').attr('data-id'); var presetName = $(e.target).closest('.x-preset').attr('data-id');
var presetData = _.where(this.model.get('presets'), {name : presetName})[0];
var presetData = _.where(this.model.get('presets'), { name : presetName })[0];
this.model.set(presetData); this.model.set(presetData);
this.model.set({ this.model.set({
id : undefined, id : undefined,
enable : true enable : true
}); });
var editView = new EditView({ var editView = new EditView({
model : this.model, model : this.model,
targetCollection : this.targetCollection targetCollection : this.targetCollection
}); });
AppLayout.modalRegion.show(editView); AppLayout.modalRegion.show(editView);
}, },
_add : function(e){
if($(e.target).closest('.btn,.btn-group').length !== 0) { _add : function(e) {
if ($(e.target).closest('.btn,.btn-group').length !== 0) {
return; return;
} }
this.model.set({ this.model.set({
id : undefined, id : undefined,
enable : true enable : true
}); });
var editView = new EditView({ var editView = new EditView({
model : this.model, model : this.model,
targetCollection : this.targetCollection targetCollection : this.targetCollection
}); });
AppLayout.modalRegion.show(editView); AppLayout.modalRegion.show(editView);
} }
}); });

View File

@ -5,29 +5,35 @@ var SchemaCollection = require('../DownloadClientCollection');
var AddCollectionView = require('./DownloadClientAddCollectionView'); var AddCollectionView = require('./DownloadClientAddCollectionView');
module.exports = { module.exports = {
open : function(collection){ open : function(collection) {
var schemaCollection = new SchemaCollection(); var schemaCollection = new SchemaCollection();
var originalUrl = schemaCollection.url; var originalUrl = schemaCollection.url;
schemaCollection.url = schemaCollection.url + '/schema'; schemaCollection.url = schemaCollection.url + '/schema';
schemaCollection.fetch(); schemaCollection.fetch();
schemaCollection.url = originalUrl; schemaCollection.url = originalUrl;
var groupedSchemaCollection = new Backbone.Collection(); var groupedSchemaCollection = new Backbone.Collection();
schemaCollection.on('sync', function(){
var groups = schemaCollection.groupBy(function(model, iterator){ schemaCollection.on('sync', function() {
var groups = schemaCollection.groupBy(function(model, iterator) {
return model.get('protocol'); return model.get('protocol');
}); });
var modelCollection = _.map(groups, function(values, key, list){ var modelCollection = _.map(groups, function(values, key, list) {
return { return {
"header" : key, 'header' : key,
collection : values collection : values
}; };
}); });
groupedSchemaCollection.reset(modelCollection); groupedSchemaCollection.reset(modelCollection);
}); });
var view = new AddCollectionView({ var view = new AddCollectionView({
collection : groupedSchemaCollection, collection : groupedSchemaCollection,
targetCollection : collection targetCollection : collection
}); });
AppLayout.modalRegion.show(view); AppLayout.modalRegion.show(view);
} }
}; };

View File

@ -3,11 +3,15 @@ var Marionette = require('marionette');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/Delete/DownloadClientDeleteViewTemplate', template : 'Settings/DownloadClient/Delete/DownloadClientDeleteViewTemplate',
events : {'click .x-confirm-delete' : '_delete'},
_delete : function(){ events : {
'click .x-confirm-delete' : '_delete'
},
_delete : function() {
this.model.destroy({ this.model.destroy({
wait : true, wait : true,
success : function(){ success : function() {
vent.trigger(vent.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
} }
}); });

View File

@ -2,19 +2,24 @@ var Backbone = require('backbone');
var DownloadClientModel = require('./DownloadClientModel'); var DownloadClientModel = require('./DownloadClientModel');
module.exports = Backbone.Collection.extend({ module.exports = Backbone.Collection.extend({
model : DownloadClientModel, model : DownloadClientModel,
url : window.NzbDrone.ApiRoot + '/downloadclient', url : window.NzbDrone.ApiRoot + '/downloadclient',
comparator : function(left, right, collection){
comparator : function(left, right, collection) {
var result = 0; var result = 0;
if(left.get('protocol')) {
if (left.get('protocol')) {
result = -left.get('protocol').localeCompare(right.get('protocol')); result = -left.get('protocol').localeCompare(right.get('protocol'));
} }
if(result === 0 && left.get('name')) {
if (result === 0 && left.get('name')) {
result = left.get('name').localeCompare(right.get('name')); result = left.get('name').localeCompare(right.get('name'));
} }
if(result === 0) {
if (result === 0) {
result = left.get('implementation').localeCompare(right.get('implementation')); result = left.get('implementation').localeCompare(right.get('implementation'));
} }
return result; return result;
} }
}); });

View File

@ -6,12 +6,20 @@ module.exports = Marionette.CompositeView.extend({
itemView : ItemView, itemView : ItemView,
itemViewContainer : '.download-client-list', itemViewContainer : '.download-client-list',
template : 'Settings/DownloadClient/DownloadClientCollectionViewTemplate', template : 'Settings/DownloadClient/DownloadClientCollectionViewTemplate',
ui : {"addCard" : '.x-add-card'},
events : {"click .x-add-card" : '_openSchemaModal'}, ui : {
appendHtml : function(collectionView, itemView, index){ 'addCard' : '.x-add-card'
},
events : {
'click .x-add-card' : '_openSchemaModal'
},
appendHtml : function(collectionView, itemView, index) {
collectionView.ui.addCard.parent('li').before(itemView.el); collectionView.ui.addCard.parent('li').before(itemView.el);
}, },
_openSchemaModal : function(){
_openSchemaModal : function() {
SchemaModal.open(this.collection); SchemaModal.open(this.collection);
} }
}); });

View File

@ -3,13 +3,18 @@ var Marionette = require('marionette');
var EditView = require('./Edit/DownloadClientEditView'); var EditView = require('./Edit/DownloadClientEditView');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/DownloadClientItemViewTemplate', template : 'Settings/DownloadClient/DownloadClientItemViewTemplate',
tagName : 'li', tagName : 'li',
events : {"click" : '_edit'},
initialize : function(){ events : {
'click' : '_edit'
},
initialize : function() {
this.listenTo(this.model, 'sync', this.render); this.listenTo(this.model, 'sync', this.render);
}, },
_edit : function(){
_edit : function() {
var view = new EditView({ var view = new EditView({
model : this.model, model : this.model,
targetCollection : this.model.collection targetCollection : this.model.collection

View File

@ -7,23 +7,26 @@ var RemotePathMappingCollection = require('./RemotePathMapping/RemotePathMapping
var RemotePathMappingCollectionView = require('./RemotePathMapping/RemotePathMappingCollectionView'); var RemotePathMappingCollectionView = require('./RemotePathMapping/RemotePathMappingCollectionView');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Settings/DownloadClient/DownloadClientLayoutTemplate', template : 'Settings/DownloadClient/DownloadClientLayoutTemplate',
regions : {
regions : {
downloadClients : '#x-download-clients-region', downloadClients : '#x-download-clients-region',
downloadHandling : '#x-download-handling-region', downloadHandling : '#x-download-handling-region',
droneFactory : '#x-dronefactory-region', droneFactory : '#x-dronefactory-region',
remotePathMappings : '#x-remotepath-mapping-region' remotePathMappings : '#x-remotepath-mapping-region'
}, },
initialize : function(){
initialize : function() {
this.downloadClientsCollection = new DownloadClientCollection(); this.downloadClientsCollection = new DownloadClientCollection();
this.downloadClientsCollection.fetch(); this.downloadClientsCollection.fetch();
this.remotePathMappingCollection = new RemotePathMappingCollection(); this.remotePathMappingCollection = new RemotePathMappingCollection();
this.remotePathMappingCollection.fetch(); this.remotePathMappingCollection.fetch();
}, },
onShow : function(){
this.downloadClients.show(new DownloadClientCollectionView({collection : this.downloadClientsCollection})); onShow : function() {
this.downloadHandling.show(new DownloadHandlingView({model : this.model})); this.downloadClients.show(new DownloadClientCollectionView({ collection : this.downloadClientsCollection }));
this.droneFactory.show(new DroneFactoryView({model : this.model})); this.downloadHandling.show(new DownloadHandlingView({ model : this.model }));
this.remotePathMappings.show(new RemotePathMappingCollectionView({collection : this.remotePathMappingCollection})); this.droneFactory.show(new DroneFactoryView({ model : this.model }));
this.remotePathMappings.show(new RemotePathMappingCollectionView({ collection : this.remotePathMappingCollection }));
} }
}); });

View File

@ -2,47 +2,49 @@ var Marionette = require('marionette');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView'); var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView'); var AsValidatedView = require('../../../Mixins/AsValidatedView');
module.exports = (function(){ var view = Marionette.ItemView.extend({
var view = Marionette.ItemView.extend({ template : 'Settings/DownloadClient/DownloadHandling/DownloadHandlingViewTemplate',
template : 'Settings/DownloadClient/DownloadHandling/DownloadHandlingViewTemplate',
ui : { ui : {
completedDownloadHandlingCheckbox : '.x-completed-download-handling', completedDownloadHandlingCheckbox : '.x-completed-download-handling',
completedDownloadOptions : '.x-completed-download-options', completedDownloadOptions : '.x-completed-download-options',
failedAutoRedownladCheckbox : '.x-failed-auto-redownload', failedAutoRedownladCheckbox : '.x-failed-auto-redownload',
failedDownloadOptions : '.x-failed-download-options' failedDownloadOptions : '.x-failed-download-options'
}, },
events : {
"change .x-completed-download-handling" : '_setCompletedDownloadOptionsVisibility', events : {
"change .x-failed-auto-redownload" : '_setFailedDownloadOptionsVisibility' 'change .x-completed-download-handling' : '_setCompletedDownloadOptionsVisibility',
}, 'change .x-failed-auto-redownload' : '_setFailedDownloadOptionsVisibility'
onRender : function(){ },
if(!this.ui.completedDownloadHandlingCheckbox.prop('checked')) {
this.ui.completedDownloadOptions.hide(); onRender : function() {
} if (!this.ui.completedDownloadHandlingCheckbox.prop('checked')) {
if(!this.ui.failedAutoRedownladCheckbox.prop('checked')) { this.ui.completedDownloadOptions.hide();
this.ui.failedDownloadOptions.hide();
}
},
_setCompletedDownloadOptionsVisibility : function(){
var checked = this.ui.completedDownloadHandlingCheckbox.prop('checked');
if(checked) {
this.ui.completedDownloadOptions.slideDown();
}
else {
this.ui.completedDownloadOptions.slideUp();
}
},
_setFailedDownloadOptionsVisibility : function(){
var checked = this.ui.failedAutoRedownladCheckbox.prop('checked');
if(checked) {
this.ui.failedDownloadOptions.slideDown();
}
else {
this.ui.failedDownloadOptions.slideUp();
}
} }
}); if (!this.ui.failedAutoRedownladCheckbox.prop('checked')) {
AsModelBoundView.call(view); this.ui.failedDownloadOptions.hide();
AsValidatedView.call(view); }
return view; },
}).call(this);
_setCompletedDownloadOptionsVisibility : function() {
var checked = this.ui.completedDownloadHandlingCheckbox.prop('checked');
if (checked) {
this.ui.completedDownloadOptions.slideDown();
} else {
this.ui.completedDownloadOptions.slideUp();
}
},
_setFailedDownloadOptionsVisibility : function() {
var checked = this.ui.failedAutoRedownladCheckbox.prop('checked');
if (checked) {
this.ui.failedDownloadOptions.slideDown();
} else {
this.ui.failedDownloadOptions.slideUp();
}
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
module.exports = view;

View File

@ -3,15 +3,19 @@ var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView'); var AsValidatedView = require('../../../Mixins/AsValidatedView');
require('../../../Mixins/FileBrowser'); require('../../../Mixins/FileBrowser');
module.exports = (function(){ var view = Marionette.ItemView.extend({
var view = Marionette.ItemView.extend({ template : 'Settings/DownloadClient/DroneFactory/DroneFactoryViewTemplate',
template : 'Settings/DownloadClient/DroneFactory/DroneFactoryViewTemplate',
ui : {droneFactory : '.x-path'}, ui : {
onShow : function(){ droneFactory : '.x-path'
this.ui.droneFactory.fileBrowser(); },
}
}); onShow : function() {
AsModelBoundView.call(view); this.ui.droneFactory.fileBrowser();
AsValidatedView.call(view); }
return view; });
}).call(this);
AsModelBoundView.call(view);
AsValidatedView.call(view);
module.exports = view;

View File

@ -1,4 +1,4 @@
var vent = require('vent'); var vent = require('vent');
var Marionette = require('marionette'); var Marionette = require('marionette');
var DeleteView = require('../Delete/DownloadClientDeleteView'); var DeleteView = require('../Delete/DownloadClientDeleteView');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView'); var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
@ -8,40 +8,49 @@ require('../../../Form/FormBuilder');
require('../../../Mixins/FileBrowser'); require('../../../Mixins/FileBrowser');
require('bootstrap'); require('bootstrap');
module.exports = (function(){ var view = Marionette.ItemView.extend({
var view = Marionette.ItemView.extend({ template : 'Settings/DownloadClient/Edit/DownloadClientEditViewTemplate',
template : 'Settings/DownloadClient/Edit/DownloadClientEditViewTemplate',
ui : { ui : {
path : '.x-path', path : '.x-path',
modalBody : '.modal-body' modalBody : '.modal-body'
}, },
events : {
'click .x-back' : '_back' events : {
}, 'click .x-back' : '_back'
_deleteView : DeleteView, },
initialize : function(options){
this.targetCollection = options.targetCollection; _deleteView : DeleteView,
},
onShow : function(){ initialize : function(options) {
if(this.ui.path.length > 0) { this.targetCollection = options.targetCollection;
this.ui.modalBody.addClass('modal-overflow'); },
}
this.ui.path.fileBrowser(); onShow : function() {
}, if (this.ui.path.length > 0) {
_onAfterSave : function(){ this.ui.modalBody.addClass('modal-overflow');
this.targetCollection.add(this.model, {merge : true});
vent.trigger(vent.Commands.CloseModalCommand);
},
_onAfterSaveAndAdd : function(){
this.targetCollection.add(this.model, {merge : true});
require('../Add/DownloadClientSchemaModal').open(this.targetCollection);
},
_back : function(){
require('../Add/DownloadClientSchemaModal').open(this.targetCollection);
} }
});
AsModelBoundView.call(view); this.ui.path.fileBrowser();
AsValidatedView.call(view); },
AsEditModalView.call(view);
return view; _onAfterSave : function() {
}).call(this); this.targetCollection.add(this.model, { merge : true });
vent.trigger(vent.Commands.CloseModalCommand);
},
_onAfterSaveAndAdd : function() {
this.targetCollection.add(this.model, { merge : true });
require('../Add/DownloadClientSchemaModal').open(this.targetCollection);
},
_back : function() {
require('../Add/DownloadClientSchemaModal').open(this.targetCollection);
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
AsEditModalView.call(view);
module.exports = view;

View File

@ -9,14 +9,20 @@ module.exports = Marionette.CompositeView.extend({
template : 'Settings/DownloadClient/RemotePathMapping/RemotePathMappingCollectionViewTemplate', template : 'Settings/DownloadClient/RemotePathMapping/RemotePathMappingCollectionViewTemplate',
itemViewContainer : '.x-rows', itemViewContainer : '.x-rows',
itemView : RemotePathMappingItemView, itemView : RemotePathMappingItemView,
events : {"click .x-add" : '_addMapping'},
_addMapping : function(){ events : {
'click .x-add' : '_addMapping'
},
_addMapping : function() {
var model = new RemotePathMappingModel(); var model = new RemotePathMappingModel();
model.collection = this.collection; model.collection = this.collection;
var view = new EditView({ var view = new EditView({
model : model, model : model,
targetCollection : this.collection targetCollection : this.collection
}); });
AppLayout.modalRegion.show(view); AppLayout.modalRegion.show(view);
} }
}); });

View File

@ -3,11 +3,15 @@ var Marionette = require('marionette');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/RemotePathMapping/RemotePathMappingDeleteViewTemplate', template : 'Settings/DownloadClient/RemotePathMapping/RemotePathMappingDeleteViewTemplate',
events : {"click .x-confirm-delete" : '_delete'},
_delete : function(){ events : {
'click .x-confirm-delete' : '_delete'
},
_delete : function() {
this.model.destroy({ this.model.destroy({
wait : true, wait : true,
success : function(){ success : function() {
vent.trigger(vent.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
} }
}); });

View File

@ -10,30 +10,36 @@ var AsEditModalView = require('../../../Mixins/AsEditModalView');
require('../../../Mixins/FileBrowser'); require('../../../Mixins/FileBrowser');
require('bootstrap'); require('bootstrap');
module.exports = (function(){ var view = Marionette.ItemView.extend({
var view = Marionette.ItemView.extend({ template : 'Settings/DownloadClient/RemotePathMapping/RemotePathMappingEditViewTemplate',
template : 'Settings/DownloadClient/RemotePathMapping/RemotePathMappingEditViewTemplate',
ui : { ui : {
path : '.x-path', path : '.x-path',
modalBody : '.modal-body' modalBody : '.modal-body'
}, },
_deleteView : DeleteView,
initialize : function(options){ _deleteView : DeleteView,
this.targetCollection = options.targetCollection;
}, initialize : function(options) {
onShow : function(){ this.targetCollection = options.targetCollection;
if(this.ui.path.length > 0) { },
this.ui.modalBody.addClass('modal-overflow');
} onShow : function() {
this.ui.path.fileBrowser(); if (this.ui.path.length > 0) {
}, this.ui.modalBody.addClass('modal-overflow');
_onAfterSave : function(){
this.targetCollection.add(this.model, {merge : true});
vent.trigger(vent.Commands.CloseModalCommand);
} }
});
AsModelBoundView.call(view); this.ui.path.fileBrowser();
AsValidatedView.call(view); },
AsEditModalView.call(view);
return view; _onAfterSave : function() {
}).call(this); this.targetCollection.add(this.model, { merge : true });
vent.trigger(vent.Commands.CloseModalCommand);
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
AsEditModalView.call(view);
module.exports = view;

View File

@ -3,17 +3,23 @@ var Marionette = require('marionette');
var EditView = require('./RemotePathMappingEditView'); var EditView = require('./RemotePathMappingEditView');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/RemotePathMapping/RemotePathMappingItemViewTemplate', template : 'Settings/DownloadClient/RemotePathMapping/RemotePathMappingItemViewTemplate',
className : 'row', className : 'row',
events : {"click .x-edit" : '_editMapping'},
initialize : function(){ events : {
'click .x-edit' : '_editMapping'
},
initialize : function() {
this.listenTo(this.model, 'sync', this.render); this.listenTo(this.model, 'sync', this.render);
}, },
_editMapping : function(){
_editMapping : function() {
var view = new EditView({ var view = new EditView({
model : this.model, model : this.model,
targetCollection : this.model.collection targetCollection : this.model.collection
}); });
AppLayout.modalRegion.show(view); AppLayout.modalRegion.show(view);
} }
}); });

View File

@ -1,4 +1,3 @@

var vent = require('../../vent'); var vent = require('../../vent');
var Marionette = require('marionette'); var Marionette = require('marionette');
var CommandController = require('../../Commands/CommandController'); var CommandController = require('../../Commands/CommandController');
@ -8,16 +7,16 @@ var AsValidatedView = require('../../Mixins/AsValidatedView');
require('../../Mixins/CopyToClipboard'); require('../../Mixins/CopyToClipboard');
var view = Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template: 'Settings/General/GeneralViewTemplate', template : 'Settings/General/GeneralViewTemplate',
events: { events : {
'change .x-auth' : '_setAuthOptionsVisibility', 'change .x-auth' : '_setAuthOptionsVisibility',
'change .x-ssl' : '_setSslOptionsVisibility', 'change .x-ssl' : '_setSslOptionsVisibility',
'click .x-reset-api-key' : '_resetApiKey', 'click .x-reset-api-key' : '_resetApiKey',
'change .x-update-mechanism' : '_setScriptGroupVisibility' 'change .x-update-mechanism' : '_setScriptGroupVisibility'
}, },
ui: { ui : {
authToggle : '.x-auth', authToggle : '.x-auth',
authOptions : '.x-auth-options', authOptions : '.x-auth-options',
sslToggle : '.x-ssl', sslToggle : '.x-ssl',
@ -29,16 +28,16 @@ var view = Marionette.ItemView.extend({
scriptGroup : '.x-script-group' scriptGroup : '.x-script-group'
}, },
initialize: function () { initialize : function() {
this.listenTo(vent, vent.Events.CommandComplete, this._commandComplete); this.listenTo(vent, vent.Events.CommandComplete, this._commandComplete);
}, },
onRender: function(){ onRender : function() {
if(this.ui.authToggle.val() === 'none'){ if (this.ui.authToggle.val() === 'none') {
this.ui.authOptions.hide(); this.ui.authOptions.hide();
} }
if(!this.ui.sslToggle.prop('checked')){ if (!this.ui.sslToggle.prop('checked')) {
this.ui.sslOptions.hide(); this.ui.sslOptions.hide();
} }
@ -47,18 +46,18 @@ var view = Marionette.ItemView.extend({
} }
CommandController.bindToCommand({ CommandController.bindToCommand({
element: this.ui.resetApiKey, element : this.ui.resetApiKey,
command: { command : {
name: 'resetApiKey' name : 'resetApiKey'
} }
}); });
}, },
onShow: function () { onShow : function() {
this.ui.copyApiKey.copyToClipboard(this.ui.apiKeyInput); this.ui.copyApiKey.copyToClipboard(this.ui.apiKeyInput);
}, },
_setAuthOptionsVisibility: function () { _setAuthOptionsVisibility : function() {
var showAuthOptions = this.ui.authToggle.val() !== 'none'; var showAuthOptions = this.ui.authToggle.val() !== 'none';
@ -71,7 +70,7 @@ var view = Marionette.ItemView.extend({
} }
}, },
_setSslOptionsVisibility: function () { _setSslOptionsVisibility : function() {
var showSslOptions = this.ui.sslToggle.prop('checked'); var showSslOptions = this.ui.sslToggle.prop('checked');
@ -84,7 +83,7 @@ var view = Marionette.ItemView.extend({
} }
}, },
_resetApiKey: function () { _resetApiKey : function() {
if (window.confirm('Reset API Key?')) { if (window.confirm('Reset API Key?')) {
CommandController.Execute('resetApiKey', { CommandController.Execute('resetApiKey', {
name : 'resetApiKey' name : 'resetApiKey'
@ -92,13 +91,13 @@ var view = Marionette.ItemView.extend({
} }
}, },
_commandComplete: function (options) { _commandComplete : function(options) {
if (options.command.get('name') === 'resetapikey') { if (options.command.get('name') === 'resetapikey') {
this.model.fetch(); this.model.fetch();
} }
}, },
_setScriptGroupVisibility: function () { _setScriptGroupVisibility : function() {
if (this._showScriptGroup()) { if (this._showScriptGroup()) {
this.ui.scriptGroup.slideDown(); this.ui.scriptGroup.slideDown();
@ -109,7 +108,7 @@ var view = Marionette.ItemView.extend({
} }
}, },
_showScriptGroup: function () { _showScriptGroup : function() {
return this.ui.updateMechanism.val() === 'script'; return this.ui.updateMechanism.val() === 'script';
} }
}); });

View File

@ -3,7 +3,7 @@ var ThingyHeaderGroupView = require('../../ThingyHeaderGroupView');
var AddItemView = require('./IndexerAddItemView'); var AddItemView = require('./IndexerAddItemView');
module.exports = ThingyAddCollectionView.extend({ module.exports = ThingyAddCollectionView.extend({
itemView : ThingyHeaderGroupView.extend({itemView : AddItemView}), itemView : ThingyHeaderGroupView.extend({ itemView : AddItemView }),
itemViewContainer : '.add-indexer .items', itemViewContainer : '.add-indexer .items',
template : 'Settings/Indexers/Add/IndexerAddCollectionViewTemplate' template : 'Settings/Indexers/Add/IndexerAddCollectionViewTemplate'
}); });

View File

@ -1,34 +1,41 @@
var _ = require('underscore'); var _ = require('underscore');
var $ = require('jquery'); var $ = require('jquery');
var AppLayout = require('../../../AppLayout'); var AppLayout = require('../../../AppLayout');
var Marionette = require('marionette'); var Marionette = require('marionette');
var EditView = require('../Edit/IndexerEditView'); var EditView = require('../Edit/IndexerEditView');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/Indexers/Add/IndexerAddItemViewTemplate', template : 'Settings/Indexers/Add/IndexerAddItemViewTemplate',
tagName : 'li', tagName : 'li',
className : 'add-thingy-item', className : 'add-thingy-item',
events : { events : {
'click .x-preset' : '_addPreset', 'click .x-preset' : '_addPreset',
'click' : '_add' 'click' : '_add'
}, },
initialize : function(options){
initialize : function(options) {
this.targetCollection = options.targetCollection; this.targetCollection = options.targetCollection;
}, },
_addPreset : function(e){
_addPreset : function(e) {
var presetName = $(e.target).closest('.x-preset').attr('data-id'); var presetName = $(e.target).closest('.x-preset').attr('data-id');
var presetData = _.where(this.model.get('presets'), {name : presetName})[0]; var presetData = _.where(this.model.get('presets'), { name : presetName })[0];
this.model.set(presetData); this.model.set(presetData);
this._openEdit(); this._openEdit();
}, },
_add : function(e){
if($(e.target).closest('.btn,.btn-group').length !== 0) { _add : function(e) {
if ($(e.target).closest('.btn,.btn-group').length !== 0) {
return; return;
} }
this._openEdit(); this._openEdit();
}, },
_openEdit : function(){
_openEdit : function() {
this.model.set({ this.model.set({
id : undefined, id : undefined,
enableRss : this.model.get('supportsRss'), enableRss : this.model.get('supportsRss'),
@ -39,6 +46,7 @@ module.exports = Marionette.ItemView.extend({
model : this.model, model : this.model,
targetCollection : this.targetCollection targetCollection : this.targetCollection
}); });
AppLayout.modalRegion.show(editView); AppLayout.modalRegion.show(editView);
} }
}); });

View File

@ -5,29 +5,35 @@ var SchemaCollection = require('../IndexerCollection');
var AddCollectionView = require('./IndexerAddCollectionView'); var AddCollectionView = require('./IndexerAddCollectionView');
module.exports = { module.exports = {
open : function(collection){ open : function(collection) {
var schemaCollection = new SchemaCollection(); var schemaCollection = new SchemaCollection();
var originalUrl = schemaCollection.url; var originalUrl = schemaCollection.url;
schemaCollection.url = schemaCollection.url + '/schema'; schemaCollection.url = schemaCollection.url + '/schema';
schemaCollection.fetch(); schemaCollection.fetch();
schemaCollection.url = originalUrl; schemaCollection.url = originalUrl;
var groupedSchemaCollection = new Backbone.Collection(); var groupedSchemaCollection = new Backbone.Collection();
schemaCollection.on('sync', function(){
var groups = schemaCollection.groupBy(function(model, iterator){ schemaCollection.on('sync', function() {
var groups = schemaCollection.groupBy(function(model, iterator) {
return model.get('protocol'); return model.get('protocol');
}); });
var modelCollection = _.map(groups, function(values, key, list){ var modelCollection = _.map(groups, function(values, key, list) {
return { return {
"header" : key, "header" : key,
collection : values collection : values
}; };
}); });
groupedSchemaCollection.reset(modelCollection); groupedSchemaCollection.reset(modelCollection);
}); });
var view = new AddCollectionView({ var view = new AddCollectionView({
collection : groupedSchemaCollection, collection : groupedSchemaCollection,
targetCollection : collection targetCollection : collection
}); });
AppLayout.modalRegion.show(view); AppLayout.modalRegion.show(view);
} }
}; };

View File

@ -3,11 +3,15 @@ var Marionette = require('marionette');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/Indexers/Delete/IndexerDeleteViewTemplate', template : 'Settings/Indexers/Delete/IndexerDeleteViewTemplate',
events : {"click .x-confirm-delete" : '_delete'},
_delete : function(){ events : {
'click .x-confirm-delete' : '_delete'
},
_delete : function() {
this.model.destroy({ this.model.destroy({
wait : true, wait : true,
success : function(){ success : function() {
vent.trigger(vent.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
} }
}); });

View File

@ -1,4 +1,4 @@
var vent = require('vent'); var vent = require('vent');
var Marionette = require('marionette'); var Marionette = require('marionette');
var DeleteView = require('../Delete/IndexerDeleteView'); var DeleteView = require('../Delete/IndexerDeleteView');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView'); var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
@ -8,33 +8,41 @@ require('../../../Form/FormBuilder');
require('../../../Mixins/AutoComplete'); require('../../../Mixins/AutoComplete');
require('bootstrap'); require('bootstrap');
module.exports = (function(){ var view = Marionette.ItemView.extend({
var view = Marionette.ItemView.extend({ template : 'Settings/Indexers/Edit/IndexerEditViewTemplate',
template : 'Settings/Indexers/Edit/IndexerEditViewTemplate',
events : { events : {
'click .x-back' : '_back' 'click .x-back' : '_back'
}, },
_deleteView : DeleteView,
initialize : function(options){ _deleteView : DeleteView,
this.targetCollection = options.targetCollection;
}, initialize : function(options) {
_onAfterSave : function(){ this.targetCollection = options.targetCollection;
this.targetCollection.add(this.model, {merge : true}); },
vent.trigger(vent.Commands.CloseModalCommand);
}, _onAfterSave : function() {
_onAfterSaveAndAdd : function(){ this.targetCollection.add(this.model, { merge : true });
this.targetCollection.add(this.model, {merge : true}); vent.trigger(vent.Commands.CloseModalCommand);
require('../Add/IndexerSchemaModal').open(this.targetCollection); },
},
_back : function(){ _onAfterSaveAndAdd : function() {
if(this.model.isNew()) { this.targetCollection.add(this.model, { merge : true });
this.model.destroy();
} require('../Add/IndexerSchemaModal').open(this.targetCollection);
require('../Add/IndexerSchemaModal').open(this.targetCollection); },
_back : function() {
if (this.model.isNew()) {
this.model.destroy();
} }
});
AsModelBoundView.call(view); require('../Add/IndexerSchemaModal').open(this.targetCollection);
AsValidatedView.call(view); }
AsEditModalView.call(view); });
return view;
}).call(this); AsModelBoundView.call(view);
AsValidatedView.call(view);
AsEditModalView.call(view);
module.exports = view;

View File

@ -2,19 +2,24 @@ var Backbone = require('backbone');
var IndexerModel = require('./IndexerModel'); var IndexerModel = require('./IndexerModel');
module.exports = Backbone.Collection.extend({ module.exports = Backbone.Collection.extend({
model : IndexerModel, model : IndexerModel,
url : window.NzbDrone.ApiRoot + '/indexer', url : window.NzbDrone.ApiRoot + '/indexer',
comparator : function(left, right, collection){
comparator : function(left, right, collection) {
var result = 0; var result = 0;
if(left.get('protocol')) {
if (left.get('protocol')) {
result = -left.get('protocol').localeCompare(right.get('protocol')); result = -left.get('protocol').localeCompare(right.get('protocol'));
} }
if(result === 0 && left.get('name')) {
if (result === 0 && left.get('name')) {
result = left.get('name').localeCompare(right.get('name')); result = left.get('name').localeCompare(right.get('name'));
} }
if(result === 0) {
if (result === 0) {
result = left.get('implementation').localeCompare(right.get('implementation')); result = left.get('implementation').localeCompare(right.get('implementation'));
} }
return result; return result;
} }
}); });

View File

@ -6,12 +6,20 @@ module.exports = Marionette.CompositeView.extend({
itemView : ItemView, itemView : ItemView,
itemViewContainer : '.indexer-list', itemViewContainer : '.indexer-list',
template : 'Settings/Indexers/IndexerCollectionViewTemplate', template : 'Settings/Indexers/IndexerCollectionViewTemplate',
ui : {"addCard" : '.x-add-card'},
events : {"click .x-add-card" : '_openSchemaModal'}, ui : {
appendHtml : function(collectionView, itemView, index){ 'addCard' : '.x-add-card'
},
events : {
'click .x-add-card' : '_openSchemaModal'
},
appendHtml : function(collectionView, itemView, index) {
collectionView.ui.addCard.parent('li').before(itemView.el); collectionView.ui.addCard.parent('li').before(itemView.el);
}, },
_openSchemaModal : function(){
_openSchemaModal : function() {
SchemaModal.open(this.collection); SchemaModal.open(this.collection);
} }
}); });

View File

@ -3,13 +3,18 @@ var Marionette = require('marionette');
var EditView = require('./Edit/IndexerEditView'); var EditView = require('./Edit/IndexerEditView');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/Indexers/IndexerItemViewTemplate', template : 'Settings/Indexers/IndexerItemViewTemplate',
tagName : 'li', tagName : 'li',
events : {"click" : '_edit'},
initialize : function(){ events : {
'click' : '_edit'
},
initialize : function() {
this.listenTo(this.model, 'sync', this.render); this.listenTo(this.model, 'sync', this.render);
}, },
_edit : function(){
_edit : function() {
var view = new EditView({ var view = new EditView({
model : this.model, model : this.model,
targetCollection : this.model.collection targetCollection : this.model.collection

View File

@ -6,21 +6,25 @@ var RestrictionCollection = require('./Restriction/RestrictionCollection');
var RestrictionCollectionView = require('./Restriction/RestrictionCollectionView'); var RestrictionCollectionView = require('./Restriction/RestrictionCollectionView');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Settings/Indexers/IndexerLayoutTemplate', template : 'Settings/Indexers/IndexerLayoutTemplate',
regions : {
regions : {
indexers : '#x-indexers-region', indexers : '#x-indexers-region',
indexerOptions : '#x-indexer-options-region', indexerOptions : '#x-indexer-options-region',
restriction : '#x-restriction-region' restriction : '#x-restriction-region'
}, },
initialize : function(){
initialize : function() {
this.indexersCollection = new IndexerCollection(); this.indexersCollection = new IndexerCollection();
this.indexersCollection.fetch(); this.indexersCollection.fetch();
this.restrictionCollection = new RestrictionCollection(); this.restrictionCollection = new RestrictionCollection();
this.restrictionCollection.fetch(); this.restrictionCollection.fetch();
}, },
onShow : function(){
this.indexers.show(new CollectionView({collection : this.indexersCollection})); onShow : function() {
this.indexerOptions.show(new OptionsView({model : this.model})); this.indexers.show(new CollectionView({ collection : this.indexersCollection }));
this.restriction.show(new RestrictionCollectionView({collection : this.restrictionCollection})); this.indexerOptions.show(new OptionsView({ model : this.model }));
this.restriction.show(new RestrictionCollectionView({ collection : this.restrictionCollection }));
} }
}); });

View File

@ -2,9 +2,11 @@ var Marionette = require('marionette');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView'); var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView'); var AsValidatedView = require('../../../Mixins/AsValidatedView');
module.exports = (function(){ var view = Marionette.ItemView.extend({
var view = Marionette.ItemView.extend({template : 'Settings/Indexers/Options/IndexerOptionsViewTemplate'}); template : 'Settings/Indexers/Options/IndexerOptionsViewTemplate'
AsModelBoundView.call(view); });
AsValidatedView.call(view);
return view; AsModelBoundView.call(view);
}).call(this); AsValidatedView.call(view);
module.exports = view;

View File

@ -9,13 +9,18 @@ module.exports = Marionette.CompositeView.extend({
template : 'Settings/Indexers/Restriction/RestrictionCollectionViewTemplate', template : 'Settings/Indexers/Restriction/RestrictionCollectionViewTemplate',
itemViewContainer : '.x-rows', itemViewContainer : '.x-rows',
itemView : RestrictionItemView, itemView : RestrictionItemView,
events : {"click .x-add" : '_addMapping'},
_addMapping : function(){ events : {
var model = this.collection.create({tags : []}); 'click .x-add' : '_addMapping'
},
_addMapping : function() {
var model = this.collection.create({ tags : [] });
var view = new EditView({ var view = new EditView({
model : model, model : model,
targetCollection : this.collection targetCollection : this.collection
}); });
AppLayout.modalRegion.show(view); AppLayout.modalRegion.show(view);
} }
}); });

View File

@ -3,11 +3,15 @@ var Marionette = require('marionette');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/Indexers/Restriction/RestrictionDeleteViewTemplate', template : 'Settings/Indexers/Restriction/RestrictionDeleteViewTemplate',
events : {'click .x-confirm-delete' : '_delete'},
_delete : function(){ events : {
'click .x-confirm-delete' : '_delete'
},
_delete : function() {
this.model.destroy({ this.model.destroy({
wait : true, wait : true,
success : function(){ success : function() {
vent.trigger(vent.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
} }
}); });

View File

@ -11,39 +11,45 @@ require('../../../Mixins/TagInput');
require('bootstrap'); require('bootstrap');
require('bootstrap.tagsinput'); require('bootstrap.tagsinput');
module.exports = (function(){ var view = Marionette.ItemView.extend({
var view = Marionette.ItemView.extend({ template : 'Settings/Indexers/Restriction/RestrictionEditViewTemplate',
template : 'Settings/Indexers/Restriction/RestrictionEditViewTemplate',
ui : { ui : {
required : '.x-required', required : '.x-required',
ignored : '.x-ignored', ignored : '.x-ignored',
tags : '.x-tags' tags : '.x-tags'
}, },
_deleteView : DeleteView,
initialize : function(options){ _deleteView : DeleteView,
this.targetCollection = options.targetCollection;
}, initialize : function(options) {
onRender : function(){ this.targetCollection = options.targetCollection;
this.ui.required.tagsinput({ },
trimValue : true,
tagClass : 'label label-success' onRender : function() {
}); this.ui.required.tagsinput({
this.ui.ignored.tagsinput({ trimValue : true,
trimValue : true, tagClass : 'label label-success'
tagClass : 'label label-danger' });
});
this.ui.tags.tagInput({ this.ui.ignored.tagsinput({
model : this.model, trimValue : true,
property : 'tags' tagClass : 'label label-danger'
}); });
},
_onAfterSave : function(){ this.ui.tags.tagInput({
this.targetCollection.add(this.model, {merge : true}); model : this.model,
vent.trigger(vent.Commands.CloseModalCommand); property : 'tags'
} });
}); },
AsModelBoundView.call(view);
AsValidatedView.call(view); _onAfterSave : function() {
AsEditModalView.call(view); this.targetCollection.add(this.model, { merge : true });
return view; vent.trigger(vent.Commands.CloseModalCommand);
}).call(this); }
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
AsEditModalView.call(view);
module.exports = view;

View File

@ -3,14 +3,22 @@ var Marionette = require('marionette');
var EditView = require('./RestrictionEditView'); var EditView = require('./RestrictionEditView');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/Indexers/Restriction/RestrictionItemViewTemplate', template : 'Settings/Indexers/Restriction/RestrictionItemViewTemplate',
className : 'row', className : 'row',
ui : {tags : '.x-tags'},
events : {"click .x-edit" : '_edit'}, ui : {
initialize : function(){ tags : '.x-tags'
},
events : {
'click .x-edit' : '_edit'
},
initialize : function() {
this.listenTo(this.model, 'sync', this.render); this.listenTo(this.model, 'sync', this.render);
}, },
_edit : function(){
_edit : function() {
var view = new EditView({ var view = new EditView({
model : this.model, model : this.model,
targetCollection : this.model.collection targetCollection : this.model.collection

View File

@ -5,15 +5,19 @@ var AsValidatedView = require('../../../Mixins/AsValidatedView');
require('../../../Mixins/DirectoryAutoComplete'); require('../../../Mixins/DirectoryAutoComplete');
require('../../../Mixins/FileBrowser'); require('../../../Mixins/FileBrowser');
module.exports = (function(){ var view = Marionette.ItemView.extend({
var view = Marionette.ItemView.extend({ template : 'Settings/MediaManagement/FileManagement/FileManagementViewTemplate',
template : 'Settings/MediaManagement/FileManagement/FileManagementViewTemplate',
ui : {recyclingBin : '.x-path'}, ui : {
onShow : function(){ recyclingBin : '.x-path'
this.ui.recyclingBin.fileBrowser(); },
}
}); onShow : function() {
AsModelBoundView.call(view); this.ui.recyclingBin.fileBrowser();
AsValidatedView.call(view); }
return view; });
}).call(this);
AsModelBoundView.call(view);
AsValidatedView.call(view);
module.exports = view;

View File

@ -5,21 +5,24 @@ var FileManagementView = require('./FileManagement/FileManagementView');
var PermissionsView = require('./Permissions/PermissionsView'); var PermissionsView = require('./Permissions/PermissionsView');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Settings/MediaManagement/MediaManagementLayoutTemplate', template : 'Settings/MediaManagement/MediaManagementLayoutTemplate',
regions : {
regions : {
episodeNaming : '#episode-naming', episodeNaming : '#episode-naming',
sorting : '#sorting', sorting : '#sorting',
fileManagement : '#file-management', fileManagement : '#file-management',
permissions : '#permissions' permissions : '#permissions'
}, },
initialize : function(options){
initialize : function(options) {
this.settings = options.settings; this.settings = options.settings;
this.namingSettings = options.namingSettings; this.namingSettings = options.namingSettings;
}, },
onShow : function(){
this.episodeNaming.show(new NamingView({model : this.namingSettings})); onShow : function() {
this.sorting.show(new SortingView({model : this.settings})); this.episodeNaming.show(new NamingView({ model : this.namingSettings }));
this.fileManagement.show(new FileManagementView({model : this.settings})); this.sorting.show(new SortingView({ model : this.settings }));
this.permissions.show(new PermissionsView({model : this.settings})); this.fileManagement.show(new FileManagementView({ model : this.settings }));
this.permissions.show(new PermissionsView({ model : this.settings }));
} }
}); });

View File

@ -5,101 +5,114 @@ var NamingSampleModel = require('../NamingSampleModel');
var BasicNamingModel = require('./BasicNamingModel'); var BasicNamingModel = require('./BasicNamingModel');
var AsModelBoundView = require('../../../../Mixins/AsModelBoundView'); var AsModelBoundView = require('../../../../Mixins/AsModelBoundView');
module.exports = (function(){ var view = Marionette.ItemView.extend({
var view = Marionette.ItemView.extend({ template : 'Settings/MediaManagement/Naming/Basic/BasicNamingViewTemplate',
template : 'Settings/MediaManagement/Naming/Basic/BasicNamingViewTemplate',
ui : { ui : {
namingOptions : '.x-naming-options', namingOptions : '.x-naming-options',
singleEpisodeExample : '.x-single-episode-example', singleEpisodeExample : '.x-single-episode-example',
multiEpisodeExample : '.x-multi-episode-example', multiEpisodeExample : '.x-multi-episode-example',
dailyEpisodeExample : '.x-daily-episode-example' dailyEpisodeExample : '.x-daily-episode-example'
}, },
initialize : function(options){
this.namingModel = options.model; initialize : function(options) {
this.model = new BasicNamingModel(); this.namingModel = options.model;
this._parseNamingModel(); this.model = new BasicNamingModel();
this.listenTo(this.model, 'change', this._buildFormat);
this.listenTo(this.namingModel, 'sync', this._parseNamingModel); this._parseNamingModel();
},
_parseNamingModel : function(){ this.listenTo(this.model, 'change', this._buildFormat);
var standardFormat = this.namingModel.get('standardEpisodeFormat'); this.listenTo(this.namingModel, 'sync', this._parseNamingModel);
var includeSeriesTitle = standardFormat.match(/\{Series[-_. ]Title\}/i); },
var includeEpisodeTitle = standardFormat.match(/\{Episode[-_. ]Title\}/i);
var includeQuality = standardFormat.match(/\{Quality[-_. ]Title\}/i); _parseNamingModel : function() {
var numberStyle = standardFormat.match(/s?\{season(?:\:0+)?\}[ex]\{episode(?:\:0+)?\}/i); var standardFormat = this.namingModel.get('standardEpisodeFormat');
var replaceSpaces = standardFormat.indexOf(' ') === -1;
var separator = standardFormat.match(/\}( - |\.-\.|\.| )|( - |\.-\.|\.| )\{/i); var includeSeriesTitle = standardFormat.match(/\{Series[-_. ]Title\}/i);
if(separator === null || separator[1] === '.-.') { var includeEpisodeTitle = standardFormat.match(/\{Episode[-_. ]Title\}/i);
separator = ' - '; var includeQuality = standardFormat.match(/\{Quality[-_. ]Title\}/i);
} var numberStyle = standardFormat.match(/s?\{season(?:\:0+)?\}[ex]\{episode(?:\:0+)?\}/i);
else { var replaceSpaces = standardFormat.indexOf(' ') === -1;
separator = separator[1]; var separator = standardFormat.match(/\}( - |\.-\.|\.| )|( - |\.-\.|\.| )\{/i);
}
if(numberStyle === null) { if (separator === null || separator[1] === '.-.') {
numberStyle = 'S{season:00}E{episode:00}'; separator = ' - ';
} } else {
else { separator = separator[1];
numberStyle = numberStyle[0];
}
this.model.set({
includeSeriesTitle : includeSeriesTitle !== null,
includeEpisodeTitle : includeEpisodeTitle !== null,
includeQuality : includeQuality !== null,
numberStyle : numberStyle,
replaceSpaces : replaceSpaces,
separator : separator
}, {silent : true});
},
_buildFormat : function(){
if(Config.getValueBoolean(Config.Keys.AdvancedSettings)) {
return;
}
var standardEpisodeFormat = '';
var dailyEpisodeFormat = '';
if(this.model.get('includeSeriesTitle')) {
if(this.model.get('replaceSpaces')) {
standardEpisodeFormat += '{Series.Title}';
dailyEpisodeFormat += '{Series.Title}';
}
else {
standardEpisodeFormat += '{Series Title}';
dailyEpisodeFormat += '{Series Title}';
}
standardEpisodeFormat += this.model.get('separator');
dailyEpisodeFormat += this.model.get('separator');
}
standardEpisodeFormat += this.model.get('numberStyle');
dailyEpisodeFormat += '{Air-Date}';
if(this.model.get('includeEpisodeTitle')) {
standardEpisodeFormat += this.model.get('separator');
dailyEpisodeFormat += this.model.get('separator');
if(this.model.get('replaceSpaces')) {
standardEpisodeFormat += '{Episode.Title}';
dailyEpisodeFormat += '{Episode.Title}';
}
else {
standardEpisodeFormat += '{Episode Title}';
dailyEpisodeFormat += '{Episode Title}';
}
}
if(this.model.get('includeQuality')) {
if(this.model.get('replaceSpaces')) {
standardEpisodeFormat += ' {Quality.Title}';
dailyEpisodeFormat += ' {Quality.Title}';
}
else {
standardEpisodeFormat += ' {Quality Title}';
dailyEpisodeFormat += ' {Quality Title}';
}
}
if(this.model.get('replaceSpaces')) {
standardEpisodeFormat = standardEpisodeFormat.replace(/\s/g, '.');
dailyEpisodeFormat = dailyEpisodeFormat.replace(/\s/g, '.');
}
this.namingModel.set('standardEpisodeFormat', standardEpisodeFormat);
this.namingModel.set('dailyEpisodeFormat', dailyEpisodeFormat);
this.namingModel.set('animeEpisodeFormat', standardEpisodeFormat);
} }
});
return AsModelBoundView.call(view); if (numberStyle === null) {
}).call(this); numberStyle = 'S{season:00}E{episode:00}';
} else {
numberStyle = numberStyle[0];
}
this.model.set({
includeSeriesTitle : includeSeriesTitle !== null,
includeEpisodeTitle : includeEpisodeTitle !== null,
includeQuality : includeQuality !== null,
numberStyle : numberStyle,
replaceSpaces : replaceSpaces,
separator : separator
}, { silent : true });
},
_buildFormat : function() {
if (Config.getValueBoolean(Config.Keys.AdvancedSettings)) {
return;
}
var standardEpisodeFormat = '';
var dailyEpisodeFormat = '';
if (this.model.get('includeSeriesTitle')) {
if (this.model.get('replaceSpaces')) {
standardEpisodeFormat += '{Series.Title}';
dailyEpisodeFormat += '{Series.Title}';
} else {
standardEpisodeFormat += '{Series Title}';
dailyEpisodeFormat += '{Series Title}';
}
standardEpisodeFormat += this.model.get('separator');
dailyEpisodeFormat += this.model.get('separator');
}
standardEpisodeFormat += this.model.get('numberStyle');
dailyEpisodeFormat += '{Air-Date}';
if (this.model.get('includeEpisodeTitle')) {
standardEpisodeFormat += this.model.get('separator');
dailyEpisodeFormat += this.model.get('separator');
if (this.model.get('replaceSpaces')) {
standardEpisodeFormat += '{Episode.Title}';
dailyEpisodeFormat += '{Episode.Title}';
} else {
standardEpisodeFormat += '{Episode Title}';
dailyEpisodeFormat += '{Episode Title}';
}
}
if (this.model.get('includeQuality')) {
if (this.model.get('replaceSpaces')) {
standardEpisodeFormat += ' {Quality.Title}';
dailyEpisodeFormat += ' {Quality.Title}';
} else {
standardEpisodeFormat += ' {Quality Title}';
dailyEpisodeFormat += ' {Quality Title}';
}
}
if (this.model.get('replaceSpaces')) {
standardEpisodeFormat = standardEpisodeFormat.replace(/\s/g, '.');
dailyEpisodeFormat = dailyEpisodeFormat.replace(/\s/g, '.');
}
this.namingModel.set('standardEpisodeFormat', standardEpisodeFormat);
this.namingModel.set('dailyEpisodeFormat', dailyEpisodeFormat);
this.namingModel.set('animeEpisodeFormat', standardEpisodeFormat);
}
});
module.exports = AsModelBoundView.call(view);

View File

@ -1,3 +1,3 @@
var Backbone = require('backbone'); var Backbone = require('backbone');
module.exports = Backbone.Model.extend({url : window.NzbDrone.ApiRoot + '/config/naming/samples'}); module.exports = Backbone.Model.extend({ url : window.NzbDrone.ApiRoot + '/config/naming/samples' });

View File

@ -5,7 +5,7 @@ var BasicNamingView = require('./Basic/BasicNamingView');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView'); var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView'); var AsValidatedView = require('../../../Mixins/AsValidatedView');
module.exports = (function(){ module.exports = (function() {
var view = Marionette.Layout.extend({ var view = Marionette.Layout.extend({
template : 'Settings/MediaManagement/Naming/NamingViewTemplate', template : 'Settings/MediaManagement/Naming/NamingViewTemplate',
ui : { ui : {
@ -27,31 +27,30 @@ module.exports = (function(){
"click .x-naming-token-helper a" : '_addToken', "click .x-naming-token-helper a" : '_addToken',
"change .x-multi-episode-style" : '_multiEpisodeFomatChanged' "change .x-multi-episode-style" : '_multiEpisodeFomatChanged'
}, },
regions : {basicNamingRegion : '.x-basic-naming'}, regions : { basicNamingRegion : '.x-basic-naming' },
onRender : function(){ onRender : function() {
if(!this.model.get('renameEpisodes')) { if (!this.model.get('renameEpisodes')) {
this.ui.namingOptions.hide(); this.ui.namingOptions.hide();
} }
var basicNamingView = new BasicNamingView({model : this.model}); var basicNamingView = new BasicNamingView({ model : this.model });
this.basicNamingRegion.show(basicNamingView); this.basicNamingRegion.show(basicNamingView);
this.namingSampleModel = new NamingSampleModel(); this.namingSampleModel = new NamingSampleModel();
this.listenTo(this.model, 'change', this._updateSamples); this.listenTo(this.model, 'change', this._updateSamples);
this.listenTo(this.namingSampleModel, 'sync', this._showSamples); this.listenTo(this.namingSampleModel, 'sync', this._showSamples);
this._updateSamples(); this._updateSamples();
}, },
_setFailedDownloadOptionsVisibility : function(){ _setFailedDownloadOptionsVisibility : function() {
var checked = this.ui.renameEpisodesCheckbox.prop('checked'); var checked = this.ui.renameEpisodesCheckbox.prop('checked');
if(checked) { if (checked) {
this.ui.namingOptions.slideDown(); this.ui.namingOptions.slideDown();
} } else {
else {
this.ui.namingOptions.slideUp(); this.ui.namingOptions.slideUp();
} }
}, },
_updateSamples : function(){ _updateSamples : function() {
this.namingSampleModel.fetch({data : this.model.toJSON()}); this.namingSampleModel.fetch({ data : this.model.toJSON() });
}, },
_showSamples : function(){ _showSamples : function() {
this.ui.singleEpisodeExample.html(this.namingSampleModel.get('singleEpisodeExample')); this.ui.singleEpisodeExample.html(this.namingSampleModel.get('singleEpisodeExample'));
this.ui.multiEpisodeExample.html(this.namingSampleModel.get('multiEpisodeExample')); this.ui.multiEpisodeExample.html(this.namingSampleModel.get('multiEpisodeExample'));
this.ui.dailyEpisodeExample.html(this.namingSampleModel.get('dailyEpisodeExample')); this.ui.dailyEpisodeExample.html(this.namingSampleModel.get('dailyEpisodeExample'));
@ -60,16 +59,15 @@ module.exports = (function(){
this.ui.seriesFolderExample.html(this.namingSampleModel.get('seriesFolderExample')); this.ui.seriesFolderExample.html(this.namingSampleModel.get('seriesFolderExample'));
this.ui.seasonFolderExample.html(this.namingSampleModel.get('seasonFolderExample')); this.ui.seasonFolderExample.html(this.namingSampleModel.get('seasonFolderExample'));
}, },
_addToken : function(e){ _addToken : function(e) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
var target = e.target; var target = e.target;
var token = ''; var token = '';
var input = this.$(target).closest('.x-helper-input').children('input'); var input = this.$(target).closest('.x-helper-input').children('input');
if(this.$(target).attr('data-token')) { if (this.$(target).attr('data-token')) {
token = '{{0}}'.format(this.$(target).attr('data-token')); token = '{{0}}'.format(this.$(target).attr('data-token'));
} } else {
else {
token = this.$(target).attr('data-separator'); token = this.$(target).attr('data-separator');
} }
input.val(input.val() + token); input.val(input.val() + token);
@ -77,7 +75,7 @@ module.exports = (function(){
this.ui.namingTokenHelper.removeClass('open'); this.ui.namingTokenHelper.removeClass('open');
input.focus(); input.focus();
}, },
multiEpisodeFormatChanged : function(){ multiEpisodeFormatChanged : function() {
this.model.set('multiEpisodeStyle', this.ui.multiEpisodeStyle.val()); this.model.set('multiEpisodeStyle', this.ui.multiEpisodeStyle.val());
} }
}); });

View File

@ -2,9 +2,10 @@ var Marionette = require('marionette');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView'); var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView'); var AsValidatedView = require('../../../Mixins/AsValidatedView');
module.exports = (function(){ var view = Marionette.ItemView.extend({
var view = Marionette.ItemView.extend({template : 'Settings/MediaManagement/Permissions/PermissionsViewTemplate'}); template : 'Settings/MediaManagement/Permissions/PermissionsViewTemplate'
AsModelBoundView.call(view); });
AsValidatedView.call(view); AsModelBoundView.call(view);
return view; AsValidatedView.call(view);
}).call(this);
module.exports = view;

View File

@ -2,9 +2,11 @@ var Marionette = require('marionette');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView'); var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView'); var AsValidatedView = require('../../../Mixins/AsValidatedView');
module.exports = (function(){ var view = Marionette.ItemView.extend({
var view = Marionette.ItemView.extend({template : 'Settings/MediaManagement/Sorting/SortingViewTemplate'}); template : 'Settings/MediaManagement/Sorting/SortingViewTemplate'
AsModelBoundView.call(view); });
AsValidatedView.call(view);
return view; AsModelBoundView.call(view);
}).call(this); AsValidatedView.call(view);
module.exports = view;

View File

@ -4,15 +4,16 @@ var AsModelBoundView = require('../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../Mixins/AsValidatedView'); var AsValidatedView = require('../../Mixins/AsValidatedView');
var AsEditModalView = require('../../Mixins/AsEditModalView'); var AsEditModalView = require('../../Mixins/AsEditModalView');
module.exports = (function(){ var view = Marionette.ItemView.extend({
var view = Marionette.ItemView.extend({ template : 'Settings/Metadata/MetadataEditViewTemplate',
template : 'Settings/Metadata/MetadataEditViewTemplate',
_onAfterSave : function(){ _onAfterSave : function() {
vent.trigger(vent.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
} }
}); });
AsModelBoundView.call(view);
AsValidatedView.call(view); AsModelBoundView.call(view);
AsEditModalView.call(view); AsValidatedView.call(view);
return view; AsEditModalView.call(view);
}).call(this);
module.exports = view;

View File

@ -3,18 +3,22 @@ var Marionette = require('marionette');
var EditView = require('./MetadataEditView'); var EditView = require('./MetadataEditView');
var AsModelBoundView = require('../../Mixins/AsModelBoundView'); var AsModelBoundView = require('../../Mixins/AsModelBoundView');
module.exports = (function(){ var view = Marionette.ItemView.extend({
var view = Marionette.ItemView.extend({ template : 'Settings/Metadata/MetadataItemViewTemplate',
template : 'Settings/Metadata/MetadataItemViewTemplate', tagName : 'li',
tagName : 'li',
events : {"click" : '_edit'}, events : {
initialize : function(){ 'click' : '_edit'
this.listenTo(this.model, 'sync', this.render); },
},
_edit : function(){ initialize : function() {
var view = new EditView({model : this.model}); this.listenTo(this.model, 'sync', this.render);
AppLayout.modalRegion.show(view); },
}
}); _edit : function() {
return AsModelBoundView.call(view); var view = new EditView({ model : this.model });
}).call(this); AppLayout.modalRegion.show(view);
}
});
module.exports = AsModelBoundView.call(view);

View File

@ -3,14 +3,18 @@ var MetadataCollection = require('./MetadataCollection');
var MetadataCollectionView = require('./MetadataCollectionView'); var MetadataCollectionView = require('./MetadataCollectionView');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Settings/Metadata/MetadataLayoutTemplate', template : 'Settings/Metadata/MetadataLayoutTemplate',
regions : {metadata : '#x-metadata-providers'},
initialize : function(options){ regions : {
metadata : '#x-metadata-providers'
},
initialize : function(options) {
this.settings = options.settings; this.settings = options.settings;
this.metadataCollection = new MetadataCollection(); this.metadataCollection = new MetadataCollection();
this.metadataCollection.fetch(); this.metadataCollection.fetch();
}, },
onShow : function(){ onShow : function() {
this.metadata.show(new MetadataCollectionView({collection : this.metadataCollection})); this.metadata.show(new MetadataCollectionView({ collection : this.metadataCollection }));
} }
}); });

View File

@ -5,46 +5,58 @@ var Marionette = require('marionette');
var EditView = require('../Edit/NotificationEditView'); var EditView = require('../Edit/NotificationEditView');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/Notifications/Add/NotificationAddItemViewTemplate', template : 'Settings/Notifications/Add/NotificationAddItemViewTemplate',
tagName : 'li', tagName : 'li',
className : 'add-thingy-item', className : 'add-thingy-item',
events : {
"click .x-preset" : '_addPreset', events : {
"click" : '_add' 'click .x-preset' : '_addPreset',
'click' : '_add'
}, },
initialize : function(options){
initialize : function(options) {
this.targetCollection = options.targetCollection; this.targetCollection = options.targetCollection;
}, },
_addPreset : function(e){
_addPreset : function(e) {
var presetName = $(e.target).closest('.x-preset').attr('data-id'); var presetName = $(e.target).closest('.x-preset').attr('data-id');
var presetData = _.where(this.model.get('presets'), {name : presetName})[0];
var presetData = _.where(this.model.get('presets'), { name : presetName })[0];
this.model.set(presetData); this.model.set(presetData);
this.model.set({ this.model.set({
id : undefined, id : undefined,
onGrab : true, onGrab : true,
onDownload : true, onDownload : true,
onUpgrade : true onUpgrade : true
}); });
var editView = new EditView({ var editView = new EditView({
model : this.model, model : this.model,
targetCollection : this.targetCollection targetCollection : this.targetCollection
}); });
AppLayout.modalRegion.show(editView); AppLayout.modalRegion.show(editView);
}, },
_add : function(e){
if($(e.target).closest('.btn,.btn-group').length !== 0) { _add : function(e) {
if ($(e.target).closest('.btn,.btn-group').length !== 0) {
return; return;
} }
this.model.set({ this.model.set({
id : undefined, id : undefined,
onGrab : true, onGrab : true,
onDownload : true, onDownload : true,
onUpgrade : true onUpgrade : true
}); });
var editView = new EditView({ var editView = new EditView({
model : this.model, model : this.model,
targetCollection : this.targetCollection targetCollection : this.targetCollection
}); });
AppLayout.modalRegion.show(editView); AppLayout.modalRegion.show(editView);
} }
}); });

View File

@ -3,7 +3,7 @@ var SchemaCollection = require('../NotificationCollection');
var AddCollectionView = require('./NotificationAddCollectionView'); var AddCollectionView = require('./NotificationAddCollectionView');
module.exports = { module.exports = {
open : function(collection){ open : function(collection) {
var schemaCollection = new SchemaCollection(); var schemaCollection = new SchemaCollection();
var originalUrl = schemaCollection.url; var originalUrl = schemaCollection.url;
schemaCollection.url = schemaCollection.url + '/schema'; schemaCollection.url = schemaCollection.url + '/schema';

View File

@ -3,11 +3,14 @@ var Marionette = require('marionette');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/Notifications/Delete/NotificationDeleteViewTemplate', template : 'Settings/Notifications/Delete/NotificationDeleteViewTemplate',
events : {"click .x-confirm-delete" : '_delete'},
_delete : function(){ events : {
'click .x-confirm-delete' : '_delete'
},
_delete : function() {
this.model.destroy({ this.model.destroy({
wait : true, wait : true,
success : function(){ success : function() {
vent.trigger(vent.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
} }
}); });

View File

@ -1,4 +1,4 @@
var vent = require('vent'); var vent = require('vent');
var Marionette = require('marionette'); var Marionette = require('marionette');
var DeleteView = require('../Delete/NotificationDeleteView'); var DeleteView = require('../Delete/NotificationDeleteView');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView'); var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
@ -7,55 +7,66 @@ var AsEditModalView = require('../../../Mixins/AsEditModalView');
require('../../../Form/FormBuilder'); require('../../../Form/FormBuilder');
require('../../../Mixins/TagInput'); require('../../../Mixins/TagInput');
module.exports = (function(){ var view = Marionette.ItemView.extend({
var view = Marionette.ItemView.extend({ template : 'Settings/Notifications/Edit/NotificationEditViewTemplate',
template : 'Settings/Notifications/Edit/NotificationEditViewTemplate',
ui : { ui : {
onDownloadToggle : '.x-on-download', onDownloadToggle : '.x-on-download',
onUpgradeSection : '.x-on-upgrade', onUpgradeSection : '.x-on-upgrade',
tags : '.x-tags' tags : '.x-tags'
}, },
events : {
'click .x-back' : '_back', events : {
'change .x-on-download' : '_onDownloadChanged' 'click .x-back' : '_back',
}, 'change .x-on-download' : '_onDownloadChanged'
_deleteView : DeleteView, },
initialize : function(options){
this.targetCollection = options.targetCollection; _deleteView : DeleteView,
},
onRender : function(){ initialize : function(options) {
this._onDownloadChanged(); this.targetCollection = options.targetCollection;
this.ui.tags.tagInput({ },
model : this.model,
property : 'tags' onRender : function() {
}); this._onDownloadChanged();
}, this.ui.tags.tagInput({
_onAfterSave : function(){ model : this.model,
this.targetCollection.add(this.model, {merge : true}); property : 'tags'
vent.trigger(vent.Commands.CloseModalCommand); });
}, },
_onAfterSaveAndAdd : function(){
this.targetCollection.add(this.model, {merge : true}); _onAfterSave : function() {
require('../Add/NotificationSchemaModal').open(this.targetCollection); this.targetCollection.add(this.model, { merge : true });
}, vent.trigger(vent.Commands.CloseModalCommand);
_back : function(){ },
if(this.model.isNew()) {
this.model.destroy(); _onAfterSaveAndAdd : function() {
} this.targetCollection.add(this.model, { merge : true });
require('../Add/NotificationSchemaModal').open(this.targetCollection);
}, require('../Add/NotificationSchemaModal').open(this.targetCollection);
_onDownloadChanged : function(){ },
var checked = this.ui.onDownloadToggle.prop('checked');
if(checked) { _back : function() {
this.ui.onUpgradeSection.show(); if (this.model.isNew()) {
} this.model.destroy();
else {
this.ui.onUpgradeSection.hide();
}
} }
});
AsModelBoundView.call(view); require('../Add/NotificationSchemaModal').open(this.targetCollection);
AsValidatedView.call(view); },
AsEditModalView.call(view);
return view; _onDownloadChanged : function() {
}).call(this); var checked = this.ui.onDownloadToggle.prop('checked');
if (checked) {
this.ui.onUpgradeSection.show();
} else {
this.ui.onUpgradeSection.hide();
}
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
AsEditModalView.call(view);
module.exports = view;

View File

@ -1,4 +1,4 @@
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
{{#if id}} {{#if id}}

View File

@ -6,12 +6,20 @@ module.exports = Marionette.CompositeView.extend({
itemView : ItemView, itemView : ItemView,
itemViewContainer : '.notification-list', itemViewContainer : '.notification-list',
template : 'Settings/Notifications/NotificationCollectionViewTemplate', template : 'Settings/Notifications/NotificationCollectionViewTemplate',
ui : {"addCard" : '.x-add-card'},
events : {"click .x-add-card" : '_openSchemaModal'}, ui : {
appendHtml : function(collectionView, itemView, index){ 'addCard' : '.x-add-card'
},
events : {
'click .x-add-card' : '_openSchemaModal'
},
appendHtml : function(collectionView, itemView, index) {
collectionView.ui.addCard.parent('li').before(itemView.el); collectionView.ui.addCard.parent('li').before(itemView.el);
}, },
_openSchemaModal : function(){
_openSchemaModal : function() {
SchemaModal.open(this.collection); SchemaModal.open(this.collection);
} }
}); });

View File

@ -3,13 +3,18 @@ var Marionette = require('marionette');
var EditView = require('./Edit/NotificationEditView'); var EditView = require('./Edit/NotificationEditView');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/Notifications/NotificationItemViewTemplate', template : 'Settings/Notifications/NotificationItemViewTemplate',
tagName : 'li', tagName : 'li',
events : {"click" : '_edit'},
initialize : function(){ events : {
'click' : '_edit'
},
initialize : function() {
this.listenTo(this.model, 'sync', this.render); this.listenTo(this.model, 'sync', this.render);
}, },
_edit : function(){
_edit : function() {
var view = new EditView({ var view = new EditView({
model : this.model, model : this.model,
targetCollection : this.model.collection targetCollection : this.model.collection

View File

@ -1,20 +1,19 @@
var Handlebars = require('handlebars'); var Handlebars = require('handlebars');
var _ = require('underscore'); var _ = require('underscore');
module.exports = (function(){ Handlebars.registerHelper('allowedLabeler', function() {
Handlebars.registerHelper('allowedLabeler', function(){ var ret = '';
var ret = ''; var cutoff = this.cutoff;
var cutoff = this.cutoff;
_.each(this.items, function(item){ _.each(this.items, function(item) {
if(item.allowed) { if (item.allowed) {
if(item.quality.id === cutoff.id) { if (item.quality.id === cutoff.id) {
ret += '<li><span class="label label-info" title="Cutoff">' + item.quality.name + '</span></li>'; ret += '<li><span class="label label-info" title="Cutoff">' + item.quality.name + '</span></li>';
} } else {
else { ret += '<li><span class="label label-default">' + item.quality.name + '</span></li>';
ret += '<li><span class="label label-default">' + item.quality.name + '</span></li>';
}
} }
}); }
return new Handlebars.SafeString(ret);
}); });
}).call(this);
return new Handlebars.SafeString(ret);
});

View File

@ -4,9 +4,10 @@ var DelayProfileItemView = require('./DelayProfileItemView');
module.exports = BackboneSortableCollectionView.extend({ module.exports = BackboneSortableCollectionView.extend({
className : 'delay-profiles', className : 'delay-profiles',
modelView : DelayProfileItemView, modelView : DelayProfileItemView,
events : {
"click li, td" : '_listItem_onMousedown', events : {
"dblclick li, td" : '_listItem_onDoubleClick', 'click li, td' : '_listItem_onMousedown',
"keydown" : '_onKeydown' 'dblclick li, td' : '_listItem_onDoubleClick',
'keydown' : '_onKeydown'
} }
}); });

View File

@ -4,13 +4,18 @@ var Marionette = require('marionette');
var EditView = require('./Edit/DelayProfileEditView'); var EditView = require('./Edit/DelayProfileEditView');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/Profile/Delay/DelayProfileItemViewTemplate', template : 'Settings/Profile/Delay/DelayProfileItemViewTemplate',
className : 'row', className : 'row',
events : {"click .x-edit" : '_edit'},
initialize : function(){ events : {
'click .x-edit' : '_edit'
},
initialize : function() {
this.listenTo(this.model, 'sync', this.render); this.listenTo(this.model, 'sync', this.render);
}, },
_edit : function(){
_edit : function() {
var view = new EditView({ var view = new EditView({
model : this.model, model : this.model,
targetCollection : this.model.collection targetCollection : this.model.collection

View File

@ -1,4 +1,4 @@
var $ = require('jquery'); var $ = require('jquery');
var _ = require('underscore'); var _ = require('underscore');
var vent = require('vent'); var vent = require('vent');
var AppLayout = require('../../../AppLayout'); var AppLayout = require('../../../AppLayout');
@ -9,45 +9,67 @@ var EditView = require('./Edit/DelayProfileEditView');
var Model = require('./DelayProfileModel'); var Model = require('./DelayProfileModel');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Settings/Profile/Delay/DelayProfileLayoutTemplate', template : 'Settings/Profile/Delay/DelayProfileLayoutTemplate',
regions : {delayProfiles : '.x-rows'},
events : {"click .x-add" : '_add'}, regions : {
initialize : function(options){ delayProfiles : '.x-rows'
},
events : {
'click .x-add' : '_add'
},
initialize : function(options) {
this.collection = options.collection; this.collection = options.collection;
this._updateOrderedCollection(); this._updateOrderedCollection();
this.listenTo(this.collection, 'sync', this._updateOrderedCollection); this.listenTo(this.collection, 'sync', this._updateOrderedCollection);
this.listenTo(this.collection, 'add', this._updateOrderedCollection); this.listenTo(this.collection, 'add', this._updateOrderedCollection);
this.listenTo(this.collection, 'remove', function(){ this.listenTo(this.collection, 'remove', function() {
this.collection.fetch(); this.collection.fetch();
}); });
}, },
onRender : function(){
onRender : function() {
this.sortableListView = new DelayProfileCollectionView({ this.sortableListView = new DelayProfileCollectionView({
sortable : true, sortable : true,
collection : this.orderedCollection, collection : this.orderedCollection,
sortableOptions : {handle : '.x-drag-handle'},
sortableModelsFilter : function(model){ sortableOptions : {
handle : '.x-drag-handle'
},
sortableModelsFilter : function(model) {
return model.get('id') !== 1; return model.get('id') !== 1;
} }
}); });
this.delayProfiles.show(this.sortableListView); this.delayProfiles.show(this.sortableListView);
this.listenTo(this.sortableListView, 'sortStop', this._updateOrder); this.listenTo(this.sortableListView, 'sortStop', this._updateOrder);
}, },
_updateOrder : function(){
_updateOrder : function() {
var self = this; var self = this;
this.collection.forEach(function(model){
if(model.get('id') === 1) { this.collection.forEach(function(model) {
if (model.get('id') === 1) {
return; return;
} }
var orderedModel = self.orderedCollection.get(model); var orderedModel = self.orderedCollection.get(model);
var order = self.orderedCollection.indexOf(orderedModel) + 1; var order = self.orderedCollection.indexOf(orderedModel) + 1;
if(model.get('order') !== order) {
if (model.get('order') !== order) {
model.set('order', order); model.set('order', order);
model.save(); model.save();
} }
}); });
}, },
_add : function(){
_add : function() {
var model = new Model({ var model = new Model({
enableUsenet : true, enableUsenet : true,
enableTorrent : true, enableTorrent : true,
@ -57,18 +79,22 @@ module.exports = Marionette.Layout.extend({
order : this.collection.length, order : this.collection.length,
tags : [] tags : []
}); });
model.collection = this.collection; model.collection = this.collection;
var view = new EditView({ var view = new EditView({
model : model, model : model,
targetCollection : this.collection targetCollection : this.collection
}); });
AppLayout.modalRegion.show(view); AppLayout.modalRegion.show(view);
}, },
_updateOrderedCollection : function(){
if(!this.orderedCollection) { _updateOrderedCollection : function() {
if (!this.orderedCollection) {
this.orderedCollection = new Backbone.Collection(); this.orderedCollection = new Backbone.Collection();
} }
this.orderedCollection.reset(_.sortBy(this.collection.models, function(model){
this.orderedCollection.reset(_.sortBy(this.collection.models, function(model) {
return model.get('order'); return model.get('order');
})); }));
} }

View File

@ -3,12 +3,17 @@ var Marionette = require('marionette');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/Profile/Delay/Delete/DelayProfileDeleteViewTemplate', template : 'Settings/Profile/Delay/Delete/DelayProfileDeleteViewTemplate',
events : {"click .x-confirm-delete" : '_delete'},
_delete : function(){ events : {
'click .x-confirm-delete' : '_delete'
},
_delete : function() {
var collection = this.model.collection; var collection = this.model.collection;
this.model.destroy({ this.model.destroy({
wait : true, wait : true,
success : function(){ success : function() {
vent.trigger(vent.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
} }
}); });

View File

@ -1,4 +1,4 @@
var vent = require('vent'); var vent = require('vent');
var AppLayout = require('../../../../AppLayout'); var AppLayout = require('../../../../AppLayout');
var Marionette = require('marionette'); var Marionette = require('marionette');
var DeleteView = require('../Delete/DelayProfileDeleteView'); var DeleteView = require('../Delete/DelayProfileDeleteView');
@ -8,93 +8,115 @@ var AsEditModalView = require('../../../../Mixins/AsEditModalView');
require('../../../../Mixins/TagInput'); require('../../../../Mixins/TagInput');
require('bootstrap'); require('bootstrap');
module.exports = (function(){ var view = Marionette.ItemView.extend({
var view = Marionette.ItemView.extend({ template : 'Settings/Profile/Delay/Edit/DelayProfileEditViewTemplate',
template : 'Settings/Profile/Delay/Edit/DelayProfileEditViewTemplate',
_deleteView : DeleteView, _deleteView : DeleteView,
ui : {
tags : '.x-tags', ui : {
usenetDelay : '.x-usenet-delay', tags : '.x-tags',
torrentDelay : '.x-torrent-delay', usenetDelay : '.x-usenet-delay',
protocol : '.x-protocol' torrentDelay : '.x-torrent-delay',
}, protocol : '.x-protocol'
events : {"change .x-protocol" : '_updateModel'}, },
initialize : function(options){
this.targetCollection = options.targetCollection; events : {
}, 'change .x-protocol' : '_updateModel'
onRender : function(){ },
if(this.model.id !== 1) {
this.ui.tags.tagInput({ initialize : function(options) {
model : this.model, this.targetCollection = options.targetCollection;
property : 'tags' },
});
} onRender : function() {
this._toggleControls(); if (this.model.id !== 1) {
}, this.ui.tags.tagInput({
_onAfterSave : function(){ model : this.model,
this.targetCollection.add(this.model, {merge : true}); property : 'tags'
vent.trigger(vent.Commands.CloseModalCommand); });
},
_updateModel : function(){
var protocol = this.ui.protocol.val();
if(protocol === 'preferUsenet') {
this.model.set({
enableUsenet : true,
enableTorrent : true,
preferredProtocol : 'usenet'
});
}
if(protocol === 'preferTorrent') {
this.model.set({
enableUsenet : true,
enableTorrent : true,
preferredProtocol : 'torrent'
});
}
if(protocol === 'onlyUsenet') {
this.model.set({
enableUsenet : true,
enableTorrent : false,
preferredProtocol : 'usenet'
});
}
if(protocol === 'onlyTorrent') {
this.model.set({
enableUsenet : false,
enableTorrent : true,
preferredProtocol : 'torrent'
});
}
this._toggleControls();
},
_toggleControls : function(){
var enableUsenet = this.model.get('enableUsenet');
var enableTorrent = this.model.get('enableTorrent');
var preferred = this.model.get('preferredProtocol');
if(preferred === 'usenet') {
this.ui.protocol.val('preferUsenet');
}
else {
this.ui.protocol.val('preferTorrent');
}
if(enableUsenet) {
this.ui.usenetDelay.show();
}
else {
this.ui.protocol.val('onlyTorrent');
this.ui.usenetDelay.hide();
}
if(enableTorrent) {
this.ui.torrentDelay.show();
}
else {
this.ui.protocol.val('onlyUsenet');
this.ui.torrentDelay.hide();
}
} }
});
AsModelBoundView.call(view); this._toggleControls();
AsValidatedView.call(view); },
AsEditModalView.call(view);
return view; _onAfterSave : function() {
}).call(this); this.targetCollection.add(this.model, { merge : true });
vent.trigger(vent.Commands.CloseModalCommand);
},
_updateModel : function() {
var protocol = this.ui.protocol.val();
if (protocol === 'preferUsenet') {
this.model.set({
enableUsenet : true,
enableTorrent : true,
preferredProtocol : 'usenet'
});
}
if (protocol === 'preferTorrent') {
this.model.set({
enableUsenet : true,
enableTorrent : true,
preferredProtocol : 'torrent'
});
}
if (protocol === 'onlyUsenet') {
this.model.set({
enableUsenet : true,
enableTorrent : false,
preferredProtocol : 'usenet'
});
}
if (protocol === 'onlyTorrent') {
this.model.set({
enableUsenet : false,
enableTorrent : true,
preferredProtocol : 'torrent'
});
}
this._toggleControls();
},
_toggleControls : function() {
var enableUsenet = this.model.get('enableUsenet');
var enableTorrent = this.model.get('enableTorrent');
var preferred = this.model.get('preferredProtocol');
if (preferred === 'usenet') {
this.ui.protocol.val('preferUsenet');
}
else {
this.ui.protocol.val('preferTorrent');
}
if (enableUsenet) {
this.ui.usenetDelay.show();
}
else {
this.ui.protocol.val('onlyTorrent');
this.ui.usenetDelay.hide();
}
if (enableTorrent) {
this.ui.torrentDelay.show();
}
else {
this.ui.protocol.val('onlyUsenet');
this.ui.torrentDelay.hide();
}
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
AsEditModalView.call(view);
module.exports = view;

View File

@ -2,10 +2,14 @@ var vent = require('vent');
var Marionette = require('marionette'); var Marionette = require('marionette');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/Profile/DeleteProfileViewTemplate', template : 'Settings/Profile/DeleteProfileViewTemplate',
events : {"click .x-confirm-delete" : '_removeProfile'},
_removeProfile : function(){ events : {
this.model.destroy({wait : true}).done(function(){ 'click .x-confirm-delete' : '_removeProfile'
},
_removeProfile : function() {
this.model.destroy({ wait : true }).done(function() {
vent.trigger(vent.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
}); });
} }

View File

@ -1,3 +1,5 @@
var Marionette = require('marionette'); var Marionette = require('marionette');
module.exports = Marionette.ItemView.extend({template : 'Settings/Profile/Edit/EditProfileItemViewTemplate'}); module.exports = Marionette.ItemView.extend({
template : 'Settings/Profile/Edit/EditProfileItemViewTemplate'
});

View File

@ -1,4 +1,4 @@
var _ = require('underscore'); var _ = require('underscore');
var vent = require('vent'); var vent = require('vent');
var AppLayout = require('../../../AppLayout'); var AppLayout = require('../../../AppLayout');
var Marionette = require('marionette'); var Marionette = require('marionette');
@ -11,85 +11,107 @@ var SeriesCollection = require('../../../Series/SeriesCollection');
var Config = require('../../../Config'); var Config = require('../../../Config');
var AsEditModalView = require('../../../Mixins/AsEditModalView'); var AsEditModalView = require('../../../Mixins/AsEditModalView');
module.exports = (function(){ var view = Marionette.Layout.extend({
var view = Marionette.Layout.extend({ template : 'Settings/Profile/Edit/EditProfileLayoutTemplate',
template : 'Settings/Profile/Edit/EditProfileLayoutTemplate',
regions : { regions : {
fields : '#x-fields', fields : '#x-fields',
qualities : '#x-qualities' qualities : '#x-qualities'
}, },
ui : {deleteButton : '.x-delete'},
_deleteView : DeleteView, ui : {
initialize : function(options){ deleteButton : '.x-delete'
this.profileCollection = options.profileCollection; },
this.itemsCollection = new Backbone.Collection(_.toArray(this.model.get('items')).reverse());
this.listenTo(SeriesCollection, 'all', this._updateDisableStatus); _deleteView : DeleteView,
},
onRender : function(){ initialize : function(options) {
this._updateDisableStatus(); this.profileCollection = options.profileCollection;
}, this.itemsCollection = new Backbone.Collection(_.toArray(this.model.get('items')).reverse());
onShow : function(){ this.listenTo(SeriesCollection, 'all', this._updateDisableStatus);
this.fieldsView = new EditProfileView({model : this.model}); },
this._showFieldsView();
var advancedShown = Config.getValueBoolean(Config.Keys.AdvancedSettings, false); onRender : function() {
this.sortableListView = new QualitySortableCollectionView({ this._updateDisableStatus();
selectable : true, },
selectMultiple : true,
clickToSelect : true, onShow : function() {
clickToToggle : true, this.fieldsView = new EditProfileView({ model : this.model });
sortable : advancedShown, this._showFieldsView();
sortableOptions : {handle : '.x-drag-handle'}, var advancedShown = Config.getValueBoolean(Config.Keys.AdvancedSettings, false);
visibleModelsFilter : function(model){
return model.get('quality').id !== 0 || advancedShown; this.sortableListView = new QualitySortableCollectionView({
}, selectable : true,
collection : this.itemsCollection, selectMultiple : true,
model : this.model clickToSelect : true,
}); clickToToggle : true,
this.sortableListView.setSelectedModels(this.itemsCollection.filter(function(item){ sortable : advancedShown,
return item.get('allowed') === true;
})); sortableOptions : {
this.qualities.show(this.sortableListView); handle : '.x-drag-handle'
this.listenTo(this.sortableListView, 'selectionChanged', this._selectionChanged); },
this.listenTo(this.sortableListView, 'sortStop', this._updateModel);
}, visibleModelsFilter : function(model) {
_onBeforeSave : function(){ return model.get('quality').id !== 0 || advancedShown;
var cutoff = this.fieldsView.getCutoff(); },
this.model.set('cutoff', cutoff);
}, collection : this.itemsCollection,
_onAfterSave : function(){ model : this.model
this.profileCollection.add(this.model, {merge : true}); });
vent.trigger(vent.Commands.CloseModalCommand);
}, this.sortableListView.setSelectedModels(this.itemsCollection.filter(function(item) {
_selectionChanged : function(newSelectedModels, oldSelectedModels){ return item.get('allowed') === true;
var addedModels = _.difference(newSelectedModels, oldSelectedModels); }));
var removeModels = _.difference(oldSelectedModels, newSelectedModels); this.qualities.show(this.sortableListView);
_.each(removeModels, function(item){
item.set('allowed', false); this.listenTo(this.sortableListView, 'selectionChanged', this._selectionChanged);
}); this.listenTo(this.sortableListView, 'sortStop', this._updateModel);
_.each(addedModels, function(item){ },
item.set('allowed', true);
}); _onBeforeSave : function() {
this._updateModel(); var cutoff = this.fieldsView.getCutoff();
}, this.model.set('cutoff', cutoff);
_updateModel : function(){ },
this.model.set('items', this.itemsCollection.toJSON().reverse());
this._showFieldsView(); _onAfterSave : function() {
}, this.profileCollection.add(this.model, { merge : true });
_showFieldsView : function(){ vent.trigger(vent.Commands.CloseModalCommand);
this.fields.show(this.fieldsView); },
},
_updateDisableStatus : function(){ _selectionChanged : function(newSelectedModels, oldSelectedModels) {
if(this._isQualityInUse()) { var addedModels = _.difference(newSelectedModels, oldSelectedModels);
this.ui.deleteButton.addClass('disabled'); var removeModels = _.difference(oldSelectedModels, newSelectedModels);
this.ui.deleteButton.attr('title', 'Can\'t delete a profile that is attached to a series.');
} _.each(removeModels, function(item) {
else { item.set('allowed', false);
this.ui.deleteButton.removeClass('disabled'); });
} _.each(addedModels, function(item) {
}, item.set('allowed', true);
_isQualityInUse : function(){ });
return SeriesCollection.where({"profileId" : this.model.id}).length !== 0; this._updateModel();
},
_updateModel : function() {
this.model.set('items', this.itemsCollection.toJSON().reverse());
this._showFieldsView();
},
_showFieldsView : function() {
this.fields.show(this.fieldsView);
},
_updateDisableStatus : function() {
if (this._isQualityInUse()) {
this.ui.deleteButton.addClass('disabled');
this.ui.deleteButton.attr('title', 'Can\'t delete a profile that is attached to a series.');
} else {
this.ui.deleteButton.removeClass('disabled');
} }
}); },
return AsEditModalView.call(view);
}).call(this); _isQualityInUse : function() {
return SeriesCollection.where({ 'profileId' : this.model.id }).length !== 0;
}
});
module.exports = AsEditModalView.call(view);

View File

@ -5,18 +5,24 @@ var Config = require('../../../Config');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView'); var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView'); var AsValidatedView = require('../../../Mixins/AsValidatedView');
module.exports = (function(){ var view = Marionette.ItemView.extend({
var view = Marionette.ItemView.extend({ template : 'Settings/Profile/Edit/EditProfileViewTemplate',
template : 'Settings/Profile/Edit/EditProfileViewTemplate',
ui : {cutoff : '.x-cutoff'}, ui : { cutoff : '.x-cutoff' },
templateHelpers : function(){
return {languages : LanguageCollection.toJSON()}; templateHelpers : function() {
}, return {
getCutoff : function(){ languages : LanguageCollection.toJSON()
var self = this; };
return _.findWhere(_.pluck(this.model.get('items'), 'quality'), {id : parseInt(self.ui.cutoff.val(), 10)}); },
}
}); getCutoff : function() {
AsValidatedView.call(view); var self = this;
return AsModelBoundView.call(view);
}).call(this); return _.findWhere(_.pluck(this.model.get('items'), 'quality'), { id : parseInt(self.ui.cutoff.val(), 10) });
}
});
AsValidatedView.call(view);
module.exports = AsModelBoundView.call(view);

View File

@ -2,12 +2,16 @@ var BackboneSortableCollectionView = require('backbone.collectionview');
var EditProfileItemView = require('./EditProfileItemView'); var EditProfileItemView = require('./EditProfileItemView');
module.exports = BackboneSortableCollectionView.extend({ module.exports = BackboneSortableCollectionView.extend({
className : 'qualities', className : 'qualities',
modelView : EditProfileItemView, modelView : EditProfileItemView,
attributes : {"validation-name" : 'items'},
events : { attributes : {
"click li, td" : '_listItem_onMousedown', 'validation-name' : 'items'
"dblclick li, td" : '_listItem_onDoubleClick', },
"keydown" : '_onKeydown'
events : {
'click li, td' : '_listItem_onMousedown',
'dblclick li, td' : '_listItem_onDoubleClick',
'keydown' : '_onKeydown'
} }
}); });

View File

@ -1,12 +1,12 @@
var Backbone = require('backbone'); var Backbone = require('backbone');
var LanguageModel = require('./LanguageModel'); var LanguageModel = require('./LanguageModel');
module.exports = (function(){ var LanuageCollection = Backbone.Collection.extend({
var LanuageCollection = Backbone.Collection.extend({ model : LanguageModel,
model : LanguageModel, url : window.NzbDrone.ApiRoot + '/language'
url : window.NzbDrone.ApiRoot + '/language' });
});
var languages = new LanuageCollection(); var languages = new LanuageCollection();
languages.fetch(); languages.fetch();
return languages;
}).call(this); module.exports = languages;

View File

@ -2,13 +2,14 @@ var _ = require('underscore');
var Handlebars = require('handlebars'); var Handlebars = require('handlebars');
var LanguageCollection = require('./Language/LanguageCollection'); var LanguageCollection = require('./Language/LanguageCollection');
module.exports = (function(){ Handlebars.registerHelper('languageLabel', function() {
Handlebars.registerHelper('languageLabel', function(){ var wantedLanguage = this.language;
var wantedLanguage = this.language;
var language = LanguageCollection.find(function(lang){ var language = LanguageCollection.find(function(lang) {
return lang.get('nameLower') === wantedLanguage; return lang.get('nameLower') === wantedLanguage;
});
var result = '<span class="label label-primary">' + language.get('name') + '</span>';
return new Handlebars.SafeString(result);
}); });
}).call(this);
var result = '<span class="label label-primary">' + language.get('name') + '</span>';
return new Handlebars.SafeString(result);
});

View File

@ -9,16 +9,24 @@ module.exports = Marionette.CompositeView.extend({
itemView : ProfileView, itemView : ProfileView,
itemViewContainer : '.profiles', itemViewContainer : '.profiles',
template : 'Settings/Profile/ProfileCollectionTemplate', template : 'Settings/Profile/ProfileCollectionTemplate',
ui : {"addCard" : '.x-add-card'},
events : {"click .x-add-card" : '_addProfile'}, ui : {
appendHtml : function(collectionView, itemView, index){ 'addCard' : '.x-add-card'
},
events : {
'click .x-add-card' : '_addProfile'
},
appendHtml : function(collectionView, itemView, index) {
collectionView.ui.addCard.parent('li').before(itemView.el); collectionView.ui.addCard.parent('li').before(itemView.el);
}, },
_addProfile : function(){
_addProfile : function() {
var self = this; var self = this;
var schemaCollection = new ProfileCollection(); var schemaCollection = new ProfileCollection();
schemaCollection.fetch({ schemaCollection.fetch({
success : function(collection){ success : function(collection) {
var model = _.first(collection.models); var model = _.first(collection.models);
model.set('id', undefined); model.set('id', undefined);
model.set('name', ''); model.set('name', '');
@ -27,6 +35,7 @@ module.exports = Marionette.CompositeView.extend({
model : model, model : model,
profileCollection : self.collection profileCollection : self.collection
}); });
AppLayout.modalRegion.show(view); AppLayout.modalRegion.show(view);
} }
}); });

View File

@ -6,19 +6,23 @@ var DelayProfileCollection = require('./Delay/DelayProfileCollection');
var LanguageCollection = require('./Language/LanguageCollection'); var LanguageCollection = require('./Language/LanguageCollection');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Settings/Profile/ProfileLayoutTemplate', template : 'Settings/Profile/ProfileLayoutTemplate',
regions : {
regions : {
profile : '#profile', profile : '#profile',
delayProfile : '#delay-profile' delayProfile : '#delay-profile'
}, },
initialize : function(options){
initialize : function(options) {
this.settings = options.settings; this.settings = options.settings;
ProfileCollection.fetch(); ProfileCollection.fetch();
this.delayProfileCollection = new DelayProfileCollection(); this.delayProfileCollection = new DelayProfileCollection();
this.delayProfileCollection.fetch(); this.delayProfileCollection.fetch();
}, },
onShow : function(){
this.profile.show(new ProfileCollectionView({collection : ProfileCollection})); onShow : function() {
this.delayProfile.show(new DelayProfileLayout({collection : this.delayProfileCollection})); this.profile.show(new ProfileCollectionView({ collection : ProfileCollection }));
this.delayProfile.show(new DelayProfileLayout({ collection : this.delayProfileCollection }));
} }
}); });

View File

@ -6,25 +6,30 @@ require('./AllowedLabeler');
require('./LanguageLabel'); require('./LanguageLabel');
require('bootstrap'); require('bootstrap');
module.exports = (function(){ var view = Marionette.ItemView.extend({
var view = Marionette.ItemView.extend({ template : 'Settings/Profile/ProfileViewTemplate',
template : 'Settings/Profile/ProfileViewTemplate', tagName : 'li',
tagName : 'li',
ui : { ui : {
"progressbar" : '.progress .bar', "progressbar" : '.progress .bar',
"deleteButton" : '.x-delete' "deleteButton" : '.x-delete'
}, },
events : {"click" : '_editProfile'},
initialize : function(){ events : {
this.listenTo(this.model, 'sync', this.render); 'click' : '_editProfile'
}, },
_editProfile : function(){
var view = new EditProfileView({ initialize : function() {
model : this.model, this.listenTo(this.model, 'sync', this.render);
profileCollection : this.model.collection },
});
AppLayout.modalRegion.show(view); _editProfile : function() {
} var view = new EditProfileView({
}); model : this.model,
return AsModelBoundView.call(view); profileCollection : this.model.collection
}).call(this); });
AppLayout.modalRegion.show(view);
}
});
module.exports = AsModelBoundView.call(view);

View File

@ -3,24 +3,31 @@ var DeepModel = require('backbone.deepmodel');
var Messenger = require('../Shared/Messenger'); var Messenger = require('../Shared/Messenger');
module.exports = DeepModel.DeepModel.extend({ module.exports = DeepModel.DeepModel.extend({
test : function(){ test : function() {
var self = this; var self = this;
this.trigger('validation:sync'); this.trigger('validation:sync');
var params = {}; var params = {};
params.url = this.collection.url + '/test'; params.url = this.collection.url + '/test';
params.contentType = 'application/json'; params.contentType = 'application/json';
params.data = JSON.stringify(this.toJSON()); params.data = JSON.stringify(this.toJSON());
params.type = 'POST'; params.type = 'POST';
params.isValidatedCall = true; params.isValidatedCall = true;
var promise = $.ajax(params); var promise = $.ajax(params);
Messenger.monitor({ Messenger.monitor({
promise : promise, promise : promise,
successMessage : 'Testing \'{0}\' completed'.format(this.get('name')), successMessage : 'Testing \'{0}\' completed'.format(this.get('name')),
errorMessage : 'Testing \'{0}\' failed'.format(this.get('name')) errorMessage : 'Testing \'{0}\' failed'.format(this.get('name'))
}); });
promise.fail(function(response){
promise.fail(function(response) {
self.trigger('validation:failed', response); self.trigger('validation:failed', response);
}); });
return promise; return promise;
} }
}); });

View File

@ -2,7 +2,9 @@ var Marionette = require('marionette');
var QualityDefinitionItemView = require('./QualityDefinitionItemView'); var QualityDefinitionItemView = require('./QualityDefinitionItemView');
module.exports = Marionette.CompositeView.extend({ module.exports = Marionette.CompositeView.extend({
template : 'Settings/Quality/Definition/QualityDefinitionCollectionTemplate', template : 'Settings/Quality/Definition/QualityDefinitionCollectionTemplate',
itemViewContainer : '.x-rows', itemViewContainer : '.x-rows',
itemView : QualityDefinitionItemView
itemView : QualityDefinitionItemView
}); });

View File

@ -3,62 +3,87 @@ var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var fileSize = require('filesize'); var fileSize = require('filesize');
require('jquery-ui'); require('jquery-ui');
module.exports = (function(){ var view = Marionette.ItemView.extend({
var view = Marionette.ItemView.extend({ template : 'Settings/Quality/Definition/QualityDefinitionItemViewTemplate',
template : 'Settings/Quality/Definition/QualityDefinitionItemViewTemplate', className : 'row',
className : 'row',
ui : { ui : {
sizeSlider : '.x-slider', sizeSlider : '.x-slider',
thirtyMinuteMinSize : '.x-min-thirty', thirtyMinuteMinSize : '.x-min-thirty',
sixtyMinuteMinSize : '.x-min-sixty', sixtyMinuteMinSize : '.x-min-sixty',
thirtyMinuteMaxSize : '.x-max-thirty', thirtyMinuteMaxSize : '.x-max-thirty',
sixtyMinuteMaxSize : '.x-max-sixty' sixtyMinuteMaxSize : '.x-max-sixty'
}, },
events : {"slide .x-slider" : '_updateSize'},
initialize : function(options){ events : {
this.profileCollection = options.profiles; 'slide .x-slider' : '_updateSize'
this.filesize = fileSize; },
},
onRender : function(){ initialize : function(options) {
if(this.model.get('quality').id === 0) { this.profileCollection = options.profiles;
this.$el.addClass('row advanced-setting'); this.filesize = fileSize;
} },
this.ui.sizeSlider.slider({
range : true, onRender : function() {
min : 0, if (this.model.get('quality').id === 0) {
max : 200, this.$el.addClass('row advanced-setting');
values : [this.model.get('minSize'), this.model.get('maxSize')]
});
this._changeSize();
},
_updateSize : function(event, ui){
this.model.set('minSize', ui.values[0]);
this.model.set('maxSize', ui.values[1]);
this._changeSize();
},
_changeSize : function(){
var minSize = this.model.get('minSize');
var maxSize = this.model.get('maxSize');
{
var minBytes = minSize * 1024 * 1024;
var minThirty = fileSize(minBytes * 30, 1, false);
var minSixty = fileSize(minBytes * 60, 1, false);
this.ui.thirtyMinuteMinSize.html(minThirty);
this.ui.sixtyMinuteMinSize.html(minSixty);
}
{
if(maxSize === 0) {
this.ui.thirtyMinuteMaxSize.html('Unlimited');
this.ui.sixtyMinuteMaxSize.html('Unlimited');
return;
}
var maxBytes = maxSize * 1024 * 1024;
var maxThirty = fileSize(maxBytes * 30, 1, false);
var maxSixty = fileSize(maxBytes * 60, 1, false);
this.ui.thirtyMinuteMaxSize.html(maxThirty);
this.ui.sixtyMinuteMaxSize.html(maxSixty);
}
} }
});
return AsModelBoundView.call(view); this.ui.sizeSlider.slider({
}).call(this); range : true,
min : 0,
max : 200,
values : [
this.model.get('minSize'),
this.model.get('maxSize')
]
});
this._changeSize();
},
_updateSize : function(event, ui) {
this.model.set('minSize', ui.values[0]);
this.model.set('maxSize', ui.values[1]);
this._changeSize();
},
_changeSize : function() {
var minSize = this.model.get('minSize');
var maxSize = this.model.get('maxSize');
{
var minBytes = minSize * 1024 * 1024;
var minThirty = fileSize(minBytes * 30, 1, false);
var minSixty = fileSize(minBytes * 60, 1, false);
this.ui.thirtyMinuteMinSize.html(minThirty);
this.ui.sixtyMinuteMinSize.html(minSixty);
}
{
if (maxSize === 0) {
this.ui.thirtyMinuteMaxSize.html('Unlimited');
this.ui.sixtyMinuteMaxSize.html('Unlimited');
return;
}
var maxBytes = maxSize * 1024 * 1024;
var maxThirty = fileSize(maxBytes * 30, 1, false);
var maxSixty = fileSize(maxBytes * 60, 1, false);
this.ui.thirtyMinuteMaxSize.html(maxThirty);
this.ui.sixtyMinuteMaxSize.html(maxSixty);
}
/*if (parseInt(maxSize, 10) === 0) {
thirty = 'No Limit';
sixty = 'No Limit';
}*/
}
});
view = AsModelBoundView.call(view);
module.exports = view;

View File

@ -3,14 +3,19 @@ var QualityDefinitionCollection = require('../../Quality/QualityDefinitionCollec
var QualityDefinitionCollectionView = require('./Definition/QualityDefinitionCollectionView'); var QualityDefinitionCollectionView = require('./Definition/QualityDefinitionCollectionView');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Settings/Quality/QualityLayoutTemplate', template : 'Settings/Quality/QualityLayoutTemplate',
regions : {qualityDefinition : '#quality-definition'},
initialize : function(options){ regions : {
qualityDefinition : '#quality-definition'
},
initialize : function(options) {
this.settings = options.settings; this.settings = options.settings;
this.qualityDefinitionCollection = new QualityDefinitionCollection(); this.qualityDefinitionCollection = new QualityDefinitionCollection();
this.qualityDefinitionCollection.fetch(); this.qualityDefinitionCollection.fetch();
}, },
onShow : function(){
this.qualityDefinition.show(new QualityDefinitionCollectionView({collection : this.qualityDefinitionCollection})); onShow : function() {
this.qualityDefinition.show(new QualityDefinitionCollectionView({ collection : this.qualityDefinitionCollection }));
} }
}); });

View File

@ -24,8 +24,9 @@ var LoadingView = require('../Shared/LoadingView');
var Config = require('../Config'); var Config = require('../Config');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Settings/SettingsLayoutTemplate', template : 'Settings/SettingsLayoutTemplate',
regions : {
regions : {
mediaManagement : '#media-management', mediaManagement : '#media-management',
profiles : '#profiles', profiles : '#profiles',
quality : '#quality', quality : '#quality',
@ -37,7 +38,8 @@ module.exports = Marionette.Layout.extend({
uiRegion : '#ui', uiRegion : '#ui',
loading : '#loading-region' loading : '#loading-region'
}, },
ui : {
ui : {
mediaManagementTab : '.x-media-management-tab', mediaManagementTab : '.x-media-management-tab',
profilesTab : '.x-profiles-tab', profilesTab : '.x-profiles-tab',
qualityTab : '.x-quality-tab', qualityTab : '.x-quality-tab',
@ -49,28 +51,33 @@ module.exports = Marionette.Layout.extend({
uiTab : '.x-ui-tab', uiTab : '.x-ui-tab',
advancedSettings : '.x-advanced-settings' advancedSettings : '.x-advanced-settings'
}, },
events : {
"click .x-media-management-tab" : '_showMediaManagement', events : {
"click .x-profiles-tab" : '_showProfiles', 'click .x-media-management-tab' : '_showMediaManagement',
"click .x-quality-tab" : '_showQuality', 'click .x-profiles-tab' : '_showProfiles',
"click .x-indexers-tab" : '_showIndexers', 'click .x-quality-tab' : '_showQuality',
"click .x-download-client-tab" : '_showDownloadClient', 'click .x-indexers-tab' : '_showIndexers',
"click .x-notifications-tab" : '_showNotifications', 'click .x-download-client-tab' : '_showDownloadClient',
"click .x-metadata-tab" : '_showMetadata', 'click .x-notifications-tab' : '_showNotifications',
"click .x-general-tab" : '_showGeneral', 'click .x-metadata-tab' : '_showMetadata',
"click .x-ui-tab" : '_showUi', 'click .x-general-tab' : '_showGeneral',
"click .x-save-settings" : '_save', 'click .x-ui-tab' : '_showUi',
"change .x-advanced-settings" : '_toggleAdvancedSettings' 'click .x-save-settings' : '_save',
'change .x-advanced-settings' : '_toggleAdvancedSettings'
}, },
initialize : function(options){
if(options.action) { initialize : function(options) {
if (options.action) {
this.action = options.action.toLowerCase(); this.action = options.action.toLowerCase();
} }
this.listenTo(vent, vent.Hotkeys.SaveSettings, this._save); this.listenTo(vent, vent.Hotkeys.SaveSettings, this._save);
}, },
onRender : function(){
onRender : function() {
this.loading.show(new LoadingView()); this.loading.show(new LoadingView());
var self = this; var self = this;
this.mediaManagementSettings = new MediaManagementSettingsModel(); this.mediaManagementSettings = new MediaManagementSettingsModel();
this.namingSettings = new NamingModel(); this.namingSettings = new NamingModel();
this.indexerSettings = new IndexerSettingsModel(); this.indexerSettings = new IndexerSettingsModel();
@ -78,26 +85,29 @@ module.exports = Marionette.Layout.extend({
this.notificationCollection = new NotificationCollection(); this.notificationCollection = new NotificationCollection();
this.generalSettings = new GeneralSettingsModel(); this.generalSettings = new GeneralSettingsModel();
this.uiSettings = new UiSettingsModel(); this.uiSettings = new UiSettingsModel();
Backbone.$.when(this.mediaManagementSettings.fetch(), this.namingSettings.fetch(), this.indexerSettings.fetch(), this.downloadClientSettings.fetch(), this.notificationCollection.fetch(), this.generalSettings.fetch(), this.uiSettings.fetch()).done(function(){ Backbone.$.when(this.mediaManagementSettings.fetch(), this.namingSettings.fetch(), this.indexerSettings.fetch(), this.downloadClientSettings.fetch(),
if(!self.isClosed) { this.notificationCollection.fetch(), this.generalSettings.fetch(), this.uiSettings.fetch()).done(function() {
self.loading.$el.hide(); if (!self.isClosed) {
self.mediaManagement.show(new MediaManagementLayout({ self.loading.$el.hide();
settings : self.mediaManagementSettings, self.mediaManagement.show(new MediaManagementLayout({
namingSettings : self.namingSettings settings : self.mediaManagementSettings,
})); namingSettings : self.namingSettings
self.profiles.show(new ProfileLayout()); }));
self.quality.show(new QualityLayout()); self.profiles.show(new ProfileLayout());
self.indexers.show(new IndexerLayout({model : self.indexerSettings})); self.quality.show(new QualityLayout());
self.downloadClient.show(new DownloadClientLayout({model : self.downloadClientSettings})); self.indexers.show(new IndexerLayout({ model : self.indexerSettings }));
self.notifications.show(new NotificationCollectionView({collection : self.notificationCollection})); self.downloadClient.show(new DownloadClientLayout({ model : self.downloadClientSettings }));
self.metadata.show(new MetadataLayout()); self.notifications.show(new NotificationCollectionView({ collection : self.notificationCollection }));
self.general.show(new GeneralView({model : self.generalSettings})); self.metadata.show(new MetadataLayout());
self.uiRegion.show(new UiView({model : self.uiSettings})); self.general.show(new GeneralView({ model : self.generalSettings }));
} self.uiRegion.show(new UiView({ model : self.uiSettings }));
}); }
});
this._setAdvancedSettingsState(); this._setAdvancedSettingsState();
}, },
onShow : function(){
onShow : function() {
switch (this.action) { switch (this.action) {
case 'profiles': case 'profiles':
this._showProfiles(); this._showProfiles();
@ -130,92 +140,112 @@ module.exports = Marionette.Layout.extend({
this._showMediaManagement(); this._showMediaManagement();
} }
}, },
_showMediaManagement : function(e){
if(e) { _showMediaManagement : function(e) {
if (e) {
e.preventDefault(); e.preventDefault();
} }
this.ui.mediaManagementTab.tab('show'); this.ui.mediaManagementTab.tab('show');
this._navigate('settings/mediamanagement'); this._navigate('settings/mediamanagement');
}, },
_showProfiles : function(e){
if(e) { _showProfiles : function(e) {
if (e) {
e.preventDefault(); e.preventDefault();
} }
this.ui.profilesTab.tab('show'); this.ui.profilesTab.tab('show');
this._navigate('settings/profiles'); this._navigate('settings/profiles');
}, },
_showQuality : function(e){
if(e) { _showQuality : function(e) {
if (e) {
e.preventDefault(); e.preventDefault();
} }
this.ui.qualityTab.tab('show'); this.ui.qualityTab.tab('show');
this._navigate('settings/quality'); this._navigate('settings/quality');
}, },
_showIndexers : function(e){
if(e) { _showIndexers : function(e) {
if (e) {
e.preventDefault(); e.preventDefault();
} }
this.ui.indexersTab.tab('show'); this.ui.indexersTab.tab('show');
this._navigate('settings/indexers'); this._navigate('settings/indexers');
}, },
_showDownloadClient : function(e){
if(e) { _showDownloadClient : function(e) {
if (e) {
e.preventDefault(); e.preventDefault();
} }
this.ui.downloadClientTab.tab('show'); this.ui.downloadClientTab.tab('show');
this._navigate('settings/downloadclient'); this._navigate('settings/downloadclient');
}, },
_showNotifications : function(e){
if(e) { _showNotifications : function(e) {
if (e) {
e.preventDefault(); e.preventDefault();
} }
this.ui.notificationsTab.tab('show'); this.ui.notificationsTab.tab('show');
this._navigate('settings/connect'); this._navigate('settings/connect');
}, },
_showMetadata : function(e){
if(e) { _showMetadata : function(e) {
if (e) {
e.preventDefault(); e.preventDefault();
} }
this.ui.metadataTab.tab('show'); this.ui.metadataTab.tab('show');
this._navigate('settings/metadata'); this._navigate('settings/metadata');
}, },
_showGeneral : function(e){
if(e) { _showGeneral : function(e) {
if (e) {
e.preventDefault(); e.preventDefault();
} }
this.ui.generalTab.tab('show'); this.ui.generalTab.tab('show');
this._navigate('settings/general'); this._navigate('settings/general');
}, },
_showUi : function(e){
if(e) { _showUi : function(e) {
if (e) {
e.preventDefault(); e.preventDefault();
} }
this.ui.uiTab.tab('show'); this.ui.uiTab.tab('show');
this._navigate('settings/ui'); this._navigate('settings/ui');
}, },
_navigate : function(route){
_navigate : function(route) {
Backbone.history.navigate(route, { Backbone.history.navigate(route, {
trigger : false, trigger : false,
replace : true replace : true
}); });
}, },
_save : function(){
_save : function() {
vent.trigger(vent.Commands.SaveSettings); vent.trigger(vent.Commands.SaveSettings);
}, },
_setAdvancedSettingsState : function(){
_setAdvancedSettingsState : function() {
var checked = Config.getValueBoolean(Config.Keys.AdvancedSettings); var checked = Config.getValueBoolean(Config.Keys.AdvancedSettings);
this.ui.advancedSettings.prop('checked', checked); this.ui.advancedSettings.prop('checked', checked);
if(checked) {
if (checked) {
$('body').addClass('show-advanced-settings'); $('body').addClass('show-advanced-settings');
} }
}, },
_toggleAdvancedSettings : function(){
_toggleAdvancedSettings : function() {
var checked = this.ui.advancedSettings.prop('checked'); var checked = this.ui.advancedSettings.prop('checked');
Config.setValue(Config.Keys.AdvancedSettings, checked); Config.setValue(Config.Keys.AdvancedSettings, checked);
if(checked) {
if (checked) {
$('body').addClass('show-advanced-settings'); $('body').addClass('show-advanced-settings');
} } else {
else {
$('body').removeClass('show-advanced-settings'); $('body').removeClass('show-advanced-settings');
} }
} }

View File

@ -3,27 +3,32 @@ var DeepModel = require('backbone.deepmodel');
var AsChangeTrackingModel = require('../Mixins/AsChangeTrackingModel'); var AsChangeTrackingModel = require('../Mixins/AsChangeTrackingModel');
var Messenger = require('../Shared/Messenger'); var Messenger = require('../Shared/Messenger');
module.exports = (function(){ var model = DeepModel.DeepModel.extend({
var model = DeepModel.DeepModel.extend({
initialize : function(){ initialize : function() {
this.listenTo(vent, vent.Commands.SaveSettings, this.saveSettings); this.listenTo(vent, vent.Commands.SaveSettings, this.saveSettings);
this.listenTo(this, 'destroy', this._stopListening); this.listenTo(this, 'destroy', this._stopListening);
}, },
saveSettings : function(){
if(!this.isSaved) { saveSettings : function() {
var savePromise = this.save(); if (!this.isSaved) {
Messenger.monitor({ var savePromise = this.save();
promise : savePromise,
successMessage : this.successMessage, Messenger.monitor({
errorMessage : this.errorMessage promise : savePromise,
}); successMessage : this.successMessage,
return savePromise; errorMessage : this.errorMessage
} });
return undefined;
}, return savePromise;
_stopListening : function(){
this.stopListening(vent, vent.Commands.SaveSettings);
} }
});
return AsChangeTrackingModel.call(model); return undefined;
}).call(this); },
_stopListening : function() {
this.stopListening(vent, vent.Commands.SaveSettings);
}
});
module.exports = AsChangeTrackingModel.call(model);

View File

@ -1,10 +1,13 @@
var Marionette = require('marionette'); var Marionette = require('marionette');
module.exports = Marionette.CompositeView.extend({ module.exports = Marionette.CompositeView.extend({
itemViewOptions : function(){ itemViewOptions : function() {
return {targetCollection : this.targetCollection || this.options.targetCollection}; return {
targetCollection : this.targetCollection || this.options.targetCollection
};
}, },
initialize : function(options){
initialize : function(options) {
this.targetCollection = options.targetCollection; this.targetCollection = options.targetCollection;
} }
}); });

View File

@ -5,10 +5,14 @@ module.exports = Marionette.CompositeView.extend({
itemViewContainer : '.item-list', itemViewContainer : '.item-list',
template : 'Settings/ThingyHeaderGroupViewTemplate', template : 'Settings/ThingyHeaderGroupViewTemplate',
tagName : 'div', tagName : 'div',
itemViewOptions : function(){
return {targetCollection : this.targetCollection || this.options.targetCollection}; itemViewOptions : function() {
return {
targetCollection : this.targetCollection || this.options.targetCollection
};
}, },
initialize : function(){
initialize : function() {
this.collection = new Backbone.Collection(this.model.get('collection')); this.collection = new Backbone.Collection(this.model.get('collection'));
} }
}); });

View File

@ -1,20 +1,22 @@
var vent = require('vent'); var vent = require('vent');
var Marionette = require('marionette'); var Marionette = require('marionette');
var UiSettingsModel = require('../../Shared/UiSettingsModel'); var UiSettingsModel = require('../../Shared/UiSettingsModel');
var AsModelBoundView = require('../../Mixins/AsModelBoundView'); var AsModelBoundView = require('../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../Mixins/AsValidatedView'); var AsValidatedView = require('../../Mixins/AsValidatedView');
module.exports = (function(){ var view = Marionette.ItemView.extend({
var view = Marionette.ItemView.extend({ template : 'Settings/UI/UiViewTemplate',
template : 'Settings/UI/UiViewTemplate',
initialize : function(){ initialize : function() {
this.listenTo(this.model, 'sync', this._reloadUiSettings); this.listenTo(this.model, 'sync', this._reloadUiSettings);
}, },
_reloadUiSettings : function(){
UiSettingsModel.fetch(); _reloadUiSettings : function() {
} UiSettingsModel.fetch();
}); }
AsModelBoundView.call(view); });
AsValidatedView.call(view);
return view; AsModelBoundView.call(view);
}).call(this); AsValidatedView.call(view);
module.exports = view;