mirror of
https://github.com/Radarr/Radarr
synced 2025-12-21 15:56:23 +01:00
42 lines
No EOL
1.1 KiB
JavaScript
42 lines
No EOL
1.1 KiB
JavaScript
var _ = require('underscore');
|
|
var Backbone = require('backbone');
|
|
|
|
module.exports = 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';
|
|
}
|
|
}); |