mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-17 15:02:34 +02:00
moved most of addseries to use require.js
This commit is contained in:
parent
5e26596623
commit
52d815b1d4
2
NzbDrone.Web/ClassDiagram1.cd
Normal file
2
NzbDrone.Web/ClassDiagram1.cd
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ClassDiagram />
|
@ -204,12 +204,14 @@
|
|||||||
<Content Include="_backboneApp\AddSeries\Existing\ImportSeriesView.js" />
|
<Content Include="_backboneApp\AddSeries\Existing\ImportSeriesView.js" />
|
||||||
<Content Include="_backboneApp\AddSeries\Existing\UnmappedFolderModel.js" />
|
<Content Include="_backboneApp\AddSeries\Existing\UnmappedFolderModel.js" />
|
||||||
<Content Include="_backboneApp\AddSeries\Existing\RootFolderCompositeViewTemplate.html" />
|
<Content Include="_backboneApp\AddSeries\Existing\RootFolderCompositeViewTemplate.html" />
|
||||||
<Content Include="_backboneApp\AddSeries\RootFolders\RootDirTemplate.html" />
|
<Content Include="_backboneApp\AddSeries\RootFolders\RootFolderTemplate.html" />
|
||||||
<Content Include="_backboneApp\AddSeries\RootFolders\RootDirView.js" />
|
<Content Include="_backboneApp\AddSeries\RootFolders\RootFolderView.js" />
|
||||||
<Content Include="_backboneApp\AddSeries\RootFolders\RootDirItemTemplate.html" />
|
<Content Include="_backboneApp\AddSeries\RootFolders\RootFolderItemTemplate.html" />
|
||||||
<Content Include="_backboneApp\AddSeries\RootFolders\RootDirModel.js" />
|
<Content Include="_backboneApp\AddSeries\RootFolders\RootFolderModel.js" />
|
||||||
<Content Include="_backboneApp\AddSeries\RootFolders\RootDirCollection.js" />
|
<Content Include="_backboneApp\AddSeries\RootFolders\RootFolderCollection.js" />
|
||||||
<Content Include="_backboneApp\Content\jquery.dataTables.bootstrap.css" />
|
<Content Include="_backboneApp\Content\jquery.dataTables.bootstrap.css" />
|
||||||
|
<Content Include="_backboneApp\JsLibraries\jquery.js" />
|
||||||
|
<Content Include="_backboneApp\Routing.js" />
|
||||||
<Content Include="_backboneApp\JsLibraries\backbone.modelbinder.js" />
|
<Content Include="_backboneApp\JsLibraries\backbone.modelbinder.js" />
|
||||||
<Content Include="_backboneApp\AddSeries\New\AddNewSeriesTemplate.html" />
|
<Content Include="_backboneApp\AddSeries\New\AddNewSeriesTemplate.html" />
|
||||||
<Content Include="_backboneApp\AddSeries\New\AddNewSeriesView.js" />
|
<Content Include="_backboneApp\AddSeries\New\AddNewSeriesView.js" />
|
||||||
@ -220,6 +222,7 @@
|
|||||||
<Content Include="_backboneApp\JsLibraries\jquery.dataTables.extensions.js" />
|
<Content Include="_backboneApp\JsLibraries\jquery.dataTables.extensions.js" />
|
||||||
<Content Include="_backboneApp\JsLibraries\jquery.dataTables-1.10.0-dev.js" />
|
<Content Include="_backboneApp\JsLibraries\jquery.dataTables-1.10.0-dev.js" />
|
||||||
<Content Include="_backboneApp\JsLibraries\jquery.dataTables.bootstrap.pagination.js" />
|
<Content Include="_backboneApp\JsLibraries\jquery.dataTables.bootstrap.pagination.js" />
|
||||||
|
<Content Include="_backboneApp\JsLibraries\require-jquery.js" />
|
||||||
<Content Include="_backboneApp\Quality\qualityProfileModel.js" />
|
<Content Include="_backboneApp\Quality\qualityProfileModel.js" />
|
||||||
<Content Include="_backboneApp\Quality\qualityProfileCollection.js" />
|
<Content Include="_backboneApp\Quality\qualityProfileCollection.js" />
|
||||||
<Content Include="_backboneApp\Quality\qualityTypeModel.js" />
|
<Content Include="_backboneApp\Quality\qualityTypeModel.js" />
|
||||||
@ -432,11 +435,11 @@
|
|||||||
<Content Include="_backboneApp\Shared\SpinnerTemplate.html" />
|
<Content Include="_backboneApp\Shared\SpinnerTemplate.html" />
|
||||||
<Content Include="_backboneApp\Shared\SpinnerView.js" />
|
<Content Include="_backboneApp\Shared\SpinnerView.js" />
|
||||||
<Content Include="Eloquera.config" />
|
<Content Include="Eloquera.config" />
|
||||||
|
<Content Include="ClassDiagram1.cd" />
|
||||||
<None Include="_backboneApp\JsLibraries\jquery-1.8.2.intellisense.js" />
|
<None Include="_backboneApp\JsLibraries\jquery-1.8.2.intellisense.js" />
|
||||||
<Content Include="_backboneApp\JsLibraries\backbone.collectionbinder.js" />
|
<Content Include="_backboneApp\JsLibraries\backbone.collectionbinder.js" />
|
||||||
<Content Include="_backboneApp\JsLibraries\backbone.debug.js" />
|
<Content Include="_backboneApp\JsLibraries\backbone.debug.js" />
|
||||||
<Content Include="_backboneApp\JsLibraries\handlebars.js" />
|
<Content Include="_backboneApp\JsLibraries\handlebars.js" />
|
||||||
<Content Include="_backboneApp\JsLibraries\jquery.js" />
|
|
||||||
<Content Include="_backboneApp\JsLibraries\jquery-ui-1.9.0.js" />
|
<Content Include="_backboneApp\JsLibraries\jquery-ui-1.9.0.js" />
|
||||||
<Content Include="_backboneApp\JsLibraries\backbone.marionette.viewswapper.js" />
|
<Content Include="_backboneApp\JsLibraries\backbone.marionette.viewswapper.js" />
|
||||||
<Content Include="_backboneApp\JsLibraries\sugar.js" />
|
<Content Include="_backboneApp\JsLibraries\sugar.js" />
|
||||||
|
@ -4,12 +4,10 @@
|
|||||||
|
|
||||||
@using Cassette.Scripts
|
@using Cassette.Scripts
|
||||||
@using Cassette.Stylesheets
|
@using Cassette.Stylesheets
|
||||||
@using NzbDrone.Web
|
|
||||||
@using NzbDrone.Web.Backbone.NzbDrone
|
@using NzbDrone.Web.Backbone.NzbDrone
|
||||||
@using NzbDrone.Web.Helpers
|
@using NzbDrone.Web.Helpers
|
||||||
@{
|
@{
|
||||||
Bundles.Reference<StylesheetBundle>(CassetteBundleConfiguration.BASE_STYLE);
|
Bundles.Reference<StylesheetBundle>(CassetteBundleConfiguration.BASE_STYLE);
|
||||||
Bundles.Reference<ScriptBundle>(CassetteBundleConfiguration.NZBDRONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
@ -45,7 +43,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="logo" class="row">
|
<div id="logo" class="row">
|
||||||
<div class="span18 offset2">
|
<div class="span18 offset2">
|
||||||
Single page
|
Single page
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="content" class="row">
|
<div id="content" class="row">
|
||||||
@ -65,9 +63,7 @@
|
|||||||
<div id="footer-region" class="span20"></div>
|
<div id="footer-region" class="span20"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@Bundles.RenderScripts()
|
<script data-main="/_backboneApp/app" src="/_backboneApp/JsLibraries/require-jquery.js"></script>
|
||||||
<script type="text/javascript">
|
<script src="/_backboneApp/Routing.js"></script>
|
||||||
NzbDrone.start();
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,111 +1,111 @@
|
|||||||
/// <reference path="../app.js" />
|
define([
|
||||||
/// <reference path="New/AddNewSeriesView.js" />
|
'app',
|
||||||
/// <reference path="RootFolders/RootDirView.js" />
|
'AddSeries/RootFolders/RootFolderView',
|
||||||
/// <reference path="../Quality/qualityProfileCollection.js" />
|
'AddSeries/RootFolders/RootFolderCollection',
|
||||||
/// <reference path="../Shared/SpinnerView.js" />
|
'AddSeries/New/AddNewSeriesView',
|
||||||
/// <reference path="Existing/ImportSeriesView.js" />
|
'AddSeries/Existing/ImportSeriesView',
|
||||||
|
'Quality/QualityProfileCollection'
|
||||||
|
],
|
||||||
|
function () {
|
||||||
|
NzbDrone.AddSeries.AddSeriesLayout = Backbone.Marionette.Layout.extend({
|
||||||
|
template: 'AddSeries/addSeriesLayoutTemplate',
|
||||||
|
|
||||||
NzbDrone.AddSeries.AddSeriesLayout = Backbone.Marionette.Layout.extend({
|
regions: {
|
||||||
template: 'AddSeries/addSeriesLayoutTemplate',
|
addNew: '#add-new',
|
||||||
|
importExisting: '#import-existing',
|
||||||
|
rootFolders: '#root-folders'
|
||||||
|
},
|
||||||
|
|
||||||
regions: {
|
ui: {
|
||||||
addNew: '#add-new',
|
addNewTab: '.x-add-new-tab',
|
||||||
importExisting: '#import-existing',
|
importExistingTab: '.x-import-existing-tab',
|
||||||
rootFolders: '#root-folders'
|
rootFoldersTab: '.x-root-folders-tab'
|
||||||
},
|
},
|
||||||
|
|
||||||
ui: {
|
events: {
|
||||||
addNewTab: '.x-add-new-tab',
|
'click .x-add-new-tab': 'showAddNew',
|
||||||
importExistingTab: '.x-import-existing-tab',
|
'click .x-import-existing-tab': 'showImport',
|
||||||
rootFoldersTab: '.x-root-folders-tab'
|
'click .x-root-folders-tab': 'showRootFolders'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
showAddNew: function (e) {
|
||||||
|
if (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
events: {
|
this.ui.addNewTab.tab('show');
|
||||||
'click .x-add-new-tab': 'showAddNew',
|
NzbDrone.Router.navigate('series/add/new');
|
||||||
'click .x-import-existing-tab': 'showImport',
|
|
||||||
'click .x-root-folders-tab': 'showRootFolders'
|
|
||||||
},
|
|
||||||
|
|
||||||
showAddNew: function (e) {
|
},
|
||||||
if (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.ui.addNewTab.tab('show');
|
showImport: function (e) {
|
||||||
NzbDrone.Router.navigate('series/add/new');
|
if (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
},
|
this.ui.importExistingTab.tab('show');
|
||||||
|
NzbDrone.Router.navigate('series/add/import');
|
||||||
|
},
|
||||||
|
|
||||||
showImport: function (e) {
|
showRootFolders: function (e) {
|
||||||
if (e) {
|
if (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.ui.importExistingTab.tab('show');
|
this.ui.rootFoldersTab.tab('show');
|
||||||
NzbDrone.Router.navigate('series/add/import');
|
NzbDrone.Router.navigate('series/add/rootfolders');
|
||||||
},
|
},
|
||||||
|
|
||||||
showRootFolders: function (e) {
|
rootFolderCollection: new NzbDrone.AddSeries.RootFolders.RootFolderCollection(),
|
||||||
if (e) {
|
qualityProfileCollection: new NzbDrone.Quality.QualityProfileCollection(),
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.ui.rootFoldersTab.tab('show');
|
initialize: function (context, action, query) {
|
||||||
NzbDrone.Router.navigate('series/add/rootfolders');
|
if (action) {
|
||||||
},
|
this.action = action.toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
rootFolderCollection: new NzbDrone.AddSeries.RootDirCollection(),
|
if (query) {
|
||||||
qualityProfileCollection: new NzbDrone.Quality.QualityProfileCollection(),
|
this.query = query.toLowerCase();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onRender: function () {
|
||||||
|
|
||||||
initialize: function (context, action, query) {
|
this.qualityProfileCollection.fetch();
|
||||||
if (action) {
|
this.rootFolderCollection.fetch();
|
||||||
this.action = action.toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (query) {
|
this.addNew.show(new NzbDrone.AddSeries.New.AddNewSeriesView({ rootFolders: this.rootFolderCollection, qualityProfiles: this.qualityProfileCollection }));
|
||||||
this.query = query.toLowerCase();
|
this.importExisting.show(new NzbDrone.AddSeries.Existing.ImportSeriesView({ collection: this.rootFolderCollection, quality: this.qualityProfileCollection }));
|
||||||
}
|
this.rootFolders.show(new NzbDrone.AddSeries.RootDirView({ collection: this.rootFolderCollection }));
|
||||||
},
|
|
||||||
|
|
||||||
onRender: function () {
|
this.listenTo(this.rootFolderCollection, 'add', this.evaluateActions, this);
|
||||||
|
this.listenTo(this.rootFolderCollection, 'remove', this.evaluateActions, this);
|
||||||
|
this.listenTo(this.rootFolderCollection, 'reset', this.evaluateActions, this);
|
||||||
|
},
|
||||||
|
|
||||||
this.qualityProfileCollection.fetch();
|
onShow: function () {
|
||||||
this.rootFolderCollection.fetch();
|
switch (this.action) {
|
||||||
|
case 'import':
|
||||||
|
this.showImport();
|
||||||
|
break;
|
||||||
|
case 'rootfolders':
|
||||||
|
this.showRootFolders();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
this.showAddNew();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
this.addNew.show(new NzbDrone.AddSeries.AddNewSeriesView({ rootFolders: this.rootFolderCollection, qualityProfiles: this.qualityProfileCollection }));
|
evaluateActions: function () {
|
||||||
this.importExisting.show(new NzbDrone.AddSeries.Existing.ImportSeriesView({ collection: this.rootFolderCollection, quality: this.qualityProfileCollection }));
|
if (this.rootFolderCollection.length === 0) {
|
||||||
this.rootFolders.show(new NzbDrone.AddSeries.RootDirView({ collection: this.rootFolderCollection }));
|
this.ui.addNewTab.hide();
|
||||||
|
this.ui.importExistingTab.hide();
|
||||||
|
this.showRootFolders();
|
||||||
|
} else {
|
||||||
|
this.ui.addNewTab.show();
|
||||||
|
this.ui.importExistingTab.show();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
this.listenTo(this.rootFolderCollection, 'add', this.evaluateActions, this);
|
|
||||||
this.listenTo(this.rootFolderCollection, 'remove', this.evaluateActions, this);
|
|
||||||
this.listenTo(this.rootFolderCollection, 'reset', this.evaluateActions, this);
|
|
||||||
},
|
|
||||||
|
|
||||||
onShow: function () {
|
|
||||||
switch (this.action) {
|
|
||||||
case 'import':
|
|
||||||
this.showImport();
|
|
||||||
break;
|
|
||||||
case 'rootfolders':
|
|
||||||
this.showRootFolders();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
this.showAddNew();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
evaluateActions: function () {
|
|
||||||
if (this.rootFolderCollection.length === 0) {
|
|
||||||
this.ui.addNewTab.hide();
|
|
||||||
this.ui.importExistingTab.hide();
|
|
||||||
this.showRootFolders();
|
|
||||||
} else {
|
|
||||||
this.ui.addNewTab.show();
|
|
||||||
this.ui.importExistingTab.show();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
@ -1,154 +1,149 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
/// <reference path="../../app.js" />
|
|
||||||
/// <reference path="UnmappedFolderModel.js" />
|
define(['app', 'AddSeries/Existing/UnmappedFolderModel', 'AddSeries/SearchResultCollection', 'Series/SeriesModel'], function () {
|
||||||
/// <reference path="../../Series/SeriesModel.js" />
|
|
||||||
/// <reference path="../SearchResultCollection.js" />
|
|
||||||
|
|
||||||
|
|
||||||
NzbDrone.AddSeries.Existing.FolderMatchResultView = Backbone.Marionette.ItemView.extend({
|
NzbDrone.AddSeries.Existing.FolderMatchResultView = Backbone.Marionette.ItemView.extend({
|
||||||
template: 'AddSeries/Existing/FolderMatchResultViewTemplatate',
|
template: 'AddSeries/Existing/FolderMatchResultViewTemplatate',
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
'click .x-btn-add': 'addSeries'
|
'click .x-btn-add': 'addSeries'
|
||||||
},
|
},
|
||||||
|
|
||||||
addSeries: function () {
|
addSeries: function () {
|
||||||
|
|
||||||
var seriesId = this.model.get('id');
|
var seriesId = this.model.get('id');
|
||||||
var title = this.model.get('seriesName');
|
var title = this.model.get('seriesName');
|
||||||
var quality = this.options.qualityProfile.val();
|
var quality = this.options.qualityProfile.val();
|
||||||
var path = this.options.rootFolder + "\\" + title;
|
var path = this.options.rootFolder + "\\" + title;
|
||||||
|
|
||||||
var model = new NzbDrone.Series.SeriesModel({
|
var model = new NzbDrone.Series.SeriesModel({
|
||||||
seriesId: seriesId,
|
seriesId: seriesId,
|
||||||
title: title,
|
title: title,
|
||||||
qualityProfileId: quality,
|
qualityProfileId: quality,
|
||||||
path: path
|
path: path
|
||||||
});
|
});
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
model.save(undefined, {
|
model.save(undefined, {
|
||||||
success: function () {
|
success: function () {
|
||||||
var notificationModel = new NzbDrone.Shared.NotificationModel({
|
var notificationModel = new NzbDrone.Shared.NotificationModel({
|
||||||
title: 'Added',
|
title: 'Added',
|
||||||
message: title,
|
message: title,
|
||||||
level: 'success'
|
level: 'success'
|
||||||
});
|
});
|
||||||
|
|
||||||
NzbDrone.Shared.NotificationCollectionView.Instance.collection.add(notificationModel);
|
NzbDrone.Shared.NotificationCollectionView.Instance.collection.add(notificationModel);
|
||||||
self.close();
|
self.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
NzbDrone.AddSeries.Existing.UnmappedFolderCompositeView = Backbone.Marionette.CompositeView.extend({
|
||||||
|
|
||||||
|
template: 'AddSeries/Existing/UnmappedFolderCompositeViewTemplatate',
|
||||||
|
itemViewContainer: '.x-folder-name-match-results',
|
||||||
|
itemView: NzbDrone.AddSeries.Existing.FolderMatchResultView,
|
||||||
|
|
||||||
|
events: {
|
||||||
|
'click .x-btn-search': 'search'
|
||||||
|
},
|
||||||
|
|
||||||
|
ui: {
|
||||||
|
searchButton: '.x-btn-search',
|
||||||
|
searchText: '.x-txt-search',
|
||||||
|
profileList: '.x-lst-quality-profile'
|
||||||
|
},
|
||||||
|
|
||||||
|
initialize: function () {
|
||||||
|
this.collection = new NzbDrone.AddSeries.SearchResultCollection();
|
||||||
|
},
|
||||||
|
|
||||||
|
search: function () {
|
||||||
|
|
||||||
|
var icon = this.ui.searchButton.find('icon');
|
||||||
|
|
||||||
|
icon.removeClass('icon-search').addClass('icon-spin icon-spinner disabled');
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
this.collection.fetch({
|
||||||
|
data: $.param({ term: this.ui.searchText.val() }),
|
||||||
|
success: function (model) {
|
||||||
|
icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search');
|
||||||
|
|
||||||
|
},
|
||||||
|
fail: function () {
|
||||||
|
icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
itemViewOptions: function () {
|
||||||
|
return {
|
||||||
|
qualityProfile: this.ui.profileList,
|
||||||
|
rootFolder: this.model.get('rootFolder')
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
NzbDrone.AddSeries.Existing.RootFolderCompositeView = Backbone.Marionette.CompositeView.extend({
|
||||||
|
|
||||||
|
template: "AddSeries/Existing/RootFolderCompositeViewTemplate",
|
||||||
|
itemViewContainer: ".x-existing-folder-container",
|
||||||
|
itemView: NzbDrone.AddSeries.Existing.UnmappedFolderCompositeView,
|
||||||
|
|
||||||
|
initialize: function () {
|
||||||
|
|
||||||
|
if (!this.model) {
|
||||||
|
throw "model is required.";
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
if (!this.options.quality) {
|
||||||
|
throw "quality collection is required.";
|
||||||
NzbDrone.AddSeries.Existing.UnmappedFolderCompositeView = Backbone.Marionette.CompositeView.extend({
|
|
||||||
|
|
||||||
template: 'AddSeries/Existing/UnmappedFolderCompositeViewTemplatate',
|
|
||||||
itemViewContainer: '.x-folder-name-match-results',
|
|
||||||
itemView: NzbDrone.AddSeries.Existing.FolderMatchResultView,
|
|
||||||
|
|
||||||
events: {
|
|
||||||
'click .x-btn-search': 'search'
|
|
||||||
},
|
|
||||||
|
|
||||||
ui: {
|
|
||||||
searchButton: '.x-btn-search',
|
|
||||||
searchText: '.x-txt-search',
|
|
||||||
profileList: '.x-lst-quality-profile'
|
|
||||||
},
|
|
||||||
|
|
||||||
initialize: function () {
|
|
||||||
this.collection = new NzbDrone.AddSeries.SearchResultCollection();
|
|
||||||
},
|
|
||||||
|
|
||||||
search: function () {
|
|
||||||
|
|
||||||
var icon = this.ui.searchButton.find('icon');
|
|
||||||
|
|
||||||
icon.removeClass('icon-search').addClass('icon-spin icon-spinner disabled');
|
|
||||||
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
this.collection.fetch({
|
|
||||||
data: $.param({ term: this.ui.searchText.val() }),
|
|
||||||
success: function (model) {
|
|
||||||
icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search');
|
|
||||||
|
|
||||||
},
|
|
||||||
fail: function () {
|
|
||||||
icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search');
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
itemViewOptions: function () {
|
|
||||||
return {
|
|
||||||
qualityProfile: this.ui.profileList,
|
|
||||||
rootFolder: this.model.get('rootFolder')
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
NzbDrone.AddSeries.Existing.RootFolderCompositeView = Backbone.Marionette.CompositeView.extend({
|
|
||||||
|
|
||||||
template: "AddSeries/Existing/RootFolderCompositeViewTemplate",
|
|
||||||
itemViewContainer: ".x-existing-folder-container",
|
|
||||||
itemView: NzbDrone.AddSeries.Existing.UnmappedFolderCompositeView,
|
|
||||||
|
|
||||||
initialize: function () {
|
|
||||||
|
|
||||||
if (!this.model) {
|
|
||||||
throw "model is required.";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.options.quality) {
|
|
||||||
throw "quality collection is required.";
|
|
||||||
}
|
|
||||||
|
|
||||||
this.collection = new NzbDrone.AddSeries.Existing.UnmappedFolderCollection();
|
|
||||||
this.refreshItems();
|
|
||||||
this.listenTo(this.options.quality, 'reset', this.refreshItems, this);
|
|
||||||
},
|
|
||||||
|
|
||||||
refreshItems: function () {
|
|
||||||
this.collection.importItems(this.model, this.options.quality);
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
NzbDrone.AddSeries.Existing.ImportSeriesView = Backbone.Marionette.CollectionView.extend({
|
|
||||||
|
|
||||||
itemView: NzbDrone.AddSeries.Existing.RootFolderCompositeView,
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
initialize: function () {
|
|
||||||
|
|
||||||
if (!this.collection) {
|
|
||||||
throw "root folder collection is required.";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.options.quality) {
|
|
||||||
throw "quality collection is required.";
|
|
||||||
}
|
|
||||||
|
|
||||||
this.itemViewOptions = {
|
|
||||||
quality: this.options.quality
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
this.collection = new NzbDrone.AddSeries.Existing.UnmappedFolderCollection();
|
||||||
|
this.refreshItems();
|
||||||
|
this.listenTo(this.options.quality, 'reset', this.refreshItems, this);
|
||||||
|
},
|
||||||
|
|
||||||
|
refreshItems: function () {
|
||||||
|
this.collection.importItems(this.model, this.options.quality);
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
NzbDrone.AddSeries.Existing.ImportSeriesView = Backbone.Marionette.CollectionView.extend({
|
||||||
|
|
||||||
|
itemView: NzbDrone.AddSeries.Existing.RootFolderCompositeView,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
initialize: function () {
|
||||||
|
|
||||||
|
if (!this.collection) {
|
||||||
|
throw "root folder collection is required.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.options.quality) {
|
||||||
|
throw "quality collection is required.";
|
||||||
|
}
|
||||||
|
|
||||||
|
this.itemViewOptions = {
|
||||||
|
quality: this.options.quality
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,34 +1,35 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
/// <reference path="../../app.js" />
|
|
||||||
NzbDrone.AddSeries.Existing.UnmappedFolderModel = Backbone.Model.extend({
|
define(['app'], function () {
|
||||||
|
|
||||||
|
|
||||||
});
|
NzbDrone.AddSeries.Existing.UnmappedFolderModel = Backbone.Model.extend({
|
||||||
|
|
||||||
NzbDrone.AddSeries.Existing.UnmappedFolderCollection = Backbone.Collection.extend({
|
|
||||||
model: NzbDrone.AddSeries.Existing.UnmappedFolderModel,
|
|
||||||
|
|
||||||
|
|
||||||
importItems: function (rootFolderModel, quality) {
|
});
|
||||||
|
|
||||||
if (!rootFolderModel) {
|
NzbDrone.AddSeries.Existing.UnmappedFolderCollection = Backbone.Collection.extend({
|
||||||
throw "folder array is required";
|
model: NzbDrone.AddSeries.Existing.UnmappedFolderModel,
|
||||||
|
|
||||||
|
|
||||||
|
importItems: function (rootFolderModel, quality) {
|
||||||
|
|
||||||
|
if (!rootFolderModel) {
|
||||||
|
throw "folder array is required";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!quality) {
|
||||||
|
throw "quality is required";
|
||||||
|
}
|
||||||
|
|
||||||
|
this.reset();
|
||||||
|
|
||||||
|
var qualityCollection = quality;
|
||||||
|
var rootFolder = rootFolderModel.get('path');
|
||||||
|
|
||||||
|
_.each(rootFolderModel.get('unmappedFolders'), function (folder) {
|
||||||
|
this.push(new NzbDrone.AddSeries.Existing.UnmappedFolderModel({ rootFolder: rootFolder, folder: folder, quality: qualityCollection }));
|
||||||
|
}, this);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
if (!quality) {
|
|
||||||
throw "quality is required";
|
|
||||||
}
|
|
||||||
|
|
||||||
this.reset();
|
|
||||||
|
|
||||||
var qualityCollection = quality;
|
|
||||||
var rootFolder = rootFolderModel.get('path');
|
|
||||||
|
|
||||||
_.each(rootFolderModel.get('unmappedFolders'), function (folder) {
|
|
||||||
this.push(new NzbDrone.AddSeries.Existing.UnmappedFolderModel({rootFolder:rootFolder, folder: folder, quality: qualityCollection }));
|
|
||||||
}, this);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,84 +1,83 @@
|
|||||||
'use strict;'
|
define(['app', 'AddSeries/New/SearchResultView'], function () {
|
||||||
/// <reference path="../../app.js" />
|
|
||||||
/// <reference path="SearchResultView.js" />
|
|
||||||
|
|
||||||
NzbDrone.AddSeries.AddNewSeriesView = Backbone.Marionette.Layout.extend({
|
NzbDrone.AddSeries.New.AddNewSeriesView = Backbone.Marionette.Layout.extend({
|
||||||
template: 'AddSeries/New/AddNewSeriesTemplate',
|
template: 'AddSeries/New/AddNewSeriesTemplate',
|
||||||
route: 'Series/add/new',
|
route: 'Series/add/new',
|
||||||
|
|
||||||
ui: {
|
ui: {
|
||||||
seriesSearch: '.search input'
|
seriesSearch: '.search input'
|
||||||
},
|
},
|
||||||
|
|
||||||
regions: {
|
regions: {
|
||||||
searchResult: '#search-result',
|
searchResult: '#search-result',
|
||||||
},
|
},
|
||||||
|
|
||||||
collection: new NzbDrone.AddSeries.SearchResultCollection(),
|
collection: new NzbDrone.AddSeries.SearchResultCollection(),
|
||||||
|
|
||||||
initialize: function (options) {
|
initialize: function (options) {
|
||||||
if (options.rootFolders === undefined) {
|
if (options.rootFolders === undefined) {
|
||||||
throw 'rootFolder arg. is required.';
|
throw 'rootFolder arg. is required.';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.qualityProfiles === undefined) {
|
if (options.qualityProfiles === undefined) {
|
||||||
throw 'qualityProfiles arg. is required.';
|
throw 'qualityProfiles arg. is required.';
|
||||||
}
|
}
|
||||||
|
|
||||||
this.rootFoldersCollection = options.rootFolders;
|
this.rootFoldersCollection = options.rootFolders;
|
||||||
this.qualityProfileCollection = options.qualityProfiles;
|
this.qualityProfileCollection = options.qualityProfiles;
|
||||||
},
|
},
|
||||||
|
|
||||||
onRender: function () {
|
onRender: function () {
|
||||||
console.log('binding auto complete');
|
console.log('binding auto complete');
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.ui.seriesSearch
|
this.ui.seriesSearch
|
||||||
.data('timeout', null)
|
.data('timeout', null)
|
||||||
.keyup(function () {
|
.keyup(function () {
|
||||||
window.clearTimeout(self.$el.data('timeout'));
|
window.clearTimeout(self.$el.data('timeout'));
|
||||||
self.$el.data('timeout', window.setTimeout(self.search, 500, self));
|
self.$el.data('timeout', window.setTimeout(self.search, 500, self));
|
||||||
|
});
|
||||||
|
|
||||||
|
this.resultView = new NzbDrone.AddSeries.SearchResultView({ collection: this.collection });
|
||||||
|
},
|
||||||
|
|
||||||
|
search: function (context) {
|
||||||
|
|
||||||
|
context.abortExistingRequest();
|
||||||
|
|
||||||
|
var term = context.ui.seriesSearch.val();
|
||||||
|
context.collection.reset();
|
||||||
|
|
||||||
|
if (term !== '') {
|
||||||
|
context.searchResult.show(new NzbDrone.Shared.SpinnerView());
|
||||||
|
|
||||||
|
context.currentSearchRequest = context.collection.fetch({
|
||||||
|
data: $.param({ term: term }),
|
||||||
|
success: function (model) {
|
||||||
|
context.resultUpdated(model, context);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
context.searchResult.close();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
abortExistingRequest: function () {
|
||||||
|
if (this.currentSearchRequest && this.currentSearchRequest.readyState > 0 && this.currentSearchRequest.readyState < 4) {
|
||||||
|
console.log('aborting previous pending search request.');
|
||||||
|
this.currentSearchRequest.abort();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
resultUpdated: function (options, context) {
|
||||||
|
_.each(options.models, function (model) {
|
||||||
|
model.set('rootFolders', context.rootFoldersCollection);
|
||||||
|
model.set('qualityProfiles', context.qualityProfileCollection);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.resultView = new NzbDrone.AddSeries.SearchResultView({ collection: this.collection });
|
context.searchResult.show(context.resultView);
|
||||||
},
|
|
||||||
|
|
||||||
search: function (context) {
|
|
||||||
|
|
||||||
context.abortExistingRequest();
|
|
||||||
|
|
||||||
var term = context.ui.seriesSearch.val();
|
|
||||||
context.collection.reset();
|
|
||||||
|
|
||||||
if (term !== '') {
|
|
||||||
context.searchResult.show(new NzbDrone.Shared.SpinnerView());
|
|
||||||
|
|
||||||
context.currentSearchRequest = context.collection.fetch({
|
|
||||||
data: $.param({ term: term }),
|
|
||||||
success: function (model) {
|
|
||||||
context.resultUpdated(model, context);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
} else {
|
|
||||||
context.searchResult.close();
|
|
||||||
}
|
}
|
||||||
},
|
});
|
||||||
|
});
|
||||||
abortExistingRequest : function () {
|
|
||||||
if (this.currentSearchRequest && this.currentSearchRequest.readyState > 0 && this.currentSearchRequest.readyState < 4) {
|
|
||||||
console.log('aborting previous pending search request.');
|
|
||||||
this.currentSearchRequest.abort();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
resultUpdated: function (options, context) {
|
|
||||||
_.each(options.models, function (model) {
|
|
||||||
model.set('rootFolders', context.rootFoldersCollection);
|
|
||||||
model.set('qualityProfiles', context.qualityProfileCollection);
|
|
||||||
});
|
|
||||||
|
|
||||||
context.searchResult.show(context.resultView);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
@ -1,71 +1,69 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
/*global NzbDrone, Backbone*/
|
|
||||||
/// <reference path="../../app.js" />
|
|
||||||
/// <reference path="../SearchResultModel.js" />
|
|
||||||
/// <reference path="../../Series/SeriesModel.js" />
|
|
||||||
/// <reference path="../SearchResultCollection.js" />
|
|
||||||
|
|
||||||
NzbDrone.AddSeries.SearchItemView = Backbone.Marionette.ItemView.extend({
|
define(['app', 'AddSeries/SearchResultCollection', 'AddSeries/SearchResultModel', 'Series/SeriesModel'], function () {
|
||||||
|
|
||||||
|
NzbDrone.AddSeries.New.SearchItemView = Backbone.Marionette.ItemView.extend({
|
||||||
|
|
||||||
template: "AddSeries/New/SearchResultTemplate",
|
template: "AddSeries/New/SearchResultTemplate",
|
||||||
className: 'search-item',
|
className: 'search-item',
|
||||||
|
|
||||||
ui: {
|
ui: {
|
||||||
qualityProfile: '.x-quality-profile',
|
qualityProfile: '.x-quality-profile',
|
||||||
rootFolder: '.x-root-folder',
|
rootFolder: '.x-root-folder',
|
||||||
addButton: '.x-add'
|
addButton: '.x-add'
|
||||||
},
|
},
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
'click .x-add': 'add'
|
'click .x-add': 'add'
|
||||||
},
|
},
|
||||||
|
|
||||||
onRender: function () {
|
onRender: function () {
|
||||||
this.listenTo(this.model, 'change', this.render);
|
this.listenTo(this.model, 'change', this.render);
|
||||||
},
|
},
|
||||||
|
|
||||||
add: function () {
|
add: function () {
|
||||||
|
|
||||||
var seriesId = this.model.get('id');
|
var seriesId = this.model.get('id');
|
||||||
var title = this.model.get('seriesName');
|
var title = this.model.get('seriesName');
|
||||||
var quality = this.ui.qualityProfile.val();
|
var quality = this.ui.qualityProfile.val();
|
||||||
var rootFolderId = this.ui.rootFolder.val();
|
var rootFolderId = this.ui.rootFolder.val();
|
||||||
|
|
||||||
//Todo: This wiil create an invalid path on linux...
|
//Todo: This wiil create an invalid path on linux...
|
||||||
var rootPath = this.model.get('rootFolders').get(rootFolderId).get('path');
|
var rootPath = this.model.get('rootFolders').get(rootFolderId).get('path');
|
||||||
var path = rootPath + "\\" + title;
|
var path = rootPath + "\\" + title;
|
||||||
|
|
||||||
var model = new NzbDrone.Series.SeriesModel({
|
var model = new NzbDrone.Series.SeriesModel({
|
||||||
seriesId: seriesId,
|
seriesId: seriesId,
|
||||||
title: title,
|
title: title,
|
||||||
qualityProfileId: quality,
|
qualityProfileId: quality,
|
||||||
path: path
|
path: path
|
||||||
});
|
});
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
model.save(undefined, {
|
model.save(undefined, {
|
||||||
success: function () {
|
success: function () {
|
||||||
var notificationModel = new NzbDrone.Shared.NotificationModel({
|
var notificationModel = new NzbDrone.Shared.NotificationModel({
|
||||||
title: 'Added',
|
title: 'Added',
|
||||||
message: title,
|
message: title,
|
||||||
level: 'success'
|
level: 'success'
|
||||||
});
|
});
|
||||||
|
|
||||||
NzbDrone.Shared.NotificationCollectionView.Instance.collection.add(notificationModel);
|
NzbDrone.Shared.NotificationCollectionView.Instance.collection.add(notificationModel);
|
||||||
self.close();
|
self.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
NzbDrone.AddSeries.SearchResultView = Backbone.Marionette.CollectionView.extend({
|
NzbDrone.AddSeries.SearchResultView = Backbone.Marionette.CollectionView.extend({
|
||||||
|
|
||||||
itemView: NzbDrone.AddSeries.SearchItemView,
|
itemView: NzbDrone.AddSeries.SearchItemView,
|
||||||
|
|
||||||
className: 'accordion',
|
className: 'accordion',
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
this.listenTo(this.collection, 'reset', this.render);
|
this.listenTo(this.collection, 'reset', this.render);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
/// <reference path="../../app.js" />
|
|
||||||
/// <reference path="RootDirModel.js" />
|
|
||||||
|
|
||||||
NzbDrone.AddSeries.RootDirCollection = Backbone.Collection.extend({
|
|
||||||
url: NzbDrone.Constants.ApiRoot + '/rootdir',
|
|
||||||
model: NzbDrone.AddSeries.RootDirModel,
|
|
||||||
});
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
|||||||
/// <reference path="../../app.js" />
|
|
||||||
NzbDrone.AddSeries.RootDirModel = Backbone.Model.extend({
|
|
||||||
|
|
||||||
mutators: {
|
|
||||||
freeSpaceString: function () {
|
|
||||||
return this.get('freeSpace').bytes(2) + " Free";
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
defaults: {
|
|
||||||
freeSpace: 0,
|
|
||||||
}
|
|
||||||
});
|
|
@ -1,90 +0,0 @@
|
|||||||
'use strict;'
|
|
||||||
/// <reference path="../../app.js" />
|
|
||||||
/// <reference path="RootDirModel.js" />
|
|
||||||
/// <reference path="RootDirCollection.js" />
|
|
||||||
/// <reference path="../../Shared/AutoComplete.js" />
|
|
||||||
|
|
||||||
NzbDrone.AddSeries.RootDirItemView = Backbone.Marionette.ItemView.extend({
|
|
||||||
|
|
||||||
template: 'AddSeries/RootFolders/RootDirItemTemplate',
|
|
||||||
tagName: 'tr',
|
|
||||||
|
|
||||||
events: {
|
|
||||||
'click .x-remove': 'removeFolder',
|
|
||||||
},
|
|
||||||
|
|
||||||
onRender: function () {
|
|
||||||
NzbDrone.ModelBinder.bind(this.model, this.el);
|
|
||||||
},
|
|
||||||
|
|
||||||
removeFolder: function () {
|
|
||||||
this.model.destroy({ wait: true });
|
|
||||||
this.model.collection.remove(this.model);
|
|
||||||
},
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
NzbDrone.AddSeries.RootDirListView = Backbone.Marionette.CollectionView.extend({
|
|
||||||
itemView: NzbDrone.AddSeries.RootDirItemView,
|
|
||||||
|
|
||||||
tagName: 'table',
|
|
||||||
className: 'table table-hover',
|
|
||||||
});
|
|
||||||
|
|
||||||
NzbDrone.AddSeries.RootDirView = Backbone.Marionette.Layout.extend({
|
|
||||||
template: 'AddSeries/RootFolders/RootDirTemplate',
|
|
||||||
route: 'series/add/rootdir',
|
|
||||||
|
|
||||||
ui: {
|
|
||||||
pathInput: '.x-path input'
|
|
||||||
},
|
|
||||||
|
|
||||||
regions: {
|
|
||||||
currentDirs: '#current-dirs',
|
|
||||||
},
|
|
||||||
|
|
||||||
events: {
|
|
||||||
'click .x-add': 'addFolder',
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
collection: new NzbDrone.AddSeries.RootDirCollection(),
|
|
||||||
|
|
||||||
onRender: function () {
|
|
||||||
|
|
||||||
this.currentDirs.show(new NzbDrone.AddSeries.RootDirListView({ collection: this.collection }));
|
|
||||||
this.collection.fetch();
|
|
||||||
|
|
||||||
this.ui.pathInput.folderAutoComplete();
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
addFolder: function () {
|
|
||||||
var newDir = new NzbDrone.AddSeries.RootDirModel(
|
|
||||||
{
|
|
||||||
Path: this.ui.pathInput.val()
|
|
||||||
});
|
|
||||||
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
this.collection.create(newDir, {
|
|
||||||
wait: true, success: function () {
|
|
||||||
self.collection.fetch();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
search: function (context) {
|
|
||||||
|
|
||||||
var term = context.ui.seriesSearch.val();
|
|
||||||
|
|
||||||
if (term === "") {
|
|
||||||
context.collection.reset();
|
|
||||||
} else {
|
|
||||||
console.log(term);
|
|
||||||
context.collection.fetch({ data: $.param({ term: term }) });
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
},
|
|
||||||
});
|
|
@ -0,0 +1,10 @@
|
|||||||
|
define(['app', 'AddSeries/RootFolders/RootFolderModel'], function () {
|
||||||
|
|
||||||
|
NzbDrone.AddSeries.RootFolders.RootFolderCollection = Backbone.Collection.extend({
|
||||||
|
url: NzbDrone.Constants.ApiRoot + '/rootdir',
|
||||||
|
model: NzbDrone.AddSeries.RootFolders.RootFolderModel,
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
|||||||
|
define(['app'], function () {
|
||||||
|
NzbDrone.AddSeries.RootFolders.RootFolderModel = Backbone.Model.extend({
|
||||||
|
mutators: {
|
||||||
|
freeSpaceString: function () {
|
||||||
|
return this.get('freeSpace').bytes(2) + " Free";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
defaults: {
|
||||||
|
freeSpace: 0,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,91 @@
|
|||||||
|
'use strict;'
|
||||||
|
|
||||||
|
define(['app', 'AddSeries/RootFolders/RootFolderCollection', 'Shared/AutoComplete'], function () {
|
||||||
|
|
||||||
|
|
||||||
|
NzbDrone.AddSeries.RootFolderItemView = Backbone.Marionette.ItemView.extend({
|
||||||
|
|
||||||
|
template: 'AddSeries/RootFolders/RootFolderItemTemplate',
|
||||||
|
tagName: 'tr',
|
||||||
|
|
||||||
|
events: {
|
||||||
|
'click .x-remove': 'removeFolder',
|
||||||
|
},
|
||||||
|
|
||||||
|
onRender: function () {
|
||||||
|
NzbDrone.ModelBinder.bind(this.model, this.el);
|
||||||
|
},
|
||||||
|
|
||||||
|
removeFolder: function () {
|
||||||
|
this.model.destroy({ wait: true });
|
||||||
|
this.model.collection.remove(this.model);
|
||||||
|
},
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
NzbDrone.AddSeries.RootDirListView = Backbone.Marionette.CollectionView.extend({
|
||||||
|
itemView: NzbDrone.AddSeries.RootFolderItemView,
|
||||||
|
|
||||||
|
tagName: 'table',
|
||||||
|
className: 'table table-hover',
|
||||||
|
});
|
||||||
|
|
||||||
|
NzbDrone.AddSeries.RootDirView = Backbone.Marionette.Layout.extend({
|
||||||
|
template: 'AddSeries/RootFolders/RootFolderTemplate',
|
||||||
|
route: 'series/add/rootdir',
|
||||||
|
|
||||||
|
ui: {
|
||||||
|
pathInput: '.x-path input'
|
||||||
|
},
|
||||||
|
|
||||||
|
regions: {
|
||||||
|
currentDirs: '#current-dirs',
|
||||||
|
},
|
||||||
|
|
||||||
|
events: {
|
||||||
|
'click .x-add': 'addFolder',
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
collection: new NzbDrone.AddSeries.RootFolders.RootFolderCollection(),
|
||||||
|
|
||||||
|
onRender: function () {
|
||||||
|
|
||||||
|
this.currentDirs.show(new NzbDrone.AddSeries.RootDirListView({ collection: this.collection }));
|
||||||
|
this.collection.fetch();
|
||||||
|
|
||||||
|
this.ui.pathInput.folderAutoComplete();
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
addFolder: function () {
|
||||||
|
var newDir = new NzbDrone.AddSeries.RootFolders.RootFolderModel(
|
||||||
|
{
|
||||||
|
Path: this.ui.pathInput.val()
|
||||||
|
});
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
this.collection.create(newDir, {
|
||||||
|
wait: true, success: function () {
|
||||||
|
self.collection.fetch();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
search: function (context) {
|
||||||
|
|
||||||
|
var term = context.ui.seriesSearch.val();
|
||||||
|
|
||||||
|
if (term === "") {
|
||||||
|
context.collection.reset();
|
||||||
|
} else {
|
||||||
|
console.log(term);
|
||||||
|
context.collection.fetch({ data: $.param({ term: term }) });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
@ -1,10 +1,10 @@
|
|||||||
/// <reference path="../app.js" />
|
"use strict";
|
||||||
/// <reference path="SearchResultModel.js" />
|
define(['app', 'AddSeries/SearchResultModel'], function () {
|
||||||
"use strict";
|
NzbDrone.AddSeries.SearchResultCollection = Backbone.Collection.extend({
|
||||||
|
url: NzbDrone.Constants.ApiRoot + '/series/lookup',
|
||||||
NzbDrone.AddSeries.SearchResultCollection = Backbone.Collection.extend({
|
model: NzbDrone.AddSeries.SearchResultModel
|
||||||
url: NzbDrone.Constants.ApiRoot + '/series/lookup',
|
});
|
||||||
model: NzbDrone.AddSeries.SearchResultModel
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,23 +1,25 @@
|
|||||||
/// <reference path="../app.js" />
|
define(['app', 'AddSeries/RootFolders/RootFolderCollection', 'Quality/QualityProfileCollection'], function () {
|
||||||
/// <reference path="RootFolders/RootDirCollection.js" />
|
|
||||||
/// <reference path="../Quality/qualityProfileCollection.js" />
|
|
||||||
NzbDrone.AddSeries.SearchResultModel = Backbone.Model.extend({
|
|
||||||
mutators: {
|
|
||||||
seriesYear: function () {
|
|
||||||
var date = Date.utc.create(this.get('firstAired')).format('({yyyy})');
|
|
||||||
|
|
||||||
//don't append year, if the series name already has the name appended.
|
|
||||||
if (this.get('seriesName').endsWith(date)) {
|
NzbDrone.AddSeries.SearchResultModel = Backbone.Model.extend({
|
||||||
return "";
|
mutators: {
|
||||||
} else {
|
seriesYear: function () {
|
||||||
return date;
|
var date = Date.utc.create(this.get('firstAired')).format('({yyyy})');
|
||||||
|
|
||||||
|
//don't append year, if the series name already has the name appended.
|
||||||
|
if (this.get('seriesName').endsWith(date)) {
|
||||||
|
return "";
|
||||||
|
} else {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
|
||||||
|
|
||||||
defaults: {
|
defaults: {
|
||||||
qualityProfiles: new NzbDrone.Quality.QualityProfileCollection(),
|
qualityProfiles: new NzbDrone.Quality.QualityProfileCollection(),
|
||||||
rootFolders: new NzbDrone.AddSeries.RootDirCollection()
|
rootFolders: new NzbDrone.AddSeries.RootFolders.RootFolderModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -8,7 +8,7 @@ namespace NzbDrone.Web.Backbone.NzbDrone
|
|||||||
public class CassetteBundleConfiguration : IConfiguration<BundleCollection>
|
public class CassetteBundleConfiguration : IConfiguration<BundleCollection>
|
||||||
{
|
{
|
||||||
public const string BASE_STYLE = "BASE_STYLE";
|
public const string BASE_STYLE = "BASE_STYLE";
|
||||||
public const string NZBDRONE = "NZBDRONE";
|
//public const string NZBDRONE = "NZBDRONE";
|
||||||
internal const string FONTS = "FONTS";
|
internal const string FONTS = "FONTS";
|
||||||
|
|
||||||
private const string APP_PATH = "_backboneApp";
|
private const string APP_PATH = "_backboneApp";
|
||||||
@ -17,7 +17,7 @@ public void Configure(BundleCollection bundles)
|
|||||||
{
|
{
|
||||||
bundles.AddUrlWithAlias<StylesheetBundle>("//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,400,600,300'", FONTS);
|
bundles.AddUrlWithAlias<StylesheetBundle>("//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,400,600,300'", FONTS);
|
||||||
|
|
||||||
bundles.AddPerIndividualFile<ScriptBundle>(APP_PATH);
|
//bundles.AddPerIndividualFile<ScriptBundle>(APP_PATH);
|
||||||
|
|
||||||
bundles.Add<StylesheetBundle>(BASE_STYLE, new[]{
|
bundles.Add<StylesheetBundle>(BASE_STYLE, new[]{
|
||||||
APP_PATH + "\\Content\\Bootstrap\\bootstrap.less",
|
APP_PATH + "\\Content\\Bootstrap\\bootstrap.less",
|
||||||
@ -28,15 +28,17 @@ public void Configure(BundleCollection bundles)
|
|||||||
},
|
},
|
||||||
bundle => bundle.AddReference("/" + FONTS));
|
bundle => bundle.AddReference("/" + FONTS));
|
||||||
|
|
||||||
bundles.Add<ScriptBundle>("~/_backboneApp/JsLibraries/backbone.js");
|
/* bundles.Add<ScriptBundle>("~/_backboneApp/JsLibraries/backbone.js");
|
||||||
|
|
||||||
bundles.Add<ScriptBundle>(NZBDRONE, new[]{
|
bundles.Add<ScriptBundle>(NZBDRONE, new[]{
|
||||||
|
APP_PATH + "\\app.js",
|
||||||
|
APP_PATH + "\\routing.js",
|
||||||
APP_PATH + "\\Series\\Index\\IndexLayout.js",
|
APP_PATH + "\\Series\\Index\\IndexLayout.js",
|
||||||
APP_PATH + "\\AddSeries\\AddSeriesLayout.js",
|
APP_PATH + "\\AddSeries\\AddSeriesLayout.js",
|
||||||
APP_PATH + "\\Shared\\NotificationView.js",
|
APP_PATH + "\\Shared\\NotificationView.js",
|
||||||
|
|
||||||
|
|
||||||
});
|
});*/
|
||||||
|
|
||||||
/* bundles.Add<ScriptBundle>(NZBDRONE, new[]{
|
/* bundles.Add<ScriptBundle>(NZBDRONE, new[]{
|
||||||
|
|
||||||
|
@ -1,34 +1,36 @@
|
|||||||
/// <reference path="handlebars.js" />
|
|
||||||
|
define(['underscore', 'marionette', 'handlebars', 'jquery'], function (_, Marionette, Handlebars, $) {
|
||||||
|
_.extend(Marionette.TemplateCache.prototype, {
|
||||||
|
|
||||||
_.extend(Marionette.TemplateCache.prototype, {
|
loadTemplate: function (templateId) {
|
||||||
|
|
||||||
loadTemplate: function (templateId) {
|
|
||||||
|
|
||||||
|
|
||||||
var template;
|
var template;
|
||||||
|
|
||||||
console.log("Loading template '" + templateId + "'");
|
console.log("Loading template '" + templateId + "'");
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '_backboneApp//' + templateId + '.html',
|
url: '_backboneApp//' + templateId + '.html',
|
||||||
cache:false,
|
cache: false,
|
||||||
async: false
|
async: false
|
||||||
|
|
||||||
}).done(function (data) {
|
}).done(function (data) {
|
||||||
template = data;
|
template = data;
|
||||||
|
|
||||||
}).fail(function (data) {
|
}).fail(function (data) {
|
||||||
console.log("couldn't load template " + this.templateId + " Error: " + data.statusText);
|
console.log("couldn't load template " + this.templateId + " Error: " + data.statusText);
|
||||||
template = "<div class='alert alert-error'>Couldn't load template '" + templateId + "'. Status: " + data.statusText + "</div>";
|
template = "<div class='alert alert-error'>Couldn't load template '" + templateId + "'. Status: " + data.statusText + "</div>";
|
||||||
});
|
});
|
||||||
|
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
_.extend(Marionette.TemplateCache.prototype, {
|
||||||
|
|
||||||
|
compileTemplate: function (rawTemplate) {
|
||||||
|
return Handlebars.compile(rawTemplate);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
_.extend(Marionette.TemplateCache.prototype, {
|
|
||||||
|
|
||||||
compileTemplate: function (rawTemplate) {
|
|
||||||
return Handlebars.compile(rawTemplate);
|
|
||||||
}
|
|
||||||
});
|
|
19125
NzbDrone.Web/_backboneApp/JsLibraries/jquery.js
vendored
19125
NzbDrone.Web/_backboneApp/JsLibraries/jquery.js
vendored
File diff suppressed because it is too large
Load Diff
11555
NzbDrone.Web/_backboneApp/JsLibraries/require-jquery.js
Normal file
11555
NzbDrone.Web/_backboneApp/JsLibraries/require-jquery.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,8 @@
|
|||||||
/// <reference path="../app.js" />
|
define(['app', 'Quality/QualityProfileModel'], function () {
|
||||||
/// <reference path="qualityProfileModel.js" />
|
|
||||||
|
|
||||||
NzbDrone.Quality.QualityProfileCollection = Backbone.Collection.extend({
|
NzbDrone.Quality.QualityProfileCollection = Backbone.Collection.extend({
|
||||||
model: NzbDrone.Quality.QualityProfileModel,
|
model: NzbDrone.Quality.QualityProfileModel,
|
||||||
url: NzbDrone.Constants.ApiRoot + '/qualityprofiles'
|
url: NzbDrone.Constants.ApiRoot + '/qualityprofiles'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
@ -1,47 +1,48 @@
|
|||||||
/// <reference path="../app.js" />
|
define(['app'], function () {
|
||||||
|
NzbDrone.Quality.QualityProfileModel = Backbone.Model.extend({
|
||||||
|
initialize: function () {
|
||||||
|
this.validators = {};
|
||||||
|
|
||||||
NzbDrone.Quality.QualityProfileModel = Backbone.Model.extend({
|
this.validators.name = function (value) {
|
||||||
initialize: function () {
|
return value.length > 0 ? { isValid: true } : { isValid: false, message: 'You must enter a name' };
|
||||||
this.validators = {};
|
};
|
||||||
|
|
||||||
this.validators.name = function (value) {
|
//this.validators.allowed = function (value) {
|
||||||
return value.length > 0 ? { isValid: true } : { isValid: false, message: 'You must enter a name' };
|
// return value.length > 0 ? { isValid: true } : { isValid: false, message: 'You must have allowed qualities' };
|
||||||
};
|
//};
|
||||||
|
//Todo: Cutoff should be something that is allowed (double check)
|
||||||
|
this.validators.cutoff = function (value) {
|
||||||
|
return value !== null ? { isValid: true } : { isValid: false, message: 'You must have a valid cutoff' };
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
//this.validators.allowed = function (value) {
|
validateItem: function (key) {
|
||||||
// return value.length > 0 ? { isValid: true } : { isValid: false, message: 'You must have allowed qualities' };
|
return (this.validators[key]) ? this.validators[key](this.get(key)) : { isValid: true };
|
||||||
//};
|
},
|
||||||
//Todo: Cutoff should be something that is allowed (double check)
|
|
||||||
this.validators.cutoff = function (value) {
|
|
||||||
return value !== null ? { isValid: true } : { isValid: false, message: 'You must have a valid cutoff' };
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
validateItem: function (key) {
|
// TODO: Implement Backbone's standard validate() method instead.
|
||||||
return (this.validators[key]) ? this.validators[key](this.get(key)) : { isValid: true };
|
validateAll: function () {
|
||||||
},
|
|
||||||
|
|
||||||
// TODO: Implement Backbone's standard validate() method instead.
|
var messages = {};
|
||||||
validateAll: function () {
|
|
||||||
|
|
||||||
var messages = {};
|
for (var key in this.validators) {
|
||||||
|
if (this.validators.hasOwnProperty(key)) {
|
||||||
for (var key in this.validators) {
|
var check = this.validators[key](this.get(key));
|
||||||
if (this.validators.hasOwnProperty(key)) {
|
if (check.isValid === false) {
|
||||||
var check = this.validators[key](this.get(key));
|
messages[key] = check.message;
|
||||||
if (check.isValid === false) {
|
}
|
||||||
messages[key] = check.message;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return _.size(messages) > 0 ? { isValid: false, messages: messages } : { isValid: true };
|
||||||
|
},
|
||||||
|
|
||||||
|
defaults: {
|
||||||
|
Id: null,
|
||||||
|
Name: '',
|
||||||
|
//allowed: {},
|
||||||
|
Cutoff: null
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
return _.size(messages) > 0 ? { isValid: false, messages: messages } : { isValid: true };
|
|
||||||
},
|
|
||||||
|
|
||||||
defaults: {
|
|
||||||
Id: null,
|
|
||||||
Name: '',
|
|
||||||
//allowed: {},
|
|
||||||
Cutoff: null
|
|
||||||
}
|
|
||||||
});
|
|
38
NzbDrone.Web/_backboneApp/Routing.js
Normal file
38
NzbDrone.Web/_backboneApp/Routing.js
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
require(['app', 'AddSeries/AddSeriesLayout'], function () {
|
||||||
|
|
||||||
|
NzbDrone.Controller = Backbone.Marionette.Controller.extend({
|
||||||
|
|
||||||
|
addSeries: function (action, query) {
|
||||||
|
NzbDrone.mainRegion.show(new NzbDrone.AddSeries.AddSeriesLayout(this, action, query));
|
||||||
|
},
|
||||||
|
|
||||||
|
series: function (action, query) {
|
||||||
|
NzbDrone.mainRegion.show(new NzbDrone.Series.IndexLayout(this, action, query));
|
||||||
|
},
|
||||||
|
|
||||||
|
notFound: function () {
|
||||||
|
alert('route not found');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
NzbDrone.Router = Backbone.Marionette.AppRouter.extend({
|
||||||
|
|
||||||
|
controller: new NzbDrone.Controller(),
|
||||||
|
appRoutes: {
|
||||||
|
'series': 'series',
|
||||||
|
'series/index': 'series',
|
||||||
|
'series/add': 'addSeries',
|
||||||
|
'series/add/:action(/:query)': 'addSeries',
|
||||||
|
':whatever': 'notFound'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
NzbDrone.addInitializer(function () {
|
||||||
|
|
||||||
|
NzbDrone.Router = new NzbDrone.Router();
|
||||||
|
Backbone.history.start();
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
/*global NzbDrone, Backbone*/
|
/*global NzbDrone, Backbone*/
|
||||||
/// <reference path="../app.js" />
|
|
||||||
/// <reference path="SeriesModel.js" />
|
/// <reference path="SeriesModel.js" />
|
||||||
|
|
||||||
NzbDrone.Series.DeleteSeriesView = Backbone.Marionette.ItemView.extend({
|
NzbDrone.Series.DeleteSeriesView = Backbone.Marionette.ItemView.extend({
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
/*global NzbDrone, Backbone*/
|
/*global NzbDrone, Backbone*/
|
||||||
/// <reference path="../app.js" />
|
|
||||||
/// <reference path="SeriesModel.js" />
|
/// <reference path="SeriesModel.js" />
|
||||||
/// <reference path="DeleteSeriesView.js" />
|
/// <reference path="DeleteSeriesView.js" />
|
||||||
/// <reference path="../Quality/qualityProfileCollection.js" />
|
/// <reference path="../Quality/qualityProfileCollection.js" />
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
'use strict;'
|
'use strict;'
|
||||||
/// <reference path="../../app.js" />
|
|
||||||
/// <reference path="../SeriesCollection.js" />
|
/// <reference path="../SeriesCollection.js" />
|
||||||
/// <reference path="SeriesItemView.js" />
|
/// <reference path="SeriesItemView.js" />
|
||||||
/// <reference path="../../JsLibraries/jquery.dataTables.bootstrap.pagination.js" />
|
/// <reference path="../../JsLibraries/jquery.dataTables.bootstrap.pagination.js" />
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
/*global NzbDrone, Backbone*/
|
/*global NzbDrone, Backbone*/
|
||||||
/// <reference path="../../app.js" />
|
|
||||||
/// <reference path="../SeriesModel.js" />
|
/// <reference path="../SeriesModel.js" />
|
||||||
/// <reference path="../SeriesCollection.js" />
|
/// <reference path="../SeriesCollection.js" />
|
||||||
/// <reference path="../EditSeriesView.js" />
|
/// <reference path="../EditSeriesView.js" />
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/// <reference path="../app.js" />
|
|
||||||
/// <reference path="SeriesModel.js" />
|
/// <reference path="SeriesModel.js" />
|
||||||
|
|
||||||
NzbDrone.Series.SeriesCollection = Backbone.Collection.extend({
|
NzbDrone.Series.SeriesCollection = Backbone.Collection.extend({
|
||||||
|
@ -1,48 +1,43 @@
|
|||||||
NzbDrone.Series.SeriesModel = Backbone.Model.extend({
|
define(['app'], function () {
|
||||||
url: NzbDrone.Constants.ApiRoot + '/series',
|
|
||||||
|
|
||||||
mutators: {
|
|
||||||
bestDateString: function () {
|
|
||||||
var dateSource = this.get('nextAiring');
|
|
||||||
|
|
||||||
if (!dateSource) return '';
|
|
||||||
|
|
||||||
var date = Date.create(dateSource);
|
NzbDrone.Series.SeriesModel = Backbone.Model.extend({
|
||||||
|
url: NzbDrone.Constants.ApiRoot + '/series',
|
||||||
|
|
||||||
if (date.isYesterday()) return 'Yesterday';
|
mutators: {
|
||||||
if (date.isToday()) return 'Today';
|
bestDateString: function () {
|
||||||
if (date.isTomorrow()) return 'Tomorrow';
|
var dateSource = this.get('nextAiring');
|
||||||
if (date.isToday()) return 'Today';
|
|
||||||
if (date.isBefore(Date.create().addDays(7))) return date.format('{Weekday}');
|
|
||||||
|
|
||||||
return date.format('{MM}/{dd}/{yyyy}');
|
if (!dateSource) return '';
|
||||||
|
|
||||||
|
var date = Date.create(dateSource);
|
||||||
|
|
||||||
|
if (date.isYesterday()) return 'Yesterday';
|
||||||
|
if (date.isToday()) return 'Today';
|
||||||
|
if (date.isTomorrow()) return 'Tomorrow';
|
||||||
|
if (date.isToday()) return 'Today';
|
||||||
|
if (date.isBefore(Date.create().addDays(7))) return date.format('{Weekday}');
|
||||||
|
|
||||||
|
return date.format('{MM}/{dd}/{yyyy}');
|
||||||
|
},
|
||||||
|
|
||||||
|
percentOfEpisodes: function () {
|
||||||
|
var episodeCount = this.get('episodeCount');
|
||||||
|
var episodeFileCount = this.get('episodeFileCount');
|
||||||
|
|
||||||
|
var percent = 100;
|
||||||
|
|
||||||
|
if (episodeCount > 0)
|
||||||
|
percent = episodeFileCount / episodeCount * 100;
|
||||||
|
|
||||||
|
return percent;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
formatedDateString: function () {
|
|
||||||
var dateSource = this.get('nextAiring');
|
|
||||||
|
|
||||||
if (!dateSource) return '';
|
defaults: {
|
||||||
|
episodeFileCount: 0,
|
||||||
var date = Date.create(dateSource);
|
episodeCount: 0
|
||||||
|
|
||||||
return date.format('{Weekday} {Month} {dd}, {yyyy} {12hr}:{mm} {TT}');
|
|
||||||
},
|
|
||||||
|
|
||||||
percentOfEpisodes: function () {
|
|
||||||
var episodeCount = this.get('episodeCount');
|
|
||||||
var episodeFileCount = this.get('episodeFileCount');
|
|
||||||
|
|
||||||
var percent = 100;
|
|
||||||
|
|
||||||
if (episodeCount > 0)
|
|
||||||
percent = episodeFileCount / episodeCount * 100;
|
|
||||||
|
|
||||||
return percent;
|
|
||||||
}
|
}
|
||||||
},
|
});
|
||||||
|
|
||||||
defaults: {
|
});
|
||||||
episodeFileCount: 0,
|
|
||||||
episodeCount: 0
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
$.fn.folderAutoComplete = function () {
|
define(['bootstrap'], function () {
|
||||||
$(this).typeahead({
|
|
||||||
source: function (query, process) {
|
$.fn.folderAutoComplete = function () {
|
||||||
$.ajax({
|
$(this).typeahead({
|
||||||
url: '/api/directories',
|
source: function (query, process) {
|
||||||
dataType: "json",
|
$.ajax({
|
||||||
type: "POST",
|
url: '/api/directories',
|
||||||
data: { query: query },
|
dataType: "json",
|
||||||
success: function (data) {
|
type: "POST",
|
||||||
process(data);
|
data: { query: query },
|
||||||
}
|
success: function (data) {
|
||||||
});
|
process(data);
|
||||||
},
|
}
|
||||||
minLength: 3
|
});
|
||||||
});
|
},
|
||||||
}
|
minLength: 3
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
});
|
||||||
|
@ -1,24 +1,28 @@
|
|||||||
ModalRegion = Backbone.Marionette.Region.extend({
|
define('modalRegion', ['Marionette'], function (Marionette) {
|
||||||
el: "#modal-region",
|
return Marionette.Region.extend({
|
||||||
|
el: "#modal-region",
|
||||||
|
|
||||||
constructor: function () {
|
constructor: function () {
|
||||||
_.bindAll(this);
|
_.bindAll(this);
|
||||||
Backbone.Marionette.Region.prototype.constructor.apply(this, arguments);
|
Backbone.Marionette.Region.prototype.constructor.apply(this, arguments);
|
||||||
this.on("show", this.showModal, this);
|
this.on("show", this.showModal, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
getEl: function (selector) {
|
getEl: function (selector) {
|
||||||
var $el = $(selector);
|
var $el = $(selector);
|
||||||
$el.on("hidden", this.close);
|
$el.on("hidden", this.close);
|
||||||
return $el;
|
return $el;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
showModal: function (view) {
|
||||||
|
view.on("close", this.hideModal, this);
|
||||||
|
this.$el.modal('show');
|
||||||
|
},
|
||||||
|
|
||||||
|
hideModal: function () {
|
||||||
|
this.$el.modal('hide');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
showModal: function (view) {
|
|
||||||
view.on("close", this.hideModal, this);
|
|
||||||
this.$el.modal('show');
|
|
||||||
},
|
|
||||||
|
|
||||||
hideModal: function () {
|
|
||||||
this.$el.modal('hide');
|
|
||||||
}
|
|
||||||
});
|
|
@ -1,4 +1,5 @@
|
|||||||
/// <reference path="../app.js" />
|
|
||||||
|
|
||||||
NzbDrone.Shared.NotificationModel = Backbone.Model.extend({
|
NzbDrone.Shared.NotificationModel = Backbone.Model.extend({
|
||||||
|
|
||||||
mutators: {
|
mutators: {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/// <reference path="../app.js" />
|
|
||||||
/// <reference path="NotificationModel.js" />
|
/// <reference path="NotificationModel.js" />
|
||||||
|
|
||||||
NzbDrone.Shared.NotificationItemView = Backbone.Marionette.ItemView.extend({
|
NzbDrone.Shared.NotificationItemView = Backbone.Marionette.ItemView.extend({
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
/// <reference path="../app.js" />
|
NzbDrone.Shared.SpinnerView = Backbone.Marionette.ItemView.extend({
|
||||||
|
|
||||||
NzbDrone.Shared.SpinnerView = Backbone.Marionette.ItemView.extend({
|
|
||||||
|
|
||||||
template: 'Shared/SpinnerTemplate',
|
template: 'Shared/SpinnerTemplate',
|
||||||
className: 'nz-spinner row',
|
className: 'nz-spinner row',
|
||||||
|
@ -1,97 +1,85 @@
|
|||||||
/// <reference path="JsLibraries/jquery.js" />
|
require.config({
|
||||||
/// <reference path="JsLibraries/underscore.js" />
|
|
||||||
/// <reference path="JsLibraries/sugar.js" />
|
|
||||||
/// <reference path="JsLibraries/backbone.js" />
|
|
||||||
/// <reference path="JsLibraries/handlebars.js" />
|
|
||||||
/// <reference path="JsLibraries/backbone.modelbinder.js" />
|
|
||||||
/// <reference path="JsLibraries/backbone.mutators.js" />
|
|
||||||
/// <reference path="JsLibraries/backbone.shortcuts.js" />
|
|
||||||
/// <reference path="JsLibraries/backbone.marionette.js" />
|
|
||||||
/// <reference path="JsLibraries/backbone.marionette.extend.js" />
|
|
||||||
/// <reference path="JsLibraries/backbone.marionette.viewswapper.js" />
|
|
||||||
/// <reference path="JsLibraries/backbone.modelbinder.js" />
|
|
||||||
/// <reference path="JsLibraries/bootstrap.js" />
|
|
||||||
/// <reference path="Shared/ModalRegion.js" />
|
|
||||||
|
|
||||||
if (typeof console === undefined) {
|
paths: {
|
||||||
window.console = { log: function () { } };
|
'backbone': 'JsLibraries/backbone',
|
||||||
}
|
'underscore': 'JsLibraries/underscore',
|
||||||
|
'marionette': 'JsLibraries/backbone.marionette',
|
||||||
NzbDrone = new Backbone.Marionette.Application();
|
'handlebars': 'JsLibraries/handlebars',
|
||||||
NzbDrone.Series = {};
|
'bootstrap': 'JsLibraries/bootstrap',
|
||||||
NzbDrone.Series.Index = {};
|
|
||||||
NzbDrone.AddSeries = {};
|
|
||||||
NzbDrone.AddSeries.New = {};
|
|
||||||
NzbDrone.AddSeries.Existing = {};
|
|
||||||
NzbDrone.AddSeries.RootFolders = {};
|
|
||||||
NzbDrone.Quality = {};
|
|
||||||
NzbDrone.Shared = {};
|
|
||||||
|
|
||||||
/*
|
|
||||||
_.templateSettings = {
|
|
||||||
interpolate: /\{\{([\s\S]+?)\}\}/g
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
NzbDrone.ModelBinder = new Backbone.ModelBinder();
|
|
||||||
|
|
||||||
NzbDrone.Constants = {
|
|
||||||
ApiRoot: '/api'
|
|
||||||
};
|
|
||||||
|
|
||||||
NzbDrone.Events = {
|
|
||||||
DisplayInMainRegion: 'DisplayInMainRegion'
|
|
||||||
};
|
|
||||||
|
|
||||||
NzbDrone.Controller = Backbone.Marionette.Controller.extend({
|
|
||||||
|
|
||||||
addSeries: function (action, query) {
|
|
||||||
NzbDrone.mainRegion.show(new NzbDrone.AddSeries.AddSeriesLayout(this, action, query));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
series: function (action, query) {
|
shim: {
|
||||||
NzbDrone.mainRegion.show(new NzbDrone.Series.IndexLayout(this, action, query));
|
bootstrap: {
|
||||||
},
|
deps: ["jquery"],
|
||||||
|
},
|
||||||
notFound: function () {
|
underscore: {
|
||||||
alert('route not found');
|
exports: '_'
|
||||||
|
},
|
||||||
|
backbone: {
|
||||||
|
deps: ["underscore", "jquery"],
|
||||||
|
exports: "Backbone"
|
||||||
|
},
|
||||||
|
marionette: {
|
||||||
|
deps: ["backbone"],
|
||||||
|
exports: "Marionette"
|
||||||
|
},
|
||||||
|
handlebars: {
|
||||||
|
exports: "Handlebars"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
NzbDrone.Router = Backbone.Marionette.AppRouter.extend({
|
define('app', ['jquery', 'JsLibraries/backbone.modelbinder', 'marionette', 'handlebars', 'JsLibraries/backbone.marionette.extend'],
|
||||||
|
function (jquery, modelBinder, marionette, handlebars) {
|
||||||
|
|
||||||
controller: new NzbDrone.Controller(),
|
|
||||||
// "someMethod" must exist at controller.someMethod
|
|
||||||
appRoutes: {
|
|
||||||
'series': 'series',
|
|
||||||
'series/index': 'series',
|
|
||||||
'series/add': 'addSeries',
|
|
||||||
'series/add/:action(/:query)': 'addSeries',
|
|
||||||
':whatever': 'notFound'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
NzbDrone.addInitializer(function (options) {
|
window.$ = jquery;
|
||||||
|
window.jquery = jquery;
|
||||||
|
|
||||||
console.log('starting application');
|
window.Backbone.ModelBinder = modelBinder;
|
||||||
|
window.Backbone.Marionette = marionette;
|
||||||
|
window.Handlebars = handlebars;
|
||||||
|
|
||||||
NzbDrone.registerHelpers();
|
window.NzbDrone = new Backbone.Marionette.Application();
|
||||||
|
window.NzbDrone.Series = {};
|
||||||
|
window.NzbDrone.Series.Index = {};
|
||||||
|
window.NzbDrone.AddSeries = {};
|
||||||
|
window.NzbDrone.AddSeries.New = {};
|
||||||
|
window.NzbDrone.AddSeries.Existing = {};
|
||||||
|
window.NzbDrone.AddSeries.RootFolders = {};
|
||||||
|
window.NzbDrone.Quality = {};
|
||||||
|
window.NzbDrone.Shared = {};
|
||||||
|
|
||||||
NzbDrone.addRegions({
|
window.NzbDrone.Constants = {
|
||||||
mainRegion: '#main-region',
|
ApiRoot: '/api'
|
||||||
notificationRegion: '#notification-region',
|
};
|
||||||
modalRegion: ModalRegion
|
|
||||||
|
|
||||||
|
window.NzbDrone.addInitializer(function (options) {
|
||||||
|
|
||||||
|
console.log('starting application');
|
||||||
|
|
||||||
|
NzbDrone.ModelBinder = new Backbone.ModelBinder();
|
||||||
|
|
||||||
|
//TODO: move this out of here
|
||||||
|
Handlebars.registerHelper("formatStatus", function (status, monitored) {
|
||||||
|
if (!monitored) return '<i class="icon-pause grid-icon" title="Not Monitored"></i>';
|
||||||
|
if (status === 'Continuing') return '<i class="icon-play grid-icon" title="Continuing"></i>';
|
||||||
|
|
||||||
|
return '<i class="icon-stop grid-icon" title="Ended"></i>';
|
||||||
|
});
|
||||||
|
|
||||||
|
NzbDrone.addRegions({
|
||||||
|
mainRegion: '#main-region',
|
||||||
|
notificationRegion: '#notification-region',
|
||||||
|
modalRegion: '#modal-region'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
window.NzbDrone.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
NzbDrone.Router = new NzbDrone.Router();
|
|
||||||
Backbone.history.start();
|
|
||||||
});
|
|
||||||
|
|
||||||
NzbDrone.registerHelpers = function() {
|
|
||||||
Handlebars.registerHelper("formatStatus", function (status, monitored) {
|
|
||||||
if (!monitored) return '<i class="icon-pause grid-icon" title="Not Monitored"></i>';
|
|
||||||
if (status === 'Continuing') return '<i class="icon-play grid-icon" title="Continuing"></i>';
|
|
||||||
|
|
||||||
return '<i class="icon-stop grid-icon" title="Ended"></i>';
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
<FileVersion>1</FileVersion>
|
<FileVersion>1</FileVersion>
|
||||||
<AutoEnableOnStartup>False</AutoEnableOnStartup>
|
<AutoEnableOnStartup>False</AutoEnableOnStartup>
|
||||||
<AllowParallelTestExecution>true</AllowParallelTestExecution>
|
<AllowParallelTestExecution>true</AllowParallelTestExecution>
|
||||||
|
<AllowTestsToRunInParallelWithThemselves>true</AllowTestsToRunInParallelWithThemselves>
|
||||||
<FrameworkUtilisationTypeForNUnit>UseDynamicAnalysis</FrameworkUtilisationTypeForNUnit>
|
<FrameworkUtilisationTypeForNUnit>UseDynamicAnalysis</FrameworkUtilisationTypeForNUnit>
|
||||||
<FrameworkUtilisationTypeForGallio>Disabled</FrameworkUtilisationTypeForGallio>
|
<FrameworkUtilisationTypeForGallio>Disabled</FrameworkUtilisationTypeForGallio>
|
||||||
<FrameworkUtilisationTypeForMSpec>Disabled</FrameworkUtilisationTypeForMSpec>
|
<FrameworkUtilisationTypeForMSpec>Disabled</FrameworkUtilisationTypeForMSpec>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FPARAMETER/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb"><ExtraRule Prefix="" Suffix="" Style="AaBb" /></Policy></s:String>
|
||||||
<s:String x:Key="/Default/Environment/Editor/MatchingBraceHighlighting/Position/@EntryValue">BOTH_SIDES</s:String>
|
<s:String x:Key="/Default/Environment/Editor/MatchingBraceHighlighting/Position/@EntryValue">BOTH_SIDES</s:String>
|
||||||
<s:String x:Key="/Default/Environment/Editor/MatchingBraceHighlighting/Style/@EntryValue">OUTLINE</s:String>
|
<s:String x:Key="/Default/Environment/Editor/MatchingBraceHighlighting/Style/@EntryValue">OUTLINE</s:String>
|
||||||
<s:Boolean x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=5C7F3FB135E52A44B9447C48B2EEEE92/@KeyIndexDefined">True</s:Boolean>
|
<s:Boolean x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=5C7F3FB135E52A44B9447C48B2EEEE92/@KeyIndexDefined">True</s:Boolean>
|
||||||
|
Loading…
Reference in New Issue
Block a user