2015-01-30 02:10:16 +00:00
|
|
|
'use strict';
|
2013-06-24 23:41:59 +00:00
|
|
|
define(
|
|
|
|
[
|
2014-10-12 07:29:09 +00:00
|
|
|
'Activity/History/HistoryModel',
|
2013-12-13 06:37:37 +00:00
|
|
|
'backbone.pageable',
|
2014-02-25 02:50:09 +00:00
|
|
|
'Mixins/AsFilteredCollection',
|
2014-07-04 20:07:03 +00:00
|
|
|
'Mixins/AsSortedCollection',
|
2013-12-13 06:37:37 +00:00
|
|
|
'Mixins/AsPersistedStateCollection'
|
2014-07-04 20:07:03 +00:00
|
|
|
], function (HistoryModel, PageableCollection, AsFilteredCollection, AsSortedCollection, AsPersistedStateCollection) {
|
|
|
|
var Collection = PageableCollection.extend({
|
2013-09-14 07:10:19 +00:00
|
|
|
url : window.NzbDrone.ApiRoot + '/history',
|
2013-06-24 23:41:59 +00:00
|
|
|
model: HistoryModel,
|
2013-05-03 06:53:32 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
state: {
|
|
|
|
pageSize: 15,
|
|
|
|
sortKey : 'date',
|
|
|
|
order : 1
|
|
|
|
},
|
2013-05-03 06:53:32 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
queryParams: {
|
|
|
|
totalPages : null,
|
|
|
|
totalRecords: null,
|
|
|
|
pageSize : 'pageSize',
|
|
|
|
sortKey : 'sortKey',
|
|
|
|
order : 'sortDir',
|
|
|
|
directions : {
|
|
|
|
'-1': 'asc',
|
|
|
|
'1' : 'desc'
|
|
|
|
}
|
|
|
|
},
|
2013-05-03 06:53:32 +00:00
|
|
|
|
2014-02-25 02:50:09 +00:00
|
|
|
filterModes: {
|
|
|
|
'all' : [null, null],
|
|
|
|
'grabbed' : ['eventType', '1'],
|
|
|
|
'imported' : ['eventType', '3'],
|
2014-09-16 14:14:28 +00:00
|
|
|
'failed' : ['eventType', '4'],
|
|
|
|
'deleted' : ['eventType', '5']
|
2014-02-25 02:50:09 +00:00
|
|
|
},
|
|
|
|
|
2014-07-04 20:07:03 +00:00
|
|
|
sortMappings: {
|
|
|
|
'series' : { sortKey: 'series.sortTitle' }
|
|
|
|
},
|
|
|
|
|
2013-10-06 18:06:39 +00:00
|
|
|
initialize: function (options) {
|
|
|
|
delete this.queryParams.episodeId;
|
|
|
|
|
|
|
|
if (options) {
|
|
|
|
if (options.episodeId) {
|
|
|
|
this.queryParams.episodeId = options.episodeId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
parseState: function (resp) {
|
2013-10-06 18:06:39 +00:00
|
|
|
return { totalRecords: resp.totalRecords };
|
2013-06-24 23:41:59 +00:00
|
|
|
},
|
2013-05-03 06:53:32 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
parseRecords: function (resp) {
|
|
|
|
if (resp) {
|
|
|
|
return resp.records;
|
|
|
|
}
|
2013-05-03 06:53:32 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
return resp;
|
|
|
|
}
|
|
|
|
});
|
2013-12-13 06:37:37 +00:00
|
|
|
|
2014-07-04 20:07:03 +00:00
|
|
|
Collection = AsFilteredCollection.call(Collection);
|
|
|
|
Collection = AsSortedCollection.call(Collection);
|
|
|
|
return AsPersistedStateCollection.call(Collection);
|
2013-05-03 06:53:32 +00:00
|
|
|
});
|