lidarr/src/UI/Commands/CommandModel.js
Mark McDowall 86ef30480f Searching icons and spinner fix
New: Manual search has its own icon on series details instead of a dropdown
Fixed: Automatic search icon will spin showing activity
2014-09-05 08:29:10 -07:00

46 lines
1.3 KiB
JavaScript

'use strict';
define(
[
'underscore',
'backbone'
], function (_, Backbone) {
return Backbone.Model.extend({
url: window.NzbDrone.ApiRoot + '/command',
parse: function (response) {
response.name = response.name.toLocaleLowerCase();
return response;
},
isSameCommand: function (command) {
if (command.name.toLocaleLowerCase() !== this.get('name').toLocaleLowerCase()) {
return false;
}
for (var key in command) {
if (key !== 'name') {
if (Array.isArray(command[key])) {
if (_.difference(command[key], this.get(key)).length > 0) {
return false;
}
}
else if (command[key] !== this.get(key)) {
return false;
}
}
}
return true;
},
isActive: function () {
return this.get('state') !== 'completed' && this.get('state') !== 'failed';
},
isComplete: function () {
return this.get('state') === 'completed';
}
});
});