mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
settings is fully moved to required.
This commit is contained in:
parent
73f3459264
commit
6f8c73771d
@ -10,7 +10,7 @@ define(['app','backgrid'], function () {
|
||||
this._originalInit.apply(this, arguments);
|
||||
this.cellValue = this._getValue();
|
||||
|
||||
this.model.on('change', this._refresh, this);
|
||||
this.listenTo(this.model, 'change', this._refresh);
|
||||
},
|
||||
|
||||
_refresh: function () {
|
||||
|
@ -1,5 +1,6 @@
|
||||
"use strict";
|
||||
define(['app',
|
||||
'Settings/SettingsLayout',
|
||||
'Form/FormBuilder',
|
||||
'AddSeries/AddSeriesLayout',
|
||||
'Series/Index/SeriesIndexLayout',
|
||||
@ -9,7 +10,6 @@ define(['app',
|
||||
'MainMenuView',
|
||||
'Series/Details/SeriesDetailsLayout',
|
||||
'Series/EpisodeCollection',
|
||||
'Settings/SettingsLayout',
|
||||
'Logs/Layout',
|
||||
'Release/Layout',
|
||||
'Missing/MissingLayout',
|
||||
@ -17,12 +17,12 @@ define(['app',
|
||||
'Shared/FormatHelpers',
|
||||
'Shared/TemplateHelpers',
|
||||
'Shared/Footer/View'],
|
||||
function () {
|
||||
function (App, SettingsLayout) {
|
||||
var controller = Backbone.Marionette.Controller.extend({
|
||||
|
||||
series : function () {
|
||||
this._setTitle('NzbDrone');
|
||||
NzbDrone.mainRegion.show(new NzbDrone.Series.Index.SeriesIndexLayout());
|
||||
App.mainRegion.show(new NzbDrone.Series.Index.SeriesIndexLayout());
|
||||
},
|
||||
seriesDetails: function (query) {
|
||||
|
||||
@ -32,52 +32,52 @@ define(['app',
|
||||
series.fetch({
|
||||
success: function (seriesModel) {
|
||||
self._setTitle(seriesModel.get('title'));
|
||||
NzbDrone.mainRegion.show(new NzbDrone.Series.Details.SeriesDetailsLayout({ model: seriesModel }));
|
||||
App.mainRegion.show(new NzbDrone.Series.Details.SeriesDetailsLayout({ model: seriesModel }));
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
addSeries: function (action) {
|
||||
this._setTitle('Add Series');
|
||||
NzbDrone.mainRegion.show(new NzbDrone.AddSeries.AddSeriesLayout({action: action}));
|
||||
App.mainRegion.show(new NzbDrone.AddSeries.AddSeriesLayout({action: action}));
|
||||
},
|
||||
|
||||
calendar: function () {
|
||||
this._setTitle('Calendar');
|
||||
NzbDrone.mainRegion.show(new NzbDrone.Calendar.CalendarLayout());
|
||||
App.mainRegion.show(new NzbDrone.Calendar.CalendarLayout());
|
||||
},
|
||||
|
||||
|
||||
settings: function (action) {
|
||||
this._setTitle('Settings');
|
||||
NzbDrone.mainRegion.show(new NzbDrone.Settings.SettingsLayout({action: action}));
|
||||
App.mainRegion.show(new SettingsLayout({action: action}));
|
||||
},
|
||||
|
||||
missing: function () {
|
||||
this._setTitle('Missing');
|
||||
|
||||
NzbDrone.mainRegion.show(new NzbDrone.Missing.MissingLayout());
|
||||
App.mainRegion.show(new NzbDrone.Missing.MissingLayout());
|
||||
},
|
||||
|
||||
history: function () {
|
||||
this._setTitle('History');
|
||||
|
||||
NzbDrone.mainRegion.show(new NzbDrone.History.HistoryLayout());
|
||||
App.mainRegion.show(new NzbDrone.History.HistoryLayout());
|
||||
},
|
||||
|
||||
rss: function () {
|
||||
this._setTitle('RSS');
|
||||
NzbDrone.mainRegion.show(new NzbDrone.Release.Layout());
|
||||
App.mainRegion.show(new NzbDrone.Release.Layout());
|
||||
},
|
||||
|
||||
logs: function () {
|
||||
this._setTitle('logs');
|
||||
NzbDrone.mainRegion.show(new NzbDrone.Logs.Layout());
|
||||
App.mainRegion.show(new NzbDrone.Logs.Layout());
|
||||
},
|
||||
|
||||
notFound: function () {
|
||||
this._setTitle('Not Found');
|
||||
NzbDrone.mainRegion.show(new NzbDrone.Shared.NotFoundView(this));
|
||||
App.mainRegion.show(new NzbDrone.Shared.NotFoundView(this));
|
||||
},
|
||||
|
||||
|
||||
|
@ -10,8 +10,8 @@ define(['app', 'Cells/NzbDroneCell' ], function () {
|
||||
|
||||
if (this.cellValue) {
|
||||
|
||||
var icon = 'icon-question';
|
||||
var toolTip = 'unknow event';
|
||||
var icon;
|
||||
var toolTip;
|
||||
|
||||
switch (this.cellValue) {
|
||||
case 'grabbed':
|
||||
@ -22,10 +22,14 @@ define(['app', 'Cells/NzbDroneCell' ], function () {
|
||||
icon = 'icon-hdd';
|
||||
toolTip = 'Existing episode file added to library';
|
||||
break;
|
||||
case 'DownloadFolderImported':
|
||||
case 'downloadFolderImported':
|
||||
icon = 'icon-download-alt';
|
||||
toolTip = 'Episode downloaded succesfully and picked up from download client';
|
||||
toolTip = 'Episode downloaded successfully and picked up from download client';
|
||||
break;
|
||||
default :
|
||||
icon = 'icon-question';
|
||||
toolTip = 'unknown event';
|
||||
|
||||
}
|
||||
|
||||
this.$el.html('<i class="{0}" title="{1}"/>'.format(icon, toolTip));
|
||||
|
31
UI/Mixins/AsChangeTrackingModel.js
Normal file
31
UI/Mixins/AsChangeTrackingModel.js
Normal file
@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
define(
|
||||
function () {
|
||||
|
||||
return function () {
|
||||
|
||||
var originalInit = this.prototype.initialize;
|
||||
|
||||
this.prototype.initialize = function () {
|
||||
|
||||
this.isSaved = true;
|
||||
|
||||
this.on('change', function () {
|
||||
this.isSaved = false;
|
||||
}, this);
|
||||
|
||||
this.on('sync', function () {
|
||||
this.isSaved = true;
|
||||
}, this);
|
||||
|
||||
|
||||
if (originalInit) {
|
||||
originalInit.call(this);
|
||||
}
|
||||
};
|
||||
|
||||
return this;
|
||||
};
|
||||
}
|
||||
);
|
37
UI/Mixins/AsModelBoundView.js
Normal file
37
UI/Mixins/AsModelBoundView.js
Normal file
@ -0,0 +1,37 @@
|
||||
'use strict';
|
||||
|
||||
define(
|
||||
['backbone.modelbinder'],
|
||||
function (ModelBinder) {
|
||||
|
||||
return function () {
|
||||
|
||||
var originalOnRender = this.prototype.onRender,
|
||||
originalBeforeClose = this.prototype.onBeforeClose;
|
||||
|
||||
this.prototype.onRender = function () {
|
||||
if (this.model) {
|
||||
this._modelBinder = new ModelBinder();
|
||||
this._modelBinder.bind(this.model, this.el);
|
||||
}
|
||||
if (originalOnRender) {
|
||||
originalOnRender.call(this);
|
||||
}
|
||||
};
|
||||
|
||||
this.prototype.beforeClose = function () {
|
||||
|
||||
if (this._modelBinder) {
|
||||
this._modelBinder.unbind();
|
||||
delete this._modelBinder;
|
||||
}
|
||||
|
||||
if (originalBeforeClose) {
|
||||
originalBeforeClose.call(this);
|
||||
}
|
||||
};
|
||||
|
||||
return this;
|
||||
};
|
||||
}
|
||||
);
|
38
UI/Mixins/AsNamedView.js
Normal file
38
UI/Mixins/AsNamedView.js
Normal file
@ -0,0 +1,38 @@
|
||||
'use strict';
|
||||
|
||||
define(
|
||||
function () {
|
||||
|
||||
return function () {
|
||||
|
||||
this.viewName = function () {
|
||||
if (this.template) {
|
||||
var regex = new RegExp('\/', 'g');
|
||||
|
||||
return this.template
|
||||
.toLocaleLowerCase()
|
||||
.replace('template', '')
|
||||
.replace(regex, '-');
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
|
||||
var originalOnRender = this.onRender;
|
||||
|
||||
this.onRender = function () {
|
||||
|
||||
this.$el.removeClass('iv-' + this.viewName());
|
||||
this.$el.addClass('iv-' + this.viewName());
|
||||
|
||||
if (originalOnRender) {
|
||||
return originalOnRender.call(this);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
|
||||
return this;
|
||||
};
|
||||
}
|
||||
);
|
@ -1,31 +0,0 @@
|
||||
"use strict";
|
||||
define(['app'], function () {
|
||||
|
||||
NzbDrone.Mixins.SaveIfChangedModel = {
|
||||
// originalInitialize: this.initialize,
|
||||
|
||||
initialize: function () {
|
||||
this.isSaved = true;
|
||||
|
||||
this.on('change', function () {
|
||||
this.isSaved = false;
|
||||
}, this);
|
||||
|
||||
this.on('sync', function () {
|
||||
this.isSaved = true;
|
||||
}, this);
|
||||
|
||||
// if (originalInitialize) {
|
||||
// originalInitialize.call(this);
|
||||
// }
|
||||
},
|
||||
|
||||
saveIfChanged: function (options) {
|
||||
if (!this.isSaved) {
|
||||
this.save(undefined, options);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return NzbDrone.Missing.SaveIfChangedModel;
|
||||
});
|
@ -1,47 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var oldMarionetteItemViewRender = Marionette.ItemView.prototype.render;
|
||||
var oldItemCollectionViewRender = Marionette.CollectionView.prototype.render;
|
||||
|
||||
|
||||
Marionette.View.prototype.viewName = function () {
|
||||
if (this.template) {
|
||||
var regex = new RegExp('\/', 'g');
|
||||
|
||||
return this.template
|
||||
.toLocaleLowerCase()
|
||||
.replace('template', '')
|
||||
.replace(regex, '-');
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
|
||||
Marionette.ItemView.prototype.self$ = function (selector) {
|
||||
return this.$(selector).not("[class*='iv-'] " + selector);
|
||||
};
|
||||
|
||||
Marionette.ItemView.prototype.render = function () {
|
||||
|
||||
var result = oldMarionetteItemViewRender.apply(this, arguments);
|
||||
|
||||
this.$el.removeClass('iv-' + this.viewName());
|
||||
|
||||
//check to see if el has bindings (name attribute)
|
||||
// any element that has a name attribute and isn't child of another view.
|
||||
if (this.self$('[name]').length > 0) {
|
||||
if (!this.model) {
|
||||
throw 'view ' + this.viewName() + ' has binding attributes but model is not defined';
|
||||
}
|
||||
|
||||
if (!this._modelBinder) {
|
||||
this._modelBinder = new Backbone.ModelBinder();
|
||||
}
|
||||
|
||||
this._modelBinder.bind(this.model, this.el);
|
||||
}
|
||||
|
||||
this.$el.addClass('iv-' + this.viewName());
|
||||
|
||||
return result;
|
||||
};
|
@ -4,4 +4,6 @@ define(['app', 'Quality/QualitySizeModel'], function () {
|
||||
model: NzbDrone.Quality.QualitySizeModel,
|
||||
url : NzbDrone.Constants.ApiRoot + '/qualitysize'
|
||||
});
|
||||
|
||||
return NzbDrone.Quality.QualitySizeCollection;
|
||||
});
|
||||
|
@ -28,4 +28,7 @@ define(['app', 'Series/SeriesModel'], function () {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return NzbDrone.Series.Delete.DeleteSeriesView;
|
||||
|
||||
});
|
||||
|
@ -12,4 +12,7 @@ define(['app', 'Series/EpisodeModel'], function () {
|
||||
return new NzbDrone.Series.EpisodeCollection(filtered);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return NzbDrone.Series.EpisodeCollection;
|
||||
});
|
||||
|
@ -87,4 +87,6 @@ define(['app', 'Series/SeriesModel'], function () {
|
||||
status : 0
|
||||
}
|
||||
});
|
||||
|
||||
return NzbDrone.Series.EpisodeModel;
|
||||
});
|
||||
|
@ -3,4 +3,6 @@ define(['app'], function () {
|
||||
NzbDrone.Series.Index.EmptySeriesCollectionView = Backbone.Marionette.CompositeView.extend({
|
||||
template: 'Series/Index/EmptySeriesIndexTemplate'
|
||||
});
|
||||
|
||||
return NzbDrone.Series.Index.EmptySeriesCollectionView;
|
||||
});
|
||||
|
@ -5,4 +5,6 @@ define(['app'], function () {
|
||||
NzbDrone.Series.Index.EmptyView = Backbone.Marionette.CompositeView.extend({
|
||||
template: 'Series/Index/EmptyTemplate'
|
||||
});
|
||||
|
||||
return NzbDrone.Series.Index.EmptyView;
|
||||
});
|
||||
|
@ -7,4 +7,6 @@ define(['app', 'Series/Index/List/ItemView', 'Config'], function () {
|
||||
itemViewContainer : '#x-series-list',
|
||||
template : 'Series/Index/List/CollectionTemplate'
|
||||
});
|
||||
|
||||
return NzbDrone.Series.Index.List.CollectionView;
|
||||
});
|
||||
|
@ -8,7 +8,6 @@ define([
|
||||
'Series/Delete/DeleteSeriesView'
|
||||
|
||||
], function () {
|
||||
|
||||
NzbDrone.Series.Index.List.ItemView = Backbone.Marionette.ItemView.extend({
|
||||
template: 'Series/Index/List/ItemTemplate',
|
||||
|
||||
@ -31,4 +30,6 @@ define([
|
||||
NzbDrone.modalRegion.show(view);
|
||||
}
|
||||
});
|
||||
|
||||
return NzbDrone.Series.Index.List.ItemView;
|
||||
});
|
||||
|
@ -7,4 +7,6 @@ define(['app', 'Series/Index/Posters/ItemView', 'Config'], function () {
|
||||
itemViewContainer : '#x-series-posters',
|
||||
template : 'Series/Index/Posters/CollectionTemplate'
|
||||
});
|
||||
|
||||
return NzbDrone.Series.Index.Posters.CollectionView;
|
||||
});
|
||||
|
@ -40,4 +40,6 @@ define([
|
||||
this.ui.controls.slideToggle();
|
||||
}
|
||||
});
|
||||
|
||||
return NzbDrone.Series.Index.Posters.ItemView;
|
||||
});
|
||||
|
@ -4,6 +4,7 @@ define([
|
||||
'Series/Index/List/CollectionView',
|
||||
'Series/Index/Posters/CollectionView',
|
||||
'Series/Index/EmptyView',
|
||||
'Series/SeriesCollection',
|
||||
'Cells/AirDateCell',
|
||||
'Cells/SeriesTitleCell',
|
||||
'Cells/TemplatedCell',
|
||||
@ -12,7 +13,20 @@ define([
|
||||
'Config',
|
||||
'Shared/LoadingView'
|
||||
],
|
||||
function () {
|
||||
function (
|
||||
App,
|
||||
ListCollectionView,
|
||||
PosterCollectionView,
|
||||
EmptyView,
|
||||
SeriesCollection,
|
||||
AirDateCell,
|
||||
SeriesTitleCell,
|
||||
TemplatedCell,
|
||||
SeriesStatusCell,
|
||||
ToolbarLayout,
|
||||
Config,
|
||||
LoadingView)
|
||||
{
|
||||
NzbDrone.Series.Index.SeriesIndexLayout = Backbone.Marionette.Layout.extend({
|
||||
template: 'Series/Index/SeriesIndexLayoutTemplate',
|
||||
|
||||
@ -30,7 +44,7 @@ define([
|
||||
{
|
||||
name : 'this',
|
||||
label: 'Title',
|
||||
cell : NzbDrone.Cells.SeriesTitleCell
|
||||
cell : SeriesTitleCell
|
||||
},
|
||||
{
|
||||
name : 'seasonCount',
|
||||
@ -50,21 +64,21 @@ define([
|
||||
{
|
||||
name : 'nextAiring',
|
||||
label: 'Next Airing',
|
||||
cell : NzbDrone.Cells.AirDateCell
|
||||
cell : AirDateCell
|
||||
},
|
||||
{
|
||||
name : 'this',
|
||||
label : 'Episodes',
|
||||
sortable: false,
|
||||
template: 'Series/EpisodeProgressTemplate',
|
||||
cell : NzbDrone.Cells.TemplatedCell
|
||||
cell : TemplatedCell
|
||||
},
|
||||
{
|
||||
name : 'this',
|
||||
label : '',
|
||||
sortable: false,
|
||||
template: 'Series/Index/Table/ControlsColumnTemplate',
|
||||
cell : NzbDrone.Cells.TemplatedCell
|
||||
cell : TemplatedCell
|
||||
}
|
||||
],
|
||||
|
||||
@ -107,24 +121,24 @@ define([
|
||||
},
|
||||
|
||||
_showList: function () {
|
||||
var view = new NzbDrone.Series.Index.List.CollectionView();
|
||||
var view = new ListCollectionView();
|
||||
this._fetchCollection(view);
|
||||
},
|
||||
|
||||
_showPosters: function () {
|
||||
var view = new NzbDrone.Series.Index.Posters.CollectionView();
|
||||
var view = new PosterCollectionView();
|
||||
this._fetchCollection(view);
|
||||
},
|
||||
|
||||
_showEmpty: function () {
|
||||
this.series.show(new NzbDrone.Series.Index.EmptyView());
|
||||
this.series.show(new EmptyView());
|
||||
},
|
||||
|
||||
_fetchCollection: function (view) {
|
||||
var self = this;
|
||||
|
||||
if (this.seriesCollection.models.length === 0) {
|
||||
this.series.show(new NzbDrone.Shared.LoadingView());
|
||||
this.series.show(new LoadingView());
|
||||
|
||||
this.seriesCollection.fetch()
|
||||
.done(function () {
|
||||
@ -145,7 +159,7 @@ define([
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
this.seriesCollection = new NzbDrone.Series.SeriesCollection();
|
||||
this.seriesCollection = new SeriesCollection();
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
@ -178,11 +192,13 @@ define([
|
||||
]
|
||||
};
|
||||
|
||||
this.toolbar.show(new NzbDrone.Shared.Toolbar.ToolbarLayout({
|
||||
this.toolbar.show(new ToolbarLayout({
|
||||
right : [ viewButtons],
|
||||
left : [ this.leftSideButtons],
|
||||
context: this
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
||||
return NzbDrone.Series.Index.SeriesIndexLayou;
|
||||
});
|
||||
|
@ -17,4 +17,7 @@ define(['app', 'Series/SeasonModel', 'backbone.pageable'], function (App, Season
|
||||
order : null
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return NzbDrone.Series.SeasonCollection;
|
||||
});
|
||||
|
@ -18,5 +18,7 @@ define(['app'], function () {
|
||||
seasonNumber: 0
|
||||
}
|
||||
});
|
||||
|
||||
return NzbDrone.Series.SeasonModel;
|
||||
});
|
||||
|
||||
|
@ -13,4 +13,6 @@ define(['app', 'Series/SeriesModel'], function () {
|
||||
order: -1
|
||||
}
|
||||
});
|
||||
|
||||
return NzbDrone.Series.SeriesCollection;
|
||||
});
|
||||
|
@ -1,16 +1,16 @@
|
||||
'use strict';
|
||||
|
||||
define([
|
||||
'app', 'Settings/SettingsModel','bootstrap'
|
||||
'app', 'marionette', 'Mixins/AsModelBoundView', 'bootstrap'
|
||||
|
||||
], function () {
|
||||
], function (App, Marionette, AsModelBoundView) {
|
||||
|
||||
NzbDrone.Settings.DownloadClient.DownloadClientView = Backbone.Marionette.ItemView.extend({
|
||||
var view = Marionette.ItemView.extend({
|
||||
template : 'Settings/DownloadClient/DownloadClientTemplate',
|
||||
className: 'form-horizontal',
|
||||
|
||||
ui: {
|
||||
bsSwitch : '.switch',
|
||||
bsSwitch : '.switch',
|
||||
tooltip : '.help-inline i',
|
||||
pathInput : '.x-path',
|
||||
sabConfig : '.x-sab-config',
|
||||
@ -76,4 +76,6 @@ define([
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return AsModelBoundView.call(view);
|
||||
});
|
||||
|
@ -1,7 +1,8 @@
|
||||
"use strict";
|
||||
define(['app'], function () {
|
||||
NzbDrone.Settings.General.GeneralSettingsModel = Backbone.Model.extend({
|
||||
url: NzbDrone.Constants.ApiRoot + '/settings/host',
|
||||
define(['app', 'backbone', 'Mixins/AsChangeTrackingModel'], function (App, Backbone, AsChangeTrackingModel) {
|
||||
var model = Backbone.Model.extend({
|
||||
|
||||
url: App.Constants.ApiRoot + '/settings/host',
|
||||
|
||||
initialize: function () {
|
||||
this.on('change', function () {
|
||||
@ -13,4 +14,6 @@ define(['app'], function () {
|
||||
}, this);
|
||||
}
|
||||
});
|
||||
|
||||
return AsChangeTrackingModel.call(model);
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
define(['app', 'Settings/SettingsModel', 'Shared/Messenger'], function () {
|
||||
define(['app', 'Mixins/AsModelBoundView'], function (App, AsModelBoundView) {
|
||||
|
||||
NzbDrone.Settings.General.GeneralView = Backbone.Marionette.ItemView.extend({
|
||||
var view = Backbone.Marionette.ItemView.extend({
|
||||
template: 'Settings/General/GeneralTemplate',
|
||||
|
||||
initialize: function () {
|
||||
@ -12,11 +12,13 @@ define(['app', 'Settings/SettingsModel', 'Shared/Messenger'], function () {
|
||||
if (!this.model.isSaved) {
|
||||
this.model.save(undefined, NzbDrone.Settings.SyncNotificaiton.callback({
|
||||
successMessage: 'General Settings saved',
|
||||
errorMessage: "Failed to save General Settings"
|
||||
errorMessage : "Failed to save General Settings"
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return AsModelBoundView.call(view);
|
||||
});
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
define(['app', 'Settings/Indexers/Model'], function () {
|
||||
NzbDrone.Settings.Indexers.Collection = Backbone.Collection.extend({
|
||||
url : NzbDrone.Constants.ApiRoot + '/indexer',
|
||||
model: NzbDrone.Settings.Indexers.Model
|
||||
define(['app', 'Settings/Indexers/Model'], function (App, IndexerModel) {
|
||||
return Backbone.Collection.extend({
|
||||
url : App.Constants.ApiRoot + '/indexer',
|
||||
model: IndexerModel
|
||||
});
|
||||
});
|
||||
|
@ -1,60 +1,63 @@
|
||||
'use strict';
|
||||
define(['app',
|
||||
'Settings/Indexers/ItemView',
|
||||
'Settings/Indexers/EditView',
|
||||
'Settings/SyncNotification'],
|
||||
function () {
|
||||
NzbDrone.Settings.Indexers.CollectionView = Backbone.Marionette.CompositeView.extend({
|
||||
itemView : NzbDrone.Settings.Indexers.ItemView,
|
||||
itemViewContainer : '#x-indexers',
|
||||
template : 'Settings/Indexers/CollectionTemplate',
|
||||
'marionette',
|
||||
'Shared/Messenger',
|
||||
'Settings/Indexers/ItemView',
|
||||
'Settings/Indexers/EditView',
|
||||
'Settings/Indexers/Collection'],
|
||||
function (App, Marionette, Messenger, IndexerItemView, IndexerEditView, IndexerCollection) {
|
||||
return Marionette.CompositeView.extend({
|
||||
itemView : IndexerItemView,
|
||||
itemViewContainer: '#x-indexers',
|
||||
template : 'Settings/Indexers/CollectionTemplate',
|
||||
|
||||
events: {
|
||||
'click .x-add': 'openSchemaModal'
|
||||
},
|
||||
events: {
|
||||
'click .x-add': 'openSchemaModal'
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
NzbDrone.vent.on(NzbDrone.Commands.SaveSettings, this._saveSettings, this);
|
||||
this.savedCount = 0;
|
||||
},
|
||||
initialize: function () {
|
||||
this.listenTo(App.vent, App.Commands.SaveSettings, this._saveSettings);
|
||||
this.savedCount = 0;
|
||||
},
|
||||
|
||||
openSchemaModal: function () {
|
||||
var self = this;
|
||||
//TODO: Is there a better way to deal with changing URLs?
|
||||
var schemaCollection = new NzbDrone.Settings.Indexers.Collection();
|
||||
schemaCollection.url = '/api/indexer/schema';
|
||||
schemaCollection.fetch({
|
||||
success: function (collection) {
|
||||
collection.url = '/api/indexer';
|
||||
var model = _.first(collection.models);
|
||||
model.set('id', undefined);
|
||||
model.set('name', '');
|
||||
openSchemaModal: function () {
|
||||
var self = this;
|
||||
//TODO: Is there a better way to deal with changing URLs?
|
||||
var schemaCollection = new IndexerCollection();
|
||||
schemaCollection.url = '/api/indexer/schema';
|
||||
schemaCollection.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, indexerCollection: self.collection});
|
||||
NzbDrone.modalRegion.show(view);
|
||||
var view = new IndexerEditView({ model: model, indexerCollection: self.collection});
|
||||
App.modalRegion.show(view);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_saveSettings: function () {
|
||||
var self = this;
|
||||
|
||||
_.each(this.collection.models, function (model, index, list) {
|
||||
model.saveIfChanged(NzbDrone.Settings.SyncNotificaiton.callback({
|
||||
errorMessage : 'Failed to save indexer: ' + model.get('name'),
|
||||
successCallback: self._saveSuccessful,
|
||||
context : self
|
||||
}));
|
||||
});
|
||||
|
||||
if (self.savedCount > 0) {
|
||||
Messenger.show({message: 'Indexer settings saved'});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_saveSettings: function () {
|
||||
var self = this;
|
||||
this.savedCount = 0;
|
||||
},
|
||||
|
||||
_.each(this.collection.models, function (model, index, list) {
|
||||
model.saveIfChanged(NzbDrone.Settings.SyncNotificaiton.callback({
|
||||
errorMessage: 'Failed to save indexer: ' + model.get('name'),
|
||||
successCallback: self._saveSuccessful,
|
||||
context: self
|
||||
}));
|
||||
});
|
||||
|
||||
if (self.savedCount > 0) {
|
||||
NzbDrone.Shared.Messenger.show({message: 'Indexer settings saved'});
|
||||
_saveSuccessful: function () {
|
||||
this.savedCount++;
|
||||
}
|
||||
|
||||
this.savedCount = 0;
|
||||
},
|
||||
_saveSuccessful: function () {
|
||||
this.savedCount++;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -2,12 +2,14 @@
|
||||
|
||||
define([
|
||||
'app',
|
||||
'Settings/Indexers/Model'
|
||||
'marionette',
|
||||
'Shared/Messenger',
|
||||
'Mixins/AsModelBoundView'
|
||||
|
||||
], function () {
|
||||
], function (App, Marionette, Messenger, AsModelBoundView) {
|
||||
|
||||
NzbDrone.Settings.Indexers.EditView = Backbone.Marionette.ItemView.extend({
|
||||
template : 'Settings/Indexers/EditTemplate',
|
||||
var view = Marionette.ItemView.extend({
|
||||
template: 'Settings/Indexers/EditTemplate',
|
||||
|
||||
events: {
|
||||
'click .x-save': 'save'
|
||||
@ -24,12 +26,12 @@ define([
|
||||
syncNotification: function (success, error, context) {
|
||||
return {
|
||||
success: function () {
|
||||
NzbDrone.Shared.Messenger.show({
|
||||
Messenger.show({
|
||||
message: success
|
||||
});
|
||||
|
||||
context.indexerCollection.add(context.model);
|
||||
NzbDrone.modalRegion.closeModal();
|
||||
App.modalRegion.closeModal();
|
||||
},
|
||||
|
||||
error: function () {
|
||||
@ -38,4 +40,7 @@ define([
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
return AsModelBoundView.call(view);
|
||||
|
||||
});
|
||||
|
@ -1,13 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
define([
|
||||
'app',
|
||||
'Settings/Indexers/Collection'
|
||||
define(['marionette'], function () {
|
||||
|
||||
], function () {
|
||||
|
||||
NzbDrone.Settings.Indexers.ItemView = Backbone.Marionette.ItemView.extend({
|
||||
template : 'Settings/Indexers/ItemTemplate',
|
||||
tagName : 'li'
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'Settings/Indexers/ItemTemplate',
|
||||
tagName : 'li'
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -1,9 +1,9 @@
|
||||
"use strict";
|
||||
define(['app',
|
||||
'Mixins/SaveIfChangedModel',
|
||||
'backbone.deepmodel'], function (App, SaveIfChangedModel, DeepModel) {
|
||||
NzbDrone.Settings.Indexers.Model = DeepModel.DeepModel.extend({
|
||||
define([
|
||||
'backbone.deepmodel', 'Mixins/AsChangeTrackingModel'], function (DeepModel, AsChangeTrackingModel) {
|
||||
var model = DeepModel.DeepModel.extend({
|
||||
|
||||
});
|
||||
|
||||
_.extend(NzbDrone.Settings.Indexers.Model.prototype, NzbDrone.Mixins.SaveIfChangedModel);
|
||||
return AsChangeTrackingModel.call(model);
|
||||
});
|
||||
|
@ -1,11 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
define([
|
||||
'app', 'Settings/SettingsModel'
|
||||
define(['marionette', 'Mixins/AsModelBoundview', 'bootstrap'], function (Marionette, AsModelBoundView) {
|
||||
|
||||
], function () {
|
||||
|
||||
NzbDrone.Settings.Misc.MiscView = Backbone.Marionette.ItemView.extend({
|
||||
var view = Marionette.ItemView.extend({
|
||||
template : 'Settings/Misc/MiscTemplate',
|
||||
className: 'form-horizontal',
|
||||
|
||||
@ -17,4 +14,6 @@ define([
|
||||
this.ui.tooltip.tooltip({ placement: 'right', html: true });
|
||||
}
|
||||
});
|
||||
|
||||
return AsModelBoundView.call(view);
|
||||
});
|
||||
|
@ -1,9 +1,10 @@
|
||||
"use strict";
|
||||
define(['app',
|
||||
'Mixins/SaveIfChangedModel'], function () {
|
||||
NzbDrone.Settings.Naming.NamingModel = Backbone.Model.extend({
|
||||
url: NzbDrone.Constants.ApiRoot + '/config/naming'
|
||||
'Mixins/AsChangeTrackingModel'], function (App, AsChangeTrackingModel) {
|
||||
var model = Backbone.Model.extend({
|
||||
url: App.Constants.ApiRoot + '/config/naming'
|
||||
});
|
||||
|
||||
_.extend(NzbDrone.Settings.Naming.NamingModel.prototype, NzbDrone.Mixins.SaveIfChangedModel);
|
||||
return AsChangeTrackingModel.call(model);
|
||||
|
||||
});
|
||||
|
@ -1,24 +1,28 @@
|
||||
'use strict';
|
||||
define(['app',
|
||||
'Settings/Naming/NamingModel',
|
||||
'Settings/SyncNotification'], function () {
|
||||
'marionette',
|
||||
'Settings/Naming/NamingModel',
|
||||
'Settings/SyncNotification',
|
||||
'Mixins/AsModelBoundView'], function (App, Marionette, NamingModel, SyncNotification, AsModelBoundView) {
|
||||
|
||||
NzbDrone.Settings.Naming.NamingView = Backbone.Marionette.ItemView.extend({
|
||||
template : 'Settings/Naming/NamingTemplate',
|
||||
var view = Marionette.ItemView.extend({
|
||||
template: 'Settings/Naming/NamingTemplate',
|
||||
|
||||
initialize: function () {
|
||||
this.model = new NzbDrone.Settings.Naming.NamingModel();
|
||||
this.model = new NamingModel();
|
||||
this.model.fetch();
|
||||
|
||||
NzbDrone.vent.on(NzbDrone.Commands.SaveSettings, this.saveSettings, this);
|
||||
this.listenTo(App.vent, App.Commands.SaveSettings, this.saveSettings);
|
||||
|
||||
},
|
||||
|
||||
saveSettings: function () {
|
||||
this.model.saveIfChanged(undefined, NzbDrone.Settings.SyncNotificaiton.callback({
|
||||
this.model.saveIfChanged(undefined, SyncNotification.callback({
|
||||
successMessage: 'Naming Settings saved',
|
||||
errorMessage: "Failed to save Naming Settings"
|
||||
errorMessage : "Failed to save Naming Settings"
|
||||
}));
|
||||
}
|
||||
});
|
||||
})
|
||||
;
|
||||
|
||||
return AsModelBoundView.call(view);
|
||||
});
|
||||
|
27
UI/Settings/Notifications/AddItemView.js
Normal file
27
UI/Settings/Notifications/AddItemView.js
Normal file
@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
|
||||
define([
|
||||
'app',
|
||||
'marionette',
|
||||
'Settings/Notifications/EditView'
|
||||
], function (App, Marionette, EditView) {
|
||||
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'Settings/Notifications/AddItemTemplate',
|
||||
tagName : 'li',
|
||||
|
||||
events: {
|
||||
'click': 'addNotification'
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
this.notificationCollection = options.notificationCollection;
|
||||
},
|
||||
|
||||
addNotification: function () {
|
||||
this.model.set('id', undefined);
|
||||
var editView = new EditView({ model: this.model, notificationCollection: this.notificationCollection });
|
||||
App.modalRegion.show(editView);
|
||||
}
|
||||
});
|
||||
});
|
@ -1,34 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
define([
|
||||
'app',
|
||||
'Settings/Notifications/Model'
|
||||
'marionette',
|
||||
'Settings/Notifications/AddItemView'
|
||||
], function (Marionette, AddItemView) {
|
||||
|
||||
], function () {
|
||||
|
||||
NzbDrone.Settings.Notifications.AddItemView = Backbone.Marionette.ItemView.extend({
|
||||
template : 'Settings/Notifications/AddItemTemplate',
|
||||
tagName : 'li',
|
||||
|
||||
events: {
|
||||
'click': 'addNotification'
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
this.notificationCollection = options.notificationCollection;
|
||||
},
|
||||
|
||||
addNotification: function () {
|
||||
this.model.set('id', undefined);
|
||||
var view = new NzbDrone.Settings.Notifications.EditView({ model: this.model, notificationCollection: this.notificationCollection });
|
||||
NzbDrone.modalRegion.show(view);
|
||||
}
|
||||
});
|
||||
|
||||
NzbDrone.Settings.Notifications.AddView = Backbone.Marionette.CompositeView.extend({
|
||||
itemView : NzbDrone.Settings.Notifications.AddItemView,
|
||||
itemViewContainer : '.notifications .items',
|
||||
template : 'Settings/Notifications/AddTemplate',
|
||||
return Marionette.CompositeView.extend({
|
||||
itemView : AddItemView,
|
||||
itemViewContainer: '.notifications .items',
|
||||
template : 'Settings/Notifications/AddTemplate',
|
||||
|
||||
itemViewOptions: function () {
|
||||
return {
|
||||
|
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
define(['app', 'Settings/Notifications/Model'], function () {
|
||||
NzbDrone.Settings.Notifications.Collection = Backbone.Collection.extend({
|
||||
url : NzbDrone.Constants.ApiRoot + '/notification',
|
||||
model: NzbDrone.Settings.Notifications.Model
|
||||
define(['app', 'Settings/Notifications/Model'], function (App, NotificationModel) {
|
||||
return Backbone.Collection.extend({
|
||||
url : App.Constants.ApiRoot + '/notification',
|
||||
model: NotificationModel
|
||||
});
|
||||
});
|
||||
|
@ -1,22 +1,28 @@
|
||||
'use strict';
|
||||
define(['app', 'Settings/Notifications/ItemView', 'Settings/Notifications/AddView'], function () {
|
||||
NzbDrone.Settings.Notifications.CollectionView = Backbone.Marionette.CompositeView.extend({
|
||||
itemView : NzbDrone.Settings.Notifications.ItemView,
|
||||
itemViewContainer : 'tbody',
|
||||
template : 'Settings/Notifications/CollectionTemplate',
|
||||
define([
|
||||
'app',
|
||||
'marionette',
|
||||
'Settings/Notifications/Collection',
|
||||
'Settings/Notifications/ItemView',
|
||||
'Settings/Notifications/AddView'
|
||||
], function (App, Marionette, NotificationCollection, NotificationItemView, AddSelectionNotificationView) {
|
||||
return Marionette.CompositeView.extend({
|
||||
itemView : NotificationItemView,
|
||||
itemViewContainer: 'tbody',
|
||||
template : 'Settings/Notifications/CollectionTemplate',
|
||||
|
||||
events: {
|
||||
'click .x-add': 'openSchemaModal'
|
||||
},
|
||||
|
||||
openSchemaModal: function () {
|
||||
var schemaCollection = new NzbDrone.Settings.Notifications.Collection();
|
||||
var schemaCollection = new NotificationCollection();
|
||||
schemaCollection.url = '/api/notification/schema';
|
||||
schemaCollection.fetch();
|
||||
schemaCollection.url = '/api/notification';
|
||||
|
||||
var view = new NzbDrone.Settings.Notifications.AddView({ collection: schemaCollection, notificationCollection: this.collection});
|
||||
NzbDrone.modalRegion.show(view);
|
||||
var view = new AddSelectionNotificationView({ collection: schemaCollection, notificationCollection: this.collection});
|
||||
App.modalRegion.show(view);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -1,7 +1,6 @@
|
||||
'use strict';
|
||||
define(['app', 'Settings/Notifications/Model'], function () {
|
||||
|
||||
NzbDrone.Settings.Notifications.DeleteView = Backbone.Marionette.ItemView.extend({
|
||||
define(['app', 'marionette'], function (App, Marionette) {
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'Settings/Notifications/DeleteTemplate',
|
||||
|
||||
events: {
|
||||
@ -9,12 +8,10 @@ define(['app', 'Settings/Notifications/Model'], function () {
|
||||
},
|
||||
|
||||
removeNotification: function () {
|
||||
var self = this;
|
||||
|
||||
this.model.destroy({
|
||||
wait : true,
|
||||
success: function (model) {
|
||||
NzbDrone.modalRegion.closeModal();
|
||||
success: function () {
|
||||
App.modalRegion.closeModal();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -2,23 +2,27 @@
|
||||
|
||||
define([
|
||||
'app',
|
||||
'marionette',
|
||||
'Settings/Notifications/Model',
|
||||
'Settings/Notifications/DeleteView'
|
||||
'Settings/Notifications/DeleteView',
|
||||
'Settings/SyncNotification',
|
||||
'Shared/Messenger',
|
||||
'Mixins/AsModelBoundView'
|
||||
|
||||
], function () {
|
||||
], function (App, Marionette, NotificationModel, DeleteView, SyncNotification, Messenger, AsModelBoundView) {
|
||||
|
||||
NzbDrone.Settings.Notifications.EditView = Backbone.Marionette.ItemView.extend({
|
||||
template : 'Settings/Notifications/EditTemplate',
|
||||
var model = Marionette.ItemView.extend({
|
||||
template: 'Settings/Notifications/EditTemplate',
|
||||
|
||||
events: {
|
||||
'click .x-save' : '_saveNotification',
|
||||
'click .x-remove' : '_deleteNotification',
|
||||
'click .x-test' : '_test'
|
||||
'click .x-save' : '_saveNotification',
|
||||
'click .x-remove': '_deleteNotification',
|
||||
'click .x-test' : '_test'
|
||||
},
|
||||
|
||||
ui: {
|
||||
testButton : '.x-test',
|
||||
testIcon : '.x-test-icon'
|
||||
testButton: '.x-test',
|
||||
testIcon : '.x-test-icon'
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
@ -30,22 +34,22 @@ define([
|
||||
var success = 'Notification Saved: ' + name;
|
||||
var fail = 'Failed to save notification: ' + name;
|
||||
|
||||
this.model.save(undefined, NzbDrone.Settings.SyncNotificaiton.callback({
|
||||
successMessage: success,
|
||||
errorMessage: fail,
|
||||
this.model.save(undefined, SyncNotification.callback({
|
||||
successMessage : success,
|
||||
errorMessage : fail,
|
||||
successCallback: this._saveSuccess,
|
||||
context: this
|
||||
context : this
|
||||
}));
|
||||
},
|
||||
|
||||
_deleteNotification: function () {
|
||||
var view = new NzbDrone.Settings.Notifications.DeleteView({ model: this.model });
|
||||
NzbDrone.modalRegion.show(view);
|
||||
var view = new DeleteView({ model: this.model });
|
||||
App.modalRegion.show(view);
|
||||
},
|
||||
|
||||
_saveSuccess: function () {
|
||||
this.notificationCollection.add(this.model, { merge: true });
|
||||
NzbDrone.modalRegion.closeModal();
|
||||
App.modalRegion.closeModal();
|
||||
},
|
||||
|
||||
_test: function () {
|
||||
@ -62,9 +66,9 @@ define([
|
||||
});
|
||||
|
||||
var self = this;
|
||||
var commandPromise = NzbDrone.Commands.Execute(testCommand, properties);
|
||||
var commandPromise = App.Commands.Execute(testCommand, properties);
|
||||
commandPromise.done(function () {
|
||||
NzbDrone.Shared.Messenger.show({
|
||||
Messenger.show({
|
||||
message: 'Notification settings tested successfully'
|
||||
});
|
||||
});
|
||||
@ -74,7 +78,7 @@ define([
|
||||
return;
|
||||
}
|
||||
|
||||
NzbDrone.Shared.Messenger.show({
|
||||
Messenger.show({
|
||||
message: 'Failed to test notification settings',
|
||||
type : 'error'
|
||||
});
|
||||
@ -90,4 +94,6 @@ define([
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return AsModelBoundView.call(model);
|
||||
});
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
define([
|
||||
'app',
|
||||
'Settings/Notifications/Collection',
|
||||
'marionette',
|
||||
'Settings/Notifications/EditView',
|
||||
'Settings/Notifications/DeleteView'
|
||||
|
||||
], function () {
|
||||
], function (App, Marionette, EditView, DeleteView) {
|
||||
|
||||
NzbDrone.Settings.Notifications.ItemView = Backbone.Marionette.ItemView.extend({
|
||||
template : 'Settings/Notifications/ItemTemplate',
|
||||
tagName: 'tr',
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'Settings/Notifications/ItemTemplate',
|
||||
tagName : 'tr',
|
||||
|
||||
events: {
|
||||
'click .x-edit' : 'edit',
|
||||
@ -18,13 +18,13 @@ define([
|
||||
},
|
||||
|
||||
edit: function () {
|
||||
var view = new NzbDrone.Settings.Notifications.EditView({ model: this.model, notificationCollection: this.model.collection});
|
||||
NzbDrone.modalRegion.show(view);
|
||||
var view = new EditView({ model: this.model, notificationCollection: this.model.collection});
|
||||
App.modalRegion.show(view);
|
||||
},
|
||||
|
||||
deleteNotification: function () {
|
||||
var view = new NzbDrone.Settings.Notifications.DeleteView({ model: this.model});
|
||||
NzbDrone.modalRegion.show(view);
|
||||
var view = new DeleteView({ model: this.model});
|
||||
App.modalRegion.show(view);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
define(['app', 'backbone.deepmodel'], function (App, DeepModel) {
|
||||
NzbDrone.Settings.Notifications.Model = DeepModel.DeepModel.extend({
|
||||
return DeepModel.DeepModel.extend({
|
||||
});
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
define(['app', 'Quality/QualityProfileModel'], function () {
|
||||
define(['app', 'marionette', 'Mixins/AsModelBoundView'], function (App, Marionette, AsModelBoundView) {
|
||||
|
||||
NzbDrone.Settings.Quality.Profile.EditQualityProfileView = Backbone.Marionette.ItemView.extend({
|
||||
var view = Marionette.ItemView.extend({
|
||||
template: 'Settings/Quality/Profile/EditQualityProfileTemplate',
|
||||
|
||||
events: {
|
||||
@ -51,8 +51,10 @@ define(['app', 'Quality/QualityProfileModel'], function () {
|
||||
|
||||
this.model.save();
|
||||
this.trigger('saved');
|
||||
NzbDrone.modalRegion.closeModal();
|
||||
App.modalRegion.closeModal();
|
||||
}
|
||||
});
|
||||
|
||||
return AsModelBoundView.call(view);
|
||||
|
||||
});
|
||||
|
@ -1,20 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
define(['app', 'Settings/Quality/Profile/QualityProfileView'], function () {
|
||||
NzbDrone.Settings.Quality.Profile.QualityProfileCollectionView = Backbone.Marionette.CompositeView.extend({
|
||||
itemView : NzbDrone.Settings.Quality.Profile.QualityProfileView,
|
||||
define(['marionette', 'Settings/Quality/Profile/QualityProfileView'], function (Marionette, QualityProfileView) {
|
||||
return Marionette.CompositeView.extend({
|
||||
itemView : QualityProfileView,
|
||||
itemViewContainer: 'tbody',
|
||||
template : 'Settings/Quality/Profile/QualityProfileCollectionTemplate',
|
||||
|
||||
initialize: function (options) {
|
||||
},
|
||||
|
||||
ui: {
|
||||
|
||||
},
|
||||
|
||||
onCompositeCollectionRendered: function () {
|
||||
|
||||
}
|
||||
template : 'Settings/Quality/Profile/QualityProfileCollectionTemplate'
|
||||
});
|
||||
});
|
||||
|
@ -2,12 +2,12 @@
|
||||
|
||||
define([
|
||||
'app',
|
||||
'Quality/QualityProfileCollection',
|
||||
'marionette',
|
||||
'Settings/Quality/Profile/EditQualityProfileView'
|
||||
|
||||
], function () {
|
||||
], function (App, Marionette, EditProfileView) {
|
||||
|
||||
NzbDrone.Settings.Quality.Profile.QualityProfileView = Backbone.Marionette.ItemView.extend({
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'Settings/Quality/Profile/QualityProfileTemplate',
|
||||
tagName : 'tr',
|
||||
|
||||
@ -21,8 +21,8 @@ define([
|
||||
},
|
||||
|
||||
edit: function () {
|
||||
var view = new NzbDrone.Settings.Quality.Profile.EditQualityProfileView({ model: this.model});
|
||||
NzbDrone.modalRegion.show(view);
|
||||
var view = new EditProfileView({ model: this.model});
|
||||
App.modalRegion.show(view);
|
||||
},
|
||||
|
||||
removeQuality: function () {
|
||||
|
@ -1,13 +1,14 @@
|
||||
"use strict";
|
||||
define([
|
||||
'app',
|
||||
'marionette',
|
||||
'Quality/QualityProfileCollection',
|
||||
'Quality/QualitySizeCollection',
|
||||
'Settings/Quality/Profile/QualityProfileCollectionView',
|
||||
'Quality/QualitySizeCollection',
|
||||
'Settings/Quality/Size/QualitySizeCollectionView'
|
||||
],
|
||||
function (app, qualityProfileCollection) {
|
||||
NzbDrone.Settings.Quality.QualityLayout = Backbone.Marionette.Layout.extend({
|
||||
function (App, Marionette, QualityProfileCollection, QualityProfileCollectionView, QualitySizeCollection, QualitySizeCollectionView) {
|
||||
return Marionette.Layout.extend({
|
||||
template: 'Settings/Quality/QualityLayoutTemplate',
|
||||
|
||||
regions: {
|
||||
@ -16,24 +17,16 @@ define([
|
||||
qualitySize : '#quality-size'
|
||||
},
|
||||
|
||||
ui: {
|
||||
|
||||
},
|
||||
|
||||
events: {
|
||||
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
this.settings = options.settings;
|
||||
qualityProfileCollection.fetch();
|
||||
this.qualitySizeCollection = new NzbDrone.Quality.QualitySizeCollection();
|
||||
QualityProfileCollection.fetch();
|
||||
this.qualitySizeCollection = new QualitySizeCollection();
|
||||
this.qualitySizeCollection.fetch();
|
||||
},
|
||||
|
||||
onRender: function () {
|
||||
this.qualityProfile.show(new NzbDrone.Settings.Quality.Profile.QualityProfileCollectionView({collection: qualityProfileCollection}));
|
||||
this.qualitySize.show(new NzbDrone.Settings.Quality.Size.QualitySizeCollectionView({collection: this.qualitySizeCollection}));
|
||||
this.qualityProfile.show(new QualityProfileCollectionView({collection: QualityProfileCollection}));
|
||||
this.qualitySize.show(new QualitySizeCollectionView({collection: this.qualitySizeCollection}));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -1,21 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
define(['app', 'Settings/Quality/Size/QualitySizeView'], function () {
|
||||
NzbDrone.Settings.Quality.Size.QualitySizeCollectionView = Backbone.Marionette.CompositeView.extend({
|
||||
itemView : NzbDrone.Settings.Quality.Size.QualitySizeView,
|
||||
define(['marionette', 'Settings/Quality/Size/QualitySizeView'], function (Marionette, QualitySizeView) {
|
||||
return Marionette.CompositeView.extend({
|
||||
itemView : QualitySizeView,
|
||||
itemViewContainer: '#quality-sizes-container',
|
||||
template : 'Settings/Quality/Size/QualitySizeCollectionTemplate',
|
||||
|
||||
initialize: function () {
|
||||
|
||||
},
|
||||
|
||||
ui: {
|
||||
|
||||
},
|
||||
|
||||
onCompositeCollectionRendered: function () {
|
||||
|
||||
}
|
||||
template : 'Settings/Quality/Size/QualitySizeCollectionTemplate'
|
||||
});
|
||||
});
|
||||
|
@ -1,13 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
define([
|
||||
'app',
|
||||
'Quality/QualitySizeCollection',
|
||||
'bootstrap.slider'
|
||||
define(['marionette', 'bootstrap.slider'], function (Marionette) {
|
||||
|
||||
], function () {
|
||||
|
||||
NzbDrone.Settings.Quality.Size.QualitySizeView = Backbone.Marionette.ItemView.extend({
|
||||
return Marionette.ItemView.extend({
|
||||
template : 'Settings/Quality/Size/QualitySizeTemplate',
|
||||
className: 'quality-size-item',
|
||||
|
||||
|
@ -1,17 +1,37 @@
|
||||
"use strict";
|
||||
define([
|
||||
'app',
|
||||
'marionette',
|
||||
'Settings/SettingsModel',
|
||||
'Settings/General/GeneralSettingsModel',
|
||||
'Settings/Naming/NamingView',
|
||||
'Settings/Naming/NamingModel',
|
||||
'Settings/Quality/QualityLayout',
|
||||
'Settings/Indexers/CollectionView',
|
||||
'Settings/Indexers/Collection',
|
||||
'Settings/DownloadClient/DownloadClientView',
|
||||
'Settings/Notifications/CollectionView',
|
||||
'Settings/Notifications/Collection',
|
||||
'Settings/General/GeneralView',
|
||||
'Settings/General/GeneralSettingsModel',
|
||||
'Settings/Misc/MiscView'
|
||||
'Settings/Misc/MiscView',
|
||||
'Settings/SyncNotification'
|
||||
],
|
||||
function () {
|
||||
NzbDrone.Settings.SettingsLayout = Backbone.Marionette.Layout.extend({
|
||||
function (App,
|
||||
Marionette,
|
||||
SettingsModel,
|
||||
GeneralSettingsModel,
|
||||
NamingView,
|
||||
NamingModel,
|
||||
QualityLayout,
|
||||
IndexerCollectionView,
|
||||
IndexerCollection,
|
||||
DownloadClientView,
|
||||
NotificationCollectionView,
|
||||
NotificationCollection,
|
||||
GeneralView,
|
||||
MiscView,
|
||||
SyncNotification) {
|
||||
return Marionette.Layout.extend({
|
||||
template: 'Settings/SettingsLayoutTemplate',
|
||||
|
||||
regions: {
|
||||
@ -51,7 +71,7 @@ define([
|
||||
}
|
||||
|
||||
this.ui.namingTab.tab('show');
|
||||
NzbDrone.Router.navigate('settings/naming');
|
||||
App.Router.navigate('settings/naming');
|
||||
},
|
||||
|
||||
showQuality: function (e) {
|
||||
@ -60,7 +80,7 @@ define([
|
||||
}
|
||||
|
||||
this.ui.qualityTab.tab('show');
|
||||
NzbDrone.Router.navigate('settings/quality');
|
||||
App.Router.navigate('settings/quality');
|
||||
},
|
||||
|
||||
showIndexers: function (e) {
|
||||
@ -69,7 +89,7 @@ define([
|
||||
}
|
||||
|
||||
this.ui.indexersTab.tab('show');
|
||||
NzbDrone.Router.navigate('settings/indexers');
|
||||
App.Router.navigate('settings/indexers');
|
||||
},
|
||||
|
||||
showDownloadClient: function (e) {
|
||||
@ -78,7 +98,7 @@ define([
|
||||
}
|
||||
|
||||
this.ui.downloadClientTab.tab('show');
|
||||
NzbDrone.Router.navigate('settings/downloadclient');
|
||||
App.Router.navigate('settings/downloadclient');
|
||||
},
|
||||
|
||||
showNotifications: function (e) {
|
||||
@ -87,7 +107,7 @@ define([
|
||||
}
|
||||
|
||||
this.ui.notificationsTab.tab('show');
|
||||
NzbDrone.Router.navigate('settings/notifications');
|
||||
App.Router.navigate('settings/notifications');
|
||||
},
|
||||
|
||||
showGeneral: function (e) {
|
||||
@ -96,7 +116,7 @@ define([
|
||||
}
|
||||
|
||||
this.ui.generalTab.tab('show');
|
||||
NzbDrone.Router.navigate('settings/general');
|
||||
App.Router.navigate('settings/general');
|
||||
},
|
||||
|
||||
showMisc: function (e) {
|
||||
@ -105,23 +125,23 @@ define([
|
||||
}
|
||||
|
||||
this.ui.miscTab.tab('show');
|
||||
NzbDrone.Router.navigate('settings/misc');
|
||||
App.Router.navigate('settings/misc');
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
this.settings = new NzbDrone.Settings.SettingsModel();
|
||||
this.settings = new SettingsModel();
|
||||
this.settings.fetch();
|
||||
|
||||
this.generalSettings = new NzbDrone.Settings.General.GeneralSettingsModel();
|
||||
this.generalSettings = new GeneralSettingsModel();
|
||||
this.generalSettings.fetch();
|
||||
|
||||
this.namingSettings = new NzbDrone.Settings.Naming.NamingModel();
|
||||
this.namingSettings = new NamingModel();
|
||||
this.namingSettings.fetch();
|
||||
|
||||
this.indexerSettings = new NzbDrone.Settings.Indexers.Collection();
|
||||
this.indexerSettings = new IndexerCollection();
|
||||
this.indexerSettings.fetch();
|
||||
|
||||
this.notificationSettings = new NzbDrone.Settings.Notifications.Collection();
|
||||
this.notificationSettings = new NotificationCollection();
|
||||
this.notificationSettings.fetch();
|
||||
|
||||
if (options.action) {
|
||||
@ -130,13 +150,13 @@ define([
|
||||
},
|
||||
|
||||
onRender: function () {
|
||||
this.naming.show(new NzbDrone.Settings.Naming.NamingView());
|
||||
this.quality.show(new NzbDrone.Settings.Quality.QualityLayout({settings: this.settings}));
|
||||
this.indexers.show(new NzbDrone.Settings.Indexers.CollectionView({collection: this.indexerSettings}));
|
||||
this.downloadClient.show(new NzbDrone.Settings.DownloadClient.DownloadClientView({model: this.settings}));
|
||||
this.notifications.show(new NzbDrone.Settings.Notifications.CollectionView({collection: this.notificationSettings}));
|
||||
this.general.show(new NzbDrone.Settings.General.GeneralView({model: this.generalSettings}));
|
||||
this.misc.show(new NzbDrone.Settings.Misc.MiscView({model: this.settings}));
|
||||
this.naming.show(new NamingView());
|
||||
this.quality.show(new QualityLayout({settings: this.settings}));
|
||||
this.indexers.show(new IndexerCollectionView({collection: this.indexerSettings}));
|
||||
this.downloadClient.show(new DownloadClientView({model: this.settings}));
|
||||
this.notifications.show(new NotificationCollectionView({collection: this.notificationSettings}));
|
||||
this.general.show(new GeneralView({model: this.generalSettings}));
|
||||
this.misc.show(new MiscView({model: this.settings}));
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
@ -166,11 +186,11 @@ define([
|
||||
|
||||
save: function () {
|
||||
|
||||
NzbDrone.vent.trigger(NzbDrone.Commands.SaveSettings);
|
||||
App.vent.trigger(App.Commands.SaveSettings);
|
||||
|
||||
this.settings.saveIfChanged(undefined, NzbDrone.Settings.SyncNotificaiton.callback({
|
||||
this.settings.saveIfChanged(undefined, SyncNotification.callback({
|
||||
successMessage: 'Settings saved',
|
||||
errorMessage: "Failed to save settings"
|
||||
errorMessage : "Failed to save settings"
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
@ -1,9 +1,10 @@
|
||||
"use strict";
|
||||
define(['app',
|
||||
'Mixins/SaveIfChangedModel'], function () {
|
||||
NzbDrone.Settings.SettingsModel = Backbone.Model.extend({
|
||||
url: NzbDrone.Constants.ApiRoot + '/settings'
|
||||
'backbone',
|
||||
'Mixins/SaveIfChangedModel'], function (App, Backbone, AsChangeTrackingModel) {
|
||||
var model = Backbone.Model.extend({
|
||||
url: App.Constants.ApiRoot + '/settings'
|
||||
});
|
||||
|
||||
_.extend(NzbDrone.Settings.SettingsModel.prototype, NzbDrone.Mixins.SaveIfChangedModel);
|
||||
return AsChangeTrackingModel.call(model);
|
||||
});
|
||||
|
@ -1,31 +1,27 @@
|
||||
"use strict";
|
||||
define([
|
||||
'app'
|
||||
],
|
||||
function () {
|
||||
NzbDrone.Settings.SyncNotificaiton = {
|
||||
callback: function (options) {
|
||||
return {
|
||||
success: function () {
|
||||
if (options.successMessage) {
|
||||
NzbDrone.Shared.Messenger.show({message: options.successMessage});
|
||||
}
|
||||
|
||||
if (options.successCallback) {
|
||||
options.successCallback.call(options.context);
|
||||
}
|
||||
},
|
||||
error : function () {
|
||||
if (options.errorMessage) {
|
||||
NzbDrone.Shared.Messenger.show({message: options.errorMessage, type: 'error'});
|
||||
}
|
||||
|
||||
if (options.errorCallback) {
|
||||
options.errorCallback.call(options.context);
|
||||
}
|
||||
define(['shared/messenger'], function (Messenger) {
|
||||
return {
|
||||
callback: function (options) {
|
||||
return {
|
||||
success: function () {
|
||||
if (options.successMessage) {
|
||||
Messenger.show({message: options.successMessage});
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
if (options.successCallback) {
|
||||
options.successCallback.call(options.context);
|
||||
}
|
||||
},
|
||||
error : function () {
|
||||
if (options.errorMessage) {
|
||||
Messenger.show({message: options.errorMessage, type: 'error'});
|
||||
}
|
||||
|
||||
if (options.errorCallback) {
|
||||
options.errorCallback.call(options.context);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
});
|
||||
|
@ -5,4 +5,6 @@ define(['app'], function () {
|
||||
template : 'Shared/LoadingTemplate',
|
||||
className: 'nz-loading row'
|
||||
});
|
||||
});
|
||||
|
||||
return NzbDrone.Shared.LoadingView;
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
define(['app'], function () {
|
||||
NzbDrone.Shared.Messenger = {
|
||||
define(function () {
|
||||
return {
|
||||
show: function (options) {
|
||||
|
||||
if (!options.type) {
|
||||
|
@ -1,5 +1,10 @@
|
||||
"use strict";
|
||||
define(['app', 'Shared/Toolbar/Radio/RadioButtonCollectionView','Shared/Toolbar/Button/ButtonCollectionView', 'Shared/Toolbar/ButtonCollection'], function () {
|
||||
define([
|
||||
'app',
|
||||
'Shared/Toolbar/Radio/RadioButtonCollectionView',
|
||||
'Shared/Toolbar/Button/ButtonCollectionView',
|
||||
'Shared/Toolbar/ButtonCollection'
|
||||
], function () {
|
||||
NzbDrone.Shared.Toolbar.ToolbarLayout = Backbone.Marionette.Layout.extend({
|
||||
template: 'Shared/Toolbar/ToolbarLayoutTemplate',
|
||||
|
||||
@ -89,6 +94,8 @@ define(['app', 'Shared/Toolbar/Radio/RadioButtonCollectionView','Shared/Toolbar/
|
||||
}
|
||||
});
|
||||
|
||||
return NzbDrone.Shared.Toolbar.ToolbarLayout;
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
59
UI/app.js
59
UI/app.js
@ -2,22 +2,23 @@
|
||||
require.config({
|
||||
|
||||
paths: {
|
||||
'backbone' : 'JsLibraries/backbone',
|
||||
'handlebars' : 'JsLibraries/handlebars.runtime',
|
||||
'bootstrap' : 'JsLibraries/bootstrap',
|
||||
'bootstrap.slider' : 'JsLibraries/bootstrap.slider',
|
||||
'backbone.mutators' : 'JsLibraries/backbone.mutators',
|
||||
'backbone.deepmodel': 'JsLibraries/backbone.deep.model',
|
||||
'backbone.pageable' : 'JsLibraries/backbone.pageable',
|
||||
'backgrid' : 'JsLibraries/backbone.backgrid',
|
||||
'backgrid.paginator': 'JsLibraries/backbone.backgrid.paginator',
|
||||
'fullcalendar' : 'JsLibraries/fullcalendar',
|
||||
'backstrech' : 'JsLibraries/jquery.backstretch',
|
||||
'$' : 'JsLibraries/jquery',
|
||||
'underscore' : 'JsLibraries/underscore',
|
||||
'marionette' : 'JsLibraries/backbone.marionette',
|
||||
'signalR' : 'JsLibraries/jquery.signalR',
|
||||
'libs' : 'JsLibraries/'
|
||||
'backbone' : 'JsLibraries/backbone',
|
||||
'handlebars' : 'JsLibraries/handlebars.runtime',
|
||||
'bootstrap' : 'JsLibraries/bootstrap',
|
||||
'bootstrap.slider' : 'JsLibraries/bootstrap.slider',
|
||||
'backbone.mutators' : 'JsLibraries/backbone.mutators',
|
||||
'backbone.deepmodel' : 'JsLibraries/backbone.deep.model',
|
||||
'backbone.pageable' : 'JsLibraries/backbone.pageable',
|
||||
'backbone.modelbinder': 'JsLibraries/backbone.modelbinder',
|
||||
'backgrid' : 'JsLibraries/backbone.backgrid',
|
||||
'backgrid.paginator' : 'JsLibraries/backbone.backgrid.paginator',
|
||||
'fullcalendar' : 'JsLibraries/fullcalendar',
|
||||
'backstrech' : 'JsLibraries/jquery.backstretch',
|
||||
'$' : 'JsLibraries/jquery',
|
||||
'underscore' : 'JsLibraries/underscore',
|
||||
'marionette' : 'JsLibraries/backbone.marionette',
|
||||
'signalR' : 'JsLibraries/jquery.signalR',
|
||||
'libs' : 'JsLibraries/'
|
||||
},
|
||||
|
||||
shim: {
|
||||
@ -53,10 +54,15 @@ require.config({
|
||||
},
|
||||
|
||||
marionette: {
|
||||
deps : ['backbone', 'mixins/backbone.marionette.templates'],
|
||||
deps : [
|
||||
'backbone',
|
||||
'mixins/backbone.marionette.templates',
|
||||
'mixins/AsNamedView'
|
||||
],
|
||||
exports: 'Marionette',
|
||||
init : function (Backbone, TemplateMixin) {
|
||||
init : function (Backbone, TemplateMixin, AsNamedView) {
|
||||
TemplateMixin.call(Marionette.TemplateCache);
|
||||
AsNamedView.call(Marionette.ItemView.prototype);
|
||||
}
|
||||
},
|
||||
|
||||
@ -143,19 +149,6 @@ define([
|
||||
|
||||
window.NzbDrone.Calendar = {};
|
||||
|
||||
window.NzbDrone.Settings = {
|
||||
Naming : {},
|
||||
Quality : {
|
||||
Size : {},
|
||||
Profile: {}
|
||||
},
|
||||
Indexers : {},
|
||||
DownloadClient: {},
|
||||
Notifications : {},
|
||||
General : {},
|
||||
Misc : {}
|
||||
};
|
||||
|
||||
window.NzbDrone.Missing = {};
|
||||
window.NzbDrone.History = {};
|
||||
window.NzbDrone.Logs = {};
|
||||
@ -171,8 +164,8 @@ define([
|
||||
};
|
||||
|
||||
window.NzbDrone.Constants = {
|
||||
ApiRoot: '/api',
|
||||
Version: '0.0.0.0',
|
||||
ApiRoot : '/api',
|
||||
Version : '0.0.0.0',
|
||||
BuildDate: '2013-01-01T00:00:00Z'
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user