mirror of
https://github.com/owntracks/recorder.git
synced 2026-02-13 20:49:51 +00:00
add server label for map (ot-recorder --label)
This commit is contained in:
@@ -17,6 +17,12 @@
|
||||
#map-canvas { height: 100% }
|
||||
#wrapper { position: relative; }
|
||||
#mapover { position: absolute; top: 10px; left: 120px; z-index: 99; background: red; }
|
||||
#maplabel { position: absolute; top: 10px; left: 180px; z-index: 99;
|
||||
background: white;
|
||||
font-size: 1.2em;
|
||||
padding: 4px;
|
||||
border: 2px solid gray;
|
||||
}
|
||||
|
||||
</style>
|
||||
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&signed_in=true"></script>
|
||||
@@ -28,6 +34,7 @@
|
||||
<div id="wrapper">
|
||||
<div id="map-canvas" style='width: 100%; height: 600px;'/></div>
|
||||
<div id="mapover"></div>
|
||||
<div id="maplabel"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -40,6 +40,10 @@ function ws_connect() {
|
||||
try {
|
||||
var loc = JSON.parse(ev.data);
|
||||
|
||||
if (loc['_label']) {
|
||||
document.getElementById('maplabel').textContent = loc['_label'];
|
||||
}
|
||||
|
||||
if (loc['_type'] == 'location') {
|
||||
map_marker(loc);
|
||||
}
|
||||
|
||||
10
http.c
10
http.c
@@ -75,7 +75,7 @@ static char *field(struct mg_connection *conn, char *fieldname)
|
||||
void http_ws_push_json(struct mg_server *server, JsonNode *obj)
|
||||
{
|
||||
struct mg_connection *c;
|
||||
JsonNode *j;
|
||||
JsonNode *j, *tmpo;
|
||||
int len;
|
||||
char *js, *u = NULL, *d = NULL;
|
||||
|
||||
@@ -88,6 +88,7 @@ void http_ws_push_json(struct mg_server *server, JsonNode *obj)
|
||||
|
||||
for (c = mg_next(server, NULL); c != NULL; c = mg_next(server, c)) {
|
||||
if (c->is_websocket) {
|
||||
struct udata *ud = (struct udata *)c->server_param;
|
||||
#if 0
|
||||
{
|
||||
int n;
|
||||
@@ -131,11 +132,16 @@ void http_ws_push_json(struct mg_server *server, JsonNode *obj)
|
||||
}
|
||||
|
||||
|
||||
if ((js = json_stringify(obj, NULL)) != NULL) {
|
||||
tmpo = json_mkobject();
|
||||
json_copy_to_object(tmpo, obj, TRUE);
|
||||
json_append_member(tmpo, "_label", json_mkstring(ud->label));
|
||||
|
||||
if ((js = json_stringify(tmpo, NULL)) != NULL) {
|
||||
len = strlen(js);
|
||||
mg_websocket_write(c, 1, js, len);
|
||||
free(js);
|
||||
}
|
||||
json_delete(tmpo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -742,6 +742,7 @@ void usage(char *prog)
|
||||
printf(" --logfacility syslog facility (local0)\n");
|
||||
printf(" --quiet disable printing of messages to stdout\n");
|
||||
printf(" --initialize initialize storage\n");
|
||||
printf(" --label <label> server label (dflt: Recorder)\n");
|
||||
#ifdef WITH_HTTP
|
||||
printf(" --http-host <host> HTTP addr to bind to (localhost)\n");
|
||||
printf(" --http-port <port> -A HTTP port (8083); 0 to disable HTTP\n");
|
||||
@@ -807,6 +808,7 @@ int main(int argc, char **argv)
|
||||
# ifdef WITH_LMDB
|
||||
udata.luadb = NULL;
|
||||
# endif
|
||||
udata.label = strdup("Recorder");
|
||||
#endif
|
||||
|
||||
if ((p = getenv("OTR_HOST")) != NULL) {
|
||||
@@ -845,6 +847,7 @@ int main(int argc, char **argv)
|
||||
{ "hosted", no_argument, 0, 6},
|
||||
{ "quiet", no_argument, 0, 8},
|
||||
{ "initialize", no_argument, 0, 9},
|
||||
{ "label", required_argument, 0, 10},
|
||||
#ifdef WITH_LUA
|
||||
{ "lua-script", required_argument, 0, 7},
|
||||
#endif
|
||||
@@ -862,6 +865,10 @@ int main(int argc, char **argv)
|
||||
break;
|
||||
|
||||
switch (ch) {
|
||||
case 10:
|
||||
free(udata.label);
|
||||
udata.label = strdup(optarg);
|
||||
break;
|
||||
case 9:
|
||||
initialize = TRUE;
|
||||
break;
|
||||
@@ -1211,6 +1218,8 @@ int main(int argc, char **argv)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
free(ud->label);
|
||||
|
||||
#ifdef WITH_HTTP
|
||||
mg_destroy_server(&udata.mgserver);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user