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:
Qstick
2017-06-20 23:06:28 -04:00
parent fafe4e93f3
commit 916db8d356
29 changed files with 834 additions and 65 deletions
+15 -15
View File
@@ -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);
}