diff --git a/.travis.yml b/.travis.yml index d781ca28b2..d6fa54f276 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: c -before_script: "bash -c 'cd UnitTests/HttpInterface && gem install bundler && bundle'" -script: "make setup && ./configure --enable-relative --enable-all-in-one-libev --enable-all-in-one-v8 --enable-all-in-one-icu && make -j2 && make unittests-shell-server unittests-shell-server-ahuacatl unittests-http-server SKIP_RANGES=1 && echo 'done'" +before_script: "bash -c Installation/travisCI/before_script.sh" +script: "bash -c Installation/travisCI/script.sh" branches: only: - master diff --git a/CHANGELOG b/CHANGELOG index 864bf04f68..b309f4fda1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,10 @@ v1.5.0 (XXXX-XX-XX) ------------------- +* added AQL SLICE function to extract slices from lists + +* removed check-server binary + * made module loader more node compatible * the startup option `--javascript.package-path` for arangosh is now deprecated and does diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ea202bb6d..5c2fa64dfa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,6 @@ set(BIN_ARANGOIMP arangoimp) set(BIN_ARANGOIRB arangoirb) set(BIN_ARANGORESTORE arangorestore) set(BIN_ARANGOSH arangosh) -set(BIN_CHECK_SERVER check-server) set(SCRIPT_ARANGO_DFDB arango-dfdb) set(SCRIPT_FOXX_MANAGER foxx-manager) diff --git a/Documentation/UserManual/Aql.md b/Documentation/UserManual/Aql.md index a0eb4994ec..ef7afdb25b 100644 --- a/Documentation/UserManual/Aql.md +++ b/Documentation/UserManual/Aql.md @@ -1113,6 +1113,35 @@ AQL supports the following functions to operate on list values: position only `true` or `false` are returned, depending on whether the sought element is contained in the list. +- @FN{SLICE(@FA{list}, @FA{start}, @FA{length})}: extracts a slice of the list specified + by @FA{list}. The extraction will start at list element with position @FA{start}. + Positions start at 0. Up to @FA{length} elements will be extracted. If @FA{length} is + not specified, all list elements starting at @FA{start} will be returned. + If @FA{start} is negative, it can be used to indicate positions from the end of the + list. + + Examples: + + SLICE([ 1, 2, 3, 4, 5 ], 0, 1) + + will return `[ 1 ]` + + SLICE([ 1, 2, 3, 4, 5 ], 1, 2) + + will return `[ 2, 3 ]` + + SLICE([ 1, 2, 3, 4, 5 ], 3) + + will return `[ 4, 5 ]` + + SLICE([ 1, 2, 3, 4, 5 ], 1, -1) + + will return `[ 2, 3, 4 ]` + + SLICE([ 1, 2, 3, 4, 5 ], 0, -2) + + will return `[ 1, 2, 3 ]` + - @FN{UNIQUE(@FA{list})}: returns all unique elements in @FA{list}. To determine uniqueness, the function will use the comparison order defined in @ref AqlTypeOrder. Calling this function might return the unique elements in any order. @@ -1125,25 +1154,28 @@ AQL supports the following functions to operate on list values: @LIT{UNION_DISTINCT} function or apply the @LIT{UNIQUE} on the result of @LIT{union}. Example: - RETURN UNION( - [ 1, 2, 3 ], - [ 1, 2 ] - ) - - will produce: - [ [ 1, 2, 3, 1, 2 ] ] - - with duplicate removal: - - RETURN UNIQUE( - UNION( + + RETURN UNION( [ 1, 2, 3 ], [ 1, 2 ] ) - ) + + will produce: + + [ [ 1, 2, 3, 1, 2 ] ] + + with duplicate removal: + + RETURN UNIQUE( + UNION( + [ 1, 2, 3 ], + [ 1, 2 ] + ) + ) will produce: - [ [ 1, 2, 3 ] ] + + [ [ 1, 2, 3 ] ] - @FN{UNION_DISTINCT(@FA{list1, list2, ...})}: returns the union of distinct values of all lists specified. The function expects at least two list values as its arguments. diff --git a/Installation/travisCI/before_script.sh b/Installation/travisCI/before_script.sh new file mode 100755 index 0000000000..1491d58ca7 --- /dev/null +++ b/Installation/travisCI/before_script.sh @@ -0,0 +1,13 @@ +d='UnitTests/HttpInterface' + +echo +echo "$0: switching into ${d}" +cd "${d}" || exit 1 + +echo +echo "$0: installing bundler" +gem install bundler || exit 1 + +echo +echo "$0: executing bundle" +bundle || exit 1 diff --git a/Installation/travisCI/script.sh b/Installation/travisCI/script.sh new file mode 100755 index 0000000000..43b4209548 --- /dev/null +++ b/Installation/travisCI/script.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +echo +echo '$0: setup make-system' + +make setup || exit 1 + +echo +echo "$0: configuring ArangoDB" + +./configure \ + --enable-relative \ + --enable-all-in-one-libev \ + --enable-all-in-one-v8 \ + --enable-all-in-one-icu \ + || exit 1 + +echo +echo "$0: compiling ArangoDB" + +make -j2 || exit 1 + +echo +echo "$0: testing ArangoDB" + +make unittests-shell-server unittests-shell-server-ahuacatl unittests-http-server SKIP_RANGES=1 || exit 1 + +echo +echo "$0: done" diff --git a/Makefile.am b/Makefile.am index d64559b647..2d36071a16 100644 --- a/Makefile.am +++ b/Makefile.am @@ -198,6 +198,12 @@ endif sbin_PROGRAMS = \ bin/arangod +################################################################################ +### @brief helper programs +################################################################################ + +noinst_bin = + ################################################################################ ### @brief /sbin scripts ################################################################################ @@ -208,8 +214,7 @@ bin_SCRIPTS = ### @brief uninstalled programs ################################################################################ -noinst_PROGRAMS = \ - bin/check-server +noinst_PROGRAMS = ################################################################################ ### @brief /etc data diff --git a/arangod/Ahuacatl/ahuacatl-functions.c b/arangod/Ahuacatl/ahuacatl-functions.c index 0a15878e5e..04bb9cf5ff 100644 --- a/arangod/Ahuacatl/ahuacatl-functions.c +++ b/arangod/Ahuacatl/ahuacatl-functions.c @@ -675,6 +675,8 @@ TRI_associative_pointer_t* TRI_CreateFunctionsAql (void) { REGISTER_FUNCTION("STDDEV_SAMPLE", "STDDEV_SAMPLE", true, true, "l", NULL); REGISTER_FUNCTION("STDDEV_POPULATION", "STDDEV_POPULATION", true, true, "l", NULL); REGISTER_FUNCTION("UNIQUE", "UNIQUE", true, false, "l", NULL); + REGISTER_FUNCTION("SLICE", "SLICE", true, false, "l,n|n", NULL); + // note: REVERSE() can be applied on strings, too REGISTER_FUNCTION("REVERSE", "REVERSE", true, false, "ls", NULL); REGISTER_FUNCTION("FIRST", "FIRST", true, false, "l", NULL); diff --git a/arangosh/CMakeLists.txt b/arangosh/CMakeLists.txt index 5839760e74..323af2b469 100644 --- a/arangosh/CMakeLists.txt +++ b/arangosh/CMakeLists.txt @@ -230,28 +230,6 @@ install( REGEX "^.*/common/tests$" EXCLUDE REGEX "^.*/client/tests$" EXCLUDE) -################################################################################ -### @brief check-server -################################################################################ - -add_executable( - ${BIN_CHECK_SERVER} - V8Client/V8ClientConnection.cpp - V8Client/check-server.cpp -) - -target_link_libraries( - ${BIN_CHECK_SERVER} - ${LIB_ARANGO_V8} - ${LIB_ARANGO_CLIENT} - ${LIB_ARANGO} - ${V8_LIBS} - ${ICU_LIBS} - ${ZLIB_LIBS} - ${OPENSSL_LIBS} - ${MSVC_LIBS} -) - ## ----------------------------------------------------------------------------- ## --SECTION-- END-OF-FILE ## ----------------------------------------------------------------------------- diff --git a/arangosh/Makefile.files b/arangosh/Makefile.files index c8341d31ae..ba874e8bb3 100644 --- a/arangosh/Makefile.files +++ b/arangosh/Makefile.files @@ -103,25 +103,6 @@ bin_arangosh_SOURCES = \ arangosh/V8Client/V8ClientConnection.cpp \ arangosh/V8Client/arangosh.cpp -################################################################################ -### @brief program "check-server" -################################################################################ - -bin_check_server_CPPFLAGS = \ - -I@top_srcdir@/arangosh \ - $(AM_CPPFLAGS) - -bin_check_server_LDADD = \ - lib/libarango_v8.a \ - lib/libarango_client.a \ - lib/libarango.a \ - $(LIBS) \ - @V8_LIBS@ - -bin_check_server_SOURCES = \ - arangosh/V8Client/V8ClientConnection.cpp \ - arangosh/V8Client/check-server.cpp - ## ----------------------------------------------------------------------------- ## --SECTION-- END-OF-FILE ## ----------------------------------------------------------------------------- diff --git a/arangosh/V8Client/check-server.cpp b/arangosh/V8Client/check-server.cpp deleted file mode 100644 index 2de1243023..0000000000 --- a/arangosh/V8Client/check-server.cpp +++ /dev/null @@ -1,233 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief checks server is alive and answering requests -/// -/// @file -/// -/// DISCLAIMER -/// -/// Copyright 2004-2013 triAGENS GmbH, Cologne, Germany -/// -/// Licensed under the Apache License, Version 2.0 (the "License"); -/// you may not use this file except in compliance with the License. -/// You may obtain a copy of the License at -/// -/// http://www.apache.org/licenses/LICENSE-2.0 -/// -/// Unless required by applicable law or agreed to in writing, software -/// distributed under the License is distributed on an "AS IS" BASIS, -/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -/// See the License for the specific language governing permissions and -/// limitations under the License. -/// -/// Copyright holder is triAGENS GmbH, Cologne, Germany -/// -/// @author Dr. Frank Celler -/// @author Copyright 2013, triAGENS GmbH, Cologne, Germany -//////////////////////////////////////////////////////////////////////////////// - -#include "BasicsC/common.h" - -#include "ArangoShell/ArangoClient.h" -#include "BasicsC/init.h" -#include "BasicsC/logging.h" -#include "Rest/InitialiseRest.h" -#include "V8Client/V8ClientConnection.h" - -using namespace std; -using namespace triagens::basics; -using namespace triagens::rest; -using namespace triagens::httpclient; -using namespace triagens::v8client; -using namespace triagens::arango; - -// ----------------------------------------------------------------------------- -// --SECTION-- private functions -// ----------------------------------------------------------------------------- - -//////////////////////////////////////////////////////////////////////////////// -/// @brief exit function -//////////////////////////////////////////////////////////////////////////////// - -#ifdef _WIN32 - -static void checkserverExitFunction (int exitCode, void* data) { - int res = 0; - - // ........................................................................... - // TODO: need a terminate function for windows to be called and cleanup - // any windows specific stuff. - // ........................................................................... - - res = finaliseWindows(TRI_WIN_FINAL_WSASTARTUP_FUNCTION_CALL, 0); - - if (res != 0) { - exit(1); - } - - exit(exitCode); -} - -#else - -static void checkserverExitFunction (int exitCode, void* data) { -} - -#endif - -//////////////////////////////////////////////////////////////////////////////// -/// @brief startup function -//////////////////////////////////////////////////////////////////////////////// - -#ifdef _WIN32 - -static void checkserverEntryFunction () { - int maxOpenFiles = 1024; - int res = 0; - - // ........................................................................... - // Uncomment this to call this for extended debug information. - // If you familiar with valgrind ... then this is not like that, however - // you do get some similar functionality. - // ........................................................................... - //res = initialiseWindows(TRI_WIN_INITIAL_SET_DEBUG_FLAG, 0); - - res = initialiseWindows(TRI_WIN_INITIAL_SET_INVALID_HANLE_HANDLER, 0); - - if (res != 0) { - _exit(1); - } - - res = initialiseWindows(TRI_WIN_INITIAL_SET_MAX_STD_IO,(const char*)(&maxOpenFiles)); - - if (res != 0) { - _exit(1); - } - - res = initialiseWindows(TRI_WIN_INITIAL_WSASTARTUP_FUNCTION_CALL, 0); - - if (res != 0) { - _exit(1); - } - - TRI_Application_Exit_SetExit(checkserverExitFunction); -} - -#else - -static void checkserverEntryFunction () { -} - -#endif - -//////////////////////////////////////////////////////////////////////////////// -/// @brief return a new client connection instance -//////////////////////////////////////////////////////////////////////////////// - -static V8ClientConnection* CreateConnection (Endpoint* endpoint) { - return new V8ClientConnection(endpoint, - "_system", // database - "", // user - "", // - 300, // request timeout - 3, // connection timeout - 3, // retries - false, - 0); -} - -// ----------------------------------------------------------------------------- -// --SECTION-- public functions -// ----------------------------------------------------------------------------- - -//////////////////////////////////////////////////////////////////////////////// -/// @brief main -//////////////////////////////////////////////////////////////////////////////// - -int main (int argc, char* argv[]) { - int ret = EXIT_SUCCESS; - - checkserverEntryFunction(); - - TRIAGENS_C_INITIALISE(argc, argv); - TRIAGENS_REST_INITIALISE(argc, argv); - - TRI_InitialiseLogging(false); - - if (4 < argc || argc < 2) { - cerr << "usage: " << argv[0] << " [ [start|stop]]" << endl; - exit(EXIT_FAILURE); - } - - int loop = 1; - bool start = true; - - if (2 < argc) { - loop = StringUtils::int32(argv[2]); - } - - if (3 < argc) { - if (strcmp(argv[3], "stop") == 0) { - start = false; - } - } - - const char* endpointString = argv[1]; - Endpoint* endpoint = Endpoint::clientFactory(endpointString); - - if (endpoint != 0) { - bool connected = false; - bool waitFor = start; - int i = 0; - - do { - V8ClientConnection* connection = CreateConnection(endpoint); - - if (connection->isConnected() && connection->getLastHttpReturnCode() == HttpResponse::OK) { - cout << "version: " << connection->getVersion() << endl; - connected = true; - } - else { - cout << "cannot connect to '" << endpointString << "'" << endl; - } - - delete connection; - - i++; - - if (waitFor != connected && i < loop) { - sleep(1); - } - } - while (waitFor != connected && i < loop); - - if (connected != waitFor) { - if (start) { - cout << "server '" << endpointString << "' failed to start" << endl; - } - else { - cout << "server '" << endpointString << "' failed to stop" << endl; - } - - ret = EXIT_FAILURE; - } - } - else { - cout << "cannot parse endpoint definition '" << endpointString << "'" << endl; - ret = EXIT_FAILURE; - } - - TRIAGENS_REST_SHUTDOWN; - - checkserverExitFunction(ret, NULL); - - return ret; -} - -// ----------------------------------------------------------------------------- -// --SECTION-- END-OF-FILE -// ----------------------------------------------------------------------------- - -// Local Variables: -// mode: outline-minor -// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}" -// End: diff --git a/js/actions/api-user.js b/js/actions/api-user.js index 743cdaae42..69a9ac744e 100644 --- a/js/actions/api-user.js +++ b/js/actions/api-user.js @@ -76,6 +76,11 @@ var users = require("org/arangodb/users"); //////////////////////////////////////////////////////////////////////////////// function get_api_user (req, res) { + if (req.suffix.length === 0) { + actions.resultOk(req, res, actions.HTTP_OK, users.all()); + return; + } + if (req.suffix.length !== 1) { actions.resultBad(req, res, arangodb.ERROR_HTTP_BAD_PARAMETER); return; diff --git a/js/apps/system/aardvark/frontend/css/layout.css b/js/apps/system/aardvark/frontend/css/layout.css index a2ae6ff16e..b8db921115 100644 --- a/js/apps/system/aardvark/frontend/css/layout.css +++ b/js/apps/system/aardvark/frontend/css/layout.css @@ -202,3 +202,64 @@ li a [class^="icon_arangodb"], li a [class*=" icon_arangodb"] { font-size: 23px; color: #736B68; } +/*copy to scss*/ +.fixedDropdown { + margin: 34px 0 0 0 !important; + border-radius: 0 !important; + width: 210px; +} + +.fixedDropdown:after { + visibility: hidden; +} + +.fixedDropdown .dropdown-item { + border-bottom: 1px solid rgba(0, 0, 0, 0.2); +} + +.fixedDropdown .dropdown-header { + border-bottom: 1px solid rgba(0, 0, 0, 0.2); + padding: 0 !important; +} + +.fixedDropdown a { + padding-left: 5px !important; +} + +.fixedDropdown .notificationItemContent { + width: 170px; + float: left; + margin-left: 5px; +} + +.fixedDropdown button { + float:right; + margin-right: 5px; +} + +.innerDropdownInnerUL { + min-height: 220px; + height: 220px !important; + width: 100%; + overflow-y: scroll; + overflow-x: hidden; + float: left; + border-bottom: 1px solid rgba(0, 0, 0, 0.2); +} + +.innerDropdownInnerUL li { + width: auto !important; +} + +.innerDropdownInnerUL li:last-child { + color: red; + border-bottom: 0; +} + +.fixedDropdown .notificationItem { + color: black; +} + +.notificationItem i { + float:left; +} diff --git a/js/apps/system/aardvark/frontend/css/navigationView.css b/js/apps/system/aardvark/frontend/css/navigationView.css index 9a97c67b3d..59cd591200 100644 --- a/js/apps/system/aardvark/frontend/css/navigationView.css +++ b/js/apps/system/aardvark/frontend/css/navigationView.css @@ -61,3 +61,6 @@ body, input, textarea, .page-title span, .pingback a.url { margin-right: 15px; } +.fixedDropdown { + margin: 34px 0 0 !important; +} diff --git a/js/apps/system/aardvark/frontend/html/body.html.part b/js/apps/system/aardvark/frontend/html/body.html.part index 602114113e..894c524818 100644 --- a/js/apps/system/aardvark/frontend/html/body.html.part +++ b/js/apps/system/aardvark/frontend/html/body.html.part @@ -4,8 +4,12 @@ - +
+
+
+
+ diff --git a/js/apps/system/aardvark/frontend/img/tmpNotificationCounter.jpg b/js/apps/system/aardvark/frontend/img/tmpNotificationCounter.jpg new file mode 100644 index 0000000000..c6b76ad1c8 Binary files /dev/null and b/js/apps/system/aardvark/frontend/img/tmpNotificationCounter.jpg differ diff --git a/js/apps/system/aardvark/frontend/img/tmp_dashbord_activity_green.jpg b/js/apps/system/aardvark/frontend/img/tmp_dashbord_activity_green.jpg new file mode 100644 index 0000000000..79da4e1ad6 Binary files /dev/null and b/js/apps/system/aardvark/frontend/img/tmp_dashbord_activity_green.jpg differ diff --git a/js/apps/system/aardvark/frontend/img/tmp_dashbord_activity_red.jpg b/js/apps/system/aardvark/frontend/img/tmp_dashbord_activity_red.jpg new file mode 100644 index 0000000000..08318180ae Binary files /dev/null and b/js/apps/system/aardvark/frontend/img/tmp_dashbord_activity_red.jpg differ diff --git a/js/apps/system/aardvark/frontend/img/tmp_dashbord_activity_yellow.jpg b/js/apps/system/aardvark/frontend/img/tmp_dashbord_activity_yellow.jpg new file mode 100644 index 0000000000..e30fcb337d Binary files /dev/null and b/js/apps/system/aardvark/frontend/img/tmp_dashbord_activity_yellow.jpg differ diff --git a/js/apps/system/aardvark/frontend/js/arango/arango.js b/js/apps/system/aardvark/frontend/js/arango/arango.js index e85bad77c1..bdbcd38618 100644 --- a/js/apps/system/aardvark/frontend/js/arango/arango.js +++ b/js/apps/system/aardvark/frontend/js/arango/arango.js @@ -101,49 +101,12 @@ return returnVal; }, - removeNotifications: function () { - $.gritter.removeAll(); - this.lastNotificationMessage = null; + arangoNotification: function (message) { }, - arangoNotification: function (message, time) { - var returnVal = false; - $.gritter.add({ - title: "Notice:", - text: message, - time: time || 3000, - before_open: function(){ - returnVal = true; - } - }); - this.lastNotificationMessage = null; - return returnVal; - }, arangoError: function (message) { - var returnVal = false; - $.gritter.add({ - title: "Error:", - text: message, - sticky: true, - before_open: function(){ - if (this.lastNotificationMessage === message) { - // prevent display the same message over & over - return false; - } - if($('.gritter-item-wrapper').length === 3) { - // not more than 3 messages at once - return false; - } - this.lastNotificationMessage = message; - returnVal = true; - }, - before_close: function(){ - // reset last text when closing a specific message - this.lastNotificationMessage = null; - } - }); - return returnVal; }, + getRandomToken: function () { return Math.round(new Date().getTime()); }, diff --git a/js/apps/system/aardvark/frontend/js/collections/arangoUsers.js b/js/apps/system/aardvark/frontend/js/collections/arangoUsers.js index 602c45373f..6a56f88102 100644 --- a/js/apps/system/aardvark/frontend/js/collections/arangoUsers.js +++ b/js/apps/system/aardvark/frontend/js/collections/arangoUsers.js @@ -11,7 +11,7 @@ window.ArangoUsers = Backbone.Collection.extend({ "testing": true }, - url: "../api/user", + url: "/_api/user", initialize: function() { //check cookies / local storage diff --git a/js/apps/system/aardvark/frontend/js/models/notification.js b/js/apps/system/aardvark/frontend/js/models/notification.js index cf53eb4201..483edeaee8 100644 --- a/js/apps/system/aardvark/frontend/js/models/notification.js +++ b/js/apps/system/aardvark/frontend/js/models/notification.js @@ -5,10 +5,12 @@ window.Notification = Backbone.Model.extend({ defaults: { - "title": "", - "content": "", - "priority": "", - "seen": false + "title" : "", + "date" : 0, + "content" : "", + "priority" : "", + "tags" : "", + "seen" : false } }); diff --git a/js/apps/system/aardvark/frontend/js/routers/router.js b/js/apps/system/aardvark/frontend/js/routers/router.js index 98c52c8299..62cfc00838 100644 --- a/js/apps/system/aardvark/frontend/js/routers/router.js +++ b/js/apps/system/aardvark/frontend/js/routers/router.js @@ -76,16 +76,11 @@ }); this.foxxList = new window.FoxxCollection(); - this.notificationList = new window.NotificationCollection(); this.footerView = new window.FooterView(); this.naviView = new window.NavigationView(); -// this.statView = new window.StatisticBarView(); -// this.userBarView = new window.UserBarView(); this.footerView.render(); this.naviView.render(); -// this.statView.render(); -// this.userBarView.render(); this.graphView = new window.GraphView({ graphs: this.graphs, collection: window.arangoCollectionsStore diff --git a/js/apps/system/aardvark/frontend/js/templates/foxxActiveView.ejs b/js/apps/system/aardvark/frontend/js/templates/foxxActiveView.ejs index 7fe086dfa8..dc84773d39 100644 --- a/js/apps/system/aardvark/frontend/js/templates/foxxActiveView.ejs +++ b/js/apps/system/aardvark/frontend/js/templates/foxxActiveView.ejs @@ -1,37 +1,40 @@ +<% var appInfos = attributes.app.split(":"); %> +
+ + +
+ +
+ + <%if (attributes.development) {%> + +
+ development +
+
+ <%} else if (attributes.active) {%> + +
+ active +
+
+ <%} else {%> + +
+ inactive +
+
+ <%}%> +
<%= appInfos[1] %><%= attributes.isSystem ? " (system)" : "" %><%= appInfos[0] === "dev" ? " (dev)" : ""%>
+
+ + + Description: <%=attributes.description %>
Mount: <%=attributes.mount %>
Version: <%=appInfos[2] %>
Prefix: <%=attributes.options && attributes.options.collectionPrefix%>
- -

- <%if (attributes.development) {%> - -
- development -
-
- <%} else if (attributes.active) {%> - -
- active -
-
- <%} else {%> - -
- inactive -
-
- <%}%> - + Git: >Repository +--> diff --git a/js/apps/system/aardvark/frontend/js/templates/foxxInstalledView.ejs b/js/apps/system/aardvark/frontend/js/templates/foxxInstalledView.ejs index 2a25165516..57fa927bf3 100644 --- a/js/apps/system/aardvark/frontend/js/templates/foxxInstalledView.ejs +++ b/js/apps/system/aardvark/frontend/js/templates/foxxInstalledView.ejs @@ -1,3 +1,19 @@ +
+ + <% if(attributes.status === "loaded") { %> + + <%} else {%> + + <%}%> +
+ +
+ +
<%= attributes.status %>
+
<%= attributes.name %><%= attributes.isSystem ? " (system)" : "" %>
+
+ +
<%= attributes.name %><%= attributes.isSystem ? " (system)" : "" %>
diff --git a/js/apps/system/aardvark/frontend/js/templates/notificationItem.ejs b/js/apps/system/aardvark/frontend/js/templates/notificationItem.ejs new file mode 100644 index 0000000000..54d885f6d6 --- /dev/null +++ b/js/apps/system/aardvark/frontend/js/templates/notificationItem.ejs @@ -0,0 +1,10 @@ + + <% var i; for (i=0; i < notifications.length; i++) { %> + + <% console.log(i); } %> diff --git a/js/apps/system/aardvark/frontend/js/templates/statisticBarView.ejs b/js/apps/system/aardvark/frontend/js/templates/statisticBarView.ejs index 94fd48343f..8b95ea6615 100644 --- a/js/apps/system/aardvark/frontend/js/templates/statisticBarView.ejs +++ b/js/apps/system/aardvark/frontend/js/templates/statisticBarView.ejs @@ -1,5 +1,7 @@ - \ No newline at end of file + diff --git a/js/apps/system/aardvark/frontend/js/templates/userBarView.ejs b/js/apps/system/aardvark/frontend/js/templates/userBarView.ejs index e69de29bb2..906631060b 100644 --- a/js/apps/system/aardvark/frontend/js/templates/userBarView.ejs +++ b/js/apps/system/aardvark/frontend/js/templates/userBarView.ejs @@ -0,0 +1,41 @@ + diff --git a/js/apps/system/aardvark/frontend/js/templates/userManagementView.ejs b/js/apps/system/aardvark/frontend/js/templates/userManagementView.ejs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/apps/system/aardvark/frontend/js/templates/userProfileView.ejs b/js/apps/system/aardvark/frontend/js/templates/userProfileView.ejs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/apps/system/aardvark/frontend/js/views/collectionView.js b/js/apps/system/aardvark/frontend/js/views/collectionView.js index d84fd03439..35bc23c76e 100644 --- a/js/apps/system/aardvark/frontend/js/views/collectionView.js +++ b/js/apps/system/aardvark/frontend/js/views/collectionView.js @@ -131,10 +131,6 @@ } var changeResult = window.arangoCollectionsStore.changeCollection(collid, wfs, journalSize); - if (result === true) { - arangoHelper.arangoNotification("Collection renamed"); - } - if (result !== true) { if (result !== undefined) { arangoHelper.arangoError("Collection error: " + result); @@ -168,14 +164,12 @@ } }); this.hideModal(); - arangoHelper.arangoNotification("Collection renamed"); } else { arangoHelper.arangoError("Collection error: " + result2); } } else { - //arangoHelper.arangoNotification("No changes."); this.hideModal(); } } @@ -209,10 +203,7 @@ var self = this; var collName = self.myCollection.name; var returnval = window.arangoCollectionsStore.deleteCollection(collName); - if (returnval === true) { - arangoHelper.arangoNotification('Collection deleted successfully.'); - } - else { + if (returnval === false) { arangoHelper.arangoError('Could not delete collection.'); } self.hideModal(); diff --git a/js/apps/system/aardvark/frontend/js/views/databaseView.js b/js/apps/system/aardvark/frontend/js/views/databaseView.js index 27e1d3d4fc..ec138ea7f7 100644 --- a/js/apps/system/aardvark/frontend/js/views/databaseView.js +++ b/js/apps/system/aardvark/frontend/js/views/databaseView.js @@ -105,7 +105,6 @@ self.handleError(err.status, err.statusText, name); }, success: function(data) { - arangoHelper.arangoNotification("Database " + name + " created."); self.hideModal(); self.updateDatabases(); } diff --git a/js/apps/system/aardvark/frontend/js/views/documentSourceView.js b/js/apps/system/aardvark/frontend/js/views/documentSourceView.js index ba35e580c9..75cd2eff54 100644 --- a/js/apps/system/aardvark/frontend/js/views/documentSourceView.js +++ b/js/apps/system/aardvark/frontend/js/views/documentSourceView.js @@ -93,10 +93,7 @@ } result = window.arangoDocumentStore.saveDocument(this.colid, this.docid, model); - if (result === true) { - arangoHelper.arangoNotification('Document saved'); - } - else if (result === false) { + if (result === false) { arangoHelper.arangoError('Document error'); } } @@ -104,10 +101,7 @@ editor = ace.edit("sourceEditor"); model = editor.getValue(); result = window.arangoDocumentStore.saveEdge(this.colid, this.docid, model); - if (result === true) { - arangoHelper.arangoNotification('Edge saved'); - } - else if (result === false) { + if (result === false) { arangoHelper.arangoError('Edge error'); } } diff --git a/js/apps/system/aardvark/frontend/js/views/documentsView.js b/js/apps/system/aardvark/frontend/js/views/documentsView.js index 5ee4b26bf0..7022ce966f 100644 --- a/js/apps/system/aardvark/frontend/js/views/documentsView.js +++ b/js/apps/system/aardvark/frontend/js/views/documentsView.js @@ -350,7 +350,6 @@ //Success if (result !== false) { window.location.hash = "collection/" + result; - arangoHelper.arangoNotification('Document created'); return; } //Error @@ -424,18 +423,16 @@ result = window.arangoDocumentStore.deleteDocument(this.colid, this.docid); if (result === true) { //on success - arangoHelper.arangoNotification('Document deleted'); deleted = true; } else if (result === false) { - arangoHelper.arangoError('Could not delete document'); + arangoHelper.arangoError('Doc error'); } } else if (this.type === 'edge') { result = window.arangoDocumentStore.deleteEdge(this.colid, this.docid); if (result === true) { //on success - arangoHelper.arangoNotification('Edge deleted'); deleted = true; } else if (result === false) { diff --git a/js/apps/system/aardvark/frontend/js/views/footerView.js b/js/apps/system/aardvark/frontend/js/views/footerView.js index f986587322..947426a024 100644 --- a/js/apps/system/aardvark/frontend/js/views/footerView.js +++ b/js/apps/system/aardvark/frontend/js/views/footerView.js @@ -34,7 +34,6 @@ success: function(data) { if (self.isOffline === true) { self.isOffline = false; - arangoHelper.removeNotifications(); if (!self.firstLogin) { window.setTimeout(function(){ arangoHelper.arangoNotification("Server connected"); diff --git a/js/apps/system/aardvark/frontend/js/views/foxxActiveView.js b/js/apps/system/aardvark/frontend/js/views/foxxActiveView.js index fd4b53f414..25447ba90b 100644 --- a/js/apps/system/aardvark/frontend/js/views/foxxActiveView.js +++ b/js/apps/system/aardvark/frontend/js/views/foxxActiveView.js @@ -6,7 +6,7 @@ window.FoxxActiveView = Backbone.View.extend({ tagName: 'li', - className: "span3", + className: "tile", template: templateEngine.createTemplate("foxxActiveView.ejs"), events: { diff --git a/js/apps/system/aardvark/frontend/js/views/navigationView.js b/js/apps/system/aardvark/frontend/js/views/navigationView.js index 360ada2d4b..756daf7861 100644 --- a/js/apps/system/aardvark/frontend/js/views/navigationView.js +++ b/js/apps/system/aardvark/frontend/js/views/navigationView.js @@ -18,8 +18,8 @@ collection: window.arangoDatabase, current: window.currentDB }); -// this.userBarView = new window.UserBarView({}); -// this.statisticBarView = new window.StatisticBarView({}); + this.userBarView = new window.UserBarView({}); + this.statisticBarView = new window.StatisticBarView({}); }, handleSelectDatabase: function () { @@ -34,8 +34,8 @@ isSystem: window.currentDB.get("isSystem") })); this.dbSelectionView.render($("#dbSelect")); -// this.userBarView.render($("#userBar")); -// this.statisticBarView.render($("#statisticBar")); + this.userBarView.render($("#userBar")); + this.statisticBarView.render($("#statisticBar")); return this; }, diff --git a/js/apps/system/aardvark/frontend/js/views/newCollectionView.js b/js/apps/system/aardvark/frontend/js/views/newCollectionView.js index 8f03b80f3f..cf1f419540 100644 --- a/js/apps/system/aardvark/frontend/js/views/newCollectionView.js +++ b/js/apps/system/aardvark/frontend/js/views/newCollectionView.js @@ -85,7 +85,6 @@ if (returnobj.status === true) { self.hidden(); $("#add-collection").modal('hide'); - arangoHelper.arangoNotification("Collection created"); window.App.navigate("collection/" + collName + "/documents/1", {trigger: true}); } diff --git a/js/apps/system/aardvark/frontend/js/views/notificationView.js b/js/apps/system/aardvark/frontend/js/views/notificationView.js new file mode 100644 index 0000000000..a3e222fd99 --- /dev/null +++ b/js/apps/system/aardvark/frontend/js/views/notificationView.js @@ -0,0 +1,25 @@ +/*jslint indent: 2, nomen: true, maxlen: 100, vars: true, white: true, plusplus: true */ +/*global window, document, Backbone, EJS, SwaggerUi, hljs, $, arangoHelper, templateEngine */ +(function() { + + "use strict"; + + window.notificationView = Backbone.View.extend({ + el: '#content', + + template: templateEngine.createTemplate("notificationView.ejs"), + + events: { + }, + + initialize: function() { + //this.collection.fetch({async:false}); + }, + + render: function(){ + $(this.el).html(this.template.render({})); + return this; + } + + }); +}()); diff --git a/js/apps/system/aardvark/frontend/js/views/statisticBarView.js b/js/apps/system/aardvark/frontend/js/views/statisticBarView.js index 97f80882b2..619ad207d5 100644 --- a/js/apps/system/aardvark/frontend/js/views/statisticBarView.js +++ b/js/apps/system/aardvark/frontend/js/views/statisticBarView.js @@ -13,7 +13,9 @@ template: templateEngine.createTemplate("statisticBarView.ejs"), render: function () { - $(this.el).html(this.template.render({isSystem: window.currentDB.get("isSystem")})); + $(this.el).html(this.template.render({ + isSystem: window.currentDB.get("isSystem") + })); return this; }, diff --git a/js/apps/system/aardvark/frontend/js/views/userBarView.js b/js/apps/system/aardvark/frontend/js/views/userBarView.js index bf7af8d274..14bd0b111e 100644 --- a/js/apps/system/aardvark/frontend/js/views/userBarView.js +++ b/js/apps/system/aardvark/frontend/js/views/userBarView.js @@ -1,21 +1,94 @@ /*jslint indent: 2, nomen: true, maxlen: 100, vars: true, white: true, plusplus: true */ /*global Backbone, templateEngine, $, window*/ (function () { - "use strict"; + "use strict"; - window.UserBarView = Backbone.View.extend({ - el: '#statisticBar', + window.UserBarView = Backbone.View.extend({ - events: { + events: { + "change #userBarSelect": "navigateBySelect", + "click .tab": "navigateByTab", + "mouseenter .dropdown": "showDropdown", + "mouseleave .dropdown": "hideDropdown", + "click .navlogo #stat_hd" : "toggleNotification" + }, - }, + initialize: function () { + this.notificationList = new window.NotificationCollection(); + }, - template: templateEngine.createTemplate("userBarView.ejs"), + notificationItem: templateEngine.createTemplate("notificationItem.ejs"), - render: function() { - $(this.el).html(this.template.render(this.template.text)); - return this; + template: templateEngine.createTemplate("userBarView.ejs"), - } - }); -}()); \ No newline at end of file + navigateBySelect: function () { + var navigateTo = $("#arangoCollectionSelect").find("option:selected").val(); + window.App.navigate(navigateTo, {trigger: true}); + }, + + navigateByTab: function (e) { + var tab = e.target || e.srcElement; + tab = $(tab).closest("a"); + var navigateTo = tab.attr("id"); + if (navigateTo === "user") { + $("#user_dropdown").slideToggle(200); + e.preventDefault(); + return; + } + window.App.navigate(navigateTo, {trigger: true}); + e.preventDefault(); + }, + + toggleNotification: function (e) { + $('#notification_menu').toggle(); + }, + + showDropdown: function (e) { + var tab = e.target || e.srcElement; + var navigateTo = tab.id; + if (navigateTo === "user") { + $("#user_dropdown").show(200); + return; + } + }, + + hideDropdown: function (e) { + var tab = e.target || e.srcElement; + var navigateTo = tab.id; + if (navigateTo === "") { + tab = $(tab).closest(".user-dropdown-menu"); + navigateTo = tab.attr("id"); + } + if (navigateTo === "user" || navigateTo === "user_dropdown" || navigateTo === "userimage" ) { + $("#user_dropdown").hide(); + return; + } + }, + + updateNotifications: function() { + this.renderNotifications(); + }, + + renderNotifications: function() { + $('.innerDropdownInnerUL').html(this.notificationItem.render({ + notifications : this.notificationList.models + })); + }, + + render: function (el) { + this.$el = el; + this.$el.html(this.template.render({ + img : "https://s.gravatar.com/avatar/9c53a795affc3c3c03801ffae90e2e11?s=80", + prename : "Floyd", + lastname : "Pepper", + notifications : this.notificationList.models + })); + + this.renderNotifications(); + + this.delegateEvents(); + this.updateNotifications(); + return this.$el; + } + }); +}()); diff --git a/js/apps/system/aardvark/frontend/js/views/userManagementView.js b/js/apps/system/aardvark/frontend/js/views/userManagementView.js new file mode 100644 index 0000000000..0948f54624 --- /dev/null +++ b/js/apps/system/aardvark/frontend/js/views/userManagementView.js @@ -0,0 +1,25 @@ +/*jslint indent: 2, nomen: true, maxlen: 100, vars: true, white: true, plusplus: true */ +/*global window, document, Backbone, EJS, SwaggerUi, hljs, $, arangoHelper, templateEngine */ +(function() { + + "use strict"; + + window.userManagementView = Backbone.View.extend({ + el: '#content', + + template: templateEngine.createTemplate("userManagementView.ejs"), + + events: { + }, + + initialize: function() { + //this.collection.fetch({async:false}); + }, + + render: function(){ + $(this.el).html(this.template.render({})); + return this; + } + + }); +}()); diff --git a/js/apps/system/aardvark/frontend/js/views/userProfileView.js b/js/apps/system/aardvark/frontend/js/views/userProfileView.js new file mode 100644 index 0000000000..47ad396462 --- /dev/null +++ b/js/apps/system/aardvark/frontend/js/views/userProfileView.js @@ -0,0 +1,25 @@ +/*jslint indent: 2, nomen: true, maxlen: 100, vars: true, white: true, plusplus: true */ +/*global window, document, Backbone, EJS, SwaggerUi, hljs, $, arangoHelper, templateEngine */ +(function() { + + "use strict"; + + window.userProfileView = Backbone.View.extend({ + el: '#content', + + template: templateEngine.createTemplate("userProfileView.ejs"), + + events: { + }, + + initialize: function() { + //this.collection.fetch({async:false}); + }, + + render: function(){ + $(this.el).html(this.template.render({})); + return this; + } + + }); +}()); diff --git a/js/apps/system/aardvark/frontend/scss/_colors.scss b/js/apps/system/aardvark/frontend/scss/_colors.scss index 9263706fd6..e9635f74b5 100644 --- a/js/apps/system/aardvark/frontend/scss/_colors.scss +++ b/js/apps/system/aardvark/frontend/scss/_colors.scss @@ -22,3 +22,4 @@ $c_dark_grey: #999999; $c_transp: transparent; $c_semi_transp: rgba(0, 0, 0, 0.2); +$c_very_transp: rgba(0, 0, 0, 0.05); diff --git a/js/apps/system/aardvark/frontend/scss/_tiles.scss b/js/apps/system/aardvark/frontend/scss/_tiles.scss index 1585c8980a..9ab4577a22 100644 --- a/js/apps/system/aardvark/frontend/scss/_tiles.scss +++ b/js/apps/system/aardvark/frontend/scss/_tiles.scss @@ -9,6 +9,8 @@ li.tile { text-align:center; height:100px; width: 230px; + list-style: none; + background-color: $c_very_transp; margin: { left: 6px; right: 6px; diff --git a/js/apps/system/aardvark/frontend/scss/generated.css b/js/apps/system/aardvark/frontend/scss/generated.css index 6c69c868a3..b209670c9a 100644 --- a/js/apps/system/aardvark/frontend/scss/generated.css +++ b/js/apps/system/aardvark/frontend/scss/generated.css @@ -189,6 +189,8 @@ li.tile { text-align: center; height: 100px; width: 230px; + list-style: none; + background-color: rgba(0, 0, 0, 0.05); margin-left: 6px; margin-right: 6px; margin-bottom: 13px; diff --git a/js/apps/system/aardvark/index.html b/js/apps/system/aardvark/index.html index 73bf4f6d01..8c0946bc6c 100644 --- a/js/apps/system/aardvark/index.html +++ b/js/apps/system/aardvark/index.html @@ -2,7 +2,6 @@ - ArangoDB Web Interface diff --git a/js/apps/system/aardvark/test/karma/karma.conf.js b/js/apps/system/aardvark/test/karma/karma.conf.js index a1ab7b1583..db3e61deca 100644 --- a/js/apps/system/aardvark/test/karma/karma.conf.js +++ b/js/apps/system/aardvark/test/karma/karma.conf.js @@ -126,6 +126,7 @@ module.exports = function(karma) { 'frontend/js/models/arangoStatistics.js', 'frontend/js/models/arangoStatisticsDescription.js', 'frontend/js/models/foxx.js', + 'frontend/js/models/notification.js', 'frontend/js/models/graph.js', 'frontend/js/models/clusterServer.js', 'frontend/js/models/clusterCoordinator.js', @@ -149,6 +150,7 @@ module.exports = function(karma) { 'frontend/js/collections/clusterDatabases.js', 'frontend/js/collections/clusterCollections.js', 'frontend/js/collections/clusterShards.js', + 'frontend/js/collections/notificationCollection.js', // Views 'frontend/js/views/navigationView.js', diff --git a/js/apps/system/aardvark/test/specs/arango/arangoSpec.js b/js/apps/system/aardvark/test/specs/arango/arangoSpec.js index caa5c301c3..03661cbbb9 100644 --- a/js/apps/system/aardvark/test/specs/arango/arangoSpec.js +++ b/js/apps/system/aardvark/test/specs/arango/arangoSpec.js @@ -69,16 +69,4 @@ describe("Arango Helper", function() { }); - describe("arango gritter ", function() { - it("warn. notification", function() { - var dummy = arangoHelper.arangoNotification("test"); - expect(dummy).toBe(true); - }); - it("crit. notification", function() { - var dummy = arangoHelper.arangoError("test"); - expect(dummy).toBe(true); - $.gritter.removeAll(); - }); - }); - }); diff --git a/js/common/modules/org/arangodb/users-common.js b/js/common/modules/org/arangodb/users-common.js index e31bb63084..8d1736591f 100644 --- a/js/common/modules/org/arangodb/users-common.js +++ b/js/common/modules/org/arangodb/users-common.js @@ -31,6 +31,7 @@ var internal = require("internal"); // OK: time var arangodb = require("org/arangodb"); var crypto = require("org/arangodb/crypto"); +var _ = require("underscore"); var db = arangodb.db; var ArangoError = arangodb.ArangoError; @@ -439,6 +440,32 @@ exports.document = function (username) { }; }; +//////////////////////////////////////////////////////////////////////////////// +/// @fn JSF_allUser +/// @brief gets all existing users +/// +/// @FUN{users.all()} +/// +/// Fetches all existing ArangoDB users from the database. +//////////////////////////////////////////////////////////////////////////////// + +exports.all = function () { + var cursor = getStorage().all(); + var result = [ ]; + + while (cursor.hasNext()) { + var doc = cursor.next(); + var user = { + user: doc.user, + active: doc.active, + extra: doc.extra || { } + }; + result.push(user); + } + + return result; +}; + //////////////////////////////////////////////////////////////////////////////// /// @fn JSF_reloadUsers /// @brief reloads the user authentication data diff --git a/js/server/modules/org/arangodb/ahuacatl.js b/js/server/modules/org/arangodb/ahuacatl.js index 1c8055e308..a35778f7cc 100644 --- a/js/server/modules/org/arangodb/ahuacatl.js +++ b/js/server/modules/org/arangodb/ahuacatl.js @@ -2751,6 +2751,36 @@ function UNION_DISTINCT () { return result; } +//////////////////////////////////////////////////////////////////////////////// +/// @brief extract a slice from a list +//////////////////////////////////////////////////////////////////////////////// + +function SLICE (value, from, to) { + "use strict"; + + if (TYPEWEIGHT(value) !== TYPEWEIGHT_LIST) { + THROW(INTERNAL.errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH, "SLICE"); + } + + if (TYPEWEIGHT(from) !== TYPEWEIGHT_NUMBER) { + THROW(INTERNAL.errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH, "SLICE"); + } + + if (TYPEWEIGHT(to) === TYPEWEIGHT_NULL) { + to = undefined; + } + else if (TYPEWEIGHT(to) !== TYPEWEIGHT_NUMBER) { + THROW(INTERNAL.errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH, "SLICE"); + } + else { + if (to >= 0) { + to += from; + } + } + + return value.slice(from, to); +} + //////////////////////////////////////////////////////////////////////////////// /// @brief subtract lists from other lists //////////////////////////////////////////////////////////////////////////////// @@ -4238,6 +4268,7 @@ exports.RANGE = RANGE; exports.UNIQUE = UNIQUE; exports.UNION = UNION; exports.UNION_DISTINCT = UNION_DISTINCT; +exports.SLICE = SLICE; exports.MINUS = MINUS; exports.INTERSECTION = INTERSECTION; exports.MAX = MAX; diff --git a/js/server/tests/ahuacatl-functions.js b/js/server/tests/ahuacatl-functions.js index 3498e2bddc..fb63e24380 100644 --- a/js/server/tests/ahuacatl-functions.js +++ b/js/server/tests/ahuacatl-functions.js @@ -557,6 +557,74 @@ function ahuacatlFunctionsTestSuite () { assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN UNIQUE({ })"); }, +//////////////////////////////////////////////////////////////////////////////// +/// @brief test slice function +//////////////////////////////////////////////////////////////////////////////// + + testSlice : function () { + var expected, actual; + + actual = getQueryResults("RETURN SLICE([ ], 0, 1)"); + assertEqual([ [ ] ], actual); + + actual = getQueryResults("RETURN SLICE([ 1, 2, 3, 4, 5 ], 0, 1)"); + assertEqual([ [ 1 ] ], actual); + + actual = getQueryResults("RETURN SLICE([ 1, 2, 3, 4, 5 ], 0, 2)"); + assertEqual([ [ 1, 2 ] ], actual); + + actual = getQueryResults("RETURN SLICE([ 1, 2, 3, 4, 5 ], 1, 2)"); + assertEqual([ [ 2, 3 ] ], actual); + + actual = getQueryResults("RETURN SLICE([ 1, 2, 3, 4, 5 ], 0)"); + assertEqual([ [ 1, 2, 3, 4, 5 ] ], actual); + + actual = getQueryResults("RETURN SLICE([ 1, 2, 3, 4, 5 ], 3)"); + assertEqual([ [ 4, 5 ] ], actual); + + actual = getQueryResults("RETURN SLICE([ 1, 2, 3, 4, 5 ], 0, -1)"); + assertEqual([ [ 1, 2, 3, 4 ] ], actual); + + actual = getQueryResults("RETURN SLICE([ 1, 2, 3, 4, 5 ], 0, -2)"); + assertEqual([ [ 1, 2, 3 ] ], actual); + + actual = getQueryResults("RETURN SLICE([ 1, 2, 3, 4, 5 ], 2, -1)"); + assertEqual([ [ 3, 4 ] ], actual); + + actual = getQueryResults("RETURN SLICE([ 1, 2, 3, 4, 5 ], 10)"); + assertEqual([ [ ] ], actual); + + actual = getQueryResults("RETURN SLICE([ 1, 2, 3, 4, 5 ], 1000)"); + assertEqual([ [ ] ], actual); + + actual = getQueryResults("RETURN SLICE([ 1, 2, 3, 4, 5 ], -1000)"); + assertEqual([ [ 1, 2, 3, 4, 5 ] ], actual); + + actual = getQueryResults("RETURN SLICE([ 1, 2, 3, 4, 5 ], 1, -10)"); + assertEqual([ [ ] ], actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test slice function +//////////////////////////////////////////////////////////////////////////////// + + testSliceInvalid : function () { + assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_NUMBER_MISMATCH.code, "RETURN SLICE()"); + assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_NUMBER_MISMATCH.code, "RETURN SLICE(true)"); + assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_NUMBER_MISMATCH.code, "RETURN SLICE(1)"); + assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_NUMBER_MISMATCH.code, "RETURN SLICE('foo')"); + assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_NUMBER_MISMATCH.code, "RETURN SLICE({ })"); + assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_NUMBER_MISMATCH.code, "RETURN SLICE([ ])"); + assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN SLICE([ ], { })"); + assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN SLICE([ ], true)"); + assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN SLICE([ ], 'foo')"); + assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN SLICE([ ], [ ])"); + assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN SLICE([ ], { })"); + assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN SLICE([ ], 1, false)"); + assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN SLICE([ ], 1, 'foo')"); + assertQueryError(errors.ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH.code, "RETURN SLICE([ ], 1, [ ])"); + }, + //////////////////////////////////////////////////////////////////////////////// /// @brief test left function ////////////////////////////////////////////////////////////////////////////////