mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-26 22:46:37 -04:00
UI Cleanup - Updated System, Tags and Wanted subtrees.
This commit is contained in:
@@ -5,43 +5,59 @@ var AsFilteredCollection = require('../../Mixins/AsFilteredCollection');
|
||||
var AsSortedCollection = require('../../Mixins/AsSortedCollection');
|
||||
var AsPersistedStateCollection = require('../../Mixins/AsPersistedStateCollection');
|
||||
|
||||
module.exports = (function(){
|
||||
var Collection = PagableCollection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/wanted/cutoff',
|
||||
model : EpisodeModel,
|
||||
tableName : 'wanted.cutoff',
|
||||
state : {
|
||||
pageSize : 15,
|
||||
sortKey : 'airDateUtc',
|
||||
order : 1
|
||||
},
|
||||
queryParams : {
|
||||
totalPages : null,
|
||||
totalRecords : null,
|
||||
pageSize : 'pageSize',
|
||||
sortKey : 'sortKey',
|
||||
order : 'sortDir',
|
||||
directions : {
|
||||
"-1" : 'asc',
|
||||
"1" : 'desc'
|
||||
}
|
||||
},
|
||||
filterModes : {
|
||||
"monitored" : ['monitored', 'true'],
|
||||
"unmonitored" : ['monitored', 'false']
|
||||
},
|
||||
sortMappings : {"series" : {sortKey : 'series.sortTitle'}},
|
||||
parseState : function(resp){
|
||||
return {totalRecords : resp.totalRecords};
|
||||
},
|
||||
parseRecords : function(resp){
|
||||
if(resp) {
|
||||
return resp.records;
|
||||
}
|
||||
return resp;
|
||||
var Collection = PagableCollection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/wanted/cutoff',
|
||||
model : EpisodeModel,
|
||||
tableName : 'wanted.cutoff',
|
||||
|
||||
state : {
|
||||
pageSize : 15,
|
||||
sortKey : 'airDateUtc',
|
||||
order : 1
|
||||
},
|
||||
|
||||
queryParams : {
|
||||
totalPages : null,
|
||||
totalRecords : null,
|
||||
pageSize : 'pageSize',
|
||||
sortKey : 'sortKey',
|
||||
order : 'sortDir',
|
||||
directions : {
|
||||
'-1' : 'asc',
|
||||
'1' : 'desc'
|
||||
}
|
||||
});
|
||||
Collection = AsFilteredCollection.call(Collection);
|
||||
Collection = AsSortedCollection.call(Collection);
|
||||
return AsPersistedStateCollection.call(Collection);
|
||||
}).call(this);
|
||||
},
|
||||
|
||||
// Filter Modes
|
||||
filterModes : {
|
||||
'monitored' : [
|
||||
'monitored',
|
||||
'true'
|
||||
],
|
||||
'unmonitored' : [
|
||||
'monitored',
|
||||
'false'
|
||||
],
|
||||
},
|
||||
|
||||
sortMappings : {
|
||||
'series' : { sortKey : 'series.sortTitle' }
|
||||
},
|
||||
|
||||
parseState : function(resp) {
|
||||
return { totalRecords : resp.totalRecords };
|
||||
},
|
||||
|
||||
parseRecords : function(resp) {
|
||||
if (resp) {
|
||||
return resp.records;
|
||||
}
|
||||
|
||||
return resp;
|
||||
}
|
||||
});
|
||||
|
||||
Collection = AsFilteredCollection.call(Collection);
|
||||
Collection = AsSortedCollection.call(Collection);
|
||||
|
||||
module.exports = AsPersistedStateCollection.call(Collection);
|
||||
@@ -16,127 +16,169 @@ require('backgrid.selectall');
|
||||
require('../../Mixins/backbone.signalr.mixin');
|
||||
|
||||
module.exports = Marionette.Layout.extend({
|
||||
template : 'Wanted/Cutoff/CutoffUnmetLayoutTemplate',
|
||||
regions : {
|
||||
template : 'Wanted/Cutoff/CutoffUnmetLayoutTemplate',
|
||||
|
||||
regions : {
|
||||
cutoff : '#x-cutoff-unmet',
|
||||
toolbar : '#x-toolbar',
|
||||
pager : '#x-pager'
|
||||
},
|
||||
ui : {searchSelectedButton : '.btn i.icon-search'},
|
||||
columns : [{
|
||||
name : '',
|
||||
cell : 'select-row',
|
||||
headerCell : 'select-all',
|
||||
sortable : false
|
||||
}, {
|
||||
name : 'series',
|
||||
label : 'Series Title',
|
||||
cell : SeriesTitleCell,
|
||||
sortValue : 'series.sortTitle'
|
||||
}, {
|
||||
name : 'this',
|
||||
label : 'Episode',
|
||||
cell : EpisodeNumberCell,
|
||||
sortable : false
|
||||
}, {
|
||||
name : 'this',
|
||||
label : 'Episode Title',
|
||||
cell : EpisodeTitleCell,
|
||||
sortable : false
|
||||
}, {
|
||||
name : 'airDateUtc',
|
||||
label : 'Air Date',
|
||||
cell : RelativeDateCell
|
||||
}, {
|
||||
name : 'status',
|
||||
label : 'Status',
|
||||
cell : EpisodeStatusCell,
|
||||
sortable : false
|
||||
}],
|
||||
initialize : function(){
|
||||
this.collection = new CutoffUnmetCollection().bindSignalR({updateOnly : true});
|
||||
|
||||
ui : {
|
||||
searchSelectedButton : '.btn i.icon-search'
|
||||
},
|
||||
|
||||
columns : [
|
||||
{
|
||||
name : '',
|
||||
cell : 'select-row',
|
||||
headerCell : 'select-all',
|
||||
sortable : false
|
||||
},
|
||||
{
|
||||
name : 'series',
|
||||
label : 'Series Title',
|
||||
cell : SeriesTitleCell,
|
||||
sortValue : 'series.sortTitle'
|
||||
},
|
||||
{
|
||||
name : 'this',
|
||||
label : 'Episode',
|
||||
cell : EpisodeNumberCell,
|
||||
sortable : false
|
||||
},
|
||||
{
|
||||
name : 'this',
|
||||
label : 'Episode Title',
|
||||
cell : EpisodeTitleCell,
|
||||
sortable : false
|
||||
},
|
||||
{
|
||||
name : 'airDateUtc',
|
||||
label : 'Air Date',
|
||||
cell : RelativeDateCell
|
||||
},
|
||||
{
|
||||
name : 'status',
|
||||
label : 'Status',
|
||||
cell : EpisodeStatusCell,
|
||||
sortable : false
|
||||
}
|
||||
],
|
||||
|
||||
initialize : function() {
|
||||
this.collection = new CutoffUnmetCollection().bindSignalR({ updateOnly : true });
|
||||
|
||||
this.listenTo(this.collection, 'sync', this._showTable);
|
||||
},
|
||||
onShow : function(){
|
||||
|
||||
onShow : function() {
|
||||
this.cutoff.show(new LoadingView());
|
||||
this._showToolbar();
|
||||
this.collection.fetch();
|
||||
},
|
||||
_showTable : function(){
|
||||
|
||||
_showTable : function() {
|
||||
this.cutoffGrid = new Backgrid.Grid({
|
||||
columns : this.columns,
|
||||
collection : this.collection,
|
||||
className : 'table table-hover'
|
||||
});
|
||||
|
||||
this.cutoff.show(this.cutoffGrid);
|
||||
|
||||
this.pager.show(new GridPager({
|
||||
columns : this.columns,
|
||||
collection : this.collection
|
||||
}));
|
||||
},
|
||||
_showToolbar : function(){
|
||||
|
||||
_showToolbar : function() {
|
||||
var leftSideButtons = {
|
||||
type : 'default',
|
||||
storeState : false,
|
||||
items : [{
|
||||
title : 'Search Selected',
|
||||
icon : 'icon-search',
|
||||
callback : this._searchSelected,
|
||||
ownerContext : this,
|
||||
className : 'x-search-selected'
|
||||
}, {
|
||||
title : 'Season Pass',
|
||||
icon : 'icon-bookmark',
|
||||
route : 'seasonpass'
|
||||
}]
|
||||
items : [
|
||||
{
|
||||
title : 'Search Selected',
|
||||
icon : 'icon-search',
|
||||
callback : this._searchSelected,
|
||||
ownerContext : this,
|
||||
className : 'x-search-selected'
|
||||
},
|
||||
{
|
||||
title : 'Season Pass',
|
||||
icon : 'icon-bookmark',
|
||||
route : 'seasonpass'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
var filterOptions = {
|
||||
type : 'radio',
|
||||
storeState : false,
|
||||
menuKey : 'wanted.filterMode',
|
||||
defaultAction : 'monitored',
|
||||
items : [{
|
||||
key : 'monitored',
|
||||
title : '',
|
||||
tooltip : 'Monitored Only',
|
||||
icon : 'icon-nd-monitored',
|
||||
callback : this._setFilter
|
||||
}, {
|
||||
key : 'unmonitored',
|
||||
title : '',
|
||||
tooltip : 'Unmonitored Only',
|
||||
icon : 'icon-nd-unmonitored',
|
||||
callback : this._setFilter
|
||||
}]
|
||||
items : [
|
||||
{
|
||||
key : 'monitored',
|
||||
title : '',
|
||||
tooltip : 'Monitored Only',
|
||||
icon : 'icon-nd-monitored',
|
||||
callback : this._setFilter
|
||||
},
|
||||
{
|
||||
key : 'unmonitored',
|
||||
title : '',
|
||||
tooltip : 'Unmonitored Only',
|
||||
icon : 'icon-nd-unmonitored',
|
||||
callback : this._setFilter
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
this.toolbar.show(new ToolbarLayout({
|
||||
left : [leftSideButtons],
|
||||
right : [filterOptions],
|
||||
left : [
|
||||
leftSideButtons
|
||||
],
|
||||
right : [
|
||||
filterOptions
|
||||
],
|
||||
context : this
|
||||
}));
|
||||
|
||||
CommandController.bindToCommand({
|
||||
element : this.$('.x-search-selected'),
|
||||
command : {name : 'episodeSearch'}
|
||||
command : {
|
||||
name : 'episodeSearch'
|
||||
}
|
||||
});
|
||||
},
|
||||
_setFilter : function(buttonContext){
|
||||
|
||||
_setFilter : function(buttonContext) {
|
||||
var mode = buttonContext.model.get('key');
|
||||
|
||||
this.collection.state.currentPage = 1;
|
||||
var promise = this.collection.setFilterMode(mode);
|
||||
if(buttonContext) {
|
||||
|
||||
if (buttonContext) {
|
||||
buttonContext.ui.icon.spinForPromise(promise);
|
||||
}
|
||||
},
|
||||
_searchSelected : function(){
|
||||
|
||||
_searchSelected : function() {
|
||||
var selected = this.cutoffGrid.getSelectedModels();
|
||||
if(selected.length === 0) {
|
||||
|
||||
if (selected.length === 0) {
|
||||
Messenger.show({
|
||||
type : 'error',
|
||||
message : 'No episodes selected'
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var ids = _.pluck(selected, 'id');
|
||||
|
||||
CommandController.Execute('episodeSearch', {
|
||||
name : 'episodeSearch',
|
||||
episodeIds : ids
|
||||
|
||||
Reference in New Issue
Block a user