mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-18 21:34:28 -04:00
Merge branch 'view-filtering' of https://github.com/Taloth/NzbDrone into view-filtering
This commit is contained in:
@@ -4,9 +4,10 @@ define(
|
||||
[
|
||||
'backbone.pageable',
|
||||
'System/Logs/LogsModel',
|
||||
'Mixins/AsFilteredCollection',
|
||||
'Mixins/AsPersistedStateCollection'
|
||||
],
|
||||
function (PagableCollection, LogsModel, AsPersistedStateCollection) {
|
||||
function (PagableCollection, LogsModel, AsFilteredCollection, AsPersistedStateCollection) {
|
||||
var collection = PagableCollection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/log',
|
||||
model: LogsModel,
|
||||
@@ -30,6 +31,14 @@ define(
|
||||
}
|
||||
},
|
||||
|
||||
// Filter Modes
|
||||
filterModes: {
|
||||
'all' : [null, null],
|
||||
'info' : ['level', 'Info'],
|
||||
'warn' : ['level', 'Warn'],
|
||||
'error' : ['level', 'Error']
|
||||
},
|
||||
|
||||
parseState: function (resp, queryParams, state) {
|
||||
return {totalRecords: resp.totalRecords};
|
||||
},
|
||||
@@ -43,5 +52,7 @@ define(
|
||||
}
|
||||
});
|
||||
|
||||
return AsPersistedStateCollection.call(collection);
|
||||
collection = AsFilteredCollection.apply(collection);
|
||||
|
||||
return AsPersistedStateCollection.apply(collection);
|
||||
});
|
||||
|
||||
@@ -66,7 +66,6 @@ define(
|
||||
|
||||
onRender: function () {
|
||||
this.grid.show(new LoadingView());
|
||||
this.collection.fetch();
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
@@ -88,6 +87,44 @@ define(
|
||||
},
|
||||
|
||||
_showToolbar: function () {
|
||||
var filterButtons = {
|
||||
type : 'radio',
|
||||
storeState : true,
|
||||
menuKey : 'logs.filterMode',
|
||||
defaultAction: 'all',
|
||||
items :
|
||||
[
|
||||
{
|
||||
key : 'all',
|
||||
title : '',
|
||||
tooltip : 'All',
|
||||
icon : 'icon-circle-blank',
|
||||
callback : this._setFilter
|
||||
},
|
||||
{
|
||||
key : 'info',
|
||||
title : '',
|
||||
tooltip : 'Info',
|
||||
icon : 'icon-info',
|
||||
callback : this._setFilter
|
||||
},
|
||||
{
|
||||
key : 'warn',
|
||||
title : '',
|
||||
tooltip : 'Warn',
|
||||
icon : 'icon-warn',
|
||||
callback : this._setFilter
|
||||
},
|
||||
{
|
||||
key : 'error',
|
||||
title : '',
|
||||
tooltip : 'Error',
|
||||
icon : 'icon-error',
|
||||
callback : this._setFilter
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
var rightSideButtons = {
|
||||
type : 'default',
|
||||
storeState: false,
|
||||
@@ -111,6 +148,7 @@ define(
|
||||
this.toolbar.show(new ToolbarLayout({
|
||||
right :
|
||||
[
|
||||
filterButtons,
|
||||
rightSideButtons
|
||||
],
|
||||
context: this
|
||||
@@ -125,6 +163,19 @@ define(
|
||||
buttonContext.ui.icon.spinForPromise(promise);
|
||||
}
|
||||
},
|
||||
|
||||
_setFilter: function(buttonContext) {
|
||||
var mode = buttonContext.model.get('key');
|
||||
|
||||
this.collection.setFilterMode(mode, { reset: false });
|
||||
|
||||
this.collection.state.currentPage = 1;
|
||||
var promise = this.collection.fetch({ reset: true });
|
||||
|
||||
if (buttonContext) {
|
||||
buttonContext.ui.icon.spinForPromise(promise);
|
||||
}
|
||||
},
|
||||
|
||||
_commandComplete: function (options) {
|
||||
if (options.command.get('name') === 'clearlog') {
|
||||
|
||||
Reference in New Issue
Block a user