mirror of https://gitee.com/bigwinds/arangodb
removed async calls
This commit is contained in:
parent
8900710a44
commit
2c23eccaad
|
@ -17,59 +17,50 @@
|
||||||
desc: undefined
|
desc: undefined
|
||||||
},
|
},
|
||||||
|
|
||||||
getProperties: function () {
|
getProperties: function (callback) {
|
||||||
var data2;
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
cache: false,
|
cache: false,
|
||||||
url: "/_api/collection/" + encodeURIComponent(this.get("id")) + "/properties",
|
url: "/_api/collection/" + encodeURIComponent(this.get("id")) + "/properties",
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
processData: false,
|
processData: false,
|
||||||
async: false,
|
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
data2 = data;
|
callback(false, data);
|
||||||
},
|
},
|
||||||
error: function(data) {
|
error: function(data) {
|
||||||
data2 = data;
|
callback(true, data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return data2;
|
|
||||||
},
|
},
|
||||||
getFigures: function () {
|
getFigures: function (callback) {
|
||||||
var data2;
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
cache: false,
|
cache: false,
|
||||||
url: "/_api/collection/" + this.get("id") + "/figures",
|
url: "/_api/collection/" + this.get("id") + "/figures",
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
processData: false,
|
processData: false,
|
||||||
async: false,
|
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
data2 = data;
|
callback(false, data);
|
||||||
},
|
},
|
||||||
error: function(data) {
|
error: function() {
|
||||||
data2 = data;
|
callback(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return data2;
|
|
||||||
},
|
},
|
||||||
getRevision: function () {
|
getRevision: function (callback, figures) {
|
||||||
var data2;
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
cache: false,
|
cache: false,
|
||||||
url: "/_api/collection/" + this.get("id") + "/revision",
|
url: "/_api/collection/" + this.get("id") + "/revision",
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
processData: false,
|
processData: false,
|
||||||
async: false,
|
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
data2 = data;
|
callback(false, data, figures);
|
||||||
},
|
},
|
||||||
error: function(data) {
|
error: function() {
|
||||||
data2 = data;
|
callback(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return data2;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getIndex: function (callback) {
|
getIndex: function (callback) {
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
<script id="modalCollectionInfo.ejs" type="text/template">
|
<script id="modalCollectionInfo.ejs" type="text/template">
|
||||||
<%
|
<%
|
||||||
var figuresData = content.getFigures();
|
var figuresData = content.figures;
|
||||||
var revision = content.getRevision();
|
var revision = content.revision;
|
||||||
var index = content.getIndex();
|
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<ul id="infoTab" class="nav nav-tabs">
|
<ul id="infoTab" class="nav nav-tabs">
|
||||||
|
@ -50,7 +49,7 @@
|
||||||
<th class="collectionInfoTh2">ID:</th>
|
<th class="collectionInfoTh2">ID:</th>
|
||||||
<th class="collectionInfoTh">
|
<th class="collectionInfoTh">
|
||||||
<div id="show-collection-id" class="modal-text">
|
<div id="show-collection-id" class="modal-text">
|
||||||
<%=content.get("id")%>
|
<%=content.model.get("id")%>
|
||||||
</div>
|
</div>
|
||||||
<th>
|
<th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -67,14 +66,14 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th class="collectionInfoTh2">Type:</th>
|
<th class="collectionInfoTh2">Type:</th>
|
||||||
<th class="collectionInfoTh">
|
<th class="collectionInfoTh">
|
||||||
<div class="modal-text"><%=content.get("type")%></div>
|
<div class="modal-text"><%=content.model.get("type")%></div>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th class="collectionInfoTh2">Status:</th>
|
<th class="collectionInfoTh2">Status:</th>
|
||||||
<th class="collectionInfoTh">
|
<th class="collectionInfoTh">
|
||||||
<div class="modal-text"><%=content.get("status")%></div>
|
<div class="modal-text"><%=content.model.get("status")%></div>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|
|
@ -270,319 +270,350 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collectionIsLoaded) {
|
if (collectionIsLoaded) {
|
||||||
// needs to be refactored. move getProperties into model
|
|
||||||
var journalSize = this.model.getProperties().journalSize;
|
|
||||||
journalSize = journalSize/(1024*1024);
|
|
||||||
|
|
||||||
tableContent.push(
|
var callback = function(error, data) {
|
||||||
window.modalView.createTextEntry(
|
if (error) {
|
||||||
"change-collection-size",
|
arangoHelper.arangoError("Collection", "Could not fetch properties");
|
||||||
"Journal size",
|
|
||||||
journalSize,
|
|
||||||
"The maximal size of a journal or datafile (in MB). Must be at least 1.",
|
|
||||||
"",
|
|
||||||
true,
|
|
||||||
[
|
|
||||||
{
|
|
||||||
rule: Joi.string().allow('').optional().regex(/^[0-9]*$/),
|
|
||||||
msg: "Must be a number."
|
|
||||||
}
|
|
||||||
]
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
var indexBuckets = this.model.getProperties().indexBuckets;
|
|
||||||
|
|
||||||
tableContent.push(
|
|
||||||
window.modalView.createTextEntry(
|
|
||||||
"change-index-buckets",
|
|
||||||
"Index buckets",
|
|
||||||
indexBuckets,
|
|
||||||
"The number of index buckets for this collection. Must be at least 1 and a power of 2.",
|
|
||||||
"",
|
|
||||||
true,
|
|
||||||
[
|
|
||||||
{
|
|
||||||
rule: Joi.string().allow('').optional().regex(/^[1-9][0-9]*$/),
|
|
||||||
msg: "Must be a number greater than 1 and a power of 2."
|
|
||||||
}
|
|
||||||
]
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// prevent "unexpected sync method error"
|
|
||||||
var wfs = this.model.getProperties().waitForSync;
|
|
||||||
tableContent.push(
|
|
||||||
window.modalView.createSelectEntry(
|
|
||||||
"change-collection-sync",
|
|
||||||
"Wait for sync",
|
|
||||||
wfs,
|
|
||||||
"Synchronize to disk before returning from a create or update of a document.",
|
|
||||||
[{value: false, label: "No"}, {value: true, label: "Yes"}] )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
tableContent.push(
|
|
||||||
window.modalView.createReadOnlyEntry(
|
|
||||||
"change-collection-id", "ID", this.model.get('id'), ""
|
|
||||||
)
|
|
||||||
);
|
|
||||||
tableContent.push(
|
|
||||||
window.modalView.createReadOnlyEntry(
|
|
||||||
"change-collection-type", "Type", this.model.get('type'), ""
|
|
||||||
)
|
|
||||||
);
|
|
||||||
tableContent.push(
|
|
||||||
window.modalView.createReadOnlyEntry(
|
|
||||||
"change-collection-status", "Status", this.model.get('status'), ""
|
|
||||||
)
|
|
||||||
);
|
|
||||||
buttons.push(
|
|
||||||
window.modalView.createDeleteButton(
|
|
||||||
"Delete",
|
|
||||||
this.deleteCollection.bind(this)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
buttons.push(
|
|
||||||
window.modalView.createDeleteButton(
|
|
||||||
"Truncate",
|
|
||||||
this.truncateCollection.bind(this)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
if (collectionIsLoaded) {
|
|
||||||
buttons.push(
|
|
||||||
window.modalView.createNotificationButton(
|
|
||||||
"Unload",
|
|
||||||
this.unloadCollection.bind(this)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
buttons.push(
|
|
||||||
window.modalView.createNotificationButton(
|
|
||||||
"Load",
|
|
||||||
this.loadCollection.bind(this)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
buttons.push(
|
|
||||||
window.modalView.createSuccessButton(
|
|
||||||
"Save",
|
|
||||||
this.saveModifiedCollection.bind(this)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
var tabBar = ["General", "Indices"],
|
|
||||||
templates = ["modalTable.ejs", "indicesView.ejs"];
|
|
||||||
|
|
||||||
window.modalView.show(
|
|
||||||
templates,
|
|
||||||
"Modify Collection",
|
|
||||||
buttons,
|
|
||||||
tableContent, null, null,
|
|
||||||
this.events, null,
|
|
||||||
tabBar
|
|
||||||
);
|
|
||||||
if (this.model.get("status") === 'loaded') {
|
|
||||||
this.getIndex();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$($('#infoTab').children()[1]).remove();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
bindIndexEvents: function() {
|
|
||||||
this.unbindIndexEvents();
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
$('#indexEditView #addIndex').bind('click', function() {
|
|
||||||
self.toggleNewIndexView();
|
|
||||||
|
|
||||||
$('#cancelIndex').unbind('click');
|
|
||||||
$('#cancelIndex').bind('click', function() {
|
|
||||||
self.toggleNewIndexView();
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#createIndex').unbind('click');
|
|
||||||
$('#createIndex').bind('click', function() {
|
|
||||||
self.createIndex();
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#newIndexType').bind('change', function() {
|
|
||||||
self.selectIndexType();
|
|
||||||
});
|
|
||||||
|
|
||||||
$('.deleteIndex').bind('click', function(e) {
|
|
||||||
console.log("asdasd");
|
|
||||||
self.prepDeleteIndex(e);
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#infoTab a').bind('click', function(e) {
|
|
||||||
$('#indexDeleteModal').remove();
|
|
||||||
if ($(e.currentTarget).html() === 'Indices' && !$(e.currentTarget).parent().hasClass('active')) {
|
|
||||||
|
|
||||||
$('#newIndexView').hide();
|
|
||||||
$('#indexEditView').show();
|
|
||||||
|
|
||||||
$('#modal-dialog .modal-footer .button-danger').hide();
|
|
||||||
$('#modal-dialog .modal-footer .button-success').hide();
|
|
||||||
$('#modal-dialog .modal-footer .button-notification').hide();
|
|
||||||
//$('#addIndex').detach().appendTo('#modal-dialog .modal-footer');
|
|
||||||
}
|
|
||||||
if ($(e.currentTarget).html() === 'General' && !$(e.currentTarget).parent().hasClass('active')) {
|
|
||||||
$('#modal-dialog .modal-footer .button-danger').show();
|
|
||||||
$('#modal-dialog .modal-footer .button-success').show();
|
|
||||||
$('#modal-dialog .modal-footer .button-notification').show();
|
|
||||||
var elem = $('.index-button-bar')[0];
|
|
||||||
var elem2 = $('.index-button-bar2')[0];
|
|
||||||
//$('#addIndex').detach().appendTo(elem);
|
|
||||||
if ($('#cancelIndex').is(':visible')) {
|
|
||||||
$('#cancelIndex').detach().appendTo(elem2);
|
|
||||||
$('#createIndex').detach().appendTo(elem2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
unbindIndexEvents: function() {
|
|
||||||
$('#indexEditView #addIndex').unbind('click');
|
|
||||||
$('#newIndexType').unbind('change');
|
|
||||||
$('#infoTab a').unbind('click');
|
|
||||||
$('.deleteIndex').unbind('click');
|
|
||||||
/*
|
|
||||||
//$('#documentsToolbar ul').unbind('click');
|
|
||||||
this.markFilterToggle();
|
|
||||||
this.changeEditMode(false);
|
|
||||||
0Ads0asd0sd0f0asdf0sa0f
|
|
||||||
"click #documentsToolbar ul" : "resetIndexForms"
|
|
||||||
*/
|
|
||||||
},
|
|
||||||
|
|
||||||
createInfoModal: function() {
|
|
||||||
var buttons = [],
|
|
||||||
tableContent = this.model;
|
|
||||||
window.modalView.show(
|
|
||||||
"modalCollectionInfo.ejs",
|
|
||||||
"Collection: " + this.model.get('name'),
|
|
||||||
buttons,
|
|
||||||
tableContent
|
|
||||||
);
|
|
||||||
},
|
|
||||||
//index functions
|
|
||||||
resetIndexForms: function () {
|
|
||||||
$('#indexHeader input').val('').prop("checked", false);
|
|
||||||
$('#newIndexType').val('Cap').prop('selected',true);
|
|
||||||
this.selectIndexType();
|
|
||||||
},
|
|
||||||
|
|
||||||
createIndex: function () {
|
|
||||||
//e.preventDefault();
|
|
||||||
var self = this;
|
|
||||||
var indexType = $('#newIndexType').val();
|
|
||||||
var result;
|
|
||||||
var postParameter = {};
|
|
||||||
var fields;
|
|
||||||
var unique;
|
|
||||||
var sparse;
|
|
||||||
|
|
||||||
switch (indexType) {
|
|
||||||
case 'Cap':
|
|
||||||
var size = parseInt($('#newCapSize').val(), 10) || 0;
|
|
||||||
var byteSize = parseInt($('#newCapByteSize').val(), 10) || 0;
|
|
||||||
postParameter = {
|
|
||||||
type: 'cap',
|
|
||||||
size: size,
|
|
||||||
byteSize: byteSize
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
case 'Geo':
|
|
||||||
//HANDLE ARRAY building
|
|
||||||
fields = $('#newGeoFields').val();
|
|
||||||
var geoJson = self.checkboxToValue('#newGeoJson');
|
|
||||||
var constraint = self.checkboxToValue('#newGeoConstraint');
|
|
||||||
var ignoreNull = self.checkboxToValue('#newGeoIgnoreNull');
|
|
||||||
postParameter = {
|
|
||||||
type: 'geo',
|
|
||||||
fields: self.stringToArray(fields),
|
|
||||||
geoJson: geoJson,
|
|
||||||
constraint: constraint,
|
|
||||||
ignoreNull: ignoreNull
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
case 'Hash':
|
|
||||||
fields = $('#newHashFields').val();
|
|
||||||
unique = self.checkboxToValue('#newHashUnique');
|
|
||||||
sparse = self.checkboxToValue('#newHashSparse');
|
|
||||||
postParameter = {
|
|
||||||
type: 'hash',
|
|
||||||
fields: self.stringToArray(fields),
|
|
||||||
unique: unique,
|
|
||||||
sparse: sparse
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
case 'Fulltext':
|
|
||||||
fields = ($('#newFulltextFields').val());
|
|
||||||
var minLength = parseInt($('#newFulltextMinLength').val(), 10) || 0;
|
|
||||||
postParameter = {
|
|
||||||
type: 'fulltext',
|
|
||||||
fields: self.stringToArray(fields),
|
|
||||||
minLength: minLength
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
case 'Skiplist':
|
|
||||||
fields = $('#newSkiplistFields').val();
|
|
||||||
unique = self.checkboxToValue('#newSkiplistUnique');
|
|
||||||
sparse = self.checkboxToValue('#newSkiplistSparse');
|
|
||||||
postParameter = {
|
|
||||||
type: 'skiplist',
|
|
||||||
fields: self.stringToArray(fields),
|
|
||||||
unique: unique,
|
|
||||||
sparse: sparse
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
var callback = function(error, msg){
|
|
||||||
if (error) {
|
|
||||||
if (msg) {
|
|
||||||
var message = JSON.parse(msg.responseText);
|
|
||||||
arangoHelper.arangoError("Document error", message.errorMessage);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
arangoHelper.arangoError("Document error", "Could not create index.");
|
var journalSize = data.journalSize/(1024*1024);
|
||||||
|
var indexBuckets = data.indexBuckets;
|
||||||
|
var wfs = data.waitForSync;
|
||||||
|
|
||||||
|
tableContent.push(
|
||||||
|
window.modalView.createTextEntry(
|
||||||
|
"change-collection-size",
|
||||||
|
"Journal size",
|
||||||
|
journalSize,
|
||||||
|
"The maximal size of a journal or datafile (in MB). Must be at least 1.",
|
||||||
|
"",
|
||||||
|
true,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
rule: Joi.string().allow('').optional().regex(/^[0-9]*$/),
|
||||||
|
msg: "Must be a number."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
tableContent.push(
|
||||||
|
window.modalView.createTextEntry(
|
||||||
|
"change-index-buckets",
|
||||||
|
"Index buckets",
|
||||||
|
indexBuckets,
|
||||||
|
"The number of index buckets for this collection. Must be at least 1 and a power of 2.",
|
||||||
|
"",
|
||||||
|
true,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
rule: Joi.string().allow('').optional().regex(/^[1-9][0-9]*$/),
|
||||||
|
msg: "Must be a number greater than 1 and a power of 2."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// prevent "unexpected sync method error"
|
||||||
|
tableContent.push(
|
||||||
|
window.modalView.createSelectEntry(
|
||||||
|
"change-collection-sync",
|
||||||
|
"Wait for sync",
|
||||||
|
wfs,
|
||||||
|
"Synchronize to disk before returning from a create or update of a document.",
|
||||||
|
[{value: false, label: "No"}, {value: true, label: "Yes"}] )
|
||||||
|
);
|
||||||
|
|
||||||
|
tableContent.push(
|
||||||
|
window.modalView.createReadOnlyEntry(
|
||||||
|
"change-collection-id", "ID", this.model.get('id'), ""
|
||||||
|
)
|
||||||
|
);
|
||||||
|
tableContent.push(
|
||||||
|
window.modalView.createReadOnlyEntry(
|
||||||
|
"change-collection-type", "Type", this.model.get('type'), ""
|
||||||
|
)
|
||||||
|
);
|
||||||
|
tableContent.push(
|
||||||
|
window.modalView.createReadOnlyEntry(
|
||||||
|
"change-collection-status", "Status", this.model.get('status'), ""
|
||||||
|
)
|
||||||
|
);
|
||||||
|
buttons.push(
|
||||||
|
window.modalView.createDeleteButton(
|
||||||
|
"Delete",
|
||||||
|
this.deleteCollection.bind(this)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
buttons.push(
|
||||||
|
window.modalView.createDeleteButton(
|
||||||
|
"Truncate",
|
||||||
|
this.truncateCollection.bind(this)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if (collectionIsLoaded) {
|
||||||
|
buttons.push(
|
||||||
|
window.modalView.createNotificationButton(
|
||||||
|
"Unload",
|
||||||
|
this.unloadCollection.bind(this)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
buttons.push(
|
||||||
|
window.modalView.createNotificationButton(
|
||||||
|
"Load",
|
||||||
|
this.loadCollection.bind(this)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
buttons.push(
|
||||||
|
window.modalView.createSuccessButton(
|
||||||
|
"Save",
|
||||||
|
this.saveModifiedCollection.bind(this)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
var tabBar = ["General", "Indices"],
|
||||||
|
templates = ["modalTable.ejs", "indicesView.ejs"];
|
||||||
|
|
||||||
|
window.modalView.show(
|
||||||
|
templates,
|
||||||
|
"Modify Collection",
|
||||||
|
buttons,
|
||||||
|
tableContent, null, null,
|
||||||
|
this.events, null,
|
||||||
|
tabBar
|
||||||
|
);
|
||||||
|
if (this.model.get("status") === 'loaded') {
|
||||||
|
this.getIndex();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$($('#infoTab').children()[1]).remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.refreshCollectionsView();
|
|
||||||
|
}.bind(this);
|
||||||
|
|
||||||
|
this.model.getProperties(callback);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
bindIndexEvents: function() {
|
||||||
|
this.unbindIndexEvents();
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
$('#indexEditView #addIndex').bind('click', function() {
|
||||||
|
self.toggleNewIndexView();
|
||||||
|
|
||||||
|
$('#cancelIndex').unbind('click');
|
||||||
|
$('#cancelIndex').bind('click', function() {
|
||||||
|
self.toggleNewIndexView();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#createIndex').unbind('click');
|
||||||
|
$('#createIndex').bind('click', function() {
|
||||||
|
self.createIndex();
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#newIndexType').bind('change', function() {
|
||||||
|
self.selectIndexType();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.deleteIndex').bind('click', function(e) {
|
||||||
|
console.log("asdasd");
|
||||||
|
self.prepDeleteIndex(e);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#infoTab a').bind('click', function(e) {
|
||||||
|
$('#indexDeleteModal').remove();
|
||||||
|
if ($(e.currentTarget).html() === 'Indices' && !$(e.currentTarget).parent().hasClass('active')) {
|
||||||
|
|
||||||
|
$('#newIndexView').hide();
|
||||||
|
$('#indexEditView').show();
|
||||||
|
|
||||||
|
$('#modal-dialog .modal-footer .button-danger').hide();
|
||||||
|
$('#modal-dialog .modal-footer .button-success').hide();
|
||||||
|
$('#modal-dialog .modal-footer .button-notification').hide();
|
||||||
|
//$('#addIndex').detach().appendTo('#modal-dialog .modal-footer');
|
||||||
|
}
|
||||||
|
if ($(e.currentTarget).html() === 'General' && !$(e.currentTarget).parent().hasClass('active')) {
|
||||||
|
$('#modal-dialog .modal-footer .button-danger').show();
|
||||||
|
$('#modal-dialog .modal-footer .button-success').show();
|
||||||
|
$('#modal-dialog .modal-footer .button-notification').show();
|
||||||
|
var elem = $('.index-button-bar')[0];
|
||||||
|
var elem2 = $('.index-button-bar2')[0];
|
||||||
|
//$('#addIndex').detach().appendTo(elem);
|
||||||
|
if ($('#cancelIndex').is(':visible')) {
|
||||||
|
$('#cancelIndex').detach().appendTo(elem2);
|
||||||
|
$('#createIndex').detach().appendTo(elem2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
unbindIndexEvents: function() {
|
||||||
|
$('#indexEditView #addIndex').unbind('click');
|
||||||
|
$('#newIndexType').unbind('change');
|
||||||
|
$('#infoTab a').unbind('click');
|
||||||
|
$('.deleteIndex').unbind('click');
|
||||||
|
/*
|
||||||
|
//$('#documentsToolbar ul').unbind('click');
|
||||||
|
this.markFilterToggle();
|
||||||
|
this.changeEditMode(false);
|
||||||
|
0Ads0asd0sd0f0asdf0sa0f
|
||||||
|
"click #documentsToolbar ul" : "resetIndexForms"
|
||||||
|
*/
|
||||||
|
},
|
||||||
|
|
||||||
|
createInfoModal: function() {
|
||||||
|
|
||||||
|
var callbackRev = function(error, revision, figures) {
|
||||||
|
if (error) {
|
||||||
|
arangoHelper.arangoError("Figures", "Could not get revision.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var buttons = [];
|
||||||
|
var tableContent = {
|
||||||
|
figures: figures,
|
||||||
|
revision: revision,
|
||||||
|
model: this.model
|
||||||
|
};
|
||||||
|
window.modalView.show(
|
||||||
|
"modalCollectionInfo.ejs",
|
||||||
|
"Collection: " + this.model.get('name'),
|
||||||
|
buttons,
|
||||||
|
tableContent
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}.bind(this);
|
||||||
|
|
||||||
|
var callback = function(error, data) {
|
||||||
|
if (error) {
|
||||||
|
arangoHelper.arangoError("Figures", "Could not get figures.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var figures = data;
|
||||||
|
this.model.getRevision(callbackRev, figures);
|
||||||
|
}
|
||||||
|
}.bind(this);
|
||||||
|
|
||||||
|
this.model.getFigures(callback);
|
||||||
|
},
|
||||||
|
//index functions
|
||||||
|
resetIndexForms: function () {
|
||||||
|
$('#indexHeader input').val('').prop("checked", false);
|
||||||
|
$('#newIndexType').val('Cap').prop('selected',true);
|
||||||
|
this.selectIndexType();
|
||||||
|
},
|
||||||
|
|
||||||
|
createIndex: function () {
|
||||||
|
//e.preventDefault();
|
||||||
|
var self = this;
|
||||||
|
var indexType = $('#newIndexType').val();
|
||||||
|
var postParameter = {};
|
||||||
|
var fields;
|
||||||
|
var unique;
|
||||||
|
var sparse;
|
||||||
|
|
||||||
|
switch (indexType) {
|
||||||
|
case 'Cap':
|
||||||
|
var size = parseInt($('#newCapSize').val(), 10) || 0;
|
||||||
|
var byteSize = parseInt($('#newCapByteSize').val(), 10) || 0;
|
||||||
|
postParameter = {
|
||||||
|
type: 'cap',
|
||||||
|
size: size,
|
||||||
|
byteSize: byteSize
|
||||||
};
|
};
|
||||||
|
break;
|
||||||
|
case 'Geo':
|
||||||
|
//HANDLE ARRAY building
|
||||||
|
fields = $('#newGeoFields').val();
|
||||||
|
var geoJson = self.checkboxToValue('#newGeoJson');
|
||||||
|
var constraint = self.checkboxToValue('#newGeoConstraint');
|
||||||
|
var ignoreNull = self.checkboxToValue('#newGeoIgnoreNull');
|
||||||
|
postParameter = {
|
||||||
|
type: 'geo',
|
||||||
|
fields: self.stringToArray(fields),
|
||||||
|
geoJson: geoJson,
|
||||||
|
constraint: constraint,
|
||||||
|
ignoreNull: ignoreNull
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
case 'Hash':
|
||||||
|
fields = $('#newHashFields').val();
|
||||||
|
unique = self.checkboxToValue('#newHashUnique');
|
||||||
|
sparse = self.checkboxToValue('#newHashSparse');
|
||||||
|
postParameter = {
|
||||||
|
type: 'hash',
|
||||||
|
fields: self.stringToArray(fields),
|
||||||
|
unique: unique,
|
||||||
|
sparse: sparse
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
case 'Fulltext':
|
||||||
|
fields = ($('#newFulltextFields').val());
|
||||||
|
var minLength = parseInt($('#newFulltextMinLength').val(), 10) || 0;
|
||||||
|
postParameter = {
|
||||||
|
type: 'fulltext',
|
||||||
|
fields: self.stringToArray(fields),
|
||||||
|
minLength: minLength
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
case 'Skiplist':
|
||||||
|
fields = $('#newSkiplistFields').val();
|
||||||
|
unique = self.checkboxToValue('#newSkiplistUnique');
|
||||||
|
sparse = self.checkboxToValue('#newSkiplistSparse');
|
||||||
|
postParameter = {
|
||||||
|
type: 'skiplist',
|
||||||
|
fields: self.stringToArray(fields),
|
||||||
|
unique: unique,
|
||||||
|
sparse: sparse
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
var callback = function(error, msg){
|
||||||
|
if (error) {
|
||||||
|
if (msg) {
|
||||||
|
var message = JSON.parse(msg.responseText);
|
||||||
|
arangoHelper.arangoError("Document error", message.errorMessage);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
arangoHelper.arangoError("Document error", "Could not create index.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.refreshCollectionsView();
|
||||||
|
};
|
||||||
|
|
||||||
window.modalView.hide();
|
window.modalView.hide();
|
||||||
//$($('#infoTab').children()[1]).find('a').click();
|
//$($('#infoTab').children()[1]).find('a').click();
|
||||||
self.model.createIndex(postParameter, callback);
|
self.model.createIndex(postParameter, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
lastTarget: null,
|
lastTarget: null,
|
||||||
|
|
||||||
prepDeleteIndex: function (e) {
|
prepDeleteIndex: function (e) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.lastTarget = e;
|
this.lastTarget = e;
|
||||||
|
|
||||||
this.lastId = $(this.lastTarget.currentTarget).
|
this.lastId = $(this.lastTarget.currentTarget).
|
||||||
parent().
|
parent().
|
||||||
parent().
|
parent().
|
||||||
first().
|
first().
|
||||||
children().
|
children().
|
||||||
first().
|
first().
|
||||||
text();
|
text();
|
||||||
//window.modalView.hide();
|
//window.modalView.hide();
|
||||||
|
|
||||||
//delete modal
|
//delete modal
|
||||||
$("#modal-dialog .modal-footer").after(
|
$("#modal-dialog .modal-footer").after(
|
||||||
'<div id="indexDeleteModal" style="display:block;" class="alert alert-error modal-delete-confirmation">' +
|
'<div id="indexDeleteModal" style="display:block;" class="alert alert-error modal-delete-confirmation">' +
|
||||||
'<strong>Really delete?</strong>' +
|
'<strong>Really delete?</strong>' +
|
||||||
'<button id="indexConfirmDelete" class="button-danger pull-right modal-confirm-delete">Yes</button>' +
|
'<button id="indexConfirmDelete" class="button-danger pull-right modal-confirm-delete">Yes</button>' +
|
||||||
'<button id="indexAbortDelete" class="button-neutral pull-right">No</button>' +
|
'<button id="indexAbortDelete" class="button-neutral pull-right">No</button>' +
|
||||||
'</div>');
|
'</div>');
|
||||||
$('#indexConfirmDelete').unbind('click');
|
$('#indexConfirmDelete').unbind('click');
|
||||||
$('#indexConfirmDelete').bind('click', function() {
|
$('#indexConfirmDelete').bind('click', function() {
|
||||||
|
@ -596,98 +627,98 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
refreshCollectionsView: function() {
|
refreshCollectionsView: function() {
|
||||||
window.App.arangoCollectionsStore.fetch({
|
window.App.arangoCollectionsStore.fetch({
|
||||||
success: function () {
|
success: function () {
|
||||||
window.App.collectionsView.render();
|
window.App.collectionsView.render();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteIndex: function () {
|
deleteIndex: function () {
|
||||||
var callback = function(error) {
|
var callback = function(error) {
|
||||||
if (error) {
|
if (error) {
|
||||||
arangoHelper.arangoError("Could not delete index");
|
arangoHelper.arangoError("Could not delete index");
|
||||||
$("tr th:contains('"+ this.lastId+"')").parent().children().last().html(
|
$("tr th:contains('"+ this.lastId+"')").parent().children().last().html(
|
||||||
'<span class="deleteIndex icon_arangodb_roundminus"' +
|
'<span class="deleteIndex icon_arangodb_roundminus"' +
|
||||||
' data-original-title="Delete index" title="Delete index"></span>'
|
' data-original-title="Delete index" title="Delete index"></span>'
|
||||||
);
|
);
|
||||||
this.model.set("locked", false);
|
this.model.set("locked", false);
|
||||||
this.refreshCollectionsView();
|
|
||||||
}
|
|
||||||
else if (!error && error !== undefined) {
|
|
||||||
$("tr th:contains('"+ this.lastId+"')").parent().remove();
|
|
||||||
this.model.set("locked", false);
|
|
||||||
this.refreshCollectionsView();
|
|
||||||
}
|
|
||||||
this.refreshCollectionsView();
|
this.refreshCollectionsView();
|
||||||
}.bind(this);
|
}
|
||||||
|
else if (!error && error !== undefined) {
|
||||||
|
$("tr th:contains('"+ this.lastId+"')").parent().remove();
|
||||||
|
this.model.set("locked", false);
|
||||||
|
this.refreshCollectionsView();
|
||||||
|
}
|
||||||
|
this.refreshCollectionsView();
|
||||||
|
}.bind(this);
|
||||||
|
|
||||||
this.model.set("locked", true);
|
this.model.set("locked", true);
|
||||||
this.model.deleteIndex(this.lastId, callback);
|
this.model.deleteIndex(this.lastId, callback);
|
||||||
|
|
||||||
$("tr th:contains('"+ this.lastId+"')").parent().children().last().html(
|
$("tr th:contains('"+ this.lastId+"')").parent().children().last().html(
|
||||||
'<i class="fa fa-circle-o-notch fa-spin"></i>'
|
'<i class="fa fa-circle-o-notch fa-spin"></i>'
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
selectIndexType: function () {
|
selectIndexType: function () {
|
||||||
$('.newIndexClass').hide();
|
$('.newIndexClass').hide();
|
||||||
var type = $('#newIndexType').val();
|
var type = $('#newIndexType').val();
|
||||||
$('#newIndexType'+type).show();
|
$('#newIndexType'+type).show();
|
||||||
},
|
},
|
||||||
|
|
||||||
getIndex: function () {
|
getIndex: function () {
|
||||||
|
|
||||||
var callback = function(error, data) {
|
var callback = function(error, data) {
|
||||||
if (error) {
|
if (error) {
|
||||||
window.arangoHelper.arangoError('Index', data.errorMessage);
|
window.arangoHelper.arangoError('Index', data.errorMessage);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.renderIndex(data);
|
||||||
|
}
|
||||||
|
}.bind(this);
|
||||||
|
|
||||||
|
this.model.getIndex(callback);
|
||||||
|
},
|
||||||
|
|
||||||
|
renderIndex: function(data) {
|
||||||
|
|
||||||
|
this.index = data;
|
||||||
|
|
||||||
|
var cssClass = 'collectionInfoTh modal-text';
|
||||||
|
if (this.index) {
|
||||||
|
var fieldString = '';
|
||||||
|
var actionString = '';
|
||||||
|
|
||||||
|
_.each(this.index.indexes, function(v) {
|
||||||
|
if (v.type === 'primary' || v.type === 'edge') {
|
||||||
|
actionString = '<span class="icon_arangodb_locked" ' +
|
||||||
|
'data-original-title="No action"></span>';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.renderIndex(data);
|
actionString = '<span class="deleteIndex icon_arangodb_roundminus" ' +
|
||||||
|
'data-original-title="Delete index" title="Delete index"></span>';
|
||||||
}
|
}
|
||||||
}.bind(this);
|
|
||||||
|
|
||||||
this.model.getIndex(callback);
|
if (v.fields !== undefined) {
|
||||||
},
|
fieldString = v.fields.join(", ");
|
||||||
|
}
|
||||||
|
|
||||||
renderIndex: function(data) {
|
//cut index id
|
||||||
|
var position = v.id.indexOf('/');
|
||||||
this.index = data;
|
var indexId = v.id.substr(position + 1, v.id.length);
|
||||||
|
var selectivity = (
|
||||||
var cssClass = 'collectionInfoTh modal-text';
|
v.hasOwnProperty("selectivityEstimate") ?
|
||||||
if (this.index) {
|
|
||||||
var fieldString = '';
|
|
||||||
var actionString = '';
|
|
||||||
|
|
||||||
_.each(this.index.indexes, function(v) {
|
|
||||||
if (v.type === 'primary' || v.type === 'edge') {
|
|
||||||
actionString = '<span class="icon_arangodb_locked" ' +
|
|
||||||
'data-original-title="No action"></span>';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
actionString = '<span class="deleteIndex icon_arangodb_roundminus" ' +
|
|
||||||
'data-original-title="Delete index" title="Delete index"></span>';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (v.fields !== undefined) {
|
|
||||||
fieldString = v.fields.join(", ");
|
|
||||||
}
|
|
||||||
|
|
||||||
//cut index id
|
|
||||||
var position = v.id.indexOf('/');
|
|
||||||
var indexId = v.id.substr(position + 1, v.id.length);
|
|
||||||
var selectivity = (
|
|
||||||
v.hasOwnProperty("selectivityEstimate") ?
|
|
||||||
(v.selectivityEstimate * 100).toFixed(2) + "%" :
|
(v.selectivityEstimate * 100).toFixed(2) + "%" :
|
||||||
"n/a"
|
"n/a"
|
||||||
);
|
);
|
||||||
var sparse = (v.hasOwnProperty("sparse") ? v.sparse : "n/a");
|
var sparse = (v.hasOwnProperty("sparse") ? v.sparse : "n/a");
|
||||||
|
|
||||||
$('#collectionEditIndexTable').append(
|
$('#collectionEditIndexTable').append(
|
||||||
'<tr>' +
|
'<tr>' +
|
||||||
'<th class=' + JSON.stringify(cssClass) + '>' + indexId + '</th>' +
|
'<th class=' + JSON.stringify(cssClass) + '>' + indexId + '</th>' +
|
||||||
'<th class=' + JSON.stringify(cssClass) + '>' + v.type + '</th>' +
|
'<th class=' + JSON.stringify(cssClass) + '>' + v.type + '</th>' +
|
||||||
'<th class=' + JSON.stringify(cssClass) + '>' + v.unique + '</th>' +
|
'<th class=' + JSON.stringify(cssClass) + '>' + v.unique + '</th>' +
|
||||||
|
@ -696,49 +727,49 @@
|
||||||
'<th class=' + JSON.stringify(cssClass) + '>' + fieldString + '</th>' +
|
'<th class=' + JSON.stringify(cssClass) + '>' + fieldString + '</th>' +
|
||||||
'<th class=' + JSON.stringify(cssClass) + '>' + actionString + '</th>' +
|
'<th class=' + JSON.stringify(cssClass) + '>' + actionString + '</th>' +
|
||||||
'</tr>'
|
'</tr>'
|
||||||
);
|
);
|
||||||
});
|
|
||||||
}
|
|
||||||
this.bindIndexEvents();
|
|
||||||
},
|
|
||||||
|
|
||||||
toggleNewIndexView: function () {
|
|
||||||
var elem = $('.index-button-bar2')[0];
|
|
||||||
var elem2 = $('.index-button-bar')[0];
|
|
||||||
if ($('#indexEditView').is(':visible')) {
|
|
||||||
$('#indexEditView').hide();
|
|
||||||
$('#newIndexView').show();
|
|
||||||
//$('#addIndex').detach().appendTo(elem2);
|
|
||||||
$('#cancelIndex').detach().appendTo('#modal-dialog .modal-footer');
|
|
||||||
$('#createIndex').detach().appendTo('#modal-dialog .modal-footer');
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$('#indexEditView').show();
|
|
||||||
$('#newIndexView').hide();
|
|
||||||
//$('#addIndex').detach().appendTo('#modal-dialog .modal-footer');
|
|
||||||
$('#cancelIndex').detach().appendTo(elem);
|
|
||||||
$('#createIndex').detach().appendTo(elem);
|
|
||||||
}
|
|
||||||
|
|
||||||
arangoHelper.fixTooltips(".icon_arangodb, .arangoicon", "right");
|
|
||||||
this.resetIndexForms();
|
|
||||||
},
|
|
||||||
|
|
||||||
stringToArray: function (fieldString) {
|
|
||||||
var fields = [];
|
|
||||||
fieldString.split(',').forEach(function(field){
|
|
||||||
field = field.replace(/(^\s+|\s+$)/g,'');
|
|
||||||
if (field !== '') {
|
|
||||||
fields.push(field);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return fields;
|
|
||||||
},
|
|
||||||
|
|
||||||
checkboxToValue: function (id) {
|
|
||||||
return $(id).prop('checked');
|
|
||||||
}
|
}
|
||||||
|
this.bindIndexEvents();
|
||||||
|
},
|
||||||
|
|
||||||
|
toggleNewIndexView: function () {
|
||||||
|
var elem = $('.index-button-bar2')[0];
|
||||||
|
var elem2 = $('.index-button-bar')[0];
|
||||||
|
if ($('#indexEditView').is(':visible')) {
|
||||||
|
$('#indexEditView').hide();
|
||||||
|
$('#newIndexView').show();
|
||||||
|
//$('#addIndex').detach().appendTo(elem2);
|
||||||
|
$('#cancelIndex').detach().appendTo('#modal-dialog .modal-footer');
|
||||||
|
$('#createIndex').detach().appendTo('#modal-dialog .modal-footer');
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('#indexEditView').show();
|
||||||
|
$('#newIndexView').hide();
|
||||||
|
//$('#addIndex').detach().appendTo('#modal-dialog .modal-footer');
|
||||||
|
$('#cancelIndex').detach().appendTo(elem);
|
||||||
|
$('#createIndex').detach().appendTo(elem);
|
||||||
|
}
|
||||||
|
|
||||||
|
arangoHelper.fixTooltips(".icon_arangodb, .arangoicon", "right");
|
||||||
|
this.resetIndexForms();
|
||||||
|
},
|
||||||
|
|
||||||
|
stringToArray: function (fieldString) {
|
||||||
|
var fields = [];
|
||||||
|
fieldString.split(',').forEach(function(field){
|
||||||
|
field = field.replace(/(^\s+|\s+$)/g,'');
|
||||||
|
if (field !== '') {
|
||||||
|
fields.push(field);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return fields;
|
||||||
|
},
|
||||||
|
|
||||||
|
checkboxToValue: function (id) {
|
||||||
|
return $(id).prop('checked');
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
|
Loading…
Reference in New Issue