mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-24 22:35:39 -04:00
Add Track and TrackFile API Resources
Add Track and TrackFile API Resources, Add Rename Track Resource, Add GetFilesByAlbum function to Media File Service, Add Links to Artist Detail Page, Misc other UI work
This commit is contained in:
@@ -4,11 +4,11 @@ var TrackModel = require('./TrackModel');
|
||||
require('./TrackCollection');
|
||||
|
||||
module.exports = PageableCollection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/episode',
|
||||
url : window.NzbDrone.ApiRoot + '/track',
|
||||
model : TrackModel,
|
||||
|
||||
state : {
|
||||
sortKey : 'episodeNumber',
|
||||
sortKey : 'trackNumber',
|
||||
order : 1,
|
||||
pageSize : 100000
|
||||
},
|
||||
@@ -18,28 +18,28 @@ module.exports = PageableCollection.extend({
|
||||
originalFetch : Backbone.Collection.prototype.fetch,
|
||||
|
||||
initialize : function(options) {
|
||||
this.seriesId = options.seriesId;
|
||||
this.artistId = options.artistId;
|
||||
},
|
||||
|
||||
bySeason : function(season) {
|
||||
var filtered = this.filter(function(episode) {
|
||||
return episode.get('seasonNumber') === season;
|
||||
bySeason : function(album) {
|
||||
var filtered = this.filter(function(track) {
|
||||
return track.get('albumId') === album;
|
||||
});
|
||||
|
||||
var EpisodeCollection = require('./TrackCollection');
|
||||
var TrackCollection = require('./TrackCollection');
|
||||
|
||||
return new EpisodeCollection(filtered);
|
||||
return new TrackCollection(filtered);
|
||||
},
|
||||
|
||||
comparator : function(model1, model2) {
|
||||
var episode1 = model1.get('episodeNumber');
|
||||
var episode2 = model2.get('episodeNumber');
|
||||
var track1 = model1.get('trackNumber');
|
||||
var track2 = model2.get('trackNumber');
|
||||
|
||||
if (episode1 < episode2) {
|
||||
if (track1 < track2) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (episode1 > episode2) {
|
||||
if (track1 > track2) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -47,15 +47,15 @@ module.exports = PageableCollection.extend({
|
||||
},
|
||||
|
||||
fetch : function(options) {
|
||||
if (!this.seriesId) {
|
||||
throw 'seriesId is required';
|
||||
if (!this.artistId) {
|
||||
throw 'artistId is required';
|
||||
}
|
||||
|
||||
if (!options) {
|
||||
options = {};
|
||||
}
|
||||
|
||||
options.data = { seriesId : this.seriesId };
|
||||
options.data = { artistId : this.artistId };
|
||||
|
||||
return this.originalFetch.call(this, options);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user