1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-09-17 15:02:34 +02:00

removed NzbDrone. namespace, everything is done using require.

This commit is contained in:
Keivan Beigi 2013-06-24 16:41:59 -07:00
parent ef62af75df
commit b0bd3f34f1
121 changed files with 2570 additions and 2587 deletions

View File

@ -10,8 +10,6 @@ module.exports = function (grunt) {
'UI/JsLibraries/backbone.modelbinder.js' : 'http://raw.github.com/theironcook/Backbone.ModelBinder/master/Backbone.ModelBinder.js', 'UI/JsLibraries/backbone.modelbinder.js' : 'http://raw.github.com/theironcook/Backbone.ModelBinder/master/Backbone.ModelBinder.js',
'UI/JsLibraries/backbone.mutators.js' : 'http://raw.github.com/asciidisco/Backbone.Mutators/master/backbone.mutators.js', 'UI/JsLibraries/backbone.mutators.js' : 'http://raw.github.com/asciidisco/Backbone.Mutators/master/backbone.mutators.js',
'UI/JsLibraries/backbone.shortcuts.js' : 'http://raw.github.com/bry4n/backbone-shortcuts/master/backbone.shortcuts.js', 'UI/JsLibraries/backbone.shortcuts.js' : 'http://raw.github.com/bry4n/backbone-shortcuts/master/backbone.shortcuts.js',
'UI/JsLibraries/backbone.relational.js' : 'http://raw.github.com/PaulUithol/Backbone-relational/0.8.5/backbone-relational.js',
'UI/JsLibraries/backbone.associations.js' : 'http://raw.github.com/dhruvaray/backbone-associations/master/backbone-associations.js',
'UI/JsLibraries/backbone.pageable.js' : 'http://raw.github.com/wyuenho/backbone-pageable/master/lib/backbone-pageable.js', 'UI/JsLibraries/backbone.pageable.js' : 'http://raw.github.com/wyuenho/backbone-pageable/master/lib/backbone-pageable.js',
'UI/JsLibraries/backbone.backgrid.js' : 'http://raw.github.com/wyuenho/backgrid/master/lib/backgrid.js', 'UI/JsLibraries/backbone.backgrid.js' : 'http://raw.github.com/wyuenho/backgrid/master/lib/backgrid.js',
@ -28,6 +26,7 @@ module.exports = function (grunt) {
'UI/JsLibraries/require.js' : 'http://raw.github.com/jrburke/requirejs/master/require.js', 'UI/JsLibraries/require.js' : 'http://raw.github.com/jrburke/requirejs/master/require.js',
'UI/JsLibraries/sugar.js' : 'http://raw.github.com/andrewplummer/Sugar/master/release/sugar-full.development.js', 'UI/JsLibraries/sugar.js' : 'http://raw.github.com/andrewplummer/Sugar/master/release/sugar-full.development.js',
'UI/JsLibraries/underscore.js' : 'http://underscorejs.org/underscore.js', 'UI/JsLibraries/underscore.js' : 'http://underscorejs.org/underscore.js',
'UI/JsLibraries/lodash.underscore.js' : 'http://raw.github.com/bestiejs/lodash/master/dist/lodash.underscore.js',
'UI/JsLibraries/lunr.js' : 'http://raw.github.com/olivernn/lunr.js/master/lunr.js', 'UI/JsLibraries/lunr.js' : 'http://raw.github.com/olivernn/lunr.js/master/lunr.js',
'UI/JsLibraries/messenger.js' : 'http://raw.github.com/HubSpot/messenger/master/build/js/messenger.js', 'UI/JsLibraries/messenger.js' : 'http://raw.github.com/HubSpot/messenger/master/build/js/messenger.js',
@ -36,6 +35,7 @@ module.exports = function (grunt) {
'UI/Content/bootstrap.toggle-switch.css' : 'http://raw.github.com/ghinda/css-toggle-switch/gh-pages/toggle-switch.css', 'UI/Content/bootstrap.toggle-switch.css' : 'http://raw.github.com/ghinda/css-toggle-switch/gh-pages/toggle-switch.css',
/*
'UI/Content/FontAwesome/fontawesome.otf' : 'http://github.com/FortAwesome/Font-Awesome/blob/master/build/assets/font-awesome/font/FontAwesome.otf?raw=true', 'UI/Content/FontAwesome/fontawesome.otf' : 'http://github.com/FortAwesome/Font-Awesome/blob/master/build/assets/font-awesome/font/FontAwesome.otf?raw=true',
'UI/Content/FontAwesome/fontawesome-webfont.eot' : 'http://github.com/FortAwesome/Font-Awesome/blob/master/build/assets/font-awesome/font/fontawesome-webfont.eot?raw=true', 'UI/Content/FontAwesome/fontawesome-webfont.eot' : 'http://github.com/FortAwesome/Font-Awesome/blob/master/build/assets/font-awesome/font/fontawesome-webfont.eot?raw=true',
'UI/Content/FontAwesome/fontawesome-webfont.svg' : 'http://github.com/FortAwesome/Font-Awesome/blob/master/build/assets/font-awesome/font/fontawesome-webfont.svg?raw=true', 'UI/Content/FontAwesome/fontawesome-webfont.svg' : 'http://github.com/FortAwesome/Font-Awesome/blob/master/build/assets/font-awesome/font/fontawesome-webfont.svg?raw=true',
@ -51,6 +51,7 @@ module.exports = function (grunt) {
'UI/Content/FontAwesome/mixins.less' : 'http://raw.github.com/FortAwesome/Font-Awesome/master/build/assets/font-awesome/less/mixins.less', 'UI/Content/FontAwesome/mixins.less' : 'http://raw.github.com/FortAwesome/Font-Awesome/master/build/assets/font-awesome/less/mixins.less',
'UI/Content/FontAwesome/path.less' : 'http://raw.github.com/FortAwesome/Font-Awesome/master/build/assets/font-awesome/less/path.less', 'UI/Content/FontAwesome/path.less' : 'http://raw.github.com/FortAwesome/Font-Awesome/master/build/assets/font-awesome/less/path.less',
'UI/Content/FontAwesome/variables.less' : 'http://raw.github.com/FortAwesome/Font-Awesome/master/build/assets/font-awesome/less/variables.less' 'UI/Content/FontAwesome/variables.less' : 'http://raw.github.com/FortAwesome/Font-Awesome/master/build/assets/font-awesome/less/variables.less'
*/
}, },
clean: { clean: {
@ -125,6 +126,9 @@ module.exports = function (grunt) {
}, },
watch: { watch: {
options: {
nospawn: false,
},
bootstrap : { bootstrap : {
files: ['UI/**/Bootstrap/**', 'UI/**/FontAwesome/**'], files: ['UI/**/Bootstrap/**', 'UI/**/FontAwesome/**'],
tasks: ['less:bootstrap'] tasks: ['less:bootstrap']

View File

@ -5,7 +5,6 @@
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="jQuery-1.9.1" level="application" /> <orderEntry type="library" name="jQuery-1.9.1" level="application" />
<orderEntry type="library" name="libraries" level="project" />
</component> </component>
</module> </module>

View File

@ -35,10 +35,7 @@
<option name="FINALLY_ON_NEW_LINE" value="true" /> <option name="FINALLY_ON_NEW_LINE" value="true" />
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" /> <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
<option name="SPACE_AFTER_COLON" value="false" /> <option name="SPACE_AFTER_COLON" value="false" />
<option name="CALL_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" /> <option name="METHOD_PARAMETERS_WRAP" value="5" />
<option name="CALL_PARAMETERS_RPAREN_ON_NEXT_LINE" value="true" />
<option name="METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
<option name="METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE" value="true" />
<option name="ARRAY_INITIALIZER_WRAP" value="2" /> <option name="ARRAY_INITIALIZER_WRAP" value="2" />
<option name="IF_BRACE_FORCE" value="3" /> <option name="IF_BRACE_FORCE" value="3" />
<option name="DOWHILE_BRACE_FORCE" value="3" /> <option name="DOWHILE_BRACE_FORCE" value="3" />

View File

@ -4,6 +4,7 @@
<w>backgrid</w> <w>backgrid</w>
<w>bnzbd</w> <w>bnzbd</w>
<w>clickable</w> <w>clickable</w>
<w>couldn</w>
<w>mouseenter</w> <w>mouseenter</w>
<w>mouseleave</w> <w>mouseleave</w>
</words> </words>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="JavaScriptLibraryMappings"> <component name="JavaScriptLibraryMappings">
<file url="PROJECT" libraries="{libraries}" /> <file url="PROJECT" libraries="{jQuery-1.9.1}" />
</component> </component>
</project> </project>

View File

@ -63,7 +63,7 @@
<option passfail="false" /> <option passfail="false" />
<option white="false" /> <option white="false" />
<option maxerr="50" /> <option maxerr="50" />
<option predef="NzbDrone, define, Backbone, _, window,Handlebars,require,$,Marionette, Backgrid, jQuery, signalR" /> <option predef="window, define, require ,$" />
</component> </component>
</project> </project>

View File

@ -1,51 +0,0 @@
<component name="libraryTable">
<library name="libraries" type="javaScript">
<properties>
<sourceFilesUrls>
<item url="file://$PROJECT_DIR$/JsLibraries/bootstrap.js" />
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.debug.js" />
<item url="file://$PROJECT_DIR$/JsLibraries/jquery.js" />
<item url="file://$PROJECT_DIR$/JsLibraries/sugar.js" />
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.shortcuts.js" />
<item url="file://$PROJECT_DIR$/JsLibraries/jquery.tablesorter.pager.js" />
<item url="file://$PROJECT_DIR$/JsLibraries/handlebars.runtime.js" />
<item url="file://$PROJECT_DIR$/JsLibraries/jquery.tablesorter.bootstrap.js" />
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.modelbinder.js" />
<item url="file://$PROJECT_DIR$/JsLibraries/jquery.tablesorter.js" />
<item url="file://$PROJECT_DIR$/JsLibraries/fullcalendar.js" />
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.collectionbinder.js" />
<item url="file://$PROJECT_DIR$/JsLibraries/underscore.js" />
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.marionette.js" />
<item url="file://$PROJECT_DIR$/JsLibraries/bootstrap.slider.js" />
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.marionette.viewswapper.js" />
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.js" />
<item url="file://$PROJECT_DIR$/JsLibraries/require.js" />
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.mutators.js" />
</sourceFilesUrls>
</properties>
<CLASSES>
<root url="file://$PROJECT_DIR$/JsLibraries/bootstrapSwitch.js" />
<root url="file://$PROJECT_DIR$/JsLibraries/toastr-1.1.5.js" />
<root url="file://$PROJECT_DIR$/JsLibraries/bootstrap.js" />
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.debug.js" />
<root url="file://$PROJECT_DIR$/JsLibraries/jquery.js" />
<root url="file://$PROJECT_DIR$/JsLibraries/sugar.js" />
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.shortcuts.js" />
<root url="file://$PROJECT_DIR$/JsLibraries/jquery.tablesorter.pager.js" />
<root url="file://$PROJECT_DIR$/JsLibraries/handlebars.runtime.js" />
<root url="file://$PROJECT_DIR$/JsLibraries/jquery.tablesorter.bootstrap.js" />
<root url="file://$PROJECT_DIR$/JsLibraries/jquery.tablesorter.js" />
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.modelbinder.js" />
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.collectionbinder.js" />
<root url="file://$PROJECT_DIR$/JsLibraries/fullcalendar.js" />
<root url="file://$PROJECT_DIR$/JsLibraries/underscore.js" />
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.marionette.js" />
<root url="file://$PROJECT_DIR$/JsLibraries/bootstrap.slider.js" />
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.marionette.viewswapper.js" />
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.js" />
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.mutators.js" />
<root url="file://$PROJECT_DIR$/JsLibraries/require.js" />
</CLASSES>
<SOURCES />
</library>
</component>

View File

@ -1,13 +1,9 @@
'use strict'; 'use strict';
define( define(
[ [
'marionette', 'marionette',
'AddSeries/Collection', 'AddSeries/Collection',
'AddSeries/SearchResultCollectionView', 'AddSeries/SearchResultCollectionView',
'Shared/SpinnerView',
'app',
'AddSeries/RootFolders/Collection',
'AddSeries/SearchResultView',
'Shared/SpinnerView' 'Shared/SpinnerView'
], function (Marionette, AddSeriesCollection, SearchResultCollectionView, SpinnerView) { ], function (Marionette, AddSeriesCollection, SearchResultCollectionView, SpinnerView) {
return Marionette.Layout.extend({ return Marionette.Layout.extend({

View File

@ -1,12 +1,11 @@
'use strict'; 'use strict';
define( define(
[ [
'app',
'backbone', 'backbone',
'Series/SeriesModel' 'Series/SeriesModel'
], function (App, Backbone, SeriesModel) { ], function (Backbone, SeriesModel) {
return Backbone.Collection.extend({ return Backbone.Collection.extend({
url : Constants.ApiRoot + '/series/lookup', url : window.ApiRoot + '/series/lookup',
model: SeriesModel, model: SeriesModel,
parse: function (response) { parse: function (response) {

View File

@ -1,4 +1,4 @@
'use strict'; 'use strict';
define( define(
[ [
'backbone', 'backbone',
@ -6,12 +6,12 @@ define(
'mixins/backbone.signalr.mixin' 'mixins/backbone.signalr.mixin'
], function (Backbone, RootFolderModel) { ], function (Backbone, RootFolderModel) {
var rootFolderCollection = Backbone.Collection.extend({ var RootFolderCollection = Backbone.Collection.extend({
url : NzbDrone.Constants.ApiRoot + '/rootfolder', url : window.ApiRoot + '/rootfolder',
model: RootFolderModel model: RootFolderModel
}); });
var collection = new rootFolderCollection().BindSignalR(); var collection = new RootFolderCollection().BindSignalR();
return collection; return collection;
}); });

View File

@ -1,12 +1,12 @@
'use strict'; 'use strict';
define([ define(
'app', [
'Calendar/UpcomingCollectionView', 'marionette',
'Calendar/CalendarView', 'Calendar/UpcomingCollection',
'Shared/Toolbar/ToolbarLayout' 'Calendar/UpcomingCollectionView',
], 'Calendar/CalendarView',
function () { ], function (Marionette, UpcomingCollection, UpcomingCollectionView, CalendarView) {
NzbDrone.Calendar.CalendarLayout = Backbone.Marionette.Layout.extend({ return Marionette.Layout.extend({
template: 'Calendar/CalendarLayoutTemplate', template: 'Calendar/CalendarLayoutTemplate',
regions: { regions: {
@ -15,7 +15,7 @@ define([
}, },
initialize: function () { initialize: function () {
this.upcomingCollection = new NzbDrone.Calendar.UpcomingCollection(); this.upcomingCollection = new UpcomingCollection();
this.upcomingCollection.fetch(); this.upcomingCollection.fetch();
}, },
@ -25,13 +25,13 @@ define([
}, },
_showUpcoming: function () { _showUpcoming: function () {
this.upcoming.show(new NzbDrone.Calendar.UpcomingCollectionView({ this.upcoming.show(new UpcomingCollectionView({
collection: this.upcomingCollection collection: this.upcomingCollection
})); }));
}, },
_showCalendar: function () { _showCalendar: function () {
this.calendar.show(new NzbDrone.Calendar.CalendarView()); this.calendar.show(new CalendarView());
} }
}); });
}); });

View File

@ -1,81 +1,87 @@
'use strict'; 'use strict';
define(['app', 'Calendar/Collection','fullcalendar'], function () { define(
NzbDrone.Calendar.CalendarView = Backbone.Marionette.ItemView.extend({ [
initialize : function () { 'marionette',
this.collection = new NzbDrone.Calendar.Collection(); 'Calendar/Collection',
}, 'fullcalendar'
render: function () { ], function (Marionette, CalendarCollection) {
$(this.$el).empty().fullCalendar({
defaultView : 'basicWeek',
allDayDefault : false,
ignoreTimezone: false,
weekMode : 'variable',
timeFormat : 'h(:mm)tt',
header : {
left : 'prev,next today',
center: 'title',
right : 'month,basicWeek'
},
buttonText : {
prev: '<i class="icon-arrow-left"></i>',
next: '<i class="icon-arrow-right"></i>'
},
events : this.getEvents,
eventRender : function (event, element) {
$(element).addClass(event.statusLevel);
$(element).children('.fc-event-inner').addClass(event.statusLevel);
element.popover({ var _instance;
title : '{seriesTitle} - {season}x{episode} - {episodeTitle}'.assign({
seriesTitle : event.title,
season : event.seasonNumber,
episode : event.episodeNumber.pad(2),
episodeTitle: event.episodeTitle
}),
content : event.overview,
placement: 'bottom',
trigger : 'manual'
});
},
eventMouseover: function () {
$(this).popover('show');
},
eventMouseout : function () {
$(this).popover('hide');
}
});
NzbDrone.Calendar.CalendarView.Instance = this; return Marionette.ItemView.extend({
}, initialize: function () {
this.collection = new CalendarCollection();
},
render : function () {
$(this.$el).empty().fullCalendar({
defaultView : 'basicWeek',
allDayDefault : false,
ignoreTimezone: false,
weekMode : 'variable',
timeFormat : 'h(:mm)tt',
header : {
left : 'prev,next today',
center: 'title',
right : 'month,basicWeek'
},
buttonText : {
prev: '<i class="icon-arrow-left"></i>',
next: '<i class="icon-arrow-right"></i>'
},
events : this.getEvents,
eventRender : function (event, element) {
$(element).addClass(event.statusLevel);
$(element).children('.fc-event-inner').addClass(event.statusLevel);
onShow: function () { element.popover({
this.$('.fc-button-today').click(); title : '{seriesTitle} - {season}x{episode} - {episodeTitle}'.assign({
}, seriesTitle : event.title,
season : event.seasonNumber,
episode : event.episodeNumber.pad(2),
episodeTitle: event.episodeTitle
}),
content : event.overview,
placement: 'bottom',
trigger : 'manual'
});
},
eventMouseover: function () {
$(this).popover('show');
},
eventMouseout : function () {
$(this).popover('hide');
}
});
getEvents: function (start, end, callback) { _instance = this;
var bbView = NzbDrone.Calendar.CalendarView.Instance; },
var startDate = Date.create(start).format(Date.ISO8601_DATETIME); onShow: function () {
var endDate = Date.create(end).format(Date.ISO8601_DATETIME); this.$('.fc-button-today').click();
},
bbView.collection.fetch({ getEvents: function (start, end, callback) {
data : { start: startDate, end: endDate }, var startDate = Date.create(start).format(Date.ISO8601_DATETIME);
success: function (calendarCollection) { var endDate = Date.create(end).format(Date.ISO8601_DATETIME);
_.each(calendarCollection.models, function (element) {
var episodeTitle = element.get('title');
var seriesTitle = element.get('series').get('title');
var start = element.get('airDate');
element.set('title', seriesTitle); _instance.collection.fetch({
element.set('episodeTitle', episodeTitle); data : { start: startDate, end: endDate },
element.set('start', start); success: function (calendarCollection) {
element.set('allDay', false); _.each(calendarCollection.models, function (element) {
}); var episodeTitle = element.get('title');
var seriesTitle = element.get('series').get('title');
var start = element.get('airDate');
callback(calendarCollection.toJSON()); element.set('title', seriesTitle);
} element.set('episodeTitle', episodeTitle);
}); element.set('start', start);
} element.set('allDay', false);
});
callback(calendarCollection.toJSON());
}
});
}
});
}); });
});

View File

@ -1,13 +1,17 @@
'use strict'; 'use strict';
define(['app', 'Series/EpisodeModel'], function () { define(
NzbDrone.Calendar.Collection = Backbone.Collection.extend({ [
url : NzbDrone.Constants.ApiRoot + '/calendar', 'backbone',
model : NzbDrone.Series.EpisodeModel, 'Series/EpisodeModel'
], function (Backbone, EpisodeModel) {
return Backbone.Collection.extend({
url : window.ApiRoot + '/calendar',
model: EpisodeModel,
comparator: function(model) { comparator: function (model) {
var date = new Date(model.get('airDate')); var date = new Date(model.get('airDate'));
var time = date.getTime(); var time = date.getTime();
return time; return time;
} }
});
}); });
});

View File

@ -1,13 +1,17 @@
'use strict'; 'use strict';
define(['app', 'Series/EpisodeModel'], function () { define(
NzbDrone.Calendar.UpcomingCollection = Backbone.Collection.extend({ [
url : NzbDrone.Constants.ApiRoot + '/calendar', 'backbone',
model : NzbDrone.Series.EpisodeModel, 'Series/EpisodeModel'
], function (Backbone, EpisodeModel) {
return Backbone.Collection.extend({
url : window.ApiRoot + '/calendar',
model: EpisodeModel,
comparator: function(model) { comparator: function (model) {
var date = new Date(model.get('airDate')); var date = new Date(model.get('airDate'));
var time = date.getTime(); var time = date.getTime();
return time; return time;
} }
});
}); });
});

View File

@ -1,7 +1,11 @@
'use strict'; 'use strict';
define(['app', 'Calendar/UpcomingItemView'], function () { define(
NzbDrone.Calendar.UpcomingCollectionView = Backbone.Marionette.CollectionView.extend({ [
itemView: NzbDrone.Calendar.UpcomingItemView 'marionette',
'Calendar/UpcomingItemView'
], function (Marionette, UpcomingItemView) {
return Marionette.CollectionView.extend({
itemView: UpcomingItemView
});
}); });
});

View File

@ -1,12 +1,11 @@
'use strict'; 'use strict';
define([ define(
'app', [
'Calendar/UpcomingCollection' 'marionette'
], function (Marionette) {
], function () { return Marionette.ItemView.extend({
NzbDrone.Calendar.UpcomingItemView = Backbone.Marionette.ItemView.extend({ template: 'Calendar/UpcomingItemTemplate',
template : 'Calendar/UpcomingItemTemplate', tagName : 'div'
tagName : 'div' });
}); });
});

View File

@ -1,121 +1,121 @@
.calendar { .calendar {
th, td { th, td {
border-color: #eeeeee; border-color : #eeeeee;
} }
.primary { .primary {
border-color: #007ccd; border-color : #007ccd;
background-color: #007ccd; background-color : #007ccd;
} }
.fc-event-skin { .fc-event-skin {
background-color: #007ccd; background-color : #007ccd;
border: 1px solid #007ccd; border : 1px solid #007ccd;
border-radius: 4px; border-radius : 4px;
text-align: center; text-align : center;
} }
.info { .info {
border-color: #14b8d4; border-color : #14b8d4;
background-color: #14b8d4; background-color : #14b8d4;
} }
.inverse { .inverse {
border-color: #333333; border-color : #333333;
background-color: #333333; background-color : #333333;
} }
.warning { .warning {
border-color: #ffa93c; border-color : #ffa93c;
background-color: #ffa93c; background-color : #ffa93c;
} }
.danger { .danger {
border-color: #ea494a; border-color : #ea494a;
background-color: #ea494a; background-color : #ea494a;
} }
th { th {
background-color: #eeeeee; background-color : #eeeeee;
} }
.purple { .purple {
border-color: #7932ea; border-color : #7932ea;
background-color: #7932ea; background-color : #7932ea;
} }
.success { .success {
border-color: #4cb158; border-color : #4cb158;
background-color: #4cb158; background-color : #4cb158;
} }
h2 { h2 {
font-size: 17.5px; font-size : 17.5px;
} }
} }
.event { .event {
display: inline-block; display : inline-block;
width: 100%; width : 100%;
margin-bottom: 10px; margin-bottom : 10px;
border-top: 1px solid #eeeeee; border-top : 1px solid #eeeeee;
padding-top: 10px; padding-top : 10px;
.primary { .primary {
border-color: #007ccd; border-color : #007ccd;
} }
.info { .info {
border-color: #14b8d4; border-color : #14b8d4;
} }
h4 { h4 {
text-transform: none !important; text-transform : none !important;
font-weight: 500; font-weight : 500;
color: #008dcd; color : #008dcd;
margin: 5px 0px; margin : 5px 0px;
} }
.inverse { .inverse {
border-color: #333333; border-color : #333333;
} }
.warning { .warning {
border-color: #ffa93c; border-color : #ffa93c;
} }
p { p {
color: #999999; color : #999999;
} }
.danger { .danger {
border-color: #ea494a; border-color : #ea494a;
} }
.date { .date {
text-align: center; text-align : center;
display: inline-block; display : inline-block;
border-left: 4px solid #eeeeee; border-left : 4px solid #eeeeee;
padding-left: 16px; padding-left : 16px;
float: left; float : left;
margin-right: 20px; margin-right : 20px;
h4 { h4 {
line-height: 1em; line-height : 1em;
color: #555555; color : #555555;
font-weight: 300; font-weight : 300;
} }
h1 { h1 {
font-weight: 500; font-weight : 500;
line-height: 0.8em; line-height : 0.8em;
} }
} }
.purple { .purple {
border-color: #7932ea; border-color : #7932ea;
} }
.success { .success {
border-color: #4cb158; border-color : #4cb158;
} }
} }

View File

@ -1,15 +1,19 @@
'use strict'; 'use strict';
define(['app', 'Shared/FormatHelpers', 'Cells/NzbDroneCell'], function () { define(
return NzbDrone.Cells.NzbDroneCell.extend({ [
className: 'air-date-cell', 'backgrid',
'Shared/FormatHelpers'
], function (Backgrid, FormatHelpers) {
return Backgrid.Cell.extend({
className: 'air-date-cell',
render: function () { render: function () {
this.$el.empty(); this.$el.empty();
var airDate = this.model.get(this.column.get('name')); var airDate = this.model.get(this.column.get('name'));
this.$el.html(NzbDrone.Shared.FormatHelpers.DateHelper(airDate)); this.$el.html(FormatHelpers.DateHelper(airDate));
return this; return this;
} }
});
}); });
});

View File

@ -1,49 +1,52 @@
'use strict'; 'use strict';
define(['app', 'Cells/NzbDroneCell'], function () { define(
return NzbDrone.Cells.NzbDroneCell.extend({ [
'Cells/NzbDroneCell'
], function (NzbDroneCell) {
return NzbDroneCell.extend({
className: 'episode-number-cell', className: 'episode-number-cell',
render: function () { render: function () {
this.$el.empty(); this.$el.empty();
var airDateField = this.column.get('airDate') || 'airDate'; var airDateField = this.column.get('airDate') || 'airDate';
var seasonField = this.column.get('seasonNumber') || 'seasonNumber'; var seasonField = this.column.get('seasonNumber') || 'seasonNumber';
var episodeField = this.column.get('episodes') || 'episodeNumber'; var episodeField = this.column.get('episodes') || 'episodeNumber';
if (this.cellValue) { if (this.cellValue) {
var airDate = this.cellValue.get(airDateField); var airDate = this.cellValue.get(airDateField);
var seasonNumber = this.cellValue.get(seasonField); var seasonNumber = this.cellValue.get(seasonField);
var episodes = this.cellValue.get(episodeField); var episodes = this.cellValue.get(episodeField);
var result = 'Unknown'; var result = 'Unknown';
if (episodes) { if (episodes) {
var paddedEpisodes; var paddedEpisodes;
if (episodes.constructor === Array) { if (episodes.constructor === Array) {
paddedEpisodes = _.map(episodes,function (episodeNumber) { paddedEpisodes = _.map(episodes,function (episodeNumber) {
return episodeNumber.pad(2); return episodeNumber.pad(2);
}).join(); }).join();
}
else {
paddedEpisodes = episodes.pad(2);
}
result = 'S{0}-E{1}'.format(seasonNumber.pad(2), paddedEpisodes);
} }
else { else if (airDate) {
paddedEpisodes = episodes.pad(2); result = new Date(airDate).toLocaleDateString();
} }
result = 'S{0}-E{1}'.format(seasonNumber.pad(2), paddedEpisodes); this.$el.html(result);
} }
else if (airDate) { this.delegateEvents();
result = new Date(airDate).toLocaleDateString(); return this;
}
this.$el.html(result);
} }
this.delegateEvents(); });
return this;
}
}); });
});

View File

@ -1,34 +1,37 @@
'use strict'; 'use strict';
define(['app','cells/nzbdronecell' ], function () { define(
return NzbDrone.Cells.NzbDroneCell.extend({ [
'backgrid'
], function (Backgrid) {
return Backgrid.Cell.extend({
className: 'episode-status-cell', className: 'episode-status-cell',
render: function () { render: function () {
this.$el.empty(); this.$el.empty();
if (this.model) { if (this.model) {
var icon; var icon;
if (this.model.get('episodeFile')) { if (this.model.get('episodeFile')) {
icon = 'icon-ok'; icon = 'icon-ok';
}
else {
if (this.model.get('hasAired')) {
icon = 'icon-warning-sign';
} }
else { else {
icon = 'icon-time'; if (this.model.get('hasAired')) {
icon = 'icon-warning-sign';
}
else {
icon = 'icon-time';
}
} }
this.$el.html('<i class="{0}"/>'.format(icon));
} }
this.$el.html('<i class="{0}"/>'.format(icon)); return this;
} }
});
return this;
}
}); });
});

View File

@ -1,22 +1,27 @@
'use strict'; 'use strict';
define(['app', 'Cells/NzbDroneCell'], function () { define(
return NzbDrone.Cells.NzbDroneCell.extend({ [
'app',
'Cells/NzbDroneCell',
'Episode/Layout'
], function (App, NzbDroneCell, EpisodeLayout) {
return NzbDroneCell.extend({
className: 'episode-title-cell', className: 'episode-title-cell',
events: { events: {
'click': 'showDetails' 'click': 'showDetails'
}, },
showDetails: function () { showDetails: function () {
var view = new NzbDrone.Episode.Layout({ model: this.cellValue }); var view = new EpisodeLayout({ model: this.cellValue });
NzbDrone.modalRegion.show(view); App.modalRegion.show(view);
}, },
render: function () { render: function () {
this.$el.html(this.cellValue.get('title')); this.$el.html(this.cellValue.get('title'));
return this; return this;
} }
});
}); });
});

View File

@ -1,15 +1,19 @@
'use strict'; 'use strict';
define(['app', 'Shared/FormatHelpers','backgrid'], function () { define(
NzbDrone.Cells.FileSizeCell = Backgrid.Cell.extend({ [
'backgrid',
'Shared/FormatHelpers'
], function (Backgrid, FormatHelpers) {
return Backgrid.Cell.extend({
className: 'file-size-cell', className: 'file-size-cell',
render: function () { render: function () {
var size = this.model.get(this.column.get('name')); var size = this.model.get(this.column.get('name'));
this.$el.html(NzbDrone.Shared.FormatHelpers.FileSizeHelper(size)); this.$el.html(FormatHelpers.FileSizeHelper(size));
this.delegateEvents(); this.delegateEvents();
return this; return this;
} }
});
}); });
});

View File

@ -1,13 +1,16 @@
'use strict'; 'use strict';
define(['app','backgrid'], function () { define(
NzbDrone.Cells.IndexerCell = Backgrid.Cell.extend({ [
'backgrid'
], function (Backgrid) {
return Backgrid.Cell.extend({
class : 'indexer-cell', class : 'indexer-cell',
render: function () { render: function () {
var indexer = this.model.get(this.column.get('name')); var indexer = this.model.get(this.column.get('name'));
this.$el.html(indexer); this.$el.html(indexer);
return this; return this;
} }
});
}); });
});

View File

@ -1,44 +1,47 @@
'use strict'; 'use strict';
define(['app','backgrid'], function () { define(
NzbDrone.Cells.NzbDroneCell = Backgrid.Cell.extend({ [
'backgrid'
], function (Backgrid) {
return Backgrid.Cell.extend({
_originalInit: Backgrid.Cell.prototype.initialize, _originalInit: Backgrid.Cell.prototype.initialize,
initialize: function () { initialize: function () {
this._originalInit.apply(this, arguments); this._originalInit.apply(this, arguments);
this.cellValue = this._getValue(); this.cellValue = this._getValue();
this.listenTo(this.model, 'change', this._refresh); this.listenTo(this.model, 'change', this._refresh);
}, },
_refresh: function () { _refresh: function () {
this.cellValue = this._getValue(); this.cellValue = this._getValue();
this.render(); this.render();
}, },
_getValue: function () { _getValue: function () {
var name = this.column.get('name'); var name = this.column.get('name');
if (name === 'this') { if (name === 'this') {
return this.model; return this.model;
}
var value = this.model.get(name);
if (!value) {
return undefined;
}
//if not a model
if (!value.get && typeof value === 'object') {
value = new Backbone.Model(value);
}
return value;
} }
var value = this.model.get(name); });
if (!value) {
return undefined;
}
//if not a model
if (!value.get && typeof value === 'object') {
value = new Backbone.Model(value);
}
return value;
}
}); });
});

View File

@ -1,9 +1,12 @@
'use strict'; 'use strict';
define(['app', 'Cells/TemplatedCell'], function (App, TemplatedCell) { define(
return TemplatedCell.extend({ [
'Cells/TemplatedCell'
], function (TemplatedCell) {
return TemplatedCell.extend({
className: 'quality-cell', className: 'quality-cell',
template : 'Cells/QualityTemplate' template : 'Cells/QualityTemplate'
});
}); });
});

View File

@ -1,15 +1,18 @@
'use strict'; 'use strict';
define(['app','Cells/NzbDroneCell'], function () { define(
return NzbDrone.Cells.NzbDroneCell.extend({ [
'Cells/NzbDroneCell'
], function (NzbDroneCell) {
return NzbDroneCell.extend({
className : 'relative-date-cell', className: 'relative-date-cell',
render: function () { render: function () {
var date = this.model.get(this.column.get('name')); var date = this.model.get(this.column.get('name'));
this.$el.html(Date.create(date).relative()); this.$el.html(Date.create(date).relative());
return this; return this;
} }
});
}); });
});

View File

@ -1,25 +0,0 @@
'use strict';
define(['app','cells/nzbdronecell'], function () {
return NzbDrone.Cells.NzbDroneCell.extend({
className: 'series-status-cell',
render: function () {
this.$el.empty();
var monitored = this.model.get('monitored');
var status = this.model.get('status');
if (!monitored) {
this.$el.html('<i class="icon-pause grid-icon" title="Not Monitored"></i>');
}
else if (status === 'continuing') {
this.$el.html('<i class="icon-play grid-icon" title="Continuing"></i>');
}
else {
this.$el.html('<i class="icon-stop grid-icon" title="Ended"></i>');
}
return this;
}
});
});

View File

@ -1,9 +1,12 @@
'use strict'; 'use strict';
define(['app', 'Cells/TemplatedCell'], function (App, TemplatedCell) { define(
return TemplatedCell.extend({ [
'Cells/TemplatedCell'
], function (TemplatedCell) {
return TemplatedCell.extend({
className: 'series-title', className: 'series-title',
template : 'Cells/SeriesTitleTemplate' template : 'Cells/SeriesTitleTemplate'
});
}); });
});

View File

@ -1,17 +1,23 @@
'use strict'; 'use strict';
define(['app','Cells/NzbDroneCell'], function () { define(
return NzbDrone.Cells.NzbDroneCell.extend({ [
render: function () { 'marionette',
'Cells/NzbDroneCell'
], function (Marionette, NzbDroneCell) {
return NzbDroneCell.extend({
var templateName = this.column.get('template') || this.template;
this.templateFunction = Marionette.TemplateCache.get(templateName); render: function () {
var data = this.cellValue.toJSON();
var html = this.templateFunction(data);
this.$el.html(html);
return this; var templateName = this.column.get('template') || this.template;
}
this.templateFunction = Marionette.TemplateCache.get(templateName);
var data = this.cellValue.toJSON();
var html = this.templateFunction(data);
this.$el.html(html);
return this;
}
});
}); });
});

View File

@ -1,39 +1,42 @@
'use strict'; 'use strict';
define(['app', 'Episode/Layout'], function () { define(
return Backgrid.Cell.extend({ [
'backgrid'
], function (Backgrid) {
return Backgrid.Cell.extend({
className: 'toggle-cell clickable', className: 'toggle-cell clickable',
events: { events: {
'click': '_onClick' 'click': '_onClick'
}, },
_onClick: function () { _onClick: function () {
var name = this.column.get('name'); var name = this.column.get('name');
this.model.set(name, !this.model.get(name)); this.model.set(name, !this.model.get(name));
this.render(); this.render();
this.model.save(); this.model.save();
}, },
render: function () { render: function () {
this.$el.empty(); this.$el.empty();
this.$el.html('<i />'); this.$el.html('<i />');
var name = this.column.get('name'); var name = this.column.get('name');
if (this.model.get(name)) { if (this.model.get(name)) {
this.$('i').addClass(this.column.get('trueClass')); this.$('i').addClass(this.column.get('trueClass'));
}
else {
this.$('i').addClass(this.column.get('falseClass'));
}
return this;
} }
else { });
this.$('i').addClass(this.column.get('falseClass'));
}
return this;
}
}); });
});

View File

@ -1,17 +1,16 @@
'use strict'; 'use strict';
define(['app'], function () { define({
Execute: function (name, properties) {
var data = { command: name };
NzbDrone.Commands.Execute = function (name, properties) { if (properties) {
var data = { command: name }; $.extend(data, properties);
}
if (properties) { return $.ajax({
$.extend(data, properties); type: 'POST',
url : window.ApiRoot + '/command',
data: JSON.stringify(data)
});
} }
});
return $.ajax({
type: 'POST',
url : NzbDrone.Constants.ApiRoot + '/command',
data: JSON.stringify(data)
});
};
});

View File

@ -2,41 +2,38 @@
define( define(
[ [
'app' 'app'
], function () { ], function (App) {
return {
NzbDrone.Config = {
Events: { Events: {
ConfigUpdatedEvent: 'ConfigUpdatedEvent' ConfigUpdatedEvent: 'ConfigUpdatedEvent'
}, },
Keys : { Keys : {
DefaultQualityProfileId: 'DefaultQualityProfileId' DefaultQualityProfileId: 'DefaultQualityProfileId'
} },
};
NzbDrone.Config.GetValue = function (key, defaultValue) { GetValue: function (key, defaultValue) {
var storeValue = localStorage.getItem(key); var storeValue = localStorage.getItem(key);
if (!storeValue) {
return defaultValue;
}
return storeValue.toString();
},
SetValue: function (key, value) {
console.log('Config: [{0}] => [{1}] '.format(key, value));
if (this.GetValue(key) === value.toString()) {
return;
}
localStorage.setItem(key, value);
App.vent.trigger(this.Events.ConfigUpdatedEvent, {key: key, value: value});
if (!storeValue) {
return defaultValue;
} }
return storeValue.toString();
}; };
NzbDrone.Config.SetValue = function (key, value) {
console.log('Config: [{0}] => [{1}] '.format(key, value));
if (NzbDrone.Config.GetValue(key) === value.toString()) {
return;
}
localStorage.setItem(key, value);
NzbDrone.vent.trigger(NzbDrone.Config.Events.ConfigUpdatedEvent, {key: key, value: value});
};
return NzbDrone.Config;
}); });

View File

@ -244,10 +244,6 @@ ul.messenger-theme-future {
-ms-border-radius: 4px; -ms-border-radius: 4px;
-o-border-radius: 4px; -o-border-radius: 4px;
border-radius: 4px; border-radius: 4px;
-moz-user-select: none;
-webkit-user-select: none;
-o-user-select: none;
user-select: none;
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #5c5b5b), color-stop(100%, #353535)); background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #5c5b5b), color-stop(100%, #353535));
background-image: -webkit-linear-gradient(#5c5b5b, #353535); background-image: -webkit-linear-gradient(#5c5b5b, #353535);
background-image: -moz-linear-gradient(#5c5b5b, #353535); background-image: -moz-linear-gradient(#5c5b5b, #353535);

View File

@ -1,4 +1,4 @@
.control-group { .control-group {
.controls { .controls {
i.danger { i.danger {
color: #b94a48; color: #b94a48;
@ -19,6 +19,14 @@
margin-bottom: 0px; margin-bottom: 0px;
} }
.help-inline-checkbox { .help-inline-checkbox {
padding-left: 5px; padding-left: 5px;
display: inline-block; display: inline-block;
@ -35,6 +43,8 @@
font-size: 12px; font-size: 12px;
} }
textarea.nzb-restrictions { textarea.nzb-restrictions {
width: 260px; width: 260px;
} }

View File

@ -1,40 +1,36 @@
'use strict'; 'use strict';
define( define(
[ [
'app', 'app',
'marionette',
'History/HistoryLayout',
'Settings/SettingsLayout', 'Settings/SettingsLayout',
'AddSeries/AddSeriesLayout', 'AddSeries/AddSeriesLayout',
'Missing/MissingLayout',
'History/HistoryLayout',
'Form/FormBuilder',
'Series/Index/SeriesIndexLayout', 'Series/Index/SeriesIndexLayout',
'Calendar/CalendarLayout',
'Shared/NotificationView',
'Shared/NotFoundView',
'MainMenuView',
'Series/Details/SeriesDetailsLayout', 'Series/Details/SeriesDetailsLayout',
'Series/EpisodeCollection', 'Missing/MissingLayout',
'Series/SeriesModel',
'Calendar/CalendarLayout',
'Logs/Layout', 'Logs/Layout',
'Release/Layout', 'Release/Layout',
'Shared/FormatHelpers', 'Shared/NotFoundView'
'Shared/TemplateHelpers', ], function (App, Marionette, HistoryLayout, SettingsLayout, AddSeriesLayout, SeriesIndexLayout, SeriesDetailsLayout, MissingLayout, SeriesModel, CalendarLayout, NotFoundView,
'Shared/Footer/View' LogsLayout, ReleaseLayout) {
], function (App, SettingsLayout, AddSeriesLayout, MissingLayout, HistoryLayout) { return Marionette.Controller.extend({
var controller = Backbone.Marionette.Controller.extend({
series : function () { series : function () {
this._setTitle('NzbDrone'); this._setTitle('NzbDrone');
App.mainRegion.show(new NzbDrone.Series.Index.SeriesIndexLayout()); App.mainRegion.show(new SeriesIndexLayout());
}, },
seriesDetails: function (query) { seriesDetails: function (query) {
var self = this; var self = this;
this._setTitle('Loading Series'); this._setTitle('Loading Series');
var series = new NzbDrone.Series.SeriesModel({ id: query }); var series = new SeriesModel({ id: query });
series.fetch({ series.fetch({
success: function (seriesModel) { success: function (seriesModel) {
self._setTitle(seriesModel.get('title')); self._setTitle(seriesModel.get('title'));
App.mainRegion.show(new NzbDrone.Series.Details.SeriesDetailsLayout({ model: seriesModel })); App.mainRegion.show(new SeriesDetailsLayout({ model: seriesModel }));
} }
}); });
}, },
@ -46,7 +42,7 @@ define(
calendar: function () { calendar: function () {
this._setTitle('Calendar'); this._setTitle('Calendar');
App.mainRegion.show(new NzbDrone.Calendar.CalendarLayout()); App.mainRegion.show(new CalendarLayout());
}, },
@ -69,17 +65,17 @@ define(
rss: function () { rss: function () {
this._setTitle('RSS'); this._setTitle('RSS');
App.mainRegion.show(new NzbDrone.Release.Layout()); App.mainRegion.show(new ReleaseLayout());
}, },
logs: function () { logs: function () {
this._setTitle('logs'); this._setTitle('logs');
App.mainRegion.show(new NzbDrone.Logs.Layout()); App.mainRegion.show(new LogsLayout());
}, },
notFound: function () { notFound: function () {
this._setTitle('Not Found'); this._setTitle('Not Found');
App.mainRegion.show(new NzbDrone.Shared.NotFoundView(this)); App.mainRegion.show(new NotFoundView(this));
}, },
@ -112,8 +108,5 @@ define(
} }
} }
}); });
return new controller();
}); });

View File

@ -1,78 +1,85 @@
'use strict'; 'use strict';
define(['app', 'Shared/SpinnerView', 'Episode/Summary/View', 'Episode/Search/Layout', 'Release/Collection'], function () { define(
[
'marionette',
'Episode/Summary/View',
'Episode/Search/Layout',
'Release/Collection',
'Shared/SpinnerView'
], function (Marionette, SummaryView, SearchLayout, ReleaseCollection, SpinnerView) {
NzbDrone.Episode.Layout = Backbone.Marionette.Layout.extend({ return Marionette.Layout.extend({
template: 'Episode/LayoutTemplate', template: 'Episode/LayoutTemplate',
regions: { regions: {
summary : '#episode-summary', summary : '#episode-summary',
activity: '#episode-activity', activity: '#episode-activity',
search : '#episode-search' search : '#episode-search'
}, },
ui: { ui: {
summary : '.x-episode-summary', summary : '.x-episode-summary',
activity: '.x-episode-activity', activity: '.x-episode-activity',
search : '.x-episode-search' search : '.x-episode-search'
}, },
events: { events: {
'click .x-episode-summary' : 'showSummary', 'click .x-episode-summary' : 'showSummary',
'click .x-episode-activity': 'showActivity', 'click .x-episode-activity': 'showActivity',
'click .x-episode-search' : 'showSearch' 'click .x-episode-search' : 'showSearch'
}, },
onShow: function () { onShow: function () {
this.showSummary(); this.showSummary();
this._releaseSearchActivated = false; this._releaseSearchActivated = false;
}, },
showSummary: function (e) { showSummary: function (e) {
if (e) { if (e) {
e.preventDefault(); e.preventDefault();
}
this.ui.summary.tab('show');
this.summary.show(new NzbDrone.Episode.Summary.View({model: this.model}));
},
showActivity: function (e) {
if (e) {
e.preventDefault();
}
this.ui.activity.tab('show');
},
showSearch: function (e) {
if (e) {
e.preventDefault();
}
if (this._releaseSearchActivated) {
return;
}
var self = this;
this.ui.search.tab('show');
this.search.show(new NzbDrone.Shared.SpinnerView());
var releases = new NzbDrone.Release.Collection();
var promise = releases.fetchEpisodeReleases(this.model.id);
promise.done(function () {
if (!self.isClosed) {
self.search.show(new NzbDrone.Episode.Search.Layout({collection: releases}));
} }
});
} this.ui.summary.tab('show');
this.summary.show(new SummaryView({model: this.model}));
},
showActivity: function (e) {
if (e) {
e.preventDefault();
}
this.ui.activity.tab('show');
},
showSearch: function (e) {
if (e) {
e.preventDefault();
}
if (this._releaseSearchActivated) {
return;
}
var self = this;
this.ui.search.tab('show');
this.search.show(new SpinnerView());
var releases = new ReleaseCollection();
var promise = releases.fetchEpisodeReleases(this.model.id);
promise.done(function () {
if (!self.isClosed) {
self.search.show(new SearchLayout({collection: releases}));
}
});
}
});
}); });
});

View File

@ -1,68 +1,70 @@
'use strict'; 'use strict';
define([ define(
'app', [
'Cells/FileSizeCell', 'marionette',
'Cells/QualityCell', 'backgrid',
'Release/ApprovalStatusCell', 'Cells/FileSizeCell',
'Release/DownloadReportCell' 'Cells/QualityCell',
], function () { 'Release/ApprovalStatusCell',
'Release/DownloadReportCell'
], function (Marionette, Backgrid, FileSizeCell, QualityCell, ApprovalStatusCell, DownloadReportCell) {
NzbDrone.Episode.Search.Layout = Backbone.Marionette.Layout.extend({ return Marionette.Layout.extend({
template: 'Episode/Search/LayoutTemplate', template: 'Episode/Search/LayoutTemplate',
regions: { regions: {
grid: '#episode-release-grid' grid: '#episode-release-grid'
},
columns: [
{
name : 'age',
label : 'Age',
sortable: true,
cell : Backgrid.IntegerCell
},
{
name : 'title',
label : 'Title',
sortable: true,
cell : Backgrid.StringCell
},
{
name : 'size',
label : 'Size',
sortable: true,
cell : NzbDrone.Cells.FileSizeCell
},
{
name : 'quality',
label : 'Quality',
sortable: true,
cell : NzbDrone.Cells.QualityCell
}, },
{ columns:
name : 'rejections', [
label: 'decision',
cell : NzbDrone.Release.ApprovalStatusCell
},
{
name : 'download',
label: '',
cell : NzbDrone.Release.DownloadReportCell
}
],
onShow: function () {
if (!this.isClosed) {
this.grid.show(new Backgrid.Grid(
{ {
name : 'age',
label : 'Age',
sortable: true,
cell : Backgrid.IntegerCell
},
{
name : 'title',
label : 'Title',
sortable: true,
cell : Backgrid.StringCell
},
{
name : 'size',
label : 'Size',
sortable: true,
cell : FileSizeCell
},
{
name : 'quality',
label : 'Quality',
sortable: true,
cell : QualityCell
},
{
name : 'rejections',
label: 'decision',
cell : ApprovalStatusCell
},
{
name : 'download',
label: '',
cell : DownloadReportCell
}
],
onShow: function () {
if (!this.isClosed) {
this.grid.show(new Backgrid.Grid({
row : Backgrid.Row, row : Backgrid.Row,
columns : this.columns, columns : this.columns,
collection: this.collection, collection: this.collection,
className : 'table table-hover' className : 'table table-hover'
})); }));
}
} }
} });
});
}); });

View File

@ -1,8 +1,11 @@
'use strict'; 'use strict';
define(['app'], function () { define(
[
'marionette'
], function (Marionette) {
return Marionette.ItemView.extend({
template: 'Episode/Summary/ViewTemplate'
});
NzbDrone.Episode.Summary.View = Backbone.Marionette.ItemView.extend({
template: 'Episode/Summary/ViewTemplate'
}); });
});

View File

@ -1,31 +1,50 @@
'use strict'; 'use strict';
define(['app', 'handlebars'], function (App,Handlebars) { define(
Handlebars.registerHelper('formBuilder', function () { [
var ret = ''; 'handlebars'
_.each(this.fields, function (field) { ], function (Handlebars) {
ret += NzbDrone.Form.FieldBuilder(field);
var formBuilder = function (field) {
if (!field.type) {
return Handlebars.helpers.partial.apply(field,
[
'Form/TextboxTemplate'
]);
}
if (field.type === 'password') {
return Handlebars.helpers.partial.apply(field,
[
'Form/PasswordTemplate'
]);
}
if (field.type === 'checkbox') {
return Handlebars.helpers.partial.apply(field,
[
'Form/CheckboxTemplate'
]);
}
if (field.type === 'select') {
return Handlebars.helpers.partial.apply(field,
[
'Form/SelectTemplate'
]);
}
return Handlebars.helpers.partial.apply(field,
[
'Form/TextboxTemplate'
]);
};
Handlebars.registerHelper('formBuilder', function () {
var ret = '';
_.each(this.fields, function (field) {
ret += this.FieldBuilder(field);
});
return new Handlebars.SafeString(ret);
}); });
return new Handlebars.SafeString(ret);
}); });
NzbDrone.Form.FieldBuilder = function (field) {
if (!field.type) {
return Handlebars.helpers.partial.apply(field, ['Form/TextboxTemplate']);
}
if (field.type === 'password') {
return Handlebars.helpers.partial.apply(field, ['Form/PasswordTemplate']);
}
if (field.type === 'checkbox') {
return Handlebars.helpers.partial.apply(field, ['Form/CheckboxTemplate']);
}
if (field.type === 'select') {
return Handlebars.helpers.partial.apply(field, ['Form/SelectTemplate']);
}
return Handlebars.helpers.partial.apply(field, ['Form/TextboxTemplate']);
};
});

View File

@ -1,30 +1,33 @@
'use strict'; 'use strict';
define(['templates'], function (Templates) { define(
return function () { [
this.get = function (templateId) { 'templates'
], function (Templates) {
return function () {
this.get = function (templateId) {
var templateKey = templateId.toLowerCase(); var templateKey = templateId.toLowerCase();
var templateFunction = Templates[templateKey]; var templateFunction = Templates[templateKey];
if (!templateFunction) { if (!templateFunction) {
throw 'couldn\'t find pre-compiled template ' + templateKey; throw 'couldn\'t find pre-compiled template ' + templateKey;
}
return function (data) {
try {
return templateFunction(data);
}
catch (error) {
console.error('template render failed for ' + templateKey + ' ' + error);
console.error(data);
throw error;
} }
return function (data) {
try {
return templateFunction(data);
}
catch (error) {
console.error('template render failed for ' + templateKey + ' ' + error);
console.error(data);
throw error;
}
};
}; };
}; };
}; });
});

View File

@ -1,37 +1,41 @@
'use strict'; 'use strict';
define(['app', 'History/Model', 'backbone.pageable'], function (App, HistoryModel, PageableCollection) { define(
return PageableCollection.extend({ [
url : NzbDrone.Constants.ApiRoot + '/history', 'History/Model',
model : NzbDrone.History.Model, 'backbone.pageable'
], function ( HistoryModel, PageableCollection) {
return PageableCollection.extend({
url : window.ApiRoot + '/history',
model: HistoryModel,
state: { state: {
pageSize: 15, pageSize: 15,
sortKey: 'date', sortKey : 'date',
order: 1 order : 1
}, },
queryParams: { queryParams: {
totalPages: null, totalPages : null,
totalRecords: null, totalRecords: null,
pageSize: 'pageSize', pageSize : 'pageSize',
sortKey: 'sortKey', sortKey : 'sortKey',
order: 'sortDir', order : 'sortDir',
directions: { directions : {
'-1': 'asc', '-1': 'asc',
'1': 'desc' '1' : 'desc'
}
},
parseState: function (resp) {
return {totalRecords: resp.totalRecords};
},
parseRecords: function (resp) {
if (resp) {
return resp.records;
}
return resp;
} }
}, });
parseState: function (resp, queryParams, state) {
return {totalRecords: resp.totalRecords};
},
parseRecords: function (resp) {
if (resp) {
return resp.records;
}
return resp;
}
}); });
});

View File

@ -1,41 +1,44 @@
'use strict'; 'use strict';
define(['app', 'Cells/NzbDroneCell' ], function () { define(
return NzbDrone.Cells.NzbDroneCell.extend({ [
'Cells/NzbDroneCell'
], function (NzbDroneCell) {
return NzbDroneCell.extend({
className: 'history-event-type-cell', className: 'history-event-type-cell',
render: function () { render: function () {
this.$el.empty(); this.$el.empty();
if (this.cellValue) { if (this.cellValue) {
var icon; var icon;
var toolTip; var toolTip;
switch (this.cellValue) { switch (this.cellValue) {
case 'grabbed': case 'grabbed':
icon = 'icon-cloud-download'; icon = 'icon-cloud-download';
toolTip = 'Episode grabbed from indexer and sent to download client'; toolTip = 'Episode grabbed from indexer and sent to download client';
break; break;
case 'seriesFolderImported': case 'seriesFolderImported':
icon = 'icon-hdd'; icon = 'icon-hdd';
toolTip = 'Existing episode file added to library'; toolTip = 'Existing episode file added to library';
break; break;
case 'downloadFolderImported': case 'downloadFolderImported':
icon = 'icon-download-alt'; icon = 'icon-download-alt';
toolTip = 'Episode downloaded successfully and picked up from download client'; toolTip = 'Episode downloaded successfully and picked up from download client';
break; break;
default : default :
icon = 'icon-question'; icon = 'icon-question';
toolTip = 'unknown event'; toolTip = 'unknown event';
}
this.$el.html('<i class="{0}" title="{1}"/>'.format(icon, toolTip));
} }
this.$el.html('<i class="{0}" title="{1}"/>'.format(icon, toolTip)); return this;
} }
});
return this;
}
}); });
});

View File

@ -1,33 +1,19 @@
'use strict'; 'use strict';
define([ define(
'app', [
'History/Collection', 'marionette',
'History/EventTypeCell', 'backgrid',
'Cells/RelativeDateCell', 'History/Collection',
'Cells/TemplatedCell', 'History/EventTypeCell',
'Cells/SeriesTitleCell', 'Cells/SeriesTitleCell',
'Cells/EpisodeNumberCell', 'Cells/EpisodeNumberCell',
'Cells/EpisodeTitleCell', 'Cells/EpisodeTitleCell',
'Cells/QualityCell', 'Cells/QualityCell',
'Shared/Toolbar/ToolbarLayout', 'Cells/RelativeDateCell',
'Shared/Grid/Pager', 'Shared/Grid/Pager',
'Shared/Grid/HeaderCell', 'Shared/LoadingView'
'Shared/LoadingView' ], function (Marionette, Backgrid, HistoryCollection, EventTypeCell, SeriesTitleCell, EpisodeNumberCell, EpisodeTitleCell, QualityCell, RelativeDateCell, GridPager, LoadingView) {
], return Marionette.Layout.extend({
function (App,
HistoryCollection,
EventTypeCell,
RelativeDateCell,
TemplatedCell,
SeriesTitleCell,
EpisodeNumberCell,
EpisodeTitleCell,
QualityCell,
ToolbarLayout,
Pager,
HeaderCell,
LoadingView) {
return Backbone.Marionette.Layout.extend({
template: 'History/HistoryLayoutTemplate', template: 'History/HistoryLayoutTemplate',
regions: { regions: {
@ -36,54 +22,53 @@ define([
pager : '#x-pager' pager : '#x-pager'
}, },
columns: [ columns:
{ [
name: 'eventType',
label:'',
cell : EventTypeCell
},
{
name : 'series',
label : 'Series',
cell : SeriesTitleCell
},
{
name : 'episode',
label : 'Episode',
sortable: false,
cell : EpisodeNumberCell
},
{
name : 'episode',
label : 'Episode Title',
sortable: false,
cell : EpisodeTitleCell
},
{
name : 'quality',
label : 'Quality',
cell : QualityCell
},
{
name : 'date',
label: 'Date',
cell : RelativeDateCell
}
],
_showTable: function () {
this.history.show(new Backgrid.Grid(
{ {
row : NzbDrone.History.Row, name : 'eventType',
columns : this.columns, label: '',
collection: this.historyCollection, cell : EventTypeCell
className : 'table table-hover' },
})); {
name : 'series',
label: 'Series',
cell : SeriesTitleCell
},
{
name : 'episode',
label : 'Episode',
sortable: false,
cell : EpisodeNumberCell
},
{
name : 'episode',
label : 'Episode Title',
sortable: false,
cell : EpisodeTitleCell
},
{
name : 'quality',
label: 'Quality',
cell : QualityCell
},
{
name : 'date',
label: 'Date',
cell : RelativeDateCell
}
],
this.pager.show(new Pager({ _showTable: function (collection) {
this.history.show(new Backgrid.Grid({
columns : this.columns, columns : this.columns,
collection: this.historyCollection collection: collection,
className : 'table table-hover'
}));
this.pager.show(new GridPager({
columns : this.columns,
collection: collection
})); }));
}, },
@ -92,16 +77,11 @@ define([
this.history.show(new LoadingView()); this.history.show(new LoadingView());
this.historyCollection = new HistoryCollection(); var collection = new HistoryCollection();
this.historyCollection.fetch() collection.fetch().done(function () {
.done(function () { self._showTable(collection);
self._showTable(); });
});
//this.toolbar.show(new NzbDrone.Shared.Toolbar.ToolbarLayout({right: [ viewButtons], context: this}));
} }
}) });
; });
})
;

View File

@ -1,22 +1,25 @@
'use strict'; 'use strict';
define(['app','Series/SeriesModel', 'Series/EpisodeModel'], function () { define(
NzbDrone.History.Model = Backbone.Model.extend({ [
mutators: { 'backbone',
seasonNumber: function () { 'Series/SeriesModel',
return this.get('episode').seasonNumber; 'Series/EpisodeModel'
], function (Backbone, SeriesModel, EpisodeModel) {
return Backbone.Model.extend({
mutators: {
seasonNumber: function () {
return this.get('episode').seasonNumber;
},
paddedEpisodeNumber: function () {
return this.get('episode').episodeNumber.pad(2);
}
}, },
paddedEpisodeNumber: function () { parse: function (model) {
return this.get('episode').episodeNumber.pad(2); model.series = new SeriesModel(model.series);
model.episode = new EpisodeModel(model.episode);
return model;
} }
}, });
parse: function (model) {
model.series = new NzbDrone.Series.SeriesModel(model.series);
model.episode = new NzbDrone.Series.EpisodeModel(model.episode);
return model;
}
}); });
});

View File

@ -1,28 +1,28 @@
<!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">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server"> <head runat="server">
<title>NzbDrone</title> <title>NzbDrone</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/> <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<link href="/content/font.css" rel='stylesheet' type='text/css'/> <link href="/Content/Font.css" rel='stylesheet' type='text/css'/>
<link href="/content/bootstrap.css" rel='stylesheet' type='text/css'/> <link href="/Content/Bootstrap.css" rel='stylesheet' type='text/css'/>
<link href="/content/bootstrap.slider.css" rel='stylesheet' type='text/css'/> <link href="/Content/bootstrap.slider.css" rel='stylesheet' type='text/css'/>
<link href="/Content/Messenger/messenger.css" rel='stylesheet' type='text/css'/> <link href="/Content/Messenger/messenger.css" rel='stylesheet' type='text/css'/>
<link href="/Content/Messenger/messenger.future.css" rel='stylesheet' type='text/css'/> <link href="/Content/Messenger/messenger.future.css" rel='stylesheet' type='text/css'/>
<link href="/content/theme.css" rel='stylesheet' type='text/css'> <link href="/Content/Theme.css" rel='stylesheet' type='text/css'>
<link href="/Cells/cells.css" rel='stylesheet' type='text/css'> <link href="/Cells/Cells.css" rel='stylesheet' type='text/css'>
<link href="/content/fullcalendar.css" rel='stylesheet' type='text/css'> <link href="/Content/fullcalendar.css" rel='stylesheet' type='text/css'>
<link href="/content/backbone.css" rel='stylesheet' type='text/css'/> <link href="/Content/Backbone.css" rel='stylesheet' type='text/css'/>
<link href="/content/backbone.backgrid.filter.css" rel='stylesheet' type='text/css'/> <link href="/Content/backbone.backgrid.filter.css" rel='stylesheet' type='text/css'/>
<link href="/content/bootstrap.toggle-switch.css" rel='stylesheet' type='text/css'/> <link href="/Content/bootstrap.toggle-switch.css" rel='stylesheet' type='text/css'/>
<link href="/AddSeries/addseries.css" rel='stylesheet' type='text/css'/> <link href="/AddSeries/Addseries.css" rel='stylesheet' type='text/css'/>
<link href="/content/menu.css" rel='stylesheet' type='text/css'/> <link href="/Content/menu.css" rel='stylesheet' type='text/css'/>
<link href="/content/form.css" rel='stylesheet' type='text/css'/> <link href="/Content/form.css" rel='stylesheet' type='text/css'/>
<link href="/series/series.css" rel='stylesheet' type='text/css'/> <link href="/Series/Series.css" rel='stylesheet' type='text/css'/>
<link href="/series/details.css" rel='stylesheet' type='text/css'/> <link href="/Series/Details.css" rel='stylesheet' type='text/css'/>
<link href="/content/base.css" rel='stylesheet' type='text/css'/> <link href="/Content/Base.css" rel='stylesheet' type='text/css'/>
<link href="/settings/notifications/notifications.css" rel='stylesheet' type='text/css'/> <link href="/Settings/Notifications/notifications.css" rel='stylesheet' type='text/css'/>
<link href="/settings/indexers/indexers.css" rel='stylesheet' type='text/css'/> <link href="/Settings/Indexers/indexers.css" rel='stylesheet' type='text/css'/>
<link href="/calendar/calendar.css" rel='stylesheet' type='text/css'/> <link href="/Calendar/Calendar.css" rel='stylesheet' type='text/css'/>
</head> </head>
<body> <body>
<div id="in-sub-nav"> <div id="in-sub-nav">

View File

@ -1,14 +1,6 @@
'use strict'; 'use strict';
(function () { (function () {
/* var model = new NzbDrone.Shared.NotificationModel();
model.set('title','test notification');
model.set('message','test message');
model.set('level', 'error');
this.push(model);
*/
if (!window.console) { if (!window.console) {
window.console = {}; window.console = {};
} }

View File

@ -1,8 +1,8 @@
'use strict'; 'use strict';
define(['app', 'Logs/Model', 'backbone.pageable'], function (app, SeriesModel, PagableCollection) { define(['backbone.pageable', 'Logs/Model', ], function (PagableCollection, LogsModel) {
NzbDrone.Logs.Collection = PagableCollection.extend({ return PagableCollection.extend({
url : NzbDrone.Constants.ApiRoot + '/log', url : window.ApiRoot + '/log',
model: NzbDrone.Logs.Model, model: LogsModel,
state: { state: {
pageSize: 50, pageSize: 50,

View File

@ -1,12 +1,12 @@
'use strict'; 'use strict';
define([ define([
'app', 'marionette',
'Logs/Collection', 'backgrid',
'Shared/Toolbar/ToolbarLayout', 'Shared/Grid/Pager',
'Shared/Grid/Pager' 'Logs/Collection'
], ],
function () { function (Marionette,Backgrid, GridPager, LogCollection) {
NzbDrone.Logs.Layout = Backbone.Marionette.Layout.extend({ return Marionette.Layout.extend({
template: 'Logs/LayoutTemplate', template: 'Logs/LayoutTemplate',
regions: { regions: {
@ -51,20 +51,19 @@ define([
className : 'table table-hover' className : 'table table-hover'
})); }));
this.pager.show(new NzbDrone.Shared.Grid.Pager({ this.pager.show(new GridPager({
columns : this.columns, columns : this.columns,
collection: this.collection collection: this.collection
})); }));
}, },
initialize: function () { initialize: function () {
this.collection = new NzbDrone.Logs.Collection(); this.collection = new LogCollection();
this.collection.fetch(); this.collection.fetch();
}, },
onShow: function () { onShow: function () {
this.showTable(); this.showTable();
//this.toolbar.show(new NzbDrone.Shared.Toolbar.ToolbarLayout({right: [ viewButtons], context: this}));
} }
}) })

View File

@ -1,14 +1,8 @@
'use strict'; 'use strict';
define(['app'], function (app) { define(
NzbDrone.Logs.Model = Backbone.Model.extend({ [
/* mutators: { 'backbone'
seasonNumber: function () { ], function (Backbone) {
return this.get('episode').seasonNumber; return Backbone.Model.extend({
}, });
paddedEpisodeNumber: function () {
return this.get('episode').episodeNumber.pad(2);
}
}*/
}); });
});

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
define(['app'], function () { define(['marionette'], function (Marionette) {
var MainMenuView = Backbone.Marionette.ItemView.extend({ var MainMenuView = Marionette.ItemView.extend({
events: { events: {
'click a': 'onClick' 'click a': 'onClick'
}, },

View File

@ -1,37 +1,41 @@
'use strict'; 'use strict';
define(['app', 'Series/EpisodeModel', 'backbone.pageable'], function (app, EpisodeModel, PagableCollection) { define(
return PagableCollection.extend({ [
url : NzbDrone.Constants.ApiRoot + '/missing', 'Series/EpisodeModel',
model: NzbDrone.Series.EpisodeModel, 'backbone.pageable'
], function (EpisodeModel, PagableCollection) {
return PagableCollection.extend({
url : window.ApiRoot + '/missing',
model: EpisodeModel,
state: { state: {
pageSize: 15, pageSize: 15,
sortKey : 'airDate', sortKey : 'airDate',
order : 1 order : 1
}, },
queryParams: { queryParams: {
totalPages : null, totalPages : null,
totalRecords: null, totalRecords: null,
pageSize : 'pageSize', pageSize : 'pageSize',
sortKey : 'sortKey', sortKey : 'sortKey',
order : 'sortDir', order : 'sortDir',
directions : { directions : {
'-1': 'asc', '-1': 'asc',
'1' : 'desc' '1' : 'desc'
}
},
parseState: function (resp) {
return {totalRecords: resp.totalRecords};
},
parseRecords: function (resp) {
if (resp) {
return resp.records;
}
return resp;
} }
}, });
parseState: function (resp, queryParams, state) {
return {totalRecords: resp.totalRecords};
},
parseRecords: function (resp) {
if (resp) {
return resp.records;
}
return resp;
}
}); });
});

View File

@ -1,29 +1,17 @@
'use strict'; 'use strict';
define( define(
[ [
'app', 'marionette',
'Missing/Row', 'backgrid',
'Missing/Collection', 'Missing/Collection',
'Cells/AirDateCell',
'Series/Index/Table/SeriesStatusCell',
'Shared/Toolbar/ToolbarLayout',
'Cells/SeriesTitleCell', 'Cells/SeriesTitleCell',
'Cells/EpisodeNumberCell', 'Cells/EpisodeNumberCell',
'Cells/EpisodeTitleCell', 'Cells/EpisodeTitleCell',
'Cells/AirDateCell',
'Shared/Grid/Pager', 'Shared/Grid/Pager',
'Shared/LoadingView' 'Shared/LoadingView'
], function (App, ], function (Marionette, Backgrid, MissingCollection, SeriesTitleCell, EpisodeNumberCell, EpisodeTitleCell, AirDateCell, GridPager, LoadingView) {
MissingRow, return Marionette.Layout.extend({
MissingCollection,
AirDateCell,
SeriesStatusCell,
ToolbarLayout,
SeriesTitleCell,
EpisodeNumberCell,
EpisodeTitleCell,
Pager,
LoadingView) {
return Backbone.Marionette.Layout.extend({
template: 'Missing/MissingLayoutTemplate', template: 'Missing/MissingLayoutTemplate',
regions: { regions: {
@ -53,21 +41,20 @@ define(
cell : EpisodeTitleCell cell : EpisodeTitleCell
}, },
{ {
name : 'airDate', name : 'airDate',
label : 'Air Date', label: 'Air Date',
cell : AirDateCell cell : AirDateCell
} }
], ],
_showTable: function () { _showTable: function () {
this.missing.show(new Backgrid.Grid({ this.missing.show(new Backgrid.Grid({
row : MissingRow, columns : this.columns,
columns : this.columns, collection: this.missingCollection,
collection: this.missingCollection, className : 'table table-hover'
className : 'table table-hover' }));
}));
this.pager.show(new NzbDrone.Shared.Grid.Pager({ this.pager.show(new GridPager({
columns : this.columns, columns : this.columns,
collection: this.missingCollection collection: this.missingCollection
})); }));
@ -80,8 +67,8 @@ define(
this.missingCollection = new MissingCollection(); this.missingCollection = new MissingCollection();
this.missingCollection.fetch().done(function () { this.missingCollection.fetch().done(function () {
self._showTable(); self._showTable();
}); });
} }
}); });
}); });

View File

@ -1,12 +1,12 @@
'use strict'; 'use strict';
define(['app'], function () { define(function () {
$.fn.autoComplete = function (resource) { $.fn.autoComplete = function (resource) {
$(this).typeahead({ $(this).typeahead({
source : function (filter, callback) { source : function (filter, callback) {
$.ajax({ $.ajax({
url : NzbDrone.Constants.ApiRoot + resource, url : window.ApiRoot + resource,
dataType: 'json', dataType: 'json',
type : 'GET', type : 'GET',
data : { query: filter }, data : { query: filter },
@ -16,7 +16,7 @@ define(['app'], function () {
}); });
}, },
minLength: 3, minLength: 3,
items :20 items : 20
}); });
}; };

View File

@ -1,49 +1,55 @@
'use strict'; 'use strict';
define(['app', 'signalR'], function () { define(
[
'signalR'
], function () {
_.extend(Backbone.Collection.prototype, {BindSignalR: function (options) { _.extend(Backbone.Collection.prototype, {BindSignalR: function (options) {
if (!options || !options.url) { if (!options || !options.url) {
console.assert(this.url, 'url must be provided or collection must have url'); console.assert(this.url, 'url must be provided or collection must have url');
options = { options = {
url: this.url.replace('api', 'signalr') url: this.url.replace('api', 'signalr')
}; };
}
var self = this;
var _getStatus = function (status) {
switch (status) {
case 0:
return 'connecting';
case 1:
return 'connected';
case 2:
return 'reconnecting';
case 4:
return 'disconnected';
default:
throw 'invalid status ' + status;
} }
}; var self = this;
var _getStatus = function (status) {
switch (status) {
case 0:
return 'connecting';
case 1:
return 'connected';
case 2:
return 'reconnecting';
case 4:
return 'disconnected';
default:
throw 'invalid status ' + status;
}
};
var connection = $.connection(options.url); var connection = $.connection(options.url);
connection.stateChanged(function (change) { connection.stateChanged(function (change) {
console.debug('{0} [{1}]'.format(options.url, _getStatus(change.newState))); console.debug('{0} [{1}]'.format(options.url, _getStatus(change.newState)));
}); });
connection.received(function (model) { connection.received(function (model) {
console.debug(model); console.debug(model);
self.fetch(); self.fetch();
}); });
connection.start({ transport: ['longPolling'] }); connection.start({ transport:
[
'longPolling'
] });
return this; return this;
}}); }});
}); });

View File

@ -1,9 +1,10 @@
'use strict'; 'use strict';
define(['app', 'Quality/QualitySizeModel'], function () { define(
NzbDrone.Quality.QualitySizeCollection = Backbone.Collection.extend({ [
model: NzbDrone.Quality.QualitySizeModel, 'Quality/QualitySizeModel'
url : NzbDrone.Constants.ApiRoot + '/qualitysize' ], function (QualitySizeModel) {
return Backbone.Collection.extend({
model: QualitySizeModel,
url : window.ApiRoot + '/qualitysize'
});
}); });
return NzbDrone.Quality.QualitySizeCollection;
});

View File

@ -1,18 +1,17 @@
'use strict'; 'use strict';
define(['app'], function () { define(
NzbDrone.Quality.QualitySizeModel = Backbone.Model.extend({ [
'backbone'
], function (Backbone) {
return Backbone.Model.extend({
initialize: function () { mutators: {
this.validators = {}; thirtyMinuteSize: function () {
}, return this.get('maxSize') * 30;
},
mutators: { sixtyMinuteSize : function () {
thirtyMinuteSize: function () { return this.get('maxSize') * 60;
return this.get('maxSize') * 30; }
},
sixtyMinuteSize : function () {
return this.get('maxSize') * 60;
} }
} });
}); });
});

View File

@ -1,14 +1,18 @@
'use strict'; 'use strict';
define(['app', 'Quality/QualityProfileModel'], function () { define(
[
'backbone',
'Quality/QualityProfileModel'
], function (Backbone, QualityProfileModel) {
var qualityProfileCollection = Backbone.Collection.extend({ var QualityProfileCollection = Backbone.Collection.extend({
model: NzbDrone.Quality.QualityProfileModel, model: QualityProfileModel,
url : NzbDrone.Constants.ApiRoot + '/qualityprofiles' url : window.ApiRoot + '/qualityprofiles'
});
var profiles = new QualityProfileCollection();
profiles.fetch();
return profiles;
}); });
var profiles = new qualityProfileCollection();
profiles.fetch();
return profiles;
});

View File

@ -1,12 +1,14 @@
'use strict'; 'use strict';
define(['app', 'backbone.deepmodel'], function (App, DeepModel) { define(
NzbDrone.Quality.QualityProfileModel = DeepModel.DeepModel.extend({ [
'backbone.deepmodel'
defaults: { ], function (DeepModel) {
id : null, return DeepModel.DeepModel.extend({
name : '', defaults: {
cutoff: null id : null,
} name : '',
cutoff: null
}
});
}); });
});

View File

@ -1,22 +1,26 @@
'use strict'; 'use strict';
define(
[
'backgrid'
], function (Backgrid) {
require(['app', 'backgrid'], function () {
NzbDrone.Release.ApprovalStatusCell = Backgrid.Cell.extend({
className: 'approval-status-cell', return Backgrid.Cell.extend({
render: function () { className: 'approval-status-cell',
var rejections = this.model.get(this.column.get('name'));
var result = ''; render: function () {
var rejections = this.model.get(this.column.get('name'));
_.each(rejections, function (reason) { var result = '';
result += reason + ' ';
});
this.$el.html(result); _.each(rejections, function (reason) {
this.delegateEvents(); result += reason + ' ';
return this; });
}
this.$el.html(result);
this.delegateEvents();
return this;
}
});
}); });
});

View File

@ -1,17 +1,21 @@
'use strict'; 'use strict';
define(['app', 'Release/Model', 'backbone.pageable'], function (app, SeriesModel, PagableCollection) { define(
NzbDrone.Release.Collection = PagableCollection.extend({ [
url : NzbDrone.Constants.ApiRoot + '/release', 'Release/Model',
model: NzbDrone.Release.Model, 'backbone.pageable'
], function (ReleaseModel, PagableCollection) {
return PagableCollection.extend({
url : window.ApiRoot + '/release',
model: ReleaseModel,
mode: 'client', mode: 'client',
state: { state: {
pageSize: 2000 pageSize: 2000
}, },
fetchEpisodeReleases: function (episodeId) { fetchEpisodeReleases: function (episodeId) {
return this.fetch({ data: { episodeId: episodeId }}); return this.fetch({ data: { episodeId: episodeId }});
} }
});
}); });
});

View File

@ -1,33 +1,32 @@
'use strict'; 'use strict';
define(['app','backgrid'], function () { define(
NzbDrone.Release.DownloadReportCell = Backgrid.Cell.extend({ [
'backgrid'
], function (Backgrid) {
return Backgrid.Cell.extend({
className: 'download-report-cell', className: 'download-report-cell',
events: { events: {
'click': '_onClick' 'click': '_onClick'
}, },
_onClick: function () { _onClick: function () {
var self = this; var self = this;
this.$el.html('<i class =\'icon-spinner icon-spin\' />'); this.$el.html('<i class =\'icon-spinner icon-spin\' />');
this.model.save() this.model.save().always(function () {
.always(function () { self.$el.html('<i class =\'icon-download-alt\' />');
self.$el.html('<i class =\'icon-download-alt\' />'); });
}); },
},
render: function () { render: function () {
this.$el.html('<i class =\'icon-download-alt\' />'); this.$el.html('<i class =\'icon-download-alt\' />');
return this; return this;
} }
});
}); });
return NzbDrone.Release.DownloadReportCell;
});

View File

@ -1,17 +1,17 @@
'use strict'; 'use strict';
define([ define(
'app', [
'Release/Collection', 'marionette',
'Release/ApprovalStatusCell', 'backgrid',
'Shared/SpinnerView', 'Release/Collection',
'Shared/Toolbar/ToolbarLayout', 'Cells/IndexerCell',
'Cells/EpisodeNumberCell', 'Cells/EpisodeNumberCell',
'Cells/FileSizeCell', 'Cells/FileSizeCell',
'Cells/IndexerCell', 'Cells/QualityCell',
'Cells/QualityCell' 'Release/ApprovalStatusCell',
], 'Shared/SpinnerView'
function () { ], function (Marionette, Backgrid, ReleaseCollection, IndexerCell, EpisodeNumberCell, FileSizeCell, QualityCell, ApprovalStatusCell, SpinnerView) {
NzbDrone.Release.Layout = Backbone.Marionette.Layout.extend({ return Marionette.Layout.extend({
template: 'Release/LayoutTemplate', template: 'Release/LayoutTemplate',
regions: { regions: {
@ -19,60 +19,60 @@ define([
toolbar: '#x-toolbar' toolbar: '#x-toolbar'
}, },
columns: [ columns:
{ [
name : 'indexer', {
label : 'Indexer', name : 'indexer',
sortable: true, label : 'Indexer',
cell : NzbDrone.Cells.IndexerCell sortable: true,
}, cell : IndexerCell
},
{ {
name : 'title', name : 'title',
label : 'Title', label : 'Title',
sortable: true, sortable: true,
cell : Backgrid.StringCell cell : Backgrid.StringCell
}, },
{ {
name : 'episodeNumbers', name : 'episodeNumbers',
episodes: 'episodeNumbers', episodes: 'episodeNumbers',
label : 'season', label : 'season',
cell : NzbDrone.Cells.EpisodeNumberCell cell : EpisodeNumberCell
}, },
{ {
name : 'size', name : 'size',
label : 'Size', label : 'Size',
sortable: true, sortable: true,
cell : NzbDrone.Cells.FileSizeCell cell : FileSizeCell
}, },
{ {
name : 'quality', name : 'quality',
label : 'Quality', label : 'Quality',
sortable: true, sortable: true,
cell : NzbDrone.Cells.QualityCell cell : QualityCell
}, },
{ {
name : 'rejections', name : 'rejections',
label: 'decision', label: 'decision',
cell : NzbDrone.Release.ApprovalStatusCell cell : ApprovalStatusCell
} }
], ],
showTable: function () { showTable: function () {
if (!this.isClosed) { if (!this.isClosed) {
this.grid.show(new Backgrid.Grid( this.grid.show(new Backgrid.Grid({
{ row : Backgrid.Row,
row : Backgrid.Row, columns : this.columns,
columns : this.columns, collection: this.collection,
collection: this.collection, className : 'table table-hover'
className : 'table table-hover' }));
}));
} }
}, },
initialize: function () { initialize: function () {
this.collection = new NzbDrone.Release.Collection(); this.collection = new ReleaseCollection();
this.fetchPromise = this.collection.fetch(); this.fetchPromise = this.collection.fetch();
}, },
@ -80,12 +80,11 @@ define([
var self = this; var self = this;
this.grid.show(new NzbDrone.Shared.SpinnerView()); this.grid.show(new SpinnerView());
this.fetchPromise.done(function () { this.fetchPromise.done(function () {
self.showTable(); self.showTable();
}); });
//this.toolbar.show(new NzbDrone.Shared.Toolbar.ToolbarLayout({right: [ viewButtons], context: this}));
} }
}); });

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
define(['app'], function () { define(['backbone'], function (Backbone) {
NzbDrone.Release.Model = Backbone.Model.extend({ return Backbone.Model.extend({
/* mutators: { /* mutators: {
seasonNumber: function () { seasonNumber: function () {
return this.get('episode').seasonNumber; return this.get('episode').seasonNumber;

View File

@ -1,4 +1,4 @@
'use strict'; 'use strict';
require( require(
[ [
'app', 'app',
@ -7,9 +7,9 @@ require(
'jQuery/RouteBinder' 'jQuery/RouteBinder'
], function (App, Marionette, Controller, RouterBinder) { ], function (App, Marionette, Controller, RouterBinder) {
NzbDrone.Router = Marionette.AppRouter.extend({ var Router = Marionette.AppRouter.extend({
controller: Controller, controller: new Controller(),
appRoutes : { appRoutes : {
'' : 'series', '' : 'series',
'series' : 'series', 'series' : 'series',
@ -28,17 +28,16 @@ require(
} }
}); });
NzbDrone.addInitializer(function () { App.addInitializer(function () {
NzbDrone.Router = new NzbDrone.Router(); App.Router = new Router();
Backbone.history.start({ pushState: true }); Backbone.history.start({ pushState: true });
RouterBinder.bind(NzbDrone.Router); RouterBinder.bind(App.Router);
// NzbDrone.footerRegion.show(new FooterView());
}); });
return NzbDrone.Router; return App.Router;
}); });

View File

@ -2,10 +2,10 @@
define( define(
[ [
'app', 'app',
'Series/SeriesModel' 'marionette'
], function () { ], function (App, Marionette) {
NzbDrone.Series.Delete.DeleteSeriesView = Backbone.Marionette.ItemView.extend({ return Marionette.ItemView.extend({
template: 'Series/Delete/DeleteSeriesTemplate', template: 'Series/Delete/DeleteSeriesTemplate',
events: { events: {
@ -24,11 +24,8 @@ define(
data: { 'deleteFiles': deleteFiles }, data: { 'deleteFiles': deleteFiles },
wait: true wait: true
}).done(function () { }).done(function () {
NzbDrone.modalRegion.close(); App.modalRegion.close();
}); });
} }
}); });
return NzbDrone.Series.Delete.DeleteSeriesView;
}); });

View File

@ -1,28 +1,28 @@
'use strict'; 'use strict';
define(['app', define(
'Series/Details/SeasonLayout', [
'Series/SeasonCollection', 'marionette',
'Series/EpisodeCollection'], 'Series/Details/SeasonLayout'
function (App, SeasonLayout, SeasonCollection, EpisodeCollection) { ], function (Marionette, SeasonLayout) {
NzbDrone.Series.Details.SeasonCollectionView = Backbone.Marionette.CollectionView.extend({ return Marionette.CollectionView.extend({
itemView : SeasonLayout, itemView: SeasonLayout,
initialize: function (options) { initialize: function (options) {
if (!options.episodeCollection) { if (!options.episodeCollection) {
throw 'episodeCollection is needed'; throw 'episodeCollection is needed';
}
this.episodeCollection = options.episodeCollection;
},
itemViewOptions: function () {
return {
episodeCollection: this.episodeCollection
};
} }
this.episodeCollection = options.episodeCollection; });
},
itemViewOptions: function () {
return {
episodeCollection: this.episodeCollection
};
}
}); });
});

View File

@ -1,13 +1,17 @@
'use strict'; 
define([ 'use strict';
'app', define(
'Cells/EpisodeStatusCell', [
'Cells/EpisodeTitleCell', 'marionette',
'Cells/AirDateCell', 'backgrid',
'Cells/ToggleCell', 'Cells/ToggleCell',
'Shared/Messenger'], 'Cells/EpisodeTitleCell',
function (App, EpisodeStatusCell, EpisodeTitleCell, AirDateCell, ToggleCell, Messenger) { 'Cells/AirDateCell',
return Backbone.Marionette.Layout.extend({ 'Cells/EpisodeStatusCell',
'Commands/CommandController',
'Shared/Messenger'
], function ( Marionette, Backgrid, ToggleCell, EpisodeTitleCell, AirDateCell, EpisodeStatusCell, CommandController, Messenger) {
return Marionette.Layout.extend({
template: 'Series/Details/SeasonLayoutTemplate', template: 'Series/Details/SeasonLayoutTemplate',
ui: { ui: {
@ -22,39 +26,38 @@ define([
episodeGrid: '#x-episode-grid' episodeGrid: '#x-episode-grid'
}, },
columns: [ columns:
[
{ {
name : 'ignored', name : 'ignored',
label : '', label : '',
cell : ToggleCell, cell : ToggleCell,
trueClass : 'icon-bookmark-empty', trueClass : 'icon-bookmark-empty',
falseClass: 'icon-bookmark' falseClass: 'icon-bookmark'
}, },
{ {
name : 'episodeNumber', name : 'episodeNumber',
label: '#', label: '#',
cell : Backgrid.IntegerCell.extend({ cell : Backgrid.IntegerCell.extend({
className: 'episode-number-cell' className: 'episode-number-cell'
}) })
}, },
{
{ name : 'this',
name : 'this', label: 'Title',
label: 'Title', cell : EpisodeTitleCell
cell : EpisodeTitleCell },
}, {
{ name : 'airDate',
name : 'airDate', label: 'Air Date',
label: 'Air Date', cell : AirDateCell
cell : AirDateCell } ,
} , {
{ name : 'status',
name : 'status', label: 'Status',
label: 'Status', cell : EpisodeStatusCell
cell : EpisodeStatusCell }
} ],
],
initialize: function (options) { initialize: function (options) {
@ -66,12 +69,11 @@ define([
}, },
onShow: function () { onShow: function () {
this.episodeGrid.show(new Backgrid.Grid( this.episodeGrid.show(new Backgrid.Grid({
{ columns : this.columns,
columns : this.columns, collection: this.episodeCollection,
collection: this.episodeCollection, className : 'table table-hover season-grid'
className : 'table table-hover season-grid' }));
}));
}, },
_seasonSearch: function () { _seasonSearch: function () {
@ -82,12 +84,12 @@ define([
this.ui.seasonSearch.addClass('icon-spinner icon-spin'); this.ui.seasonSearch.addClass('icon-spinner icon-spin');
var properties = { var properties = {
seriesId: this.model.get('seriesId'), seriesId : this.model.get('seriesId'),
seasonNumber: this.model.get('seasonNumber') seasonNumber: this.model.get('seasonNumber')
}; };
var self = this; var self = this;
var commandPromise = App.Commands.Execute(command, properties); var commandPromise = CommandController.Execute(command, properties);
commandPromise.fail(function (options) { commandPromise.fail(function (options) {
if (options.readyState === 0 || options.status === 0) { if (options.readyState === 0 || options.status === 0) {

View File

@ -1,6 +1,14 @@
'use strict'; 'use strict';
define(['app', 'Series/Details/SeasonCollectionView', 'Shared/LoadingView','backstrech'], function () { define(
NzbDrone.Series.Details.SeriesDetailsLayout = Backbone.Marionette.Layout.extend({ [
'marionette',
'Series/EpisodeCollection',
'Series/SeasonCollection',
'Series/Details/SeasonCollectionView',
'Shared/LoadingView',
'backstrech'
], function (Marionette, EpisodeCollection, SeasonCollection, SeasonCollectionView, LoadingView) {
return Marionette.Layout.extend({
itemViewContainer: '.x-series-seasons', itemViewContainer: '.x-series-seasons',
template : 'Series/Details/SeriesDetailsTemplate', template : 'Series/Details/SeriesDetailsTemplate',
@ -27,19 +35,17 @@ define(['app', 'Series/Details/SeasonCollectionView', 'Shared/LoadingView','back
$('body').removeClass('backdrop'); $('body').removeClass('backdrop');
} }
this.seasons.show(new NzbDrone.Shared.LoadingView()); this.seasons.show(new LoadingView());
this.seasonCollection = new NzbDrone.Series.SeasonCollection(); this.seasonCollection = new SeasonCollection();
this.episodeCollection = new NzbDrone.Series.EpisodeCollection(); this.episodeCollection = new EpisodeCollection();
$.when(this.episodeCollection.fetch({data: { seriesId: this.model.id }}), this.seasonCollection.fetch({data: { seriesId: this.model.id }})) $.when(this.episodeCollection.fetch({data: { seriesId: this.model.id }}), this.seasonCollection.fetch({data: { seriesId: this.model.id }})).done(function () {
.done(function () { self.seasons.show(new SeasonCollectionView({
self.seasons.show(new NzbDrone.Series.Details.SeasonCollectionView({ collection : self.seasonCollection,
collection : self.seasonCollection, episodeCollection: self.episodeCollection
episodeCollection: self.episodeCollection }));
})); });
}
);
}, },
onClose: function () { onClose: function () {
@ -47,5 +53,4 @@ define(['app', 'Series/Details/SeasonCollectionView', 'Shared/LoadingView','back
$('body').removeClass('backdrop'); $('body').removeClass('backdrop');
} }
}); });
} });
);

View File

@ -1,45 +1,50 @@
'use strict'; 'use strict';
define(['app', 'Series/SeriesModel', 'Series/Delete/DeleteSeriesView', 'Quality/QualityProfileCollection'], function (app, seriesModel, deleteSeriesView, qualityProfiles) { define(
[
'App',
'marionette',
'Series/Delete/DeleteSeriesView',
'Quality/QualityProfileCollection',
'Mixins/AsModelBoundView'
], function (App, Marionette, DeleteSeriesView, QualityProfiles, AsModelBoundView) {
NzbDrone.Series.Edit.EditSeriesView = Backbone.Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template : 'Series/Edit/EditSeriesTemplate', template: 'Series/Edit/EditSeriesTemplate',
ui: { ui: {
progressbar : '.progress .bar', progressbar : '.progress .bar',
qualityProfile : '.x-quality-profile', qualityProfile : '.x-quality-profile',
backlogSettings: '.x-backlog-setting' backlogSettings: '.x-backlog-setting'
}, },
events: { events: {
'click .x-save' : 'saveSeries', 'click .x-save' : 'saveSeries',
'click .x-remove': 'removeSeries' 'click .x-remove': 'removeSeries'
}, },
initialize : function(){ initialize: function () {
this.model.set('qualityProfiles', QualityProfiles);
this.model.set('qualityProfiles',qualityProfiles); },
},
saveSeries: function () { saveSeries: function () {
//Todo: Get qualityProfile + backlog setting from UI //Todo: Get qualityProfile + backlog setting from UI
var qualityProfile = this.ui.qualityProfile.val(); var qualityProfile = this.ui.qualityProfile.val();
var qualityProfileText = this.ui.qualityProfile.children('option:selected').text(); var qualityProfileText = this.ui.qualityProfile.children('option:selected').text();
var backlogSetting = this.ui.backlogSettings.val(); var backlogSetting = this.ui.backlogSettings.val();
this.model.set({ qualityProfileId: qualityProfile, backlogSetting: backlogSetting, qualityProfileName: qualityProfileText }); this.model.set({ qualityProfileId: qualityProfile, backlogSetting: backlogSetting, qualityProfileName: qualityProfileText });
this.model.save(); this.model.save();
this.trigger('saved'); this.trigger('saved');
NzbDrone.modalRegion.closeModal(); App.modalRegion.closeModal();
}, },
removeSeries: function () { removeSeries: function () {
var view = new NzbDrone.Series.Delete.DeleteSeriesView({ model: this.model }); var view = new DeleteSeriesView({ model: this.model });
NzbDrone.modalRegion.show(view); App.modalRegion.show(view);
} }
});
return AsModelBoundView.apply(view);
}); });
});

View File

@ -1,18 +1,21 @@
'use strict'; 'use strict';
define(['app', 'Series/EpisodeModel'], function () { define(
NzbDrone.Series.EpisodeCollection = Backbone.Collection.extend({ [
url : NzbDrone.Constants.ApiRoot + '/episodes', 'backbone',
model: NzbDrone.Series.EpisodeModel, 'Series/EpisodeModel'
], function (Backbone, EpisodeModel) {
return Backbone.Collection.extend({
url : window.ApiRoot + '/episodes',
model: EpisodeModel,
bySeason: function (season) { bySeason: function (season) {
var filtered = this.filter(function (episode) { var filtered = this.filter(function (episode) {
return episode.get('seasonNumber') === season; return episode.get('seasonNumber') === season;
}); });
return new NzbDrone.Series.EpisodeCollection(filtered); var EpisodeCollection = require('Series/EpisodeCollection');
}
return new EpisodeCollection(filtered);
}
});
}); });
return NzbDrone.Series.EpisodeCollection;
});

View File

@ -1,92 +1,95 @@
'use strict'; 'use strict';
define(['app', 'Series/SeriesModel'], function () { define(
NzbDrone.Series.EpisodeModel = Backbone.Model.extend({ [
'backbone',
'Series/SeriesModel'
], function (Backbone, SeriesModel) {
return Backbone.Model.extend({
mutators: { mutators: {
paddedEpisodeNumber: function () { paddedEpisodeNumber: function () {
var test = this.get('episodeNumber'); return this.get('episodeNumber').pad(2);
return this.get('episodeNumber').pad(2); },
}, day : function () {
day : function () { return Date.create(this.get('airDate')).format('{dd}');
return Date.create(this.get('airDate')).format('{dd}'); },
}, month : function () {
month : function () { return Date.create(this.get('airDate')).format('{MON}');
return Date.create(this.get('airDate')).format('{MON}'); },
}, startTime : function () {
startTime : function () { var start = Date.create(this.get('airDate'));
var start = Date.create(this.get('airDate'));
if (start.format('{mm}') === '00') { if (start.format('{mm}') === '00') {
return start.format('{h}{tt}'); return start.format('{h}{tt}');
}
return start.format('{h}.{mm}{tt}');
},
end : function () {
if (this.has('series')) {
var start = Date.create(this.get('airDate'));
var runtime = this.get('series').runtime;
return start.addMinutes(runtime);
}
return undefined;
},
statusLevel : function () {
var episodeFileId = this.get('episodeFileId');
var currentTime = Date.create();
var start = Date.create(this.get('airDate'));
var end = Date.create(this.get('end'));
if (currentTime.isBetween(start, end)) {
return 'warning';
}
if (start.isBefore(currentTime) && episodeFileId === 0) {
return 'danger';
}
if (status === 'Ready') {
return 'success';
}
return 'primary';
},
hasAired : function () {
return Date.create(this.get('airDate')).isBefore(Date.create());
} }
return start.format('{h}.{mm}{tt}');
}, },
end : function () {
parse: function (model) {
model.series = new SeriesModel(model.series);
return model;
},
toJSON: function () {
var json = _.clone(this.attributes);
_.each(this.mutators, _.bind(function (mutator, name) {
// check if we have some getter mutations
if (_.isObject(this.mutators[name]) === true && _.isFunction(this.mutators[name].get)) {
json[name] = _.bind(this.mutators[name].get, this)();
}
else {
json[name] = _.bind(this.mutators[name], this)();
}
}, this));
if (this.has('series')) { if (this.has('series')) {
var start = Date.create(this.get('airDate')); json.series = this.get('series').toJSON();
var runtime = this.get('series').runtime;
return start.addMinutes(runtime);
} }
return json;
}, },
statusLevel : function () {
var episodeFileId = this.get('episodeFileId');
var currentTime = Date.create();
var start = Date.create(this.get('airDate'));
var end = Date.create(this.get('end'));
if (currentTime.isBetween(start, end)) { defaults: {
return 'warning'; seasonNumber: 0,
} status : 0
if (start.isBefore(currentTime) && episodeFileId === 0) {
return 'danger';
}
if (status === 'Ready') {
return 'success';
}
return 'primary';
},
hasAired : function () {
return Date.create(this.get('airDate')).isBefore(Date.create());
} }
}, });
parse: function (model) {
model.series = new NzbDrone.Series.SeriesModel(model.series);
return model;
},
toJSON: function () {
var json = _.clone(this.attributes);
_.each(this.mutators, _.bind(function (mutator, name) {
// check if we have some getter mutations
if (_.isObject(this.mutators[name]) === true && _.isFunction(this.mutators[name].get)) {
json[name] = _.bind(this.mutators[name].get, this)();
} else {
json[name] = _.bind(this.mutators[name], this)();
}
}, this));
if (this.has('series'))
{
json.series = this.get('series').toJSON();
}
return json;
},
defaults: {
seasonNumber: 0,
status : 0
}
}); });
return NzbDrone.Series.EpisodeModel;
});

View File

@ -1,8 +1,9 @@
'use strict'; 'use strict';
define(['app'], function () { define(
NzbDrone.Series.Index.EmptySeriesCollectionView = Backbone.Marionette.CompositeView.extend({ [
template: 'Series/Index/EmptySeriesIndexTemplate' 'marionette'
], function (Marionette) {
return Marionette.CompositeView.extend({
template: 'Series/Index/EmptySeriesIndexTemplate'
});
}); });
return NzbDrone.Series.Index.EmptySeriesCollectionView;
});

View File

@ -1,10 +1,11 @@
'use strict'; 'use strict';
define(['app'], function () { define(
[
'marionette'
], function (Marionette) {
NzbDrone.Series.Index.EmptyView = Backbone.Marionette.CompositeView.extend({ return Marionette.CompositeView.extend({
template: 'Series/Index/EmptyTemplate' template: 'Series/Index/EmptyTemplate'
});
}); });
return NzbDrone.Series.Index.EmptyView;
});

View File

@ -1,12 +1,14 @@
'use strict'; 'use strict';
define(['app', 'Series/Index/List/ItemView', 'Config'], function () { define(
[
'marionette',
'Series/Index/List/ItemView'
], function (Marionette, ListItemView) {
NzbDrone.Series.Index.List.CollectionView = Backbone.Marionette.CompositeView.extend({ return Marionette.CompositeView.extend({
itemView : NzbDrone.Series.Index.List.ItemView, itemView : ListItemView,
itemViewContainer : '#x-series-list', itemViewContainer: '#x-series-list',
template : 'Series/Index/List/CollectionTemplate' template : 'Series/Index/List/CollectionTemplate'
});
}); });
return NzbDrone.Series.Index.List.CollectionView;
});

View File

@ -1,36 +1,33 @@
'use strict'; 'use strict';
define([ define(
'app', [
'Quality/QualityProfileCollection', 'app',
'Series/SeriesCollection', 'marionette',
'Series/Edit/EditSeriesView', 'Series/Edit/EditSeriesView',
'Series/Delete/DeleteSeriesView', 'Series/Delete/DeleteSeriesView'
'Shared/FormatHelpers'
], function () { ], function (App, Marionette, EditSeriesView, DeleteSeriesView) {
NzbDrone.Series.Index.List.ItemView = Backbone.Marionette.ItemView.extend({ return Marionette.ItemView.extend({
template: 'Series/Index/List/ItemTemplate', template: 'Series/Index/List/ItemTemplate',
ui: { ui: {
'progressbar': '.progress .bar' 'progressbar': '.progress .bar'
}, },
events: { events: {
'click .x-edit' : 'editSeries', 'click .x-edit' : 'editSeries',
'click .x-remove': 'removeSeries' 'click .x-remove': 'removeSeries'
}, },
editSeries: function () { editSeries: function () {
var view = new NzbDrone.Series.Edit.EditSeriesView({ model: this.model}); var view = new EditSeriesView({ model: this.model});
NzbDrone.modalRegion.show(view); App.modalRegion.show(view);
}, },
removeSeries: function () { removeSeries: function () {
var view = new NzbDrone.Series.Delete.DeleteSeriesView({ model: this.model }); var view = new DeleteSeriesView({ model: this.model });
NzbDrone.modalRegion.show(view); App.modalRegion.show(view);
} }
});
}); });
return NzbDrone.Series.Index.List.ItemView;
});

View File

@ -1,12 +1,14 @@
'use strict'; 'use strict';
define(['app', 'Series/Index/Posters/ItemView', 'Config'], function () { define(
[
'marionette',
'Series/Index/Posters/ItemView'
], function (Marionette, PosterItemView) {
NzbDrone.Series.Index.Posters.CollectionView = Backbone.Marionette.CompositeView.extend({ return Marionette.CompositeView.extend({
itemView : NzbDrone.Series.Index.Posters.ItemView, itemView : PosterItemView,
itemViewContainer : '#x-series-posters', itemViewContainer: '#x-series-posters',
template : 'Series/Index/Posters/CollectionTemplate' template : 'Series/Index/Posters/CollectionTemplate'
});
}); });
return NzbDrone.Series.Index.Posters.CollectionView;
});

View File

@ -1,45 +1,44 @@
'use strict'; 'use strict';
define([ define(
'app', [
'Series/SeriesCollection', 'app',
'Series/Edit/EditSeriesView', 'marionette',
'Series/Delete/DeleteSeriesView' 'Series/Edit/EditSeriesView',
'Series/Delete/DeleteSeriesView'
], function () { ], function (App, Marionette, EditSeriesView, DeleteSeriesView) {
NzbDrone.Series.Index.Posters.ItemView = Backbone.Marionette.ItemView.extend({ return Marionette.ItemView.extend({
tagName : 'li', tagName : 'li',
template: 'Series/Index/Posters/ItemTemplate', template: 'Series/Index/Posters/ItemTemplate',
ui: { ui: {
'progressbar': '.progress .bar', 'progressbar': '.progress .bar',
'controls': '.series-controls' 'controls' : '.series-controls'
}, },
events: { events: {
'click .x-edit' : 'editSeries', 'click .x-edit' : 'editSeries',
'click .x-remove': 'removeSeries', 'click .x-remove' : 'removeSeries',
'mouseenter .x-series-poster': 'posterHoverAction', 'mouseenter .x-series-poster': 'posterHoverAction',
'mouseleave .x-series-poster': 'posterHoverAction' 'mouseleave .x-series-poster': 'posterHoverAction'
}, },
editSeries: function () { editSeries: function () {
var view = new NzbDrone.Series.Edit.EditSeriesView({ model: this.model}); var view = new EditSeriesView({ model: this.model});
NzbDrone.modalRegion.show(view); App.modalRegion.show(view);
}, },
removeSeries: function () { removeSeries: function () {
var view = new NzbDrone.Series.Delete.DeleteSeriesView({ model: this.model }); var view = new DeleteSeriesView({ model: this.model });
NzbDrone.modalRegion.show(view); App.modalRegion.show(view);
}, },
posterHoverAction: function () { posterHoverAction: function () {
this.ui.controls.slideToggle(); this.ui.controls.slideToggle();
} }
});
}); });
return NzbDrone.Series.Index.Posters.ItemView;
});

View File

@ -1,33 +1,22 @@
'use strict'; 'use strict';
define([ define(
'app', [
'Series/Index/List/CollectionView', 'marionette',
'Series/Index/Posters/CollectionView', 'Series/Index/Posters/CollectionView',
'Series/Index/EmptyView', 'Series/Index/List/CollectionView',
'Series/SeriesCollection', 'Series/Index/EmptyView',
'Cells/AirDateCell', 'Series/SeriesCollection',
'Cells/SeriesTitleCell', 'Cells/AirDateCell',
'Cells/SeriesStatusCell', 'Cells/SeriesTitleCell',
'Cells/TemplatedCell', 'Cells/TemplatedCell',
'Shared/Toolbar/ToolbarLayout', 'Series/Index/Table/SeriesStatusCell',
'Config', 'Series/Index/Table/Row',
'Shared/LoadingView' 'Shared/Toolbar/ToolbarLayout',
], 'Config',
function ( 'Shared/LoadingView'
App, ], function (Marionette, PosterCollectionView, ListCollectionView, EmptyView, SeriesCollection, AirDateCell, SeriesTitleCell, TemplatedCell, SeriesStatusCell, SeriesIndexRow,
ListCollectionView, ToolbarLayout, Config, LoadingView) {
PosterCollectionView, return Marionette.Layout.extend({
EmptyView,
SeriesCollection,
AirDateCell,
SeriesTitleCell,
SeriesStatusCell,
TemplatedCell,
ToolbarLayout,
Config,
LoadingView)
{
NzbDrone.Series.Index.SeriesIndexLayout = Backbone.Marionette.Layout.extend({
template: 'Series/Index/SeriesIndexLayoutTemplate', template: 'Series/Index/SeriesIndexLayoutTemplate',
regions: { regions: {
@ -35,87 +24,88 @@ define([
toolbar: '#x-toolbar' toolbar: '#x-toolbar'
}, },
columns: [ columns:
{ [
name : 'status', {
label: '', name : 'status',
cell : SeriesStatusCell label: '',
}, cell : SeriesStatusCell
{ },
name : 'this', {
label: 'Title', name : 'this',
cell : SeriesTitleCell label: 'Title',
}, cell : SeriesTitleCell
{ },
name : 'seasonCount', {
label: 'Seasons', name : 'seasonCount',
cell : 'integer' label: 'Seasons',
}, cell : 'integer'
{ },
name : 'quality', {
label: 'Quality', name : 'quality',
cell : 'integer' label: 'Quality',
}, cell : 'integer'
{ },
name : 'network', {
label: 'Network', name : 'network',
cell : 'string' label: 'Network',
}, cell : 'string'
{ },
name : 'nextAiring', {
label: 'Next Airing', name : 'nextAiring',
cell : AirDateCell label: 'Next Airing',
}, cell : AirDateCell
{ },
name : 'this', {
label : 'Episodes', name : 'this',
sortable: false, label : 'Episodes',
template: 'Series/EpisodeProgressTemplate', sortable: false,
cell : TemplatedCell template: 'Series/EpisodeProgressTemplate',
}, cell : TemplatedCell
{ },
name : 'this', {
label : '', name : 'this',
sortable: false, label : '',
template: 'Series/Index/Table/ControlsColumnTemplate', sortable: false,
cell : TemplatedCell template: 'Series/Index/Table/ControlsColumnTemplate',
} cell : TemplatedCell
], }
],
leftSideButtons: { leftSideButtons: {
type : 'default', type : 'default',
storeState: false, storeState: false,
items : [ items :
{ [
title: 'Add Series', {
icon : 'icon-plus', title: 'Add Series',
route: 'series/add' icon : 'icon-plus',
}, route: 'series/add'
{ },
title : 'RSS Sync', {
icon : 'icon-rss', title : 'RSS Sync',
command : 'rsssync', icon : 'icon-rss',
successMessage: 'RSS Sync Completed', command : 'rsssync',
errorMessage : 'RSS Sync Failed!' successMessage: 'RSS Sync Completed',
}, errorMessage : 'RSS Sync Failed!'
{ },
title : 'Update Library', {
icon : 'icon-refresh', title : 'Update Library',
command : 'refreshseries', icon : 'icon-refresh',
successMessage: 'Library was updated!', command : 'refreshseries',
errorMessage : 'Library update failed!' successMessage: 'Library was updated!',
} errorMessage : 'Library update failed!'
] }
]
}, },
_showTable: function () { _showTable: function () {
var view = new Backgrid.Grid( var view = new Backgrid.Grid({
{ row : SeriesIndexRow,
row : NzbDrone.Series.Index.Table.Row, columns : this.columns,
columns : this.columns, collection: this.seriesCollection,
collection: this.seriesCollection, className : 'table table-hover'
className : 'table table-hover' });
});
this._fetchCollection(view); this._fetchCollection(view);
}, },
@ -140,16 +130,15 @@ define([
if (this.seriesCollection.models.length === 0) { if (this.seriesCollection.models.length === 0) {
this.series.show(new LoadingView()); this.series.show(new LoadingView());
this.seriesCollection.fetch() this.seriesCollection.fetch().done(function () {
.done(function () { if (self.seriesCollection.models.length === 0) {
if (self.seriesCollection.models.length === 0) { self._showEmpty();
self._showEmpty(); }
} else {
else { view.collection = self.seriesCollection;
view.collection = self.seriesCollection; self.series.show(view);
self.series.show(view); }
} });
});
} }
else { else {
@ -170,35 +159,40 @@ define([
storeState : true, storeState : true,
menuKey : 'seriesViewMode', menuKey : 'seriesViewMode',
defaultAction: 'listView', defaultAction: 'listView',
items : [ items :
{ [
key : 'tableView', {
title : '', key : 'tableView',
icon : 'icon-table', title : '',
callback: this._showTable icon : 'icon-table',
}, callback: this._showTable
{ },
key : 'listView', {
title : '', key : 'listView',
icon : 'icon-list', title : '',
callback: this._showList icon : 'icon-list',
}, callback: this._showList
{ },
key : 'posterView', {
title : '', key : 'posterView',
icon : 'icon-picture', title : '',
callback: this._showPosters icon : 'icon-picture',
} callback: this._showPosters
] }
]
}; };
this.toolbar.show(new ToolbarLayout({ this.toolbar.show(new ToolbarLayout({
right : [ viewButtons], right :
left : [ this.leftSideButtons], [
viewButtons
],
left :
[
this.leftSideButtons
],
context: this context: this
})); }));
} }
}); });
return NzbDrone.Series.Index.SeriesIndexLayou;
}); });

View File

@ -1,22 +1,26 @@
'use strict'; 'use strict';
define(['app','backgrid'], function () { define(
NzbDrone.Series.Index.Table.Row = Backgrid.Row.extend({ [
events: { 'app',
'click .x-edit' : 'editSeries', 'backgrid',
'click .x-remove': 'removeSeries' 'Series/Edit/EditSeriesView',
}, 'Series/Delete/DeleteSeriesView'
], function (App, Backgrid, EditSeriesView, DeleteSeriesView) {
return Backgrid.Row.extend({
events: {
'click .x-edit' : 'editSeries',
'click .x-remove': 'removeSeries'
},
editSeries: function () { editSeries: function () {
var view = new NzbDrone.Series.Edit.EditSeriesView({ model: this.model}); var view = new EditSeriesView({ model: this.model});
NzbDrone.modalRegion.show(view); App.modalRegion.show(view);
}, },
removeSeries: function () { removeSeries: function () {
var view = new NzbDrone.Series.Delete.DeleteSeriesView({ model: this.model }); var view = new DeleteSeriesView({ model: this.model });
NzbDrone.modalRegion.show(view); App.modalRegion.show(view);
} }
});
}); });
return NzbDrone.Series.Table.Row;
});

View File

@ -0,0 +1,28 @@
'use strict';
define(
[
'backgrid'
], function (Backgrid) {
return Backgrid.Cell.extend({
className: 'series-status-cell',
render: function () {
this.$el.empty();
var monitored = this.model.get('monitored');
var status = this.model.get('status');
if (!monitored) {
this.$el.html('<i class="icon-pause grid-icon" title="Not Monitored"></i>');
}
else if (status === 'continuing') {
this.$el.html('<i class="icon-play grid-icon" title="Continuing"></i>');
}
else {
this.$el.html('<i class="icon-stop grid-icon" title="Ended"></i>');
}
return this;
}
});
});

View File

@ -1,23 +1,24 @@
'use strict'; 'use strict';
define(['app', 'Series/SeasonModel', 'backbone.pageable'], function (App, SeasonModel, PageAbleCollection) { define(
NzbDrone.Series.SeasonCollection = PageAbleCollection.extend({ [
url : NzbDrone.Constants.ApiRoot + '/season', 'Series/SeasonModel',
model: NzbDrone.Series.SeasonModel, 'backbone.pageable'
], function (SeasonModel, PageAbleCollection) {
return PageAbleCollection.extend({
url : window.ApiRoot + '/season',
model: SeasonModel,
mode: 'client', mode: 'client',
state: { state: {
sortKey : 'seasonNumber', sortKey : 'seasonNumber',
order : 1, order : 1,
pageSize: 1000000 pageSize: 1000000
}, },
queryParams: { queryParams: {
sortKey: null, sortKey: null,
order : null order : null
} }
});
}); });
return NzbDrone.Series.SeasonCollection;
});

View File

@ -1,24 +1,25 @@
'use strict'; 'use strict';
define(['app'], function () { define(
NzbDrone.Series.SeasonModel = Backbone.Model.extend({ [
'backbone'
], function (Backbone) {
return Backbone.Model.extend({
mutators: { mutators: {
seasonTitle: function () { seasonTitle: function () {
var seasonNumber = this.get('seasonNumber'); var seasonNumber = this.get('seasonNumber');
if (seasonNumber === 0) { if (seasonNumber === 0) {
return 'Specials'; return 'Specials';
}
return 'Season ' + seasonNumber;
} }
},
return 'Season ' + seasonNumber; defaults: {
seasonNumber: 0
} }
}, });
defaults: {
seasonNumber: 0
}
}); });
return NzbDrone.Series.SeasonModel;
});

View File

@ -1,18 +1,20 @@
'use strict'; 'use strict';
define(['app', 'Series/SeriesModel'], function () { define(
NzbDrone.Series.SeriesCollection = Backbone.Collection.extend({ [
url : NzbDrone.Constants.ApiRoot + '/series', 'backbone',
model: NzbDrone.Series.SeriesModel, 'Series/SeriesModel'
], function (Backbone, SeriesModel) {
return Backbone.Collection.extend({
url : window.ApiRoot + '/series',
model: SeriesModel,
comparator: function(model) { comparator: function (model) {
return model.get('title'); return model.get('title');
}, },
state: { state: {
sortKey: 'title', sortKey: 'title',
order: -1 order : -1
} }
});
}); });
return NzbDrone.Series.SeriesCollection;
});

View File

@ -1,87 +1,88 @@
'use strict'; 'use strict';
define(['app', 'Quality/QualityProfileCollection'], function (app, qualityProfiles) { define(
NzbDrone.Series.SeriesModel = Backbone.Model.extend({ [
'backbone',
'Quality/QualityProfileCollection',
], function (Backbone, QualityProfileCollection) {
return Backbone.Model.extend({
urlRoot: NzbDrone.Constants.ApiRoot + '/series', urlRoot: Constants.ApiRoot + '/series',
mutators: { mutators: {
percentOfEpisodes: function () { percentOfEpisodes: function () {
var episodeCount = this.get('episodeCount'); var episodeCount = this.get('episodeCount');
var episodeFileCount = this.get('episodeFileCount'); var episodeFileCount = this.get('episodeFileCount');
var percent = 100; var percent = 100;
if (episodeCount > 0) { if (episodeCount > 0) {
percent = episodeFileCount / episodeCount * 100; percent = episodeFileCount / episodeCount * 100;
}
return percent;
},
poster : function () {
var poster = _.find(this.get('images'), function (image) {
return image.coverType === 'poster';
});
if (poster) {
return poster.url;
}
return undefined;
},
fanArt : function () {
var poster = _.find(this.get('images'), function (image) {
return image.coverType === 'fanart';
});
if (poster) {
return poster.url;
}
return undefined;
},
traktUrl : function () {
return 'http://trakt.tv/show/' + this.get('titleSlug');
},
imdbUrl : function () {
return 'http://imdb.com/title/' + this.get('imdbId');
},
isContinuing : function () {
return this.get('status') === 'continuing';
},
shortDate : function () {
var date = this.get('nextAiring');
if (!date) {
return '';
}
return Date.create(date).short();
},
route : function () {
return '/series/details/' + this.get('titleSlug');
//return '/series/details/' + this.get('id');
},
qualityProfile: function () {
var profile = QualityProfileCollection.get(this.get('qualityProfileId'));
if (profile) {
return profile.toJSON();
}
return undefined;
} }
return percent;
},
poster : function () {
var poster = _.find(this.get('images'), function (image) {
return image.coverType === 'poster';
});
if (poster) {
return poster.url;
}
return undefined;
},
fanArt : function () {
var poster = _.find(this.get('images'), function (image) {
return image.coverType === 'fanart';
});
if (poster) {
return poster.url;
}
return undefined;
},
traktUrl : function () {
return 'http://trakt.tv/show/' + this.get('titleSlug');
},
imdbUrl : function () {
return 'http://imdb.com/title/' + this.get('imdbId');
},
isContinuing : function () {
return this.get('status') === 'continuing';
},
shortDate : function () {
var date = this.get('nextAiring');
if (!date) {
return '';
}
return Date.create(date).short();
},
route : function () {
return '/series/details/' + this.get('titleSlug');
//return '/series/details/' + this.get('id');
}, },
qualityProfile: function () { defaults: {
episodeFileCount: 0,
var profile = qualityProfiles.get(this.get('qualityProfileId')); episodeCount : 0,
isExisting : false,
if (profile) { status : 0
return profile.toJSON();
}
return undefined;
} }
}, });
defaults: {
episodeFileCount: 0,
episodeCount : 0,
isExisting : false,
status : 0
}
}); });
return NzbDrone.Series.SeriesModel;
});

View File

@ -1,6 +1,8 @@
window.ApiRoot = '/api';
var statusText = $.ajax({ var statusText = $.ajax({
type : 'GET', type : 'GET',
url : '/api/system/status', url : window.ApiRoot + '/system/status',
async: false async: false
}).responseText; }).responseText;

View File

@ -1,79 +1,81 @@
'use strict'; 'use strict';
define([ define(
'app', 'marionette', 'Mixins/AsModelBoundView', 'bootstrap' [
'marionette',
'Mixins/AsModelBoundView',
'bootstrap'
], function (Marionette, AsModelBoundView) {
], function (App, Marionette, AsModelBoundView) { var view = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/DownloadClientTemplate',
className: 'form-horizontal',
var view = Marionette.ItemView.extend({ ui: {
template : 'Settings/DownloadClient/DownloadClientTemplate', bsSwitch : '.switch',
className: 'form-horizontal', tooltip : '.help-inline i',
pathInput : '.x-path',
sabConfig : '.x-sab-config',
blackholeConfig : '.x-blackhole-config',
pneumaticConfig : '.x-pneumatic-config',
nzbGetConfig : '.x-nzbget-config',
downloadClientSelect: '.x-download-client'
},
ui: { events: {
bsSwitch : '.switch', 'change .x-download-client': 'downloadClientChanged'
tooltip : '.help-inline i', },
pathInput : '.x-path',
sabConfig : '.x-sab-config',
blackholeConfig : '.x-blackhole-config',
pneumaticConfig : '.x-pneumatic-config',
nzbGetConfig : '.x-nzbget-config',
downloadClientSelect: '.x-download-client'
},
events: { onRender: function () {
'change .x-download-client': 'downloadClientChanged' this.ui.pathInput.autoComplete('/directories');
}, this.refreshUIVisibility(this.model.get('downloadClient'));
},
onRender: function () { downloadClientChanged: function () {
this.ui.pathInput.autoComplete('/directories'); var clientId = this.ui.downloadClientSelect.val();
this.refreshUIVisibility(this.model.get('downloadClient')); this.refreshUIVisibility(clientId);
}, },
downloadClientChanged: function () { refreshUIVisibility: function (clientId) {
var clientId = this.ui.downloadClientSelect.val();
this.refreshUIVisibility(clientId);
},
refreshUIVisibility: function (clientId) { if (!clientId) {
clientId = 'sabnzbd';
}
if (!clientId) { switch (clientId.toString()) {
clientId = 'sabnzbd'; case 'sabnzbd':
this.ui.sabConfig.show();
this.ui.blackholeConfig.hide();
this.ui.pneumaticConfig.hide();
this.ui.nzbGetConfig.hide();
break;
case 'blackhole':
this.ui.sabConfig.hide();
this.ui.blackholeConfig.show();
this.ui.pneumaticConfig.hide();
this.ui.nzbGetConfig.hide();
break;
case 'pneumatic':
this.ui.sabConfig.hide();
this.ui.blackholeConfig.hide();
this.ui.pneumaticConfig.show();
this.ui.nzbGetConfig.hide();
break;
case 'nzbget':
this.ui.sabConfig.hide();
this.ui.blackholeConfig.hide();
this.ui.pneumaticConfig.hide();
this.ui.nzbGetConfig.show();
break;
default :
throw 'unknown download client id' + clientId;
}
} }
});
switch (clientId.toString()) { return AsModelBoundView.call(view);
case 'sabnzbd':
this.ui.sabConfig.show();
this.ui.blackholeConfig.hide();
this.ui.pneumaticConfig.hide();
this.ui.nzbGetConfig.hide();
break;
case 'blackhole':
this.ui.sabConfig.hide();
this.ui.blackholeConfig.show();
this.ui.pneumaticConfig.hide();
this.ui.nzbGetConfig.hide();
break;
case 'pneumatic':
this.ui.sabConfig.hide();
this.ui.blackholeConfig.hide();
this.ui.pneumaticConfig.show();
this.ui.nzbGetConfig.hide();
break;
case 'nzbget':
this.ui.sabConfig.hide();
this.ui.blackholeConfig.hide();
this.ui.pneumaticConfig.hide();
this.ui.nzbGetConfig.show();
break;
default :
throw 'unknown download client id' + clientId;
}
}
}); });
return AsModelBoundView.call(view);
});

View File

@ -1,19 +1,23 @@
'use strict'; 'use strict';
define(['app', 'backbone', 'Mixins/AsChangeTrackingModel'], function (App, Backbone, AsChangeTrackingModel) { define(
var model = Backbone.Model.extend({ [
'backbone',
'Mixins/AsChangeTrackingModel'
], function (Backbone, AsChangeTrackingModel) {
var model = Backbone.Model.extend({
url: App.Constants.ApiRoot + '/settings/host', url: window.ApiRoot + '/settings/host',
initialize: function () { initialize: function () {
this.on('change', function () { this.on('change', function () {
this.isSaved = false; this.isSaved = false;
}, this); }, this);
this.on('sync', function () { this.on('sync', function () {
this.isSaved = true; this.isSaved = true;
}, this); }, this);
} }
});
return AsChangeTrackingModel.call(model);
}); });
return AsChangeTrackingModel.call(model);
});

View File

@ -1,7 +1,10 @@
'use strict'; 'use strict';
define(['app', 'Settings/Indexers/Model'], function (App, IndexerModel) { define(
return Backbone.Collection.extend({ [
url : App.Constants.ApiRoot + '/indexer', 'Settings/Indexers/Model'
model: IndexerModel ], function (IndexerModel) {
return Backbone.Collection.extend({
url : window.ApiRoot + '/indexer',
model: IndexerModel
});
}); });
});

View File

@ -1,26 +1,26 @@
'use strict'; 'use strict';
define([ define(
'app', [
'marionette', 'marionette',
'Mixins/AsModelBoundView' 'Mixins/AsModelBoundView'
], function (App, Marionette, AsModelBoundView) { ], function (Marionette, AsModelBoundView) {
var view = Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template: 'Settings/Indexers/EditTemplate', template: 'Settings/Indexers/EditTemplate',
events: { events: {
'click .x-save': 'save' 'click .x-save': 'save'
}, },
initialize: function (options) { initialize: function (options) {
this.indexerCollection = options.indexerCollection; this.indexerCollection = options.indexerCollection;
}, },
save: function () { save: function () {
this.model.saveSettings(); this.model.saveSettings();
} }
});
return AsModelBoundView.call(view);
}); });
return AsModelBoundView.call(view);
});

View File

@ -1,10 +1,12 @@
'use strict'; 'use strict';
define(['app', define(
'Settings/SettingsModelBase'], function (App, ModelBase) { [
return ModelBase.extend({ 'Settings/SettingsModelBase'
url : App.Constants.ApiRoot + '/config/naming', ], function (ModelBase) {
successMessage: 'Naming settings saved', return ModelBase.extend({
errorMessage : 'Couldn\'t save naming settings' url : window.ApiRoot + '/config/naming',
}); successMessage: 'Naming settings saved',
errorMessage : 'Couldn\'t save naming settings'
});
}); });

View File

@ -1,18 +1,20 @@
'use strict'; 'use strict';
define(['app', define(
'marionette', [
'Settings/Naming/NamingModel', 'marionette',
'Mixins/AsModelBoundView'], function (App, Marionette, NamingModel, AsModelBoundView) { 'Settings/Naming/NamingModel',
'Mixins/AsModelBoundView'
], function (Marionette, NamingModel, AsModelBoundView) {
var view = Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template: 'Settings/Naming/NamingTemplate', template: 'Settings/Naming/NamingTemplate',
initialize: function () { initialize: function () {
this.model = new NamingModel(); this.model = new NamingModel();
this.model.fetch(); this.model.fetch();
} }
});
return AsModelBoundView.call(view);
}); });
return AsModelBoundView.call(view);
});

View File

@ -1,7 +1,10 @@
'use strict'; 'use strict';
define(['app', 'Settings/Notifications/Model'], function (App, NotificationModel) { define(
return Backbone.Collection.extend({ [
url : App.Constants.ApiRoot + '/notification', 'Settings/Notifications/Model'
model: NotificationModel ], function (NotificationModel) {
return Backbone.Collection.extend({
url : window.ApiRoot + '/notification',
model: NotificationModel
});
}); });
});

View File

@ -1,5 +1,8 @@
'use strict'; 'use strict';
define(['app', 'backbone.deepmodel'], function (App, DeepModel) { define(
return DeepModel.DeepModel.extend({ [
'backbone.deepmodel'
], function (DeepModel) {
return DeepModel.DeepModel.extend({
});
}); });
});

View File

@ -0,0 +1,11 @@
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>Delete: {{name}}</h3>
</div>
<div class="modal-body">
<p>Are you sure you want to delete '{{name}}'?</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal">cancel</button>
<button class="btn btn-danger x-confirm-delete">delete</button>
</div>

View File

@ -0,0 +1,24 @@
'use strict';
define(
[
'app',
'marionette'
], function (App, Marionette) {
return Marionette.ItemView.extend({
template: 'Quality/Profile/DeleteTemplate',
events: {
'click .x-confirm-delete': '_removeProfile'
},
_removeProfile: function () {
this.model.destroy({
wait: true
}).done(function () {
App.modalRegion.close();
});
}
});
});

View File

@ -1,35 +1,40 @@
'use strict'; 
'use strict';
define([ define(
'app', [
'marionette', 'app',
'Settings/Quality/Profile/EditQualityProfileView', 'marionette',
'Mixins/AsModelBoundView' 'Settings/Quality/Profile/EditQualityProfileView',
], function (App, Marionette, EditProfileView, AsModelBoundView) { 'Settings/Quality/Profile/DeleteView',
'Mixins/AsModelBoundView'
var view = Marionette.ItemView.extend({ ], function (App, Marionette, EditProfileView, DeleteProfileView, AsModelBoundView) {
template: 'Settings/Quality/Profile/QualityProfileTemplate',
tagName : 'tr',
ui: { var view = Marionette.ItemView.extend({
'progressbar': '.progress .bar' template: 'Settings/Quality/Profile/QualityProfileTemplate',
}, tagName : 'tr',
events: { ui: {
'click .x-edit' : 'edit', 'progressbar': '.progress .bar'
'click .x-remove': 'removeQuality' },
},
edit: function () { events: {
var view = new EditProfileView({ model: this.model}); 'click .x-edit' : 'edit',
App.modalRegion.show(view); 'click .x-remove': 'removeQuality'
}, },
removeQuality: function () { edit: function () {
var view = new NzbDrone.Series.Delete.DeleteSeriesView({ model: this.model }); var view = new EditProfileView({ model: this.model});
NzbDrone.modalRegion.show(view); App.modalRegion.show(view);
} },
removeQuality: function () {
var view = new DeleteProfileView({ model: this.model });
App.modalRegion.show(view);
}
});
return AsModelBoundView.call(view);
}); });
return AsModelBoundView.call(view);
});

View File

@ -1,13 +1,12 @@
'use strict'; 'use strict';
define([ define(
'app', [
'marionette', 'marionette',
'Quality/QualityProfileCollection', 'Quality/QualityProfileCollection',
'Settings/Quality/Profile/QualityProfileCollectionView', 'Settings/Quality/Profile/QualityProfileCollectionView',
'Quality/QualitySizeCollection', 'Quality/QualitySizeCollection',
'Settings/Quality/Size/QualitySizeCollectionView' 'Settings/Quality/Size/QualitySizeCollectionView'
], ], function (Marionette, QualityProfileCollection, QualityProfileCollectionView, QualitySizeCollection, QualitySizeCollectionView) {
function (App, Marionette, QualityProfileCollection, QualityProfileCollectionView, QualitySizeCollection, QualitySizeCollectionView) {
return Marionette.Layout.extend({ return Marionette.Layout.extend({
template: 'Settings/Quality/QualityLayoutTemplate', template: 'Settings/Quality/QualityLayoutTemplate',

View File

@ -1,21 +1,22 @@
'use strict'; 'use strict';
define([ define(
'app', [
'marionette', 'app',
'Settings/SettingsModel', 'marionette',
'Settings/General/GeneralSettingsModel', 'Settings/SettingsModel',
'Settings/Naming/NamingView', 'Settings/General/GeneralSettingsModel',
'Settings/Naming/NamingModel', 'Settings/Naming/NamingModel',
'Settings/Quality/QualityLayout', 'Settings/Naming/NamingView',
'Settings/Indexers/CollectionView', 'Settings/Quality/QualityLayout',
'Settings/Indexers/Collection', 'Settings/Indexers/CollectionView',
'Settings/DownloadClient/DownloadClientView', 'Settings/Indexers/Collection',
'Settings/Notifications/CollectionView', 'Settings/DownloadClient/DownloadClientView',
'Settings/Notifications/Collection', 'Settings/Notifications/CollectionView',
'Settings/General/GeneralView', 'Settings/Notifications/Collection',
'Settings/Misc/MiscView' 'Settings/General/GeneralView',
], 'Settings/Misc/MiscView'
function (App, Marionette, SettingsModel, GeneralSettingsModel, NamingView, NamingModel, QualityLayout, IndexerCollectionView, IndexerCollection, DownloadClientView, NotificationCollectionView, NotificationCollection, GeneralView, MiscView) { ], function (App, Marionette, SettingsModel, GeneralSettingsModel,NamingModel, NamingView, QualityLayout, IndexerCollectionView, IndexerCollection, DownloadClientView,
NotificationCollectionView, NotificationCollection, GeneralView, MiscView) {
return Marionette.Layout.extend({ return Marionette.Layout.extend({
template: 'Settings/SettingsLayoutTemplate', template: 'Settings/SettingsLayoutTemplate',
@ -56,7 +57,7 @@ define([
} }
this.ui.namingTab.tab('show'); this.ui.namingTab.tab('show');
App.Router.navigate('settings/naming'); this._navigate('settings/naming');
}, },
showQuality: function (e) { showQuality: function (e) {
@ -65,7 +66,7 @@ define([
} }
this.ui.qualityTab.tab('show'); this.ui.qualityTab.tab('show');
App.Router.navigate('settings/quality'); this._navigate('settings/quality');
}, },
showIndexers: function (e) { showIndexers: function (e) {
@ -74,7 +75,7 @@ define([
} }
this.ui.indexersTab.tab('show'); this.ui.indexersTab.tab('show');
App.Router.navigate('settings/indexers'); this._navigate('settings/indexers');
}, },
showDownloadClient: function (e) { showDownloadClient: function (e) {
@ -83,7 +84,7 @@ define([
} }
this.ui.downloadClientTab.tab('show'); this.ui.downloadClientTab.tab('show');
App.Router.navigate('settings/downloadclient'); this._navigate('settings/downloadclient');
}, },
showNotifications: function (e) { showNotifications: function (e) {
@ -92,7 +93,7 @@ define([
} }
this.ui.notificationsTab.tab('show'); this.ui.notificationsTab.tab('show');
App.Router.navigate('settings/notifications'); this._navigate('settings/notifications');
}, },
showGeneral: function (e) { showGeneral: function (e) {
@ -101,7 +102,7 @@ define([
} }
this.ui.generalTab.tab('show'); this.ui.generalTab.tab('show');
App.Router.navigate('settings/general'); this._navigate('settings/general');
}, },
showMisc: function (e) { showMisc: function (e) {
@ -110,7 +111,13 @@ define([
} }
this.ui.miscTab.tab('show'); this.ui.miscTab.tab('show');
App.Router.navigate('settings/misc'); this._navigate('settings/misc');
},
_navigate:function(route){
require(['Router'], function(){
App.Router.navigate(route);
});
}, },
initialize: function (options) { initialize: function (options) {

View File

@ -1,8 +1,8 @@
'use strict'; 'use strict';
define(['app', define(['app',
'Settings/SettingsModelBase'], function (App, SettingsModelBase) { 'Settings/SettingsModelBase'], function (App, SettingsModelBase) {
return SettingsModelBase.extend({ return SettingsModelBase.extend({
url : App.Constants.ApiRoot + '/settings', url : window.ApiRoot + '/settings',
successMessage: 'Settings saved', successMessage: 'Settings saved',
errorMessage : 'Failed to save settings' errorMessage : 'Failed to save settings'
}); });

View File

@ -1,37 +1,38 @@
'use strict'; 'use strict';
define(['app'], function () { define(
NzbDrone.Shared.FormatHelpers.FileSizeHelper = function (sourceSize) { [
var size = Number(sourceSize); 'sugar'
return size.bytes(1); ], {
}; FileSizeHelper: function (sourceSize) {
var size = Number(sourceSize);
return size.bytes(1);
},
NzbDrone.Shared.FormatHelpers.DateHelper = function (sourceDate) { DateHelper: function (sourceDate) {
if (!sourceDate) { if (!sourceDate) {
return ''; return '';
} }
var date = Date.create(sourceDate); var date = Date.create(sourceDate);
if (date.isYesterday()) { if (date.isYesterday()) {
return 'Yesterday'; return 'Yesterday';
} }
if (date.isToday()) { if (date.isToday()) {
return 'Today'; return 'Today';
} }
if (date.isTomorrow()) { if (date.isTomorrow()) {
return 'Tomorrow'; return 'Tomorrow';
} }
if (date.isAfter(Date.create('tomorrow')) && date.isBefore(Date.create().addDays(7))) { if (date.isAfter(Date.create('tomorrow')) && date.isBefore(Date.create().addDays(7))) {
return date.format('{Weekday}'); return date.format('{Weekday}');
} }
if (date.isAfter(Date.create().addDays(6))) { if (date.isAfter(Date.create().addDays(6))) {
return date.relative().replace(' from now', ''); return date.relative().replace(' from now', '');
}
return date.format('{MM}/{dd}/{yyyy}');
} }
});
return date.format('{MM}/{dd}/{yyyy}');
};
return NzbDrone.Shared.FormatHelpers;
});

Some files were not shown because too many files have changed in this diff Show More