2013-08-31 03:08:19 +00:00
|
|
|
'use strict';
|
|
|
|
define(
|
|
|
|
[
|
|
|
|
'backbone'
|
|
|
|
], function (Backbone) {
|
|
|
|
return Backbone.Model.extend({
|
2013-09-14 07:10:19 +00:00
|
|
|
url: window.NzbDrone.ApiRoot + '/command',
|
2013-09-11 06:33:47 +00:00
|
|
|
|
|
|
|
parse: function (response) {
|
|
|
|
response.name = response.name.toLocaleLowerCase();
|
|
|
|
return response;
|
|
|
|
},
|
|
|
|
|
|
|
|
isSameCommand: function (command) {
|
|
|
|
|
2013-09-29 08:48:47 +00:00
|
|
|
if (command.name.toLocaleLowerCase() !== this.get('name').toLocaleLowerCase()) {
|
2013-09-11 06:33:47 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var key in command) {
|
|
|
|
if (key !== 'name' && command[key] !== this.get(key)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2013-09-29 08:48:47 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
isActive: function () {
|
|
|
|
return this.get('state') !== 'completed' && this.get('state') !== 'failed';
|
|
|
|
},
|
|
|
|
|
|
|
|
isComplete: function () {
|
|
|
|
return this.get('state') === 'completed';
|
2013-09-11 06:33:47 +00:00
|
|
|
}
|
2013-08-31 03:08:19 +00:00
|
|
|
});
|
|
|
|
});
|