mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-17 21:25:39 -04:00
rjs -> webpack
This commit is contained in:
@@ -1,39 +1,26 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backgrid',
|
||||
'marionette',
|
||||
'bootstrap'
|
||||
], function (Backgrid, Marionette) {
|
||||
var Backgrid = require('backgrid');
|
||||
var Marionette = require('marionette');
|
||||
require('bootstrap');
|
||||
|
||||
return Backgrid.Cell.extend({
|
||||
|
||||
className: 'approval-status-cell',
|
||||
template : 'Cells/ApprovalStatusCellTemplate',
|
||||
|
||||
render: function () {
|
||||
|
||||
var rejections = this.model.get(this.column.get('name'));
|
||||
|
||||
if (rejections.length === 0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
this.templateFunction = Marionette.TemplateCache.get(this.template);
|
||||
|
||||
var html = this.templateFunction(rejections);
|
||||
this.$el.html('<i class="icon-exclamation-sign"/>');
|
||||
|
||||
this.$el.popover({
|
||||
content : html,
|
||||
html : true,
|
||||
trigger : 'hover',
|
||||
title : 'Release Rejected',
|
||||
placement: 'left',
|
||||
container: this.$el
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
module.exports = Backgrid.Cell.extend({
|
||||
className : 'approval-status-cell',
|
||||
template : 'Cells/ApprovalStatusCellTemplate',
|
||||
render : function(){
|
||||
var rejections = this.model.get(this.column.get('name'));
|
||||
if(rejections.length === 0) {
|
||||
return this;
|
||||
}
|
||||
this.templateFunction = Marionette.TemplateCache.get(this.template);
|
||||
var html = this.templateFunction(rejections);
|
||||
this.$el.html('<i class="icon-exclamation-sign"/>');
|
||||
this.$el.popover({
|
||||
content : html,
|
||||
html : true,
|
||||
trigger : 'hover',
|
||||
title : 'Release Rejected',
|
||||
placement : 'left',
|
||||
container : this.$el
|
||||
});
|
||||
});
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -1,33 +1,20 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'vent',
|
||||
'backgrid'
|
||||
], function (vent, Backgrid) {
|
||||
return Backgrid.Cell.extend({
|
||||
var vent = require('../vent');
|
||||
var Backgrid = require('backgrid');
|
||||
|
||||
className : 'delete-episode-file-cell',
|
||||
|
||||
events: {
|
||||
'click': '_onClick'
|
||||
},
|
||||
|
||||
render: function () {
|
||||
this.$el.empty();
|
||||
this.$el.html('<i class="icon-nd-delete"></i>');
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
_onClick: function () {
|
||||
var self = this;
|
||||
|
||||
if (window.confirm('Are you sure you want to delete \'{0}\' from disk?'.format(this.model.get('path')))) {
|
||||
this.model.destroy()
|
||||
.done(function () {
|
||||
vent.trigger(vent.Events.EpisodeFileDeleted, { episodeFile: self.model });
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = Backgrid.Cell.extend({
|
||||
className : 'delete-episode-file-cell',
|
||||
events : {"click" : '_onClick'},
|
||||
render : function(){
|
||||
this.$el.empty();
|
||||
this.$el.html('<i class="icon-nd-delete"></i>');
|
||||
return this;
|
||||
},
|
||||
_onClick : function(){
|
||||
var self = this;
|
||||
if(window.confirm('Are you sure you want to delete \'{0}\' from disk?'.format(this.model.get('path')))) {
|
||||
this.model.destroy().done(function(){
|
||||
vent.trigger(vent.Events.EpisodeFileDeleted, {episodeFile : self.model});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,78 +1,59 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backgrid',
|
||||
'marionette',
|
||||
'underscore',
|
||||
'Settings/Profile/ProfileSchemaCollection'
|
||||
], function (Backgrid, Marionette, _, ProfileSchemaCollection) {
|
||||
return Backgrid.CellEditor.extend({
|
||||
var Backgrid = require('backgrid');
|
||||
var Marionette = require('marionette');
|
||||
var _ = require('underscore');
|
||||
var ProfileSchemaCollection = require('../../Settings/Profile/ProfileSchemaCollection');
|
||||
|
||||
className: 'quality-cell-editor',
|
||||
template : 'Cells/Edit/QualityCellEditorTemplate',
|
||||
tagName : 'select',
|
||||
|
||||
events: {
|
||||
'change' : 'save',
|
||||
'blur' : 'close',
|
||||
'keydown': 'close'
|
||||
},
|
||||
|
||||
render: function () {
|
||||
var self = this;
|
||||
|
||||
var profileSchemaCollection = new ProfileSchemaCollection();
|
||||
var promise = profileSchemaCollection.fetch();
|
||||
|
||||
promise.done(function () {
|
||||
var templateName = self.template;
|
||||
self.schema = profileSchemaCollection.first();
|
||||
|
||||
var selected = _.find(self.schema.get('items'), function (model) {
|
||||
return model.quality.id === self.model.get(self.column.get('name')).quality.id;
|
||||
});
|
||||
|
||||
if (selected) {
|
||||
selected.quality.selected = true;
|
||||
}
|
||||
|
||||
self.templateFunction = Marionette.TemplateCache.get(templateName);
|
||||
var data = self.schema.toJSON();
|
||||
var html = self.templateFunction(data);
|
||||
self.$el.html(html);
|
||||
});
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
save: function (e) {
|
||||
var model = this.model;
|
||||
var column = this.column;
|
||||
var selected = parseInt(this.$el.val(), 10);
|
||||
|
||||
var profileItem = _.find(this.schema.get('items'), function(model) {
|
||||
return model.quality.id === selected;
|
||||
});
|
||||
|
||||
var newQuality = {
|
||||
quality : profileItem.quality,
|
||||
revision : {
|
||||
version : 1,
|
||||
real : 0
|
||||
}
|
||||
};
|
||||
|
||||
model.set(column.get('name'), newQuality);
|
||||
model.save();
|
||||
model.trigger('backgrid:edited', model, column, new Backgrid.Command(e));
|
||||
},
|
||||
|
||||
close: function (e) {
|
||||
var model = this.model;
|
||||
var column = this.column;
|
||||
var command = new Backgrid.Command(e);
|
||||
|
||||
model.trigger('backgrid:edited', model, column, command);
|
||||
module.exports = Backgrid.CellEditor.extend({
|
||||
className : 'quality-cell-editor',
|
||||
template : 'Cells/Edit/QualityCellEditorTemplate',
|
||||
tagName : 'select',
|
||||
events : {
|
||||
"change" : 'save',
|
||||
"blur" : 'close',
|
||||
"keydown" : 'close'
|
||||
},
|
||||
render : function(){
|
||||
var self = this;
|
||||
var profileSchemaCollection = new ProfileSchemaCollection();
|
||||
var promise = profileSchemaCollection.fetch();
|
||||
promise.done(function(){
|
||||
var templateName = self.template;
|
||||
self.schema = profileSchemaCollection.first();
|
||||
var selected = _.find(self.schema.get('items'), function(model){
|
||||
return model.quality.id === self.model.get(self.column.get('name')).quality.id;
|
||||
});
|
||||
if(selected) {
|
||||
selected.quality.selected = true;
|
||||
}
|
||||
self.templateFunction = Marionette.TemplateCache.get(templateName);
|
||||
var data = self.schema.toJSON();
|
||||
var html = self.templateFunction(data);
|
||||
self.$el.html(html);
|
||||
});
|
||||
});
|
||||
return this;
|
||||
},
|
||||
save : function(e){
|
||||
var model = this.model;
|
||||
var column = this.column;
|
||||
var selected = parseInt(this.$el.val(), 10);
|
||||
var profileItem = _.find(this.schema.get('items'), function(model){
|
||||
return model.quality.id === selected;
|
||||
});
|
||||
var newQuality = {
|
||||
quality : profileItem.quality,
|
||||
revision : {
|
||||
version : 1,
|
||||
real : 0
|
||||
}
|
||||
};
|
||||
model.set(column.get('name'), newQuality);
|
||||
model.save();
|
||||
model.trigger('backgrid:edited', model, column, new Backgrid.Command(e));
|
||||
},
|
||||
close : function(e){
|
||||
var model = this.model;
|
||||
var column = this.column;
|
||||
var command = new Backgrid.Command(e);
|
||||
model.trigger('backgrid:edited', model, column, command);
|
||||
}
|
||||
});
|
||||
@@ -1,49 +1,37 @@
|
||||
'use strict';
|
||||
var vent = require('../vent');
|
||||
var NzbDroneCell = require('./NzbDroneCell');
|
||||
var CommandController = require('../Commands/CommandController');
|
||||
|
||||
define(
|
||||
[
|
||||
'vent',
|
||||
'Cells/NzbDroneCell',
|
||||
'Commands/CommandController'
|
||||
], function (vent, NzbDroneCell, CommandController) {
|
||||
return NzbDroneCell.extend({
|
||||
|
||||
className: 'episode-actions-cell',
|
||||
|
||||
events: {
|
||||
'click .x-automatic-search' : '_automaticSearch',
|
||||
'click .x-manual-search' : '_manualSearch'
|
||||
},
|
||||
|
||||
render: function () {
|
||||
this.$el.empty();
|
||||
|
||||
this.$el.html(
|
||||
'<i class="icon-search x-automatic-search" title="Automatic Search"></i>' +
|
||||
'<i class="icon-nd-manual-search x-manual-search" title="Manual Search"></i>'
|
||||
);
|
||||
|
||||
CommandController.bindToCommand({
|
||||
element: this.$el.find('.x-automatic-search'),
|
||||
command: {
|
||||
name : 'episodeSearch',
|
||||
episodeIds : [ this.model.get('id') ]
|
||||
}
|
||||
});
|
||||
|
||||
this.delegateEvents();
|
||||
return this;
|
||||
},
|
||||
|
||||
_automaticSearch: function () {
|
||||
CommandController.Execute('episodeSearch', {
|
||||
name : 'episodeSearch',
|
||||
episodeIds : [ this.model.get('id') ]
|
||||
});
|
||||
},
|
||||
|
||||
_manualSearch: function () {
|
||||
vent.trigger(vent.Commands.ShowEpisodeDetails, { episode: this.cellValue, hideSeriesLink: true, openingTab: 'search' });
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'episode-actions-cell',
|
||||
events : {
|
||||
"click .x-automatic-search" : '_automaticSearch',
|
||||
"click .x-manual-search" : '_manualSearch'
|
||||
},
|
||||
render : function(){
|
||||
this.$el.empty();
|
||||
this.$el.html('<i class="icon-search x-automatic-search" title="Automatic Search"></i>' + '<i class="icon-nd-manual-search x-manual-search" title="Manual Search"></i>');
|
||||
CommandController.bindToCommand({
|
||||
element : this.$el.find('.x-automatic-search'),
|
||||
command : {
|
||||
name : 'episodeSearch',
|
||||
episodeIds : [this.model.get('id')]
|
||||
}
|
||||
});
|
||||
});
|
||||
this.delegateEvents();
|
||||
return this;
|
||||
},
|
||||
_automaticSearch : function(){
|
||||
CommandController.Execute('episodeSearch', {
|
||||
name : 'episodeSearch',
|
||||
episodeIds : [this.model.get('id')]
|
||||
});
|
||||
},
|
||||
_manualSearch : function(){
|
||||
vent.trigger(vent.Commands.ShowEpisodeDetails, {
|
||||
episode : this.cellValue,
|
||||
hideSeriesLink : true,
|
||||
openingTab : 'search'
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -1,63 +1,42 @@
|
||||
'use strict';
|
||||
var _ = require('underscore');
|
||||
var ToggleCell = require('./ToggleCell');
|
||||
var SeriesCollection = require('../Series/SeriesCollection');
|
||||
var Messenger = require('../Shared/Messenger');
|
||||
|
||||
define(
|
||||
[
|
||||
'underscore',
|
||||
'Cells/ToggleCell',
|
||||
'Series/SeriesCollection',
|
||||
'Shared/Messenger'
|
||||
], function (_, ToggleCell, SeriesCollection, Messenger) {
|
||||
return ToggleCell.extend({
|
||||
|
||||
className: 'toggle-cell episode-monitored',
|
||||
|
||||
_originalOnClick: ToggleCell.prototype._onClick,
|
||||
|
||||
_onClick: function (e) {
|
||||
|
||||
var series = SeriesCollection.get(this.model.get('seriesId'));
|
||||
|
||||
if (!series.get('monitored')) {
|
||||
|
||||
Messenger.show({
|
||||
message: 'Unable to change monitored state when series is not monitored',
|
||||
type : 'error'
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.shiftKey && this.model.episodeCollection.lastToggled) {
|
||||
this._selectRange();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this._originalOnClick.apply(this, arguments);
|
||||
this.model.episodeCollection.lastToggled = this.model;
|
||||
},
|
||||
|
||||
_selectRange: function () {
|
||||
var episodeCollection = this.model.episodeCollection;
|
||||
var lastToggled = episodeCollection.lastToggled;
|
||||
|
||||
var currentIndex = episodeCollection.indexOf(this.model);
|
||||
var lastIndex = episodeCollection.indexOf(lastToggled);
|
||||
|
||||
var low = Math.min(currentIndex, lastIndex);
|
||||
var high = Math.max(currentIndex, lastIndex);
|
||||
var range = _.range(low + 1, high);
|
||||
|
||||
_.each(range, function (index) {
|
||||
var model = episodeCollection.at(index);
|
||||
|
||||
model.set('monitored', lastToggled.get('monitored'));
|
||||
model.save();
|
||||
});
|
||||
|
||||
this.model.set('monitored', lastToggled.get('monitored'));
|
||||
this.model.save();
|
||||
this.model.episodeCollection.lastToggled = undefined;
|
||||
}
|
||||
module.exports = ToggleCell.extend({
|
||||
className : 'toggle-cell episode-monitored',
|
||||
_originalOnClick : ToggleCell.prototype._onClick,
|
||||
_onClick : function(e){
|
||||
var series = SeriesCollection.get(this.model.get('seriesId'));
|
||||
if(!series.get('monitored')) {
|
||||
Messenger.show({
|
||||
message : 'Unable to change monitored state when series is not monitored',
|
||||
type : 'error'
|
||||
});
|
||||
return;
|
||||
}
|
||||
if(e.shiftKey && this.model.episodeCollection.lastToggled) {
|
||||
this._selectRange();
|
||||
return;
|
||||
}
|
||||
this._originalOnClick.apply(this, arguments);
|
||||
this.model.episodeCollection.lastToggled = this.model;
|
||||
},
|
||||
_selectRange : function(){
|
||||
var episodeCollection = this.model.episodeCollection;
|
||||
var lastToggled = episodeCollection.lastToggled;
|
||||
var currentIndex = episodeCollection.indexOf(this.model);
|
||||
var lastIndex = episodeCollection.indexOf(lastToggled);
|
||||
var low = Math.min(currentIndex, lastIndex);
|
||||
var high = Math.max(currentIndex, lastIndex);
|
||||
var range = _.range(low + 1, high);
|
||||
_.each(range, function(index){
|
||||
var model = episodeCollection.at(index);
|
||||
model.set('monitored', lastToggled.get('monitored'));
|
||||
model.save();
|
||||
});
|
||||
});
|
||||
this.model.set('monitored', lastToggled.get('monitored'));
|
||||
this.model.save();
|
||||
this.model.episodeCollection.lastToggled = undefined;
|
||||
}
|
||||
});
|
||||
@@ -1,79 +1,58 @@
|
||||
'use strict';
|
||||
var NzbDroneCell = require('./NzbDroneCell');
|
||||
var FormatHelpers = require('../Shared/FormatHelpers');
|
||||
var _ = require('underscore');
|
||||
|
||||
define(
|
||||
[
|
||||
'Cells/NzbDroneCell',
|
||||
'Shared/FormatHelpers',
|
||||
'underscore'
|
||||
], function (NzbDroneCell, FormatHelpers, _) {
|
||||
return NzbDroneCell.extend({
|
||||
|
||||
className: 'episode-number-cell',
|
||||
|
||||
render: function () {
|
||||
|
||||
this.$el.empty();
|
||||
|
||||
var airDateField = this.column.get('airDateUtc') || 'airDateUtc';
|
||||
var seasonField = this.column.get('seasonNumber') || 'seasonNumber';
|
||||
var episodeField = this.column.get('episodes') || 'episodeNumber';
|
||||
var absoluteEpisodeField = 'absoluteEpisodeNumber';
|
||||
|
||||
if (this.model) {
|
||||
var result = 'Unknown';
|
||||
|
||||
var airDate = this.model.get(airDateField);
|
||||
var seasonNumber = this.model.get(seasonField);
|
||||
var episodes = this.model.get(episodeField);
|
||||
var absoluteEpisodeNumber = this.model.get(absoluteEpisodeField);
|
||||
|
||||
if (this.cellValue) {
|
||||
if (!seasonNumber) {
|
||||
seasonNumber = this.cellValue.get(seasonField);
|
||||
}
|
||||
|
||||
if (!episodes) {
|
||||
episodes = this.cellValue.get(episodeField);
|
||||
}
|
||||
|
||||
if (absoluteEpisodeNumber === undefined) {
|
||||
absoluteEpisodeNumber = this.cellValue.get(absoluteEpisodeField);
|
||||
}
|
||||
|
||||
if (!airDate) {
|
||||
this.model.get(airDateField);
|
||||
}
|
||||
}
|
||||
|
||||
if (episodes) {
|
||||
|
||||
var paddedEpisodes;
|
||||
var paddedAbsoluteEpisode;
|
||||
|
||||
if (episodes.constructor === Array) {
|
||||
paddedEpisodes = _.map(episodes,function (episodeNumber) {
|
||||
return FormatHelpers.pad(episodeNumber, 2);
|
||||
}).join();
|
||||
}
|
||||
else {
|
||||
paddedEpisodes = FormatHelpers.pad(episodes, 2);
|
||||
paddedAbsoluteEpisode = FormatHelpers.pad(absoluteEpisodeNumber, 2);
|
||||
}
|
||||
|
||||
result = '{0}x{1}'.format(seasonNumber, paddedEpisodes);
|
||||
|
||||
if (absoluteEpisodeNumber !== undefined && paddedAbsoluteEpisode) {
|
||||
result += ' ({0})'.format(paddedAbsoluteEpisode);
|
||||
}
|
||||
}
|
||||
else if (airDate) {
|
||||
result = new Date(airDate).toLocaleDateString();
|
||||
}
|
||||
|
||||
this.$el.html(result);
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'episode-number-cell',
|
||||
render : function(){
|
||||
this.$el.empty();
|
||||
var airDateField = this.column.get('airDateUtc') || 'airDateUtc';
|
||||
var seasonField = this.column.get('seasonNumber') || 'seasonNumber';
|
||||
var episodeField = this.column.get('episodes') || 'episodeNumber';
|
||||
var absoluteEpisodeField = 'absoluteEpisodeNumber';
|
||||
if(this.model) {
|
||||
var result = 'Unknown';
|
||||
var airDate = this.model.get(airDateField);
|
||||
var seasonNumber = this.model.get(seasonField);
|
||||
var episodes = this.model.get(episodeField);
|
||||
var absoluteEpisodeNumber = this.model.get(absoluteEpisodeField);
|
||||
if(this.cellValue) {
|
||||
if(!seasonNumber) {
|
||||
seasonNumber = this.cellValue.get(seasonField);
|
||||
}
|
||||
if(!episodes) {
|
||||
episodes = this.cellValue.get(episodeField);
|
||||
}
|
||||
if(absoluteEpisodeNumber === undefined) {
|
||||
absoluteEpisodeNumber = this.cellValue.get(absoluteEpisodeField);
|
||||
}
|
||||
if(!airDate) {
|
||||
this.model.get(airDateField);
|
||||
}
|
||||
this.delegateEvents();
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
if(episodes) {
|
||||
var paddedEpisodes;
|
||||
var paddedAbsoluteEpisode;
|
||||
if(episodes.constructor === Array) {
|
||||
paddedEpisodes = _.map(episodes, function(episodeNumber){
|
||||
return FormatHelpers.pad(episodeNumber, 2);
|
||||
}).join();
|
||||
}
|
||||
else {
|
||||
paddedEpisodes = FormatHelpers.pad(episodes, 2);
|
||||
paddedAbsoluteEpisode = FormatHelpers.pad(absoluteEpisodeNumber, 2);
|
||||
}
|
||||
result = '{0}x{1}'.format(seasonNumber, paddedEpisodes);
|
||||
if(absoluteEpisodeNumber !== undefined && paddedAbsoluteEpisode) {
|
||||
result += ' ({0})'.format(paddedAbsoluteEpisode);
|
||||
}
|
||||
}
|
||||
else if(airDate) {
|
||||
result = new Date(airDate).toLocaleDateString();
|
||||
}
|
||||
this.$el.html(result);
|
||||
}
|
||||
this.delegateEvents();
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -1,33 +1,21 @@
|
||||
'use strict';
|
||||
var Marionette = require('marionette');
|
||||
var NzbDroneCell = require('./NzbDroneCell');
|
||||
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'Cells/NzbDroneCell'
|
||||
], function (Marionette, NzbDroneCell) {
|
||||
return NzbDroneCell.extend({
|
||||
className: 'episode-progress-cell',
|
||||
template : 'Cells/EpisodeProgressCellTemplate',
|
||||
|
||||
render: function () {
|
||||
|
||||
var episodeCount = this.model.get('episodeCount');
|
||||
var episodeFileCount = this.model.get('episodeFileCount');
|
||||
|
||||
var percent = 100;
|
||||
|
||||
if (episodeCount > 0) {
|
||||
percent = episodeFileCount / episodeCount * 100;
|
||||
}
|
||||
|
||||
this.model.set('percentOfEpisodes', percent);
|
||||
|
||||
this.templateFunction = Marionette.TemplateCache.get(this.template);
|
||||
var data = this.model.toJSON();
|
||||
var html = this.templateFunction(data);
|
||||
this.$el.html(html);
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'episode-progress-cell',
|
||||
template : 'Cells/EpisodeProgressCellTemplate',
|
||||
render : function(){
|
||||
var episodeCount = this.model.get('episodeCount');
|
||||
var episodeFileCount = this.model.get('episodeFileCount');
|
||||
var percent = 100;
|
||||
if(episodeCount > 0) {
|
||||
percent = episodeFileCount / episodeCount * 100;
|
||||
}
|
||||
this.model.set('percentOfEpisodes', percent);
|
||||
this.templateFunction = Marionette.TemplateCache.get(this.template);
|
||||
var data = this.model.toJSON();
|
||||
var html = this.templateFunction(data);
|
||||
this.$el.html(html);
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -1,135 +1,98 @@
|
||||
'use strict';
|
||||
var reqres = require('../reqres');
|
||||
var Backbone = require('backbone');
|
||||
var NzbDroneCell = require('./NzbDroneCell');
|
||||
var QueueCollection = require('../Activity/Queue/QueueCollection');
|
||||
var moment = require('moment');
|
||||
var FormatHelpers = require('../Shared/FormatHelpers');
|
||||
|
||||
define(
|
||||
[
|
||||
'reqres',
|
||||
'backbone',
|
||||
'Cells/NzbDroneCell',
|
||||
'Activity/Queue/QueueCollection',
|
||||
'moment',
|
||||
'Shared/FormatHelpers'
|
||||
], function (reqres, Backbone, NzbDroneCell, QueueCollection, moment, FormatHelpers) {
|
||||
return NzbDroneCell.extend({
|
||||
|
||||
className: 'episode-status-cell',
|
||||
|
||||
render: function () {
|
||||
this.listenTo(QueueCollection, 'sync', this._renderCell);
|
||||
|
||||
this._renderCell();
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
_renderCell: function () {
|
||||
|
||||
if (this.episodeFile) {
|
||||
this.stopListening(this.episodeFile, 'change', this._refresh);
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'episode-status-cell',
|
||||
render : function(){
|
||||
this.listenTo(QueueCollection, 'sync', this._renderCell);
|
||||
this._renderCell();
|
||||
return this;
|
||||
},
|
||||
_renderCell : function(){
|
||||
if(this.episodeFile) {
|
||||
this.stopListening(this.episodeFile, 'change', this._refresh);
|
||||
}
|
||||
this.$el.empty();
|
||||
if(this.model) {
|
||||
var icon;
|
||||
var tooltip;
|
||||
var hasAired = moment(this.model.get('airDateUtc')).isBefore(moment());
|
||||
this.episodeFile = this._getFile();
|
||||
if(this.episodeFile) {
|
||||
this.listenTo(this.episodeFile, 'change', this._refresh);
|
||||
var quality = this.episodeFile.get('quality');
|
||||
var revision = quality.revision;
|
||||
var size = FormatHelpers.bytes(this.episodeFile.get('size'));
|
||||
var title = 'Episode downloaded';
|
||||
if(revision.real && revision.real > 0) {
|
||||
title += '[REAL]';
|
||||
}
|
||||
|
||||
this.$el.empty();
|
||||
|
||||
if (this.model) {
|
||||
|
||||
var icon;
|
||||
var tooltip;
|
||||
|
||||
var hasAired = moment(this.model.get('airDateUtc')).isBefore(moment());
|
||||
this.episodeFile = this._getFile();
|
||||
|
||||
if (this.episodeFile) {
|
||||
this.listenTo(this.episodeFile, 'change', this._refresh);
|
||||
|
||||
var quality = this.episodeFile.get('quality');
|
||||
var revision = quality.revision;
|
||||
var size = FormatHelpers.bytes(this.episodeFile.get('size'));
|
||||
var title = 'Episode downloaded';
|
||||
|
||||
if (revision.real && revision.real > 0) {
|
||||
title += '[REAL]';
|
||||
}
|
||||
|
||||
if (revision.version && revision.version > 1) {
|
||||
title += ' [PROPER]';
|
||||
}
|
||||
|
||||
if (size !== '') {
|
||||
title += ' - {0}'.format(size);
|
||||
}
|
||||
|
||||
if (this.episodeFile.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));
|
||||
}
|
||||
|
||||
if(revision.version && revision.version > 1) {
|
||||
title += ' [PROPER]';
|
||||
}
|
||||
if(size !== '') {
|
||||
title += ' - {0}'.format(size);
|
||||
}
|
||||
if(this.episodeFile.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;
|
||||
}
|
||||
else {
|
||||
var model = this.model;
|
||||
var downloading = QueueCollection.findEpisode(model.get('id'));
|
||||
if(downloading) {
|
||||
var progress = 100 - downloading.get('sizeleft') / downloading.get('size') * 100;
|
||||
if(progress === 0) {
|
||||
icon = 'icon-nd-downloading';
|
||||
tooltip = 'Episode is downloading';
|
||||
}
|
||||
else {
|
||||
this.$el.html('<div class="progress" title="Episode is downloading - {0}% {1}">'.format(progress.toFixed(1), downloading.get('title')) + '<div class="progress-bar progress-bar-purple" style="width: {0}%;"></div></div>'.format(progress));
|
||||
return;
|
||||
}
|
||||
|
||||
else {
|
||||
var model = this.model;
|
||||
var downloading = QueueCollection.findEpisode(model.get('id'));
|
||||
|
||||
if (downloading) {
|
||||
var progress = 100 - (downloading.get('sizeleft') / downloading.get('size') * 100);
|
||||
|
||||
if (progress === 0) {
|
||||
icon = 'icon-nd-downloading';
|
||||
tooltip = 'Episode is downloading';
|
||||
}
|
||||
|
||||
else {
|
||||
this.$el.html('<div class="progress" title="Episode is downloading - {0}% {1}">'.format(progress.toFixed(1), downloading.get('title')) +
|
||||
'<div class="progress-bar progress-bar-purple" style="width: {0}%;"></div></div>'.format(progress));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
else if (this.model.get('grabbed')) {
|
||||
icon = 'icon-nd-downloading';
|
||||
tooltip = 'Episode is downloading';
|
||||
}
|
||||
|
||||
else if (!this.model.get('airDateUtc')) {
|
||||
icon = 'icon-nd-tba';
|
||||
tooltip = 'TBA';
|
||||
}
|
||||
|
||||
else if (hasAired) {
|
||||
icon = 'icon-nd-missing';
|
||||
tooltip = 'Episode missing from disk';
|
||||
}
|
||||
else {
|
||||
icon = 'icon-nd-not-aired';
|
||||
tooltip = 'Episode has not aired';
|
||||
}
|
||||
}
|
||||
|
||||
this.$el.html('<i class="{0}" title="{1}"/>'.format(icon, tooltip));
|
||||
}
|
||||
},
|
||||
|
||||
_getFile: function () {
|
||||
var hasFile = this.model.get('hasFile');
|
||||
|
||||
if (hasFile) {
|
||||
var episodeFile;
|
||||
|
||||
if (reqres.hasHandler(reqres.Requests.GetEpisodeFileById)) {
|
||||
episodeFile = reqres.request(reqres.Requests.GetEpisodeFileById, this.model.get('episodeFileId'));
|
||||
}
|
||||
|
||||
else if (this.model.has('episodeFile')) {
|
||||
episodeFile = new Backbone.Model(this.model.get('episodeFile'));
|
||||
}
|
||||
|
||||
if (episodeFile) {
|
||||
return episodeFile;
|
||||
}
|
||||
else if(this.model.get('grabbed')) {
|
||||
icon = 'icon-nd-downloading';
|
||||
tooltip = 'Episode is downloading';
|
||||
}
|
||||
else if(!this.model.get('airDateUtc')) {
|
||||
icon = 'icon-nd-tba';
|
||||
tooltip = 'TBA';
|
||||
}
|
||||
else if(hasAired) {
|
||||
icon = 'icon-nd-missing';
|
||||
tooltip = 'Episode missing from disk';
|
||||
}
|
||||
else {
|
||||
icon = 'icon-nd-not-aired';
|
||||
tooltip = 'Episode has not aired';
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
});
|
||||
this.$el.html('<i class="{0}" title="{1}"/>'.format(icon, tooltip));
|
||||
}
|
||||
},
|
||||
_getFile : function(){
|
||||
var hasFile = this.model.get('hasFile');
|
||||
if(hasFile) {
|
||||
var episodeFile;
|
||||
if(reqres.hasHandler(reqres.Requests.GetEpisodeFileById)) {
|
||||
episodeFile = reqres.request(reqres.Requests.GetEpisodeFileById, this.model.get('episodeFileId'));
|
||||
}
|
||||
else if(this.model.has('episodeFile')) {
|
||||
episodeFile = new Backbone.Model(this.model.get('episodeFile'));
|
||||
}
|
||||
if(episodeFile) {
|
||||
return episodeFile;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
@@ -1,33 +1,22 @@
|
||||
'use strict';
|
||||
var vent = require('../vent');
|
||||
var NzbDroneCell = require('./NzbDroneCell');
|
||||
|
||||
define(
|
||||
[
|
||||
'vent',
|
||||
'Cells/NzbDroneCell'
|
||||
], function (vent, NzbDroneCell) {
|
||||
return NzbDroneCell.extend({
|
||||
|
||||
className: 'episode-title-cell',
|
||||
|
||||
events: {
|
||||
'click': '_showDetails'
|
||||
},
|
||||
|
||||
render: function () {
|
||||
var title = this.cellValue.get('title');
|
||||
|
||||
if (!title || title === '') {
|
||||
title = 'TBA';
|
||||
}
|
||||
|
||||
this.$el.html(title);
|
||||
return this;
|
||||
},
|
||||
|
||||
_showDetails: function () {
|
||||
var hideSeriesLink = this.column.get('hideSeriesLink');
|
||||
|
||||
vent.trigger(vent.Commands.ShowEpisodeDetails, { episode: this.cellValue, hideSeriesLink: hideSeriesLink });
|
||||
}
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'episode-title-cell',
|
||||
events : {"click" : '_showDetails'},
|
||||
render : function(){
|
||||
var title = this.cellValue.get('title');
|
||||
if(!title || title === '') {
|
||||
title = 'TBA';
|
||||
}
|
||||
this.$el.html(title);
|
||||
return this;
|
||||
},
|
||||
_showDetails : function(){
|
||||
var hideSeriesLink = this.column.get('hideSeriesLink');
|
||||
vent.trigger(vent.Commands.ShowEpisodeDetails, {
|
||||
episode : this.cellValue,
|
||||
hideSeriesLink : hideSeriesLink
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -1,52 +1,39 @@
|
||||
'use strict';
|
||||
var NzbDroneCell = require('./NzbDroneCell');
|
||||
|
||||
define(
|
||||
[
|
||||
'Cells/NzbDroneCell'
|
||||
], function (NzbDroneCell) {
|
||||
return NzbDroneCell.extend({
|
||||
|
||||
className: 'history-event-type-cell',
|
||||
|
||||
render: function () {
|
||||
this.$el.empty();
|
||||
|
||||
if (this.cellValue) {
|
||||
|
||||
var icon;
|
||||
var toolTip;
|
||||
|
||||
switch (this.cellValue.get('eventType')) {
|
||||
case 'grabbed':
|
||||
icon = 'icon-nd-downloading';
|
||||
toolTip = 'Episode grabbed from {0} and sent to download client'.format(this.cellValue.get('data').indexer);
|
||||
break;
|
||||
case 'seriesFolderImported':
|
||||
icon = 'icon-hdd';
|
||||
toolTip = 'Existing episode file added to library';
|
||||
break;
|
||||
case 'downloadFolderImported':
|
||||
icon = 'icon-nd-imported';
|
||||
toolTip = 'Episode downloaded successfully and picked up from download client';
|
||||
break;
|
||||
case 'downloadFailed':
|
||||
icon = 'icon-nd-download-failed';
|
||||
toolTip = 'Episode download failed';
|
||||
break;
|
||||
case 'episodeFileDeleted':
|
||||
icon = 'icon-nd-deleted';
|
||||
toolTip = 'Episode file deleted';
|
||||
break;
|
||||
default :
|
||||
icon = 'icon-question';
|
||||
toolTip = 'unknown event';
|
||||
|
||||
}
|
||||
|
||||
this.$el.html('<i class="{0}" title="{1}" data-placement="right"/>'.format(icon, toolTip));
|
||||
}
|
||||
|
||||
return this;
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'history-event-type-cell',
|
||||
render : function(){
|
||||
this.$el.empty();
|
||||
if(this.cellValue) {
|
||||
var icon;
|
||||
var toolTip;
|
||||
switch (this.cellValue.get('eventType')) {
|
||||
case 'grabbed':
|
||||
icon = 'icon-nd-downloading';
|
||||
toolTip = 'Episode grabbed from {0} and sent to download client'.format(this.cellValue.get('data').indexer);
|
||||
break;
|
||||
case 'seriesFolderImported':
|
||||
icon = 'icon-hdd';
|
||||
toolTip = 'Existing episode file added to library';
|
||||
break;
|
||||
case 'downloadFolderImported':
|
||||
icon = 'icon-nd-imported';
|
||||
toolTip = 'Episode downloaded successfully and picked up from download client';
|
||||
break;
|
||||
case 'downloadFailed':
|
||||
icon = 'icon-nd-download-failed';
|
||||
toolTip = 'Episode download failed';
|
||||
break;
|
||||
case 'episodeFileDeleted':
|
||||
icon = 'icon-nd-deleted';
|
||||
toolTip = 'Episode file deleted';
|
||||
break;
|
||||
default:
|
||||
icon = 'icon-question';
|
||||
toolTip = 'unknown event';
|
||||
}
|
||||
});
|
||||
});
|
||||
this.$el.html('<i class="{0}" title="{1}" data-placement="right"/>'.format(icon, toolTip));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -1,19 +1,12 @@
|
||||
'use strict';
|
||||
var Backgrid = require('backgrid');
|
||||
var FormatHelpers = require('../Shared/FormatHelpers');
|
||||
|
||||
define(
|
||||
[
|
||||
'backgrid',
|
||||
'Shared/FormatHelpers'
|
||||
], function (Backgrid, FormatHelpers) {
|
||||
return Backgrid.Cell.extend({
|
||||
|
||||
className: 'file-size-cell',
|
||||
|
||||
render: function () {
|
||||
var size = this.model.get(this.column.get('name'));
|
||||
this.$el.html(FormatHelpers.bytes(size));
|
||||
this.delegateEvents();
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = Backgrid.Cell.extend({
|
||||
className : 'file-size-cell',
|
||||
render : function(){
|
||||
var size = this.model.get(this.column.get('name'));
|
||||
this.$el.html(FormatHelpers.bytes(size));
|
||||
this.delegateEvents();
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -1,16 +1,10 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backgrid'
|
||||
], function (Backgrid) {
|
||||
return Backgrid.Cell.extend({
|
||||
var Backgrid = require('backgrid');
|
||||
|
||||
className : 'indexer-cell',
|
||||
|
||||
render: function () {
|
||||
var indexer = this.model.get(this.column.get('name'));
|
||||
this.$el.html(indexer);
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = Backgrid.Cell.extend({
|
||||
className : 'indexer-cell',
|
||||
render : function(){
|
||||
var indexer = this.model.get(this.column.get('name'));
|
||||
this.$el.html(indexer);
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -1,63 +1,42 @@
|
||||
'use strict';
|
||||
var Backgrid = require('backgrid');
|
||||
var Backbone = require('backbone');
|
||||
|
||||
define(
|
||||
[
|
||||
'backgrid',
|
||||
'backbone'
|
||||
], function (Backgrid, Backbone) {
|
||||
return Backgrid.Cell.extend({
|
||||
|
||||
_originalInit: Backgrid.Cell.prototype.initialize,
|
||||
|
||||
initialize: function () {
|
||||
this._originalInit.apply(this, arguments);
|
||||
this.cellValue = this._getValue();
|
||||
|
||||
this.listenTo(this.model, 'change', this._refresh);
|
||||
|
||||
if (this._onEdit) {
|
||||
this.listenTo(this.model, 'backgrid:edit', function (model, column, cell, editor) {
|
||||
if (column.get('name') === this.column.get('name')) {
|
||||
this._onEdit(model, column, cell, editor);
|
||||
}
|
||||
});
|
||||
module.exports = Backgrid.Cell.extend({
|
||||
_originalInit : Backgrid.Cell.prototype.initialize,
|
||||
initialize : function(){
|
||||
this._originalInit.apply(this, arguments);
|
||||
this.cellValue = this._getValue();
|
||||
this.listenTo(this.model, 'change', this._refresh);
|
||||
if(this._onEdit) {
|
||||
this.listenTo(this.model, 'backgrid:edit', function(model, column, cell, editor){
|
||||
if(column.get('name') === this.column.get('name')) {
|
||||
this._onEdit(model, column, cell, editor);
|
||||
}
|
||||
},
|
||||
|
||||
_refresh: function () {
|
||||
this.cellValue = this._getValue();
|
||||
this.render();
|
||||
},
|
||||
|
||||
_getValue: function () {
|
||||
|
||||
var cellValue = this.column.get('cellValue');
|
||||
|
||||
if (cellValue) {
|
||||
if (cellValue === 'this') {
|
||||
return this.model;
|
||||
}
|
||||
}
|
||||
|
||||
var name = this.column.get('name');
|
||||
|
||||
if (name === 'this') {
|
||||
return this.model;
|
||||
}
|
||||
|
||||
var value = this.model.get(name);
|
||||
|
||||
if (!value) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
//if not a model
|
||||
if (!value.get && typeof value === 'object') {
|
||||
value = new Backbone.Model(value);
|
||||
}
|
||||
|
||||
return value;
|
||||
});
|
||||
}
|
||||
},
|
||||
_refresh : function(){
|
||||
this.cellValue = this._getValue();
|
||||
this.render();
|
||||
},
|
||||
_getValue : function(){
|
||||
var cellValue = this.column.get('cellValue');
|
||||
if(cellValue) {
|
||||
if(cellValue === 'this') {
|
||||
return this.model;
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
var name = this.column.get('name');
|
||||
if(name === 'this') {
|
||||
return this.model;
|
||||
}
|
||||
var value = this.model.get(name);
|
||||
if(!value) {
|
||||
return undefined;
|
||||
}
|
||||
if(!value.get && typeof value === 'object') {
|
||||
value = new Backbone.Model(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
});
|
||||
@@ -1,25 +1,16 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backgrid',
|
||||
'Profile/ProfileCollection',
|
||||
'underscore'
|
||||
], function (Backgrid, ProfileCollection,_) {
|
||||
return Backgrid.Cell.extend({
|
||||
className: 'profile-cell',
|
||||
var Backgrid = require('backgrid');
|
||||
var ProfileCollection = require('../Profile/ProfileCollection');
|
||||
var _ = require('underscore');
|
||||
|
||||
render: function () {
|
||||
|
||||
this.$el.empty();
|
||||
var profileId = this.model.get(this.column.get('name'));
|
||||
|
||||
var profile = _.findWhere(ProfileCollection.models, { id: profileId });
|
||||
|
||||
if (profile) {
|
||||
this.$el.html(profile.get('name'));
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = Backgrid.Cell.extend({
|
||||
className : 'profile-cell',
|
||||
render : function(){
|
||||
this.$el.empty();
|
||||
var profileId = this.model.get(this.column.get('name'));
|
||||
var profile = _.findWhere(ProfileCollection.models, {id : profileId});
|
||||
if(profile) {
|
||||
this.$el.html(profile.get('name'));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -1,13 +1,8 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'Cells/TemplatedCell',
|
||||
'Cells/Edit/QualityCellEditor'
|
||||
], function (TemplatedCell, QualityCellEditor) {
|
||||
return TemplatedCell.extend({
|
||||
var TemplatedCell = require('./TemplatedCell');
|
||||
var QualityCellEditor = require('./Edit/QualityCellEditor');
|
||||
|
||||
className: 'quality-cell',
|
||||
template : 'Cells/QualityCellTemplate',
|
||||
editor : QualityCellEditor
|
||||
});
|
||||
});
|
||||
module.exports = TemplatedCell.extend({
|
||||
className : 'quality-cell',
|
||||
template : 'Cells/QualityCellTemplate',
|
||||
editor : QualityCellEditor
|
||||
});
|
||||
@@ -1,37 +1,25 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'Cells/NzbDroneCell',
|
||||
'moment',
|
||||
'Shared/FormatHelpers',
|
||||
'Shared/UiSettingsModel'
|
||||
], function (NzbDroneCell, moment, FormatHelpers, UiSettings) {
|
||||
return NzbDroneCell.extend({
|
||||
var NzbDroneCell = require('./NzbDroneCell');
|
||||
var moment = require('moment');
|
||||
var FormatHelpers = require('../Shared/FormatHelpers');
|
||||
var UiSettings = require('../Shared/UiSettingsModel');
|
||||
|
||||
className: 'relative-date-cell',
|
||||
|
||||
render: function () {
|
||||
|
||||
var dateStr = this.model.get(this.column.get('name'));
|
||||
|
||||
if (dateStr) {
|
||||
var date = moment(dateStr);
|
||||
var result = '<span title="{0}">{1}</span>';
|
||||
var tooltip = date.format(UiSettings.longDateTime());
|
||||
var text;
|
||||
|
||||
if (UiSettings.get('showRelativeDates')) {
|
||||
text = FormatHelpers.relativeDate(dateStr);
|
||||
}
|
||||
|
||||
else {
|
||||
text = date.format(UiSettings.get('shortDateFormat'));
|
||||
}
|
||||
|
||||
this.$el.html(result.format(tooltip, text));
|
||||
}
|
||||
|
||||
return this;
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'relative-date-cell',
|
||||
render : function(){
|
||||
var dateStr = this.model.get(this.column.get('name'));
|
||||
if(dateStr) {
|
||||
var date = moment(dateStr);
|
||||
var result = '<span title="{0}">{1}</span>';
|
||||
var tooltip = date.format(UiSettings.longDateTime());
|
||||
var text;
|
||||
if(UiSettings.get('showRelativeDates')) {
|
||||
text = FormatHelpers.relativeDate(dateStr);
|
||||
}
|
||||
});
|
||||
});
|
||||
else {
|
||||
text = date.format(UiSettings.get('shortDateFormat'));
|
||||
}
|
||||
this.$el.html(result.format(tooltip, text));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -1,37 +1,25 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'Cells/NzbDroneCell',
|
||||
'moment',
|
||||
'Shared/FormatHelpers',
|
||||
'Shared/UiSettingsModel'
|
||||
], function (NzbDroneCell, moment, FormatHelpers, UiSettings) {
|
||||
return NzbDroneCell.extend({
|
||||
var NzbDroneCell = require('./NzbDroneCell');
|
||||
var moment = require('moment');
|
||||
var FormatHelpers = require('../Shared/FormatHelpers');
|
||||
var UiSettings = require('../Shared/UiSettingsModel');
|
||||
|
||||
className: 'relative-time-cell',
|
||||
|
||||
render: function () {
|
||||
|
||||
var dateStr = this.model.get(this.column.get('name'));
|
||||
|
||||
if (dateStr) {
|
||||
var date = moment(dateStr);
|
||||
var result = '<span title="{0}">{1}</span>';
|
||||
var tooltip = date.format(UiSettings.longDateTime());
|
||||
var text;
|
||||
|
||||
if (UiSettings.get('showRelativeDates')) {
|
||||
text = date.fromNow();
|
||||
}
|
||||
|
||||
else {
|
||||
text = date.format(UiSettings.shortDateTime());
|
||||
}
|
||||
|
||||
this.$el.html(result.format(tooltip, text));
|
||||
}
|
||||
|
||||
return this;
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'relative-time-cell',
|
||||
render : function(){
|
||||
var dateStr = this.model.get(this.column.get('name'));
|
||||
if(dateStr) {
|
||||
var date = moment(dateStr);
|
||||
var result = '<span title="{0}">{1}</span>';
|
||||
var tooltip = date.format(UiSettings.longDateTime());
|
||||
var text;
|
||||
if(UiSettings.get('showRelativeDates')) {
|
||||
text = date.fromNow();
|
||||
}
|
||||
});
|
||||
});
|
||||
else {
|
||||
text = date.format(UiSettings.shortDateTime());
|
||||
}
|
||||
this.$el.html(result.format(tooltip, text));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -1,28 +1,17 @@
|
||||
'use strict';
|
||||
var NzbDroneCell = require('./NzbDroneCell');
|
||||
|
||||
define(
|
||||
[
|
||||
'Cells/NzbDroneCell'
|
||||
], function (NzbDroneCell) {
|
||||
return NzbDroneCell.extend({
|
||||
|
||||
className: 'release-title-cell',
|
||||
|
||||
render: function () {
|
||||
this.$el.empty();
|
||||
|
||||
var title = this.model.get('title');
|
||||
var infoUrl = this.model.get('infoUrl');
|
||||
|
||||
if (infoUrl) {
|
||||
this.$el.html('<a href="{0}">{1}</a>'.format(infoUrl, title));
|
||||
}
|
||||
|
||||
else {
|
||||
this.$el.html(title);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'release-title-cell',
|
||||
render : function(){
|
||||
this.$el.empty();
|
||||
var title = this.model.get('title');
|
||||
var infoUrl = this.model.get('infoUrl');
|
||||
if(infoUrl) {
|
||||
this.$el.html('<a href="{0}">{1}</a>'.format(infoUrl, title));
|
||||
}
|
||||
else {
|
||||
this.$el.html(title);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -1,19 +1,11 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backgrid'
|
||||
], function (Backgrid) {
|
||||
return Backgrid.Cell.extend({
|
||||
var Backgrid = require('backgrid');
|
||||
|
||||
className : 'season-folder-cell',
|
||||
|
||||
render: function () {
|
||||
this.$el.empty();
|
||||
|
||||
var seasonFolder = this.model.get(this.column.get('name'));
|
||||
this.$el.html(seasonFolder.toString());
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = Backgrid.Cell.extend({
|
||||
className : 'season-folder-cell',
|
||||
render : function(){
|
||||
this.$el.empty();
|
||||
var seasonFolder = this.model.get(this.column.get('name'));
|
||||
this.$el.html(seasonFolder.toString());
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -1,49 +1,35 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'jquery',
|
||||
'underscore',
|
||||
'backgrid.selectall'
|
||||
], function ($, _, BackgridSelectAll) {
|
||||
return BackgridSelectAll.extend({
|
||||
var $ = require('jquery');
|
||||
var _ = require('underscore');
|
||||
var BackgridSelectAll = require('backgrid.selectall');
|
||||
|
||||
enterEditMode: function (e) {
|
||||
if (e.shiftKey && this.model.collection.lastToggled) {
|
||||
this._selectRange();
|
||||
}
|
||||
|
||||
var checked = $(e.target).prop('checked');
|
||||
|
||||
this.model.collection.lastToggled = this.model;
|
||||
this.model.collection.checked = checked;
|
||||
},
|
||||
|
||||
onChange: function (e) {
|
||||
var checked = $(e.target).prop('checked');
|
||||
this.$el.parent().toggleClass('selected', checked);
|
||||
this.model.trigger('backgrid:selected', this.model, checked);
|
||||
},
|
||||
|
||||
_selectRange: function () {
|
||||
var collection = this.model.collection;
|
||||
var lastToggled = collection.lastToggled;
|
||||
var checked = collection.checked;
|
||||
|
||||
var currentIndex = collection.indexOf(this.model);
|
||||
var lastIndex = collection.indexOf(lastToggled);
|
||||
|
||||
var low = Math.min(currentIndex, lastIndex);
|
||||
var high = Math.max(currentIndex, lastIndex);
|
||||
var range = _.range(low + 1, high);
|
||||
|
||||
_.each(range, function (index) {
|
||||
var model = collection.at(index);
|
||||
|
||||
model.trigger('backgrid:select', model, checked);
|
||||
});
|
||||
|
||||
this.model.collection.lastToggled = undefined;
|
||||
this.model.collection.checked = undefined;
|
||||
}
|
||||
module.exports = BackgridSelectAll.extend({
|
||||
enterEditMode : function(e){
|
||||
if(e.shiftKey && this.model.collection.lastToggled) {
|
||||
this._selectRange();
|
||||
}
|
||||
var checked = $(e.target).prop('checked');
|
||||
this.model.collection.lastToggled = this.model;
|
||||
this.model.collection.checked = checked;
|
||||
},
|
||||
onChange : function(e){
|
||||
var checked = $(e.target).prop('checked');
|
||||
this.$el.parent().toggleClass('selected', checked);
|
||||
this.model.trigger('backgrid:selected', this.model, checked);
|
||||
},
|
||||
_selectRange : function(){
|
||||
var collection = this.model.collection;
|
||||
var lastToggled = collection.lastToggled;
|
||||
var checked = collection.checked;
|
||||
var currentIndex = collection.indexOf(this.model);
|
||||
var lastIndex = collection.indexOf(lastToggled);
|
||||
var low = Math.min(currentIndex, lastIndex);
|
||||
var high = Math.max(currentIndex, lastIndex);
|
||||
var range = _.range(low + 1, high);
|
||||
_.each(range, function(index){
|
||||
var model = collection.at(index);
|
||||
model.trigger('backgrid:select', model, checked);
|
||||
});
|
||||
});
|
||||
this.model.collection.lastToggled = undefined;
|
||||
this.model.collection.checked = undefined;
|
||||
}
|
||||
});
|
||||
@@ -1,53 +1,34 @@
|
||||
'use strict';
|
||||
var vent = require('../vent');
|
||||
var NzbDroneCell = require('./NzbDroneCell');
|
||||
var CommandController = require('../Commands/CommandController');
|
||||
|
||||
define(
|
||||
[
|
||||
'vent',
|
||||
'Cells/NzbDroneCell',
|
||||
'Commands/CommandController'
|
||||
], function (vent, NzbDroneCell, CommandController) {
|
||||
return NzbDroneCell.extend({
|
||||
|
||||
className: 'series-actions-cell',
|
||||
|
||||
ui: {
|
||||
refresh: '.x-refresh'
|
||||
},
|
||||
|
||||
events: {
|
||||
'click .x-edit' : '_editSeries',
|
||||
'click .x-refresh' : '_refreshSeries'
|
||||
},
|
||||
|
||||
render: function () {
|
||||
this.$el.empty();
|
||||
|
||||
this.$el.html(
|
||||
'<i class="icon-refresh x-refresh hidden-xs" title="" data-original-title="Update series info and scan disk"></i> ' +
|
||||
'<i class="icon-nd-edit x-edit" title="" data-original-title="Edit Series"></i>'
|
||||
);
|
||||
|
||||
CommandController.bindToCommand({
|
||||
element: this.$el.find('.x-refresh'),
|
||||
command: {
|
||||
name : 'refreshSeries',
|
||||
seriesId : this.model.get('id')
|
||||
}
|
||||
});
|
||||
|
||||
this.delegateEvents();
|
||||
return this;
|
||||
},
|
||||
|
||||
_editSeries: function () {
|
||||
vent.trigger(vent.Commands.EditSeriesCommand, {series:this.model});
|
||||
},
|
||||
|
||||
_refreshSeries: function () {
|
||||
CommandController.Execute('refreshSeries', {
|
||||
name : 'refreshSeries',
|
||||
seriesId: this.model.id
|
||||
});
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'series-actions-cell',
|
||||
ui : {refresh : '.x-refresh'},
|
||||
events : {
|
||||
"click .x-edit" : '_editSeries',
|
||||
"click .x-refresh" : '_refreshSeries'
|
||||
},
|
||||
render : function(){
|
||||
this.$el.empty();
|
||||
this.$el.html('<i class="icon-refresh x-refresh hidden-xs" title="" data-original-title="Update series info and scan disk"></i> ' + '<i class="icon-nd-edit x-edit" title="" data-original-title="Edit Series"></i>');
|
||||
CommandController.bindToCommand({
|
||||
element : this.$el.find('.x-refresh'),
|
||||
command : {
|
||||
name : 'refreshSeries',
|
||||
seriesId : this.model.get('id')
|
||||
}
|
||||
});
|
||||
});
|
||||
this.delegateEvents();
|
||||
return this;
|
||||
},
|
||||
_editSeries : function(){
|
||||
vent.trigger(vent.Commands.EditSeriesCommand, {series : this.model});
|
||||
},
|
||||
_refreshSeries : function(){
|
||||
CommandController.Execute('refreshSeries', {
|
||||
name : 'refreshSeries',
|
||||
seriesId : this.model.id
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -1,36 +1,26 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'Cells/NzbDroneCell'
|
||||
], function (NzbDroneCell) {
|
||||
return NzbDroneCell.extend({
|
||||
className: 'series-status-cell',
|
||||
var NzbDroneCell = require('./NzbDroneCell');
|
||||
|
||||
render: function () {
|
||||
this.$el.empty();
|
||||
var monitored = this.model.get('monitored');
|
||||
var status = this.model.get('status');
|
||||
|
||||
if (status === 'ended') {
|
||||
this.$el.html('<i class="icon-stop grid-icon" title="Ended"></i>');
|
||||
this._setStatusWeight(3);
|
||||
}
|
||||
|
||||
else if (!monitored) {
|
||||
this.$el.html('<i class="icon-pause grid-icon" title="Not Monitored"></i>');
|
||||
this._setStatusWeight(2);
|
||||
}
|
||||
|
||||
else {
|
||||
this.$el.html('<i class="icon-play grid-icon" title="Continuing"></i>');
|
||||
this._setStatusWeight(1);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
_setStatusWeight: function (weight) {
|
||||
this.model.set('statusWeight', weight, {silent: true});
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'series-status-cell',
|
||||
render : function(){
|
||||
this.$el.empty();
|
||||
var monitored = this.model.get('monitored');
|
||||
var status = this.model.get('status');
|
||||
if(status === 'ended') {
|
||||
this.$el.html('<i class="icon-stop grid-icon" title="Ended"></i>');
|
||||
this._setStatusWeight(3);
|
||||
}
|
||||
else if(!monitored) {
|
||||
this.$el.html('<i class="icon-pause grid-icon" title="Not Monitored"></i>');
|
||||
this._setStatusWeight(2);
|
||||
}
|
||||
else {
|
||||
this.$el.html('<i class="icon-play grid-icon" title="Continuing"></i>');
|
||||
this._setStatusWeight(1);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
_setStatusWeight : function(weight){
|
||||
this.model.set('statusWeight', weight, {silent : true});
|
||||
}
|
||||
});
|
||||
@@ -1,12 +1,6 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'Cells/TemplatedCell'
|
||||
], function (TemplatedCell) {
|
||||
return TemplatedCell.extend({
|
||||
var TemplatedCell = require('./TemplatedCell');
|
||||
|
||||
className: 'series-title-cell',
|
||||
template : 'Cells/SeriesTitleTemplate'
|
||||
|
||||
});
|
||||
});
|
||||
module.exports = TemplatedCell.extend({
|
||||
className : 'series-title-cell',
|
||||
template : 'Cells/SeriesTitleTemplate'
|
||||
});
|
||||
@@ -1,23 +1,14 @@
|
||||
'use strict';
|
||||
var Marionette = require('marionette');
|
||||
var NzbDroneCell = require('./NzbDroneCell');
|
||||
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'Cells/NzbDroneCell'
|
||||
], function (Marionette, NzbDroneCell) {
|
||||
return NzbDroneCell.extend({
|
||||
|
||||
render: function () {
|
||||
|
||||
var templateName = this.column.get('template') || this.template;
|
||||
|
||||
this.templateFunction = Marionette.TemplateCache.get(templateName);
|
||||
var data = this.cellValue.toJSON();
|
||||
var html = this.templateFunction(data);
|
||||
this.$el.html(html);
|
||||
|
||||
this.delegateEvents();
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = NzbDroneCell.extend({
|
||||
render : function(){
|
||||
var templateName = this.column.get('template') || this.template;
|
||||
this.templateFunction = Marionette.TemplateCache.get(templateName);
|
||||
var data = this.cellValue.toJSON();
|
||||
var html = this.templateFunction(data);
|
||||
this.$el.html(html);
|
||||
this.delegateEvents();
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -1,53 +1,32 @@
|
||||
'use strict';
|
||||
var Backgrid = require('backgrid');
|
||||
|
||||
define(
|
||||
[
|
||||
'backgrid'
|
||||
], function (Backgrid) {
|
||||
return Backgrid.Cell.extend({
|
||||
|
||||
className: 'toggle-cell',
|
||||
|
||||
events: {
|
||||
'click': '_onClick'
|
||||
},
|
||||
|
||||
_onClick: function () {
|
||||
|
||||
var self = this;
|
||||
|
||||
this.$el.tooltip('hide');
|
||||
|
||||
var name = this.column.get('name');
|
||||
this.model.set(name, !this.model.get(name));
|
||||
|
||||
this.$('i').addClass('icon-spinner icon-spin');
|
||||
|
||||
this.model.save().always(function () {
|
||||
self.render();
|
||||
});
|
||||
},
|
||||
|
||||
render: function () {
|
||||
this.$el.empty();
|
||||
this.$el.html('<i />');
|
||||
|
||||
var name = this.column.get('name');
|
||||
|
||||
if (this.model.get(name)) {
|
||||
this.$('i').addClass(this.column.get('trueClass'));
|
||||
}
|
||||
else {
|
||||
this.$('i').addClass(this.column.get('falseClass'));
|
||||
}
|
||||
|
||||
var tooltip = this.column.get('tooltip');
|
||||
|
||||
if (tooltip) {
|
||||
this.$('i').attr('title', tooltip);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
module.exports = Backgrid.Cell.extend({
|
||||
className : 'toggle-cell',
|
||||
events : {"click" : '_onClick'},
|
||||
_onClick : function(){
|
||||
var self = this;
|
||||
this.$el.tooltip('hide');
|
||||
var name = this.column.get('name');
|
||||
this.model.set(name, !this.model.get(name));
|
||||
this.$('i').addClass('icon-spinner icon-spin');
|
||||
this.model.save().always(function(){
|
||||
self.render();
|
||||
});
|
||||
});
|
||||
},
|
||||
render : function(){
|
||||
this.$el.empty();
|
||||
this.$el.html('<i />');
|
||||
var name = this.column.get('name');
|
||||
if(this.model.get(name)) {
|
||||
this.$('i').addClass(this.column.get('trueClass'));
|
||||
}
|
||||
else {
|
||||
this.$('i').addClass(this.column.get('falseClass'));
|
||||
}
|
||||
var tooltip = this.column.get('tooltip');
|
||||
if(tooltip) {
|
||||
this.$('i').attr('title', tooltip);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user