summaryrefslogtreecommitdiff
path: root/server/src/admin_connection.cc
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/admin_connection.cc')
-rw-r--r--server/src/admin_connection.cc36
1 files changed, 28 insertions, 8 deletions
diff --git a/server/src/admin_connection.cc b/server/src/admin_connection.cc
index e8c5b02..e470946 100644
--- a/server/src/admin_connection.cc
+++ b/server/src/admin_connection.cc
@@ -28,6 +28,7 @@
#include "admin_connection.h"
#include "admin_rc.h"
+#include "admin_export.h"
#include "debug.h"
@@ -55,7 +56,10 @@ static std::string admin_listactivesessions(Environment &env)
std::vector<std::string> act = env.sessions.activeSessions();
std::vector<std::string>::iterator i = act.begin();
while(i != act.end()) {
- str += "Session " + *i + "\n";
+ Session *s = env.sessions.session(*i);
+ SessionAutolock lock(*s);
+ str += "Session " + *i + ": "+s->templ+" on "+s->patientid+" "+
+ std::string(s->active()?"[active]":"[idle]")+"\n";
i++;
}
@@ -80,6 +84,8 @@ AdminConnection::~AdminConnection() {}
bool AdminConnection::handle(const char *data, size_t size)
{
+ status = 200; // OK
+
if(data == NULL && size == 0) {
DEBUG(admin, "URI: %s\n", uri.c_str());
@@ -89,6 +95,7 @@ bool AdminConnection::handle(const char *data, size_t size)
"<strong>/sessionunlock?id=<em>[ID]</em></strong> unlock session with [ID] as its session id.\n"
"<strong>/listactivesessions</strong> lists all active sessions on the server.\n"
"<strong>/flushsessions</strong> flushes all active sessions to disc.\n"
+ "<strong>/export?template=<em>[TEMPLATE]</em></strong> export template with name [TEMPLATE] to a\n csf file (comma seperated file, that can be opened in OOCalc or Excel).\n"
+ admin_rc("footer");
return true;
}
@@ -106,17 +113,31 @@ bool AdminConnection::handle(const char *data, size_t size)
}
if(uri == "/flushsessions") {
- reply = admin_header(uri) + admin_flush(env)
- + admin_rc("footer");
+ reply = admin_header(uri) + admin_flush(env) + admin_rc("footer");
+ return true;
+ }
+
+ if(uri == "/export" && args.find("template") != args.end()) {
+ bool ok;
+ std::string res = admin_export(env, args["template"], &ok);
+ if(!ok) reply = admin_header(uri) + res + admin_rc("footer");
+ else {
+ reply = res;
+ hdrs["Content-Type"] = "text/csv; charset=UTF-8";
+ hdrs["Content-Disposition"] = "attachment; filename=\""+args["template"]+".csv\"";
+ }
return true;
}
if(uri == "/favicon.ico") {
+ hdrs["Content-Type"] = "image/ico";
reply = admin_rc("favicon");
return true;
}
- reply = "'" + uri + "' not recognised as a valid command.";
+ reply = admin_header(uri) +
+ "'" + uri + "' not recognised as a valid command."
+ + admin_rc("footer");
return true;
}
@@ -125,11 +146,10 @@ bool AdminConnection::handle(const char *data, size_t size)
void AdminConnection::getReply(Httpd::Reply &r)
{
- headers_t hdrs;
- if(uri == "/favicon.ico") hdrs["Content-Type"] = "image/ico";
- else hdrs["Content-Type"] = "text/html; charset=UTF-8";
+ if(hdrs.find("Content-Type") == hdrs.end())
+ hdrs["Content-Type"] = "text/html; charset=UTF-8";
r.data = reply;
r.headers = hdrs;
- r.status = 200; // http 'OK'
+ r.status = status; // http 'OK'
}