commit
3e545a9d62
Binary file not shown.
@ -0,0 +1,69 @@
|
||||
'use strict';
|
||||
|
||||
define(
|
||||
[
|
||||
'backgrid',
|
||||
'Shared/Grid/HeaderCell'
|
||||
], function (Backgrid, NzbDroneHeaderCell) {
|
||||
|
||||
Backgrid.QualityHeaderCell = NzbDroneHeaderCell.extend({
|
||||
events: {
|
||||
'click': 'onClick'
|
||||
},
|
||||
|
||||
onClick: function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var self = this;
|
||||
var columnName = this.column.get('name');
|
||||
|
||||
if (this.column.get('sortable')) {
|
||||
if (this.direction() === 'ascending') {
|
||||
this.sort(columnName, 'descending', function (left, right) {
|
||||
var leftVal = left.get(columnName);
|
||||
var rightVal = right.get(columnName);
|
||||
|
||||
return self._comparator(leftVal, rightVal);
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.sort(columnName, 'ascending', function (left, right) {
|
||||
var leftVal = left.get(columnName);
|
||||
var rightVal = right.get(columnName);
|
||||
|
||||
return self._comparator(rightVal, leftVal);
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_comparator: function (leftVal, rightVal) {
|
||||
var leftWeight = leftVal.quality.weight;
|
||||
var rightWeight = rightVal.quality.weight;
|
||||
|
||||
if (!leftWeight && !rightWeight) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!leftWeight) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!rightWeight) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (leftWeight === rightWeight) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (leftWeight > rightWeight) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
return Backgrid.QualityHeaderCell;
|
||||
});
|
@ -1,56 +1,66 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'app',
|
||||
'Commands/CommandModel',
|
||||
'Commands/CommandCollection',
|
||||
'underscore',
|
||||
'jQuery/jquery.spin'
|
||||
], function (CommandModel, CommandCollection, _) {
|
||||
], function (App, CommandModel, CommandCollection, _) {
|
||||
|
||||
return{
|
||||
var singleton = function () {
|
||||
|
||||
Execute: function (name, properties) {
|
||||
return {
|
||||
|
||||
var attr = _.extend({name: name.toLocaleLowerCase()}, properties);
|
||||
Execute: function (name, properties) {
|
||||
|
||||
var commandModel = new CommandModel(attr);
|
||||
var attr = _.extend({name: name.toLocaleLowerCase()}, properties);
|
||||
|
||||
return commandModel.save().success(function () {
|
||||
CommandCollection.add(commandModel);
|
||||
});
|
||||
},
|
||||
var commandModel = new CommandModel(attr);
|
||||
|
||||
bindToCommand: function (options) {
|
||||
return commandModel.save().success(function () {
|
||||
CommandCollection.add(commandModel);
|
||||
});
|
||||
},
|
||||
|
||||
var self = this;
|
||||
bindToCommand: function (options) {
|
||||
|
||||
var existingCommand = CommandCollection.findCommand(options.command);
|
||||
var self = this;
|
||||
|
||||
if (existingCommand) {
|
||||
this._bindToCommandModel.call(this, existingCommand, options);
|
||||
}
|
||||
var existingCommand = CommandCollection.findCommand(options.command);
|
||||
|
||||
CommandCollection.bind('add sync', function (model) {
|
||||
if (model.isSameCommand(options.command)) {
|
||||
self._bindToCommandModel.call(self, model, options);
|
||||
if (existingCommand) {
|
||||
this._bindToCommandModel.call(this, existingCommand, options);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_bindToCommandModel: function bindToCommand(model, options) {
|
||||
CommandCollection.bind('add sync', function (model) {
|
||||
if (model.isSameCommand(options.command)) {
|
||||
self._bindToCommandModel.call(self, model, options);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
if (!model.isActive()) {
|
||||
options.element.stopSpin();
|
||||
return;
|
||||
}
|
||||
_bindToCommandModel: function bindToCommand(model, options) {
|
||||
|
||||
model.bind('change:state', function (model) {
|
||||
if (!model.isActive()) {
|
||||
options.element.stopSpin();
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
options.element.startSpin();
|
||||
}
|
||||
}
|
||||
model.bind('change:state', function (model) {
|
||||
if (!model.isActive()) {
|
||||
options.element.stopSpin();
|
||||
|
||||
if (model.isComplete()) {
|
||||
App.vent.trigger(App.Events.CommandComplete, { command: model, model: options.model });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
options.element.startSpin();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
return singleton();
|
||||
});
|
||||
|
@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
define(
|
||||
[
|
||||
'handlebars'
|
||||
], function (Handlebars) {
|
||||
|
||||
Handlebars.registerHelper('currentVersion', function (version) {
|
||||
var currentVersion = window.NzbDrone.ServerStatus.version;
|
||||
|
||||
if (currentVersion === version)
|
||||
{
|
||||
return new Handlebars.SafeString('<i class="icon-ok" title="Installed"></i>');
|
||||
}
|
||||
|
||||
return '';
|
||||
});
|
||||
});
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue