mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-22 22:14:44 -04:00
Activity instead of History
New: Renamed history to activity New: Queue is default tab of activity
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'handlebars'
|
||||
], function (Handlebars) {
|
||||
|
||||
Handlebars.registerHelper('historyAge', function () {
|
||||
|
||||
var unit = 'days';
|
||||
var age = this.age;
|
||||
|
||||
if (age < 2) {
|
||||
unit = 'hours';
|
||||
age = parseFloat(this.ageHours).toFixed(1);
|
||||
}
|
||||
|
||||
return new Handlebars.SafeString('<dt>Age (when grabbed):</dt><dd>{0} {1}</dd>'.format(age, unit));
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'jquery',
|
||||
'vent',
|
||||
'marionette',
|
||||
'Activity/History/Details/HistoryDetailsView'
|
||||
], function ($, vent, Marionette, HistoryDetailsView) {
|
||||
|
||||
return Marionette.Layout.extend({
|
||||
template: 'Activity/History/Details/HistoryDetailsLayoutTemplate',
|
||||
|
||||
regions: {
|
||||
bodyRegion: '.modal-body'
|
||||
},
|
||||
|
||||
events: {
|
||||
'click .x-mark-as-failed': '_markAsFailed'
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
this.bodyRegion.show(new HistoryDetailsView({ model: this.model }));
|
||||
},
|
||||
|
||||
_markAsFailed: function () {
|
||||
var url = window.NzbDrone.ApiRoot + '/history/failed';
|
||||
var data = {
|
||||
id: this.model.get('id')
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: data
|
||||
});
|
||||
|
||||
vent.trigger(vent.Commands.CloseModalCommand);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,22 @@
|
||||
<div class="modal-content">
|
||||
<div class="history-detail-modal">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
|
||||
<h3>
|
||||
{{#if_eq eventType compare="grabbed"}}Grabbed{{/if_eq}}
|
||||
{{#if_eq eventType compare="downloadFailed"}}Download Failed{{/if_eq}}
|
||||
{{#if_eq eventType compare="downloadFolderImported"}}Episode Imported{{/if_eq}}
|
||||
{{#if_eq eventType compare="episodeFileDeleted"}}Episode File Deleted{{/if_eq}}
|
||||
</h3>
|
||||
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
{{#if_eq eventType compare="grabbed"}}<button class="btn btn-danger x-mark-as-failed">mark as failed</button>{{/if_eq}}
|
||||
<button class="btn" data-dismiss="modal">close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,11 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'Activity/History/Details/HistoryDetailsAge'
|
||||
], function (Marionette) {
|
||||
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'Activity/History/Details/HistoryDetailsViewTemplate'
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,98 @@
|
||||
{{#if_eq eventType compare="grabbed"}}
|
||||
<dl class="dl-horizontal">
|
||||
|
||||
<dt>Name:</dt>
|
||||
<dd>{{sourceTitle}}</dd>
|
||||
|
||||
{{#with data}}
|
||||
{{#if indexer}}
|
||||
<dt>Indexer:</dt>
|
||||
<dd>{{indexer}}</dd>
|
||||
{{/if}}
|
||||
|
||||
{{#if releaseGroup}}
|
||||
<dt>Release Group:</dt>
|
||||
<dd>{{releaseGroup}}</dd>
|
||||
{{/if}}
|
||||
|
||||
{{#if nzbInfoUrl}}
|
||||
<dt>Info:</dt>
|
||||
<dd><a href="{{nzbInfoUrl}}">{{nzbInfoUrl}}</a></dd>
|
||||
{{/if}}
|
||||
|
||||
{{#if downloadClient}}
|
||||
<dt>Download Client:</dt>
|
||||
<dd>{{downloadClient}}</dd>
|
||||
{{/if}}
|
||||
|
||||
{{#if downloadClientId}}
|
||||
<dt>Download Client ID:</dt>
|
||||
<dd>{{downloadClientId}}</dd>
|
||||
{{/if}}
|
||||
|
||||
{{#if age}}
|
||||
{{historyAge}}
|
||||
{{/if}}
|
||||
{{/with}}
|
||||
</dl>
|
||||
{{/if_eq}}
|
||||
|
||||
{{#if_eq eventType compare="downloadFailed"}}
|
||||
<dl class="dl-horizontal">
|
||||
|
||||
<dt>Name:</dt>
|
||||
<dd>{{sourceTitle}}</dd>
|
||||
|
||||
{{#with data}}
|
||||
<dt>Message:</dt>
|
||||
<dd>{{message}}</dd>
|
||||
{{/with}}
|
||||
</dl>
|
||||
{{/if_eq}}
|
||||
|
||||
{{#if_eq eventType compare="downloadFolderImported"}}
|
||||
<dl class="dl-horizontal">
|
||||
|
||||
{{#if sourceTitle}}
|
||||
<dt>Name:</dt>
|
||||
<dd>{{sourceTitle}}</dd>
|
||||
{{/if}}
|
||||
|
||||
{{#with data}}
|
||||
{{#if droppedPath}}
|
||||
<dt>Source:</dt>
|
||||
<dd>{{droppedPath}}</dd>
|
||||
{{/if}}
|
||||
|
||||
{{#if importedPath}}
|
||||
<dt>Imported To:</dt>
|
||||
<dd>{{importedPath}}</dd>
|
||||
{{/if}}
|
||||
{{/with}}
|
||||
</dl>
|
||||
{{/if_eq}}
|
||||
|
||||
{{#if_eq eventType compare="episodeFileDeleted"}}
|
||||
<dl class="dl-horizontal">
|
||||
|
||||
<dt>Path:</dt>
|
||||
<dd>{{sourceTitle}}</dd>
|
||||
|
||||
{{#with data}}
|
||||
<dt>Reason:</dt>
|
||||
<dd>
|
||||
{{#if_eq reason compare="Manual"}}
|
||||
File was deleted by via UI
|
||||
{{/if_eq}}
|
||||
|
||||
{{#if_eq reason compare="MissingFromDisk"}}
|
||||
NzbDrone was unable to find the file on disk so it was removed
|
||||
{{/if_eq}}
|
||||
|
||||
{{#if_eq reason compare="Upgrade"}}
|
||||
File was deleted to import an upgrade
|
||||
{{/if_eq}}
|
||||
</dd>
|
||||
{{/with}}
|
||||
</dl>
|
||||
{{/if_eq}}
|
||||
@@ -0,0 +1,70 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'Activity/History/HistoryModel',
|
||||
'backbone.pageable',
|
||||
'Mixins/AsFilteredCollection',
|
||||
'Mixins/AsSortedCollection',
|
||||
'Mixins/AsPersistedStateCollection'
|
||||
], function (HistoryModel, PageableCollection, AsFilteredCollection, AsSortedCollection, AsPersistedStateCollection) {
|
||||
var Collection = PageableCollection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/history',
|
||||
model: HistoryModel,
|
||||
|
||||
state: {
|
||||
pageSize: 15,
|
||||
sortKey : 'date',
|
||||
order : 1
|
||||
},
|
||||
|
||||
queryParams: {
|
||||
totalPages : null,
|
||||
totalRecords: null,
|
||||
pageSize : 'pageSize',
|
||||
sortKey : 'sortKey',
|
||||
order : 'sortDir',
|
||||
directions : {
|
||||
'-1': 'asc',
|
||||
'1' : 'desc'
|
||||
}
|
||||
},
|
||||
|
||||
filterModes: {
|
||||
'all' : [null, null],
|
||||
'grabbed' : ['eventType', '1'],
|
||||
'imported' : ['eventType', '3'],
|
||||
'failed' : ['eventType', '4'],
|
||||
'deleted' : ['eventType', '5']
|
||||
},
|
||||
|
||||
sortMappings: {
|
||||
'series' : { sortKey: 'series.sortTitle' }
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
delete this.queryParams.episodeId;
|
||||
|
||||
if (options) {
|
||||
if (options.episodeId) {
|
||||
this.queryParams.episodeId = options.episodeId;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
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);
|
||||
return AsPersistedStateCollection.call(Collection);
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
define(
|
||||
[
|
||||
'vent',
|
||||
'Cells/NzbDroneCell'
|
||||
], function (vent, NzbDroneCell) {
|
||||
return NzbDroneCell.extend({
|
||||
|
||||
className: 'history-details-cell',
|
||||
|
||||
events: {
|
||||
'click': '_showDetails'
|
||||
},
|
||||
|
||||
render: function () {
|
||||
this.$el.empty();
|
||||
this.$el.html('<i class="icon-info-sign"></i>');
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
_showDetails: function () {
|
||||
vent.trigger(vent.Commands.ShowHistoryDetails, { model: this.model });
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,173 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'backgrid',
|
||||
'Activity/History/HistoryCollection',
|
||||
'Cells/EventTypeCell',
|
||||
'Cells/SeriesTitleCell',
|
||||
'Cells/EpisodeNumberCell',
|
||||
'Cells/EpisodeTitleCell',
|
||||
'Activity/History/HistoryQualityCell',
|
||||
'Cells/RelativeDateCell',
|
||||
'Activity/History/HistoryDetailsCell',
|
||||
'Shared/Grid/Pager',
|
||||
'Shared/Toolbar/ToolbarLayout',
|
||||
'Shared/LoadingView'
|
||||
], function (Marionette,
|
||||
Backgrid,
|
||||
HistoryCollection,
|
||||
EventTypeCell,
|
||||
SeriesTitleCell,
|
||||
EpisodeNumberCell,
|
||||
EpisodeTitleCell,
|
||||
HistoryQualityCell,
|
||||
RelativeDateCell,
|
||||
HistoryDetailsCell,
|
||||
GridPager,
|
||||
ToolbarLayout,
|
||||
LoadingView) {
|
||||
return Marionette.Layout.extend({
|
||||
template: 'Activity/History/HistoryLayoutTemplate',
|
||||
|
||||
regions: {
|
||||
history: '#x-history',
|
||||
toolbar: '#x-history-toolbar',
|
||||
pager : '#x-history-pager'
|
||||
},
|
||||
|
||||
columns:
|
||||
[
|
||||
{
|
||||
name : 'eventType',
|
||||
label : '',
|
||||
cell : EventTypeCell,
|
||||
cellValue : 'this'
|
||||
},
|
||||
{
|
||||
name : 'series',
|
||||
label : 'Series',
|
||||
cell : SeriesTitleCell
|
||||
},
|
||||
{
|
||||
name : 'episode',
|
||||
label : 'Episode',
|
||||
cell : EpisodeNumberCell,
|
||||
sortable : false
|
||||
},
|
||||
{
|
||||
name : 'episode',
|
||||
label : 'Episode Title',
|
||||
cell : EpisodeTitleCell,
|
||||
sortable : false
|
||||
},
|
||||
{
|
||||
name : 'this',
|
||||
label : 'Quality',
|
||||
cell : HistoryQualityCell,
|
||||
sortable : false
|
||||
},
|
||||
{
|
||||
name : 'date',
|
||||
label : 'Date',
|
||||
cell : RelativeDateCell
|
||||
},
|
||||
{
|
||||
name : 'this',
|
||||
label : '',
|
||||
cell : HistoryDetailsCell,
|
||||
sortable : false
|
||||
}
|
||||
],
|
||||
|
||||
initialize: function () {
|
||||
this.collection = new HistoryCollection({ tableName: 'history' });
|
||||
this.listenTo(this.collection, 'sync', this._showTable);
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
this.history.show(new LoadingView());
|
||||
this._showToolbar();
|
||||
},
|
||||
|
||||
_showTable: function (collection) {
|
||||
|
||||
this.history.show(new Backgrid.Grid({
|
||||
columns : this.columns,
|
||||
collection: collection,
|
||||
className : 'table table-hover'
|
||||
}));
|
||||
|
||||
this.pager.show(new GridPager({
|
||||
columns : this.columns,
|
||||
collection: collection
|
||||
}));
|
||||
},
|
||||
|
||||
_showToolbar: function () {
|
||||
var filterOptions = {
|
||||
type : 'radio',
|
||||
storeState : true,
|
||||
menuKey : 'history.filterMode',
|
||||
defaultAction : 'all',
|
||||
items :
|
||||
[
|
||||
{
|
||||
key : 'all',
|
||||
title : '',
|
||||
tooltip : 'All',
|
||||
icon : 'icon-circle-blank',
|
||||
callback : this._setFilter
|
||||
},
|
||||
{
|
||||
key : 'grabbed',
|
||||
title : '',
|
||||
tooltip : 'Grabbed',
|
||||
icon : 'icon-nd-downloading',
|
||||
callback : this._setFilter
|
||||
},
|
||||
{
|
||||
key : 'imported',
|
||||
title : '',
|
||||
tooltip : 'Imported',
|
||||
icon : 'icon-nd-imported',
|
||||
callback : this._setFilter
|
||||
},
|
||||
{
|
||||
key : 'failed',
|
||||
title : '',
|
||||
tooltip : 'Failed',
|
||||
icon : 'icon-nd-download-failed',
|
||||
callback : this._setFilter
|
||||
},
|
||||
{
|
||||
key : 'deleted',
|
||||
title : '',
|
||||
tooltip : 'Deleted',
|
||||
icon : 'icon-nd-deleted',
|
||||
callback : this._setFilter
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
this.toolbar.show(new ToolbarLayout({
|
||||
right :
|
||||
[
|
||||
filterOptions
|
||||
],
|
||||
context: this
|
||||
}));
|
||||
},
|
||||
|
||||
_setFilter: function(buttonContext) {
|
||||
var mode = buttonContext.model.get('key');
|
||||
|
||||
this.collection.state.currentPage = 1;
|
||||
var promise = this.collection.setFilterMode(mode);
|
||||
|
||||
if (buttonContext) {
|
||||
buttonContext.ui.icon.spinForPromise(promise);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
<div id="x-history-toolbar"/>
|
||||
<div class="row">
|
||||
<div class="col-md-12 table-responsive">
|
||||
<div id="x-history"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div id="x-history-pager"/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,16 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone',
|
||||
'Series/SeriesModel',
|
||||
'Series/EpisodeModel'
|
||||
], function (Backbone, SeriesModel, EpisodeModel) {
|
||||
return Backbone.Model.extend({
|
||||
parse: function (model) {
|
||||
model.series = new SeriesModel(model.series);
|
||||
model.episode = new EpisodeModel(model.episode);
|
||||
model.episode.set('series', model.series);
|
||||
return model;
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,36 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'Cells/NzbDroneCell'
|
||||
], function (NzbDroneCell) {
|
||||
return NzbDroneCell.extend({
|
||||
|
||||
className: 'history-quality-cell',
|
||||
|
||||
render: function () {
|
||||
|
||||
var title = '';
|
||||
var quality = this.model.get('quality');
|
||||
var revision = quality.revision;
|
||||
|
||||
if (revision.real && revision.real > 0) {
|
||||
title += ' REAL';
|
||||
}
|
||||
|
||||
if (revision.version && revision.version > 1) {
|
||||
title += ' PROPER';
|
||||
}
|
||||
|
||||
title = title.trim();
|
||||
|
||||
if (this.model.get('qualityCutoffNotMet')) {
|
||||
this.$el.html('<span class="badge badge-inverse" title="{0}">{1}</span>'.format(title, quality.quality.name));
|
||||
}
|
||||
else {
|
||||
this.$el.html('<span class="badge" title="{0}">{1}</span>'.format(title, quality.quality.name));
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user