mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of https://github.com/arangodb/arangodb into cmakification
This commit is contained in:
commit
6fe2dd2465
12
CHANGELOG
12
CHANGELOG
|
@ -75,8 +75,18 @@ v3.0.0 (XXXX-XX-XX)
|
|||
|
||||
* added WorkMonitor to inspect server threads
|
||||
|
||||
* when downloading a Foxx service from the web interface the suggested filename
|
||||
now takes the form $name@$version.zip instead of simply "app.zip"
|
||||
|
||||
v2.8.2 (XXXX-XX-XX)
|
||||
|
||||
v2.8.3 (XXXX-XX-XX)
|
||||
-------------------
|
||||
|
||||
* Foxx Model event listeners defined on the model are now correctly invoked by
|
||||
the Repository methods (issue #1665)
|
||||
|
||||
|
||||
v2.8.2 (2016-02-09)
|
||||
-------------------
|
||||
|
||||
* the continuous replication applier will now prevent the master's WAL logfiles
|
||||
|
|
|
@ -10,6 +10,8 @@ var aqlfunctions = require("@arangodb/aql/functions");
|
|||
To register a function, the fully qualified function name plus the
|
||||
function code must be specified.
|
||||
|
||||
The [HTTP Interface](../HttpAqlUserFunctions/README.md) also offers User Functions management.
|
||||
|
||||
!SUBSECTION Registering an AQL user function
|
||||
|
||||
`aqlfunctions.register(name, code, isDeterministic)`
|
||||
|
|
|
@ -300,11 +300,10 @@
|
|||
* Project Home: http://www.embeddedjs.com
|
||||
* License: [MIT License](http://www.embeddedjs.com/) under Highlights
|
||||
|
||||
#### filesize.js
|
||||
#### prettyBytes.js
|
||||
|
||||
* Project Home: http://filesizejs.com/
|
||||
* GITHUB: https://github.com/avoidwork/filesize.js
|
||||
* License: [BSD-style 3-Clause License](https://github.com/avoidwork/filesize.js/blob/master/LICENSE)
|
||||
* GITHUB: https://github.com/sindresorhus/pretty-bytes
|
||||
* License: [MIT License](https://github.com/sindresorhus/pretty-bytes/blob/master/license)
|
||||
|
||||
#### Jasmine
|
||||
|
||||
|
|
|
@ -98,6 +98,8 @@ int ContinuousSyncer::run() {
|
|||
|
||||
uint64_t shortTermFailsInRow = 0;
|
||||
|
||||
_applier->started();
|
||||
|
||||
retry:
|
||||
double const start = TRI_microtime();
|
||||
std::string errorMsg;
|
||||
|
|
|
@ -3486,6 +3486,8 @@ void RestReplicationHandler::handleCommandApplierSetConfig() {
|
|||
int res =
|
||||
TRI_ConfigureReplicationApplier(_vocbase->_replicationApplier, &config);
|
||||
|
||||
config.freeInternalStrings();
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
generateError(HttpResponse::responseCode(res), res);
|
||||
return;
|
||||
|
|
|
@ -125,7 +125,7 @@ static int LoadConfiguration(TRI_vocbase_t* vocbase,
|
|||
|
||||
// read the database name
|
||||
TRI_json_t const* value = TRI_LookupObjectJson(json.get(), "database");
|
||||
|
||||
|
||||
if (!TRI_IsStringJson(value)) {
|
||||
config->_database = TRI_DuplicateString(TRI_CORE_MEM_ZONE, vocbase->_name);
|
||||
} else {
|
||||
|
@ -1075,6 +1075,7 @@ int TRI_SaveConfigurationReplicationApplier(
|
|||
TRI_replication_applier_t::TRI_replication_applier_t(TRI_server_t* server,
|
||||
TRI_vocbase_t* vocbase)
|
||||
: _databaseName(vocbase->_name),
|
||||
_starts(0),
|
||||
_server(server),
|
||||
_vocbase(vocbase),
|
||||
_terminateThread(false) {}
|
||||
|
@ -1133,6 +1134,9 @@ int TRI_replication_applier_t::start(TRI_voc_tick_t initialTick, bool useTick,
|
|||
_state._lastError._msg = nullptr;
|
||||
}
|
||||
|
||||
// save previous counter value
|
||||
uint64_t oldStarts = _starts.load();
|
||||
|
||||
_state._lastError._code = TRI_ERROR_NO_ERROR;
|
||||
|
||||
TRI_GetTimeStampReplication(_state._lastError._time,
|
||||
|
@ -1150,6 +1154,11 @@ int TRI_replication_applier_t::start(TRI_voc_tick_t initialTick, bool useTick,
|
|||
|
||||
syncer.release();
|
||||
|
||||
uint64_t iterations = 0;
|
||||
while (oldStarts == _starts.load() && ++iterations < 50 * 10) {
|
||||
usleep(20000);
|
||||
}
|
||||
|
||||
if (useTick) {
|
||||
LOG_TOPIC(INFO, Logger::REPLICATION) << "started replication applier for database '" << _databaseName.c_str() << "', endpoint '" << _configuration._endpoint << "' from tick " << initialTick;
|
||||
} else {
|
||||
|
|
|
@ -68,6 +68,9 @@ class TRI_replication_applier_configuration_t {
|
|||
std::unordered_map<std::string, bool> _restrictCollections;
|
||||
|
||||
public:
|
||||
TRI_replication_applier_configuration_t(TRI_replication_applier_configuration_t const&) = delete;
|
||||
TRI_replication_applier_configuration_t& operator=(TRI_replication_applier_configuration_t const&) = delete;
|
||||
|
||||
TRI_replication_applier_configuration_t() {}
|
||||
|
||||
~TRI_replication_applier_configuration_t() { freeInternalStrings(); }
|
||||
|
@ -230,6 +233,14 @@ class TRI_replication_applier_t {
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::shared_ptr<VPackBuilder> toVelocyPack() const;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief increase the starts counter
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void started() {
|
||||
++_starts;
|
||||
}
|
||||
|
||||
private:
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -240,6 +251,7 @@ class TRI_replication_applier_t {
|
|||
|
||||
private:
|
||||
std::string _databaseName;
|
||||
std::atomic<uint64_t> _starts;
|
||||
|
||||
public:
|
||||
TRI_server_t* _server;
|
||||
|
|
|
@ -1108,9 +1108,16 @@ static int RunClusterDump(std::string& errorMsg) {
|
|||
// Iterate over the Map of shardId to server list
|
||||
for (auto const it : VPackObjectIterator(shards)) {
|
||||
TRI_ASSERT(it.key.isString());
|
||||
TRI_ASSERT(it.value.isArray());
|
||||
TRI_ASSERT(it.value[0].isString());
|
||||
|
||||
std::string shardName = it.key.copyString();
|
||||
|
||||
if (! it.value.isArray() || it.value.length() == 0 || !it.value[0].isString()) {
|
||||
TRI_CLOSE(fd);
|
||||
errorMsg = "unexpected value for 'shards' attribute";
|
||||
|
||||
return TRI_ERROR_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
std::string DBserver = it.value[0].copyString();
|
||||
|
||||
if (Progress) {
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
"frontend/js/lib/jquery.textfill.min.js",
|
||||
"frontend/js/lib/jquery.noty.packaged.min.js",
|
||||
"frontend/js/lib/select2.min.js",
|
||||
"frontend/js/lib/sigma.min.js",
|
||||
"frontend/js/lib/jsoneditor-min.js",
|
||||
"frontend/js/lib/strftime-min.js",
|
||||
"frontend/js/lib/d3.fisheye.min.js",
|
||||
|
@ -55,7 +56,7 @@
|
|||
"frontend/js/lib/highlight.7.3.pack.min.js",
|
||||
"frontend/js/lib/joi.browser.js",
|
||||
"frontend/js/lib/md5.min.js",
|
||||
"frontend/js/lib/filesize.min.js",
|
||||
"frontend/js/lib/pretty-bytes.js",
|
||||
"frontend/src/ace.js",
|
||||
"frontend/src/theme-textmate.js",
|
||||
"frontend/src/mode-json.js",
|
||||
|
|
|
@ -38,6 +38,7 @@ var cluster = require("@arangodb/cluster");
|
|||
var joi = require("joi");
|
||||
var util = require("util");
|
||||
var internal = require("internal");
|
||||
var contentDisposition = require('content-disposition');
|
||||
var notifications = require("@arangodb/configuration").notifications;
|
||||
var db = require("@arangodb").db;
|
||||
var foxxInstallKey = joi.string().required().description(
|
||||
|
@ -246,7 +247,7 @@ controller.get("/query/download/:user", function(req, res) {
|
|||
var result = db._users.byExample({"user": user}).toArray()[0];
|
||||
|
||||
res.set("Content-Type", "application/json");
|
||||
res.set("Content-Disposition", "attachment; filename=queries.json");
|
||||
res.set("Content-Disposition", contentDisposition('queries.json'));
|
||||
|
||||
if (result === null || result === undefined) {
|
||||
res.json([]);
|
||||
|
@ -278,7 +279,7 @@ controller.get("/query/result/download/:query", function(req, res) {
|
|||
|
||||
var result = db._query(parsedQuery.query, parsedQuery.bindVars).toArray();
|
||||
res.set("Content-Type", "application/json");
|
||||
res.set("Content-Disposition", "attachment; filename=results.json");
|
||||
res.set("Content-Disposition", contentDisposition('results.json'));
|
||||
res.json(result);
|
||||
|
||||
}).summary("Download the result of a query")
|
||||
|
|
|
@ -1407,17 +1407,46 @@ window.StatisticsCollection = Backbone.Collection.extend({
|
|||
},
|
||||
|
||||
setFiltersForQuery: function(bindVars) {
|
||||
var self = this;
|
||||
|
||||
if (this.filters.length === 0) {
|
||||
return "";
|
||||
}
|
||||
var query = " FILTER",
|
||||
var query = " FILTER", res = '',
|
||||
parts = _.map(this.filters, function(f, i) {
|
||||
var res = " x.`";
|
||||
res += f.attr;
|
||||
res += "` ";
|
||||
res += f.op;
|
||||
res += " @param";
|
||||
res += i;
|
||||
if (f.op === 'LIKE') {
|
||||
res = " " + f.op + "(x.`" + f.attr + "`, @param";
|
||||
res += i;
|
||||
res += ")";
|
||||
}
|
||||
else {
|
||||
if (f.op === 'IN' || f.op === 'NOT IN') {
|
||||
res = ' ';
|
||||
}
|
||||
else {
|
||||
res = " x.`";
|
||||
}
|
||||
|
||||
res += f.attr;
|
||||
|
||||
if (f.op === 'IN' || f.op === 'NOT IN') {
|
||||
res += " ";
|
||||
}
|
||||
else {
|
||||
res += "` ";
|
||||
}
|
||||
|
||||
res += f.op;
|
||||
|
||||
if (f.op === 'IN' || f.op === 'NOT IN') {
|
||||
res += " x.@param";
|
||||
}
|
||||
else {
|
||||
res += " @param";
|
||||
}
|
||||
res += i;
|
||||
}
|
||||
|
||||
bindVars["param" + i] = f.val;
|
||||
return res;
|
||||
});
|
||||
|
|
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
|
@ -5288,6 +5288,7 @@ div.dropdownImport {
|
|||
margin-top: 5px; }
|
||||
|
||||
select.filterSelect {
|
||||
color: #00f;
|
||||
margin-left: 10px;
|
||||
margin-right: 10px;
|
||||
width: 100px; }
|
||||
|
|
Binary file not shown.
|
@ -61,15 +61,4 @@
|
|||
description: "The configuration for the template.",
|
||||
type: Configuration
|
||||
});
|
||||
|
||||
controller.get("/download/:file", function(req, res) {
|
||||
res.json(false);
|
||||
/*
|
||||
var fileName = req.params("file"),
|
||||
path = fs.join(fs.getTempPath(), "downloads", fileName);
|
||||
res.set("Content-Type", "application/octet-stream");
|
||||
res.set("Content-Disposition", "attachment; filename=app.zip");
|
||||
res.body = fs.readFileSync(path);
|
||||
*/
|
||||
});
|
||||
}());
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
var highlightAuto = require("highlight.js").highlightAuto;
|
||||
var docu = require("./lib/swagger").Swagger;
|
||||
var underscore = require("lodash");
|
||||
var contentDisposition = require('content-disposition');
|
||||
var mountPoint = {
|
||||
type: joi.string().required().description(
|
||||
"The mount point of the app. Has to be url-encoded."
|
||||
|
@ -349,7 +350,7 @@
|
|||
var dir = fs.join(fs.makeAbsolute(app.root), app.path);
|
||||
var zipPath = fmUtils.zipDirectory(dir);
|
||||
res.set("Content-Type", "application/octet-stream");
|
||||
res.set("Content-Disposition", "attachment; filename=app.zip");
|
||||
res.set("Content-Disposition", contentDisposition(`${app.name}@${app.version}.zip`));
|
||||
res.body = fs.readFileSync(zipPath);
|
||||
})
|
||||
.queryParam("mount", mountPoint);
|
||||
|
|
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
|
@ -1,3 +1,3 @@
|
|||
<script src="sharedLibs.js?version=1452528228639"></script>
|
||||
<script src="libs.js?version=1452528228639"></script>
|
||||
<script src="app.js?version=1452528228639"></script>
|
||||
<script src="sharedLibs.js?version=1455026760724"></script>
|
||||
<script src="libs.js?version=1455026760724"></script>
|
||||
<script src="app.js?version=1455026760724"></script>
|
||||
|
|
|
@ -812,6 +812,9 @@ if (list.length > 0) {
|
|||
<option value="<="><=</option>
|
||||
<option value=">">></option>
|
||||
<option value=">=">>=</option>
|
||||
<option value="LIKE">LIKE</option>
|
||||
<option value="IN">IN</option>
|
||||
<option value="NOT IN">NOT IN</option>
|
||||
</select><input id="attribute_value0" type="text" placeholder="Attribute value" class="filterValue">
|
||||
<a id="addFilterItem" class="add-filter-item"><i class="icon-plus arangoicon"></i></a>
|
||||
<button id="resetView" class="button-warning btn-old-padding">Reset</button>
|
||||
|
@ -1630,7 +1633,7 @@ if (list.length > 0) {
|
|||
<th class="collectionInfoTh2">Journal size:</th>
|
||||
<th class="collectionInfoTh">
|
||||
<div id="show-collection-size" class="modal-text">
|
||||
<%=filesize(figuresData.journalSize)%>
|
||||
<%=prettyBytes(figuresData.journalSize)%>
|
||||
</div>
|
||||
</th>
|
||||
<th class="tooltipInfoTh">
|
||||
|
@ -1723,7 +1726,7 @@ if (list.length > 0) {
|
|||
<th class="modal-text">Datafiles</th>
|
||||
<th class="modal-text"><%=figuresData.figures.datafiles.count%></th>
|
||||
<th class="modal-text">
|
||||
<%=filesize(figuresData.figures.datafiles.fileSize)%>
|
||||
<%=prettyBytes(figuresData.figures.datafiles.fileSize)%>
|
||||
</th>
|
||||
<th class="tooltipInfoTh">
|
||||
<div>
|
||||
|
@ -1737,7 +1740,7 @@ if (list.length > 0) {
|
|||
<th class="modal-text">Journals</th>
|
||||
<th class="modal-text"><%=figuresData.figures.journals.count%></th>
|
||||
<th class="modal-text">
|
||||
<%=filesize(figuresData.figures.journals.fileSize)%>
|
||||
<%=prettyBytes(figuresData.figures.journals.fileSize)%>
|
||||
</th>
|
||||
<th class="tooltipInfoTh">
|
||||
<a class="modalTooltips" title="Number and total size of journal files.">
|
||||
|
@ -1748,7 +1751,7 @@ if (list.length > 0) {
|
|||
<th class="modal-text">Compactors</th>
|
||||
<th class="modal-text"><%=figuresData.figures.compactors.count%></th>
|
||||
<th class="modal-text">
|
||||
<%=filesize(figuresData.figures.compactors.fileSize)%>
|
||||
<%=prettyBytes(figuresData.figures.compactors.fileSize)%>
|
||||
</th>
|
||||
<th class="tooltipInfoTh">
|
||||
<a class="modalTooltips" title="Number and total size of compactor files.">
|
||||
|
@ -1759,7 +1762,7 @@ if (list.length > 0) {
|
|||
<th class="modal-text">Shape files</th>
|
||||
<th class="modal-text"><%=figuresData.figures.shapefiles.count%></th>
|
||||
<th class="modal-text">
|
||||
<%=filesize(figuresData.figures.shapefiles.fileSize)%>
|
||||
<%=prettyBytes(figuresData.figures.shapefiles.fileSize)%>
|
||||
</th>
|
||||
<th class="tooltipInfoTh">
|
||||
<a class="modalTooltips" title="Number and total size of shape files.">
|
||||
|
@ -1770,7 +1773,7 @@ if (list.length > 0) {
|
|||
<th class="modal-text">Indexes</th>
|
||||
<th class="modal-text"><%=figuresData.figures.indexes.count%></th>
|
||||
<th class="modal-text">
|
||||
<%=filesize(figuresData.figures.indexes.size)%>
|
||||
<%=prettyBytes(figuresData.figures.indexes.size)%>
|
||||
</th>
|
||||
<th class="tooltipInfoTh">
|
||||
<a class="modalTooltips" title="Number and total memory usage of indexes.">
|
||||
|
@ -1831,7 +1834,7 @@ if (list.length > 0) {
|
|||
<th class="modal-text">Alive</th>
|
||||
<th class="modal-text"><%=figuresData.figures.alive.count%></th>
|
||||
<th class="modal-text">
|
||||
<%=filesize(figuresData.figures.alive.size)%>
|
||||
<%=prettyBytes(figuresData.figures.alive.size)%>
|
||||
</th>
|
||||
<th class="modal-text"> -</th>
|
||||
<th class="tooltipInfoTh">
|
||||
|
@ -1844,7 +1847,7 @@ if (list.length > 0) {
|
|||
<th class="modal-text">Dead</th>
|
||||
<th class="modal-text"><%=figuresData.figures.dead.count%></th>
|
||||
<th class="modal-text">
|
||||
<%=filesize(figuresData.figures.dead.size)%>
|
||||
<%=prettyBytes(figuresData.figures.dead.size)%>
|
||||
</th>
|
||||
<th class="modal-text"><%=figuresData.figures.dead.deletion%></th>
|
||||
|
||||
|
@ -2605,12 +2608,13 @@ var cutByResolution = function (str) {
|
|||
odd = !odd;
|
||||
});
|
||||
%>
|
||||
</tbody></script><script id="testView.ejs" type="text/template"><h1>Text File Reader</h1>
|
||||
<div>
|
||||
Select a text file:
|
||||
<input type="file" id="fileInput">
|
||||
</div>
|
||||
<pre id="fileDisplayArea"><pre></script><script id="userBarView.ejs" type="text/template"><ul class="navlist" id="userBarUl">
|
||||
</tbody></script><script id="testView.ejs" type="text/template"><div class="headerBar">
|
||||
<a class="arangoHeader">Test</a>
|
||||
</div>
|
||||
|
||||
<div id="testContent" class="test-content-id innerContent">
|
||||
<div id="graph-container"></div>
|
||||
</div></script><script id="userBarView.ejs" type="text/template"><ul class="navlist" id="userBarUl">
|
||||
|
||||
<li class="dropdown user-menu userImg">
|
||||
<a href="#" class="tab userImg" id="user" >
|
||||
|
@ -2755,4 +2759,4 @@ var cutByResolution = function (str) {
|
|||
<% }); %>
|
||||
</ul>
|
||||
</div>
|
||||
<% } %></script></head><body><nav class="navbar"><div class="resizecontainer"><div class="navlogo"><a class="logo" href="#"><img class="arangodbLogo" src="img/arangodb_logo_small.png"></a></div><div id="progressPlaceholderIcon"></div><div class="statmenu" id="statisticBar"></div><div class="usermenu" id="userBar" style="float:right"></div><div class="notificationmenu" id="notificationBar" style="float:right"></div><div class="navmenu" id="navigationBar"></div></div></nav><div class="centralRow resizecontainer"><div id="content" class="centralContent"></div></div><div id="modalPlaceholder"></div><div id="progressPlaceholder" style="display:none"></div><footer class="footer"><div class="resizecontainer" id="footerBar"></div></footer><div class="arangoFrame" style=""><div class="outerDiv"><div class="innerDiv"></div></div></div><script src="sharedLibs.js?version=1452528228639"></script><script src="libs.js?version=1452528228639"></script><script src="app.js?version=1452528228639"></script></body></html>
|
||||
<% } %></script></head><body><nav class="navbar"><div class="resizecontainer"><div class="navlogo"><a class="logo" href="#"><img class="arangodbLogo" src="img/arangodb_logo_small.png"></a></div><div id="progressPlaceholderIcon"></div><div class="statmenu" id="statisticBar"></div><div class="usermenu" id="userBar" style="float:right"></div><div class="notificationmenu" id="notificationBar" style="float:right"></div><div class="navmenu" id="navigationBar"></div></div></nav><div class="centralRow resizecontainer"><div id="content" class="centralContent"></div></div><div id="modalPlaceholder"></div><div id="progressPlaceholder" style="display:none"></div><footer class="footer"><div class="resizecontainer" id="footerBar"></div></footer><div class="arangoFrame" style=""><div class="outerDiv"><div class="innerDiv"></div></div></div><script src="sharedLibs.js?version=1455026760724"></script><script src="libs.js?version=1455026760724"></script><script src="app.js?version=1455026760724"></script></body></html>
|
Binary file not shown.
|
@ -875,6 +875,9 @@ if (list.length > 0) {
|
|||
<option value="<="><=</option>
|
||||
<option value=">">></option>
|
||||
<option value=">=">>=</option>
|
||||
<option value="LIKE">LIKE</option>
|
||||
<option value="IN">IN</option>
|
||||
<option value="NOT IN">NOT IN</option>
|
||||
</select><input id="attribute_value0" type="text" placeholder="Attribute value" class="filterValue">
|
||||
<a id="addFilterItem" class="add-filter-item"><i class="icon-plus arangoicon"></i></a>
|
||||
<button id="resetView" class="button-warning btn-old-padding">Reset</button>
|
||||
|
@ -1755,7 +1758,7 @@ if (list.length > 0) {
|
|||
<th class="collectionInfoTh2">Journal size:</th>
|
||||
<th class="collectionInfoTh">
|
||||
<div id="show-collection-size" class="modal-text">
|
||||
<%=filesize(figuresData.journalSize)%>
|
||||
<%=prettyBytes(figuresData.journalSize)%>
|
||||
</div>
|
||||
</th>
|
||||
<th class="tooltipInfoTh">
|
||||
|
@ -1848,7 +1851,7 @@ if (list.length > 0) {
|
|||
<th class="modal-text">Datafiles</th>
|
||||
<th class="modal-text"><%=figuresData.figures.datafiles.count%></th>
|
||||
<th class="modal-text">
|
||||
<%=filesize(figuresData.figures.datafiles.fileSize)%>
|
||||
<%=prettyBytes(figuresData.figures.datafiles.fileSize)%>
|
||||
</th>
|
||||
<th class="tooltipInfoTh">
|
||||
<div>
|
||||
|
@ -1862,7 +1865,7 @@ if (list.length > 0) {
|
|||
<th class="modal-text">Journals</th>
|
||||
<th class="modal-text"><%=figuresData.figures.journals.count%></th>
|
||||
<th class="modal-text">
|
||||
<%=filesize(figuresData.figures.journals.fileSize)%>
|
||||
<%=prettyBytes(figuresData.figures.journals.fileSize)%>
|
||||
</th>
|
||||
<th class="tooltipInfoTh">
|
||||
<a class="modalTooltips" title="Number and total size of journal files.">
|
||||
|
@ -1873,7 +1876,7 @@ if (list.length > 0) {
|
|||
<th class="modal-text">Compactors</th>
|
||||
<th class="modal-text"><%=figuresData.figures.compactors.count%></th>
|
||||
<th class="modal-text">
|
||||
<%=filesize(figuresData.figures.compactors.fileSize)%>
|
||||
<%=prettyBytes(figuresData.figures.compactors.fileSize)%>
|
||||
</th>
|
||||
<th class="tooltipInfoTh">
|
||||
<a class="modalTooltips" title="Number and total size of compactor files.">
|
||||
|
@ -1884,7 +1887,7 @@ if (list.length > 0) {
|
|||
<th class="modal-text">Shape files</th>
|
||||
<th class="modal-text"><%=figuresData.figures.shapefiles.count%></th>
|
||||
<th class="modal-text">
|
||||
<%=filesize(figuresData.figures.shapefiles.fileSize)%>
|
||||
<%=prettyBytes(figuresData.figures.shapefiles.fileSize)%>
|
||||
</th>
|
||||
<th class="tooltipInfoTh">
|
||||
<a class="modalTooltips" title="Number and total size of shape files.">
|
||||
|
@ -1895,7 +1898,7 @@ if (list.length > 0) {
|
|||
<th class="modal-text">Indexes</th>
|
||||
<th class="modal-text"><%=figuresData.figures.indexes.count%></th>
|
||||
<th class="modal-text">
|
||||
<%=filesize(figuresData.figures.indexes.size)%>
|
||||
<%=prettyBytes(figuresData.figures.indexes.size)%>
|
||||
</th>
|
||||
<th class="tooltipInfoTh">
|
||||
<a class="modalTooltips" title="Number and total memory usage of indexes.">
|
||||
|
@ -1956,7 +1959,7 @@ if (list.length > 0) {
|
|||
<th class="modal-text">Alive</th>
|
||||
<th class="modal-text"><%=figuresData.figures.alive.count%></th>
|
||||
<th class="modal-text">
|
||||
<%=filesize(figuresData.figures.alive.size)%>
|
||||
<%=prettyBytes(figuresData.figures.alive.size)%>
|
||||
</th>
|
||||
<th class="modal-text"> -</th>
|
||||
<th class="tooltipInfoTh">
|
||||
|
@ -1969,7 +1972,7 @@ if (list.length > 0) {
|
|||
<th class="modal-text">Dead</th>
|
||||
<th class="modal-text"><%=figuresData.figures.dead.count%></th>
|
||||
<th class="modal-text">
|
||||
<%=filesize(figuresData.figures.dead.size)%>
|
||||
<%=prettyBytes(figuresData.figures.dead.size)%>
|
||||
</th>
|
||||
<th class="modal-text"><%=figuresData.figures.dead.deletion%></th>
|
||||
|
||||
|
@ -2802,13 +2805,13 @@ var cutByResolution = function (str) {
|
|||
</script>
|
||||
|
||||
<script id="testView.ejs" type="text/template">
|
||||
<h1>Text File Reader</h1>
|
||||
<div>
|
||||
Select a text file:
|
||||
<input type="file" id="fileInput">
|
||||
</div>
|
||||
<pre id="fileDisplayArea"><pre>
|
||||
<div class="headerBar">
|
||||
<a class="arangoHeader">Test</a>
|
||||
</div>
|
||||
|
||||
<div id="testContent" class="test-content-id innerContent">
|
||||
<div id="graph-container"></div>
|
||||
</div>
|
||||
|
||||
</script>
|
||||
|
||||
|
@ -3011,9 +3014,9 @@ var cutByResolution = function (str) {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<script src="sharedLibs.js?version=1452528228639"></script>
|
||||
<script src="libs.js?version=1452528228639"></script>
|
||||
<script src="app.js?version=1452528228639"></script>
|
||||
<script src="sharedLibs.js?version=1455026760724"></script>
|
||||
<script src="libs.js?version=1455026760724"></script>
|
||||
<script src="app.js?version=1455026760724"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
File diff suppressed because one or more lines are too long
Binary file not shown.
|
@ -5278,6 +5278,7 @@ div.dropdownImport {
|
|||
margin-top: 5px; }
|
||||
|
||||
select.filterSelect {
|
||||
color: #00f;
|
||||
margin-left: 10px;
|
||||
margin-right: 10px;
|
||||
width: 100px; }
|
||||
|
@ -7950,7 +7951,7 @@ main {
|
|||
.arangoDataTable tr {
|
||||
cursor: pointer; }
|
||||
.arangoDataTable td {
|
||||
padding: 10px 18px !important; }
|
||||
padding: 8px 18px !important; }
|
||||
.arangoDataTable .key {
|
||||
font-weight: 100;
|
||||
margin-top: 4px;
|
||||
|
@ -7984,7 +7985,7 @@ table.arangoDataTable tr.odd {
|
|||
display: none; }
|
||||
|
||||
#documentsTableID_wrapper {
|
||||
min-height: 513px !important;
|
||||
min-height: 480px !important;
|
||||
padding-bottom: 0 !important; }
|
||||
#documentsTableID_wrapper .fg-toolbar {
|
||||
visibility: hidden; }
|
||||
|
|
Binary file not shown.
|
@ -1,6 +0,0 @@
|
|||
/*
|
||||
2015 Jason Mulligan
|
||||
@version 3.1.2
|
||||
*/
|
||||
"use strict";!function(a){var b=/b$/,c={bits:["B","kb","Mb","Gb","Tb","Pb","Eb","Zb","Yb"],bytes:["B","kB","MB","GB","TB","PB","EB","ZB","YB"]},d=function(a){var d=void 0===arguments[1]?{}:arguments[1],e=[],f=!1,g=0,h=void 0,i=void 0,j=void 0,k=void 0,l=void 0,m=void 0,n=void 0,o=void 0,p=void 0,q=void 0,r=void 0;if(isNaN(a))throw new Error("Invalid arguments");return j=d.bits===!0,p=d.unix===!0,i=void 0!==d.base?d.base:2,o=void 0!==d.round?d.round:p?1:2,q=void 0!==d.spacer?d.spacer:p?"":" ",r=void 0!==d.suffixes?d.suffixes:{},n=void 0!==d.output?d.output:"string",h=void 0!==d.exponent?d.exponent:-1,m=Number(a),l=0>m,k=i>2?1e3:1024,l&&(m=-m),0===m?(e[0]=0,e[1]=p?"":"B"):((-1===h||isNaN(h))&&(h=Math.floor(Math.log(m)/Math.log(k))),h>8&&(g=1e3*g*(h-8),h=8),g=2===i?m/Math.pow(2,10*h):m/Math.pow(1e3,h),j&&(g=8*g,g>k&&(g/=k,h++)),e[0]=Number(g.toFixed(h>0?o:0)),e[1]=c[j?"bits":"bytes"][h],!f&&p&&(j&&b.test(e[1])&&(e[1]=e[1].toLowerCase()),e[1]=e[1].charAt(0),"B"===e[1]?(e[0]=Math.floor(e[0]),e[1]=""):j||"k"!==e[1]||(e[1]="K"))),l&&(e[0]=-e[0]),e[1]=r[e[1]]||e[1],"array"===n?e:"exponent"===n?h:"object"===n?{value:e[0],suffix:e[1]}:e.join(q)};"undefined"!=typeof exports?module.exports=d:"function"==typeof define?define(function(){return d}):a.filesize=d}("undefined"!=typeof global?global:window);
|
||||
//# sourceMappingURL=filesize.min.js.map
|
|
@ -0,0 +1,46 @@
|
|||
/*!
|
||||
pretty-bytes
|
||||
Convert bytes to a human readable string: 1337 → 1.34 kB
|
||||
https://github.com/sindresorhus/pretty-bytes
|
||||
by Sindre Sorhus
|
||||
MIT License
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
// Number.isNaN() polyfill
|
||||
var isNaN = function (val) {
|
||||
return val !== val;
|
||||
};
|
||||
|
||||
var prettyBytes = function (num) {
|
||||
if (typeof num !== 'number' || isNaN(num)) {
|
||||
throw new TypeError('Expected a number');
|
||||
}
|
||||
|
||||
var exponent;
|
||||
var unit;
|
||||
var neg = num < 0;
|
||||
var units = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
|
||||
if (neg) {
|
||||
num = -num;
|
||||
}
|
||||
|
||||
if (num < 1) {
|
||||
return (neg ? '-' : '') + num + ' B';
|
||||
}
|
||||
|
||||
exponent = Math.min(Math.floor(Math.log(num) / Math.log(1000)), units.length - 1);
|
||||
num = (num / Math.pow(1000, exponent)).toFixed(2) * 1;
|
||||
unit = units[exponent];
|
||||
|
||||
return (neg ? '-' : '') + num + ' ' + unit;
|
||||
};
|
||||
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = prettyBytes;
|
||||
} else {
|
||||
self.prettyBytes = prettyBytes;
|
||||
}
|
||||
})();
|
File diff suppressed because one or more lines are too long
|
@ -424,7 +424,12 @@ ArangoCollection.prototype.revision = function () {
|
|||
ArangoCollection.prototype.drop = function () {
|
||||
var requestResult = this._database._connection.DELETE(this._baseurl());
|
||||
|
||||
arangosh.checkRequestResult(requestResult);
|
||||
if (requestResult !== null
|
||||
&& requestResult.error === true
|
||||
&& requestResult.errorNum !== internal.errors.ERROR_ARANGO_COLLECTION_NOT_FOUND.code) {
|
||||
// check error in case we got anything else but "collection not found"
|
||||
arangosh.checkRequestResult(requestResult);
|
||||
}
|
||||
|
||||
this._status = ArangoCollection.STATUS_DELETED;
|
||||
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
"graph/:name": "showGraph",
|
||||
"userManagement": "userManagement",
|
||||
"userProfile": "userProfile",
|
||||
"logs": "logs"
|
||||
"logs": "logs",
|
||||
"test": "test"
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
|
@ -224,6 +225,17 @@
|
|||
this.queryView.render();
|
||||
this.naviView.selectMenuItem('query-menu');
|
||||
},
|
||||
|
||||
test: function () {
|
||||
if (!this.checkUser()) {
|
||||
return;
|
||||
}
|
||||
if (!this.testView) {
|
||||
this.testView = new window.testView({
|
||||
});
|
||||
}
|
||||
this.testView.render();
|
||||
},
|
||||
|
||||
queryManagement: function () {
|
||||
if (!this.checkUser()) {
|
||||
|
|
|
@ -166,6 +166,10 @@ Module.prototype.define = function (path, definition) {
|
|||
|
||||
// first get rid of any ".." and "."
|
||||
path = this.normalise(path);
|
||||
var match = path.match(/(.+)\/index$/);
|
||||
if (match) {
|
||||
path = match[1];
|
||||
}
|
||||
|
||||
// check if you already know the module, return the exports
|
||||
if (! Module.prototype.moduleCache.hasOwnProperty(path)) {
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<th class="collectionInfoTh2">Journal size:</th>
|
||||
<th class="collectionInfoTh">
|
||||
<div id="show-collection-size" class="modal-text">
|
||||
<%=filesize(figuresData.journalSize)%>
|
||||
<%=prettyBytes(figuresData.journalSize)%>
|
||||
</div>
|
||||
</th>
|
||||
<th class="tooltipInfoTh">
|
||||
|
@ -113,7 +113,7 @@
|
|||
<th class="modal-text">Datafiles</th>
|
||||
<th class="modal-text"><%=figuresData.figures.datafiles.count%></th>
|
||||
<th class="modal-text">
|
||||
<%=filesize(figuresData.figures.datafiles.fileSize)%>
|
||||
<%=prettyBytes(figuresData.figures.datafiles.fileSize)%>
|
||||
</th>
|
||||
<th class="tooltipInfoTh">
|
||||
<div>
|
||||
|
@ -127,7 +127,7 @@
|
|||
<th class="modal-text">Journals</th>
|
||||
<th class="modal-text"><%=figuresData.figures.journals.count%></th>
|
||||
<th class="modal-text">
|
||||
<%=filesize(figuresData.figures.journals.fileSize)%>
|
||||
<%=prettyBytes(figuresData.figures.journals.fileSize)%>
|
||||
</th>
|
||||
<th class="tooltipInfoTh">
|
||||
<a class="modalTooltips" title="Number and total size of journal files.">
|
||||
|
@ -138,7 +138,7 @@
|
|||
<th class="modal-text">Compactors</th>
|
||||
<th class="modal-text"><%=figuresData.figures.compactors.count%></th>
|
||||
<th class="modal-text">
|
||||
<%=filesize(figuresData.figures.compactors.fileSize)%>
|
||||
<%=prettyBytes(figuresData.figures.compactors.fileSize)%>
|
||||
</th>
|
||||
<th class="tooltipInfoTh">
|
||||
<a class="modalTooltips" title="Number and total size of compactor files.">
|
||||
|
@ -149,7 +149,7 @@
|
|||
<th class="modal-text">Shape files</th>
|
||||
<th class="modal-text"><%=figuresData.figures.shapefiles.count%></th>
|
||||
<th class="modal-text">
|
||||
<%=filesize(figuresData.figures.shapefiles.fileSize)%>
|
||||
<%=prettyBytes(figuresData.figures.shapefiles.fileSize)%>
|
||||
</th>
|
||||
<th class="tooltipInfoTh">
|
||||
<a class="modalTooltips" title="Number and total size of shape files.">
|
||||
|
@ -160,7 +160,7 @@
|
|||
<th class="modal-text">Indexes</th>
|
||||
<th class="modal-text"><%=figuresData.figures.indexes.count%></th>
|
||||
<th class="modal-text">
|
||||
<%=filesize(figuresData.figures.indexes.size)%>
|
||||
<%=prettyBytes(figuresData.figures.indexes.size)%>
|
||||
</th>
|
||||
<th class="tooltipInfoTh">
|
||||
<a class="modalTooltips" title="Number and total memory usage of indexes.">
|
||||
|
@ -221,7 +221,7 @@
|
|||
<th class="modal-text">Alive</th>
|
||||
<th class="modal-text"><%=figuresData.figures.alive.count%></th>
|
||||
<th class="modal-text">
|
||||
<%=filesize(figuresData.figures.alive.size)%>
|
||||
<%=prettyBytes(figuresData.figures.alive.size)%>
|
||||
</th>
|
||||
<th class="modal-text"> -</th>
|
||||
<th class="tooltipInfoTh">
|
||||
|
@ -234,7 +234,7 @@
|
|||
<th class="modal-text">Dead</th>
|
||||
<th class="modal-text"><%=figuresData.figures.dead.count%></th>
|
||||
<th class="modal-text">
|
||||
<%=filesize(figuresData.figures.dead.size)%>
|
||||
<%=prettyBytes(figuresData.figures.dead.size)%>
|
||||
</th>
|
||||
<th class="modal-text"><%=figuresData.figures.dead.deletion%></th>
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<script id="testView.ejs" type="text/template">
|
||||
<h1>Text File Reader</h1>
|
||||
<div>
|
||||
Select a text file:
|
||||
<input type="file" id="fileInput">
|
||||
</div>
|
||||
<pre id="fileDisplayArea"><pre>
|
||||
<div class="headerBar">
|
||||
<a class="arangoHeader">Test</a>
|
||||
</div>
|
||||
|
||||
<div id="testContent" class="test-content-id innerContent">
|
||||
<div id="graph-container"></div>
|
||||
</div>
|
||||
|
||||
</script>
|
||||
|
|
|
@ -50,8 +50,15 @@
|
|||
page: currentPage,
|
||||
lastPage: totalPages,
|
||||
click: function(i) {
|
||||
var split = window.location.hash.split("/");
|
||||
if (split[2] === 'documents') {
|
||||
options.page = i;
|
||||
window.location.hash = split[0] + "/" + split[1] + "/" + split[2] + "/" + i;
|
||||
}
|
||||
else {
|
||||
self.jumpTo(i);
|
||||
options.page = i;
|
||||
}
|
||||
}
|
||||
};
|
||||
target.html("");
|
||||
|
|
|
@ -42,10 +42,11 @@
|
|||
this.tableView.setRemoveClick(this.remove.bind(this));
|
||||
},
|
||||
|
||||
setCollectionId : function (colid, pageid) {
|
||||
setCollectionId : function (colid, page) {
|
||||
this.collection.setCollection(colid);
|
||||
this.collection.setPage(page);
|
||||
var type = arangoHelper.collectionApiType(colid);
|
||||
this.pageid = pageid;
|
||||
this.page = page;
|
||||
this.type = type;
|
||||
|
||||
this.checkCollectionState();
|
||||
|
|
|
@ -1,41 +1,733 @@
|
|||
/*jshint browser: true */
|
||||
/*jshint unused: false */
|
||||
/*global Backbone, $, _, window, document, templateEngine, FileReader */
|
||||
/*global Backbone, sigma, templateEngine, document, _, $, arangoHelper, window*/
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
window.testView = Backbone.View.extend({
|
||||
el: '#content',
|
||||
|
||||
graph: {
|
||||
edges: [],
|
||||
nodes: []
|
||||
},
|
||||
|
||||
events: {
|
||||
"change #fileInput" : "readJSON"
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
console.log(undefined);
|
||||
},
|
||||
|
||||
template: templateEngine.createTemplate("testView.ejs"),
|
||||
|
||||
readJSON: function() {
|
||||
var fileInput = document.getElementById('fileInput');
|
||||
var file = fileInput.files[0];
|
||||
var textType = 'application/json';
|
||||
|
||||
if (file.type.match(textType)) {
|
||||
var reader = new FileReader();
|
||||
|
||||
reader.onload = function(e) {
|
||||
$('#fileDisplayArea pre').text(reader.result);
|
||||
};
|
||||
|
||||
reader.readAsText(file);
|
||||
}
|
||||
else {
|
||||
$('#fileDisplayArea pre').text("File not supported!");
|
||||
}
|
||||
render: function () {
|
||||
$(this.el).html(this.template.render({}));
|
||||
this.renderGraph();
|
||||
return this;
|
||||
},
|
||||
|
||||
render: function() {
|
||||
$(this.el).html(this.template.render());
|
||||
return this;
|
||||
}
|
||||
renderGraph: function () {
|
||||
|
||||
this.convertData();
|
||||
|
||||
console.log(this.graph);
|
||||
|
||||
this.s = new sigma({
|
||||
graph: this.graph,
|
||||
container: 'graph-container',
|
||||
verbose: true,
|
||||
renderers: [
|
||||
{
|
||||
container: document.getElementById('graph-container'),
|
||||
type: 'webgl'
|
||||
}
|
||||
]
|
||||
});
|
||||
},
|
||||
|
||||
convertData: function () {
|
||||
|
||||
var self = this;
|
||||
|
||||
_.each(this.dump, function(value) {
|
||||
|
||||
_.each(value.p, function(lol) {
|
||||
self.graph.nodes.push({
|
||||
id: lol.verticesvalue.v._id,
|
||||
label: value.v._key,
|
||||
x: Math.random(),
|
||||
y: Math.random(),
|
||||
size: Math.random()
|
||||
});
|
||||
|
||||
self.graph.edges.push({
|
||||
id: value.e._id,
|
||||
source: value.e._from,
|
||||
target: value.e._to
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
dump: [
|
||||
{
|
||||
"v": {
|
||||
"label": "7",
|
||||
"_id": "circles/G",
|
||||
"_rev": "1841663870851",
|
||||
"_key": "G"
|
||||
},
|
||||
"e": {
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "right_foo",
|
||||
"_id": "edges/1841666099075",
|
||||
"_rev": "1841666099075",
|
||||
"_key": "1841666099075",
|
||||
"_from": "circles/A",
|
||||
"_to": "circles/G"
|
||||
},
|
||||
"p": {
|
||||
"vertices": [
|
||||
{
|
||||
"label": "1",
|
||||
"_id": "circles/A",
|
||||
"_rev": "1841662691203",
|
||||
"_key": "A"
|
||||
},
|
||||
{
|
||||
"label": "7",
|
||||
"_id": "circles/G",
|
||||
"_rev": "1841663870851",
|
||||
"_key": "G"
|
||||
}
|
||||
],
|
||||
"edges": [
|
||||
{
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "right_foo",
|
||||
"_id": "edges/1841666099075",
|
||||
"_rev": "1841666099075",
|
||||
"_key": "1841666099075",
|
||||
"_from": "circles/A",
|
||||
"_to": "circles/G"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"v": {
|
||||
"label": "8",
|
||||
"_id": "circles/H",
|
||||
"_rev": "1841664067459",
|
||||
"_key": "H"
|
||||
},
|
||||
"e": {
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "right_blob",
|
||||
"_id": "edges/1841666295683",
|
||||
"_rev": "1841666295683",
|
||||
"_key": "1841666295683",
|
||||
"_from": "circles/G",
|
||||
"_to": "circles/H"
|
||||
},
|
||||
"p": {
|
||||
"vertices": [
|
||||
{
|
||||
"label": "1",
|
||||
"_id": "circles/A",
|
||||
"_rev": "1841662691203",
|
||||
"_key": "A"
|
||||
},
|
||||
{
|
||||
"label": "7",
|
||||
"_id": "circles/G",
|
||||
"_rev": "1841663870851",
|
||||
"_key": "G"
|
||||
},
|
||||
{
|
||||
"label": "8",
|
||||
"_id": "circles/H",
|
||||
"_rev": "1841664067459",
|
||||
"_key": "H"
|
||||
}
|
||||
],
|
||||
"edges": [
|
||||
{
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "right_foo",
|
||||
"_id": "edges/1841666099075",
|
||||
"_rev": "1841666099075",
|
||||
"_key": "1841666099075",
|
||||
"_from": "circles/A",
|
||||
"_to": "circles/G"
|
||||
},
|
||||
{
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "right_blob",
|
||||
"_id": "edges/1841666295683",
|
||||
"_rev": "1841666295683",
|
||||
"_key": "1841666295683",
|
||||
"_from": "circles/G",
|
||||
"_to": "circles/H"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"v": {
|
||||
"label": "9",
|
||||
"_id": "circles/I",
|
||||
"_rev": "1841664264067",
|
||||
"_key": "I"
|
||||
},
|
||||
"e": {
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "right_blub",
|
||||
"_id": "edges/1841666492291",
|
||||
"_rev": "1841666492291",
|
||||
"_key": "1841666492291",
|
||||
"_from": "circles/H",
|
||||
"_to": "circles/I"
|
||||
},
|
||||
"p": {
|
||||
"vertices": [
|
||||
{
|
||||
"label": "1",
|
||||
"_id": "circles/A",
|
||||
"_rev": "1841662691203",
|
||||
"_key": "A"
|
||||
},
|
||||
{
|
||||
"label": "7",
|
||||
"_id": "circles/G",
|
||||
"_rev": "1841663870851",
|
||||
"_key": "G"
|
||||
},
|
||||
{
|
||||
"label": "8",
|
||||
"_id": "circles/H",
|
||||
"_rev": "1841664067459",
|
||||
"_key": "H"
|
||||
},
|
||||
{
|
||||
"label": "9",
|
||||
"_id": "circles/I",
|
||||
"_rev": "1841664264067",
|
||||
"_key": "I"
|
||||
}
|
||||
],
|
||||
"edges": [
|
||||
{
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "right_foo",
|
||||
"_id": "edges/1841666099075",
|
||||
"_rev": "1841666099075",
|
||||
"_key": "1841666099075",
|
||||
"_from": "circles/A",
|
||||
"_to": "circles/G"
|
||||
},
|
||||
{
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "right_blob",
|
||||
"_id": "edges/1841666295683",
|
||||
"_rev": "1841666295683",
|
||||
"_key": "1841666295683",
|
||||
"_from": "circles/G",
|
||||
"_to": "circles/H"
|
||||
},
|
||||
{
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "right_blub",
|
||||
"_id": "edges/1841666492291",
|
||||
"_rev": "1841666492291",
|
||||
"_key": "1841666492291",
|
||||
"_from": "circles/H",
|
||||
"_to": "circles/I"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"v": {
|
||||
"label": "10",
|
||||
"_id": "circles/J",
|
||||
"_rev": "1841664460675",
|
||||
"_key": "J"
|
||||
},
|
||||
"e": {
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "right_zip",
|
||||
"_id": "edges/1841666688899",
|
||||
"_rev": "1841666688899",
|
||||
"_key": "1841666688899",
|
||||
"_from": "circles/G",
|
||||
"_to": "circles/J"
|
||||
},
|
||||
"p": {
|
||||
"vertices": [
|
||||
{
|
||||
"label": "1",
|
||||
"_id": "circles/A",
|
||||
"_rev": "1841662691203",
|
||||
"_key": "A"
|
||||
},
|
||||
{
|
||||
"label": "7",
|
||||
"_id": "circles/G",
|
||||
"_rev": "1841663870851",
|
||||
"_key": "G"
|
||||
},
|
||||
{
|
||||
"label": "10",
|
||||
"_id": "circles/J",
|
||||
"_rev": "1841664460675",
|
||||
"_key": "J"
|
||||
}
|
||||
],
|
||||
"edges": [
|
||||
{
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "right_foo",
|
||||
"_id": "edges/1841666099075",
|
||||
"_rev": "1841666099075",
|
||||
"_key": "1841666099075",
|
||||
"_from": "circles/A",
|
||||
"_to": "circles/G"
|
||||
},
|
||||
{
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "right_zip",
|
||||
"_id": "edges/1841666688899",
|
||||
"_rev": "1841666688899",
|
||||
"_key": "1841666688899",
|
||||
"_from": "circles/G",
|
||||
"_to": "circles/J"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"v": {
|
||||
"label": "11",
|
||||
"_id": "circles/K",
|
||||
"_rev": "1841664657283",
|
||||
"_key": "K"
|
||||
},
|
||||
"e": {
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "right_zup",
|
||||
"_id": "edges/1841666885507",
|
||||
"_rev": "1841666885507",
|
||||
"_key": "1841666885507",
|
||||
"_from": "circles/J",
|
||||
"_to": "circles/K"
|
||||
},
|
||||
"p": {
|
||||
"vertices": [
|
||||
{
|
||||
"label": "1",
|
||||
"_id": "circles/A",
|
||||
"_rev": "1841662691203",
|
||||
"_key": "A"
|
||||
},
|
||||
{
|
||||
"label": "7",
|
||||
"_id": "circles/G",
|
||||
"_rev": "1841663870851",
|
||||
"_key": "G"
|
||||
},
|
||||
{
|
||||
"label": "10",
|
||||
"_id": "circles/J",
|
||||
"_rev": "1841664460675",
|
||||
"_key": "J"
|
||||
},
|
||||
{
|
||||
"label": "11",
|
||||
"_id": "circles/K",
|
||||
"_rev": "1841664657283",
|
||||
"_key": "K"
|
||||
}
|
||||
],
|
||||
"edges": [
|
||||
{
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "right_foo",
|
||||
"_id": "edges/1841666099075",
|
||||
"_rev": "1841666099075",
|
||||
"_key": "1841666099075",
|
||||
"_from": "circles/A",
|
||||
"_to": "circles/G"
|
||||
},
|
||||
{
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "right_zip",
|
||||
"_id": "edges/1841666688899",
|
||||
"_rev": "1841666688899",
|
||||
"_key": "1841666688899",
|
||||
"_from": "circles/G",
|
||||
"_to": "circles/J"
|
||||
},
|
||||
{
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "right_zup",
|
||||
"_id": "edges/1841666885507",
|
||||
"_rev": "1841666885507",
|
||||
"_key": "1841666885507",
|
||||
"_from": "circles/J",
|
||||
"_to": "circles/K"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"v": {
|
||||
"label": "2",
|
||||
"_id": "circles/B",
|
||||
"_rev": "1841662887811",
|
||||
"_key": "B"
|
||||
},
|
||||
"e": {
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "left_bar",
|
||||
"_id": "edges/1841665116035",
|
||||
"_rev": "1841665116035",
|
||||
"_key": "1841665116035",
|
||||
"_from": "circles/A",
|
||||
"_to": "circles/B"
|
||||
},
|
||||
"p": {
|
||||
"vertices": [
|
||||
{
|
||||
"label": "1",
|
||||
"_id": "circles/A",
|
||||
"_rev": "1841662691203",
|
||||
"_key": "A"
|
||||
},
|
||||
{
|
||||
"label": "2",
|
||||
"_id": "circles/B",
|
||||
"_rev": "1841662887811",
|
||||
"_key": "B"
|
||||
}
|
||||
],
|
||||
"edges": [
|
||||
{
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "left_bar",
|
||||
"_id": "edges/1841665116035",
|
||||
"_rev": "1841665116035",
|
||||
"_key": "1841665116035",
|
||||
"_from": "circles/A",
|
||||
"_to": "circles/B"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"v": {
|
||||
"label": "5",
|
||||
"_id": "circles/E",
|
||||
"_rev": "1841663477635",
|
||||
"_key": "E"
|
||||
},
|
||||
"e": {
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "left_blub",
|
||||
"_id": "edges/1841665705859",
|
||||
"_rev": "1841665705859",
|
||||
"_key": "1841665705859",
|
||||
"_from": "circles/B",
|
||||
"_to": "circles/E"
|
||||
},
|
||||
"p": {
|
||||
"vertices": [
|
||||
{
|
||||
"label": "1",
|
||||
"_id": "circles/A",
|
||||
"_rev": "1841662691203",
|
||||
"_key": "A"
|
||||
},
|
||||
{
|
||||
"label": "2",
|
||||
"_id": "circles/B",
|
||||
"_rev": "1841662887811",
|
||||
"_key": "B"
|
||||
},
|
||||
{
|
||||
"label": "5",
|
||||
"_id": "circles/E",
|
||||
"_rev": "1841663477635",
|
||||
"_key": "E"
|
||||
}
|
||||
],
|
||||
"edges": [
|
||||
{
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "left_bar",
|
||||
"_id": "edges/1841665116035",
|
||||
"_rev": "1841665116035",
|
||||
"_key": "1841665116035",
|
||||
"_from": "circles/A",
|
||||
"_to": "circles/B"
|
||||
},
|
||||
{
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "left_blub",
|
||||
"_id": "edges/1841665705859",
|
||||
"_rev": "1841665705859",
|
||||
"_key": "1841665705859",
|
||||
"_from": "circles/B",
|
||||
"_to": "circles/E"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"v": {
|
||||
"label": "6",
|
||||
"_id": "circles/F",
|
||||
"_rev": "1841663674243",
|
||||
"_key": "F"
|
||||
},
|
||||
"e": {
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "left_schubi",
|
||||
"_id": "edges/1841665902467",
|
||||
"_rev": "1841665902467",
|
||||
"_key": "1841665902467",
|
||||
"_from": "circles/E",
|
||||
"_to": "circles/F"
|
||||
},
|
||||
"p": {
|
||||
"vertices": [
|
||||
{
|
||||
"label": "1",
|
||||
"_id": "circles/A",
|
||||
"_rev": "1841662691203",
|
||||
"_key": "A"
|
||||
},
|
||||
{
|
||||
"label": "2",
|
||||
"_id": "circles/B",
|
||||
"_rev": "1841662887811",
|
||||
"_key": "B"
|
||||
},
|
||||
{
|
||||
"label": "5",
|
||||
"_id": "circles/E",
|
||||
"_rev": "1841663477635",
|
||||
"_key": "E"
|
||||
},
|
||||
{
|
||||
"label": "6",
|
||||
"_id": "circles/F",
|
||||
"_rev": "1841663674243",
|
||||
"_key": "F"
|
||||
}
|
||||
],
|
||||
"edges": [
|
||||
{
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "left_bar",
|
||||
"_id": "edges/1841665116035",
|
||||
"_rev": "1841665116035",
|
||||
"_key": "1841665116035",
|
||||
"_from": "circles/A",
|
||||
"_to": "circles/B"
|
||||
},
|
||||
{
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "left_blub",
|
||||
"_id": "edges/1841665705859",
|
||||
"_rev": "1841665705859",
|
||||
"_key": "1841665705859",
|
||||
"_from": "circles/B",
|
||||
"_to": "circles/E"
|
||||
},
|
||||
{
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "left_schubi",
|
||||
"_id": "edges/1841665902467",
|
||||
"_rev": "1841665902467",
|
||||
"_key": "1841665902467",
|
||||
"_from": "circles/E",
|
||||
"_to": "circles/F"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"v": {
|
||||
"label": "3",
|
||||
"_id": "circles/C",
|
||||
"_rev": "1841663084419",
|
||||
"_key": "C"
|
||||
},
|
||||
"e": {
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "left_blarg",
|
||||
"_id": "edges/1841665312643",
|
||||
"_rev": "1841665312643",
|
||||
"_key": "1841665312643",
|
||||
"_from": "circles/B",
|
||||
"_to": "circles/C"
|
||||
},
|
||||
"p": {
|
||||
"vertices": [
|
||||
{
|
||||
"label": "1",
|
||||
"_id": "circles/A",
|
||||
"_rev": "1841662691203",
|
||||
"_key": "A"
|
||||
},
|
||||
{
|
||||
"label": "2",
|
||||
"_id": "circles/B",
|
||||
"_rev": "1841662887811",
|
||||
"_key": "B"
|
||||
},
|
||||
{
|
||||
"label": "3",
|
||||
"_id": "circles/C",
|
||||
"_rev": "1841663084419",
|
||||
"_key": "C"
|
||||
}
|
||||
],
|
||||
"edges": [
|
||||
{
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "left_bar",
|
||||
"_id": "edges/1841665116035",
|
||||
"_rev": "1841665116035",
|
||||
"_key": "1841665116035",
|
||||
"_from": "circles/A",
|
||||
"_to": "circles/B"
|
||||
},
|
||||
{
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "left_blarg",
|
||||
"_id": "edges/1841665312643",
|
||||
"_rev": "1841665312643",
|
||||
"_key": "1841665312643",
|
||||
"_from": "circles/B",
|
||||
"_to": "circles/C"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"v": {
|
||||
"label": "4",
|
||||
"_id": "circles/D",
|
||||
"_rev": "1841663281027",
|
||||
"_key": "D"
|
||||
},
|
||||
"e": {
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "left_blorg",
|
||||
"_id": "edges/1841665509251",
|
||||
"_rev": "1841665509251",
|
||||
"_key": "1841665509251",
|
||||
"_from": "circles/C",
|
||||
"_to": "circles/D"
|
||||
},
|
||||
"p": {
|
||||
"vertices": [
|
||||
{
|
||||
"label": "1",
|
||||
"_id": "circles/A",
|
||||
"_rev": "1841662691203",
|
||||
"_key": "A"
|
||||
},
|
||||
{
|
||||
"label": "2",
|
||||
"_id": "circles/B",
|
||||
"_rev": "1841662887811",
|
||||
"_key": "B"
|
||||
},
|
||||
{
|
||||
"label": "3",
|
||||
"_id": "circles/C",
|
||||
"_rev": "1841663084419",
|
||||
"_key": "C"
|
||||
},
|
||||
{
|
||||
"label": "4",
|
||||
"_id": "circles/D",
|
||||
"_rev": "1841663281027",
|
||||
"_key": "D"
|
||||
}
|
||||
],
|
||||
"edges": [
|
||||
{
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "left_bar",
|
||||
"_id": "edges/1841665116035",
|
||||
"_rev": "1841665116035",
|
||||
"_key": "1841665116035",
|
||||
"_from": "circles/A",
|
||||
"_to": "circles/B"
|
||||
},
|
||||
{
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "left_blarg",
|
||||
"_id": "edges/1841665312643",
|
||||
"_rev": "1841665312643",
|
||||
"_key": "1841665312643",
|
||||
"_from": "circles/B",
|
||||
"_to": "circles/C"
|
||||
},
|
||||
{
|
||||
"theFalse": false,
|
||||
"theTruth": true,
|
||||
"label": "left_blorg",
|
||||
"_id": "edges/1841665509251",
|
||||
"_rev": "1841665509251",
|
||||
"_key": "1841665509251",
|
||||
"_from": "circles/C",
|
||||
"_to": "circles/D"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
});
|
||||
}());
|
||||
|
|
|
@ -89,6 +89,7 @@ $c-notification-red: $c-negative;
|
|||
$c-invalid-red: rgba(234, 23, 23, .6);
|
||||
|
||||
$c-info-blue: #5bc0de;
|
||||
$c-blue: #00f;
|
||||
|
||||
$c-cluster-button-green: #617e2b;
|
||||
$c-cluster-button-green-hover: #8ba142;
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
}
|
||||
|
||||
td {
|
||||
padding: 10px 18px !important;
|
||||
padding: 8px 18px !important;
|
||||
}
|
||||
|
||||
.key {
|
||||
|
@ -84,7 +84,7 @@ table.arangoDataTable tr.odd {
|
|||
}
|
||||
|
||||
#documentsTableID_wrapper {
|
||||
min-height: 513px !important;
|
||||
min-height: 480px !important;
|
||||
padding-bottom: 0 !important;
|
||||
|
||||
.fg-toolbar {
|
||||
|
|
|
@ -173,6 +173,7 @@ div.dropdownImport {
|
|||
}
|
||||
|
||||
select.filterSelect {
|
||||
color: $c-blue;
|
||||
margin-left: 10px;
|
||||
margin-right: 10px;
|
||||
width: 100px;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
font-family: 'Open Sans',sans-serif !important;
|
||||
font-size: 10pt !important;
|
||||
font-weight: 100 !important;
|
||||
z-index: 99999999;
|
||||
}
|
||||
|
||||
.tooltip-inner {
|
||||
|
|
|
@ -423,7 +423,12 @@ ArangoCollection.prototype.revision = function () {
|
|||
ArangoCollection.prototype.drop = function () {
|
||||
var requestResult = this._database._connection.DELETE(this._baseurl());
|
||||
|
||||
arangosh.checkRequestResult(requestResult);
|
||||
if (requestResult !== null
|
||||
&& requestResult.error === true
|
||||
&& requestResult.errorNum !== internal.errors.ERROR_ARANGO_COLLECTION_NOT_FOUND.code) {
|
||||
// check error in case we got anything else but "collection not found"
|
||||
arangosh.checkRequestResult(requestResult);
|
||||
}
|
||||
|
||||
this._status = ArangoCollection.STATUS_DELETED;
|
||||
|
||||
|
|
|
@ -87,7 +87,8 @@ function Repository(collection, opts) {
|
|||
|
||||
EventEmitter.call(this);
|
||||
|
||||
_.each(this.model, function (listener, eventName) {
|
||||
Object.keys(this.model).forEach(function (eventName) {
|
||||
const listener = this.model[eventName];
|
||||
if (EVENTS.indexOf(eventName) === -1 || typeof listener !== 'function') {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -197,6 +197,14 @@ function ReplicationSuite() {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
setUp: function() {
|
||||
connectToSlave();
|
||||
try {
|
||||
replication.applier.stop();
|
||||
replication.applier.forget();
|
||||
}
|
||||
catch (err) {
|
||||
}
|
||||
|
||||
connectToMaster();
|
||||
|
||||
db._drop(cn);
|
||||
|
@ -215,6 +223,8 @@ function ReplicationSuite() {
|
|||
|
||||
connectToSlave();
|
||||
replication.applier.stop();
|
||||
replication.applier.forget();
|
||||
|
||||
db._drop(cn);
|
||||
db._drop(cn2);
|
||||
},
|
||||
|
|
|
@ -157,7 +157,7 @@ function ReplicationSuite() {
|
|||
}
|
||||
|
||||
if (compareTicks(slaveState.state.lastAppliedContinuousTick, syncResult.lastLogTick) >= 0 ||
|
||||
compareTicks(slaveState.state.lastProcessedContinuousTick, syncResult.lastLogTick) >= 0) { //||
|
||||
compareTicks(slaveState.state.lastProcessedContinuousTick, syncResult.lastLogTick) >= 0) { //||
|
||||
// compareTicks(slaveState.state.lastAvailableContinuousTick, syncResult.lastLogTick) > 0) {
|
||||
break;
|
||||
}
|
||||
|
@ -180,6 +180,13 @@ function ReplicationSuite() {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
setUp: function() {
|
||||
connectToSlave();
|
||||
try {
|
||||
replication.applier.stop();
|
||||
replication.applier.forget();
|
||||
}
|
||||
catch (err) {
|
||||
}
|
||||
connectToMaster();
|
||||
|
||||
db._drop(cn);
|
||||
|
@ -200,6 +207,7 @@ function ReplicationSuite() {
|
|||
|
||||
connectToSlave();
|
||||
replication.applier.stop();
|
||||
replication.applier.forget();
|
||||
db._drop(cn);
|
||||
db._drop(cn2);
|
||||
db._drop("_test");
|
||||
|
@ -219,7 +227,6 @@ function ReplicationSuite() {
|
|||
try {
|
||||
replication.applier.properties(configuration);
|
||||
} catch (err) {
|
||||
require("internal").print(err);
|
||||
assertEqual(errors.ERROR_HTTP_UNAUTHORIZED.code, err.errorNum);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -0,0 +1,123 @@
|
|||
/*global describe, it, beforeEach */
|
||||
'use strict';
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Spec for foxx repository
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2016 ArangoDB 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 ArangoDB GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Alan Plum
|
||||
/// @author Copyright 2016, ArangoDB GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const expect = require('chai').expect;
|
||||
const sinon = require('sinon');
|
||||
const FoxxRepository = require('@arangodb/foxx/repository').Repository;
|
||||
const FoxxModel = require('@arangodb/foxx/model').Model;
|
||||
|
||||
describe('Repository Events', function () {
|
||||
let collection, Model;
|
||||
|
||||
beforeEach(function () {
|
||||
Model = FoxxModel.extend({}, {});
|
||||
collection = {};
|
||||
});
|
||||
|
||||
it('should emit beforeCreate and afterCreate events when creating the model', function () {
|
||||
var model = prepInstance(Model, 'Create');
|
||||
collection.type = sinon.stub().returns(2);
|
||||
collection.save = sinon.stub();
|
||||
var repository = new FoxxRepository(collection, {model: Model});
|
||||
expect(repository.save(model)).to.equal(model);
|
||||
expect(model.get('beforeCalled')).to.equal(true);
|
||||
expect(model.get('afterCalled')).to.equal(true);
|
||||
});
|
||||
|
||||
it('should emit beforeSave and afterSave events when creating the model', function () {
|
||||
var model = prepInstance(Model, 'Save');
|
||||
collection.type = sinon.stub().returns(2);
|
||||
collection.save = sinon.stub();
|
||||
var repository = new FoxxRepository(collection, {model: Model});
|
||||
expect(repository.save(model)).to.equal(model);
|
||||
expect(model.get('beforeCalled')).to.equal(true);
|
||||
expect(model.get('afterCalled')).to.equal(true);
|
||||
});
|
||||
|
||||
it('should emit beforeUpdate and afterUpdate events when updating the model', function () {
|
||||
var newData = {newAttribute: 'test'};
|
||||
var model = prepInstance(Model, 'Update', newData);
|
||||
collection.type = sinon.stub().returns(2);
|
||||
collection.update = sinon.stub();
|
||||
var repository = new FoxxRepository(collection, {model: Model});
|
||||
expect(repository.update(model, newData)).to.equal(model);
|
||||
expect(model.get('beforeCalled')).to.equal(true);
|
||||
expect(model.get('afterCalled')).to.equal(true);
|
||||
});
|
||||
|
||||
it('should emit beforeSave and afterSave events when updating the model', function () {
|
||||
var newData = {newAttribute: 'test'};
|
||||
var model = prepInstance(Model, 'Save', newData);
|
||||
collection.type = sinon.stub().returns(2);
|
||||
collection.update = sinon.stub();
|
||||
var repository = new FoxxRepository(collection, {model: Model});
|
||||
expect(repository.update(model, newData)).to.equal(model);
|
||||
expect(model.get('beforeCalled')).to.equal(true);
|
||||
expect(model.get('afterCalled')).to.equal(true);
|
||||
});
|
||||
|
||||
it('should emit beforeRemove and afterRemove events when removing the model', function () {
|
||||
var model = prepInstance(Model, 'Remove');
|
||||
collection.type = sinon.stub().returns(2);
|
||||
collection.remove = sinon.stub();
|
||||
var repository = new FoxxRepository(collection, {model: Model});
|
||||
repository.remove(model);
|
||||
expect(model.get('beforeCalled')).to.equal(true);
|
||||
expect(model.get('afterCalled')).to.equal(true);
|
||||
});
|
||||
});
|
||||
|
||||
function prepInstance(Model, ev, dataToReceive) {
|
||||
let model;
|
||||
const random = String(Math.floor(Math.random() * 1000));
|
||||
|
||||
Model['before' + ev] = function (instance, data) {
|
||||
expect(instance).to.equal(model);
|
||||
expect(data).to.equal(dataToReceive);
|
||||
instance.set('random', random);
|
||||
instance.set('beforeCalled', true);
|
||||
};
|
||||
|
||||
Model['after' + ev] = function (instance, data) {
|
||||
expect(instance).to.equal(model);
|
||||
expect(data).to.equal(dataToReceive);
|
||||
instance.set('afterCalled', true);
|
||||
expect(instance.get('beforeCalled')).to.equal(true);
|
||||
expect(instance.get('random')).to.equal(random);
|
||||
};
|
||||
|
||||
model = new Model({
|
||||
random: '',
|
||||
beforeCalled: false,
|
||||
afterCalled: false
|
||||
});
|
||||
|
||||
return model;
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
/*global describe, it, beforeEach */
|
||||
'use strict';
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Spec for foxx repository
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2015-2016 ArangoDB 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 ArangoDB GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Alan Plum
|
||||
/// @author Copyright 2015, ArangoDB GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const expect = require('chai').expect;
|
||||
const sinon = require('sinon');
|
||||
const FoxxRepository = require('@arangodb/foxx/repository').Repository;
|
||||
const Model = require('@arangodb/foxx/model').Model;
|
||||
|
||||
describe('Model Events', function () {
|
||||
let collection, instance, repository;
|
||||
|
||||
beforeEach(function () {
|
||||
collection = {
|
||||
type: sinon.stub().returns(2)
|
||||
};
|
||||
instance = new Model();
|
||||
repository = new FoxxRepository(collection, {model: Model, random: '', beforeCalled: false, afterCalled: false});
|
||||
});
|
||||
|
||||
it('should be possible to subscribe and emit events', function () {
|
||||
expect(repository.on).to.be.a('function');
|
||||
expect(repository.emit).to.be.a('function');
|
||||
});
|
||||
|
||||
it('should emit beforeCreate and afterCreate events when creating the model', function () {
|
||||
collection.save = sinon.stub();
|
||||
addHooks(repository, instance, 'Create');
|
||||
expect(repository.save(instance)).to.equal(instance);
|
||||
expect(repository.beforeCalled).to.equal(true);
|
||||
expect(repository.afterCalled).to.equal(true);
|
||||
});
|
||||
|
||||
it('should emit beforeSave and afterSave events when creating the model', function () {
|
||||
collection.save = sinon.stub();
|
||||
addHooks(repository, instance, 'Save');
|
||||
expect(repository.save(instance)).to.equal(instance);
|
||||
expect(repository.beforeCalled).to.equal(true);
|
||||
expect(repository.afterCalled).to.equal(true);
|
||||
});
|
||||
|
||||
it('should emit beforeUpdate and afterUpdate events when updating the model', function () {
|
||||
var newData = {newAttribute: 'test'};
|
||||
collection.update = sinon.stub();
|
||||
addHooks(repository, instance, 'Update', newData);
|
||||
expect(repository.update(instance, newData)).to.equal(instance);
|
||||
expect(repository.beforeCalled).to.equal(true);
|
||||
expect(repository.afterCalled).to.equal(true);
|
||||
});
|
||||
|
||||
it('should emit beforeSave and afterSave events when updating the model', function () {
|
||||
var newData = {newAttribute: 'test'};
|
||||
collection.update = sinon.stub();
|
||||
addHooks(repository, instance, 'Save', newData);
|
||||
expect(repository.update(instance, newData)).to.equal(instance);
|
||||
expect(repository.beforeCalled).to.equal(true);
|
||||
expect(repository.afterCalled).to.equal(true);
|
||||
});
|
||||
|
||||
it('should emit beforeRemove and afterRemove events when removing the model', function () {
|
||||
collection.remove = sinon.stub();
|
||||
addHooks(repository, instance, 'Remove');
|
||||
repository.remove(instance);
|
||||
expect(repository.beforeCalled).to.equal(true);
|
||||
expect(repository.afterCalled).to.equal(true);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function addHooks(repo, model, ev, dataToReceive) {
|
||||
const random = String(Math.floor(Math.random() * 1000));
|
||||
|
||||
repo.on('before' + ev, function (self, data) {
|
||||
expect(this).to.equal(repo);
|
||||
expect(self).to.equal(model);
|
||||
expect(data).to.equal(dataToReceive);
|
||||
this.random = random;
|
||||
this.beforeCalled = true;
|
||||
});
|
||||
|
||||
repo.on('after' + ev, function (self, data) {
|
||||
expect(this).to.equal(repo);
|
||||
expect(self).to.equal(model);
|
||||
expect(data).to.equal(dataToReceive);
|
||||
this.afterCalled = true;
|
||||
expect(this.beforeCalled).to.equal(true);
|
||||
expect(this.random).to.equal(random);
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue