2013-07-24 04:15:58 +03:00
|
|
|
'use strict';
|
2013-06-25 02:41:59 +03:00
|
|
|
define(
|
|
|
|
[
|
2013-10-02 08:20:30 +03:00
|
|
|
'History/HistoryModel',
|
2013-06-25 02:41:59 +03:00
|
|
|
'backbone.pageable'
|
2013-07-24 04:15:58 +03:00
|
|
|
], function (HistoryModel, PageableCollection) {
|
2013-06-25 02:41:59 +03:00
|
|
|
return PageableCollection.extend({
|
2013-09-14 10:10:19 +03:00
|
|
|
url : window.NzbDrone.ApiRoot + '/history',
|
2013-06-25 02:41:59 +03:00
|
|
|
model: HistoryModel,
|
2013-05-03 09:53:32 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
state: {
|
|
|
|
pageSize: 15,
|
|
|
|
sortKey : 'date',
|
|
|
|
order : 1
|
|
|
|
},
|
2013-05-03 09:53:32 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
queryParams: {
|
|
|
|
totalPages : null,
|
|
|
|
totalRecords: null,
|
|
|
|
pageSize : 'pageSize',
|
|
|
|
sortKey : 'sortKey',
|
|
|
|
order : 'sortDir',
|
|
|
|
directions : {
|
|
|
|
'-1': 'asc',
|
|
|
|
'1' : 'desc'
|
|
|
|
}
|
|
|
|
},
|
2013-05-03 09:53:32 +03:00
|
|
|
|
2013-10-06 21:06:39 +03:00
|
|
|
initialize: function (options) {
|
|
|
|
delete this.queryParams.episodeId;
|
|
|
|
|
|
|
|
if (options) {
|
|
|
|
if (options.episodeId) {
|
|
|
|
this.queryParams.episodeId = options.episodeId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
parseState: function (resp) {
|
2013-10-06 21:06:39 +03:00
|
|
|
return { totalRecords: resp.totalRecords };
|
2013-06-25 02:41:59 +03:00
|
|
|
},
|
2013-05-03 09:53:32 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
parseRecords: function (resp) {
|
|
|
|
if (resp) {
|
|
|
|
return resp.records;
|
|
|
|
}
|
2013-05-03 09:53:32 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
return resp;
|
|
|
|
}
|
|
|
|
});
|
2013-05-03 09:53:32 +03:00
|
|
|
});
|