mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 10:47:08 -07:00
Can add indexer (in UI)
This commit is contained in:
parent
6351011cce
commit
ea929974f3
8 changed files with 168 additions and 4 deletions
|
@ -1,4 +1,10 @@
|
|||
<div class="row">
|
||||
<div class="span12">
|
||||
<button class="btn btn-success x-add">Add</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="span12">
|
||||
<div id="x-indexers" class="form-horizontal"></div>
|
||||
</div>
|
||||
|
|
|
@ -1,8 +1,32 @@
|
|||
'use strict';
|
||||
define(['app', 'Settings/Indexers/ItemView'], function () {
|
||||
define(['app',
|
||||
'Settings/Indexers/ItemView',
|
||||
'Settings/Indexers/EditView'],
|
||||
function () {
|
||||
NzbDrone.Settings.Indexers.CollectionView = Backbone.Marionette.CompositeView.extend({
|
||||
itemView : NzbDrone.Settings.Indexers.ItemView,
|
||||
itemViewContainer : '#x-indexers',
|
||||
template : 'Settings/Indexers/CollectionTemplate'
|
||||
template : 'Settings/Indexers/CollectionTemplate',
|
||||
|
||||
events: {
|
||||
'click .x-add': 'openSchemaModal'
|
||||
},
|
||||
|
||||
openSchemaModal: function () {
|
||||
//TODO: Is there a better way to deal with changing URLs?
|
||||
var schema = new NzbDrone.Settings.Indexers.Collection();
|
||||
schema.url = '/api/indexer/schema';
|
||||
schema.fetch({
|
||||
success: function (collection) {
|
||||
collection.url = '/api/indexer';
|
||||
var model = _.first(collection.models);
|
||||
model.set('id', undefined);
|
||||
model.set('name', '');
|
||||
|
||||
var view = new NzbDrone.Settings.Indexers.EditView({ model: model});
|
||||
NzbDrone.modalRegion.show(view);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
44
UI/Settings/Indexers/EditTemplate.html
Normal file
44
UI/Settings/Indexers/EditTemplate.html
Normal file
|
@ -0,0 +1,44 @@
|
|||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
{{#if id}}
|
||||
<h3>Edit</h3>
|
||||
{{else}}
|
||||
<h3>Add</h3>
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<label class="control-label">Name</label>
|
||||
|
||||
<div class="controls">
|
||||
<input type="text" name="name"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label">Enable</label>
|
||||
|
||||
<div class="controls">
|
||||
<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"></div>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{formBuilder}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
{{#if id}}
|
||||
<button class="btn btn-danger pull-left x-remove">delete</button>
|
||||
{{/if}}
|
||||
<button class="btn" data-dismiss="modal">cancel</button>
|
||||
<button class="btn btn-primary x-save">save</button>
|
||||
</div>
|
36
UI/Settings/Indexers/EditView.js
Normal file
36
UI/Settings/Indexers/EditView.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
"use strict";
|
||||
|
||||
define([
|
||||
'app',
|
||||
'Settings/Indexers/Model'
|
||||
|
||||
], function () {
|
||||
|
||||
NzbDrone.Settings.Indexers.EditView = Backbone.Marionette.ItemView.extend({
|
||||
template : 'Settings/Indexers/EditTemplate',
|
||||
|
||||
events: {
|
||||
'click .x-save': 'save'
|
||||
},
|
||||
|
||||
save: function () {
|
||||
this.model.save();
|
||||
|
||||
// window.alert('saving');
|
||||
// this.model.save(undefined, this.syncNotification("Notification Settings Saved", "Couldn't Save Notification Settings"));
|
||||
},
|
||||
|
||||
|
||||
syncNotification: function (success, error) {
|
||||
return {
|
||||
success: function () {
|
||||
window.alert(success);
|
||||
},
|
||||
|
||||
error: function () {
|
||||
window.alert(error);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue