Initial commit

This commit is contained in:
zhongjin
2020-06-15 10:58:47 +08:00
commit 4f1dfe7564
8590 changed files with 1516878 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
const Backbone = require('backbone');
module.exports = Backbone.Model.extend({
idAttribute: 'item_queue_id',
urlRoot: '/api/v1/imports',
initialize: function () {
this.bind('change', this._checkFinish, this);
},
setUrlRoot: function (urlRoot) {
this.urlRoot = urlRoot;
},
/**
* checks for poll to finish
*/
pollCheck: function (i) {
var self = this;
this.pollTimer = setInterval(function () {
// cdb.log.debug("checking job for finish: " + tries);
self.fetch({
error: function (e) {
self.trigger('change');
}
});
}, i || 1500);
},
destroyCheck: function () {
clearInterval(this.pollTimer);
},
_checkFinish: function () {
// cdb.log.info("state: " + this.get('state'), "success: " + this.get("success"));
if (this.get('success') === true) {
// cdb.log.debug("job finished");
clearInterval(this.pollTimer);
this.trigger('importComplete', this);
} else if (this.get('success') === false) {
// cdb.log.debug("job failure");
clearInterval(this.pollTimer);
this.trigger('importError', this);
} else {
this.trigger('importChange', this);
}
}
});