[icinga-checkins] icinga.org: icinga-core/dev/cgis: classic ui: Added Select hosts or services by clicking on line instead of box #2118

git at icinga.org git at icinga.org
Fri Jan 20 00:01:39 CET 2012


Module: icinga-core
Branch: dev/cgis
Commit: 4951e409053e3a7e0445b827886da990d414ab8c
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=4951e409053e3a7e0445b827886da990d414ab8c

Author: Ricardo Bartels <ricardo at bitchbrothers.com>
Date:   Thu Jan 19 23:59:32 2012 +0100

classic ui: Added Select hosts or services by clicking on line instead of box #2118

refs: #2118

Added to status.cgi and extinfo.cgi

---

 Changelog                     |    1 +
 cgi/extinfo.c                 |   13 +++++++------
 cgi/status.c                  |   12 ++++++------
 html/js/checkbox_functions.js |   20 +++++++++++++++++++-
 4 files changed, 33 insertions(+), 13 deletions(-)

diff --git a/Changelog b/Changelog
index 59e5be5..4666449 100644
--- a/Changelog
+++ b/Changelog
@@ -13,6 +13,7 @@ ENHANCEMENTS
 * classic ui: Added multiple hosts/services to status.cgi GET #1981
 * classic ui: Added nostatusheader in status.cgi as config option #2018
 * classic ui: Added statusmap resizing with exclude/include button #2186
+* classic ui: Added Select hosts or services by clicking on line instead of box #2118
 
 FIXES
 * classic ui: Fixed status totals are wrong when searching #1524
diff --git a/cgi/extinfo.c b/cgi/extinfo.c
index 4d037d8..6342f6a 100644
--- a/cgi/extinfo.c
+++ b/cgi/extinfo.c
@@ -3034,7 +3034,7 @@ void show_comments(int type) {
 			printf("%s%s%s%s", csv_data_enclosure, comment_type, csv_data_enclosure, csv_delimiter);
 			printf("%s%s%s\n", csv_data_enclosure, (temp_comment->expires == TRUE) ? expire_time : "N/A", csv_data_enclosure);
 		} else {
-			printf("<tr CLASS='%s'>", bg_class);
+			printf("<tr CLASS='%s' onClick=\"toggle_checkbox('comment_%lu','tableform%scomment');\">", bg_class, temp_comment->comment_id, (type == HOST_COMMENT) ? "host" : "service");
 			if (display_type == DISPLAY_COMMENTS) {
 				printf("<td><A HREF='%s?type=%d&host=%s'>%s</A></td>", EXTINFO_CGI, DISPLAY_HOST_INFO, url_encode(temp_comment->host_name), (temp_host->display_name != NULL) ? temp_host->display_name : temp_host->name);
 				if (type == SERVICE_COMMENT) {
@@ -3043,8 +3043,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' 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 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 type='checkbox' onClick=\"toggle_checkbox('comment_%lu','tableform%scomment');\" 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++;
@@ -3210,7 +3210,8 @@ void show_downtime(int type) {
 					printf("%s%s%s", csv_data_enclosure, csv_data_enclosure, csv_delimiter);
 			}
 		} else {
-			printf("<tr CLASS='%s'>", bg_class);
+			printf("<tr CLASS='%s' onClick=\"toggle_checkbox('downtime_%lu','tableform%sdowntime');\">", bg_class, temp_downtime->downtime_id, (type == HOST_DOWNTIME) ? "host" : "service");
+			//printf("<tr CLASS='%s'>", bg_class);
 			if (display_type == DISPLAY_DOWNTIME) {
 				printf("<td CLASS='%s'><A HREF='%s?type=%d&host=%s'>%s</A></td>", bg_class, EXTINFO_CGI, DISPLAY_HOST_INFO, url_encode(temp_downtime->host_name), (temp_host->display_name != NULL) ? temp_host->display_name : temp_host->name);
 				if (type == SERVICE_DOWNTIME) {
@@ -3289,13 +3290,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");
+			printf("<td align='center' CLASS='%s'>", bg_class);
 			if (type == HOST_DOWNTIME)
 				printf("<a href='%s?cmd_typ=%d", CMD_CGI, CMD_DEL_HOST_DOWNTIME);
 			else
 				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=\"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("<input type='checkbox' name='checkbox' id='downtime_%lu' value='&down_id=%lu'></td>", 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 a49d68b..19fc5ca 100644
--- a/cgi/status.c
+++ b/cgi/status.c
@@ -1958,7 +1958,7 @@ void show_service_detail(void) {
 
 		if (content_type == HTML_CONTENT) {
 
-			printf("<TR>\n");
+			printf("<TR onClick=\"toggle_checkbox('service_%d','tableformservice');\">\n", total_entries);
 
 			/* host name column */
 			if (new_host == TRUE) {
@@ -2191,8 +2191,8 @@ void show_service_detail(void) {
 
 			/* Checkbox for service(s) */
 			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);
+				printf("<TD CLASS='status%s' nowrap align='center'>", status_bg_class);
+				printf("<input onClick=\"toggle_checkbox('service_%d','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)
@@ -2498,7 +2498,7 @@ void show_host_detail(void) {
 
 		if (content_type == HTML_CONTENT) {
 
-			printf("<TR>\n");
+			printf("<TR onClick=\"toggle_checkbox('host_%d','tableformhost');\">\n", total_entries);
 
 
 			/**** host name column ****/
@@ -2605,8 +2605,8 @@ void show_host_detail(void) {
 
 			/* Checkbox for host(s) */
 			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);
+				printf("<TD CLASS='status%s' nowrap align='center'>", status_bg_class);
+				printf("<input onClick=\"toggle_checkbox('host_%d','tableformhost');\" type='checkbox' id='host_%d' name='host' value='%s'></TD>\n", total_entries, total_entries, temp_statusdata->host_name);
 			}
 
 			if (enable_splunk_integration == TRUE)
diff --git a/html/js/checkbox_functions.js b/html/js/checkbox_functions.js
index b64bf0b..5e59565 100644
--- a/html/js/checkbox_functions.js
+++ b/html/js/checkbox_functions.js
@@ -129,4 +129,22 @@ function checkAll(form) {
 			checkboxes.elements[i].checked = checked;
 		}
 	}
-}
\ No newline at end of file
+}
+
+function toggle_checkbox(id, form) {
+	var x = document.getElementById(id);
+	if ( x.checked == true ) {
+		x.checked=false;
+	} else {
+		x.checked=true;
+	}
+
+//	if ( id.indexOf("host") >= 0) {
+		isValidForSubmit(form);
+/*	if ( id.indexOf("host") >= 0) {
+	} else {
+		isValidForSubmit('tableformservice');
+	} */
+
+	return true;
+}





More information about the icinga-checkins mailing list