mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'sharding' of https://github.com/triAGENS/ArangoDB into sharding
This commit is contained in:
commit
fc84d4c005
|
@ -131,6 +131,8 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "linenoise.h"
|
||||
#include "utf8.h"
|
||||
|
@ -167,6 +169,7 @@ struct current {
|
|||
int chars; /* Number of chars in 'buf' (utf-8 chars) */
|
||||
int pos; /* Cursor position, measured in chars */
|
||||
int cols; /* Size of the window, in chars */
|
||||
int rows; /* Screen rows */
|
||||
const char *prompt;
|
||||
char *capture; /* Allocated capture buffer, or NULL for none. Always null terminated */
|
||||
#if defined(USE_TERMIOS)
|
||||
|
@ -174,7 +177,6 @@ struct current {
|
|||
#elif defined(USE_WINCONSOLE)
|
||||
HANDLE outh; /* Console output handle */
|
||||
HANDLE inh; /* Console input handle */
|
||||
int rows; /* Screen rows */
|
||||
int x; /* Current column during output */
|
||||
int y; /* Current row */
|
||||
#endif
|
||||
|
@ -182,6 +184,10 @@ struct current {
|
|||
|
||||
static int fd_read(struct current *current);
|
||||
static int getWindowSize(struct current *current);
|
||||
static void set_current(struct current *current, const char *str);
|
||||
static void refreshLine(const char *prompt, struct current *current);
|
||||
static void refreshPage(const struct linenoiseCompletions * lc, struct current *current);
|
||||
|
||||
|
||||
void linenoiseHistoryFree(void) {
|
||||
if (history) {
|
||||
|
@ -308,6 +314,11 @@ static int outputChars(struct current *current, const char *buf, int len)
|
|||
return write(current->fd, buf, len);
|
||||
}
|
||||
|
||||
static int newLine(struct current *current)
|
||||
{
|
||||
return outputChars(current, "\n", 1);
|
||||
}
|
||||
|
||||
static void outputControlChar(struct current *current, char ch)
|
||||
{
|
||||
fd_printf(current->fd, "\x1b[7m^%c\x1b[0m", ch);
|
||||
|
@ -393,7 +404,7 @@ static int countColorControlChars(const char* prompt)
|
|||
expect_bracket,
|
||||
expect_trail
|
||||
} state = search_esc;
|
||||
int len = 0, found = 0;
|
||||
int len = 0, found = 0, flags_counter = 0;
|
||||
char ch;
|
||||
|
||||
/* XXX: Strictly we should be checking utf8 chars rather than
|
||||
|
@ -405,6 +416,10 @@ static int countColorControlChars(const char* prompt)
|
|||
case search_esc:
|
||||
if (ch == '\x1b') {
|
||||
state = expect_bracket;
|
||||
} else {
|
||||
if(2>=(int)ch) {
|
||||
flags_counter += 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case expect_bracket:
|
||||
|
@ -430,7 +445,7 @@ static int countColorControlChars(const char* prompt)
|
|||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
return found + flags_counter;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -482,6 +497,7 @@ static int getWindowSize(struct current *current)
|
|||
|
||||
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == 0 && ws.ws_col != 0) {
|
||||
current->cols = ws.ws_col;
|
||||
current->rows = ws.ws_row;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -630,6 +646,7 @@ static void disableRawMode(struct current *current)
|
|||
static void clearScreen(struct current *current)
|
||||
{
|
||||
COORD topleft = { 0, 0 };
|
||||
current->x = current->y = 0;
|
||||
DWORD n;
|
||||
|
||||
FillConsoleOutputCharacter(current->outh, ' ',
|
||||
|
@ -650,13 +667,22 @@ static void cursorToLeft(struct current *current)
|
|||
current->x = 0;
|
||||
}
|
||||
|
||||
static int newLine(struct current *current)
|
||||
{
|
||||
current->y += 1;
|
||||
COORD pos = { (SHORT)0, (SHORT)current->y };
|
||||
DWORD n;
|
||||
SetConsoleCursorPosition(current->outh, pos);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int outputChars(struct current *current, const char *buf, int len)
|
||||
{
|
||||
COORD pos = { (SHORT)current->x, (SHORT)current->y };
|
||||
DWORD n;
|
||||
|
||||
WriteConsoleOutputCharacter(current->outh, buf, len, pos, &n);
|
||||
current->x += len;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -786,7 +812,78 @@ static int get_char(struct current *current, int pos)
|
|||
}
|
||||
return -1;
|
||||
}
|
||||
static void displayItems(const struct linenoiseCompletions * lc, struct current *current, int max_len)
|
||||
{
|
||||
int wcols;
|
||||
int cols;
|
||||
int rows;
|
||||
int i, j;
|
||||
|
||||
getWindowSize(current);
|
||||
wcols = current->cols;
|
||||
cols = max_len > wcols ? 1 : wcols/(max_len+2);
|
||||
rows = (int)ceil((float)lc->len/cols);
|
||||
|
||||
for(i=0;i<rows; i++) {
|
||||
newLine(current);
|
||||
for(j=0; j<cols; j++){
|
||||
int idx;
|
||||
const char * row_content;
|
||||
setCursorPos(current, j * (max_len + 2));
|
||||
idx = j*rows +i;
|
||||
if(idx>=lc->len) {
|
||||
break;
|
||||
}
|
||||
row_content = lc->cvec[j * rows + i];
|
||||
outputChars(current, row_content, strlen(row_content));
|
||||
}
|
||||
}
|
||||
newLine(current);
|
||||
}
|
||||
|
||||
static void refreshPage(const struct linenoiseCompletions * lc, struct current *current)
|
||||
{
|
||||
int j;
|
||||
size_t common_min_len = INT_MAX;
|
||||
size_t max_len = 0;
|
||||
char * min_chars = NULL;
|
||||
for(j=0; j<lc->len; j++) {
|
||||
size_t j_len = strlen(lc->cvec[j]);
|
||||
if(min_chars == NULL) {
|
||||
min_chars = lc->cvec[j];
|
||||
common_min_len = j_len;
|
||||
max_len = strlen(lc->cvec[j]);
|
||||
} else {
|
||||
/*
|
||||
* compute maximal length of common string
|
||||
*/
|
||||
size_t tmp_len = 0;
|
||||
char * c_min_char = min_chars;
|
||||
char * j_chars = lc->cvec[j];
|
||||
int k=0;
|
||||
while(c_min_char[k] == j_chars[k]) {
|
||||
tmp_len++;
|
||||
k += 1;
|
||||
}
|
||||
if(common_min_len > tmp_len && tmp_len>0) {
|
||||
common_min_len = tmp_len;
|
||||
}
|
||||
max_len = max_len < strlen(lc->cvec[j]) ? strlen(lc->cvec[j]) : max_len;
|
||||
}
|
||||
}
|
||||
displayItems(lc, current, max_len);
|
||||
newLine(current);
|
||||
if(min_chars!=NULL) {
|
||||
// char * new_buf = strndup(min_chars, common_min_len);
|
||||
char * new_buf = malloc(common_min_len + 1);
|
||||
memcpy(new_buf, min_chars, common_min_len);
|
||||
new_buf[common_min_len] = '\0';
|
||||
set_current(current, new_buf);
|
||||
// this is posible because set_current copies the given pointer
|
||||
free(new_buf);
|
||||
}
|
||||
refreshLine(current->prompt, current);
|
||||
}
|
||||
static void refreshLine(const char *prompt, struct current *current)
|
||||
{
|
||||
int plen;
|
||||
|
@ -805,7 +902,6 @@ static void refreshLine(const char *prompt, struct current *current)
|
|||
|
||||
plen = strlen(prompt);
|
||||
pchars = utf8_strlen(prompt, plen);
|
||||
|
||||
/* Scan the prompt for embedded ansi color control sequences and
|
||||
* discount them as characters/columns.
|
||||
*/
|
||||
|
@ -881,10 +977,9 @@ static void refreshLine(const char *prompt, struct current *current)
|
|||
}
|
||||
}
|
||||
outputChars(current, buf, b);
|
||||
|
||||
/* Erase to right, move cursor to original position */
|
||||
eraseEol(current);
|
||||
setCursorPos(current, pos + pchars + backup);
|
||||
setCursorPos(current, pos + pchars + backup );
|
||||
}
|
||||
|
||||
static void set_current(struct current *current, const char *str)
|
||||
|
@ -1055,7 +1150,7 @@ static void freeCompletions(linenoiseCompletions *lc) {
|
|||
}
|
||||
|
||||
static int completeLine(struct current *current) {
|
||||
linenoiseCompletions lc = { 0, NULL };
|
||||
linenoiseCompletions lc = { 0, NULL, 0 };
|
||||
int c = 0;
|
||||
|
||||
completionCallback(current->buf,&lc);
|
||||
|
@ -1064,6 +1159,12 @@ static int completeLine(struct current *current) {
|
|||
} else {
|
||||
size_t stop = 0, i = 0;
|
||||
|
||||
if(lc.len>1 && lc.multiLine) {
|
||||
refreshPage(&lc, current);
|
||||
freeCompletions(&lc);
|
||||
return c;
|
||||
}
|
||||
|
||||
while(!stop) {
|
||||
/* Show completion or original buffer */
|
||||
if (i < lc.len) {
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
typedef struct linenoiseCompletions {
|
||||
size_t len;
|
||||
char **cvec;
|
||||
int multiLine;
|
||||
} linenoiseCompletions;
|
||||
|
||||
typedef void(linenoiseCompletionCallback)(const char *, linenoiseCompletions *);
|
||||
|
|
|
@ -22,6 +22,6 @@ if (list.length > 1) {
|
|||
%>
|
||||
<% if (current === "_system") { %>
|
||||
<li class="dropdown-header">Manager</li>
|
||||
<li id="databaseNavi" class="databases-menu"><a id="databases" class="" href="#databases">Manage DBs</a></li>
|
||||
<li id="databaseNavi" class="dropdown-item"><a id="databases" class="" href="#databases">Manage DBs</a></li>
|
||||
<% } %>
|
||||
</ul>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<ul class="navlist" id="arangoCollectionUl">
|
||||
<!-- <li class="dashboard-menu"><a id="dashboard" class="tab" href="#dashboard">Dashboard</a></li>-->
|
||||
|
||||
<li id="dbSelect" class="dropdown"></li>
|
||||
<li id="dbSelect" class="dropdown databases-menu"></li>
|
||||
<li class="collections-menu"><a id="collections" class="tab" href="#collections">Collections</a></li>
|
||||
<li class="graphviewer-menu"><a id="graph" class="tab" href="#graph">Graphs</a></li>
|
||||
<li class="applications-menu"><a id="applications" class="tab" href="#applications">Applications</a></li>
|
||||
|
@ -10,7 +10,7 @@
|
|||
<li class="dropdown">
|
||||
<a href="#" class="tab" id="tools">Tools <b class="caret"></b></a>
|
||||
<ul class="link-dropdown-menu" id="tools_dropdown">
|
||||
<li class="dropdown-header">BLUBBER</li>
|
||||
<li class="dropdown-header">Tools</li>
|
||||
<li class="dropdown-item">
|
||||
<a id="shell" class="tab" href="#shell">JS Shell</a>
|
||||
</li>
|
||||
|
|
|
@ -189,11 +189,13 @@ module.exports = function(karma) {
|
|||
'frontend/js/views/clusterCollectionView.js',
|
||||
'frontend/js/views/clusterShardsView.js',
|
||||
|
||||
'frontend/js/views/statisticBarView.js',
|
||||
'frontend/js/views/userBarView.js',
|
||||
|
||||
//Views Planner
|
||||
'plannerFrontend/js/views/planScenarioSelectorView.js',
|
||||
'plannerFrontend/js/views/planTestView.js',
|
||||
|
||||
|
||||
// Router
|
||||
'frontend/js/routers/router.js',
|
||||
'plannerFrontend/js/routers/plannerRouter.js',
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
sessionDummy,
|
||||
graphsDummy,
|
||||
foxxDummy,
|
||||
logsDummy;
|
||||
logsDummy,
|
||||
statisticBarDummy,
|
||||
userBarDummy;
|
||||
|
||||
// Spy on all views that are initialized by startup
|
||||
beforeEach(function() {
|
||||
|
@ -66,6 +68,14 @@
|
|||
foxxDummy = {
|
||||
id: "foxxDummy"
|
||||
};
|
||||
statisticBarDummy = {
|
||||
id: "statisticBarDummy",
|
||||
render : function(){}
|
||||
};
|
||||
userBarDummy = {
|
||||
id: "userBarDummy",
|
||||
render : function(){}
|
||||
};
|
||||
spyOn(storeDummy, "fetch");
|
||||
spyOn(window, "arangoCollections").andReturn(storeDummy);
|
||||
spyOn(window, "ArangoUsers").andReturn(sessionDummy);
|
||||
|
@ -103,6 +113,8 @@
|
|||
expect(options.async).toBeFalsy();
|
||||
});
|
||||
spyOn(window, "DBSelectionView");
|
||||
spyOn(window, "StatisticBarView").andReturn(statisticBarDummy);
|
||||
spyOn(window, "UserBarView").andReturn(userBarDummy);
|
||||
});
|
||||
|
||||
describe("initialisation", function() {
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
});
|
||||
fetched = false;
|
||||
spyOn(dbCollection, "fetch");
|
||||
div = document.createElement("div");
|
||||
div = document.createElement("li");
|
||||
div.id = "dbSelect";
|
||||
document.body.appendChild(div);
|
||||
view = new DBSelectionView(
|
||||
|
@ -43,19 +43,21 @@
|
|||
|
||||
it("should display all databases ordered", function() {
|
||||
view.render($(div));
|
||||
var select = $(div).children()[0],
|
||||
var dbList = $("#dbs_dropdown", $(div)),
|
||||
childs;
|
||||
expect(div.childElementCount).toEqual(1);
|
||||
childs = $(select).children();
|
||||
|
||||
expect(div.childElementCount).toEqual(2);
|
||||
childs = $(dbList).children();
|
||||
expect(childs.length).toEqual(3);
|
||||
expect(childs[0].id).toEqual(list[0]);
|
||||
expect(childs[1].id).toEqual(list[2]);
|
||||
expect(childs[2].id).toEqual(list[1]);
|
||||
|
||||
|
||||
expect($("a", $(childs[1])).attr("id")).toEqual(list[0]);
|
||||
expect($("a", $(childs[2])).attr("id")).toEqual(list[1]);
|
||||
});
|
||||
|
||||
it("should select the current db", function() {
|
||||
view.render($(div));
|
||||
expect($(div).find(":selected").attr("id")).toEqual(current.get("name"));
|
||||
expect($($(div).children()[0]).text()).toEqual("DB: " + current.get("name") + " ");
|
||||
});
|
||||
|
||||
it("should trigger fetch on collection", function() {
|
||||
|
@ -84,7 +86,7 @@
|
|||
}
|
||||
);
|
||||
view.render($(div));
|
||||
expect($(div).text().trim()).toEqual("first");
|
||||
expect($(div).text().trim()).toEqual("DB: first");
|
||||
});
|
||||
});
|
||||
}());
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
describe("The navigation bar", function() {
|
||||
|
||||
var div, view, currentDBFake, curName, isSystem;
|
||||
var div, view, currentDBFake, curName, isSystem, DBSelectionViewDummy;
|
||||
|
||||
beforeEach(function() {
|
||||
curName = "_system";
|
||||
|
@ -15,6 +15,13 @@
|
|||
window.currentDB = window.currentDB || {
|
||||
get: function() {}
|
||||
};
|
||||
|
||||
DBSelectionViewDummy = {
|
||||
id : "DBSelectionViewDummy",
|
||||
render : function(){}
|
||||
};
|
||||
|
||||
spyOn(window, "DBSelectionView").andReturn(DBSelectionViewDummy);
|
||||
spyOn(window.currentDB, "get").andCallFake(function(key) {
|
||||
if (key === "name") {
|
||||
return curName;
|
||||
|
@ -40,14 +47,6 @@
|
|||
view.render();
|
||||
});
|
||||
|
||||
it("should offer a dashboard tab", function() {
|
||||
var tab = $("#dashboard", $(div));
|
||||
expect(tab.length).toEqual(1);
|
||||
spyOn(window.App, "navigate");
|
||||
tab.click();
|
||||
expect(window.App.navigate).toHaveBeenCalledWith("dashboard", {trigger: true});
|
||||
});
|
||||
|
||||
it("should offer a collections tab", function() {
|
||||
var tab = $("#collections", $(div));
|
||||
expect(tab.length).toEqual(1);
|
||||
|
@ -106,14 +105,6 @@
|
|||
view.render();
|
||||
});
|
||||
|
||||
it("should offer a databases tab", function() {
|
||||
var tab = $("#databases", $(div));
|
||||
expect(tab.length).toEqual(1);
|
||||
spyOn(window.App, "navigate");
|
||||
tab.click();
|
||||
expect(window.App.navigate).toHaveBeenCalledWith("databases", {trigger: true});
|
||||
});
|
||||
|
||||
it("should offer a logs tab", function() {
|
||||
var tab = $("#logs", $(div));
|
||||
expect(tab.length).toEqual(1);
|
||||
|
@ -132,11 +123,6 @@
|
|||
view.render();
|
||||
});
|
||||
|
||||
it("should not offer a databases tab", function() {
|
||||
var tab = $("#databases", $(div));
|
||||
expect(tab.length).toEqual(0);
|
||||
});
|
||||
|
||||
it("should not offer a logs tab", function() {
|
||||
var tab = $("#logs", $(div));
|
||||
expect(tab.length).toEqual(0);
|
||||
|
|
|
@ -256,7 +256,13 @@ function require (path) {
|
|||
return null;
|
||||
}
|
||||
|
||||
return uri.substr(8);
|
||||
var filename = uri.substr(8);
|
||||
|
||||
if (filename[0] === ".") {
|
||||
return filename;
|
||||
}
|
||||
|
||||
return "/" + filename;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -102,10 +102,12 @@ function CommonJSTestSuite () {
|
|||
var console = require("console");
|
||||
|
||||
function createTestPackage (testPath) {
|
||||
var lib = fs.join(
|
||||
var lib = "./" + fs.join(
|
||||
"./js/common/test-data/modules/commonjs/tests/modules/1.0/",
|
||||
testPath);
|
||||
|
||||
console.log(lib);
|
||||
|
||||
var test = module.createTestEnvironment(lib);
|
||||
|
||||
test.exports.print = require("internal").print;
|
||||
|
|
|
@ -61,12 +61,15 @@ using namespace std;
|
|||
/// @brief word break characters
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRI_HAVE_LINENOISE
|
||||
|
||||
static char WordBreakCharacters[] = {
|
||||
' ', '\t', '\n', '"', '\\', '\'', '`', '@',
|
||||
'<', '>', '=', ';', '|', '&', '{', '}', '(', ')',
|
||||
'\0'
|
||||
};
|
||||
|
||||
#endif
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- private functions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -75,6 +78,8 @@ static char WordBreakCharacters[] = {
|
|||
/// @brief completion generator
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRI_HAVE_LINENOISE
|
||||
|
||||
static char* CompletionGenerator (char const* text, int state) {
|
||||
static size_t currentIndex;
|
||||
static vector<string> result;
|
||||
|
@ -182,11 +187,15 @@ static char* CompletionGenerator (char const* text, int state) {
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief linenoise completion generator
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef TRI_HAVE_LINENOISE
|
||||
|
||||
static void LinenoiseCompletionGenerator (char const* text, linenoiseCompletions * lc) {
|
||||
vector<string> completions;
|
||||
// locate global object or sub-object
|
||||
|
@ -279,6 +288,7 @@ static void LinenoiseCompletionGenerator (char const* text, linenoiseCompletions
|
|||
TRI_FreeString(TRI_CORE_MEM_ZONE, prefix);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -286,9 +296,11 @@ static void LinenoiseCompletionGenerator (char const* text, linenoiseCompletions
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef TRI_HAVE_LINENOISE
|
||||
|
||||
static void AttemptedCompletion(char const* text, linenoiseCompletions * lc) {
|
||||
LinenoiseCompletionGenerator(text, lc);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static char** AttemptedCompletion (char const* text, int start, int end) {
|
||||
|
|
|
@ -16,6 +16,14 @@ AC_ARG_ENABLE(readline,
|
|||
tr_READLINE="maybe"
|
||||
)
|
||||
|
||||
if test "x$tr_DARWIN" = xyes; then
|
||||
if test "x$tr_READLINE" = xyes; then
|
||||
tr_READLINE="linenoise"
|
||||
elif test "x$tr_READLINE" = xreadline; then
|
||||
tr_READLINE="yes"
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_ARG_WITH(readline,
|
||||
AS_HELP_STRING([--with-readline=DIR], [where the readline library and includes are located]),
|
||||
[READLINE_CPPFLAGS="-I$withval/include"
|
||||
|
|
Loading…
Reference in New Issue