Modernize
This commit is contained in:
parent
4dc5acc5d7
commit
89232b127b
21
FlowAction.cpp
Normal file
21
FlowAction.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include "FlowAction.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
FlowAction::FlowAction() {
|
||||
int len = strlen(hex);
|
||||
for(int ix = 0; ix < sizeof(actionId); ++ix) {
|
||||
actionId[ix] = hex[random() % len];
|
||||
}
|
||||
}
|
||||
|
||||
bool FlowAction::action(HTTPParameters &p) {
|
||||
return true;
|
||||
}
|
||||
|
||||
coreutils::ZString FlowAction::getId() {
|
||||
return coreutils::ZString(actionId, sizeof(actionId));
|
||||
}
|
||||
|
||||
|
||||
}
|
26
FlowAction.h
Normal file
26
FlowAction.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef __FlowAction_h__
|
||||
# define __FlowAction_h__
|
||||
|
||||
#include "HTTPParameters.h"
|
||||
#include "ZString.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
class FlowAction {
|
||||
|
||||
public:
|
||||
FlowAction();
|
||||
|
||||
virtual bool action(HTTPParameters &p);
|
||||
|
||||
coreutils::ZString getId();
|
||||
|
||||
protected:
|
||||
char actionId[64];
|
||||
const char *hex = "0123456789ABCDEF";
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
56
HTTPActionList.cpp
Normal file
56
HTTPActionList.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
#include "HTTPActionList.h"
|
||||
#include "Log.h"
|
||||
#include "HTTPParameters.h"
|
||||
#include "FlowAction.h"
|
||||
#include "Exception.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
bool HTTPActionList::processRequest(HTTPParameters &p) {
|
||||
|
||||
p.httpRequest.response.setProtocol(p.httpRequest.request.getProtocol());
|
||||
coreutils::ZString uri = p.httpRequest.request.getURI();
|
||||
if(!uri.ifNext("/"))
|
||||
throw coreutils::Exception("Expecting a /.");
|
||||
|
||||
coreutils::Log(coreutils::LOG_DEBUG_1) << "Requesting action '" << uri << "'.";
|
||||
|
||||
try {
|
||||
return actions.at(uri)->action(p);
|
||||
}
|
||||
catch(...) {
|
||||
throw coreutils::Exception("Requested resource not found.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
coreutils::ZString HTTPActionList::addAction(FlowAction *action) {
|
||||
coreutils::Log(coreutils::LOG_DEBUG_1) << "Adding flow action to list..." << action->getId();
|
||||
|
||||
for(auto [key, actionItem] : actions) {
|
||||
coreutils::Log(coreutils::LOG_DEBUG_2) << "before: " << key;
|
||||
}
|
||||
|
||||
coreutils::ZString name(action->getId());
|
||||
coreutils::Log(coreutils::LOG_DEBUG_2) << "getid: " << name;
|
||||
auto ret = actions.insert(std::make_pair(name, action));
|
||||
|
||||
if(ret.second == false) {
|
||||
coreutils::Log(coreutils::LOG_DEBUG_2) << "already exists" << action->getId();
|
||||
}
|
||||
|
||||
for(auto [key, actionItem] : actions) {
|
||||
coreutils::Log(coreutils::LOG_DEBUG_2) << "after: " << key;
|
||||
}
|
||||
|
||||
return action->getId();
|
||||
}
|
||||
|
||||
// void HTTPActionList::remove(HTTPPage &page) {}
|
||||
|
||||
void HTTPActionList::matchUri(coreutils::ZString &comparator, coreutils::ZString &uri) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
35
HTTPActionList.h
Normal file
35
HTTPActionList.h
Normal file
@ -0,0 +1,35 @@
|
||||
#ifndef __HTTPActionList_h__
|
||||
#define __HTTPActionList_h__
|
||||
|
||||
//#include "HTTPParameters.h"
|
||||
//#include "HTTPPage.h"
|
||||
//#include "FlowAction.h"
|
||||
#include "ZString.h"
|
||||
#include <map>
|
||||
|
||||
namespace http {
|
||||
|
||||
class HTTPParameters;
|
||||
class FlowAction;
|
||||
|
||||
class HTTPActionList {
|
||||
|
||||
public:
|
||||
HTTPActionList() {}
|
||||
|
||||
bool processRequest(HTTPParameters &p);
|
||||
|
||||
coreutils::ZString addAction(FlowAction *action);
|
||||
|
||||
// void removeAction(HTTPPage &page);
|
||||
|
||||
void matchUri(coreutils::ZString &comparator, coreutils::ZString &uri);
|
||||
|
||||
protected:
|
||||
std::map<coreutils::ZString, FlowAction *> actions;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -13,7 +13,6 @@ namespace http {
|
||||
HTTPConnection(core::EPoll &ePoll, core::TCPServer &server) : TCPSession(ePoll, server, "HTTP Connection") {}
|
||||
|
||||
void onDataReceived(coreutils::ZString &data) override {
|
||||
coreutils::Log(coreutils::LOG_DEBUG_1) << ":" << data;
|
||||
protocol(data);
|
||||
send();
|
||||
}
|
||||
|
38
HTTPGETHandler.cpp
Normal file
38
HTTPGETHandler.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
#include "HTTPGETHandler.h"
|
||||
#include "HTTPParameters.h"
|
||||
#include "HTTPSession.h"
|
||||
#include "HTTPServer.h"
|
||||
#include "HTTPRequest.h"
|
||||
#include "ZString.h"
|
||||
#include "IMFFormData.h"
|
||||
#include "Exception.h"
|
||||
#include "Log.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
int HTTPGETHandler::processCommand(coreutils::ZString &request, core::TCPSession &session) {
|
||||
|
||||
HTTPRequest httpRequest(request);
|
||||
|
||||
HTTPSession *httpSession = static_cast<HTTPServer&>(session.server).httpSessions.findSessionByHeader(httpRequest);
|
||||
|
||||
std::stringstream content;
|
||||
|
||||
HTTPParameters p(httpRequest, session, *httpSession, content, ((HTTPServer &)session.server).actionList);
|
||||
|
||||
try {
|
||||
static_cast<HTTPServer &>(session.server).pageList.processRequest(p);
|
||||
httpRequest.response.setCode("200");
|
||||
httpRequest.response.setText("OK");
|
||||
}
|
||||
catch(coreutils::Exception e) {
|
||||
httpRequest.response.setCode("404");
|
||||
httpRequest.response.setText("Not Found");
|
||||
}
|
||||
|
||||
session.out << httpRequest.response.getResponse(content).str();
|
||||
// coreutils::Log(coreutils::LOG_DEBUG_1) << session.out.str();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
#ifndef __HTTPHandler_h__
|
||||
#define __HTTPHandler_h__
|
||||
#ifndef __HTTPGETHandler_h__
|
||||
#define __HTTPGETHandler_h__
|
||||
|
||||
#include "Command.h"
|
||||
#include "TCPSession.h"
|
||||
@ -9,7 +9,7 @@
|
||||
|
||||
namespace http {
|
||||
|
||||
class HTTPHandler : public core::Command {
|
||||
class HTTPGETHandler : public core::Command {
|
||||
|
||||
public:
|
||||
int processCommand(coreutils::ZString &request, core::TCPSession &session) override;
|
@ -1,56 +0,0 @@
|
||||
#include "HTTPHandler.h"
|
||||
#include "HTTPSession.h"
|
||||
#include "HTTPServer.h"
|
||||
#include "HTTPRequest.h"
|
||||
#include "ZString.h"
|
||||
#include "IMFFormData.h"
|
||||
#include "Log.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
int HTTPHandler::processCommand(coreutils::ZString &request, core::TCPSession &session) {
|
||||
if(!httpRequest) {
|
||||
httpRequest = new HTTPRequest(request);
|
||||
// session->server.commands.grabInput(session, *this);
|
||||
processHTTPRequest(session);
|
||||
}
|
||||
else {
|
||||
// httpRequest->parse(request1);
|
||||
if(!request.equals("")) {
|
||||
// session->server.commands.clearGrab(session);
|
||||
processHTTPRequest(session);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HTTPHandler::processHTTPRequest(core::TCPSession &session) {
|
||||
|
||||
HTTPSession *httpSession = static_cast<HTTPServer&>(session.server).httpSessions.findSessionByHeader(httpRequest);
|
||||
|
||||
std::stringstream content;
|
||||
|
||||
if(static_cast<HTTPServer &>(session.server).pageList.processRequest(httpRequest, &session, httpSession, content)) {
|
||||
|
||||
coreutils::ZString contentType = httpRequest->getHeader("Content-Type");
|
||||
if(contentType.equals("multipart/form-data")) {
|
||||
coreutils::IMFFormData *formdata = (coreutils::IMFFormData *)httpRequest->getBody();
|
||||
coreutils::Log(coreutils::LOG_DEBUG_2) << "username is '" << formdata->getByName("username") << "'";
|
||||
}
|
||||
|
||||
httpRequest->response.setCode("200");
|
||||
httpRequest->response.setText("OK");
|
||||
session.out << httpRequest->response.getResponse(content).str();
|
||||
coreutils::Log(coreutils::LOG_DEBUG_1) << "Sending response to client..." << content.str();
|
||||
}
|
||||
else {
|
||||
httpRequest->response.setCode("404");
|
||||
httpRequest->response.setText("Not Found");
|
||||
session.out << httpRequest->response.getResponse(content).str();
|
||||
}
|
||||
delete httpRequest;
|
||||
httpRequest = NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
38
HTTPPOSTHandler.cpp
Normal file
38
HTTPPOSTHandler.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
#include "HTTPPOSTHandler.h"
|
||||
#include "HTTPParameters.h"
|
||||
#include "HTTPSession.h"
|
||||
#include "HTTPServer.h"
|
||||
#include "HTTPRequest.h"
|
||||
#include "ZString.h"
|
||||
#include "IMFFormData.h"
|
||||
#include "Exception.h"
|
||||
#include "Log.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
int HTTPPOSTHandler::processCommand(coreutils::ZString &request, core::TCPSession &session) {
|
||||
|
||||
HTTPRequest httpRequest(request);
|
||||
|
||||
HTTPSession *httpSession = ((HTTPServer &)(session.server)).httpSessions.findSessionByHeader(httpRequest);
|
||||
|
||||
std::stringstream content;
|
||||
|
||||
HTTPParameters p(httpRequest, session, *httpSession, content, ((HTTPServer &)(session.server)).actionList);
|
||||
|
||||
try {
|
||||
((HTTPServer &)(session.server)).actionList.processRequest(p);
|
||||
httpRequest.response.setCode("200");
|
||||
httpRequest.response.setText("OK");
|
||||
}
|
||||
catch(coreutils::Exception e) {
|
||||
httpRequest.response.setCode("404");
|
||||
httpRequest.response.setText("Not Found");
|
||||
}
|
||||
|
||||
session.out << httpRequest.response.getResponse(content).str();
|
||||
coreutils::Log(coreutils::LOG_DEBUG_1) << session.out.str();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
22
HTTPPOSTHandler.h
Normal file
22
HTTPPOSTHandler.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef __HTTPPOSTHandler_h__
|
||||
#define __HTTPPOSTHandler_h__
|
||||
|
||||
#include "Command.h"
|
||||
#include "HTTPRequest.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
class HTTPPOSTHandler : public core::Command {
|
||||
|
||||
public:
|
||||
int processCommand(coreutils::ZString &request, core::TCPSession &session) override;
|
||||
|
||||
private:
|
||||
HTTPRequest *httpRequest = NULL;
|
||||
bool processHTTPRequest(core::TCPSession &session);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
32
HTTPPUTHandler.cpp
Normal file
32
HTTPPUTHandler.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#include "HTTPPUTHandler.h"
|
||||
#include "HTTPSession.h"
|
||||
#include "HTTPServer.h"
|
||||
#include "HTTPRequest.h"
|
||||
#include "ZString.h"
|
||||
#include "IMFFormData.h"
|
||||
#include "Log.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
int HTTPPUTHandler::processCommand(coreutils::ZString &request, core::TCPSession &session) {
|
||||
|
||||
HTTPRequest httpRequest(request);
|
||||
|
||||
HTTPSession *httpSession = static_cast<HTTPServer&>(session.server).httpSessions.findSessionByHeader(httpRequest);
|
||||
|
||||
std::stringstream content;
|
||||
HTTPParameters p(httpRequest, session, *httpSession, content, ((HTTPServer &)session.server).actionList);
|
||||
|
||||
try {
|
||||
((HTTPServer &)(session.server)).pageList.processRequest(p);
|
||||
httpRequest.response.setCode("200");
|
||||
httpRequest.response.setText("OK");
|
||||
}
|
||||
catch(...) {}
|
||||
|
||||
session.out << httpRequest.response.getResponse(content).str();
|
||||
// coreutils::Log(coreutils::LOG_DEBUG_1) << session.out.str();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
25
HTTPPUTHandler.h
Normal file
25
HTTPPUTHandler.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef __HTTPPUTHandler_h__
|
||||
#define __HTTPPUTHandler_h__
|
||||
|
||||
#include "Command.h"
|
||||
#include "TCPSession.h"
|
||||
#include "Log.h"
|
||||
#include "IMFMessage.h"
|
||||
#include "HTTPRequest.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
class HTTPPUTHandler : public core::Command {
|
||||
|
||||
public:
|
||||
int processCommand(coreutils::ZString &request, core::TCPSession &session) override;
|
||||
|
||||
private:
|
||||
HTTPRequest *httpRequest = NULL;
|
||||
bool processHTTPRequest(core::TCPSession &session);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
10
HTTPPage.cpp
Normal file
10
HTTPPage.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
#include "HTTPPage.h"
|
||||
#include "HTTPParameters.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
int HTTPPage::page(HTTPParameters &p) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
13
HTTPPage.h
13
HTTPPage.h
@ -1,23 +1,14 @@
|
||||
#ifndef __HTTPPage_h__
|
||||
#define __HTTPPage_h__
|
||||
|
||||
#include "HTTPSession.h"
|
||||
#include "HTTPRequest.h"
|
||||
#include "TCPSession.h"
|
||||
#include "Log.h"
|
||||
#include "HTTPParameters.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
class HTTPPage {
|
||||
|
||||
public:
|
||||
|
||||
virtual int processCommand(HTTPRequest *httpRequest,
|
||||
core::TCPSession *session,
|
||||
HTTPSession *httpSession,
|
||||
std::stringstream &data) {
|
||||
return false;
|
||||
}
|
||||
virtual int page(HTTPParameters &p);
|
||||
|
||||
};
|
||||
|
||||
|
@ -1,16 +1,39 @@
|
||||
#include "HTTPPageList.h"
|
||||
#include "Log.h"
|
||||
#include "Exception.h"
|
||||
#include <utility>
|
||||
|
||||
namespace http {
|
||||
|
||||
bool HTTPPageList::processRequest(HTTPRequest *httpRequest,
|
||||
core::TCPSession *session,
|
||||
HTTPSession *httpSession,
|
||||
std::stringstream &data) {
|
||||
bool HTTPPageList::processRequest(HTTPParameters &p) {
|
||||
|
||||
httpRequest->response.setProtocol(httpRequest->request.getProtocol());
|
||||
coreutils::ZString uri = httpRequest->request.getURI();
|
||||
HTTPPage *page = pages[uri.str()];
|
||||
return page->processCommand(httpRequest, session, httpSession, data);
|
||||
p.httpRequest.response.setProtocol(p.httpRequest.request.getProtocol());
|
||||
coreutils::ZString uri = p.httpRequest.request.getURI();
|
||||
|
||||
coreutils::Log(coreutils::LOG_DEBUG_1) << "Requesting '" << uri << "'.";
|
||||
|
||||
for (auto const& [key, val] : pages) {
|
||||
p.httpRequest.uriValues.clear();
|
||||
uri.reset();
|
||||
coreutils::ZString compare(key.c_str());
|
||||
int match = compare.ifEqualsCount(uri);
|
||||
if((match > 0) && (!uri.eod())) {
|
||||
if(compare.ifNext("{")) {
|
||||
coreutils::ZString varName = compare.getTokenExclude("}");
|
||||
if(compare.ifNext("}")) {
|
||||
if(compare.eod()) {
|
||||
coreutils::ZString value = uri.getTokenExclude(" ");
|
||||
p.httpRequest.uriValues[varName] = value;
|
||||
}
|
||||
} else
|
||||
throw coreutils::Exception("Syntax error in entrypoint data.");
|
||||
}
|
||||
}
|
||||
if((match > 0) && uri.eod()) {
|
||||
return val->page(p);
|
||||
}
|
||||
}
|
||||
throw coreutils::Exception("Requested resource not found.");
|
||||
}
|
||||
|
||||
void HTTPPageList::add(HTTPPage &page, std::string name) {
|
||||
@ -19,6 +42,8 @@ namespace http {
|
||||
|
||||
void HTTPPageList::remove(HTTPPage &page) {}
|
||||
|
||||
void HTTPPageList::matchUri(coreutils::ZString &comparator, coreutils::ZString &uri) {}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,50 +2,50 @@
|
||||
# define __HTTPPageList_h__
|
||||
|
||||
# include "TCPSession.h"
|
||||
# include "HTTPRequest.h"
|
||||
# include "ZString.h"
|
||||
# include "__index.h"
|
||||
# include "__script.h"
|
||||
# include "__editview.h"
|
||||
# include "__editview_js.h"
|
||||
# include "__style.h"
|
||||
# include "__setupadmin.h"
|
||||
# include "__entrypoints.h"
|
||||
# include "__favicon_ico.h"
|
||||
# include "__welcome.h"
|
||||
# include "__mainmenu.h"
|
||||
# include "__configure.h"
|
||||
# include "__viewlist.h"
|
||||
# include "__workflow.h"
|
||||
# include "__workflow_js.h"
|
||||
# include "__addview.h"
|
||||
# include "_image.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
|
||||
class HTTPPageList {
|
||||
|
||||
|
||||
public:
|
||||
HTTPPageList() {
|
||||
add(index, "/");
|
||||
add(script, "/script");
|
||||
add(editview, "/editview");
|
||||
add(editview, "/editview/{view_name}");
|
||||
add(editview_js, "/__editview_js");
|
||||
add(style, "/style");
|
||||
add(setupadmin, "/setupadmin");
|
||||
add(entrypoints, "/entrypoints");
|
||||
add(favicon_ico, "/favicon.ico");
|
||||
add(welcome, "/welcome");
|
||||
add(mainmenu, "/mainmenu");
|
||||
add(configure, "/configure");
|
||||
add(viewlist, "/viewlist");
|
||||
add(workflow, "/workflow");
|
||||
add(workflow_js, "/__workflow_js");
|
||||
add(image, "/image/");
|
||||
add(image, "/image/{image_name}");
|
||||
add(addview, "/addview");
|
||||
}
|
||||
|
||||
bool processRequest(HTTPRequest *httpRequest, core::TCPSession *session, HTTPSession *httpSession, std::stringstream &data);
|
||||
bool processRequest(HTTPParameters &p);
|
||||
|
||||
void add(HTTPPage &page, std::string entryURL);
|
||||
|
||||
void remove(HTTPPage &page);
|
||||
|
||||
void matchUri(coreutils::ZString &comparator, coreutils::ZString &uri);
|
||||
|
||||
protected:
|
||||
std::map<std::string, HTTPPage *> pages;
|
||||
|
||||
@ -55,14 +55,13 @@ namespace http {
|
||||
__style style;
|
||||
__editview editview;
|
||||
__editview_js editview_js;
|
||||
__setupadmin setupadmin;
|
||||
__entrypoints entrypoints;
|
||||
__favicon_ico favicon_ico;
|
||||
__welcome welcome;
|
||||
__mainmenu mainmenu;
|
||||
__configure configure;
|
||||
__viewlist viewlist;
|
||||
__workflow workflow;
|
||||
__workflow_js workflow_js;
|
||||
__addview addview;
|
||||
_image image;
|
||||
|
||||
};
|
||||
|
16
HTTPParameters.cpp
Normal file
16
HTTPParameters.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
#include "HTTPParameters.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
HTTPParameters::HTTPParameters(HTTPRequest &httpRequest,
|
||||
core::TCPSession &session,
|
||||
HTTPSession &httpSession,
|
||||
std::stringstream &data,
|
||||
HTTPActionList &actionList) :
|
||||
httpRequest(httpRequest),
|
||||
session(session),
|
||||
httpSession(httpSession),
|
||||
data(data),
|
||||
actionList(actionList) {}
|
||||
|
||||
}
|
36
HTTPParameters.h
Normal file
36
HTTPParameters.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef __HTTPParameters_h__
|
||||
#define __HTTPParameters_h__
|
||||
|
||||
#include "HTTPRequest.h"
|
||||
#include "HTTPSession.h"
|
||||
#include "HTTPActionList.h"
|
||||
#include "TCPSession.h"
|
||||
#include <sstream>
|
||||
|
||||
namespace http {
|
||||
|
||||
///
|
||||
/// HTTPParameters groups the objects needed to access request
|
||||
/// data and a means to return the content of a response message.
|
||||
///
|
||||
|
||||
class HTTPParameters {
|
||||
|
||||
public:
|
||||
HTTPParameters(HTTPRequest &httpRequest,
|
||||
core::TCPSession &session,
|
||||
HTTPSession &httpSession,
|
||||
std::stringstream &data,
|
||||
HTTPActionList &actionList);
|
||||
|
||||
HTTPRequest &httpRequest;
|
||||
core::TCPSession &session;
|
||||
HTTPSession &httpSession;
|
||||
std::stringstream &data;
|
||||
HTTPActionList &actionList;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
7
HTTPRequest.cpp
Normal file
7
HTTPRequest.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include "HTTPRequest.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
HTTPRequest::HTTPRequest(coreutils::ZString &in) : request(in), message(in) {}
|
||||
|
||||
}
|
@ -1,21 +1,22 @@
|
||||
#ifndef __HTTPRequest_h__
|
||||
#define __HTTPRequest_h__
|
||||
|
||||
#include "ZString.h"
|
||||
#include "IMFMessage.h"
|
||||
#include "IMFRequest.h"
|
||||
#include "IMFResponse.h"
|
||||
#include "Exception.h"
|
||||
#include "Log.h"
|
||||
#include <map>
|
||||
|
||||
namespace http {
|
||||
|
||||
class HTTPRequest : public coreutils::IMFMessage {
|
||||
class HTTPRequest {
|
||||
|
||||
public:
|
||||
HTTPRequest(coreutils::ZString &in) : request(in), IMFMessage(in) {}
|
||||
HTTPRequest(coreutils::ZString &in);
|
||||
|
||||
std::map<coreutils::ZString, coreutils::ZString> uriValues;
|
||||
|
||||
coreutils::IMFRequest request;
|
||||
coreutils::IMFMessage message;
|
||||
coreutils::IMFResponse response;
|
||||
|
||||
};
|
||||
|
BIN
HTTPServer
BIN
HTTPServer
Binary file not shown.
12
HTTPServer.h
12
HTTPServer.h
@ -4,8 +4,11 @@
|
||||
#include "TCPServer.h"
|
||||
#include "HTTPSessions.h"
|
||||
#include "HTTPPageList.h"
|
||||
#include "HTTPActionList.h"
|
||||
#include "HTTPConnection.h"
|
||||
#include "HTTPHandler.h"
|
||||
#include "HTTPGETHandler.h"
|
||||
#include "HTTPPOSTHandler.h"
|
||||
#include "HTTPPUTHandler.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
@ -18,6 +21,7 @@ namespace http {
|
||||
: TCPServer(ePoll, ipAddress), httpSessions(httpSessions) {
|
||||
commands.add(getHandler, "GET");
|
||||
commands.add(postHandler, "POST");
|
||||
commands.add(putHandler, "PUT");
|
||||
}
|
||||
|
||||
core::TCPSession * getSocketAccept(core::EPoll &epoll) override {
|
||||
@ -26,10 +30,12 @@ namespace http {
|
||||
|
||||
HTTPSessions &httpSessions;
|
||||
HTTPPageList pageList;
|
||||
HTTPActionList actionList;
|
||||
|
||||
private:
|
||||
HTTPHandler getHandler;
|
||||
HTTPHandler postHandler;
|
||||
HTTPGETHandler getHandler;
|
||||
HTTPPOSTHandler postHandler;
|
||||
HTTPPUTHandler putHandler;
|
||||
|
||||
};
|
||||
|
||||
|
@ -1,18 +1,26 @@
|
||||
#include "HTTPSession.h"
|
||||
#include <uuid/uuid.h>
|
||||
|
||||
namespace http {
|
||||
|
||||
HTTPSession::HTTPSession() {
|
||||
sessionId = "";
|
||||
}
|
||||
|
||||
HTTPSession::HTTPSession(std::string sessionId) {
|
||||
this->sessionId = sessionId;
|
||||
generateSessionId();
|
||||
}
|
||||
|
||||
std::string HTTPSession::getSessionId() {
|
||||
return sessionId;
|
||||
HTTPSession::HTTPSession(coreutils::ZString sessionId) {
|
||||
strncpy(this->sessionId, sessionId.getData(), 37);
|
||||
}
|
||||
|
||||
|
||||
coreutils::ZString HTTPSession::getSessionId() {
|
||||
return coreutils::ZString(sessionId, 37);
|
||||
}
|
||||
|
||||
int HTTPSession::generateSessionId() {
|
||||
uuid_t uuid;
|
||||
uuid_generate_random(uuid);
|
||||
uuid_unparse(uuid, sessionId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef __HTTPSession_h__
|
||||
#define __HTTPSession_h__
|
||||
|
||||
#include "includes"
|
||||
#include "ZString.h"
|
||||
//#include "Variables.h"
|
||||
|
||||
namespace http {
|
||||
@ -10,14 +10,17 @@ namespace http {
|
||||
|
||||
public:
|
||||
HTTPSession();
|
||||
HTTPSession(std::string sessionId);
|
||||
std::string getSessionId();
|
||||
HTTPSession(coreutils::ZString sessionId);
|
||||
|
||||
coreutils::ZString getSessionId();
|
||||
|
||||
// jet::Variables sessionVariables;
|
||||
// jet::Variables cgiFormVariables;
|
||||
|
||||
private:
|
||||
std::string sessionId;
|
||||
int generateSessionId();;
|
||||
|
||||
char sessionId[37];
|
||||
|
||||
};
|
||||
|
||||
|
@ -1,55 +1,42 @@
|
||||
#include "HTTPSessions.h"
|
||||
#include "HTTPSession.h"
|
||||
#include "Log.h"
|
||||
#include <uuid/uuid.h>
|
||||
|
||||
namespace http {
|
||||
|
||||
HTTPSession * HTTPSessions::findSessionByHeader(HTTPRequest *httpRequest) {
|
||||
coreutils::ZString sessionId(httpRequest->getHeaderKeyPairValue("Cookie", "sessionId"));
|
||||
HTTPSession *session = findSessionById(sessionId, httpRequest);
|
||||
return session;
|
||||
HTTPSession * HTTPSessions::findSessionByHeader(HTTPRequest &httpRequest) {
|
||||
coreutils::ZString sessionId(httpRequest.message.getHeaderKeyPairValue("Cookie", "SessionId"));
|
||||
if(sessionId.str() == "")
|
||||
return createHTTPSession(httpRequest);
|
||||
else
|
||||
return findSessionById(sessionId, httpRequest);
|
||||
}
|
||||
|
||||
HTTPSession * HTTPSessions::findSessionById(coreutils::ZString &sessionId, HTTPRequest *httpRequest) {
|
||||
HTTPSession *httpSession;
|
||||
if(sessionId.getLength() > 0) {
|
||||
std::map<std::string, HTTPSession*>::iterator ix;
|
||||
httpSession = sessions[sessionId.str()];
|
||||
|
||||
if(ix == sessions.end()) {
|
||||
httpSession = createHTTPSession();
|
||||
httpRequest->response.setCookie("sessionId", httpSession->getSessionId());
|
||||
}
|
||||
coreutils::Log(coreutils::LOG_DEBUG_1) << "http session: " << "(" << sessionId << ") " << httpSession;
|
||||
|
||||
} else {
|
||||
httpSession = createHTTPSession();
|
||||
httpRequest->response.setCookie("sessionId", httpSession->getSessionId());
|
||||
HTTPSession * HTTPSessions::findSessionById(coreutils::ZString &sessionId, HTTPRequest &httpRequest) {
|
||||
try {
|
||||
HTTPSession *httpSession = sessions.at(sessionId);
|
||||
return httpSession;
|
||||
}
|
||||
catch (...) {
|
||||
return createHTTPSession(httpRequest);
|
||||
}
|
||||
}
|
||||
|
||||
HTTPSession * HTTPSessions::createHTTPSession(HTTPRequest &httpRequest) {
|
||||
HTTPSession *httpSession = new HTTPSession();
|
||||
coreutils::ZString sessionId(httpSession->getSessionId());
|
||||
sessions.insert(std::make_pair(sessionId, httpSession));
|
||||
std::stringstream temp;
|
||||
temp << "SessionId=" << httpSession->getSessionId();
|
||||
httpRequest.response.addHeader(coreutils::IMFHeader("Set-Cookie", temp.str().c_str()));
|
||||
return httpSession;
|
||||
}
|
||||
|
||||
HTTPSession * HTTPSessions::createHTTPSession() {
|
||||
HTTPSession *httpSession = new HTTPSession(generateSessionId());
|
||||
sessions.insert(std::make_pair(httpSession->getSessionId(), httpSession));
|
||||
return httpSession;
|
||||
}
|
||||
|
||||
std::string HTTPSessions::generateSessionId() {
|
||||
uuid_t uuid;
|
||||
uuid_generate_random(uuid);
|
||||
char uuid_s[37];
|
||||
uuid_unparse(uuid, uuid_s);
|
||||
return uuid_s;
|
||||
}
|
||||
|
||||
int HTTPSessions::processCommand(std::string command, core::TCPSession *session, std::stringstream &data) {
|
||||
int HTTPSessions::processCommand(std::string command, core::TCPSession *session, std::stringstream &data) {
|
||||
if(sessions.size() > 0) {
|
||||
int seq = 0;
|
||||
for(auto httpSession: sessions)
|
||||
data << "|" << ++seq << "|" << httpSession.second->getSessionId() << "|" << std::endl;
|
||||
|
||||
}
|
||||
else
|
||||
data << "There are no sessions active." << std::endl;
|
||||
|
@ -12,16 +12,15 @@ namespace http {
|
||||
class HTTPSessions : public core::Command {
|
||||
|
||||
public:
|
||||
HTTPSession * findSessionByHeader(HTTPRequest *httpRequest);
|
||||
HTTPSession * findSessionById(coreutils::ZString &sessionId, HTTPRequest *httpRequest);
|
||||
HTTPSession * findSessionByHeader(HTTPRequest &httpRequest);
|
||||
HTTPSession * findSessionById(coreutils::ZString &sessionId, HTTPRequest &httpRequest);
|
||||
|
||||
int processCommand(std::string request, core::TCPSession *session, std::stringstream &data);
|
||||
|
||||
private:
|
||||
HTTPSession * createHTTPSession();
|
||||
std::string generateSessionId();
|
||||
HTTPSession * createHTTPSession(HTTPRequest &httpRequest);
|
||||
|
||||
std::map<std::string, HTTPSession*> sessions;
|
||||
std::map<coreutils::ZString, HTTPSession *> sessions;
|
||||
|
||||
};
|
||||
|
||||
|
@ -84,3 +84,16 @@ type will respond.
|
||||
|
||||
|
||||
|
||||
XQ
|
||||
Within the XQ you can request action objects that are used to link
|
||||
work flow exits. Using buttons and anchors you can progress a work
|
||||
flow instance through a work flow patterns.
|
||||
|
||||
These links are calls to the server using a uniquely assigned id that
|
||||
is only active for the duration of the XQ duration on the browser. As
|
||||
soon as a link is selected all links associated with the XQ are
|
||||
cancelled.
|
||||
|
||||
The associated work flow unit is moved through the work flow pattern
|
||||
based upon the link selected in addition to the browser's form data
|
||||
being passed to the work flow unit for processing.
|
||||
|
29
__addview.h
Normal file
29
__addview.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef ____addview_h__
|
||||
#define ____addview_h__
|
||||
|
||||
#include "HTTPPage.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
class __addview : public HTTPPage {
|
||||
|
||||
int page(HTTPParameters &p) override {
|
||||
|
||||
p.data << "<form name=\"addview\" action=\"addview\" method=\"POST\">"
|
||||
" <div class=\"window\"><p>Please enter the name of the new view,"
|
||||
" then press Add View button below:"
|
||||
" <div style=\"border: 1pt solid white; padding: 3px; margin-bottom: 5px;\">"
|
||||
" <div>View Name:</div>"
|
||||
" <input type=\"text\" name=\"viewname\" size=\"30\">"
|
||||
" </div>"
|
||||
" <input type=\"button\" onmousedown=\"process('/editview/testview1','addview', 'app1'); return true;\" name=\"button1\" value=\"Add View\">"
|
||||
" </div></form>";
|
||||
|
||||
p.httpRequest.response.addHeader(coreutils::IMFHeader("Content-Type", "text/html"));
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -5,29 +5,31 @@ namespace http {
|
||||
|
||||
class __configure : public HTTPPage {
|
||||
|
||||
int processCommand(HTTPRequest *httpRequest, core::TCPSession *session, HTTPSession *httpSession, std::stringstream &data) override {
|
||||
public:
|
||||
__configure(HTTPParameters &p) { page(p); }
|
||||
|
||||
data << "<form name=\"configure\" action=\"setupadmin\" method=\"POST\">" << std::endl;
|
||||
data << " <div class=\"window\"><h1>System Configuration</h1>" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " <div style=\"border: 1pt solid white; padding: 3px; margin-bottom: 5px;\">" << std::endl;
|
||||
data << " <div>Web Domain Name:</div>" << std::endl;
|
||||
data << " <input type=\"text\" name=\"domainname\" size=\"30\">" << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << " <div style=\"border: 1pt solid white; padding: 3px; margin-bottom: 5px;\">" << std::endl;
|
||||
data << " <div>View Directory:</div>" << std::endl;
|
||||
data << " <input type=\"text\" name=\"viewdirectory\" size=\"30\">" << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << " <div style=\"border: 1pt solid white; padding: 3px; margin-bottom: 5px;\">" << std::endl;
|
||||
data << " <div>Image Library Directory:</div>" << std::endl;
|
||||
data << " <input type=\"password\" name=\"imagelibrary\" size=\"30\">" << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << " <br><br>Session Id: " << httpSession->getSessionId() << "" << std::endl;
|
||||
data << " <br>The configuration has not yet been established for this web site.</p>" << std::endl;
|
||||
data << " <input type=\"button\" onmousedown=\"process('/mainmenu','configure', 'main'); return true;\" name=\"button1\" value=\"Update Configuration\">" << std::endl;
|
||||
data << " </div></form>" << std::endl;
|
||||
int page(HTTPParameters &p) override {
|
||||
|
||||
httpRequest->response.addHeader("Content-Type", "text/html");
|
||||
p.data << "<form name=\"configure\" action=\"setupadmin\" method=\"POST\">"
|
||||
" <div class=\"window\"><h1>System Configuration</h1>"
|
||||
" <div style=\"border: 1pt solid white; padding: 3px; margin-bottom: 5px;\">"
|
||||
" <div>Web Domain Name:</div>"
|
||||
" <input type=\"text\" name=\"domainname\" size=\"30\">"
|
||||
" </div>"
|
||||
" <div style=\"border: 1pt solid white; padding: 3px; margin-bottom: 5px;\">"
|
||||
" <div>View Directory:</div>"
|
||||
" <input type=\"text\" name=\"viewdirectory\" size=\"30\">"
|
||||
" </div>"
|
||||
" <div style=\"border: 1pt solid white; padding: 3px; margin-bottom: 5px;\">"
|
||||
" <div>Image Library Directory:</div>"
|
||||
" <input type=\"password\" name=\"imagelibrary\" size=\"30\">"
|
||||
" </div>"
|
||||
" <br><br>Session Id: " << p.httpSession.getSessionId() << ""
|
||||
" <br>The configuration has not yet been established for this web site.</p>"
|
||||
" <input type=\"button\" onmousedown=\"process('/mainmenu','configure', 'main'); return true;\" name=\"button1\" value=\"Update Configuration\">"
|
||||
" </div></form>";
|
||||
|
||||
p.httpRequest.response.addHeader(coreutils::IMFHeader("Content-Type", "text/html"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
132
__editview.h
132
__editview.h
@ -8,76 +8,78 @@ namespace http {
|
||||
|
||||
class __editview : public HTTPPage {
|
||||
|
||||
int processCommand(HTTPRequest *httpRequest, core::TCPSession *session, HTTPSession *httpSession, std::stringstream &data) override {
|
||||
int page(HTTPParameters &p) override {
|
||||
|
||||
data << " <div style=\"position: relative;\">" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " <div id=\"window1\" style=\"position: absolute; left: 0px; top: 0px; border: 1pt solid black; display: inline-block; padding: 2px; background: #808080; color: #ffffff;\">" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " <span style=\"font: 20px bebasneue;\">View Editor</span>" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " <div id=\"mainpage\" " << std::endl;
|
||||
data << " style=\"width: 600px; height: 600px; border: 1px solid black; position: relative; background: #ffffff;\" " << std::endl;
|
||||
data << " onmousemove=\"mousemove(event); return true;\" " << std::endl;
|
||||
data << " onmouseup=\"mouseup(); return true;\">" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " <canvas id=\"grid\" width=\"600px\" height=\"600px\" style=\"position: absolute; left: 0px; top: 0px; alpha: 0.5; cursor: normal;\"></canvas>" << std::endl;
|
||||
data << "" << std::endl;
|
||||
|
||||
coreutils::File workspace("/home/barant/jetserver/views/testview1.view");
|
||||
char format[256];
|
||||
sprintf(format, "/home/barant/jetserver/views/%s.view", p.httpRequest.uriValues["view_name"].str().c_str());
|
||||
coreutils::File workspace(format);
|
||||
workspace.read();
|
||||
data << "<div id=\"__workspace__\">";
|
||||
data << workspace.asString();
|
||||
data << "</div>" << std::endl;
|
||||
// coreutils::ZString requestId(putRequest());
|
||||
|
||||
data << "" << std::endl;
|
||||
data << " <div id=\"window3\" style=\"position:absolute; top: 235px; left: 610px;" << std::endl;
|
||||
data << " border: 1pt solid black; display: inline-block; padding: 2px; background: #808080; color: #ffffff;\">" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " <span style=\"font: 20px bebasneue;\">OPTIONS</span>" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " <div style=\"width: 150px; height: 300px; color: #000000; border: 1px solid black; position: relative; background: #ffffff;\" " << std::endl;
|
||||
data << " onmousemove=\"mousemove(event); return true;\" " << std::endl;
|
||||
data << " onmouseup=\"mouseup(); return true;\"> " << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " <div id=\"controls\">" << std::endl;
|
||||
data << " <input type=\"checkbox\" name=\"grid\" onchange=\"showGrid = this.checked; drawGrid(); return true;\"><span style=\"font: 12px bebasneue; margin-bottom: 2px;\">Show Grid</span><br>" << std::endl;
|
||||
data << " <input type=\"checkbox\" name=\"snaptogrid\" onchange=\"snapToGrid = this.checked; return true;\"><span style=\"font: 12px bebasneue; margin-bottom: 2px;\">Snap To Grid</span><br>" << std::endl;
|
||||
data << " <span style=\"font: 12px bebasneue; margin-bottom: 2px;\">Grid Size: </span><input type=\"text\" name=\"gridsize\" id=\"gridsize\" style=\"width: 20px;\" size=\"3\" onchange=\"gridSize = parseInt(this.value); drawGrid(); return true;\"><br>" << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " <div id=\"itemparameters\" style=\"font: 12px bebasneue;\"></div>" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " <div id=\"data\" style=\"font: 12px bebasneue;\">" << std::endl;
|
||||
data << " <p>NO DATA</p>" << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " <div id=\"window2\" style=\"position:absolute; top: 0px; left: 610px; border: 1pt solid black; display: inline-block; padding: 2px; background: #808080; color: #ffffff;\">" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " <span style=\"font: 20px bebasneue;\">Toolbar</span>" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " <div id=\"toolbar\" " << std::endl;
|
||||
data << " style=\"width: 80px; height: 200px; border: 1px solid black; position: relative; background: #ffffff;\" " << std::endl;
|
||||
data << " onmousemove=\"mousemove(event); return true;\" " << std::endl;
|
||||
data << " onmouseup=\"mouseup(); return true;\">" << std::endl;
|
||||
data << " <button id=\"button1\" " << std::endl;
|
||||
data << " style=\"width: 40px; height: 40px; border: 2px solid green; position: absolute;\"" << std::endl;
|
||||
data << " onmousedown=\"mousedown(this, event); return true;\">Press</button>" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << " " << std::endl;
|
||||
data << " </div> " << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " <script src=\"/__editview_js\" />" << std::endl;
|
||||
p.data << " <div style=\"position: relative;\">"
|
||||
" <div id=\"window1\" style=\"position: absolute; left: 0px; top: 0px; border: 1pt solid black; display: inline-block; padding: 2px; background: #808080; color: #ffffff;\">"
|
||||
" <span style=\"font: 20px bebasneue;\">View Editor</span>"
|
||||
" <div id=\"mainpage\" "
|
||||
" style=\"width: 600px; height: 600px; border: 1px solid black; position: relative; background: #ffffff;\" "
|
||||
" onmousemove=\"mousemove(event); return true;\" "
|
||||
" onmouseup=\"mouseup(); return true;\">"
|
||||
" <canvas id=\"grid\" width=\"600px\" height=\"600px\" style=\"position: absolute; left: 0px; top: 0px; alpha: 0.5; cursor: normal;\"></canvas>"
|
||||
"<div id=\"__workspace__\">" << workspace.asString() << "</div>"
|
||||
" <div id=\"window3\" style=\"position:absolute; top: 235px; left: 610px;"
|
||||
" border: 1pt solid black; display: inline-block; padding: 2px; background: #808080; color: #ffffff;\">"
|
||||
" <span style=\"font: 20px bebasneue;\">OPTIONS</span>"
|
||||
" <div style=\"width: 150px; height: 300px; color: #000000; border: 1px solid black; position: relative; background: #ffffff;\" "
|
||||
" onmousemove=\"mousemove(event); return true;\" "
|
||||
" onmouseup=\"mouseup(); return true;\"> "
|
||||
" <div id=\"controls\">"
|
||||
" <input type=\"checkbox\" name=\"grid\" onchange=\"showGrid = this.checked; drawGrid(); return true;\"><span style=\"font: 12px bebasneue; margin-bottom: 2px;\">Show Grid</span><br>"
|
||||
" <input type=\"checkbox\" name=\"snaptogrid\" onchange=\"snapToGrid = this.checked; return true;\"><span style=\"font: 12px bebasneue; margin-bottom: 2px;\">Snap To Grid</span><br>"
|
||||
" <span style=\"font: 12px bebasneue; margin-bottom: 2px;\">Grid Size: </span><input type=\"text\" name=\"gridsize\" id=\"gridsize\" style=\"width: 20px;\" size=\"3\" onchange=\"gridSize = parseInt(this.value); drawGrid(); return true;\"><br>"
|
||||
" </div>"
|
||||
" <div id=\"itemparameters\" style=\"font: 12px bebasneue;\"></div>"
|
||||
" <div id=\"data\" style=\"font: 12px bebasneue;\">"
|
||||
" <p>NO DATA</p>"
|
||||
" </div>"
|
||||
" </div>"
|
||||
" </div>"
|
||||
" <div id=\"window2\" style=\"position:absolute; top: 0px; left: 610px; border: 1pt solid black; display: inline-block; padding: 2px; background: #808080; color: #ffffff;\">"
|
||||
" <span style=\"font: 20px bebasneue;\">Toolbar</span>"
|
||||
" <div id=\"toolbar\" "
|
||||
" style=\"width: 80px; height: 200px; border: 1px solid black; position: relative; background: #ffffff;\" "
|
||||
" onmousemove=\"mousemove(event); return true;\" "
|
||||
" onmouseup=\"mouseup(); return true;\">"
|
||||
" <button id=\"button1\" "
|
||||
" style=\"width: 40px; height: 40px; border: 2px solid green; position: absolute;\""
|
||||
" onmousedown=\"mousedown(this, event); return true;\">Press</button>"
|
||||
" </div>"
|
||||
" </div>"
|
||||
" <div id=\"window3\" style=\"position:absolute; top: 0px; left: 810px; border: 1pt solid black; display: inline-block; padding: 2px; background: #808080; color: #ffffff;\">"
|
||||
" <span style=\"font: 20px bebasneue;\">Styles</span>"
|
||||
" <div id=\"toolbar2\" "
|
||||
" style=\"width: 100px; height: 150px; border: 1px solid black; position: relative; background: #ffffff;\" "
|
||||
" onmousemove=\"mousemove(event); return true;\" "
|
||||
" onmouseup=\"mouseup(); return true;\">"
|
||||
" <button id=\"button1\" "
|
||||
" style=\"width: 40px; height: 40px; border: 2px solid green; position: absolute;\""
|
||||
" onmousedown=\"mousedown(this, event); return true;\">Press</button>"
|
||||
" </div>"
|
||||
" <div id=\"window4\" style=\"position:absolute; top: 600px; left: 10px; border: 1pt solid black; display: inline-block; padding: 2px; background: #808080; color: #ffffff;\">"
|
||||
" <span style=\"font: 20px bebasneue;\">Image Library</span>"
|
||||
" <div id=\"toolbar3\" "
|
||||
" style=\"width: 400px; height: 150px; border: 1px solid black; position: relative; background: #ffffff;\" "
|
||||
" onmousemove=\"mousemove(event); return true;\" "
|
||||
" onmouseup=\"mouseup(); return true;\">"
|
||||
" <button id=\"button1\" "
|
||||
" style=\"width: 40px; height: 40px; border: 2px solid green; position: absolute;\""
|
||||
" onmousedown=\"mousedown(this, event); return true;\">Press</button>"
|
||||
" </div>"
|
||||
" </div>"
|
||||
" </div>"
|
||||
" <script src=\"/__editview_js\" />";
|
||||
|
||||
httpRequest->response.addHeader("Content-Type", "text/html");
|
||||
p.httpRequest.response.addHeader(coreutils::IMFHeader("Content-Type", "text/html"));
|
||||
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
};
|
||||
|
109
__editview.js
109
__editview.js
@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
var mainpage;
|
||||
var result;
|
||||
var mousedownx;
|
||||
@ -198,110 +196,3 @@
|
||||
"</p>";
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@font-face {
|
||||
font-family: bebasneue;
|
||||
src: url('http://68.108.72.78:8080/fonts/BebasNeue.otf');
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body ondragstart="return false;"
|
||||
ondrop="return false;"
|
||||
onload="init(); return true;">
|
||||
|
||||
<div style="position: relative;">
|
||||
|
||||
<div id="window1" style="position: absolute; left: 0px; top: 0px; border: 1pt solid black; display: inline-block; padding: 2px; background: #808080; color: #ffffff;">
|
||||
|
||||
<span style="font: 20px bebasneue;">View Editor</span>
|
||||
|
||||
<div id="mainpage"
|
||||
style="width: 600px; height: 600px; border: 1px solid black; position: relative; background: #ffffff;"
|
||||
onmousemove="mousemove(event); return true;"
|
||||
onmouseup="mouseup(); return true;">
|
||||
|
||||
<canvas id="grid" width="600px" height="600px" style="position: absolute; left: 0px; top: 0px; alpha: 0.5; cursor: normal;"></canvas>
|
||||
|
||||
<img id="img1" style="position: absolute; user-select: none;" onmousedown="mousedown(this, event); return true;" src="images/barant_web_logo.png" width="336" height="69">
|
||||
|
||||
<img id="img2" style="position: absolute; user-select: none;" onmousedown="mousedown(this, event); return true;" src="images/barant_web_logo.png" width="336" height="69">
|
||||
|
||||
<button id="button1"
|
||||
style="width: 100px; height: 50px; border: 2px solid green; position: absolute;"
|
||||
onmousedown="mousedown(this, event); return true;">Press</button>
|
||||
|
||||
<div id="div1"
|
||||
style="width: 100px; height: 50px; border: 2px solid green; position: absolute;"
|
||||
onmousedown="mousedown(this, event); return true;">
|
||||
</div>
|
||||
|
||||
<div id="div2"
|
||||
style="width: 100px; height: 50px; border: 0px; position: absolute; background: #404040;"
|
||||
onmousedown="mousedown(this, event); return true;">
|
||||
</div>
|
||||
|
||||
<div id="div3"
|
||||
style="width: 100px; height: 100px; border: 10px solid red; position: absolute; background: #ffff80;"
|
||||
onmousedown="mousedown(this, event); return true;">
|
||||
</div>
|
||||
|
||||
<span id="text1" onmousedown="mousedown(this, event); return true;"
|
||||
style="position: absolute; user-select: none; border: 1pt solid black; background: #8080c0;">This is a text label</span>
|
||||
|
||||
<input id="input1" style="position: absolute;" onmousedown="mousedown(this, event); return true;" type="input" name="drag5" size="50">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="window3" style="position:absolute; top: 235px; left: 610px;
|
||||
border: 1pt solid black; display: inline-block; padding: 2px; background: #808080; color: #ffffff;">
|
||||
|
||||
<span style="font: 20px bebasneue;">OPTIONS</span>
|
||||
|
||||
<div style="width: 150px; height: 300px; color: #000000; border: 1px solid black; position: relative; background: #ffffff;"
|
||||
onmousemove="mousemove(event); return true;"
|
||||
onmouseup="mouseup(); return true;">
|
||||
|
||||
<div id="controls">
|
||||
<input type="checkbox" name="grid" onchange="showGrid = this.checked; drawGrid(); return true;"><span style="font: 12px bebasneue; margin-bottom: 2px;">Show Grid</span><br>
|
||||
<input type="checkbox" name="snaptogrid" onchange="snapToGrid = this.checked; return true;"><span style="font: 12px bebasneue; margin-bottom: 2px;">Snap To Grid</span><br>
|
||||
<span style="font: 12px bebasneue; margin-bottom: 2px;">Grid Size: </span><input type="text" name="gridsize" id="gridsize" style="width: 20px;" size="3" onchange="gridSize = parseInt(this.value); drawGrid(); return true;"><br>
|
||||
</div>
|
||||
|
||||
<div id="itemparameters" style="font: 12px bebasneue;"></div>
|
||||
|
||||
<div id="data" style="font: 12px bebasneue;">
|
||||
<p>NO DATA</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="window2" style="position:absolute; top: 0px; left: 610px; border: 1pt solid black; display: inline-block; padding: 2px; background: #808080; color: #ffffff;">
|
||||
|
||||
<span style="font: 20px bebasneue;">Toolbar</span>
|
||||
|
||||
<div id="toolbar"
|
||||
style="width: 80px; height: 200px; border: 1px solid black; position: relative; background: #ffffff;"
|
||||
onmousemove="mousemove(event); return true;"
|
||||
onmouseup="mouseup(); return true;">
|
||||
<button id="button1"
|
||||
style="width: 40px; height: 40px; border: 2px solid green; position: absolute;"
|
||||
onmousedown="mousedown(this, event); return true;">Press</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
400
__editview_js.h
400
__editview_js.h
@ -7,207 +7,209 @@ namespace http {
|
||||
|
||||
class __editview_js : public HTTPPage {
|
||||
|
||||
int processCommand(HTTPRequest *httpRequest, core::TCPSession *session, HTTPSession *httpSession, std::stringstream &data) override {
|
||||
data << " var mainpage;" << std::endl;
|
||||
data << " var result;" << std::endl;
|
||||
data << " var mousedownx;" << std::endl;
|
||||
data << " var mousedowny;" << std::endl;
|
||||
data << " var mouseDownWidth;" << std::endl;
|
||||
data << " var mouseDownHeight;" << std::endl;
|
||||
data << " var ismousedown = false;" << std::endl;
|
||||
data << " var dragobject;" << std::endl;
|
||||
data << " var dragHint = \"move\";" << std::endl;
|
||||
data << " var data;" << std::endl;
|
||||
data << " var showGrid = false;" << std::endl;
|
||||
data << " var snapToGrid = false;" << std::endl;
|
||||
data << " var gridSize = 10;" << std::endl;
|
||||
data << " var selected;" << std::endl;
|
||||
data << " var itemparameters;" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " mainpage = document.getElementById(\"mainpage\");" << std::endl;
|
||||
data << " data = document.getElementById(\"data\");" << std::endl;
|
||||
data << " itemparameters = document.getElementById(\"itemparameters\");" << std::endl;
|
||||
data << " var gridsize = document.getElementById(\"gridsize\");" << std::endl;
|
||||
data << " gridsize.value = gridSize;" << std::endl;
|
||||
data << " drawGrid();" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " function drawGrid() {" << std::endl;
|
||||
data << " var grid = document.getElementById(\"grid\");" << std::endl;
|
||||
data << " var context = grid.getContext(\"2d\");" << std::endl;
|
||||
data << " if(showGrid == true) {" << std::endl;
|
||||
data << " context.clearRect(0,0,grid.width,grid.height);" << std::endl;
|
||||
data << " context.globalAlpha = 0.2;" << std::endl;
|
||||
data << " context.lineWidth = 0.5; " << std::endl;
|
||||
data << " for(ix = 0; ix < grid.width; ix += gridSize) {" << std::endl;
|
||||
data << " context.beginPath();" << std::endl;
|
||||
data << " context.moveTo(ix, 0);" << std::endl;
|
||||
data << " context.lineTo(ix, grid.height);" << std::endl;
|
||||
data << " context.stroke();" << std::endl;
|
||||
data << " context.beginPath();" << std::endl;
|
||||
data << " context.moveTo(0, ix);" << std::endl;
|
||||
data << " context.lineTo(grid.width, ix);" << std::endl;
|
||||
data << " context.stroke(); " << std::endl;
|
||||
data << " }" << std::endl;
|
||||
data << " } else {" << std::endl;
|
||||
data << " context.clearRect(0,0,grid.width,grid.height);" << std::endl;
|
||||
data << " }" << std::endl;
|
||||
data << " }" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " function setDragHint(hint) {" << std::endl;
|
||||
data << " dragHint = hint;" << std::endl;
|
||||
data << " }" << std::endl;
|
||||
data << " " << std::endl;
|
||||
data << " function getMouseX(e) {" << std::endl;
|
||||
data << " return e.clientX - mainpage.offsetLeft - parseFloat(mainpage.style.borderWidth);" << std::endl;
|
||||
data << " }" << std::endl;
|
||||
data << " " << std::endl;
|
||||
data << " function getMouseY(e) {" << std::endl;
|
||||
data << " return e.clientY - mainpage.offsetTop - parseFloat(mainpage.style.borderWidth);" << std::endl;
|
||||
data << " }" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " function mousedown(obj, e) {" << std::endl;
|
||||
data << " var mouseX = getMouseX(e);" << std::endl;
|
||||
data << " var mouseY = getMouseY(e);" << std::endl;
|
||||
data << " mousedownx = mouseX - obj.offsetLeft;" << std::endl;
|
||||
data << " mousedowny = mouseY - obj.offsetTop;" << std::endl;
|
||||
data << " mouseDownLeft = parseFloat(obj.style.left);" << std::endl;
|
||||
data << " mouseDownTop = parseFloat(obj.style.top);" << std::endl;
|
||||
data << " mouseDownWidth = parseFloat(obj.style.width);" << std::endl;
|
||||
data << " mouseDownHeight = parseFloat(obj.style.height);" << std::endl;
|
||||
data << " dragobject = obj;" << std::endl;
|
||||
data << " selected = obj;" << std::endl;
|
||||
data << " ismousedown = true;" << std::endl;
|
||||
data << " displayParameters();" << std::endl;
|
||||
data << " }" << std::endl;
|
||||
data << " " << std::endl;
|
||||
data << " function mouseup() {" << std::endl;
|
||||
data << " ismousedown = false;" << std::endl;
|
||||
data << " dragobject = null;" << std::endl;
|
||||
data << " console.log(mainpage.innerHTML);" << std::endl;
|
||||
data << " }" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " function mousemove(e) {" << std::endl;
|
||||
data << " var mouseX = getMouseX(e);" << std::endl;
|
||||
data << " var mouseY = getMouseY(e);" << std::endl;
|
||||
data << " if(ismousedown) {" << std::endl;
|
||||
data << " " << std::endl;
|
||||
data << " if(dragHint == \"move\") {" << std::endl;
|
||||
data << " if(snapToGrid == false) {" << std::endl;
|
||||
data << " dragobject.style.left = (mouseX - mousedownx) + \"px\";" << std::endl;
|
||||
data << " dragobject.style.top = (mouseY - mousedowny) + \"px\";" << std::endl;
|
||||
data << " } else {" << std::endl;
|
||||
data << " dragobject.style.left = (Math.round((mouseX - mousedownx) / gridSize) * gridSize) + \"px\";" << std::endl;
|
||||
data << " dragobject.style.top = (Math.round((mouseY - mousedowny) / gridSize) * gridSize) + \"px\";" << std::endl;
|
||||
data << " }" << std::endl;
|
||||
data << " if((mouseX - mousedownx) < 0)" << std::endl;
|
||||
data << " dragobject.style.left = \"0px\";" << std::endl;
|
||||
data << " if((mouseY - mousedowny) < 0)" << std::endl;
|
||||
data << " dragobject.style.top = \"0px\";" << std::endl;
|
||||
data << " if((mouseX - mousedownx + parseFloat(dragobject.style.width)) > parseFloat(mainpage.style.width)) " << std::endl;
|
||||
data << " dragobject.style.left = (mouseX - mousedownx) + \"px\"; " << std::endl;
|
||||
data << " } else if(dragHint == \"rightbottomresize\") { " << std::endl;
|
||||
data << " dragobject.style.width = (mouseX - mouseDownLeft) + \"px\";" << std::endl;
|
||||
data << " dragobject.style.height = (mouseY - mouseDownTop) + \"px\";" << std::endl;
|
||||
data << " } else if(dragHint == \"rightresize\") { " << std::endl;
|
||||
data << " if(snapToGrid == false) {" << std::endl;
|
||||
data << " dragobject.style.width = (mouseX - mouseDownLeft) + \"px\"; " << std::endl;
|
||||
data << " } else {" << std::endl;
|
||||
data << " dragobject.style.width = (Math.round((mouseX - mouseDownLeft) / gridSize) * gridSize) + \"px\"; " << std::endl;
|
||||
data << " }" << std::endl;
|
||||
data << " } else if(dragHint == \"bottomresize\") { " << std::endl;
|
||||
data << " if(snapToGrid == false) {" << std::endl;
|
||||
data << " dragobject.style.height = (mouseY - mouseDownTop) + \"px\";" << std::endl;
|
||||
data << " } else {" << std::endl;
|
||||
data << " dragobject.style.height = (Math.round((mouseY - mouseDownTop) / gridSize) * gridSize) + \"px\";" << std::endl;
|
||||
data << " }" << std::endl;
|
||||
data << " } else if(dragHint == \"leftresize\") { " << std::endl;
|
||||
data << " dragobject.style.left = mouseX + \"px\";" << std::endl;
|
||||
data << " dragobject.style.width = (mouseDownWidth + (mouseDownLeft - mouseX)) + \"px\";" << std::endl;
|
||||
data << " } else if(dragHint == \"topresize\") { " << std::endl;
|
||||
data << " dragobject.style.top = mouseY + \"px\";" << std::endl;
|
||||
data << " dragobject.style.height = (mouseDownHeight + (mouseDownTop - mouseY)) + \"px\";" << std::endl;
|
||||
data << " }" << std::endl;
|
||||
data << " " << std::endl;
|
||||
data << " data.innerHTML = \"<p>\" + dragobject.nodeName + \"<br>\" + " << std::endl;
|
||||
data << " \"Action: \" + dragHint + \"<br>\" +" << std::endl;
|
||||
data << " \"MouseLocation: \" + mouseX + \":\" + mouseY + \"<br>\" +" << std::endl;
|
||||
data << " \"MouseOver Location: \" + (mouseX - dragobject.offsetLeft) + \":\" + (mouseY - dragobject.offsetTop) + \"<br>\" + " << std::endl;
|
||||
data << " \"Location: \" + dragobject.style.left + \":\" + dragobject.style.top + \"<br>\" + " << std::endl;
|
||||
data << " \"Size: \" + dragobject.style.width + \":\" + dragobject.style.height + \"<br>\" + " << std::endl;
|
||||
data << " \"</p>\";" << std::endl;
|
||||
data << " " << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " } else {" << std::endl;
|
||||
data << " var mouseabove = document.elementFromPoint(mouseX + mainpage.offsetLeft, mouseY + mainpage.offsetTop);" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " if((mouseabove.id != \"mainpage\") && (mouseabove.id != \"grid\")) {" << std::endl;
|
||||
data << " " << std::endl;
|
||||
data << " data.innerHTML = \"<p>\" + mouseabove.nodeName + \"<br>\" + " << std::endl;
|
||||
data << " \"Action: \" + dragHint + \"<br>\" +" << std::endl;
|
||||
data << " \"MouseLocation: \" + mouseX + \":\" + mouseY + \"<br>\" +" << std::endl;
|
||||
data << " \"MouseOver Location: \" + (mouseX - mouseabove.offsetLeft) + \":\" + (mouseY - mouseabove.offsetTop) + \"<br>\" + " << std::endl;
|
||||
data << " \"Location: \" + mouseabove.style.left + \":\" + mouseabove.style.top + \"<br>\" + " << std::endl;
|
||||
data << " \"Size: \" + mouseabove.style.width + \":\" + mouseabove.style.height + \"<br>\" + " << std::endl;
|
||||
data << " \"</p>\";" << std::endl;
|
||||
data << " " << std::endl;
|
||||
data << " if((mouseabove.nodeName == \"DIV\") || " << std::endl;
|
||||
data << " (mouseabove.nodeName == \"IMG\") || " << std::endl;
|
||||
data << " (mouseabove.nodeName == \"BUTTON\") ||" << std::endl;
|
||||
data << " (mouseabove.nodeName == \"INPUT\") ||" << std::endl;
|
||||
data << " (mouseabove.nodeName == \"SPAN\")) {" << std::endl;
|
||||
data << " " << std::endl;
|
||||
data << " if((parseFloat(mouseabove.style.width) <= (mouseX - mouseabove.offsetLeft)) && " << std::endl;
|
||||
data << " (parseFloat(mouseabove.style.height) <= (mouseY - mouseabove.offsetTop))) {" << std::endl;
|
||||
data << " mouseabove.style.cursor = \"nwse-resize\";" << std::endl;
|
||||
data << " dragHint = \"rightbottomresize\"; " << std::endl;
|
||||
data << " } else if((parseFloat(mouseabove.style.left) <= (mouseX - mouseabove.offsetLeft)) && " << std::endl;
|
||||
data << " ((parseFloat(mouseabove.style.borderWidth) + 2) >= (mouseY - mouseabove.offsetTop))) {" << std::endl;
|
||||
data << " mouseabove.style.cursor = \"nesw-resize\";" << std::endl;
|
||||
data << " dragHint = \"righttopresize\"; " << std::endl;
|
||||
data << " } else if(((parseFloat(mouseabove.style.borderWidth) + 2) >= (mouseX - mouseabove.offsetLeft)) && " << std::endl;
|
||||
data << " (parseFloat(mouseabove.style.height) <= (mouseY - mouseabove.offsetTop))) {" << std::endl;
|
||||
data << " mouseabove.style.cursor = \"nesw-resize\";" << std::endl;
|
||||
data << " dragHint = \"leftbottomresize\"; " << std::endl;
|
||||
data << " } else if(parseFloat(mouseabove.style.width) <= (mouseX - mouseabove.offsetLeft)) {" << std::endl;
|
||||
data << " mouseabove.style.cursor = \"ew-resize\";" << std::endl;
|
||||
data << " dragHint = \"rightresize\";" << std::endl;
|
||||
data << " } else if(parseFloat(mouseabove.style.height) <= (mouseY - mouseabove.offsetTop)) {" << std::endl;
|
||||
data << " mouseabove.style.cursor = \"ns-resize\";" << std::endl;
|
||||
data << " dragHint = \"bottomresize\";" << std::endl;
|
||||
data << " } else if((parseFloat(mouseabove.style.borderWidth) + 2) >= (mouseX - mouseabove.offsetLeft)) {" << std::endl;
|
||||
data << " mouseabove.style.cursor = \"ew-resize\";" << std::endl;
|
||||
data << " dragHint = \"leftresize\";" << std::endl;
|
||||
data << " } else if((parseFloat(mouseabove.style.borderWidth) + 2) >= (mouseY - mouseabove.offsetTop)) {" << std::endl;
|
||||
data << " mouseabove.style.cursor = \"ns-resize\";" << std::endl;
|
||||
data << " dragHint = \"topresize\";" << std::endl;
|
||||
data << " } else {" << std::endl;
|
||||
data << " mouseabove.style.cursor = \"move\";" << std::endl;
|
||||
data << " dragHint = \"move\";" << std::endl;
|
||||
data << " }" << std::endl;
|
||||
data << " } else {" << std::endl;
|
||||
data << " mouseabove.style.cursor = \"default\";" << std::endl;
|
||||
data << " }" << std::endl;
|
||||
data << " } else {" << std::endl;
|
||||
data << " mouseabove.style.cursor = \"default\";" << std::endl;
|
||||
data << " dragHint = \"\";" << std::endl;
|
||||
data << " data.innerHTML = \"<p></p>\";" << std::endl;
|
||||
data << " }" << std::endl;
|
||||
data << " }" << std::endl;
|
||||
data << " displayParameters();" << std::endl;
|
||||
data << " }" << std::endl;
|
||||
data << " " << std::endl;
|
||||
data << " function displayParameters() {" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " itemparameters.innerHTML = \"<p>\" + selected.nodeName + \": \" + selected.id + \"<br>\" + " << std::endl;
|
||||
data << " \"Location: \" + selected.style.left + \":\" + selected.style.top + \"<br>\" + " << std::endl;
|
||||
data << " \"Size: \" + selected.style.width + \":\" + selected.style.height + \"<br>\" + " << std::endl;
|
||||
data << " \"</p>\";" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " }" << std::endl;
|
||||
int page(HTTPParameters &p) override {
|
||||
|
||||
httpRequest->response.addHeader("Content-Type", "script/javascript");
|
||||
p.data << " var mainpage;"
|
||||
" var result;"
|
||||
" var mousedownx;"
|
||||
" var mousedowny;"
|
||||
" var mouseDownWidth;"
|
||||
" var mouseDownHeight;"
|
||||
" var ismousedown = false;"
|
||||
" var dragobject;"
|
||||
" var dragHint = \"move\";"
|
||||
" var data;"
|
||||
" var showGrid = false;"
|
||||
" var snapToGrid = false;"
|
||||
" var gridSize = 10;"
|
||||
" var selected;"
|
||||
" var itemparameters;"
|
||||
""
|
||||
" mainpage = document.getElementById(\"mainpage\");"
|
||||
" workspace = document.getElementById(\"__workspace__\");"
|
||||
" data = document.getElementById(\"data\");"
|
||||
" itemparameters = document.getElementById(\"itemparameters\");"
|
||||
" var gridsize = document.getElementById(\"gridsize\");"
|
||||
" gridsize.value = gridSize;"
|
||||
" drawGrid();"
|
||||
""
|
||||
" function drawGrid() {"
|
||||
" var grid = document.getElementById(\"grid\");"
|
||||
" var context = grid.getContext(\"2d\");"
|
||||
" if(showGrid == true) {"
|
||||
" context.clearRect(0,0,grid.width,grid.height);"
|
||||
" context.globalAlpha = 0.2;"
|
||||
" context.lineWidth = 0.5; "
|
||||
" for(ix = 0; ix < grid.width; ix += gridSize) {"
|
||||
" context.beginPath();"
|
||||
" context.moveTo(ix, 0);"
|
||||
" context.lineTo(ix, grid.height);"
|
||||
" context.stroke();"
|
||||
" context.beginPath();"
|
||||
" context.moveTo(0, ix);"
|
||||
" context.lineTo(grid.width, ix);"
|
||||
" context.stroke(); "
|
||||
" }"
|
||||
" } else {"
|
||||
" context.clearRect(0,0,grid.width,grid.height);"
|
||||
" }"
|
||||
" }"
|
||||
""
|
||||
" function setDragHint(hint) {"
|
||||
" dragHint = hint;"
|
||||
" }"
|
||||
" "
|
||||
" function getMouseX(e) {"
|
||||
" return e.clientX - mainpage.offsetLeft - parseFloat(mainpage.style.borderWidth);"
|
||||
" }"
|
||||
" "
|
||||
" function getMouseY(e) {"
|
||||
" return e.clientY - mainpage.offsetTop - parseFloat(mainpage.style.borderWidth);"
|
||||
" }"
|
||||
""
|
||||
" function mousedown(obj, e) {"
|
||||
" var mouseX = getMouseX(e);"
|
||||
" var mouseY = getMouseY(e);"
|
||||
" mousedownx = mouseX - obj.offsetLeft;"
|
||||
" mousedowny = mouseY - obj.offsetTop;"
|
||||
" mouseDownLeft = parseFloat(obj.style.left);"
|
||||
" mouseDownTop = parseFloat(obj.style.top);"
|
||||
" mouseDownWidth = parseFloat(obj.style.width);"
|
||||
" mouseDownHeight = parseFloat(obj.style.height);"
|
||||
" dragobject = obj;"
|
||||
" selected = obj;"
|
||||
" ismousedown = true;"
|
||||
" displayParameters();"
|
||||
" }"
|
||||
" "
|
||||
" function mouseup() {"
|
||||
" ismousedown = false;"
|
||||
" dragobject = null;"
|
||||
" console.log(workspace.innerHTML);"
|
||||
" }"
|
||||
""
|
||||
" function mousemove(e) {"
|
||||
" var mouseX = getMouseX(e);"
|
||||
" var mouseY = getMouseY(e);"
|
||||
" if(ismousedown) {"
|
||||
" "
|
||||
" if(dragHint == \"move\") {"
|
||||
" if(snapToGrid == false) {"
|
||||
" dragobject.style.left = (mouseX - mousedownx) + \"px\";"
|
||||
" dragobject.style.top = (mouseY - mousedowny) + \"px\";"
|
||||
" } else {"
|
||||
" dragobject.style.left = (Math.round((mouseX - mousedownx) / gridSize) * gridSize) + \"px\";"
|
||||
" dragobject.style.top = (Math.round((mouseY - mousedowny) / gridSize) * gridSize) + \"px\";"
|
||||
" }"
|
||||
" if((mouseX - mousedownx) < 0)"
|
||||
" dragobject.style.left = \"0px\";"
|
||||
" if((mouseY - mousedowny) < 0)"
|
||||
" dragobject.style.top = \"0px\";"
|
||||
" if((mouseX - mousedownx + parseFloat(dragobject.style.width)) > parseFloat(mainpage.style.width)) "
|
||||
" dragobject.style.left = (mouseX - mousedownx) + \"px\"; "
|
||||
" } else if(dragHint == \"rightbottomresize\") { "
|
||||
" dragobject.style.width = (mouseX - mouseDownLeft) + \"px\";"
|
||||
" dragobject.style.height = (mouseY - mouseDownTop) + \"px\";"
|
||||
" } else if(dragHint == \"rightresize\") { "
|
||||
" if(snapToGrid == false) {"
|
||||
" dragobject.style.width = (mouseX - mouseDownLeft) + \"px\"; "
|
||||
" } else {"
|
||||
" dragobject.style.width = (Math.round((mouseX - mouseDownLeft) / gridSize) * gridSize) + \"px\"; "
|
||||
" }"
|
||||
" } else if(dragHint == \"bottomresize\") { "
|
||||
" if(snapToGrid == false) {"
|
||||
" dragobject.style.height = (mouseY - mouseDownTop) + \"px\";"
|
||||
" } else {"
|
||||
" dragobject.style.height = (Math.round((mouseY - mouseDownTop) / gridSize) * gridSize) + \"px\";"
|
||||
" }"
|
||||
" } else if(dragHint == \"leftresize\") { "
|
||||
" dragobject.style.left = mouseX + \"px\";"
|
||||
" dragobject.style.width = (mouseDownWidth + (mouseDownLeft - mouseX)) + \"px\";"
|
||||
" } else if(dragHint == \"topresize\") { "
|
||||
" dragobject.style.top = mouseY + \"px\";"
|
||||
" dragobject.style.height = (mouseDownHeight + (mouseDownTop - mouseY)) + \"px\";"
|
||||
" }"
|
||||
" "
|
||||
" data.innerHTML = \"<p>\" + dragobject.nodeName + \"<br>\" + "
|
||||
" \"Action: \" + dragHint + \"<br>\" +"
|
||||
" \"MouseLocation: \" + mouseX + \":\" + mouseY + \"<br>\" +"
|
||||
" \"MouseOver Location: \" + (mouseX - dragobject.offsetLeft) + \":\" + (mouseY - dragobject.offsetTop) + \"<br>\" + "
|
||||
" \"Location: \" + dragobject.style.left + \":\" + dragobject.style.top + \"<br>\" + "
|
||||
" \"Size: \" + dragobject.style.width + \":\" + dragobject.style.height + \"<br>\" + "
|
||||
" \"</p>\";"
|
||||
" "
|
||||
""
|
||||
" } else {"
|
||||
" var mouseabove = document.elementFromPoint(mouseX + mainpage.offsetLeft, mouseY + mainpage.offsetTop);"
|
||||
""
|
||||
" if((mouseabove.id != \"mainpage\") && (mouseabove.id != \"grid\")) {"
|
||||
" "
|
||||
" data.innerHTML = \"<p>\" + mouseabove.nodeName + \"<br>\" + "
|
||||
" \"Action: \" + dragHint + \"<br>\" +"
|
||||
" \"MouseLocation: \" + mouseX + \":\" + mouseY + \"<br>\" +"
|
||||
" \"MouseOver Location: \" + (mouseX - mouseabove.offsetLeft) + \":\" + (mouseY - mouseabove.offsetTop) + \"<br>\" + "
|
||||
" \"Location: \" + mouseabove.style.left + \":\" + mouseabove.style.top + \"<br>\" + "
|
||||
" \"Size: \" + mouseabove.style.width + \":\" + mouseabove.style.height + \"<br>\" + "
|
||||
" \"</p>\";"
|
||||
" "
|
||||
" if((mouseabove.nodeName == \"DIV\") || "
|
||||
" (mouseabove.nodeName == \"IMG\") || "
|
||||
" (mouseabove.nodeName == \"BUTTON\") ||"
|
||||
" (mouseabove.nodeName == \"INPUT\") ||"
|
||||
" (mouseabove.nodeName == \"SPAN\")) {"
|
||||
" "
|
||||
" if((parseFloat(mouseabove.style.width) <= (mouseX - mouseabove.offsetLeft)) && "
|
||||
" (parseFloat(mouseabove.style.height) <= (mouseY - mouseabove.offsetTop))) {"
|
||||
" mouseabove.style.cursor = \"nwse-resize\";"
|
||||
" dragHint = \"rightbottomresize\"; "
|
||||
" } else if((parseFloat(mouseabove.style.left) <= (mouseX - mouseabove.offsetLeft)) && "
|
||||
" ((parseFloat(mouseabove.style.borderWidth) + 2) >= (mouseY - mouseabove.offsetTop))) {"
|
||||
" mouseabove.style.cursor = \"nesw-resize\";"
|
||||
" dragHint = \"righttopresize\"; "
|
||||
" } else if(((parseFloat(mouseabove.style.borderWidth) + 2) >= (mouseX - mouseabove.offsetLeft)) && "
|
||||
" (parseFloat(mouseabove.style.height) <= (mouseY - mouseabove.offsetTop))) {"
|
||||
" mouseabove.style.cursor = \"nesw-resize\";"
|
||||
" dragHint = \"leftbottomresize\"; "
|
||||
" } else if(parseFloat(mouseabove.style.width) <= (mouseX - mouseabove.offsetLeft)) {"
|
||||
" mouseabove.style.cursor = \"ew-resize\";"
|
||||
" dragHint = \"rightresize\";"
|
||||
" } else if(parseFloat(mouseabove.style.height) <= (mouseY - mouseabove.offsetTop)) {"
|
||||
" mouseabove.style.cursor = \"ns-resize\";"
|
||||
" dragHint = \"bottomresize\";"
|
||||
" } else if((parseFloat(mouseabove.style.borderWidth) + 2) >= (mouseX - mouseabove.offsetLeft)) {"
|
||||
" mouseabove.style.cursor = \"ew-resize\";"
|
||||
" dragHint = \"leftresize\";"
|
||||
" } else if((parseFloat(mouseabove.style.borderWidth) + 2) >= (mouseY - mouseabove.offsetTop)) {"
|
||||
" mouseabove.style.cursor = \"ns-resize\";"
|
||||
" dragHint = \"topresize\";"
|
||||
" } else {"
|
||||
" mouseabove.style.cursor = \"move\";"
|
||||
" dragHint = \"move\";"
|
||||
" }"
|
||||
" } else {"
|
||||
" mouseabove.style.cursor = \"default\";"
|
||||
" }"
|
||||
" } else {"
|
||||
" data.innerHTML = \"<p></p>\";"
|
||||
" mouseabove.style.cursor = \"default\";"
|
||||
" dragHint = \"\";"
|
||||
" }"
|
||||
" }"
|
||||
" displayParameters();"
|
||||
" }"
|
||||
" "
|
||||
" function displayParameters() {"
|
||||
""
|
||||
" itemparameters.innerHTML = \"<p>\" + selected.nodeName + \": \" + selected.id + \"<br>\" + "
|
||||
" \"Location: \" + selected.style.left + \":\" + selected.style.top + \"<br>\" + "
|
||||
" \"Size: \" + selected.style.width + \":\" + selected.style.height + \"<br>\" + "
|
||||
" \"</p>\";"
|
||||
""
|
||||
" }";
|
||||
|
||||
return 0;
|
||||
p.httpRequest.response.addHeader(coreutils::IMFHeader("Content-Type", "script/javascript"));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
};
|
||||
|
31
__entrypoints.h
Normal file
31
__entrypoints.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef ____entrypoints_h__
|
||||
#define ____entrypoints_h__
|
||||
|
||||
namespace http {
|
||||
|
||||
class __entrypoints : public HTTPPage {
|
||||
|
||||
int page(HTTPParameters &p) override {
|
||||
|
||||
p.data << "<form name=\"entrypoints\" action=\"entrypoints\" method=\"POST\">"
|
||||
" <div class=\"window\"><h1>Entry Points</h1>"
|
||||
" <div style=\"border: 1pt solid white; padding: 3px; margin-bottom: 5px;\">"
|
||||
" <div>Entry Point URL:</div>"
|
||||
" <input type=\"text\" name=\"entrypointurl\" size=\"30\">"
|
||||
" </div>"
|
||||
" <div style=\"border: 1pt solid white; padding: 3px; margin-bottom: 5px;\">"
|
||||
" <div>Entry Point Flow</div>"
|
||||
" <input type=\"text\" name=\"entrypointflow\" size=\"30\">"
|
||||
" </div>"
|
||||
" <br><br>Session Id: " << p.httpSession.getSessionId() << ""
|
||||
" <input type=\"button\" onmousedown=\"process('/mainmenu','configure', 'main'); return true;\" name=\"button1\" value=\"Update Configuration\">"
|
||||
" </div></form>";
|
||||
|
||||
p.httpRequest.response.addHeader(coreutils::IMFHeader("Content-Type", "text/html"));
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -7,15 +7,12 @@ namespace http {
|
||||
|
||||
class __favicon_ico : public HTTPPage {
|
||||
|
||||
int processCommand(HTTPRequest *httpRequest,
|
||||
core::TCPSession *session,
|
||||
HTTPSession *httpSession,
|
||||
std::stringstream &data) override {
|
||||
int page(HTTPParameters &p) override {
|
||||
|
||||
data << std::string(header_data, 806);
|
||||
p.data << std::string(header_data, 806);
|
||||
|
||||
httpRequest->response.addHeader("Content-Type", "image/x-icon");
|
||||
return true;
|
||||
p.httpRequest.response.addHeader(coreutils::IMFHeader("Content-Type", "image/x-icon"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char *header_data = {"\x00\x00\x01\x00\x01\x00\x20\x20\x00\x00\x01\x00\x08\x00\xA8\x08\x00"
|
||||
|
31
__index.h
31
__index.h
@ -2,29 +2,28 @@
|
||||
#define ____index_h__
|
||||
|
||||
#include "HTTPPage.h"
|
||||
#include "HTTPRequest.h"
|
||||
#include "IMFHeader.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
class __index : public HTTPPage {
|
||||
|
||||
int processCommand(HTTPRequest *httpRequest, core::TCPSession *session, HTTPSession *httpSession, std::stringstream &data) override {
|
||||
int page(HTTPParameters &p) override {
|
||||
|
||||
data << "<html>" << std::endl;
|
||||
data << " <head>" << std::endl;
|
||||
data << " <link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\" />" << std::endl;
|
||||
data << " <link type=\"text/css\" rel=\"stylesheet\" href=\"/style\" />" << std::endl;
|
||||
data << " <script src=\"/script\"></script>" << std::endl;
|
||||
data << " </head>" << std::endl;
|
||||
p.data << "<html>"
|
||||
" <head>"
|
||||
" <link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\" />"
|
||||
" <link type=\"text/css\" rel=\"stylesheet\" href=\"/style\" />"
|
||||
" <script src=\"/script\"></script>"
|
||||
" </head>"
|
||||
" <body ondragstart=\"return false;\" "
|
||||
" ondrop=\"return false;\" "
|
||||
" onLoad=\"getPage('/welcome','main');\">"
|
||||
" <div id=\"main\">If you see this then something is wrong.</div>"
|
||||
" </body>"
|
||||
"</html>";
|
||||
|
||||
data << "<body ondragstart=\"return false;\" " << std::endl;
|
||||
data << " ondrop=\"return false;\" " << std::endl;
|
||||
data << " onLoad=\"getPage('/welcome','main');\">" << std::endl;
|
||||
data << " <div id=\"main\">If you see this then something is wrong.</div>" << std::endl;
|
||||
data << " </body>" << std::endl;
|
||||
data << "</html>" << std::endl;
|
||||
|
||||
httpRequest->response.addHeader("Content-Type", "text/html");
|
||||
p.httpRequest.response.addHeader(coreutils::IMFHeader("Content-Type", "text/html"));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
55
__mainmenu.h
55
__mainmenu.h
@ -2,40 +2,41 @@
|
||||
#define ____mainmenu_h__
|
||||
|
||||
#include "HTTPPage.h"
|
||||
#include "IMFFormData.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
class __mainmenu : public HTTPPage {
|
||||
|
||||
int processCommand(HTTPRequest *httpRequest,
|
||||
core::TCPSession *session,
|
||||
HTTPSession *httpSession,
|
||||
std::stringstream &data) override {
|
||||
public:
|
||||
__mainmenu(HTTPParameters &p) { page(p); }
|
||||
|
||||
int page(HTTPParameters &p) override {
|
||||
|
||||
data << "<div>" << std::endl;
|
||||
data << " <div style=\"background: #448; color: #fff; width: 400px; margin: 5px; padding: 5px; cursor: pointer;\"" << std::endl;
|
||||
data << " onmousedown=\"getPage('/configure','main');\">" << std::endl;
|
||||
data << " <span>Setup Server Parameters</span>" << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << " <div style=\"background: #448; color: #fff; width: 400px; margin: 5px; padding: 5px; cursor: pointer;\"" << std::endl;
|
||||
data << " onmousedown=\"getPage('/viewlist','main');\">" << std::endl;
|
||||
data << " <span>View and Layout Designer</span>" << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << " <div style=\"background: #448; color: #fff; width: 400px; margin: 5px; padding: 5px; cursor: pointer;\"" << std::endl;
|
||||
data << " onmousedown=\"getPage('/entrypoints','main');\">" << std::endl;
|
||||
data << " <span>Entry Points</span>" << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << " <div style=\"background: #448; color: #fff; width: 400px; margin: 5px; padding: 5px; cursor: pointer;\"" << std::endl;
|
||||
data << " onmousedown=\"getPage('/viewlist','main');\">" << std::endl;
|
||||
data << " <span>Data Entity Editor</span>" << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << " <div style=\"background: #448; color: #fff; width: 400px; margin: 5px; padding: 5px; cursor: pointer;\"" << std::endl;
|
||||
data << " onmousedown=\"getPage('/workflow','main');\">" << std::endl;
|
||||
data << " <span>Work Flow Process Management</span>" << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << "</div>" << std::endl;
|
||||
p.data << "<div>"
|
||||
" <div style=\"background: #448; color: #fff; width: 400px; cursor: pointer;\""
|
||||
" onmousedown=\"getPage('/configure','app1');\">"
|
||||
" <span>Setup Server Parameters</span>"
|
||||
" </div>"
|
||||
" <div style=\"background: #448; color: #fff; width: 400px; cursor: pointer;\""
|
||||
" onmousedown=\"getPage('/viewlist','app1');\">"
|
||||
" <span>View and Layout Designer</span>"
|
||||
" </div>"
|
||||
" <div style=\"background: #448; color: #fff; width: 400px; cursor: pointer;\""
|
||||
" onmousedown=\"getPage('/entrypoints','app1');\">"
|
||||
" <span>Entry Points</span>"
|
||||
" </div>"
|
||||
" <div style=\"background: #448; color: #fff; width: 400px; cursor: pointer;\""
|
||||
" onmousedown=\"getPage('/viewlist','app1');\">"
|
||||
" <span>Data Entity Editor</span>"
|
||||
" </div>"
|
||||
" <div style=\"background: #448; color: #fff; width: 400px; cursor: pointer;\""
|
||||
" onmousedown=\"getPage('/workflow','app1');\">"
|
||||
" <span>Work Flow Process Management</span>"
|
||||
" </div>"
|
||||
"</div>";
|
||||
|
||||
httpRequest->response.addHeader("Content-Type", "text/html");
|
||||
p.httpRequest.response.addHeader(coreutils::IMFHeader("Content-Type", "text/html"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
76
__script.h
76
__script.h
@ -7,51 +7,45 @@ namespace http {
|
||||
|
||||
class __script : public HTTPPage {
|
||||
|
||||
int processCommand(HTTPRequest *httpRequest,
|
||||
core::TCPSession *session,
|
||||
HTTPSession *httpSession,
|
||||
std::stringstream &data) override {
|
||||
int page(HTTPParameters &p) override {
|
||||
|
||||
data << "function serverSend(url, type, receiver, formData, callback) {" << std::endl;
|
||||
data << " var server = new XMLHttpRequest();" << std::endl;
|
||||
data << " server.onload = function() {" << std::endl;
|
||||
data << " if(server.readyState == 4 && server.status == 200)" << std::endl;
|
||||
data << " callback(server.responseText, receiver);" << std::endl;
|
||||
data << " };" << std::endl;
|
||||
data << " server.open(type, url, true);" << std::endl;
|
||||
data << " server.send(formData);" << std::endl;
|
||||
data << "}" << std::endl;
|
||||
p.data << "function serverSend(url, type, receiver, formData, callback) {"
|
||||
" var server = new XMLHttpRequest();"
|
||||
" server.onload = function() {"
|
||||
" if(server.readyState == 4 && server.status == 200)"
|
||||
" callback(server.responseText, receiver);"
|
||||
" };"
|
||||
" server.open(type, url, true);"
|
||||
" server.send(formData);"
|
||||
"}"
|
||||
"function getPage(url, receiver) {"
|
||||
" serverSend(url, \"GET\", receiver, null, function(data, receiver) {"
|
||||
" insertAndExecute(receiver, data);"
|
||||
" });"
|
||||
"}"
|
||||
"function process(url, formName, receiver) {"
|
||||
" var formElement = document.querySelector(\"form[name='\" + formName + \"']\");"
|
||||
" var formData = new FormData(formElement);"
|
||||
" serverSend(url, \"POST\", receiver, formData, function(data, receiver) {"
|
||||
" insertAndExecute(receiver, data);"
|
||||
" });"
|
||||
"}"
|
||||
"function insertAndExecute(id, text) {"
|
||||
" idresolved = document.getElementById(id);"
|
||||
" idresolved.innerHTML = text;"
|
||||
" var scriptarr = idresolved.getElementsByTagName(\"script\");"
|
||||
" if(scriptarr.length > 0) {"
|
||||
" var script = document.createElement(\"script\");"
|
||||
" script.type = \"text/javascript\";"
|
||||
" script.src = scriptarr[0].src;"
|
||||
" document.getElementsByTagName(\"head\")[0].appendChild(script);"
|
||||
" }"
|
||||
"}";
|
||||
|
||||
data << "function getPage(url, receiver) {" << std::endl;
|
||||
data << " serverSend(url, \"GET\", receiver, null, function(data, receiver) {" << std::endl;
|
||||
data << " insertAndExecute(receiver, data);" << std::endl;
|
||||
data << " });" << std::endl;
|
||||
data << "}" << std::endl;
|
||||
p.httpRequest.response.addHeader(coreutils::IMFHeader("Content-Type", "text/javascript"));
|
||||
|
||||
data << "function process(url, formName, receiver) {" << std::endl;
|
||||
data << " var formElement = document.querySelector(\"form[name='\" + formName + \"']\");" << std::endl;
|
||||
data << " var formData = new FormData(formElement);" << std::endl;
|
||||
data << " serverSend(url, \"POST\", receiver, formData, function(data, receiver) {" << std::endl;
|
||||
data << " insertAndExecute(receiver, data);" << std::endl;
|
||||
data << " });" << std::endl;
|
||||
data << "}" << std::endl;
|
||||
|
||||
data << "function insertAndExecute(id, text) {" << std::endl;
|
||||
data << " idresolved = document.getElementById(id);" << std::endl;
|
||||
data << " idresolved.innerHTML = text;" << std::endl;
|
||||
data << " var scriptarr = idresolved.getElementsByTagName(\"script\");" << std::endl;
|
||||
data << " if(scriptarr.length > 0) {" << std::endl;
|
||||
data << " var script = document.createElement(\"script\");" << std::endl;
|
||||
data << " script.type = \"text/javascript\";" << std::endl;
|
||||
data << " script.src = scriptarr[0].src;" << std::endl;
|
||||
data << " document.getElementsByTagName(\"head\")[0].appendChild(script);" << std::endl;
|
||||
data << " }" << std::endl;
|
||||
data << "}" << std::endl;
|
||||
|
||||
httpRequest->response.addHeader("Content-Type", "text/javascript");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
43
__setupadmin.cpp
Normal file
43
__setupadmin.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
#include "__setupadmin.h"
|
||||
#include "__mainmenu.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
__setupadmin::__setupadmin(HTTPParameters &p) { page(p); }
|
||||
|
||||
int __setupadmin::page(HTTPParameters &p) {
|
||||
|
||||
button1Click *click = new button1Click();
|
||||
coreutils::ZString button1_Click(p.actionList.addAction(click));
|
||||
|
||||
p.data << "<form name=\"setupadmin\" method=\"POST\">"
|
||||
" <p>Please enter credential information"
|
||||
" for the security officer, then press Set Admin Profile button below:"
|
||||
" <div style=\"border: 1pt solid white; background-color: #000; padding: 3px; margin-bottom: 5px;\">"
|
||||
" <div>User Name:</div>"
|
||||
" <input type=\"text\" name=\"username\" size=\"30\">"
|
||||
" </div>"
|
||||
" <div style=\"border: 1pt solid white; padding: 3px; margin-bottom: 5px;\">"
|
||||
" <div>Password:</div>"
|
||||
" <input type=\"password\" name=\"password\" size=\"30\">"
|
||||
" </div>"
|
||||
" <div style=\"border: 1pt solid white; padding: 3px; margin-bottom: 5px;\">"
|
||||
" <div>Verify Password:</div>"
|
||||
" <input type=\"password\" name=\"verify\" size=\"30\">"
|
||||
" </div>"
|
||||
" <br><br>Session Id: " << p.httpSession.getSessionId() << ""
|
||||
" <br>The configuration has not yet been established for this web site.</p>"
|
||||
" <input type=\"button\" onmousedown=\"process('" << button1_Click << "', 'setupadmin', 'admin'); return true;\" name=\"button1\" value=\"Set Admin Profile\">"
|
||||
" </form>";
|
||||
|
||||
p.httpRequest.response.addHeader(coreutils::IMFHeader("Content-Type", "text/html"));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool __setupadmin::button1Click::action(HTTPParameters &p) {
|
||||
__mainmenu mainmenu(p);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -1,36 +1,24 @@
|
||||
#ifndef ____setupadmin_h__
|
||||
#define ____setupadmin_h__
|
||||
|
||||
#include "HTTPPage.h"
|
||||
#include "FlowAction.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
class __setupadmin : public HTTPPage {
|
||||
|
||||
int processCommand(HTTPRequest *httpRequest, core::TCPSession *session, HTTPSession *httpSession, std::stringstream &data) override {
|
||||
public:
|
||||
__setupadmin(HTTPParameters &p);
|
||||
|
||||
data << "<form name=\"setupadmin\" action=\"setupadmin\" method=\"POST\">" << std::endl;
|
||||
data << " <div class=\"window\"><p>Please enter credential information" << std::endl;
|
||||
data << " for the security officer, then press Set Admin Profile button below:" << std::endl;
|
||||
data << " <div style=\"border: 1pt solid white; padding: 3px; margin-bottom: 5px;\">" << std::endl;
|
||||
data << " <div>User Name:</div>" << std::endl;
|
||||
data << " <input type=\"text\" name=\"username\" size=\"30\">" << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << " <div style=\"border: 1pt solid white; padding: 3px; margin-bottom: 5px;\">" << std::endl;
|
||||
data << " <div>Password:</div>" << std::endl;
|
||||
data << " <input type=\"password\" name=\"password\" size=\"30\">" << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << " <div style=\"border: 1pt solid white; padding: 3px; margin-bottom: 5px;\">" << std::endl;
|
||||
data << " <div>Verify Password:</div>" << std::endl;
|
||||
data << " <input type=\"password\" name=\"verify\" size=\"30\">" << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << " <br><br>Session Id: " << httpSession->getSessionId() << "" << std::endl;
|
||||
data << " <br>The configuration has not yet been established for this web site.</p>" << std::endl;
|
||||
data << " <input type=\"button\" onmousedown=\"process('/mainmenu','setupadmin', 'main'); return true;\" name=\"button1\" value=\"Set Admin Profile\">" << std::endl;
|
||||
data << " </div></form>" << std::endl;
|
||||
int page(HTTPParameters &p) override;
|
||||
|
||||
httpRequest->response.addHeader("Content-Type", "text/html");
|
||||
class button1Click : public FlowAction {
|
||||
|
||||
return true;
|
||||
}
|
||||
public:
|
||||
bool action(HTTPParameters &p) override;
|
||||
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
45
__style.h
45
__style.h
@ -5,23 +5,42 @@
|
||||
|
||||
namespace http {
|
||||
|
||||
#include "HTTPPage.h"
|
||||
#include "HTTPParameters.h"
|
||||
|
||||
class __style : public HTTPPage {
|
||||
|
||||
int processCommand(HTTPRequest *httpRequest, core::TCPSession *session, HTTPSession *httpSession, std::stringstream &data) override {
|
||||
int page(HTTPParameters &p) override {
|
||||
|
||||
data << "body {background: #006;" << std::endl;
|
||||
data << " color: #fff;" << std::endl;
|
||||
data << " }" << std::endl;
|
||||
p.data << "body {background: #006;"
|
||||
" color: #fff;"
|
||||
" }\n"
|
||||
".window {background: #668;"
|
||||
" color: #fff;"
|
||||
" border: 1pt solid #f00;"
|
||||
" width: 400px;"
|
||||
" padding: 3px;"
|
||||
" }\n"
|
||||
".adminheader {background: #000;"
|
||||
" color: #fff;"
|
||||
" border: 1pt solid #888;"
|
||||
" width: 400px;"
|
||||
" padding: 3px;"
|
||||
" }\n"
|
||||
"h1 {background: #223;"
|
||||
" color: #fff;"
|
||||
" padding: 5px;"
|
||||
" margin: 0px 0px 5px 0px;"
|
||||
" }\n"
|
||||
"input[type=text] {background: #0000;"
|
||||
" color: #fff;"
|
||||
" border: 0px;"
|
||||
" padding: 5px;"
|
||||
" margin: 0px 0px 5px 0px;"
|
||||
" }\n";
|
||||
|
||||
data << ".window {background: #668;" << std::endl;
|
||||
data << " color: #fff;" << std::endl;
|
||||
data << " border: 1pt solid #f00;" << std::endl;
|
||||
data << " width: 400px;" << std::endl;
|
||||
data << " padding: 15px;" << std::endl;
|
||||
data << " }" << std::endl;
|
||||
|
||||
httpRequest->response.addHeader("Content-Type", "text/css");
|
||||
return true;
|
||||
p.httpRequest.response.addHeader(coreutils::IMFHeader("Content-Type", "text/css"));
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
29
__viewlist.h
29
__viewlist.h
@ -2,25 +2,22 @@
|
||||
#define ____viewlist_h__
|
||||
|
||||
#include "HTTPPage.h"
|
||||
#include "HTTPParameters.h"
|
||||
#include "Directory.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
class __viewlist : public HTTPPage {
|
||||
|
||||
int processCommand(HTTPRequest *httpRequest,
|
||||
core::TCPSession *session,
|
||||
HTTPSession *httpSession,
|
||||
std::stringstream &data) override {
|
||||
int page(HTTPParameters &p) override {
|
||||
|
||||
coreutils::Directory directory("../../jetserver/views");
|
||||
|
||||
data << "<div>" << std::endl;
|
||||
|
||||
data << " <div style=\"background: #484; color: #fff; width: 400px; margin: 5px; padding: 5px; cursor: pointer;\"" << std::endl;
|
||||
data << " onmousedown=\"getPage('/editview','main');\">" << std::endl;
|
||||
data << " <span>Create new view</span>" << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
p.data << "<div>"
|
||||
" <div style=\"background: #484; color: #fff; width: 400px; margin: 5px; padding: 5px; cursor: pointer;\""
|
||||
" onmousedown=\"getPage('/addview','app1');\">"
|
||||
" <span>Create new view</span>"
|
||||
" </div>";
|
||||
|
||||
while(!directory.eod()) {
|
||||
|
||||
@ -29,16 +26,16 @@ namespace http {
|
||||
continue;
|
||||
}
|
||||
|
||||
data << " <div style=\"background: #448; color: #fff; width: 400px; margin: 5px; padding: 5px; cursor: pointer;\"" << std::endl;
|
||||
data << " onmousedown=\"getPage('/editview?view=testview1','main');\">" << std::endl;
|
||||
data << " <span>" << directory.get().getName() << "</span>" << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
p.data << " <div style=\"background: #448; color: #fff; width: 400px; margin: 5px; padding: 5px; cursor: pointer;\""
|
||||
" onmousedown=\"getPage('/editview/' + directory.get().getName(),'app1');\">"
|
||||
" <span>" << directory.get().getName() << "</span>"
|
||||
" </div>";
|
||||
directory.next();
|
||||
}
|
||||
|
||||
data << "</div>" << std::endl;
|
||||
p.data << "</div>";
|
||||
|
||||
httpRequest->response.addHeader("Content-Type", "text/html");
|
||||
p.httpRequest.response.addHeader(coreutils::IMFHeader("Content-Type", "text/html"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
34
__welcome.cpp
Normal file
34
__welcome.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include "__welcome.h"
|
||||
#include "__setupadmin.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
int __welcome::page(HTTPParameters &p) {
|
||||
|
||||
p.data << "<div class=\"adminheader\">"
|
||||
"Session Id: " << p.httpSession.getSessionId() << " <br>User: *ADMIN"
|
||||
"</div><br>";
|
||||
|
||||
button1Click *click = new button1Click();
|
||||
coreutils::ZString button1_Click(p.actionList.addAction(click));
|
||||
|
||||
p.data << "<div id=\"admin\" class=\"window\">"
|
||||
"<form name='admin'>"
|
||||
"<p>You have successfully set up a JETServer."
|
||||
"<br>The configuration has not yet been established for this web site.</p>"
|
||||
"<input type=\"button\" onmousedown=\"process('" << button1_Click << "', 'admin', 'admin'); return true;\" name=\"button1\" value=\"Configure\">"
|
||||
"</form></div><br>";
|
||||
|
||||
p.data << "<div id=\"app1\"></div><br>";
|
||||
|
||||
p.httpRequest.response.addHeader(coreutils::IMFHeader("Content-Type", "text/html"));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool __welcome::button1Click::action(HTTPParameters &p) {
|
||||
__setupadmin setupadmin(p);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
20
__welcome.h
20
__welcome.h
@ -1,28 +1,22 @@
|
||||
#ifndef ____welcome_h__
|
||||
#define ____welcome_h__
|
||||
|
||||
#include "FlowAction.h"
|
||||
#include "HTTPPage.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
class __welcome : public HTTPPage {
|
||||
|
||||
int processCommand(HTTPRequest *httpRequest,
|
||||
core::TCPSession *session,
|
||||
HTTPSession *httpSession,
|
||||
std::stringstream &data) override {
|
||||
public:
|
||||
int page(HTTPParameters &p) override;
|
||||
|
||||
data << "<div class=\"window\">\
|
||||
<p>You have successfully set up a JETServer.\
|
||||
<br>Session Id: " << httpSession->getSessionId() << "\
|
||||
<br>The configuration has not yet been established for this web site.</p>\
|
||||
<input type=\"button\" onmousedown=\"getPage('/setupadmin','main'); return true;\" name=\"button1\" value=\"Configure\">\
|
||||
</div>";
|
||||
class button1Click : public FlowAction {
|
||||
|
||||
httpRequest->response.addHeader("Content-Type", "text/html");
|
||||
public:
|
||||
bool action(HTTPParameters &p) override;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
169
__workflow.h
169
__workflow.h
@ -7,91 +7,92 @@ namespace http {
|
||||
|
||||
class __workflow : public HTTPPage {
|
||||
|
||||
int processCommand(std::string request, core::TCPSession *session, HTTPSession *httpSession, HTTPRequest &httpRequest, std::stringstream &data) {
|
||||
data << "<svg style=\"width: 100%; height: 100%; position: absolute; top: 0px; left: 0px;\">" << std::endl;
|
||||
data << " <path id=\"connector0\" data-source=\"start:bottom\" data-dest=\"formpage1\" d=\"\" stroke=\"#FFFFFF\" stroke-width=\"1\" fill=\"none\" />" << std::endl;
|
||||
data << " <path id=\"connector1\" data-source=\"formpage1:next\" data-dest=\"formpage2\" d=\"\" stroke=\"#FFFFFF\" stroke-width=\"1\" fill=\"none\" />" << std::endl;
|
||||
data << " <path id=\"connector2\" data-source=\"formpage2:next\" data-dest=\"formpage3\" d=\"\" stroke=\"#FFFFFF\" stroke-width=\"1\" fill=\"none\" />" << std::endl;
|
||||
data << " <path id=\"connector3\" data-source=\"formpage2:previous\" data-dest=\"formpage1\" d=\"\" stroke=\"#FFFFFF\" stroke-width=\"1\" fill=\"none\" />" << std::endl;
|
||||
data << " <path id=\"connector4\" data-source=\"formpage3:previous\" data-dest=\"formpage2\" d=\"\" stroke=\"#FFFFFF\" stroke-width=\"1\" fill=\"none\" />" << std::endl;
|
||||
data << " <path id=\"connector5\" data-source=\"formpage3:process\" data-dest=\"processform\" d=\"\" stroke=\"#FFFFFF\" stroke-width=\"1\" fill=\"none\" />" << std::endl;
|
||||
data << "</svg>" << std::endl;
|
||||
data << "<div style=\"position: absolute; width: 200px; top: 20px; left: 50px; background: #C04040; border: 1px solid white;\" id=\"start\"" << std::endl;
|
||||
data << " onmousedown=\"mousedown(this, event); return true;\" " << std::endl;
|
||||
data << " onmouseup=\"mouseup(event); return true;\" " << std::endl;
|
||||
data << " onmousemove=\"mousemove(event); return true;\">" << std::endl;
|
||||
data << "[AQ] START" << std::endl;
|
||||
data << "</div>" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << "<div style=\"position: absolute; top: 100px; left: 150px; background: #E0E0E0; border: 1px solid white; color: #000000;\" " << std::endl;
|
||||
data << " id=\"formpage1\"" << std::endl;
|
||||
data << " onmousedown=\"mousedown(this, event); return true;\" " << std::endl;
|
||||
data << " onmouseup=\"mouseup(event); return true;\" " << std::endl;
|
||||
data << " onmousemove=\"mousemove(event); return true;\">" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " <div style=\"width: 200px; height: 20px; padding-left: 3px; background: #4040C0; color: #FFFFFF;\">" << std::endl;
|
||||
data << " <span>[XQ] FORM Page 1</span> " << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << " <div data-name=\"cancel\" style=\"width: 200px; height: 20px; margin-top: 2px; padding-left: 3px ;background: #C0C0FF;\">" << std::endl;
|
||||
data << " <span>Cancel</span> " << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << " <div data-name=\"next\" style=\"width: 200px; height: 20px; margin-top: 2px; padding-left: 3px; background: #C0C0FF;\">" << std::endl;
|
||||
data << " <span>Next</span> " << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << "</div>" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << "<div style=\"position: absolute; top: 300px; left: 250px; background: #E0E0E0; border: 1px solid white;\" " << std::endl;
|
||||
data << " id=\"formpage2\" " << std::endl;
|
||||
data << " onmousedown=\"mousedown(this, event); return true;\" " << std::endl;
|
||||
data << " onmouseup=\"mouseup(event); return true;\" " << std::endl;
|
||||
data << " onmousemove=\"mousemove(event); return true;\">" << std::endl;
|
||||
data << " <div style=\"width: 200px; height: 20px; padding-left: 3px; background: #4040C0; color: #FFFFFF;\">" << std::endl;
|
||||
data << " <span>[XQ] FORM Page 2</span> " << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << " <div data-name=\"previous\" style=\"width: 200px; height: 20px; margin-top: 2px; padding-left: 3px ;background: #C0C0FF;\">" << std::endl;
|
||||
data << " <span>Previous</span> " << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << " <div data-name=\"next\" style=\"width: 200px; height: 20px; margin-top: 2px; padding-left: 3px; background: #C0C0FF;\">" << std::endl;
|
||||
data << " <span>Next</span> " << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << "</div>" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << "<div style=\"position: absolute; top: 400px; left: 200px; background: #E0E0E0; border: 1px solid white;\" " << std::endl;
|
||||
data << " id=\"formpage3\" " << std::endl;
|
||||
data << " onmousedown=\"mousedown(this, event); return true;\" " << std::endl;
|
||||
data << " onmouseup=\"mouseup(event); return true;\" " << std::endl;
|
||||
data << " onmousemove=\"mousemove(event); return true;\">" << std::endl;
|
||||
data << " <div style=\"width: 200px; height: 20px; padding-left: 3px; background: #4040C0; color: #FFFFFF;\">" << std::endl;
|
||||
data << " <span>[XQ] FORM Page 3</span> " << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << " <div data-name=\"previous\" style=\"width: 200px; height: 20px; margin-top: 2px; padding-left: 3px ;background: #C0C0FF;\">" << std::endl;
|
||||
data << " <span>Previous</span> " << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << " <div data-name=\"process\" style=\"width: 200px; height: 20px; margin-top: 2px; padding-left: 3px; background: #C0C0FF;\">" << std::endl;
|
||||
data << " <span>Process Form</span> " << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << "</div>" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << "<div style=\"position: absolute; top: 500px; left: 200px; background: #E0E0E0; border: 1px solid white;\" " << std::endl;
|
||||
data << " id=\"processform\" " << std::endl;
|
||||
data << " onmousedown=\"mousedown(this, event); return true;\" " << std::endl;
|
||||
data << " onmouseup=\"mouseup(event); return true;\" " << std::endl;
|
||||
data << " onmousemove=\"mousemove(event); return true;\">" << std::endl;
|
||||
data << " <div style=\"width: 200px; height: 20px; padding-left: 3px; background: #40C040; color: #FFFFFF;\">" << std::endl;
|
||||
data << " <span>[PQ] Process Form</span> " << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << " <div data-name=\"previous\" style=\"width: 200px; height: 20px; margin-top: 2px; padding-left: 3px ;background: #C0C0FF;\">" << std::endl;
|
||||
data << " <span>Previous</span> " << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << " <div data-name=\"process\" style=\"width: 200px; height: 20px; margin-top: 2px; padding-left: 3px; background: #C0C0FF;\">" << std::endl;
|
||||
data << " <span>Process Form</span> " << std::endl;
|
||||
data << " </div>" << std::endl;
|
||||
data << "</div>" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << "<script src=\"/__workflow_js\" />" << std::endl;
|
||||
int page(HTTPParameters &p) override {
|
||||
|
||||
httpRequest.response.addHeader("Content-Type", "script/javascript");
|
||||
return 0;
|
||||
p.data << "<svg style=\"width: 100%; height: 100%; position: absolute; top: 0px; left: 0px;\">"
|
||||
" <path id=\"connector0\" data-source=\"start:bottom\" data-dest=\"formpage1\" d=\"\" stroke=\"#FFFFFF\" stroke-width=\"1\" fill=\"none\" />"
|
||||
" <path id=\"connector1\" data-source=\"formpage1:next\" data-dest=\"formpage2\" d=\"\" stroke=\"#FFFFFF\" stroke-width=\"1\" fill=\"none\" />"
|
||||
" <path id=\"connector2\" data-source=\"formpage2:next\" data-dest=\"formpage3\" d=\"\" stroke=\"#FFFFFF\" stroke-width=\"1\" fill=\"none\" />"
|
||||
" <path id=\"connector3\" data-source=\"formpage2:previous\" data-dest=\"formpage1\" d=\"\" stroke=\"#FFFFFF\" stroke-width=\"1\" fill=\"none\" />"
|
||||
" <path id=\"connector4\" data-source=\"formpage3:previous\" data-dest=\"formpage2\" d=\"\" stroke=\"#FFFFFF\" stroke-width=\"1\" fill=\"none\" />"
|
||||
" <path id=\"connector5\" data-source=\"formpage3:process\" data-dest=\"processform\" d=\"\" stroke=\"#FFFFFF\" stroke-width=\"1\" fill=\"none\" />"
|
||||
"</svg>"
|
||||
"<div style=\"position: absolute; width: 200px; top: 20px; left: 50px; background: #C04040; border: 1px solid white;\" id=\"start\""
|
||||
" onmousedown=\"mousedown(this, event); return true;\" "
|
||||
" onmouseup=\"mouseup(event); return true;\" "
|
||||
" onmousemove=\"mousemove(event); return true;\">"
|
||||
"[AQ] START"
|
||||
"</div>"
|
||||
""
|
||||
"<div style=\"position: absolute; top: 100px; left: 150px; background: #E0E0E0; border: 1px solid white; color: #000000;\" "
|
||||
" id=\"formpage1\""
|
||||
" onmousedown=\"mousedown(this, event); return true;\" "
|
||||
" onmouseup=\"mouseup(event); return true;\" "
|
||||
" onmousemove=\"mousemove(event); return true;\">"
|
||||
""
|
||||
" <div style=\"width: 200px; height: 20px; padding-left: 3px; background: #4040C0; color: #FFFFFF;\">"
|
||||
" <span>[XQ] FORM Page 1</span> "
|
||||
" </div>"
|
||||
" <div data-name=\"cancel\" style=\"width: 200px; height: 20px; margin-top: 2px; padding-left: 3px ;background: #C0C0FF;\">"
|
||||
" <span>Cancel</span> "
|
||||
" </div>"
|
||||
" <div data-name=\"next\" style=\"width: 200px; height: 20px; margin-top: 2px; padding-left: 3px; background: #C0C0FF;\">"
|
||||
" <span>Next</span> "
|
||||
" </div>"
|
||||
"</div>"
|
||||
""
|
||||
"<div style=\"position: absolute; top: 300px; left: 250px; background: #E0E0E0; border: 1px solid white;\" "
|
||||
" id=\"formpage2\" "
|
||||
" onmousedown=\"mousedown(this, event); return true;\" "
|
||||
" onmouseup=\"mouseup(event); return true;\" "
|
||||
" onmousemove=\"mousemove(event); return true;\">"
|
||||
" <div style=\"width: 200px; height: 20px; padding-left: 3px; background: #4040C0; color: #FFFFFF;\">"
|
||||
" <span>[XQ] FORM Page 2</span> "
|
||||
" </div>"
|
||||
" <div data-name=\"previous\" style=\"width: 200px; height: 20px; margin-top: 2px; padding-left: 3px ;background: #C0C0FF;\">"
|
||||
" <span>Previous</span> "
|
||||
" </div>"
|
||||
" <div data-name=\"next\" style=\"width: 200px; height: 20px; margin-top: 2px; padding-left: 3px; background: #C0C0FF;\">"
|
||||
" <span>Next</span> "
|
||||
" </div>"
|
||||
"</div>"
|
||||
""
|
||||
"<div style=\"position: absolute; top: 400px; left: 200px; background: #E0E0E0; border: 1px solid white;\" "
|
||||
" id=\"formpage3\" "
|
||||
" onmousedown=\"mousedown(this, event); return true;\" "
|
||||
" onmouseup=\"mouseup(event); return true;\" "
|
||||
" onmousemove=\"mousemove(event); return true;\">"
|
||||
" <div style=\"width: 200px; height: 20px; padding-left: 3px; background: #4040C0; color: #FFFFFF;\">"
|
||||
" <span>[XQ] FORM Page 3</span> "
|
||||
" </div>"
|
||||
" <div data-name=\"previous\" style=\"width: 200px; height: 20px; margin-top: 2px; padding-left: 3px ;background: #C0C0FF;\">"
|
||||
" <span>Previous</span> "
|
||||
" </div>"
|
||||
" <div data-name=\"process\" style=\"width: 200px; height: 20px; margin-top: 2px; padding-left: 3px; background: #C0C0FF;\">"
|
||||
" <span>Process Form</span> "
|
||||
" </div>"
|
||||
"</div>"
|
||||
""
|
||||
"<div style=\"position: absolute; top: 500px; left: 200px; background: #E0E0E0; border: 1px solid white;\" "
|
||||
" id=\"processform\" "
|
||||
" onmousedown=\"mousedown(this, event); return true;\" "
|
||||
" onmouseup=\"mouseup(event); return true;\" "
|
||||
" onmousemove=\"mousemove(event); return true;\">"
|
||||
" <div style=\"width: 200px; height: 20px; padding-left: 3px; background: #40C040; color: #FFFFFF;\">"
|
||||
" <span>[PQ] Process Form</span> "
|
||||
" </div>"
|
||||
" <div data-name=\"previous\" style=\"width: 200px; height: 20px; margin-top: 2px; padding-left: 3px ;background: #C0C0FF;\">"
|
||||
" <span>Previous</span> "
|
||||
" </div>"
|
||||
" <div data-name=\"process\" style=\"width: 200px; height: 20px; margin-top: 2px; padding-left: 3px; background: #C0C0FF;\">"
|
||||
" <span>Process Form</span> "
|
||||
" </div>"
|
||||
"</div>"
|
||||
""
|
||||
"<script src=\"/__workflow_js\" />";
|
||||
|
||||
p.httpRequest.response.addHeader(coreutils::IMFHeader("Content-Type", "script/javascript"));
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
|
159
__workflow_js.h
159
__workflow_js.h
@ -7,86 +7,87 @@ namespace http {
|
||||
|
||||
class __workflow_js : public HTTPPage {
|
||||
|
||||
int processCommand(std::string request, core::TCPSession *session, HTTPSession *httpSession, HTTPRequest &httpRequest, std::stringstream &data) {
|
||||
data << "var mouseDownX;" << std::endl;
|
||||
data << "var mouseDownY;" << std::endl;
|
||||
data << "var isMouseDown = false;" << std::endl;
|
||||
data << "var dragObject;" << std::endl;
|
||||
data << "var dragHint = \"move\";" << std::endl;
|
||||
data << "var selected;" << std::endl;
|
||||
data << "listSource();" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << "function listSource() {" << std::endl;
|
||||
data << " var connectors = document.getElementsByTagName(\"path\");" << std::endl;
|
||||
data << " for(var i = 0; connectors[i]; ++i) {" << std::endl;
|
||||
data << " var source = connectors[i].getAttribute(\"data-source\");" << std::endl;
|
||||
data << " var sourceElem = source.split(\":\");" << std::endl;
|
||||
data << " var sourceId = document.getElementById(sourceElem[0]);" << std::endl;
|
||||
data << " var offset = 0;" << std::endl;
|
||||
data << " if(sourceElem.length > 1) {" << std::endl;
|
||||
data << " var options = sourceId.getElementsByTagName(\"div\");" << std::endl;
|
||||
data << " for(var o = 0; options[o]; ++o) {" << std::endl;
|
||||
data << " var option = options[o];" << std::endl;
|
||||
data << " if(sourceElem[1] == options[o].getAttribute(\"data-name\")) {" << std::endl;
|
||||
data << " offset = option.offsetTop + (parseInt(option.style.height) / 2);" << std::endl;
|
||||
data << " }" << std::endl;
|
||||
data << " }" << std::endl;
|
||||
data << " }" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << " var dest = connectors[i].getAttribute(\"data-dest\");" << std::endl;
|
||||
data << " var destId = document.getElementById(dest);" << std::endl;
|
||||
data << " var d = \"M\" + getPos(sourceId, sourceId.offsetWidth, offset) +" << std::endl;
|
||||
data << " \" L\" + getPos(sourceId, sourceId.offsetWidth + 30, offset) + " << std::endl;
|
||||
data << " \" L\" + getPos(destId, destId.offsetWidth / 2, -30) + " << std::endl;
|
||||
data << " \" L\" + getPos(destId, destId.offsetWidth / 2);" << std::endl;
|
||||
data << " connectors[i].setAttribute(\"d\", d);" << std::endl;
|
||||
data << "// console.log(d);" << std::endl;
|
||||
data << " } " << std::endl;
|
||||
data << "}" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << "function getMouseX(e) {" << std::endl;
|
||||
data << " return e.clientX;" << std::endl;
|
||||
data << "}" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << "function getMouseY(e) {" << std::endl;
|
||||
data << " return e.clientY;" << std::endl;
|
||||
data << "}" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << "function getPos(item, offsetX = 0, offsetY = 0) {" << std::endl;
|
||||
data << " var pos = \" \" + (parseInt(item.style.left) + offsetX);" << std::endl;
|
||||
data << " pos += \" \" + (parseInt(item.style.top) + offsetY);" << std::endl;
|
||||
data << " return pos; " << std::endl;
|
||||
data << "}" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << "function mousedown(obj, e) {" << std::endl;
|
||||
data << " var mouseX = getMouseX(e);" << std::endl;
|
||||
data << " var mouseY = getMouseY(e);" << std::endl;
|
||||
data << " mouseDownX = mouseX - obj.offsetLeft;" << std::endl;
|
||||
data << " mouseDownY = mouseY - obj.offsetTop;" << std::endl;
|
||||
data << " dragObject = obj;" << std::endl;
|
||||
data << " selected = obj;" << std::endl;
|
||||
data << " isMouseDown = true;" << std::endl;
|
||||
data << "}" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << "function mouseup(e) {" << std::endl;
|
||||
data << " isMouseDown = false;" << std::endl;
|
||||
data << " dragObject = null;" << std::endl;
|
||||
data << "}" << std::endl;
|
||||
data << "" << std::endl;
|
||||
data << "function mousemove(e) {" << std::endl;
|
||||
data << " var mouseX = getMouseX(e);" << std::endl;
|
||||
data << " var mouseY = getMouseY(e);" << std::endl;
|
||||
data << " if(isMouseDown) {" << std::endl;
|
||||
data << " if(dragHint == \"move\") {" << std::endl;
|
||||
data << " dragObject.style.left = (mouseX - mouseDownX) + \"px\";" << std::endl;
|
||||
data << " dragObject.style.top = (mouseY - mouseDownY) + \"px\"; " << std::endl;
|
||||
data << " listSource();" << std::endl;
|
||||
data << " } " << std::endl;
|
||||
data << " }" << std::endl;
|
||||
data << "}" << std::endl;
|
||||
int page(HTTPParameters &p) override {
|
||||
|
||||
httpRequest.response.addHeader("Content-Type", "script/javascript");
|
||||
return 0;
|
||||
p.data << "var mouseDownX;"
|
||||
"var mouseDownY;"
|
||||
"var isMouseDown = false;"
|
||||
"var dragObject;"
|
||||
"var dragHint = \"move\";"
|
||||
"var selected;"
|
||||
"listSource();"
|
||||
""
|
||||
"function listSource() {"
|
||||
" var connectors = document.getElementsByTagName(\"path\");"
|
||||
" for(var i = 0; connectors[i]; ++i) {"
|
||||
" var source = connectors[i].getAttribute(\"data-source\");"
|
||||
" var sourceElem = source.split(\":\");"
|
||||
" var sourceId = document.getElementById(sourceElem[0]);"
|
||||
" var offset = 0;"
|
||||
" if(sourceElem.length > 1) {"
|
||||
" var options = sourceId.getElementsByTagName(\"div\");"
|
||||
" for(var o = 0; options[o]; ++o) {"
|
||||
" var option = options[o];"
|
||||
" if(sourceElem[1] == options[o].getAttribute(\"data-name\")) {"
|
||||
" offset = option.offsetTop + (parseInt(option.style.height) / 2);"
|
||||
" }"
|
||||
" }"
|
||||
" }"
|
||||
""
|
||||
" var dest = connectors[i].getAttribute(\"data-dest\");"
|
||||
" var destId = document.getElementById(dest);"
|
||||
" var d = \"M\" + getPos(sourceId, sourceId.offsetWidth, offset) +"
|
||||
" \" L\" + getPos(sourceId, sourceId.offsetWidth + 30, offset) + "
|
||||
" \" L\" + getPos(destId, destId.offsetWidth / 2, -30) + "
|
||||
" \" L\" + getPos(destId, destId.offsetWidth / 2);"
|
||||
" connectors[i].setAttribute(\"d\", d);"
|
||||
"// console.log(d);"
|
||||
" } "
|
||||
"}"
|
||||
""
|
||||
"function getMouseX(e) {"
|
||||
" return e.clientX;"
|
||||
"}"
|
||||
""
|
||||
"function getMouseY(e) {"
|
||||
" return e.clientY;"
|
||||
"}"
|
||||
""
|
||||
"function getPos(item, offsetX = 0, offsetY = 0) {"
|
||||
" var pos = \" \" + (parseInt(item.style.left) + offsetX);"
|
||||
" pos += \" \" + (parseInt(item.style.top) + offsetY);"
|
||||
" return pos; "
|
||||
"}"
|
||||
""
|
||||
"function mousedown(obj, e) {"
|
||||
" var mouseX = getMouseX(e);"
|
||||
" var mouseY = getMouseY(e);"
|
||||
" mouseDownX = mouseX - obj.offsetLeft;"
|
||||
" mouseDownY = mouseY - obj.offsetTop;"
|
||||
" dragObject = obj;"
|
||||
" selected = obj;"
|
||||
" isMouseDown = true;"
|
||||
"}"
|
||||
""
|
||||
"function mouseup(e) {"
|
||||
" isMouseDown = false;"
|
||||
" dragObject = null;"
|
||||
"}"
|
||||
""
|
||||
"function mousemove(e) {"
|
||||
" var mouseX = getMouseX(e);"
|
||||
" var mouseY = getMouseY(e);"
|
||||
" if(isMouseDown) {"
|
||||
" if(dragHint == \"move\") {"
|
||||
" dragObject.style.left = (mouseX - mouseDownX) + \"px\";"
|
||||
" dragObject.style.top = (mouseY - mouseDownY) + \"px\"; "
|
||||
" listSource();"
|
||||
" } "
|
||||
" }"
|
||||
"}";
|
||||
|
||||
p.httpRequest.response.addHeader(coreutils::IMFHeader("Content-Type", "script/javascript"));
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
|
22
_image.h
22
_image.h
@ -8,24 +8,16 @@ namespace http {
|
||||
|
||||
class _image : public HTTPPage {
|
||||
|
||||
bool test(coreutils::ZString &request) {
|
||||
if(request.str() == "/image/") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
int page(HTTPParameters &p) override {
|
||||
|
||||
int processCommand(HTTPRequest *httpRequest,
|
||||
core::TCPSession *session,
|
||||
HTTPSession *httpSession,
|
||||
std::stringstream &out) override {
|
||||
|
||||
coreutils::File workspace("/home/barant/jetserver/images/barant_web_logo.png");
|
||||
char format[256];
|
||||
sprintf(format, "/home/barant/jetserver/image/%s", p.httpRequest.uriValues["image_name"].str().c_str());
|
||||
coreutils::File workspace(format);
|
||||
workspace.read();
|
||||
httpRequest->response.addHeader("Content-Type", "image/png");
|
||||
out << workspace.asString();
|
||||
p.httpRequest.response.addHeader(coreutils::IMFHeader("Content-Type", "image/png"));
|
||||
p.data << workspace.asString();
|
||||
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -1,3 +1,3 @@
|
||||
Start testing: Sep 23 16:13 PDT
|
||||
Start testing: Mar 07 08:17 PST
|
||||
----------------------------------------------------------
|
||||
End testing: Sep 23 16:13 PDT
|
||||
End testing: Mar 07 08:17 PST
|
||||
|
6
compile
6
compile
@ -5,7 +5,7 @@ do
|
||||
filename="${file%.*}"
|
||||
list="$list $filename.o"
|
||||
echo -n "Compiling $filename..."
|
||||
g++ -g -c -I../CoreUtils -I../ServerCore $file &
|
||||
g++ -g -c -std=c++17 -I../CoreUtils -I../ServerCore $file &
|
||||
if [ $? = '0' ]
|
||||
then
|
||||
echo "OK"
|
||||
@ -18,7 +18,7 @@ done
|
||||
|
||||
wait
|
||||
echo -n "Building executable HTTPServer..."
|
||||
g++ -g -o HTTPServer $list -L../CoreUtils -lCoreUtils -L../ServerCore -lServerCore -lpthread -luuid -lssl -lcrypto
|
||||
g++ -g -o HTTPServer $list -std=c++17 -L../CoreUtils -lCoreUtils -L../ServerCore -lServerCore -lpthread -luuid -lssl -lcrypto
|
||||
if [ $? = '0' ]
|
||||
then
|
||||
echo "OK"
|
||||
@ -27,4 +27,6 @@ else
|
||||
exit -1
|
||||
fi
|
||||
|
||||
rm *.o
|
||||
|
||||
|
||||
|
@ -8,7 +8,75 @@
|
||||
},
|
||||
{
|
||||
"path": "../ServerCore"
|
||||
},
|
||||
{
|
||||
"path": "../BMAMail"
|
||||
},
|
||||
{
|
||||
"path": "../JetCore"
|
||||
}
|
||||
],
|
||||
"settings": {}
|
||||
"settings": {
|
||||
"files.associations": {
|
||||
"iosfwd": "cpp",
|
||||
"cctype": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cstring": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"array": "cpp",
|
||||
"atomic": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"bitset": "cpp",
|
||||
"chrono": "cpp",
|
||||
"complex": "cpp",
|
||||
"condition_variable": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"deque": "cpp",
|
||||
"list": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"vector": "cpp",
|
||||
"exception": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"functional": "cpp",
|
||||
"iterator": "cpp",
|
||||
"map": "cpp",
|
||||
"memory": "cpp",
|
||||
"memory_resource": "cpp",
|
||||
"numeric": "cpp",
|
||||
"optional": "cpp",
|
||||
"random": "cpp",
|
||||
"ratio": "cpp",
|
||||
"set": "cpp",
|
||||
"string": "cpp",
|
||||
"string_view": "cpp",
|
||||
"system_error": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"utility": "cpp",
|
||||
"fstream": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iomanip": "cpp",
|
||||
"iostream": "cpp",
|
||||
"istream": "cpp",
|
||||
"limits": "cpp",
|
||||
"mutex": "cpp",
|
||||
"new": "cpp",
|
||||
"ostream": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"thread": "cpp",
|
||||
"cfenv": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"bit": "cpp"
|
||||
}
|
||||
}
|
||||
}
|
23
main.cpp
23
main.cpp
@ -1,7 +1,7 @@
|
||||
#include "includes"
|
||||
#include "EPoll.h"
|
||||
#include "ConsoleServer.h"
|
||||
#include "Exception.h"
|
||||
#include "HTTPSessions.h"
|
||||
#include "File.h"
|
||||
#include "Log.h"
|
||||
#include "IPAddress.h"
|
||||
@ -15,30 +15,29 @@ int main(int argc, char **argv) {
|
||||
coreutils::Log(coreutils::LOG_INFO) << "HTTP Server starting. Build " << __DATE__ << " " << __TIME__;
|
||||
|
||||
std::string ipAddress = "0.0.0.0";
|
||||
|
||||
core::EPoll ePoll;
|
||||
|
||||
http::HTTPSessions httpSessions;
|
||||
http::HTTPServer http(ePoll, core::IPAddress(ipAddress, 8080), httpSessions);
|
||||
// http::HTTPSServer http(ePoll, core::IPAddress(ipAddress, 8143));
|
||||
|
||||
core::EPoll ePoll;
|
||||
|
||||
http::HTTPSessions httpSessions;
|
||||
|
||||
http::HTTPServer http(ePoll, core::IPAddress(ipAddress, 8080), httpSessions);
|
||||
core::ConsoleServer console(ePoll, core::IPAddress(ipAddress, 1027));
|
||||
|
||||
|
||||
console.commands.add(ePoll, "threads");
|
||||
console.commands.add(httpSessions, "sessions");
|
||||
console.commands.add(httpSessions, "sessions");
|
||||
console.commands.add(console, "consoles");
|
||||
console.commands.add(console.commands, "help");
|
||||
ePoll.start(2, 1000);
|
||||
|
||||
while(true)
|
||||
sleep(300);
|
||||
|
||||
|
||||
ePoll.stop();
|
||||
|
||||
|
||||
}
|
||||
|
||||
catch(coreutils::Exception exception) {
|
||||
std::cout << exception.text << " Error reason is '" << strerror(exception.errorNumber) << "' in file " << exception.file << " at line " << exception.line << std::endl;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user