mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
UI Cleanup - Updated Cells subtree.
This commit is contained in:
parent
83b8ab8fe9
commit
7b5c0a952b
@ -5,14 +5,20 @@ require('bootstrap');
|
||||
module.exports = Backgrid.Cell.extend({
|
||||
className : 'approval-status-cell',
|
||||
template : 'Cells/ApprovalStatusCellTemplate',
|
||||
render : function(){
|
||||
|
||||
render : function() {
|
||||
|
||||
var rejections = this.model.get(this.column.get('name'));
|
||||
if(rejections.length === 0) {
|
||||
|
||||
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,
|
||||
@ -21,6 +27,7 @@ module.exports = Backgrid.Cell.extend({
|
||||
placement : 'left',
|
||||
container : this.$el
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
@ -3,17 +3,24 @@ var Backgrid = require('backgrid');
|
||||
|
||||
module.exports = Backgrid.Cell.extend({
|
||||
className : 'delete-episode-file-cell',
|
||||
events : {"click" : '_onClick'},
|
||||
render : function(){
|
||||
|
||||
events : {
|
||||
'click' : '_onClick'
|
||||
},
|
||||
|
||||
render : function() {
|
||||
this.$el.empty();
|
||||
this.$el.html('<i class="icon-nd-delete"></i>');
|
||||
|
||||
return this;
|
||||
},
|
||||
_onClick : function(){
|
||||
|
||||
_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});
|
||||
|
||||
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 });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -7,38 +7,49 @@ module.exports = Backgrid.CellEditor.extend({
|
||||
className : 'quality-cell-editor',
|
||||
template : 'Cells/Edit/QualityCellEditorTemplate',
|
||||
tagName : 'select',
|
||||
events : {
|
||||
"change" : 'save',
|
||||
"blur" : 'close',
|
||||
"keydown" : 'close'
|
||||
|
||||
events : {
|
||||
'change' : 'save',
|
||||
'blur' : 'close',
|
||||
'keydown' : 'close'
|
||||
},
|
||||
render : function(){
|
||||
|
||||
render : function() {
|
||||
var self = this;
|
||||
|
||||
var profileSchemaCollection = new ProfileSchemaCollection();
|
||||
var promise = profileSchemaCollection.fetch();
|
||||
promise.done(function(){
|
||||
|
||||
promise.done(function() {
|
||||
var templateName = self.template;
|
||||
self.schema = profileSchemaCollection.first();
|
||||
var selected = _.find(self.schema.get('items'), function(model){
|
||||
|
||||
var selected = _.find(self.schema.get('items'), function(model) {
|
||||
return model.quality.id === self.model.get(self.column.get('name')).quality.id;
|
||||
});
|
||||
if(selected) {
|
||||
|
||||
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){
|
||||
|
||||
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){
|
||||
|
||||
var profileItem = _.find(this.schema.get('items'), function(model) {
|
||||
return model.quality.id === selected;
|
||||
});
|
||||
|
||||
var newQuality = {
|
||||
quality : profileItem.quality,
|
||||
revision : {
|
||||
@ -46,14 +57,17 @@ module.exports = Backgrid.CellEditor.extend({
|
||||
real : 0
|
||||
}
|
||||
};
|
||||
|
||||
model.set(column.get('name'), newQuality);
|
||||
model.save();
|
||||
model.trigger('backgrid:edited', model, column, new Backgrid.Command(e));
|
||||
},
|
||||
close : function(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);
|
||||
}
|
||||
});
|
@ -3,14 +3,18 @@ var NzbDroneCell = require('./NzbDroneCell');
|
||||
var CommandController = require('../Commands/CommandController');
|
||||
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'episode-actions-cell',
|
||||
events : {
|
||||
"click .x-automatic-search" : '_automaticSearch',
|
||||
"click .x-manual-search" : '_manualSearch'
|
||||
className : 'episode-actions-cell',
|
||||
|
||||
events : {
|
||||
'click .x-automatic-search' : '_automaticSearch',
|
||||
'click .x-manual-search' : '_manualSearch'
|
||||
},
|
||||
render : function(){
|
||||
|
||||
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 : {
|
||||
@ -18,16 +22,19 @@ module.exports = NzbDroneCell.extend({
|
||||
episodeIds : [this.model.get('id')]
|
||||
}
|
||||
});
|
||||
|
||||
this.delegateEvents();
|
||||
return this;
|
||||
},
|
||||
_automaticSearch : function(){
|
||||
|
||||
_automaticSearch : function() {
|
||||
CommandController.Execute('episodeSearch', {
|
||||
name : 'episodeSearch',
|
||||
episodeIds : [this.model.get('id')]
|
||||
});
|
||||
},
|
||||
_manualSearch : function(){
|
||||
|
||||
_manualSearch : function() {
|
||||
vent.trigger(vent.Commands.ShowEpisodeDetails, {
|
||||
episode : this.cellValue,
|
||||
hideSeriesLink : true,
|
||||
|
@ -4,37 +4,52 @@ var SeriesCollection = require('../Series/SeriesCollection');
|
||||
var Messenger = require('../Shared/Messenger');
|
||||
|
||||
module.exports = ToggleCell.extend({
|
||||
className : 'toggle-cell episode-monitored',
|
||||
className : 'toggle-cell episode-monitored',
|
||||
|
||||
_originalOnClick : ToggleCell.prototype._onClick,
|
||||
_onClick : function(e){
|
||||
|
||||
_onClick : function(e) {
|
||||
|
||||
var series = SeriesCollection.get(this.model.get('seriesId'));
|
||||
if(!series.get('monitored')) {
|
||||
|
||||
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) {
|
||||
|
||||
if (e.shiftKey && this.model.episodeCollection.lastToggled) {
|
||||
this._selectRange();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this._originalOnClick.apply(this, arguments);
|
||||
this.model.episodeCollection.lastToggled = this.model;
|
||||
},
|
||||
_selectRange : function(){
|
||||
|
||||
_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){
|
||||
|
||||
_.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;
|
||||
|
@ -4,52 +4,65 @@ var _ = require('underscore');
|
||||
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'episode-number-cell',
|
||||
render : function(){
|
||||
|
||||
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) {
|
||||
|
||||
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) {
|
||||
|
||||
if (this.cellValue) {
|
||||
if (!seasonNumber) {
|
||||
seasonNumber = this.cellValue.get(seasonField);
|
||||
}
|
||||
if(!episodes) {
|
||||
|
||||
if (!episodes) {
|
||||
episodes = this.cellValue.get(episodeField);
|
||||
}
|
||||
if(absoluteEpisodeNumber === undefined) {
|
||||
|
||||
if (absoluteEpisodeNumber === undefined) {
|
||||
absoluteEpisodeNumber = this.cellValue.get(absoluteEpisodeField);
|
||||
}
|
||||
if(!airDate) {
|
||||
|
||||
if (!airDate) {
|
||||
this.model.get(airDateField);
|
||||
}
|
||||
}
|
||||
if(episodes) {
|
||||
|
||||
if (episodes) {
|
||||
|
||||
var paddedEpisodes;
|
||||
var paddedAbsoluteEpisode;
|
||||
if(episodes.constructor === Array) {
|
||||
paddedEpisodes = _.map(episodes, function(episodeNumber){
|
||||
|
||||
if (episodes.constructor === Array) {
|
||||
paddedEpisodes = _.map(episodes, function(episodeNumber) {
|
||||
return FormatHelpers.pad(episodeNumber, 2);
|
||||
}).join();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
paddedEpisodes = FormatHelpers.pad(episodes, 2);
|
||||
paddedAbsoluteEpisode = FormatHelpers.pad(absoluteEpisodeNumber, 2);
|
||||
}
|
||||
|
||||
result = '{0}x{1}'.format(seasonNumber, paddedEpisodes);
|
||||
if(absoluteEpisodeNumber !== undefined && paddedAbsoluteEpisode) {
|
||||
|
||||
if (absoluteEpisodeNumber !== undefined && paddedAbsoluteEpisode) {
|
||||
result += ' ({0})'.format(paddedAbsoluteEpisode);
|
||||
}
|
||||
}
|
||||
else if(airDate) {
|
||||
} else if (airDate) {
|
||||
result = new Date(airDate).toLocaleDateString();
|
||||
}
|
||||
|
||||
this.$el.html(result);
|
||||
}
|
||||
this.delegateEvents();
|
||||
|
@ -4,18 +4,25 @@ var NzbDroneCell = require('./NzbDroneCell');
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'episode-progress-cell',
|
||||
template : 'Cells/EpisodeProgressCellTemplate',
|
||||
render : function(){
|
||||
|
||||
render : function() {
|
||||
|
||||
var episodeCount = this.model.get('episodeCount');
|
||||
var episodeFileCount = this.model.get('episodeFileCount');
|
||||
|
||||
var percent = 100;
|
||||
if(episodeCount > 0) {
|
||||
|
||||
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;
|
||||
}
|
||||
});
|
@ -6,93 +6,122 @@ var moment = require('moment');
|
||||
var FormatHelpers = require('../Shared/FormatHelpers');
|
||||
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'episode-status-cell',
|
||||
render : function(){
|
||||
className : 'episode-status-cell',
|
||||
|
||||
render : function() {
|
||||
this.listenTo(QueueCollection, 'sync', this._renderCell);
|
||||
|
||||
this._renderCell();
|
||||
|
||||
return this;
|
||||
},
|
||||
_renderCell : function(){
|
||||
if(this.episodeFile) {
|
||||
|
||||
_renderCell : function() {
|
||||
|
||||
if (this.episodeFile) {
|
||||
this.stopListening(this.episodeFile, 'change', this._refresh);
|
||||
}
|
||||
|
||||
this.$el.empty();
|
||||
if(this.model) {
|
||||
|
||||
if (this.model) {
|
||||
|
||||
var icon;
|
||||
var tooltip;
|
||||
|
||||
var hasAired = moment(this.model.get('airDateUtc')).isBefore(moment());
|
||||
this.episodeFile = this._getFile();
|
||||
if(this.episodeFile) {
|
||||
|
||||
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) {
|
||||
|
||||
if (revision.real && revision.real > 0) {
|
||||
title += '[REAL]';
|
||||
}
|
||||
if(revision.version && revision.version > 1) {
|
||||
|
||||
if (revision.version && revision.version > 1) {
|
||||
title += ' [PROPER]';
|
||||
}
|
||||
if(size !== '') {
|
||||
|
||||
if (size !== '') {
|
||||
title += ' - {0}'.format(size);
|
||||
}
|
||||
if(this.episodeFile.get('qualityCutoffNotMet')) {
|
||||
|
||||
if (this.episodeFile.get('qualityCutoffNotMet')) {
|
||||
this.$el.html('<span class="badge badge-inverse" title="{0}">{1}</span>'.format(title, quality.quality.name));
|
||||
}
|
||||
else {
|
||||
} 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) {
|
||||
|
||||
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));
|
||||
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')) {
|
||||
|
||||
else if (this.model.get('grabbed')) {
|
||||
icon = 'icon-nd-downloading';
|
||||
tooltip = 'Episode is downloading';
|
||||
}
|
||||
else if(!this.model.get('airDateUtc')) {
|
||||
|
||||
else if (!this.model.get('airDateUtc')) {
|
||||
icon = 'icon-nd-tba';
|
||||
tooltip = 'TBA';
|
||||
}
|
||||
else if(hasAired) {
|
||||
|
||||
else if (hasAired) {
|
||||
icon = 'icon-nd-missing';
|
||||
tooltip = 'Episode missing from disk';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
icon = 'icon-nd-not-aired';
|
||||
tooltip = 'Episode has not aired';
|
||||
}
|
||||
}
|
||||
|
||||
this.$el.html('<i class="{0}" title="{1}"/>'.format(icon, tooltip));
|
||||
}
|
||||
},
|
||||
_getFile : function(){
|
||||
|
||||
_getFile : function() {
|
||||
var hasFile = this.model.get('hasFile');
|
||||
if(hasFile) {
|
||||
|
||||
if (hasFile) {
|
||||
var episodeFile;
|
||||
if(reqres.hasHandler(reqres.Requests.GetEpisodeFileById)) {
|
||||
|
||||
if (reqres.hasHandler(reqres.Requests.GetEpisodeFileById)) {
|
||||
episodeFile = reqres.request(reqres.Requests.GetEpisodeFileById, this.model.get('episodeFileId'));
|
||||
}
|
||||
else if(this.model.has('episodeFile')) {
|
||||
|
||||
else if (this.model.has('episodeFile')) {
|
||||
episodeFile = new Backbone.Model(this.model.get('episodeFile'));
|
||||
}
|
||||
if(episodeFile) {
|
||||
|
||||
if (episodeFile) {
|
||||
return episodeFile;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
});
|
@ -2,17 +2,24 @@ var vent = require('vent');
|
||||
var NzbDroneCell = require('./NzbDroneCell');
|
||||
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'episode-title-cell',
|
||||
events : {"click" : '_showDetails'},
|
||||
render : function(){
|
||||
className : 'episode-title-cell',
|
||||
|
||||
events : {
|
||||
'click' : '_showDetails'
|
||||
},
|
||||
|
||||
render : function() {
|
||||
var title = this.cellValue.get('title');
|
||||
if(!title || title === '') {
|
||||
|
||||
if (!title || title === '') {
|
||||
title = 'TBA';
|
||||
}
|
||||
|
||||
this.$el.html(title);
|
||||
return this;
|
||||
},
|
||||
_showDetails : function(){
|
||||
|
||||
_showDetails : function() {
|
||||
var hideSeriesLink = this.column.get('hideSeriesLink');
|
||||
vent.trigger(vent.Commands.ShowEpisodeDetails, {
|
||||
episode : this.cellValue,
|
||||
|
@ -2,11 +2,14 @@ var NzbDroneCell = require('./NzbDroneCell');
|
||||
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'history-event-type-cell',
|
||||
render : function(){
|
||||
|
||||
render : function() {
|
||||
this.$el.empty();
|
||||
if(this.cellValue) {
|
||||
|
||||
if (this.cellValue) {
|
||||
var icon;
|
||||
var toolTip;
|
||||
|
||||
switch (this.cellValue.get('eventType')) {
|
||||
case 'grabbed':
|
||||
icon = 'icon-nd-downloading';
|
||||
@ -32,8 +35,10 @@ module.exports = NzbDroneCell.extend({
|
||||
icon = 'icon-question';
|
||||
toolTip = 'unknown event';
|
||||
}
|
||||
|
||||
this.$el.html('<i class="{0}" title="{1}" data-placement="right"/>'.format(icon, toolTip));
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
@ -3,7 +3,8 @@ var FormatHelpers = require('../Shared/FormatHelpers');
|
||||
|
||||
module.exports = Backgrid.Cell.extend({
|
||||
className : 'file-size-cell',
|
||||
render : function(){
|
||||
|
||||
render : function() {
|
||||
var size = this.model.get(this.column.get('name'));
|
||||
this.$el.html(FormatHelpers.bytes(size));
|
||||
this.delegateEvents();
|
||||
|
@ -2,7 +2,8 @@ var Backgrid = require('backgrid');
|
||||
|
||||
module.exports = Backgrid.Cell.extend({
|
||||
className : 'indexer-cell',
|
||||
render : function(){
|
||||
|
||||
render : function() {
|
||||
var indexer = this.model.get(this.column.get('name'));
|
||||
this.$el.html(indexer);
|
||||
return this;
|
||||
|
@ -2,41 +2,56 @@ var Backgrid = require('backgrid');
|
||||
var Backbone = require('backbone');
|
||||
|
||||
module.exports = Backgrid.Cell.extend({
|
||||
|
||||
_originalInit : Backgrid.Cell.prototype.initialize,
|
||||
initialize : function(){
|
||||
|
||||
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')) {
|
||||
|
||||
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(){
|
||||
|
||||
_refresh : function() {
|
||||
this.cellValue = this._getValue();
|
||||
this.render();
|
||||
},
|
||||
_getValue : function(){
|
||||
|
||||
_getValue : function() {
|
||||
|
||||
var cellValue = this.column.get('cellValue');
|
||||
if(cellValue) {
|
||||
if(cellValue === 'this') {
|
||||
|
||||
if (cellValue) {
|
||||
if (cellValue === 'this') {
|
||||
return this.model;
|
||||
}
|
||||
}
|
||||
|
||||
var name = this.column.get('name');
|
||||
if(name === 'this') {
|
||||
|
||||
if (name === 'this') {
|
||||
return this.model;
|
||||
}
|
||||
|
||||
var value = this.model.get(name);
|
||||
if(!value) {
|
||||
|
||||
if (!value) {
|
||||
return undefined;
|
||||
}
|
||||
if(!value.get && typeof value === 'object') {
|
||||
|
||||
//if not a model
|
||||
if (!value.get && typeof value === 'object') {
|
||||
value = new Backbone.Model(value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
});
|
@ -4,13 +4,18 @@ var _ = require('underscore');
|
||||
|
||||
module.exports = Backgrid.Cell.extend({
|
||||
className : 'profile-cell',
|
||||
render : function(){
|
||||
|
||||
render : function() {
|
||||
|
||||
this.$el.empty();
|
||||
var profileId = this.model.get(this.column.get('name'));
|
||||
var profile = _.findWhere(ProfileCollection.models, {id : profileId});
|
||||
if(profile) {
|
||||
|
||||
var profile = _.findWhere(ProfileCollection.models, { id : profileId });
|
||||
|
||||
if (profile) {
|
||||
this.$el.html(profile.get('name'));
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
@ -5,19 +5,23 @@ var UiSettings = require('../Shared/UiSettingsModel');
|
||||
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'relative-date-cell',
|
||||
render : function(){
|
||||
|
||||
render : function() {
|
||||
|
||||
var dateStr = this.model.get(this.column.get('name'));
|
||||
if(dateStr) {
|
||||
|
||||
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')) {
|
||||
|
||||
if (UiSettings.get('showRelativeDates')) {
|
||||
text = FormatHelpers.relativeDate(dateStr);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
text = date.format(UiSettings.get('shortDateFormat'));
|
||||
}
|
||||
|
||||
this.$el.html(result.format(tooltip, text));
|
||||
}
|
||||
return this;
|
||||
|
@ -5,21 +5,26 @@ var UiSettings = require('../Shared/UiSettingsModel');
|
||||
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'relative-time-cell',
|
||||
render : function(){
|
||||
|
||||
render : function() {
|
||||
|
||||
var dateStr = this.model.get(this.column.get('name'));
|
||||
if(dateStr) {
|
||||
|
||||
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')) {
|
||||
|
||||
if (UiSettings.get('showRelativeDates')) {
|
||||
text = date.fromNow();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
text = date.format(UiSettings.shortDateTime());
|
||||
}
|
||||
|
||||
this.$el.html(result.format(tooltip, text));
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
@ -2,16 +2,19 @@ var NzbDroneCell = require('./NzbDroneCell');
|
||||
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'release-title-cell',
|
||||
render : function(){
|
||||
|
||||
render : function() {
|
||||
this.$el.empty();
|
||||
|
||||
var title = this.model.get('title');
|
||||
var infoUrl = this.model.get('infoUrl');
|
||||
if(infoUrl) {
|
||||
|
||||
if (infoUrl) {
|
||||
this.$el.html('<a href="{0}">{1}</a>'.format(infoUrl, title));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.$el.html(title);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
@ -2,10 +2,13 @@ var Backgrid = require('backgrid');
|
||||
|
||||
module.exports = Backgrid.Cell.extend({
|
||||
className : 'season-folder-cell',
|
||||
render : function(){
|
||||
|
||||
render : function() {
|
||||
this.$el.empty();
|
||||
|
||||
var seasonFolder = this.model.get(this.column.get('name'));
|
||||
this.$el.html(seasonFolder.toString());
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
@ -3,32 +3,41 @@ var _ = require('underscore');
|
||||
var BackgridSelectAll = require('backgrid.selectall');
|
||||
|
||||
module.exports = BackgridSelectAll.extend({
|
||||
enterEditMode : function(e){
|
||||
if(e.shiftKey && this.model.collection.lastToggled) {
|
||||
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){
|
||||
|
||||
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(){
|
||||
|
||||
_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){
|
||||
|
||||
_.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;
|
||||
}
|
||||
|
@ -3,15 +3,23 @@ var NzbDroneCell = require('./NzbDroneCell');
|
||||
var CommandController = require('../Commands/CommandController');
|
||||
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'series-actions-cell',
|
||||
ui : {refresh : '.x-refresh'},
|
||||
events : {
|
||||
"click .x-edit" : '_editSeries',
|
||||
"click .x-refresh" : '_refreshSeries'
|
||||
className : 'series-actions-cell',
|
||||
|
||||
ui : {
|
||||
refresh : '.x-refresh'
|
||||
},
|
||||
render : function(){
|
||||
|
||||
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>');
|
||||
|
||||
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 : {
|
||||
@ -19,13 +27,16 @@ module.exports = NzbDroneCell.extend({
|
||||
seriesId : this.model.get('id')
|
||||
}
|
||||
});
|
||||
|
||||
this.delegateEvents();
|
||||
return this;
|
||||
},
|
||||
_editSeries : function(){
|
||||
vent.trigger(vent.Commands.EditSeriesCommand, {series : this.model});
|
||||
|
||||
_editSeries : function() {
|
||||
vent.trigger(vent.Commands.EditSeriesCommand, { series : this.model });
|
||||
},
|
||||
_refreshSeries : function(){
|
||||
|
||||
_refreshSeries : function() {
|
||||
CommandController.Execute('refreshSeries', {
|
||||
name : 'refreshSeries',
|
||||
seriesId : this.model.id
|
||||
|
@ -1,26 +1,32 @@
|
||||
var NzbDroneCell = require('./NzbDroneCell');
|
||||
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'series-status-cell',
|
||||
render : function(){
|
||||
className : 'series-status-cell',
|
||||
|
||||
render : function() {
|
||||
this.$el.empty();
|
||||
var monitored = this.model.get('monitored');
|
||||
var status = this.model.get('status');
|
||||
if(status === 'ended') {
|
||||
|
||||
if (status === 'ended') {
|
||||
this.$el.html('<i class="icon-stop grid-icon" title="Ended"></i>');
|
||||
this._setStatusWeight(3);
|
||||
}
|
||||
else if(!monitored) {
|
||||
|
||||
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});
|
||||
|
||||
_setStatusWeight : function(weight) {
|
||||
this.model.set('statusWeight', weight, { silent : true });
|
||||
}
|
||||
});
|
@ -2,12 +2,15 @@ var Marionette = require('marionette');
|
||||
var NzbDroneCell = require('./NzbDroneCell');
|
||||
|
||||
module.exports = NzbDroneCell.extend({
|
||||
render : function(){
|
||||
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;
|
||||
}
|
||||
|
@ -2,31 +2,45 @@ var Backgrid = require('backgrid');
|
||||
|
||||
module.exports = Backgrid.Cell.extend({
|
||||
className : 'toggle-cell',
|
||||
events : {"click" : '_onClick'},
|
||||
_onClick : function(){
|
||||
|
||||
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(){
|
||||
|
||||
this.model.save().always(function() {
|
||||
self.render();
|
||||
});
|
||||
},
|
||||
render : function(){
|
||||
|
||||
render : function() {
|
||||
this.$el.empty();
|
||||
this.$el.html('<i />');
|
||||
|
||||
var name = this.column.get('name');
|
||||
if(this.model.get(name)) {
|
||||
|
||||
if (this.model.get(name)) {
|
||||
this.$('i').addClass(this.column.get('trueClass'));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.$('i').addClass(this.column.get('falseClass'));
|
||||
}
|
||||
|
||||
var tooltip = this.column.get('tooltip');
|
||||
if(tooltip) {
|
||||
|
||||
if (tooltip) {
|
||||
this.$('i').attr('title', tooltip);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue
Block a user