[icinga-checkins] icinga.org: icinga-core/next: classic-ui: Added data/time selection to ' log file navigation' #3168

git at icinga.org git at icinga.org
Mon Mar 4 18:41:17 CET 2013


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

Author: Ricardo Bartels <ricardo at bitchbrothers.com>
Date:   Sun Feb  3 15:43:34 2013 +0100

classic-ui: Added data/time selection to 'log file navigation' #3168

refs: #3168

now you can select a date for the calender and jump right to it.

---

 Changelog      |    1 +
 cgi/cgiutils.c |   60 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 58 insertions(+), 3 deletions(-)

diff --git a/Changelog b/Changelog
index 12696d6..eb70e90 100644
--- a/Changelog
+++ b/Changelog
@@ -24,6 +24,7 @@ ENHANCEMENTS
 * classic ui: Add "send_ack_notifications" to cgi configuration (TheCry) #3467 - CF
 * classic ui: Changed field size for hours to 4 when setting flexible downtime #3484 - RB
 * classic ui: Added process status to JSON response #3172 - RB
+* classic ui: Added data/time selection to 'log file navigation' #3168 - RB
 
 * idoutils: use transactions for large object dumps, opt-in config option #3527 - GB
 
diff --git a/cgi/cgiutils.c b/cgi/cgiutils.c
index 73e2044..94c184e 100644
--- a/cgi/cgiutils.c
+++ b/cgi/cgiutils.c
@@ -1242,7 +1242,7 @@ void document_header(int cgi_id, int use_stylesheet, char *cgi_title) {
 	printf("<script type='text/javascript' src='%s%s'></script>\n", url_js_path, JQUERY_MAIN_JS);
 
 	/* datetimepicker libs and css */
-	if (cgi_id == CMD_CGI_ID || cgi_id == NOTIFICATIONS_CGI_ID || cgi_id == SHOWLOG_CGI_ID) {
+	if (cgi_id == CMD_CGI_ID || cgi_id == NOTIFICATIONS_CGI_ID || cgi_id == SHOWLOG_CGI_ID || cgi_id == HISTORY_CGI_ID) {
 		printf("<script type='text/javascript' src='%s%s'></script>\n", url_jquiryui_path, JQ_UI_CORE_JS);
 		printf("<script type='text/javascript' src='%s%s'></script>\n", url_jquiryui_path, JQ_UI_WIDGET_JS);
 		printf("<script type='text/javascript' src='%s%s'></script>\n", url_jquiryui_path, JQ_UI_MOUSE_JS);
@@ -1254,7 +1254,7 @@ void document_header(int cgi_id, int use_stylesheet, char *cgi_title) {
 		printf("<link rel='stylesheet' type='text/css' href='%s%s'>\n", url_jquiryui_path, JQ_UI_TIMEPICKER_CSS);
 
 		printf("<script type=\"text/javascript\">\n");
-		printf("$(function() {\n");
+		printf("$(document).ready(function() {\n");
 		printf("\t$( \".timepicker\" ).datetimepicker({\n");
 		printf("\t\tfirstDay: %d,\n", week_starts_on_monday);
 
@@ -1270,6 +1270,52 @@ void document_header(int cgi_id, int use_stylesheet, char *cgi_title) {
 		printf("\t\tchangeMonth: true,\n");
 		printf("\t\tchangeYear: true\n");
 		printf("\t});\n");
+
+		printf("\t$(\"#history-datepicker\").datepicker({\n");
+		printf("\t\tfirstDay: %d,\n", week_starts_on_monday);
+		printf("\t\tdateFormat: '@',\n");
+		printf("\t\tmaxDate: '+0d',\n");
+		printf("\t\tshowWeek: true,\n");
+		printf("\t\tchangeMonth: true,\n");
+		printf("\t\tchangeYear: true,\n");
+		printf("\t\tbeforeShow: function (input, instance) {\n");
+		printf("\t\t\tinstance.dpDiv.css({\n");
+		printf("\t\t\t\tmarginTop: '15px',\n");
+		printf("\t\t\t\tmarginLeft: '-67px'\n");
+		printf("\t\t\t});\n");
+		printf("\t\t},\n");
+		printf("\t\tonSelect: function (date) {\n");
+		printf("\t\t\tif (date == '' || date < 0) { return false;}\n");
+		printf("\t\t\tts_start = date.substring(0,date.length-3);\n");
+		printf("\t\t\tts_end = parseInt(ts_start,10) + parseInt(86399,10);\n");
+		printf("\t\t\turl = window.location.href;\n");
+		printf("\t\t\toptions = '';\n");
+		printf("\t\t\tnewoptionsArray = new Array();\n");
+		printf("\t\t\tif (url.indexOf('?') === -1) {\n");
+		printf("\t\t\t\tbase_url = url;\n");
+		printf("\t\t\t} else {\n");
+		printf("\t\t\t\tbase_url = url.substring(0,url.indexOf('?'));\n");
+		printf("\t\t\t\toptions = url.substring(url.indexOf('?')+1);\n");
+		printf("\t\t\t\toptionsArray = options.split('&');\n");
+		printf("\t\t\t\tfor (var i=0; i<optionsArray.length; i++) {\n");
+		printf("\t\t\t\t\tswitch (optionsArray[i].substring(0,optionsArray[i].indexOf('='))) {\n");
+		printf("\t\t\t\t\t\tcase 'ts_start':\n");
+		printf("\t\t\t\t\t\tcase 'ts_end':\n");
+		printf("\t\t\t\t\t\tcase 'start':\n");
+		printf("\t\t\t\t\t\tcase 'start_time':\n");
+		printf("\t\t\t\t\t\tcase 'end_time':\n");
+		printf("\t\t\t\t\t\tcase '':\n");
+		printf("\t\t\t\t\t\t\tbreak;\n");
+		printf("\t\t\t\t\t\tdefault:\n");
+		printf("\t\t\t\t\t\t\tnewoptionsArray.push(optionsArray[i]);\n");
+		printf("\t\t\t\t\t}\n");
+		printf("\t\t\t\t}\n");
+		printf("\t\t\t}\n");
+		printf("\t\t\tnewoptionsArray.push('ts_start=' + ts_start, 'ts_end=' + ts_end);\n");
+		printf("\t\t\twindow.location.href = base_url + '?' + newoptionsArray.join('&');\n");
+		printf("\t\t}\n");
+		printf("\t});\n");
+
 		printf("});\n");
 		printf("</script>\n");
 	}
@@ -2072,7 +2118,7 @@ void display_nav_table(time_t ts_start, time_t ts_end) {
 		break;
 	}
 
-	/* get url options but filter out "limit" and "status" */
+	/* get url options but filter out "ts_end", "ts_start" and "start" */
 	if (getenv("QUERY_STRING") != NULL && strcmp(getenv("QUERY_STRING"), "")) {
 		if(strlen(getenv("QUERY_STRING")) > MAX_INPUT_BUFFER) {
 			printf("display_nav_table(): Could not allocate memory for stripped_query_string\n");
@@ -2150,8 +2196,16 @@ void display_nav_table(time_t ts_start, time_t ts_end) {
 
 	printf("</tr>\n");
 
+	printf("<tr><td colspan=2></td><td align=center valign=center><input id='history-datepicker' type='hidden'><a href='#' onclick=\"$.datepicker._showDatepicker($('#history-datepicker')[0]); return false;\">Select a day ...</a></td><td colspan=2></td></tr>\n");
+
 	printf("</table>\n");
 
+	printf("<script type=\"text/javascript\">\n");
+	printf("$(function() {\n");
+	printf("\t$(\"#history-datepicker\").datepicker( \"setDate\", \"%lu000\" );\n",ts_start);
+	printf("});\n");
+	printf("</script>\n");
+
 	return;
 }
 





More information about the icinga-checkins mailing list