diff --git a/src/conf.cpp b/src/conf.cpp
index f223c27d..c53edf2c 100644
--- a/src/conf.cpp
+++ b/src/conf.cpp
@@ -545,6 +545,14 @@ struct ctx_parm config_parms[] = {
"# Method for showing stream on webcontrol.",
0, PARM_TYP_INT, PARM_CAT_14, WEBUI_LEVEL_LIMITED },
{
+ "stream_preview_actions",
+ "# Show the action buttons on the webcontrol for the camera.",
+ 0, PARM_TYP_BOOL, PARM_CAT_14, WEBUI_LEVEL_LIMITED },
+ {
+ "stream_preview_ptz",
+ "# Show the PTZ buttons on the webcontrol for the camera.",
+ 0, PARM_TYP_BOOL, PARM_CAT_14, WEBUI_LEVEL_LIMITED },
+ {
"stream_quality",
"# Quality of the jpeg images produced for stream.",
0, PARM_TYP_INT, PARM_CAT_14, WEBUI_LEVEL_LIMITED },
@@ -2744,6 +2752,32 @@ static void conf_edit_stream_preview_method(struct ctx_cam *cam, std::string &pa
MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_preview_method",_("stream_preview_method"));
}
+static void conf_edit_stream_preview_actions(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact)
+{
+ if (pact == PARM_ACT_DFLT){
+ cam->conf->stream_preview_actions = true;
+ } else if (pact == PARM_ACT_SET){
+ conf_edit_set_bool(cam->conf->stream_preview_actions, parm);
+ } else if (pact == PARM_ACT_GET){
+ conf_edit_get_bool(parm, cam->conf->stream_preview_actions);
+ }
+ return;
+ MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_preview_actions",_("stream_preview_actions"));
+}
+
+static void conf_edit_stream_preview_ptz(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact)
+{
+ if (pact == PARM_ACT_DFLT){
+ cam->conf->stream_preview_ptz = true;
+ } else if (pact == PARM_ACT_SET){
+ conf_edit_set_bool(cam->conf->stream_preview_ptz, parm);
+ } else if (pact == PARM_ACT_GET){
+ conf_edit_get_bool(parm, cam->conf->stream_preview_ptz);
+ }
+ return;
+ MOTION_LOG(DBG, TYPE_ALL, NO_ERRNO,"%s:%s","stream_preview_ptz",_("stream_preview_ptz"));
+}
+
static void conf_edit_stream_quality(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact)
{
int parm_in;
@@ -3344,9 +3378,11 @@ static void conf_edit_cat13(struct ctx_cam *cam, std::string parm_nm
static void conf_edit_cat14(struct ctx_cam *cam, std::string parm_nm
, std::string &parm_val, enum PARM_ACT pact)
{
- if (parm_nm == "stream_preview_scale"){ conf_edit_stream_preview_scale(cam, parm_val, pact);
+ if (parm_nm == "stream_preview_scale"){ conf_edit_stream_preview_scale(cam, parm_val, pact);
} else if (parm_nm == "stream_preview_newline"){ conf_edit_stream_preview_newline(cam, parm_val, pact);
} else if (parm_nm == "stream_preview_method"){ conf_edit_stream_preview_method(cam, parm_val, pact);
+ } else if (parm_nm == "stream_preview_actions"){ conf_edit_stream_preview_actions(cam, parm_val, pact);
+ } else if (parm_nm == "stream_preview_ptz"){ conf_edit_stream_preview_ptz(cam, parm_val, pact);
} else if (parm_nm == "stream_quality"){ conf_edit_stream_quality(cam, parm_val, pact);
} else if (parm_nm == "stream_grey"){ conf_edit_stream_grey(cam, parm_val, pact);
} else if (parm_nm == "stream_motion"){ conf_edit_stream_motion(cam, parm_val, pact);
diff --git a/src/conf.hpp b/src/conf.hpp
index f067897a..ba4cebab 100644
--- a/src/conf.hpp
+++ b/src/conf.hpp
@@ -156,6 +156,8 @@
int stream_preview_scale;
int stream_preview_newline;
int stream_preview_method;
+ int stream_preview_actions;
+ int stream_preview_ptz;
int stream_quality;
int stream_grey;
int stream_motion;
diff --git a/src/motionplus.cpp b/src/motionplus.cpp
index 908e83b6..548bf86c 100644
--- a/src/motionplus.cpp
+++ b/src/motionplus.cpp
@@ -588,6 +588,7 @@ static void motion_init(struct ctx_motapp *motapp)
pthread_mutex_init(&motapp->global_lock, NULL);
pthread_mutex_init(&motapp->mutex_parms, NULL);
pthread_mutex_init(&motapp->mutex_camlst, NULL);
+ pthread_mutex_init(&motapp->mutex_post, NULL);
motapp->threads_running = 0;
motapp->finish_all = false;
@@ -645,6 +646,7 @@ static void motion_cam_add(struct ctx_motapp *motapp)
indx_cam--;
motapp->cam_list[indx_cam]->camera_id = indx;
+ motapp->cam_list[indx_cam]->conf->camera_id = indx;
motapp->cam_list[indx_cam]->dbse = (struct ctx_dbse *)mymalloc(sizeof(struct ctx_dbse));
motapp->cam_list[indx_cam]->conf->webcontrol_port = 0;
@@ -791,6 +793,8 @@ int main (int argc, char **argv)
pthread_key_delete(tls_key_threadnr);
pthread_mutex_destroy(&motapp->global_lock);
pthread_mutex_destroy(&motapp->mutex_parms);
+ pthread_mutex_destroy(&motapp->mutex_camlst);
+ pthread_mutex_destroy(&motapp->mutex_post);
delete motapp;
diff --git a/src/motionplus.hpp b/src/motionplus.hpp
index b40efc68..21be87e5 100644
--- a/src/motionplus.hpp
+++ b/src/motionplus.hpp
@@ -411,7 +411,9 @@ struct ctx_motapp {
int parms_changed; /*bool indicating if the parms have changed */
pthread_mutex_t mutex_parms; /* mutex used to lock when changing parms */
- pthread_mutex_t mutex_camlst; /* Lock the list of cams while adding/removing */
+ pthread_mutex_t mutex_camlst; /* Lock the list of cams while adding/removing */
+ pthread_mutex_t mutex_post; /* mutex to allow for processing of post actions*/
+
};
diff --git a/src/webu.cpp b/src/webu.cpp
index 67a673c0..042a83f2 100644
--- a/src/webu.cpp
+++ b/src/webu.cpp
@@ -559,7 +559,9 @@ static mhdrslt webu_answer_post(struct webui_ctx *webui)
MOTION_LOG(DBG, TYPE_STREAM, NO_ERRNO ,"processing post");
- webu_post_main(webui);
+ pthread_mutex_lock(&webui->motapp->mutex_post);
+ webu_post_main(webui);
+ pthread_mutex_unlock(&webui->motapp->mutex_post);
if (webui->motapp->cam_list[0]->conf->webcontrol_interface == 3) {
webu_html_user(webui);
@@ -567,7 +569,6 @@ static mhdrslt webu_answer_post(struct webui_ctx *webui)
webu_html_page(webui);
}
-
retcd = webu_mhd_send(webui);
if (retcd == MHD_NO) {
MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,"send post page failed");
@@ -700,18 +701,24 @@ static mhdrslt webu_answer_get(struct webui_ctx *webui)
} else if ((webui->uri_camid == "config.json") ||
(webui->uri_cmd1 == "config.json")) {
- webu_json_config(webui);
+
+ pthread_mutex_lock(&webui->motapp->mutex_post);
+ webu_json_config(webui);
+ pthread_mutex_unlock(&webui->motapp->mutex_post);
+
retcd = webu_mhd_send(webui);
if (retcd == MHD_NO) {
MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO ,_("send page failed."));
}
} else {
- if (webui->motapp->cam_list[0]->conf->webcontrol_interface == 3) {
- webu_html_user(webui);
- } else {
- webu_html_page(webui);
- }
+ pthread_mutex_lock(&webui->motapp->mutex_post);
+ if (webui->motapp->cam_list[0]->conf->webcontrol_interface == 3) {
+ webu_html_user(webui);
+ } else {
+ webu_html_page(webui);
+ }
+ pthread_mutex_unlock(&webui->motapp->mutex_post);
retcd = webu_mhd_send(webui);
if (retcd == MHD_NO) {
diff --git a/src/webu_html.cpp b/src/webu_html.cpp
index 6ba6d817..10214dc8 100644
--- a/src/webu_html.cpp
+++ b/src/webu_html.cpp
@@ -110,6 +110,11 @@ static void webu_html_style_config(struct webui_ctx *webui)
" width: 15.5rem;\n"
" height: 2.5rem;\n"
" }\n"
+ " .cls_button {\n"
+ " width: 10rem;\n"
+ " height: 2rem;\n"
+ " padding: 0rem;\n"
+ " }\n"
" .cls_drop {\n"
" padding: 0rem;\n"
" text-align: right;\n"
@@ -285,19 +290,29 @@ static void webu_html_script_dropchange_cam(struct webui_ctx *webui)
webui->resp_page +=
" /*Cascade camera change in one dropdown to all the others*/\n"
" function dropchange_cam(camobj) {\n"
+ " var indx;\n\n"
+
" assign_vals(camobj.value);\n\n"
+
" var sect = document.getElementsByName('camdrop');\n"
- " for (var indx = 0; indx < sect.length; indx++) {\n"
+ " for (indx = 0; indx < sect.length; indx++) {\n"
" sect.item(indx).selectedIndex =camobj.selectedIndex;\n"
- " }\n"
+ " }\n\n"
+
+ " for (indx = 0; indx <= pData['cameras']['count']; indx++) {\n"
+ " if (pData['cameras'][indx]['id'] == camobj.value) {\n"
+ " gIndexCam = indx;\n"
+ " }\n"
+ " }\n\n"
+
" }\n\n";
}
-/* Create the javascript function submit_config */
-static void webu_html_script_submit_config(struct webui_ctx *webui)
+/* Create the javascript function send_config */
+static void webu_html_script_send_config(struct webui_ctx *webui)
{
webui->resp_page +=
- " function submit_config(category) {\n"
+ " function send_config(category) {\n"
" var formData = new FormData();\n"
" var camid = document.getElementsByName('camdrop')[0].value;\n"
" var pCfg = pData['configuration']['cam'+camid];\n\n"
@@ -320,6 +335,66 @@ static void webu_html_script_submit_config(struct webui_ctx *webui)
" }\n\n";
}
+/* Create the send_action javascript function */
+static void webu_html_script_send_action(struct webui_ctx *webui)
+{
+ webui->resp_page +=
+ " function send_action(actval) {\n\n"
+ " var formData = new FormData();\n"
+ " var camid = pData['cameras'][gIndexCam]['id'];\n\n"
+ " formData.append('command', actval);\n"
+ " formData.append('camid', camid);\n\n"
+ " var request = new XMLHttpRequest();\n"
+ " request.open('POST', '" + webui->hostfull + "');\n"
+ " request.send(formData);\n\n"
+ " return;\n"
+ " }\n\n";
+}
+
+/* Create the send_reload javascript function */
+static void webu_html_script_send_reload(struct webui_ctx *webui)
+{
+ webui->resp_page +=
+ " function send_reload(actval) {\n\n"
+ " var formData = new FormData();\n"
+ " var request = new XMLHttpRequest();\n"
+ " var xmlhttp = new XMLHttpRequest();\n"
+ " var camid = pData['cameras'][gIndexCam]['id'];\n"
+ " var ans;\n\n"
+
+ " if (actval == 'camera_delete') {\n"
+ " ans = confirm('Delete camera ' + camid);\n"
+ " if (ans == false) {\n"
+ " return;\n"
+ " }\n"
+ " }\n\n"
+
+ " xmlhttp.onreadystatechange = function() {\n"
+ " if (this.readyState == 4 && this.status == 200) {\n"
+ " pData = JSON.parse(this.responseText);\n"
+ " gIndexCam = 0;\n"
+ " assign_config_nav();\n"
+ " assign_vals(0);\n"
+ " assign_cams();\n"
+ " }\n"
+ " };\n"
+
+ " request.onreadystatechange = function() {\n"
+ " if (this.readyState == 4 && this.status == 200) {\n"
+ " xmlhttp.open('GET', '" + webui->hostfull + "/config.json');\n"
+ " xmlhttp.send();\n\n"
+ " }\n"
+ " };\n"
+
+ " formData.append('command', actval);\n"
+ " formData.append('camid', camid);\n\n"
+
+ " request.open('POST', '" + webui->hostfull + "');\n"
+ " request.send(formData);\n\n"
+
+ " }\n\n";
+}
+
/* Create the javascript function config_hideall */
static void webu_html_script_config_hideall(struct webui_ctx *webui)
{
@@ -396,6 +471,7 @@ static void webu_html_script_assign_vals(struct webui_ctx *webui)
webui->resp_page +=
" function assign_vals(camid) {\n"
" var pCfg = pData[\"configuration\"][\"cam\"+camid];\n\n"
+
" for (jkey in pCfg) {\n"
" if (document.getElementsByName(jkey)[0] != null) {\n"
" if (pCfg[jkey].enabled) {\n"
@@ -416,68 +492,179 @@ static void webu_html_script_assign_vals(struct webui_ctx *webui)
" }\n\n";
}
-/* Create the javascript function assign_config */
-static void webu_html_script_assign_config(struct webui_ctx *webui)
+
+/* Create the javascript function assign_config_nav */
+static void webu_html_script_assign_config_nav(struct webui_ctx *webui)
{
webui->resp_page +=
- " function assign_config() {\n"
+ " function assign_config_nav() {\n"
" var pCfg = pData['configuration']['cam0'];\n"
" var pCat = pData['categories'];\n"
- " var html_cfg = \"\";\n"
- " var html_nav = \"\\n\";\n"
- " var indx_lst = 0;\n\n"
+ " var html_nav = \"\\n\";\n\n"
+
+ " html_nav += \"\";\n"
+ " html_nav += \"Setup\\n\";\n\n"
+
" for (jcat in pCat) {\n"
" html_nav += \"\";\n"
" html_nav += pCat[jcat][\"display\"]+\"\\n\";\n\n"
- " html_cfg += \"
\\n\";\n"
- " html_cfg += \"
\";\n"
- " html_cfg += pCat[jcat][\"display\"];\n"
- " html_cfg += \" Parameters
\\n\";\n"
- " html_cfg += \"
\\n\";\n"
- " }\n"
- " document.getElementById(\"div_config\").innerHTML = html_cfg;\n"
+ " }\n\n"
+
" document.getElementById(\"divnav_config\").innerHTML = html_nav;\n\n"
+
+ " }\n\n";
+}
+
+/* Create the javascript function assign_config_item */
+static void webu_html_script_assign_config_item(struct webui_ctx *webui)
+{
+ webui->resp_page +=
+ " function assign_config_item(jkey) {\n"
+ " var pCfg = pData['configuration']['cam0'];\n"
+ " var html_cfg = \"\";\n"
+ " var indx_lst = 0;\n\n"
+
+ " html_cfg += \" | \\n\";\n\n"
+ " if (pCfg[jkey][\"type\"] == \"string\") {\n"
+ " html_cfg += \" | \";\n\n"
+ " } else if (pCfg[jkey][\"type\"] == \"bool\") {\n"
+ " html_cfg += \" | \";\n\n"
+ " } else if (pCfg[jkey][\"type\"] == \"int\") {\n"
+ " html_cfg += \" | \";\n\n"
+ " } else if (pCfg[jkey][\"type\"] == \"list\") {\n"
+ " html_cfg += \" | \";\n"
+ " }\n"
+ " html_cfg += \"
\\n\";\n\n"
+
+ " return html_cfg;\n\n"
+
+ " }\n\n";
+}
+
+/* Create the javascript function assign_config_cat */
+static void webu_html_script_assign_config_setup(struct webui_ctx *webui)
+{
+ webui->resp_page +=
+ " function assign_config_setup() {\n"
+ " var html_cfg = \"\";\n\n"
+
+ " html_cfg += \"\\n\";\n"
+ " html_cfg += \"
\";\n"
+ " html_cfg += \"System Setup
\\n\";\n"
+ " html_cfg += \"
| \\n\";\n"
+ " html_cfg += \"\";\n"
+ " html_cfg += \" |
\\n\";\n\n"
+
+ " html_cfg += \" |
\";\n"
+
+ " html_cfg += \" |
\";\n"
+ " html_cfg += \"|   | |
\\n\";\n"
+
+ " html_cfg += \" |
\";\n"
+ " html_cfg += \"|   | |
\\n\";\n"
+
+ " html_cfg += \" |
\";\n"
+ " html_cfg += \"|   | |
\\n\";\n"
+
+ " html_cfg += \" |
\";\n"
+ " html_cfg += \"|   | |
\\n\";\n"
+
+ " html_cfg += \" |
\";\n"
+ " html_cfg += \"|   | |
\\n\";\n"
+
+ " html_cfg += \"
\\n\";\n\n"
+
+ " return html_cfg;\n\n"
+
+ " }\n";
+}
+
+/* Create the javascript function assign_config_cat */
+static void webu_html_script_assign_config_cat(struct webui_ctx *webui)
+{
+ webui->resp_page +=
+ " function assign_config_cat(jcat) {\n"
+ " var pCfg = pData['configuration']['cam0'];\n"
+ " var pCat = pData['categories'];\n"
+ " var html_cfg = \"\";\n\n"
+
+ " html_cfg += assign_config_setup();\n\n"
+
+ " html_cfg += \"\\n\";\n"
+ " html_cfg += \"
\";\n"
+ " html_cfg += pCat[jcat][\"display\"];\n"
+ " html_cfg += \" Parameters
\\n\";\n"
+ " html_cfg += \"
| \\n\";\n"
+ " html_cfg += \"\";\n"
+ " html_cfg += \" |
\\n\";\n\n"
+ " for (jkey in pCfg) {\n"
+ " if (pCfg[jkey][\"category\"] == jcat) {\n"
+ " html_cfg += assign_config_item(jkey); \n"
+ " }\n"
+ " }\n"
+ " html_cfg += \" | \\n\";\n"
+ " html_cfg += \" |
\\n\";\n"
+ " html_cfg += \"
\\n\";\n\n"
+
+ " return html_cfg;\n\n"
+
+ " }\n";
+}
+
+/* Create the javascript function assign_config */
+static void webu_html_script_assign_config(struct webui_ctx *webui)
+{
+
+ webui->resp_page +=
+ " function assign_config() {\n"
+ " var pCat = pData['categories'];\n"
+ " var html_cfg = \"\";\n\n"
+
+ " assign_config_nav();\n\n"
+
+ " for (jcat in pCat) {\n"
+ " html_cfg += assign_config_cat(jcat);\n"
+ " }\n\n"
+
+ " document.getElementById(\"div_config\").innerHTML = html_cfg;\n\n"
+
" }\n\n";
}
@@ -490,13 +677,14 @@ static void webu_html_script_initform(struct webui_ctx *webui)
" xmlhttp.onreadystatechange = function() {\n"
" if (this.readyState == 4 && this.status == 200) {\n"
" pData = JSON.parse(this.responseText);\n"
+ " gIndexCam = 0;\n\n"
" assign_config();\n"
" assign_version();\n"
" assign_vals(0);\n"
" assign_cams();\n"
" }\n"
" };\n"
- " xmlhttp.open('GET', '" + webui->hostfull + "/config.json', true);\n"
+ " xmlhttp.open('GET', '" + webui->hostfull + "/config.json');\n"
" xmlhttp.send();\n"
" }\n\n";
}
@@ -529,21 +717,119 @@ static void webu_html_script_display_config(struct webui_ctx *webui)
" }\n\n";
}
-/* Create the action_click javascript function */
-static void webu_html_script_action_click(struct webui_ctx *webui)
+/* Create the camera_buttons_action javascript function */
+static void webu_html_script_camera_buttons_action(struct webui_ctx *webui)
{
+
webui->resp_page +=
- " function action_click(actval) {\n\n"
- " config_hideall();\n\n"
- " var formData = new FormData();\n"
- " var camid = pData['cameras'][gIndexCam]['id'];\n\n"
- " formData.append('command', actval);\n"
- " formData.append('camid', camid);\n\n"
- " var request = new XMLHttpRequest();\n"
- " request.open('POST', '" + webui->hostfull + "');\n"
- " request.send(formData);\n\n"
- " return;\n"
+ " function camera_buttons_action() {\n\n"
+ " var html_preview = \"\";\n"
+
+ " html_preview += \"|
\\n\";\n"
+
+ " html_preview += \" | \\n\";\n"
+
+ " html_preview += \" | \\n\";\n"
+
+ " html_preview += \" | \\n\";\n"
+
+ " html_preview += \"
|
\\n\";\n"
+
+ " html_preview += \" | \\n\";\n"
+
+ " html_preview += \" | \\n\";\n"
+
+ " html_preview += \" | \\n\";\n"
+
+ " html_preview += \"
|
\\n\";\n"
+ " html_preview += \"| | \\n\";\n"
+
+ " html_preview += \" | \\n\";\n"
+
+ " html_preview += \"
|
\\n\";\n"
+
+ " html_preview += \" | \\n\";\n"
+
+ " html_preview += \" | \\n\";\n"
+
+ " html_preview += \" | \\n\";\n"
+
+ " html_preview += \"
\\n\";\n\n"
+
+ " return html_preview;\n\n"
" }\n\n";
+
+}
+
+/* Create the camera_buttons_action javascript function */
+static void webu_html_script_camera_buttons_ptz(struct webui_ctx *webui)
+{
+
+ webui->resp_page +=
+ " function camera_buttons_ptz() {\n\n"
+ " var html_preview = \"\";\n"
+
+ " html_preview += \"|    |    |
\\n\";\n"
+
+ " html_preview += \" | |
\\n\";\n"
+
+ " html_preview += \" | | \\n\";\n"
+
+ " html_preview += \" |    |
\\n\";\n"
+
+ " html_preview += \" | |
\\n\";\n"
+
+ " html_preview += \"|    |    |
\\n\";\n"
+
+ " html_preview += \" | |
\\n\";\n"
+
+ " html_preview += \" | |
\\n\";\n"
+
+ " html_preview += \"|    |    |
\\n\";\n"
+
+ " return html_preview;\n\n"
+
+ " }\n\n";
+
}
/* Create the camera_click javascript function */
@@ -555,99 +841,22 @@ static void webu_html_script_camera_click(struct webui_ctx *webui)
" var camid;\n\n"
" config_hideall();\n\n"
" gIndexCam = index_cam;\n\n"
- " html_preview += \"\";\n"
- " html_preview += \"|
\\n\";\n"
-
- " html_preview += \" | \\n\";\n"
-
- " html_preview += \" | \\n\";\n"
-
- " html_preview += \" | \\n\";\n"
-
- " html_preview += \"
|
\\n\";\n"
-
- " html_preview += \" | \\n\";\n"
-
- " html_preview += \" | \\n\";\n"
-
- " html_preview += \" | \\n\";\n"
-
- " html_preview += \"
|
\\n\";\n"
- " html_preview += \"| | \\n\";\n"
-
- " html_preview += \" | \\n\";\n"
-
- " html_preview += \"
|
\\n\";\n"
-
- " html_preview += \" | \\n\";\n"
-
- " html_preview += \" | \\n\";\n"
-
- " html_preview += \" | \\n\";\n"
-
- " html_preview += \"
\\n\";\n"
-
" if (gIndexCam > 0) {\n"
- " camid = pData['cameras'][index_cam].id;\n"
- " html_preview += \"|    |    |
\\n\";\n"
+ " camid = pData['cameras'][index_cam].id;\n\n"
- " html_preview += \" | |
\\n\";\n"
+ " if ((pData['configuration']['cam'+camid].stream_preview_actions.value == true) || \n"
+ " (pData['configuration']['cam'+camid].stream_preview_ptz.value == true)) {\n"
+ " html_preview += \"\";\n"
+ " if (pData['configuration']['cam'+camid].stream_preview_actions.value == true) {\n"
+ " html_preview += camera_buttons_action();\n"
+ " }\n"
+ " if (pData['configuration']['cam'+camid].stream_preview_ptz.value == true) {\n"
+ " html_preview += camera_buttons_ptz();\n"
+ " }\n"
+ " html_preview += \"
\";\n"
+ " }\n\n"
- " html_preview += \" | | \\n\";\n"
-
- " html_preview += \" |    |
\\n\";\n"
-
- " html_preview += \" | |
\\n\";\n"
-
- " html_preview += \"|    |    |
\\n\";\n"
-
- " html_preview += \" | |
\\n\";\n"
-
- " html_preview += \" | |
\\n\";\n"
-
- " html_preview += \"|    |    |
\\n\";\n"
-
- " html_preview += \"
\";\n"
" if (pData['configuration']['cam'+camid].stream_preview_method.value == 1) {\n"
" html_preview += \"
\";\n"
@@ -751,22 +961,6 @@ static void webu_html_script_timer_pic(struct webui_ctx *webui)
}
-/* Create the pictimer_function javascript function */
-static void webu_html_script_ptz(struct webui_ctx *webui)
-{
- webui->resp_page +=
- " function action_ptz(actval) {\n\n"
- " var formData = new FormData();\n"
- " var camid = pData['cameras'][gIndexCam]['id'];\n\n"
- " formData.append('command', actval);\n"
- " formData.append('camid', camid);\n\n"
- " var request = new XMLHttpRequest();\n"
- " request.open('POST', '" + webui->hostfull + "');\n"
- " request.send(formData);\n\n"
- " return;\n"
- " }\n\n";
-}
-
/* Call all the functions to create the java scripts of page*/
static void webu_html_script(struct webui_ctx *webui)
{
@@ -774,22 +968,31 @@ static void webu_html_script(struct webui_ctx *webui)
" var pData;\n"
" var gIndexCam;\n\n";
- webu_html_script_submit_config(webui);
+ webu_html_script_send_config(webui);
+ webu_html_script_send_action(webui);
+ webu_html_script_send_reload(webui);
+
webu_html_script_dropchange_cam(webui);
webu_html_script_config_hideall(webui);
webu_html_script_config_click(webui);
+
webu_html_script_assign_version(webui);
webu_html_script_assign_cams(webui);
webu_html_script_assign_vals(webui);
+ webu_html_script_assign_config_nav(webui);
+ webu_html_script_assign_config_item(webui);
+ webu_html_script_assign_config_setup(webui);
+ webu_html_script_assign_config_cat(webui);
webu_html_script_assign_config(webui);
+
webu_html_script_initform(webui);
webu_html_script_display_cameras(webui);
webu_html_script_display_config(webui);
- webu_html_script_action_click(webui);
+ webu_html_script_camera_buttons_action(webui);
+ webu_html_script_camera_buttons_ptz(webui);
webu_html_script_camera_click(webui);
webu_html_script_timer_function(webui);
webu_html_script_timer_pic(webui);
- webu_html_script_ptz(webui);
webui->resp_page += " \n\n";
diff --git a/src/webu_json.cpp b/src/webu_json.cpp
index 56d9806c..3127c8b1 100644
--- a/src/webu_json.cpp
+++ b/src/webu_json.cpp
@@ -158,7 +158,7 @@ static void webu_json_config_cam_parms(struct webui_ctx *webui)
webui->resp_page += ",";
}
webui->resp_page += "\"cam" +
- std::to_string(webui->motapp->cam_list[indx_cam]->conf->camera_id) + "\": ";
+ std::to_string(webui->motapp->cam_list[indx_cam]->camera_id) + "\": ";
webu_json_config_parms(webui, indx_cam);
@@ -190,21 +190,21 @@ static void webu_json_config_cam_list(struct webui_ctx *webui)
webui->resp_page += "{\"name\": \"default\" ";
} else if (webui->motapp->cam_list[indx_cam]->conf->camera_name == "") {
webui->resp_page += "{\"name\": \"camera " +
- std::to_string(webui->motapp->cam_list[indx_cam]->conf->camera_id) + "\"";
+ std::to_string(webui->motapp->cam_list[indx_cam]->camera_id) + "\"";
} else {
webui->resp_page += "{\"name\": \"" +
webui->motapp->cam_list[indx_cam]->conf->camera_name + "\"";
}
webui->resp_page += ",\"id\": " +
- std::to_string(webui->motapp->cam_list[indx_cam]->conf->camera_id);
+ std::to_string(webui->motapp->cam_list[indx_cam]->camera_id);
if (indx_cam == 0) {
webui->resp_page += "}";
} else {
webui->resp_page +=
",\"url\": \"" + webui->hostfull +
- "/" + std::to_string(webui->motapp->cam_list[indx_cam]->conf->camera_id) +
+ "/" + std::to_string(webui->motapp->cam_list[indx_cam]->camera_id) +
"/\"} ";
}
@@ -234,7 +234,7 @@ static void webu_json_config_categories(struct webui_ctx *webui)
} else if (indx_cat == PARM_CAT_01) {
webui->resp_page += "{\"name\":\"camera\",\"display\":\"Camera\"}";
} else if (indx_cat == PARM_CAT_02) {
- webui->resp_page += "{\"name\":\"source\",\"display\":\"Camera Source\"}";
+ webui->resp_page += "{\"name\":\"source\",\"display\":\"Source\"}";
} else if (indx_cat == PARM_CAT_03) {
webui->resp_page += "{\"name\":\"image\",\"display\":\"Image\"}";
} else if (indx_cat == PARM_CAT_04) {
diff --git a/src/webu_post.cpp b/src/webu_post.cpp
index 5b4a4630..c82b0563 100644
--- a/src/webu_post.cpp
+++ b/src/webu_post.cpp
@@ -41,7 +41,7 @@ static void webu_post_cam_add(struct webui_ctx *webui)
}
if (indx == maxcnt) {
- webui->motapp->cam_add = true;
+ webui->motapp->cam_add = false;
MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "Error adding camera. Timed out");
return;
}
@@ -61,6 +61,7 @@ static void webu_post_cam_delete(struct webui_ctx *webui)
MOTION_LOG(INF, TYPE_ALL, NO_ERRNO, "Deleting camera.");
}
+
maxcnt = 100;
MOTION_LOG(NTC, TYPE_STREAM, NO_ERRNO,
@@ -394,6 +395,7 @@ void webu_post_main(struct webui_ctx *webui)
return;
}
+
if (webui->post_cmd == "eventend") {
webu_post_action_eventend(webui);
@@ -415,13 +417,13 @@ void webu_post_main(struct webui_ctx *webui)
} else if (webui->post_cmd == "stop") {
webu_post_action_stop(webui);
- } else if (webui->post_cmd == "write") {
+ } else if (webui->post_cmd == "config_write") {
conf_parms_write(webui->motapp);
- } else if (webui->post_cmd == "add") {
+ } else if (webui->post_cmd == "camera_add") {
webu_post_cam_add(webui);
- } else if (webui->post_cmd == "delete") {
+ } else if (webui->post_cmd == "camera_delete") {
webu_post_cam_delete(webui);
} else if (webui->post_cmd == "config") {
@@ -440,7 +442,6 @@ void webu_post_main(struct webui_ctx *webui)
MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO
, _("Invalid action requested: command: >%s< threadnbr : >%d< ")
, webui->post_cmd.c_str(), webui->threadnbr);
- return;
}
}