[icinga-checkins] icinga.org: icinga-core/mfriedrich/core: classic-ui: clicking on tablecell with checkbox also checks/unchecks checkbox

git at icinga.org git at icinga.org
Tue Aug 23 10:43:08 CEST 2011


Module: icinga-core
Branch: mfriedrich/core
Commit: 262c72812289e44e6cc41cc51486f96bf3ccb1ac
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=262c72812289e44e6cc41cc51486f96bf3ccb1ac

Author: Ricardo Bartels <ricardo at bitchbrothers.com>
Date:   Sun Aug 21 22:34:56 2011 +0200

classic-ui: clicking on tablecell with checkbox also checks/unchecks checkbox

when you have a checkbox in a multible select (stauts/extinfo) list, clicking
inside the tablecell also checks/unchecks the checkbox.

---

 cgi/extinfo.c |   11 ++++++-----
 cgi/status.c  |   12 ++++++++----
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/cgi/extinfo.c b/cgi/extinfo.c
index b337dc0..dd4f90b 100644
--- a/cgi/extinfo.c
+++ b/cgi/extinfo.c
@@ -2991,8 +2991,8 @@ void show_comments(int type) {
 				}
 			}
 			printf("<td name='comment_time'>%s</td><td name='comment_author'>%s</td><td name='comment_data'>%s</td><td name='comment_id'>%lu</td><td name='comment_persist'>%s</td><td name='comment_type'>%s</td><td name='comment_expire'>%s</td>", date_time, temp_comment->author, temp_comment->comment_data, temp_comment->comment_id, (temp_comment->persistent) ? "Yes" : "No", comment_type, (temp_comment->expires == TRUE) ? expire_time : "N/A");
-			printf("<td align='center'><a href='%s?cmd_typ=%d&com_id=%lu'><img src='%s%s' border=0 ALT='Delete This Comment' TITLE='Delete This Comment'></a>", CMD_CGI, (type == HOST_COMMENT) ? CMD_DEL_HOST_COMMENT : CMD_DEL_SVC_COMMENT, temp_comment->comment_id, url_images_path, DELETE_ICON);
-			printf("<input onclick=\"isValidForSubmit(\'tableform%scomment\');\" type='checkbox' name='checkbox' value='&com_id=%lu'></td>", (type == HOST_COMMENT) ? "host" : "service", temp_comment->comment_id);
+			printf("<td align='center' onClick=\"x=document.getElementById('comment_%lu'); if(x.checked==true) { x.checked=false; } else { x.checked=true; } isValidForSubmit('tableform%scomment');\"><a href='%s?cmd_typ=%d&com_id=%lu'><img src='%s%s' border=0 ALT='Delete This Comment' TITLE='Delete This Comment'></a>", temp_comment->comment_id, (type == HOST_COMMENT) ? "host" : "service", CMD_CGI, (type == HOST_COMMENT) ? CMD_DEL_HOST_COMMENT : CMD_DEL_SVC_COMMENT, temp_comment->comment_id, url_images_path, DELETE_ICON);
+			printf("<input onClick=\"x=document.getElementById('comment_%lu'); if(x.checked==true) { x.checked=false; } else { x.checked=true; } isValidForSubmit('tableform%scomment');\" type='checkbox' name='checkbox' id='comment_%lu' value='&com_id=%lu'></td>", temp_comment->comment_id, (type == HOST_COMMENT) ? "host" : "service", temp_comment->comment_id, temp_comment->comment_id);
 			printf("</td></tr>\n");
 		}
 		total_comments++;
@@ -3233,12 +3233,13 @@ void show_downtime(int type) {
 			printf("%s\n", csv_data_enclosure);
 		} else {
 			printf("</td>\n");
+			printf("<td align='center' CLASS='%s' onClick=\"x=document.getElementById('downtime_%lu'); if(x.checked==true) { x.checked=false; } else { x.checked=true; } isValidForSubmit('tableform%sdowntime');\">", bg_class, temp_downtime->downtime_id, (type == HOST_DOWNTIME) ? "host" : "service");
 			if (type == HOST_DOWNTIME)
-				printf("<td align='center' CLASS='%s'><a href='%s?cmd_typ=%d", bg_class, CMD_CGI, CMD_DEL_HOST_DOWNTIME);
+				printf("<a href='%s?cmd_typ=%d", CMD_CGI, CMD_DEL_HOST_DOWNTIME);
 			else
-				printf("<td align='center' CLASS='%s'><a href='%s?cmd_typ=%d", bg_class, CMD_CGI, CMD_DEL_SVC_DOWNTIME);
+				printf("<a href='%s?cmd_typ=%d", CMD_CGI, CMD_DEL_SVC_DOWNTIME);
 			printf("&down_id=%lu'><img src='%s%s' border=0 ALT='Delete/Cancel This Scheduled Downtime Entry' TITLE='Delete/Cancel This Scheduled Downtime Entry'></a>", temp_downtime->downtime_id, url_images_path, DELETE_ICON);
-			printf("<input onclick=\"isValidForSubmit(\'tableform%sdowntime\');\" type='checkbox' name='checkbox' value='&down_id=%lu'></td>", (type == HOST_DOWNTIME) ? "host" : "service", temp_downtime->downtime_id);
+			printf("<input onClick=\"x=document.getElementById('downtime_%lu'); if(x.checked==true) { x.checked=false; } else { x.checked=true; } isValidForSubmit('tableform%sdowntime');\" type='checkbox' name='checkbox' id='downtime_%lu' value='&down_id=%lu'></td>", temp_downtime->downtime_id, (type == HOST_DOWNTIME) ? "host" : "service", temp_downtime->downtime_id, temp_downtime->downtime_id);
 			printf("</td></tr>\n");
 		}
 		total_downtime++;
diff --git a/cgi/status.c b/cgi/status.c
index 6d9570e..2e94743 100644
--- a/cgi/status.c
+++ b/cgi/status.c
@@ -1873,8 +1873,10 @@ void show_service_detail(void) {
 			printf("<TD CLASS='status%s' valign='center'>%s</TD>\n", status_bg_class, temp_status->plugin_output);
 
 			/* Checkbox for service(s) */
-			if (is_authorized_for_read_only(&current_authdata) == FALSE)
-				printf("<TD CLASS='status%s' nowrap align='center'><input onclick=\"isValidForSubmit('tableformservice');\" type='checkbox' name='hostservice' value='%s^%s'></TD>\n", status_bg_class, temp_status->host_name, temp_status->svc_description);
+			if (is_authorized_for_read_only(&current_authdata) == FALSE) {
+				printf("<TD CLASS='status%s' nowrap align='center' onClick=\"x=document.getElementById('service_%d'); if(x.checked==true) { x.checked=false; } else { x.checked=true; } isValidForSubmit('tableformservice');\">", status_bg_class, total_entries);
+				printf("<input onClick=\"x=document.getElementById('service_%d'); if(x.checked==true) { x.checked=false; } else { x.checked=true; } isValidForSubmit('tableformservice');\" type='checkbox' id='service_%d' name='hostservice' value='%s^%s'></TD>\n", total_entries, total_entries, temp_status->host_name, temp_status->svc_description);
+			}
 
 			if (enable_splunk_integration == TRUE)
 				display_splunk_service_url(temp_service);
@@ -2274,8 +2276,10 @@ void show_host_detail(void) {
 				printf("<TD CLASS='status%s' valign='center'>%s</TD>\n", status_bg_class, temp_statusdata->plugin_output);
 
 				/* Checkbox for host(s) */
-				if (is_authorized_for_read_only(&current_authdata) == FALSE)
-					printf("<TD CLASS='status%s' valign='center' align='center'><input onClick=\"isValidForSubmit('tableformhost');\" type='checkbox' name='host' value='%s'></TD>\n", status_bg_class, temp_statusdata->host_name);
+				if (is_authorized_for_read_only(&current_authdata) == FALSE) {
+					printf("<TD CLASS='status%s' nowrap align='center' onClick=\"x=document.getElementById('host_%d'); if(x.checked==true) { x.checked=false; } else { x.checked=true; } isValidForSubmit('tableformhost');\">", status_bg_class, total_entries);
+					printf("<input onClick=\"x=document.getElementById('host_%d'); if(x.checked==true) { x.checked=false; } else { x.checked=true; } isValidForSubmit('tableformhost');\" type='checkbox' id='host_%d' name='host' value='%s'></TD>\n", total_entries, total_entries, temp_statusdata->host_name);
+				}
 
 
 





More information about the icinga-checkins mailing list