mirror of
https://github.com/fergalmoran/Readarr.git
synced 2026-01-27 02:54:44 +00:00
39 lines
1.0 KiB
JavaScript
39 lines
1.0 KiB
JavaScript
'use strict';
|
||
|
||
define([
|
||
'jquery',
|
||
'backbone.deepmodel',
|
||
'Shared/Messenger'
|
||
], function ($, DeepModel, Messenger) {
|
||
return DeepModel.DeepModel.extend({
|
||
|
||
test: function () {
|
||
var self = this;
|
||
|
||
this.trigger('validation:sync');
|
||
|
||
var params = {};
|
||
|
||
params.url = this.collection.url + '/test';
|
||
params.contentType = 'application/json';
|
||
params.data = JSON.stringify(this.toJSON());
|
||
params.type = 'POST';
|
||
params.isValidatedCall = true;
|
||
|
||
var promise = $.ajax(params);
|
||
|
||
Messenger.monitor({
|
||
promise : promise,
|
||
successMessage : 'Testing \'{0}\' completed'.format(this.get('name')),
|
||
errorMessage : 'Testing \'{0}\' failed'.format(this.get('name'))
|
||
});
|
||
|
||
promise.fail(function (response) {
|
||
self.trigger('validation:failed', response);
|
||
});
|
||
|
||
return promise;
|
||
}
|
||
});
|
||
});
|