1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-23 22:25:14 -04:00

New: Drone now uses the Download Client API to determine if a download is ready for import. (User configuration is required to replace the drone factory with this feature)

This commit is contained in:
Taloth Saldono
2014-04-19 17:09:22 +02:00
parent dcb586b937
commit 2035fe8578
196 changed files with 3961 additions and 2223 deletions
@@ -0,0 +1,14 @@
'use strict';
define([
'Settings/ThingyAddCollectionView',
'Settings/ThingyHeaderGroupView',
'Settings/Indexers/Add/IndexerAddItemView'
], function (ThingyAddCollectionView, ThingyHeaderGroupView, AddItemView) {
return ThingyAddCollectionView.extend({
itemView : ThingyHeaderGroupView.extend({ itemView: AddItemView }),
itemViewContainer: '.add-indexer .items',
template : 'Settings/Indexers/Add/IndexerAddCollectionViewTemplate'
});
});
@@ -0,0 +1,16 @@
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>Add Indexer</h3>
</div>
<div class="modal-body">
<div class="add-indexer add-thingies">
<ul class="items"></ul>
</div>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal">close</button>
</div>
</div>
</div>
@@ -0,0 +1,37 @@
'use strict';
define([
'jquery',
'AppLayout',
'marionette',
'Settings/Indexers/Edit/IndexerEditView'
], function ($, AppLayout, Marionette, EditView) {
return Marionette.ItemView.extend({
template: 'Settings/Indexers/Add/IndexerAddItemViewTemplate',
tagName : 'li',
events: {
'click': '_add'
},
initialize: function (options) {
this.targetCollection = options.targetCollection;
},
_add: function (e) {
if (this.$(e.target).hasClass('icon-info-sign')) {
return;
}
this.model.set({
id : undefined,
name : this.model.get('implementation'),
enable : true
});
var editView = new EditView({ model: this.model, targetCollection: this.targetCollection });
AppLayout.modalRegion.show(editView);
}
});
});
@@ -0,0 +1,6 @@
<div class="add-thingy">
{{implementation}}
{{#if link}}
<a href="{{link}}"><i class="icon-info-sign"/></a>
{{/if}}
</div>
@@ -0,0 +1,36 @@
'use strict';
define([
'underscore',
'AppLayout',
'backbone',
'Settings/Indexers/IndexerCollection',
'Settings/Indexers/Add/IndexerAddCollectionView'
], function (_, AppLayout, Backbone, SchemaCollection, AddCollectionView) {
return ({
open: function (collection) {
var schemaCollection = new SchemaCollection();
var originalUrl = schemaCollection.url;
schemaCollection.url = schemaCollection.url + '/schema';
schemaCollection.fetch();
schemaCollection.url = originalUrl;
var groupedSchemaCollection = new Backbone.Collection();
schemaCollection.on('sync', function() {
var groups = schemaCollection.groupBy(function(model, iterator) { return model.get('protocol'); });
var modelCollection = _.map(groups, function(values, key, list) {
return { 'header': key, collection: values };
});
groupedSchemaCollection.reset(modelCollection);
});
var view = new AddCollectionView({ collection: groupedSchemaCollection, targetCollection: collection });
AppLayout.modalRegion.show(view);
}
});
});
-11
View File
@@ -1,11 +0,0 @@
'use strict';
define(
[
'backbone',
'Settings/Indexers/Model',
], function (Backbone, IndexerModel) {
return Backbone.Collection.extend({
url : window.NzbDrone.ApiRoot + '/indexer',
model: IndexerModel
});
});
@@ -1,52 +0,0 @@
'use strict';
define(
[
'AppLayout',
'marionette',
'Settings/Indexers/ItemView',
'Settings/Indexers/EditView',
'Settings/Indexers/Collection',
'underscore'
], function (AppLayout, Marionette, IndexerItemView, IndexerEditView, IndexerCollection, _) {
return Marionette.CompositeView.extend({
itemView : IndexerItemView,
itemViewContainer: '#x-indexers',
template : 'Settings/Indexers/CollectionTemplate',
ui: {
'addCard': '.x-add-card'
},
events: {
'click .x-add-card': '_openSchemaModal'
},
appendHtml: function (collectionView, itemView, index) {
collectionView.ui.addCard.parent('li').before(itemView.el);
},
_openSchemaModal: function () {
var self = this;
var schemaCollection = new IndexerCollection();
var originalUrl = schemaCollection.url;
schemaCollection.url = schemaCollection.url + '/schema';
schemaCollection.fetch({
success: function (collection) {
collection.url = originalUrl;
var model = _.first(collection.models);
model.set({
id : undefined,
name : '',
enable: true
});
var view = new IndexerEditView({ model: model, indexerCollection: self.collection});
AppLayout.modalRegion.show(view);
}
});
}
});
});
@@ -0,0 +1,23 @@
'use strict';
define([
'vent',
'marionette'
], function (vent, Marionette) {
return Marionette.ItemView.extend({
template: 'Settings/Indexers/Delete/IndexerDeleteViewTemplate',
events: {
'click .x-confirm-delete': '_delete'
},
_delete: function () {
this.model.destroy({
wait : true,
success: function () {
vent.trigger(vent.Commands.CloseModalCommand);
}
});
}
});
});
-23
View File
@@ -1,23 +0,0 @@
'use strict';
define(
[
'vent',
'marionette'
], function (vent, Marionette) {
return Marionette.ItemView.extend({
template: 'Settings/Indexers/DeleteViewTemplate',
events: {
'click .x-confirm-delete': '_removeNotification'
},
_removeNotification: function () {
this.model.destroy({
wait : true,
success: function () {
vent.trigger(vent.Commands.CloseModalCommand);
}
});
}
});
});
@@ -0,0 +1,86 @@
'use strict';
define([
'vent',
'AppLayout',
'marionette',
'Settings/Indexers/Delete/IndexerDeleteView',
'Commands/CommandController',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView',
'underscore',
'Form/FormBuilder',
'Mixins/AutoComplete',
'bootstrap'
], function (vent, AppLayout, Marionette, DeleteView, CommandController, AsModelBoundView, AsValidatedView, _) {
var view = Marionette.ItemView.extend({
template: 'Settings/Indexers/Edit/IndexerEditViewTemplate',
events: {
'click .x-save' : '_save',
'click .x-save-and-add': '_saveAndAdd',
'click .x-delete' : '_delete',
'click .x-back' : '_back',
'click .x-test' : '_test'
},
initialize: function (options) {
this.targetCollection = options.targetCollection;
},
_save: function () {
var self = this;
var promise = this.model.save();
if (promise) {
promise.done(function () {
self.targetCollection.add(self.model, { merge: true });
vent.trigger(vent.Commands.CloseModalCommand);
});
}
},
_saveAndAdd: function () {
var self = this;
var promise = this.model.save();
if (promise) {
promise.done(function () {
self.targetCollection.add(self.model, { merge: true });
require('Settings/Indexers/Add/IndexerSchemaModal').open(self.targetCollection);
});
}
},
_delete: function () {
var view = new DeleteView({ model: this.model });
AppLayout.modalRegion.show(view);
},
_back: function () {
if (this.model.isNew()) {
this.model.destroy();
}
require('Settings/Indexers/Add/IndexerSchemaModal').open(this.targetCollection);
},
_test: function () {
var testCommand = 'test{0}'.format(this.model.get('implementation'));
var properties = {};
_.each(this.model.get('fields'), function (field) {
properties[field.name] = field.value;
});
CommandController.Execute(testCommand, properties);
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
return view;
});
@@ -1,14 +1,14 @@
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close x-cancel"aria-hidden="true">&times;</button>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
{{#if id}}
<h3>Edit</h3>
<h3>Edit - {{implementation}}</h3>
{{else}}
<h3>Add Newznab</h3>
<h3>Add - {{implementation}}</h3>
{{/if}}
</div>
<div class="modal-body">
<div class="modal-body indexer-modal">
<div class="form-horizontal">
<div class="form-group">
<label class="col-sm-3 control-label">Name</label>
@@ -41,12 +41,14 @@
</div>
<div class="modal-footer">
{{#if id}}
<button class="btn btn-danger pull-left x-remove">delete</button>
<button class="btn btn-danger pull-left x-delete">delete</button>
{{else}}
<button class="btn pull-left x-back">back</button>
{{/if}}
<span class="x-activity"></span>
<button class="btn x-cancel">cancel</button>
<!-- Testing is currently not yet supported for indexers, but leaving the infrastructure for later -->
<!-- <button class="btn x-test">test <i class="x-test-icon icon-nd-test"/></button> -->
<button class="btn" data-dismiss="modal">cancel</button>
<div class="btn-group">
<button class="btn btn-primary x-save">save</button>
-86
View File
@@ -1,86 +0,0 @@
'use strict';
define(
[
'vent',
'marionette',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView',
'underscore'
], function (vent, Marionette, AsModelBoundView, AsValidatedView, _) {
var view = Marionette.ItemView.extend({
template: 'Settings/Indexers/EditTemplate',
ui: {
activity: '.x-activity'
},
events: {
'click .x-save' : '_save',
'click .x-save-and-add': '_saveAndAdd',
'click .x-cancel' : '_cancel'
},
initialize: function (options) {
this.indexerCollection = options.indexerCollection;
},
_save: function () {
this.ui.activity.html('<i class="icon-nd-spinner"></i>');
var self = this;
var promise = this.model.saveSettings();
if (promise) {
promise.done(function () {
self.indexerCollection.add(self.model, { merge: true });
vent.trigger(vent.Commands.CloseModalCommand);
});
promise.fail(function () {
self.ui.activity.empty();
});
}
},
_saveAndAdd: function () {
this.ui.activity.html('<i class="icon-nd-spinner"></i>');
var self = this;
var promise = this.model.saveSettings();
if (promise) {
promise.done(function () {
self.indexerCollection.add(self.model, { merge: true });
self.model.set({
id : undefined,
name : '',
enable: false
});
_.each(self.model.get('fields'), function (value, key, list) {
self.model.set('fields.' + key + '.value', '');
});
});
promise.fail(function () {
self.ui.activity.empty();
});
}
},
_cancel: function () {
if (this.model.isNew()) {
this.model.destroy();
vent.trigger(vent.Commands.CloseModalCommand);
}
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
return view;
});
@@ -0,0 +1,31 @@
'use strict';
define([
'backbone',
'Settings/Indexers/IndexerModel'
], function (Backbone, IndexerModel) {
return Backbone.Collection.extend({
model: IndexerModel,
url : window.NzbDrone.ApiRoot + '/indexer',
comparator : function(left, right, collection) {
var result = 0;
if (left.get('protocol')) {
result = -left.get('protocol').localeCompare(right.get('protocol'));
}
if (result === 0 && left.get('name')) {
result = left.get('name').localeCompare(right.get('name'));
}
if (result === 0) {
result = left.get('implementation').localeCompare(right.get('implementation'));
}
return result;
}
});
});
@@ -0,0 +1,29 @@
'use strict';
define([
'marionette',
'Settings/Indexers/IndexerItemView',
'Settings/Indexers/Add/IndexerSchemaModal'
], function (Marionette, ItemView, SchemaModal) {
return Marionette.CompositeView.extend({
itemView : ItemView,
itemViewContainer: '.indexer-list',
template : 'Settings/Indexers/IndexerCollectionViewTemplate',
ui: {
'addCard': '.x-add-card'
},
events: {
'click .x-add-card': '_openSchemaModal'
},
appendHtml: function (collectionView, itemView, index) {
collectionView.ui.addCard.parent('li').before(itemView.el);
},
_openSchemaModal: function () {
SchemaModal.open(this.collection);
}
});
});
@@ -2,11 +2,11 @@
<legend>Indexers</legend>
<div class="row">
<div class="col-md-12">
<ul id="x-indexers" class="indexer-list thingies">
<ul class="indexer-list thingies">
<li>
<div class="indexer-settings-item add-card x-add-card">
<div class="indexer-item thingy add-card x-add-card">
<span class="center well">
<i class="icon-plus" title="Add Newznab"/>
<i class="icon-plus" title="Add Indexer"/>
</span>
</div>
</li>
@@ -0,0 +1,26 @@
'use strict';
define([
'AppLayout',
'marionette',
'Settings/Indexers/Edit/IndexerEditView'
], function (AppLayout, Marionette, EditView) {
return Marionette.ItemView.extend({
template: 'Settings/Indexers/IndexerItemViewTemplate',
tagName : 'li',
events: {
'click' : '_edit'
},
initialize: function () {
this.listenTo(this.model, 'sync', this.render);
},
_edit: function () {
var view = new EditView({ model: this.model, targetCollection: this.model.collection });
AppLayout.modalRegion.show(view);
}
});
});
@@ -0,0 +1,13 @@
<div class="indexer-item thingy" title="Click to edit">
<div>
<h3>{{name}}</h3>
</div>
<div class="settings">
{{#if enable}}
<span class="label label-success">Enabled</span>
{{else}}
<span class="label label-default">Not Enabled</span>
{{/if}}
</div>
</div>
+22 -22
View File
@@ -1,28 +1,28 @@
'use strict';
define(
[
'marionette',
'Settings/Indexers/CollectionView',
'Settings/Indexers/Options/IndexerOptionsView'
], function (Marionette, CollectionView, OptionsView) {
return Marionette.Layout.extend({
template: 'Settings/Indexers/IndexerLayoutTemplate',
define([
'marionette',
'Settings/Indexers/IndexerCollection',
'Settings/Indexers/IndexerCollectionView',
'Settings/Indexers/Options/IndexerOptionsView'
], function (Marionette, IndexerCollection, CollectionView, OptionsView) {
regions: {
indexersRegion : '#indexers-collection',
indexerOptions : '#indexer-options'
},
return Marionette.Layout.extend({
template: 'Settings/Indexers/IndexerLayoutTemplate',
initialize: function (options) {
this.settings = options.settings;
this.indexersCollection = options.indexersCollection;
},
regions: {
indexers : '#x-indexers-region',
indexerOptions : '#x-indexer-options-region'
},
onShow: function () {
this.indexersRegion.show(new CollectionView({ collection: this.indexersCollection }));
this.indexerOptions.show(new OptionsView({ model: this.settings }));
}
});
initialize: function (options) {
this.indexersCollection = new IndexerCollection();
this.indexersCollection.fetch();
},
onShow: function () {
this.indexers.show(new CollectionView({ collection: this.indexersCollection }));
this.indexerOptions.show(new OptionsView({ model: this.model }));
}
});
});
@@ -1,5 +1,4 @@
<div id="indexers-collection"></div>
<div id="x-indexers-region"></div>
<div class="form-horizontal">
<div id="indexer-options"></div>
<div id="x-indexer-options-region"></div>
</div>
+9
View File
@@ -0,0 +1,9 @@
'use strict';
define([
'backbone.deepmodel'
], function (DeepModel) {
return DeepModel.DeepModel.extend({
});
});
@@ -1,11 +1,11 @@
'use strict';
define(
[
'Settings/SettingsModelBase'
], function (SettingsModelBase) {
return SettingsModelBase.extend({
url : window.NzbDrone.ApiRoot + '/config/indexer',
successMessage: 'Indexer settings saved',
errorMessage : 'Failed to save indexer settings'
});
define([
'Settings/SettingsModelBase'
], function (SettingsModelBase) {
return SettingsModelBase.extend({
url : window.NzbDrone.ApiRoot + '/config/indexer',
successMessage: 'Indexer settings saved',
errorMessage : 'Failed to save indexer settings'
});
});
@@ -1,37 +0,0 @@
<div class="indexer-settings-item thingy">
<div>
<h3>{{name}}</h3>
{{#if_eq implementation compare="Newznab"}}
<span class="btn-group pull-right">
<button class="btn btn-xs btn-icon-only x-delete">
<i class="icon-nd-delete"/>
</button>
</span>
{{/if_eq}}
</div>
<div class="form-group">
<label class="control-label">Enable</label>
<div class="input-group">
<label class="checkbox toggle well">
<input type="checkbox" name="enable"/>
<p>
<span>Yes</span>
<span>No</span>
</p>
<div class="btn btn-primary slide-button"/>
</label>
</div>
</div>
{{formBuilder}}
{{#if_eq name compare="WomblesIndex"}}
<div class="alert">
<i class="icon-nd-warning"></i>
Does not support searching
</div>
{{/if_eq}}
</div>
-29
View File
@@ -1,29 +0,0 @@
'use strict';
define(
[
'AppLayout',
'marionette',
'Settings/Indexers/DeleteView',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView'
], function (AppLayout, Marionette, DeleteView, AsModelBoundView, AsValidatedView) {
var view = Marionette.ItemView.extend({
template: 'Settings/Indexers/ItemTemplate',
tagName : 'li',
events: {
'click .x-delete': '_deleteIndexer'
},
_deleteIndexer: function () {
var view = new DeleteView({ model: this.model});
AppLayout.modalRegion.show(view);
}
});
AsModelBoundView.call(view);
return AsValidatedView.call(view);
});
-24
View File
@@ -1,24 +0,0 @@
'use strict';
define([
'Settings/SettingsModelBase'], function (ModelBase) {
return ModelBase.extend({
baseInitialize: ModelBase.prototype.initialize,
initialize: function () {
var name = this.get('name');
if (name) {
this.successMessage = 'Saved indexer: ' + name;
this.errorMessage = 'Couldn\'t save indexer: ' + name;
}
else {
this.successMessage = 'Saved indexer';
this.errorMessage = 'Couldn\'t save indexer';
}
this.baseInitialize.call(this);
}
});
});
+23 -19
View File
@@ -1,29 +1,33 @@
.indexer-settings-item {
@import "../../Shared/Styles/clickable.less";
width: 220px;
height: 295px;
.indexer-list {
li {
display: inline-block;
vertical-align: top;
}
}
.indexer-item {
.clickable;
width: 290px;
height: 90px;
padding: 10px 15px;
h3 {
width: 175px;
overflow: visible;
}
&.add-card {
margin-top: 10px;
margin-left: 10px;
.center {
margin-top: 90px;
margin-top: -3px;
}
}
}
/* Super hack to keep using form builder, this should be dead when we do proper modals for editing */
.col-sm-1, .col-sm-3, .col-sm-5 {
display : block;
width : 100%;
padding: 0px;
float: none;
position: inherit;
.modal-overflow {
overflow-y: visible;
}
.add-indexer {
li {
width: 33%;
}
}