mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of github.com:triAGENS/ArangoDB into sharding
Conflicts: arangod/V8Server/ApplicationV8.cpp
This commit is contained in:
commit
726144ce39
|
@ -27,10 +27,12 @@
|
|||
|
||||
#include "ApplicationV8.h"
|
||||
|
||||
#include "Actions/actions.h"
|
||||
#include "ApplicationServer/ApplicationServer.h"
|
||||
#include "Basics/ConditionLocker.h"
|
||||
#include "Basics/FileUtils.h"
|
||||
#include "Basics/MutexLocker.h"
|
||||
#include "Basics/Mutex.h"
|
||||
#include "Basics/MutexLocker.h"
|
||||
#include "Basics/ReadLocker.h"
|
||||
#include "Basics/StringUtils.h"
|
||||
#include "Basics/Thread.h"
|
||||
|
@ -46,7 +48,6 @@
|
|||
#include "V8Server/v8-query.h"
|
||||
#include "V8Server/v8-vocbase.h"
|
||||
#include "VocBase/server.h"
|
||||
#include "Actions/actions.h"
|
||||
|
||||
#ifdef TRI_ENABLE_CLUSTER
|
||||
#include "Cluster/ServerState.h"
|
||||
|
@ -56,6 +57,7 @@
|
|||
using namespace triagens;
|
||||
using namespace triagens::basics;
|
||||
using namespace triagens::arango;
|
||||
using namespace triagens::rest;
|
||||
using namespace std;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -208,6 +210,7 @@ ApplicationV8::ApplicationV8 (TRI_server_t* server)
|
|||
_devAppPath(),
|
||||
_useActions(true),
|
||||
_developmentMode(false),
|
||||
_frontendDevelopmentMode(false),
|
||||
_performUpgrade(false),
|
||||
_skipUpgrade(false),
|
||||
_gcInterval(1000),
|
||||
|
@ -594,11 +597,16 @@ void ApplicationV8::setupOptions (map<string, basics::ProgramOptionsDescription>
|
|||
("javascript.dev-app-path", &_devAppPath, "directory for Foxx applications (development mode)")
|
||||
("javascript.startup-directory", &_startupPath, "path to the directory containing JavaScript startup scripts")
|
||||
("javascript.v8-options", &_v8Options, "options to pass to v8")
|
||||
|
||||
// deprecated options
|
||||
("javascript.action-directory", &DeprecatedPath, "path to the JavaScript action directory (deprecated)")
|
||||
("javascript.modules-path", &DeprecatedPath, "one or more directories separated by semi-colons (deprecated)")
|
||||
("javascript.package-path", &DeprecatedPath, "one or more directories separated by semi-colons (deprecated)")
|
||||
;
|
||||
|
||||
options[ApplicationServer::OPTIONS_HIDDEN]
|
||||
("javascript.frontend-development", &_frontendDevelopmentMode, "allows rebuild frontend assets")
|
||||
;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -803,6 +811,7 @@ bool ApplicationV8::prepareV8Instance (const size_t i) {
|
|||
TRI_AddGlobalVariableVocbase(context->_context, "APP_PATH", v8::String::New(_appPath.c_str(), _appPath.size()));
|
||||
TRI_AddGlobalVariableVocbase(context->_context, "DEV_APP_PATH", v8::String::New(_devAppPath.c_str(), _devAppPath.size()));
|
||||
TRI_AddGlobalVariableVocbase(context->_context, "DEVELOPMENT_MODE", v8::Boolean::New(_developmentMode));
|
||||
TRI_AddGlobalVariableVocbase(context->_context, "FE_DEVELOPMENT_MODE", v8::Boolean::New(_frontendDevelopmentMode));
|
||||
}
|
||||
|
||||
// set global flag before loading system files
|
||||
|
|
|
@ -434,11 +434,17 @@ namespace triagens {
|
|||
bool _useActions;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief use development mode
|
||||
/// @brief enables development mode
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool _developmentMode;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief enables frontend development mode
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool _frontendDevelopmentMode;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief perform a database upgrade
|
||||
///
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<body>
|
||||
HHALO
|
||||
<nav class="navbar">
|
||||
<div class="resizecontainer">
|
||||
<div class="navlogo">
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 769 B |
|
@ -127,6 +127,23 @@
|
|||
SYS_LOG("warning", "################################################################################");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief frontendDevelopmentMode
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
exports.frontendDevelopmentMode = false;
|
||||
|
||||
if (typeof FE_DEVELOPMENT_MODE !== "undefined") {
|
||||
exports.frontendDevelopmentMode = FE_DEVELOPMENT_MODE;
|
||||
delete FE_DEVELOPMENT_MODE;
|
||||
}
|
||||
|
||||
if (exports.frontendDevelopmentMode && exports.threadNumber === 0) {
|
||||
SYS_LOG("warning", "################################################################################");
|
||||
SYS_LOG("warning", "frontend development mode is active, never use this in production");
|
||||
SYS_LOG("warning", "################################################################################");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief logfilePath
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global window, Backbone, $, window */
|
||||
/*global window, Backbone, $,_, window */
|
||||
|
||||
window.ArangoUsers = Backbone.Collection.extend({
|
||||
model: window.Users,
|
||||
|
@ -71,6 +71,20 @@ window.ArangoUsers = Backbone.Collection.extend({
|
|||
result.push(object);
|
||||
});
|
||||
return result;
|
||||
},
|
||||
|
||||
whoAmI: function() {
|
||||
if (this.currentUser) {
|
||||
return this.currentUser;
|
||||
}
|
||||
var result;
|
||||
$.ajax("whoAmI", {async:false}).done(
|
||||
function(data) {
|
||||
result = data.name;
|
||||
}
|
||||
);
|
||||
this.currentUser = result;
|
||||
return this.currentUser;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -9,10 +9,24 @@
|
|||
<img src="<%=img%>" id="userimage" height="23" width="23" /> <b class="caret"></b>
|
||||
</a>
|
||||
<ul class="user-dropdown-menu" id="user_dropdown">
|
||||
<li class="dropdown-header"><%=prename%> <%=lastname%></li>
|
||||
<li class="dropdown-header" style="text-transform: none">
|
||||
<%
|
||||
if(username === null) {
|
||||
%>-<%
|
||||
} else {
|
||||
if (name) {%>
|
||||
<%=name%> (<%=username%>)
|
||||
<% } else {%>
|
||||
<%=username%>
|
||||
<%}
|
||||
|
||||
}
|
||||
%>
|
||||
<% if(username !== null) { %>
|
||||
<li class="dropdown-item">
|
||||
<a id="user" class="tab" href="#user">User profile</a>
|
||||
</li>
|
||||
<% } %>
|
||||
<li class="dropdown-item">
|
||||
<a id="userManagement" class="internalLink" href="#userManagement">User management</a>
|
||||
</li>
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
current: window.currentDB
|
||||
});
|
||||
this.userBarView = new window.UserBarView({
|
||||
collection: this.options.notificationCollection
|
||||
collection: this.options.notificationCollection,
|
||||
userCollection: window.activeUser
|
||||
});
|
||||
this.statisticBarView = new window.StatisticBarView({});
|
||||
},
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
this.collection.bind("add", this.renderNotifications.bind(this));
|
||||
this.collection.bind("remove", this.renderNotifications.bind(this));
|
||||
this.collection.bind("reset", this.renderNotifications.bind(this));
|
||||
this.userCollection = this.options.userCollection;
|
||||
},
|
||||
|
||||
notificationItem: templateEngine.createTemplate("notificationItem.ejs"),
|
||||
|
@ -94,11 +95,32 @@
|
|||
},
|
||||
|
||||
render: function (el) {
|
||||
var username = this.userCollection.whoAmI(),
|
||||
img = null,
|
||||
name = null,
|
||||
active = false,
|
||||
currentUser = null;
|
||||
if (username !== null) {
|
||||
this.userCollection.fetch({async:false});
|
||||
currentUser = this.userCollection.findWhere({user: username});
|
||||
currentUser.set({loggedIn : true});
|
||||
name = currentUser.get("name");
|
||||
img = currentUser.get("img");
|
||||
active = currentUser.get("active");
|
||||
}
|
||||
if (!img) {
|
||||
img = "img/arangodblogoAvatar.png";
|
||||
}
|
||||
if (!name) {
|
||||
name = "";
|
||||
}
|
||||
|
||||
this.$el = el;
|
||||
this.$el.html(this.template.render({
|
||||
img : "https://s.gravatar.com/avatar/9c53a795affc3c3c03801ffae90e2e11?s=80",
|
||||
prename : "Floyd",
|
||||
lastname : "Pepper",
|
||||
img : img,
|
||||
name : name,
|
||||
username : username,
|
||||
active : active,
|
||||
notifications : this.collection
|
||||
}));
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
"click #submitCreateUser" : "submitCreateUser",
|
||||
"click #userManagementTable .icon_arangodb_roundminus" : "removeUser",
|
||||
"click #submitDeleteUser" : "submitDeleteUser",
|
||||
// "click .editUser" : "editUser",
|
||||
"click .editUser" : "editUser",
|
||||
"click #submitEditUser" : "submitEditUser"
|
||||
},
|
||||
|
||||
|
@ -34,14 +34,28 @@
|
|||
|
||||
renderTable: function () {
|
||||
this.collection.forEach(function(user) {
|
||||
var deleteButton =
|
||||
'<span class="arangoicon icon_arangodb_roundminus" data-original-title="Delete user"></span>';
|
||||
if(user.get("loggedIn")) {
|
||||
deleteButton = '';
|
||||
}
|
||||
var username = user.get("user"),
|
||||
name = user.get("name"),
|
||||
img = user.get("img"),
|
||||
active = user.get("active");
|
||||
if (!img) {
|
||||
img = " ";
|
||||
}
|
||||
if (!name) {
|
||||
name = " ";
|
||||
}
|
||||
$("#userManagementTable tbody").append(
|
||||
'<tr class="editUser" id="' + user.get("user") + '">' +
|
||||
'<td><a>' + user.get("user") + '</a></td>' +//username
|
||||
'<td><a>' + "" + '</a></td>' +//avatar
|
||||
'<td><a>' + "" + '</a></td>' +//name
|
||||
'<td><a>' + user.get("active") + '</a></td>' +//active
|
||||
'<td><span class="arangoicon icon_arangodb_roundminus"' +
|
||||
'data-original-title="Delete user"></span></td>' +
|
||||
'<tr class="editUser" id="' + username + '">' +
|
||||
'<td><a>' + username + '</a></td>' +//username
|
||||
'<td><a>' + img + '</a></td>' +//avatar
|
||||
'<td><a>' + name + '</a></td>' +//name
|
||||
'<td><a>' + active + '</a></td>' +//active
|
||||
'<td>' + deleteButton + '</td>' +
|
||||
'</tr>'
|
||||
);
|
||||
});
|
||||
|
@ -136,7 +150,7 @@
|
|||
|
||||
editUser : function(e) {
|
||||
this.userToEdit = $(e.currentTarget).attr("id");
|
||||
console.log(this.userToEdit);
|
||||
// console.log(this.userToEdit);
|
||||
$('#editUserModal').modal('show');
|
||||
var user = this.collection.findWhere({user: this.userToEdit});
|
||||
$('#editUsername').html(user.get("user"));
|
||||
|
@ -145,14 +159,14 @@
|
|||
},
|
||||
|
||||
submitEditUser : function() {
|
||||
console.log("submitEditUser");
|
||||
// console.log("submitEditUser");
|
||||
var self = this;
|
||||
var userName = this.userToEdit;
|
||||
var name = $('#editName').val();
|
||||
var status = $('#editStatus').is(':checked');
|
||||
console.log(userName);
|
||||
console.log(name);
|
||||
console.log(status);
|
||||
// console.log(userName);
|
||||
// console.log(name);
|
||||
// console.log(status);
|
||||
if (!this.validateStatus(status)) {
|
||||
$('#editStatus').closest("th").css("backgroundColor", "red");
|
||||
return;
|
||||
|
|
|
@ -127,6 +127,23 @@
|
|||
SYS_LOG("warning", "################################################################################");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief frontendDevelopmentMode
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
exports.frontendDevelopmentMode = false;
|
||||
|
||||
if (typeof FE_DEVELOPMENT_MODE !== "undefined") {
|
||||
exports.frontendDevelopmentMode = FE_DEVELOPMENT_MODE;
|
||||
delete FE_DEVELOPMENT_MODE;
|
||||
}
|
||||
|
||||
if (exports.frontendDevelopmentMode && exports.threadNumber === 0) {
|
||||
SYS_LOG("warning", "################################################################################");
|
||||
SYS_LOG("warning", "frontend development mode is active, never use this in production");
|
||||
SYS_LOG("warning", "################################################################################");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief logfilePath
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -36,6 +36,7 @@ var fs = require("fs");
|
|||
var _ = require("underscore");
|
||||
|
||||
var executeGlobalContextFunction = require("internal").executeGlobalContextFunction;
|
||||
var frontendDevelopmentMode = require("internal").frontendDevelopmentMode;
|
||||
var checkParameter = arangodb.checkParameter;
|
||||
var transformScript = require("org/arangodb/foxx/preprocessor").preprocess;
|
||||
|
||||
|
@ -326,6 +327,80 @@ function buildAssetContent (app, assets, basePath) {
|
|||
return content;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief installs an asset for an app
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function buildFileAsset (app, path, basePath, asset) {
|
||||
var content = buildAssetContent(app, asset.files, basePath);
|
||||
var type;
|
||||
var route;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// content-type detection
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// contentType explicitly specified for asset
|
||||
if (asset.hasOwnProperty("contentType") && asset.contentType !== '') {
|
||||
type = asset.contentType;
|
||||
}
|
||||
|
||||
// path contains a dot, derive content type from path
|
||||
else if (path.match(/\.[a-zA-Z0-9]+$/)) {
|
||||
type = arangodb.guessContentType(path);
|
||||
}
|
||||
|
||||
// path does not contain a dot,
|
||||
// derive content type from included asset names
|
||||
else if (asset.files.length > 0) {
|
||||
type = arangodb.guessContentType(asset.files[0]);
|
||||
}
|
||||
|
||||
// use built-in defaulti content-type
|
||||
else {
|
||||
type = arangodb.guessContentType("");
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// return content
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
return { contentType: type, body: content };
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief generates development asset action
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function buildDevelopmentAssetRoute (app, path, basePath, asset) {
|
||||
var internal = require("internal");
|
||||
|
||||
return {
|
||||
url: { match: path },
|
||||
action: {
|
||||
callback: function (req, res) {
|
||||
var c = buildFileAsset(app, path, basePath, asset);
|
||||
|
||||
res.contentType = c.contentType;
|
||||
res.body = c.body;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief generates asset action
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function buildAssetRoute (app, path, basePath, asset) {
|
||||
var c = buildFileAsset(app, path, basePath, asset);
|
||||
|
||||
return {
|
||||
url: { match: path },
|
||||
content: { contentType: c.contentType, body: c.body }
|
||||
};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief installs the assets of an app
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -352,39 +427,16 @@ function installAssets (app, routes) {
|
|||
basePath = asset.basePath;
|
||||
}
|
||||
|
||||
normalized = arangodb.normalizeURL("/" + path);
|
||||
|
||||
if (asset.hasOwnProperty('files')) {
|
||||
var content = buildAssetContent(app, asset.files, basePath);
|
||||
var type;
|
||||
|
||||
normalized = arangodb.normalizeURL("/" + path);
|
||||
|
||||
// content-type detection
|
||||
// ----------------------
|
||||
|
||||
if (asset.hasOwnProperty("contentType") && asset.contentType !== '') {
|
||||
// contentType explicitly specified for asset
|
||||
type = asset.contentType;
|
||||
}
|
||||
else if (normalized.match(/\.[a-zA-Z0-9]+$/)) {
|
||||
// path contains a dot
|
||||
// derive content type from path
|
||||
type = arangodb.guessContentType(normalized);
|
||||
}
|
||||
else if (asset.files.length > 0) {
|
||||
// path does not contain a dot
|
||||
// derive content type from included asset names
|
||||
type = arangodb.guessContentType(asset.files[0]);
|
||||
if (frontendDevelopmentMode) {
|
||||
route = buildDevelopmentAssetRoute(app, normalized, basePath, asset);
|
||||
}
|
||||
else {
|
||||
// use built-in defaulti content-type
|
||||
type = arangodb.guessContentType("");
|
||||
route = buildAssetRoute(app, normalized, basePath, asset);
|
||||
}
|
||||
|
||||
route = {
|
||||
url: { match: normalized },
|
||||
content: { contentType: type, body: content }
|
||||
};
|
||||
|
||||
routes.routes.push(route);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue