mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-20 21:54:25 -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:
@@ -1,23 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
define([
|
||||
'marionette',
|
||||
'Settings/ThingyAddCollectionView',
|
||||
'Settings/ThingyHeaderGroupView',
|
||||
'Settings/DownloadClient/Add/DownloadClientAddItemView'
|
||||
], function (Marionette, AddItemView) {
|
||||
], function (ThingyAddCollectionView, ThingyHeaderGroupView, AddItemView) {
|
||||
|
||||
return Marionette.CompositeView.extend({
|
||||
itemView : AddItemView,
|
||||
return ThingyAddCollectionView.extend({
|
||||
itemView : ThingyHeaderGroupView.extend({ itemView: AddItemView }),
|
||||
itemViewContainer: '.add-download-client .items',
|
||||
template : 'Settings/DownloadClient/Add/DownloadClientAddCollectionViewTemplate',
|
||||
|
||||
itemViewOptions: function () {
|
||||
return {
|
||||
downloadClientCollection: this.downloadClientCollection
|
||||
};
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
this.downloadClientCollection = options.downloadClientCollection;
|
||||
}
|
||||
template : 'Settings/DownloadClient/Add/DownloadClientAddCollectionViewTemplate'
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'AppLayout',
|
||||
'marionette',
|
||||
'Settings/DownloadClient/Edit/DownloadClientEditView'
|
||||
], function (AppLayout, Marionette, EditView) {
|
||||
], function ($, AppLayout, Marionette, EditView) {
|
||||
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'Settings/DownloadClient/Add/DownloadClientAddItemViewTemplate',
|
||||
@@ -15,7 +16,7 @@ define([
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
this.downloadClientCollection = options.downloadClientCollection;
|
||||
this.targetCollection = options.targetCollection;
|
||||
},
|
||||
|
||||
_add: function (e) {
|
||||
@@ -25,11 +26,11 @@ define([
|
||||
|
||||
this.model.set({
|
||||
id : undefined,
|
||||
name : this.model.get('implementationName'),
|
||||
name : this.model.get('implementation'),
|
||||
enable : true
|
||||
});
|
||||
|
||||
var editView = new EditView({ model: this.model, downloadClientCollection: this.downloadClientCollection });
|
||||
var editView = new EditView({ model: this.model, targetCollection: this.targetCollection });
|
||||
AppLayout.modalRegion.show(editView);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
'use strict';
|
||||
|
||||
define([
|
||||
'underscore',
|
||||
'AppLayout',
|
||||
'backbone',
|
||||
'Settings/DownloadClient/DownloadClientCollection',
|
||||
'Settings/DownloadClient/Add/DownloadClientAddCollectionView'
|
||||
], 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);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,20 +0,0 @@
|
||||
'use strict';
|
||||
define([
|
||||
'AppLayout',
|
||||
'Settings/DownloadClient/DownloadClientCollection',
|
||||
'Settings/DownloadClient/Add/DownloadClientAddCollectionView'
|
||||
], function (AppLayout, DownloadClientCollection, DownloadClientAddCollectionView) {
|
||||
return ({
|
||||
|
||||
open: function (collection) {
|
||||
var schemaCollection = new DownloadClientCollection();
|
||||
var originalUrl = schemaCollection.url;
|
||||
schemaCollection.url = schemaCollection.url + '/schema';
|
||||
schemaCollection.fetch();
|
||||
schemaCollection.url = originalUrl;
|
||||
|
||||
var view = new DownloadClientAddCollectionView({ collection: schemaCollection, downloadClientCollection: collection});
|
||||
AppLayout.modalRegion.show(view);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,23 +1,23 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'vent',
|
||||
'marionette'
|
||||
], function (vent, Marionette) {
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'Settings/DownloadClient/Delete/DownloadClientDeleteViewTemplate',
|
||||
|
||||
events: {
|
||||
'click .x-confirm-delete': '_delete'
|
||||
},
|
||||
define([
|
||||
'vent',
|
||||
'marionette'
|
||||
], function (vent, Marionette) {
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'Settings/DownloadClient/Delete/DownloadClientDeleteViewTemplate',
|
||||
|
||||
_delete: function () {
|
||||
this.model.destroy({
|
||||
wait : true,
|
||||
success: function () {
|
||||
vent.trigger(vent.Commands.CloseModalCommand);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
events: {
|
||||
'click .x-confirm-delete': '_delete'
|
||||
},
|
||||
|
||||
_delete: function () {
|
||||
this.model.destroy({
|
||||
wait : true,
|
||||
success: function () {
|
||||
vent.trigger(vent.Commands.CloseModalCommand);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,12 +1,31 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone',
|
||||
'Settings/DownloadClient/DownloadClientModel'
|
||||
], function (Backbone, DownloadClientModel) {
|
||||
|
||||
return Backbone.Collection.extend({
|
||||
model: DownloadClientModel,
|
||||
url : window.NzbDrone.ApiRoot + '/downloadclient'
|
||||
});
|
||||
define([
|
||||
'backbone',
|
||||
'Settings/DownloadClient/DownloadClientModel'
|
||||
], function (Backbone, DownloadClientModel) {
|
||||
|
||||
return Backbone.Collection.extend({
|
||||
model: DownloadClientModel,
|
||||
url : window.NzbDrone.ApiRoot + '/downloadclient',
|
||||
|
||||
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;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,31 +1,29 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'underscore',
|
||||
'AppLayout',
|
||||
'marionette',
|
||||
'Settings/DownloadClient/DownloadClientItemView',
|
||||
'Settings/DownloadClient/Add/SchemaModal'
|
||||
], function (_, AppLayout, Marionette, DownloadClientItemView, SchemaModal) {
|
||||
return Marionette.CompositeView.extend({
|
||||
itemView : DownloadClientItemView,
|
||||
itemViewContainer: '#x-download-clients',
|
||||
template : 'Settings/DownloadClient/DownloadClientCollectionViewTemplate',
|
||||
|
||||
ui: {
|
||||
'addCard': '.x-add-card'
|
||||
},
|
||||
define([
|
||||
'marionette',
|
||||
'Settings/DownloadClient/DownloadClientItemView',
|
||||
'Settings/DownloadClient/Add/DownloadClientSchemaModal'
|
||||
], function (Marionette, ItemView, SchemaModal) {
|
||||
return Marionette.CompositeView.extend({
|
||||
itemView : ItemView,
|
||||
itemViewContainer: '.download-client-list',
|
||||
template : 'Settings/DownloadClient/DownloadClientCollectionViewTemplate',
|
||||
|
||||
events: {
|
||||
'click .x-add-card': '_openSchemaModal'
|
||||
},
|
||||
ui: {
|
||||
'addCard': '.x-add-card'
|
||||
},
|
||||
|
||||
appendHtml: function (collectionView, itemView, index) {
|
||||
collectionView.ui.addCard.parent('li').before(itemView.el);
|
||||
},
|
||||
events: {
|
||||
'click .x-add-card': '_openSchemaModal'
|
||||
},
|
||||
|
||||
_openSchemaModal: function () {
|
||||
SchemaModal.open(this.collection);
|
||||
}
|
||||
});
|
||||
appendHtml: function (collectionView, itemView, index) {
|
||||
collectionView.ui.addCard.parent('li').before(itemView.el);
|
||||
},
|
||||
|
||||
_openSchemaModal: function () {
|
||||
SchemaModal.open(this.collection);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<legend>Download Clients</legend>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<ul id="x-download-clients" class="download-client-list thingies">
|
||||
<ul class="download-client-list thingies">
|
||||
<li>
|
||||
<div class="download-client-item thingy add-card x-add-card">
|
||||
<span class="center well">
|
||||
|
||||
@@ -1,27 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
define(
|
||||
[
|
||||
'AppLayout',
|
||||
'marionette',
|
||||
'Settings/DownloadClient/Edit/DownloadClientEditView'
|
||||
], function (AppLayout, Marionette, EditView) {
|
||||
define([
|
||||
'AppLayout',
|
||||
'marionette',
|
||||
'Settings/DownloadClient/Edit/DownloadClientEditView'
|
||||
], function (AppLayout, Marionette, EditView) {
|
||||
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'Settings/DownloadClient/DownloadClientItemViewTemplate',
|
||||
tagName : 'li',
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'Settings/DownloadClient/DownloadClientItemViewTemplate',
|
||||
tagName : 'li',
|
||||
|
||||
events: {
|
||||
'click' : '_edit'
|
||||
},
|
||||
events: {
|
||||
'click' : '_edit'
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
this.listenTo(this.model, 'sync', this.render);
|
||||
},
|
||||
initialize: function () {
|
||||
this.listenTo(this.model, 'sync', this.render);
|
||||
},
|
||||
|
||||
_edit: function () {
|
||||
var view = new EditView({ model: this.model, downloadClientCollection: this.model.collection });
|
||||
AppLayout.modalRegion.show(view);
|
||||
}
|
||||
});
|
||||
_edit: function () {
|
||||
var view = new EditView({ model: this.model, targetCollection: this.model.collection});
|
||||
AppLayout.modalRegion.show(view);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,32 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'Settings/DownloadClient/DownloadClientCollection',
|
||||
'Settings/DownloadClient/DownloadClientCollectionView',
|
||||
'Settings/DownloadClient/Options/DownloadClientOptionsView',
|
||||
'Settings/DownloadClient/FailedDownloadHandling/FailedDownloadHandlingView'
|
||||
], function (Marionette, DownloadClientCollection, DownloadClientCollectionView, DownloadClientOptionsView, FailedDownloadHandlingView) {
|
||||
define([
|
||||
'marionette',
|
||||
'Settings/DownloadClient/DownloadClientCollection',
|
||||
'Settings/DownloadClient/DownloadClientCollectionView',
|
||||
'Settings/DownloadClient/DroneFactory/DroneFactoryView',
|
||||
'Settings/DownloadClient/DownloadHandling/DownloadHandlingView'
|
||||
], function (Marionette, DownloadClientCollection, CollectionView, DroneFactoryView, DownloadHandlingView) {
|
||||
|
||||
return Marionette.Layout.extend({
|
||||
template : 'Settings/DownloadClient/DownloadClientLayoutTemplate',
|
||||
return Marionette.Layout.extend({
|
||||
template : 'Settings/DownloadClient/DownloadClientLayoutTemplate',
|
||||
|
||||
regions: {
|
||||
downloadClients : '#x-download-clients-region',
|
||||
downloadClientOptions : '#x-download-client-options-region',
|
||||
failedDownloadHandling : '#x-failed-download-handling-region'
|
||||
},
|
||||
regions: {
|
||||
downloadClients : '#x-download-clients-region',
|
||||
downloadHandling : '#x-download-handling-region',
|
||||
droneFactory : '#x-dronefactory-region'
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
this.downloadClientCollection = new DownloadClientCollection();
|
||||
this.downloadClientCollection.fetch();
|
||||
},
|
||||
initialize: function () {
|
||||
this.downloadClientsCollection = new DownloadClientCollection();
|
||||
this.downloadClientsCollection.fetch();
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
this.downloadClients.show(new DownloadClientCollectionView({ collection: this.downloadClientCollection }));
|
||||
this.downloadClientOptions.show(new DownloadClientOptionsView({ model: this.model }));
|
||||
this.failedDownloadHandling.show(new FailedDownloadHandlingView({ model: this.model }));
|
||||
}
|
||||
});
|
||||
});
|
||||
onShow: function () {
|
||||
this.downloadClients.show(new CollectionView({ collection: this.downloadClientsCollection }));
|
||||
this.downloadHandling.show(new DownloadHandlingView({ model: this.model }));
|
||||
this.droneFactory.show(new DroneFactoryView({ model: this.model }));
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,5 @@
|
||||
<div id="x-download-clients-region"></div>
|
||||
<div class="form-horizontal">
|
||||
<div id="x-download-client-options-region"></div>
|
||||
<div id="x-failed-download-handling-region"></div>
|
||||
<div id="x-download-handling-region"></div>
|
||||
<div id="x-dronefactory-region"></div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone.deepmodel'
|
||||
], function (DeepModel) {
|
||||
return DeepModel.DeepModel.extend({
|
||||
|
||||
});
|
||||
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/downloadclient',
|
||||
successMessage: 'Download client settings saved',
|
||||
errorMessage : 'Failed to save download client settings'
|
||||
});
|
||||
|
||||
define([
|
||||
'Settings/SettingsModelBase'
|
||||
], function (SettingsModelBase) {
|
||||
return SettingsModelBase.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/config/downloadclient',
|
||||
successMessage: 'Download client settings saved',
|
||||
errorMessage : 'Failed to save download client settings'
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'Mixins/AsModelBoundView',
|
||||
'Mixins/AsValidatedView'
|
||||
], function (Marionette, AsModelBoundView, AsValidatedView) {
|
||||
|
||||
var view = Marionette.ItemView.extend({
|
||||
template: 'Settings/DownloadClient/DownloadHandling/DownloadHandlingViewTemplate',
|
||||
|
||||
ui: {
|
||||
completedDownloadHandlingCheckbox : '.x-completed-download-handling',
|
||||
completedDownloadOptions : '.x-completed-download-options',
|
||||
failedDownloadHandlingCheckbox : '.x-failed-download-handling',
|
||||
failedDownloadOptions : '.x-failed-download-options'
|
||||
},
|
||||
|
||||
events: {
|
||||
'change .x-completed-download-handling' : '_setCompletedDownloadOptionsVisibility',
|
||||
'change .x-failed-download-handling' : '_setFailedDownloadOptionsVisibility'
|
||||
},
|
||||
|
||||
onRender: function () {
|
||||
if (!this.ui.completedDownloadHandlingCheckbox.prop('checked')) {
|
||||
this.ui.completedDownloadOptions.hide();
|
||||
}
|
||||
if (!this.ui.failedDownloadHandlingCheckbox.prop('checked')) {
|
||||
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.failedDownloadHandlingCheckbox.prop('checked');
|
||||
if (checked) {
|
||||
this.ui.failedDownloadOptions.slideDown();
|
||||
}
|
||||
|
||||
else {
|
||||
this.ui.failedDownloadOptions.slideUp();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
AsModelBoundView.call(view);
|
||||
AsValidatedView.call(view);
|
||||
|
||||
return view;
|
||||
});
|
||||
+54
-4
@@ -1,6 +1,56 @@
|
||||
<fieldset class="advanced-setting">
|
||||
<legend>Failed Download Handling</legend>
|
||||
<fieldset>
|
||||
<legend>Download Client Import Handling</legend>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">Enable</label>
|
||||
|
||||
<div class="col-sm-8">
|
||||
<div class="input-group">
|
||||
<label class="checkbox toggle well">
|
||||
<input type="checkbox" name="enableCompletedDownloadHandling" class="x-completed-download-handling"/>
|
||||
<p>
|
||||
<span>Yes</span>
|
||||
<span>No</span>
|
||||
</p>
|
||||
|
||||
<div class="btn btn-primary slide-button"/>
|
||||
</label>
|
||||
|
||||
<span class="help-inline-checkbox">
|
||||
<i class="icon-nd-form-info" title="Import completed downloads in download client history"/>
|
||||
<i class="icon-nd-form-warning" title="Download client history items that are stored in the drone factory will be ignored. Configure the Drone Factory for a different path"/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="x-completed-download-options advanced-setting"">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">Remove</label>
|
||||
|
||||
<div class="col-sm-8">
|
||||
<div class="input-group">
|
||||
<label class="checkbox toggle well">
|
||||
<input type="checkbox" name="removeCompletedDownloads"/>
|
||||
<p>
|
||||
<span>Yes</span>
|
||||
<span>No</span>
|
||||
</p>
|
||||
|
||||
<div class="btn btn-primary slide-button"/>
|
||||
</label>
|
||||
|
||||
<span class="help-inline-checkbox">
|
||||
<i class="icon-nd-form-info" title="Remove imported downloads from download client history"/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="advanced-setting">
|
||||
<legend>Download Client Failed Handling</legend>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">Enable</label>
|
||||
|
||||
@@ -40,7 +90,7 @@
|
||||
</label>
|
||||
|
||||
<span class="help-inline-checkbox">
|
||||
<i class="icon-nd-form-info" title="Automatically search for and attempt to download another release when a download fails?"/>
|
||||
<i class="icon-nd-form-info" title="Automatically search for and attempt to download another release"/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -62,7 +112,7 @@
|
||||
</label>
|
||||
|
||||
<span class="help-inline-checkbox">
|
||||
<i class="icon-nd-form-info" title="Automatically remove failed downloads from history and encrypted downloads from queue?"/>
|
||||
<i class="icon-nd-form-info" title="Remove failed downloads from download client history"/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
+1
-1
@@ -8,7 +8,7 @@ define(
|
||||
], function (Marionette, AsModelBoundView, AsValidatedView) {
|
||||
|
||||
var view = Marionette.ItemView.extend({
|
||||
template: 'Settings/DownloadClient/Options/DownloadClientOptionsViewTemplate',
|
||||
template: 'Settings/DownloadClient/DroneFactory/DroneFactoryViewTemplate',
|
||||
|
||||
ui: {
|
||||
droneFactory : '.x-path'
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
<fieldset>
|
||||
<legend>Options</legend>
|
||||
<legend>Drone Factory Options</legend>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">Drone Factory</label>
|
||||
|
||||
<div class="col-sm-1 col-sm-push-8 help-inline">
|
||||
<i class="icon-nd-form-info" title="The folder where your download client downloads TV shows to (Completed Download Directory)"/>
|
||||
<i class="icon-nd-form-info" title="Optional folder to periodically scan for available imports"/>
|
||||
<i class="icon-nd-form-warning" title="Do not use the folder that contains some or all of your sorted and named TV shows - doing so could cause data loss"></i>
|
||||
</div>
|
||||
|
||||
@@ -1,97 +1,96 @@
|
||||
'use strict';
|
||||
|
||||
define(
|
||||
[
|
||||
'vent',
|
||||
'AppLayout',
|
||||
'marionette',
|
||||
'Settings/DownloadClient/Delete/DownloadClientDeleteView',
|
||||
'Commands/CommandController',
|
||||
'Mixins/AsModelBoundView',
|
||||
'Mixins/AsValidatedView',
|
||||
'underscore',
|
||||
'Form/FormBuilder',
|
||||
'Mixins/AutoComplete',
|
||||
'bootstrap'
|
||||
], function (vent, AppLayout, Marionette, DeleteView, CommandController, AsModelBoundView, AsValidatedView, _) {
|
||||
define([
|
||||
'vent',
|
||||
'AppLayout',
|
||||
'marionette',
|
||||
'Settings/DownloadClient/Delete/DownloadClientDeleteView',
|
||||
'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/DownloadClient/Edit/DownloadClientEditViewTemplate',
|
||||
var view = Marionette.ItemView.extend({
|
||||
template: 'Settings/DownloadClient/Edit/DownloadClientEditViewTemplate',
|
||||
|
||||
ui: {
|
||||
path : '.x-path',
|
||||
modalBody : '.modal-body'
|
||||
},
|
||||
ui: {
|
||||
path : '.x-path',
|
||||
modalBody : '.modal-body'
|
||||
},
|
||||
|
||||
events: {
|
||||
'click .x-save' : '_save',
|
||||
'click .x-save-and-add': '_saveAndAdd',
|
||||
'click .x-delete' : '_delete',
|
||||
'click .x-back' : '_back',
|
||||
'click .x-test' : '_test'
|
||||
},
|
||||
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.downloadClientCollection = options.downloadClientCollection;
|
||||
},
|
||||
initialize: function (options) {
|
||||
this.targetCollection = options.targetCollection;
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
//Hack to deal with modals not overflowing
|
||||
if (this.ui.path.length > 0) {
|
||||
this.ui.modalBody.addClass('modal-overflow');
|
||||
}
|
||||
|
||||
this.ui.path.autoComplete('/directories');
|
||||
},
|
||||
|
||||
_save: function () {
|
||||
var self = this;
|
||||
var promise = this.model.save();
|
||||
|
||||
if (promise) {
|
||||
promise.done(function () {
|
||||
self.downloadClientCollection.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.notificationCollection.add(self.model, { merge: true });
|
||||
|
||||
require('Settings/DownloadClient/Add/SchemaModal').open(self.downloadClientCollection);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
_delete: function () {
|
||||
var view = new DeleteView({ model: this.model });
|
||||
AppLayout.modalRegion.show(view);
|
||||
},
|
||||
|
||||
_back: function () {
|
||||
require('Settings/DownloadClient/Add/SchemaModal').open(this.downloadClientCollection);
|
||||
},
|
||||
|
||||
_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);
|
||||
onShow: function () {
|
||||
//Hack to deal with modals not overflowing
|
||||
if (this.ui.path.length > 0) {
|
||||
this.ui.modalBody.addClass('modal-overflow');
|
||||
}
|
||||
});
|
||||
|
||||
AsModelBoundView.call(view);
|
||||
AsValidatedView.call(view);
|
||||
this.ui.path.autoComplete('/directories');
|
||||
},
|
||||
|
||||
return view;
|
||||
_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/DownloadClient/Add/DownloadClientSchemaModal').open(self.targetCollection);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
_delete: function () {
|
||||
var view = new DeleteView({ model: this.model });
|
||||
AppLayout.modalRegion.show(view);
|
||||
},
|
||||
|
||||
_back: function () {
|
||||
require('Settings/DownloadClient/Add/DownloadClientSchemaModal').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,37 +0,0 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'Mixins/AsModelBoundView',
|
||||
'Mixins/AsValidatedView'
|
||||
], function (Marionette, AsModelBoundView, AsValidatedView) {
|
||||
|
||||
var view = Marionette.ItemView.extend({
|
||||
template: 'Settings/DownloadClient/FailedDownloadHandling/FailedDownloadHandlingViewTemplate',
|
||||
|
||||
ui: {
|
||||
failedDownloadHandlingCheckbox: '.x-failed-download-handling',
|
||||
failedDownloadOptions : '.x-failed-download-options'
|
||||
},
|
||||
|
||||
events: {
|
||||
'change .x-failed-download-handling': '_setFailedDownloadOptionsVisibility'
|
||||
},
|
||||
|
||||
_setFailedDownloadOptionsVisibility: function () {
|
||||
var checked = this.ui.failedDownloadHandlingCheckbox.prop('checked');
|
||||
if (checked) {
|
||||
this.ui.failedDownloadOptions.slideDown();
|
||||
}
|
||||
|
||||
else {
|
||||
this.ui.failedDownloadOptions.slideUp();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
AsModelBoundView.call(view);
|
||||
AsValidatedView.call(view);
|
||||
|
||||
return view;
|
||||
});
|
||||
Reference in New Issue
Block a user