mirror of https://gitee.com/bigwinds/arangodb
issue #2131 - display process and error of pending or failed index creations
This commit is contained in:
parent
c8511619a6
commit
4ab8671bff
|
@ -63,6 +63,8 @@
|
|||
},
|
||||
|
||||
getIndex: function (callback) {
|
||||
var self = this;
|
||||
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
cache: false,
|
||||
|
@ -70,10 +72,10 @@
|
|||
contentType: 'application/json',
|
||||
processData: false,
|
||||
success: function (data) {
|
||||
callback(false, data);
|
||||
callback(false, data, self.get('id'));
|
||||
},
|
||||
error: function (data) {
|
||||
callback(true, data);
|
||||
callback(true, data, self.get('id'));
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
|
@ -36,11 +36,11 @@
|
|||
},
|
||||
|
||||
getIndex: function () {
|
||||
var callback = function (error, data) {
|
||||
var callback = function (error, data, id) {
|
||||
if (error) {
|
||||
window.arangoHelper.arangoError('Index', data.errorMessage);
|
||||
} else {
|
||||
this.renderIndex(data);
|
||||
this.renderIndex(data, id);
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
|
@ -237,9 +237,54 @@
|
|||
'<i class="fa fa-circle-o-notch fa-spin"></i>'
|
||||
);
|
||||
},
|
||||
renderIndex: function (data) {
|
||||
renderIndex: function (data, id) {
|
||||
this.index = data;
|
||||
|
||||
// get pending jobs
|
||||
var checkState = function (error, data) {
|
||||
if (error) {
|
||||
arangoHelper.arangoError('Jobs', 'Could not read pending jobs.');
|
||||
} else {
|
||||
var readJob = function (error, data, job) {
|
||||
if (error) {
|
||||
if (data.responseJSON.code === 404) {
|
||||
// delete non existing aardvark job
|
||||
arangoHelper.deleteAardvarkJob(job);
|
||||
} else if (data.responseJSON.code === 400) {
|
||||
// index job failed -> print error
|
||||
arangoHelper.arangoError('Index creation failed', data.responseJSON.errorMessage);
|
||||
// delete non existing aardvark job
|
||||
arangoHelper.deleteAardvarkJob(job);
|
||||
} else if (data.responseJSON.code === 204) {
|
||||
// job is still in quere or pending
|
||||
arangoHelper.arangoMessage('Index', 'There is at least one new index in the queue or in the process of beeing created.');
|
||||
}
|
||||
} else {
|
||||
arangoHelper.deleteAardvarkJob(job);
|
||||
}
|
||||
};
|
||||
|
||||
_.each(data, function (job) {
|
||||
if (job.collection === id) {
|
||||
$.ajax({
|
||||
type: 'PUT',
|
||||
cache: false,
|
||||
url: arangoHelper.databaseUrl('/_api/job/' + job.id),
|
||||
contentType: 'application/json',
|
||||
success: function (data, a, b) {
|
||||
readJob(false, data, job.id);
|
||||
},
|
||||
error: function (data) {
|
||||
readJob(true, data, job.id);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
arangoHelper.getAardvarkJobs(checkState);
|
||||
|
||||
var cssClass = 'collectionInfoTh modal-text';
|
||||
if (this.index) {
|
||||
var fieldString = '';
|
||||
|
|
Loading…
Reference in New Issue