Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

classic ui: add "link to this page" to all cgis #1783 ; add export ic…

…ons instead of "export to..." text on cgis supporting it (csv, json, xml, link) #1789

removing the "Export to CSV" and replacing it by free icons.
also added icons for json, xml and links and placed them where
the cgis supported the output. the links are placed as is,
meaning target=_blank - copying needs "copy target url" or similar.

fixed wrong csvoutput in status.cgi due to command menu adaptions.
status_update_interval can now be violated twice until reports.

fixes #1783
fixes #1789
  • Loading branch information...
Michael Friedrich
Michael Friedrich committed Aug 6, 2011
1 parent c0535b9 commit ec745dde44bd44ef7807582b42fe2cb11f38f418
@@ -26,6 +26,8 @@ ENHANCEMENTS
** authorized_contactgroup_for_all_service_commands, authorized_contactgroup_for_system_commands, authorized_contactgroup_for_read_only
* classic ui: add xml output to avail.cgi for direct source of jasper reports #1712
* classic ui: add combined view of all unhandled hosts and services including the multiple command dropdowns for each (initial idea by Thruk) #1328
* classic ui: add "link to this page" to all cgis #1783
* classic ui: add export icons instead of "export to..." text on cgis supporting it (csv, json, xml, link) #1789

* idoutils: add update-version-schema for updating the idoutils db schema versions automagically, independant of update-version #1616
* idoutils: dump multiline mbufs as bulk inserts #1110
@@ -605,6 +605,8 @@ int main(int argc, char **argv){
printf("</table>\n");
printf("</form>\n");

printf("<a href='%s' target='_blank'><img src='%s%s' border=0 alt='%s'></a>\n",get_export_link(AVAIL_CGI),url_images_path,EXPORT_LINK_ICON,EXPORT_LINK_ICON_ALT);

printf("</td>\n");

/* end of top table */
@@ -993,6 +995,15 @@ int main(int argc, char **argv){
if(content_type==HTML_CONTENT){
get_time_breakdown((time_t)(report_end_time-report_start_time),&days,&hours,&minutes,&seconds);
printf("<div align=center class='reportTime'>[ Availability report completed in %d min %d sec ]</div>\n",minutes,seconds);

/* add export to csv, json, xml, link */
printf("<div class='csv_export_link' align=right>");
printf("<a href='%s' target='_blank'><img src='%s%s' border=0 alt='%s'></a>\n",get_export_csv_link(AVAIL_CGI),url_images_path,EXPORT_CSV_ICON,EXPORT_CSV_ICON_ALT);
printf("<a href='%s' target='_blank'><img src='%s%s' border=0 alt='%s'></a>\n",get_export_json_link(AVAIL_CGI),url_images_path,EXPORT_JSON_ICON,EXPORT_JSON_ICON_ALT);
printf("<a href='%s' target='_blank'><img src='%s%s' border=0 alt='%s'></a>\n",get_export_xml_link(AVAIL_CGI),url_images_path,EXPORT_XML_ICON,EXPORT_XML_ICON_ALT);
printf("<a href='%s' target='_blank'><img src='%s%s' border=0 alt='%s'></a>\n",get_export_link(AVAIL_CGI),url_images_path,EXPORT_LINK_ICON,EXPORT_LINK_ICON_ALT);
printf("</div>\n");

printf("<BR><BR>\n");
}

@@ -1781,7 +1781,8 @@ void display_info_table(char *title,int refresh, authdata *current_authdata, int
printf("<DIV CLASS='infoBoxBadProcStatus'>- Service checks are disabled</DIV>");
}

if(status_file_creation_time<(current_time-status_update_interval-10))
/* must have missed 2 update intervals */
if(status_file_creation_time<(current_time-(2*status_update_interval)))
printf("<DIV CLASS='infoBoxBadProcStatus'>Warning: Status data OUTDATED! Last status data update was %d seconds ago!</DIV>",(int)(current_time-status_file_creation_time));

printf("</TD></TR>\n");
@@ -2356,6 +2357,74 @@ char *get_export_csv_link(char *cgi) {
return ret;
}

char *get_export_json_link(char *cgi) {
char temp_buffer[MAX_INPUT_BUFFER]="";
static char ret[MAX_INPUT_BUFFER]="";

/* just do stuff if some options are requested */
if(getenv("QUERY_STRING")!=NULL){
if(strcmp(getenv("QUERY_STRING"),"")) {
snprintf(temp_buffer,sizeof(temp_buffer)-1,"%s",getenv("QUERY_STRING"));
temp_buffer[sizeof(temp_buffer)-1]='\x0';
strip_html_brackets(temp_buffer);
snprintf(ret,sizeof(ret)-1,"%s?%s&jsonoutput",cgi,temp_buffer);
ret[sizeof(ret)-1]='\x0';
} else
snprintf(ret,sizeof(ret)-1,"%s?jsonoutput",cgi);
} else
snprintf(ret,sizeof(ret)-1,"%s?jsonoutput",cgi);

ret[sizeof(ret)-1]='\x0';

return ret;
}

char *get_export_xml_link(char *cgi) {
char temp_buffer[MAX_INPUT_BUFFER]="";
static char ret[MAX_INPUT_BUFFER]="";

/* just do stuff if some options are requested */
if(getenv("QUERY_STRING")!=NULL){
if(strcmp(getenv("QUERY_STRING"),"")) {
snprintf(temp_buffer,sizeof(temp_buffer)-1,"%s",getenv("QUERY_STRING"));
temp_buffer[sizeof(temp_buffer)-1]='\x0';
strip_html_brackets(temp_buffer);
snprintf(ret,sizeof(ret)-1,"%s?%s&xmloutput",cgi,temp_buffer);
ret[sizeof(ret)-1]='\x0';
} else
snprintf(ret,sizeof(ret)-1,"%s?xmloutput",cgi);
} else
snprintf(ret,sizeof(ret)-1,"%s?xmloutput",cgi);

ret[sizeof(ret)-1]='\x0';

return ret;
}

char *get_export_link(char *cgi) {
char temp_buffer[MAX_INPUT_BUFFER]="";
static char ret[MAX_INPUT_BUFFER]="";

/* just do stuff if some options are requested */
if(getenv("QUERY_STRING")!=NULL){
if(strcmp(getenv("QUERY_STRING"),"")) {
snprintf(temp_buffer,sizeof(temp_buffer)-1,"%s",getenv("QUERY_STRING"));
temp_buffer[sizeof(temp_buffer)-1]='\x0';
strip_html_brackets(temp_buffer);
snprintf(ret,sizeof(ret)-1,"%s?%s",cgi,temp_buffer);
ret[sizeof(ret)-1]='\x0';
} else
snprintf(ret,sizeof(ret)-1,"%s",cgi);
} else
snprintf(ret,sizeof(ret)-1,"%s",cgi);

ret[sizeof(ret)-1]='\x0';

return ret;
}



/**
* Logging and file functions
**/
@@ -519,10 +519,10 @@ void display_hosts(void){
(*to_expand=='\0'?"s":" "),(*to_expand=='\0'?"":escape_string(to_expand)));

printf("<P><DIV ALIGN=CENTER>\n");
printf("<TABLE BORDER=0 CLASS='data'>\n");

print_export_link();

printf("<TABLE BORDER=0 CLASS='data'>\n");
printf("<TR>\n");
printf("<TH CLASS='data'>Host Name</TH>");
printf("<TH CLASS='data'>Alias/Description</TH>");
@@ -1081,10 +1081,9 @@ void display_hostgroups(void){
printf("<P>\n");
printf("<DIV ALIGN=CENTER>\n");

printf("<TABLE BORDER=0 CLASS='data'>\n");

print_export_link();

printf("<TABLE BORDER=0 CLASS='data'>\n");
printf("<TR>\n");
printf("<TH CLASS='data'>Group Name</TH>");
printf("<TH CLASS='data'>Description</TH>");
@@ -1214,10 +1213,10 @@ void display_servicegroups(void){
printf("<P>\n");
printf("<DIV ALIGN=CENTER>\n");

printf("<TABLE BORDER=0 CLASS='data'>\n");

print_export_link();

printf("<TABLE BORDER=0 CLASS='data'>\n");

printf("<TR>\n");
printf("<TH CLASS='data'>Group Name</TH>");
printf("<TH CLASS='data'>Description</TH>");
@@ -1353,10 +1352,10 @@ void display_contacts(void){
printf("<P>\n");
printf("<DIV ALIGN=CENTER>\n");

printf("<TABLE CLASS='data'>\n");

print_export_link();

printf("<TABLE CLASS='data'>\n");

printf("<TR>\n");
printf("<TH CLASS='data'>Contact Name</TH>");
printf("<TH CLASS='data'>Alias</TH>");
@@ -1634,10 +1633,10 @@ void display_contactgroups(void){
printf("<P>\n");
printf("<DIV ALIGN=CENTER>\n");

printf("<TABLE BORDER=0 CELLSPACING=3 CELLPADDING=0>\n");

print_export_link();

printf("<TABLE BORDER=0 CELLSPACING=3 CELLPADDING=0>\n");

printf("<TR>\n");
printf("<TH CLASS='data'>Group Name</TH>\n");
printf("<TH CLASS='data'>Description</TH>\n");
@@ -1776,10 +1775,10 @@ void display_services(void){
printf("<P>\n");
printf("<DIV ALIGN=CENTER>\n");

printf("<TABLE BORDER=0 CLASS='data'>\n");

print_export_link();

printf("<TABLE BORDER=0 CLASS='data'>\n");

printf("<TR>\n");
printf("<TH CLASS='data'>Host</TH>\n");
printf("<TH CLASS='data'>Description</TH>\n");
@@ -2319,10 +2318,10 @@ void display_timeperiods(void){
printf("<P>\n");
printf("<DIV ALIGN=CENTER>\n");

printf("<TABLE BORDER=0 CLASS='data'>\n");

print_export_link();

printf("<TABLE BORDER=0 CLASS='data'>\n");

printf("<TR>\n");
printf("<TH CLASS='data'>Name</TH>\n");
printf("<TH CLASS='data'>Alias/Description</TH>\n");
@@ -2594,10 +2593,10 @@ void display_commands(void){
(*to_expand=='\0'?"s":" "),(*to_expand=='\0'?"":escape_string(to_expand)));

printf("<P><DIV ALIGN=CENTER>\n");
printf("<TABLE BORDER=0 CLASS='data'>\n");

print_export_link();

printf("<TABLE BORDER=0 CLASS='data'>\n");

printf("<TR><TH CLASS='data'>Command Name</TH><TH CLASS='data'>Command Line</TH></TR>\n");
}

@@ -2669,10 +2668,10 @@ void display_servicedependencies(void){
printf("<P>\n");
printf("<DIV ALIGN=CENTER>\n");

printf("<TABLE BORDER=0 CLASS='data'>\n");

print_export_link();

printf("<TABLE BORDER=0 CLASS='data'>\n");

printf("<TR>\n");
printf("<TH CLASS='data' COLSPAN=2>Dependent Service</TH>");
printf("<TH CLASS='data' COLSPAN=2>Master Service</TH>");
@@ -2824,10 +2823,10 @@ void display_serviceescalations(void){
printf("<P>\n");
printf("<DIV ALIGN=CENTER>\n");

printf("<TABLE BORDER=0 CLASS='data'>\n");

print_export_link();

printf("<TABLE BORDER=0 CLASS='data'>\n");

printf("<TR>\n");
printf("<TH CLASS='data'>Host</TH>");
printf("<TH CLASS='data'>Description</TH>");
@@ -3072,10 +3071,10 @@ void display_hostdependencies(void){
printf("<P>\n");
printf("<DIV ALIGN=CENTER>\n");

printf("<TABLE BORDER=0 CLASS='data'>\n");

print_export_link();

printf("<TABLE BORDER=0 CLASS='data'>\n");

printf("<TR>\n");
printf("<TH CLASS='data'>Dependent Host</TH>");
printf("<TH CLASS='data'>Master Host</TH>");
@@ -3207,10 +3206,10 @@ void display_hostescalations(void){
printf("<P>\n");
printf("<DIV ALIGN=CENTER>\n");

printf("<TABLE BORDER=0 CLASS='data'>\n");

print_export_link();

printf("<TABLE BORDER=0 CLASS='data'>\n");

printf("<TR>\n");
printf("<TH CLASS='data'>Host</TH>");
printf("<TH CLASS='data'>Contacts/Groups</TH>");
@@ -3424,10 +3423,10 @@ void display_modules(void){
(*to_expand=='\0'?"s":" "),(*to_expand=='\0'?"":escape_string(to_expand)));

printf("<P><DIV ALIGN=CENTER>\n");
printf("<TABLE BORDER=0 CLASS='data'>\n");

print_export_link();

printf("<TABLE BORDER=0 CLASS='data'>\n");

printf("<TR><TH CLASS='data'>Module Name</TH><TH CLASS='data'>Module Type</TH><TH CLASS='data'>Module Path</TH><TH CLASS='data'>Module Args</TH></TR>\n");
}

@@ -3732,6 +3731,12 @@ void display_options(void){

void print_export_link(void){
printf("<TR>\n<td><div class='csv_export_link' style='text-align:left;'>");
/* add export to csv link */
printf("<a href='%s' target='_blank'>Export to CSV</a></div></td>\n</TR>\n",get_export_csv_link(CONFIG_CGI));
/* add export to csv, json, link */
printf("<div class='csv_export_link'>");
printf("<a href='%s' target='_blank'><img src='%s%s' border=0 alt='%s'></a>\n",get_export_csv_link(CONFIG_CGI),url_images_path,EXPORT_CSV_ICON,EXPORT_CSV_ICON_ALT);
printf("<a href='%s' target='_blank'><img src='%s%s' border=0 alt='%s'></a>\n",get_export_json_link(CONFIG_CGI),url_images_path,EXPORT_JSON_ICON,EXPORT_JSON_ICON_ALT);
printf("<a href='%s' target='_blank'><img src='%s%s' border=0 alt='%s'></a>\n",get_export_link(CONFIG_CGI),url_images_path,EXPORT_LINK_ICON,EXPORT_LINK_ICON_ALT);
printf("</div>\n");

printf("</td>\n</TR>\n");
}
@@ -706,8 +706,12 @@ int main(void){
printf("<DIV CLASS='commentNav'>[&nbsp;<A HREF='#HOSTCOMMENTS' CLASS='commentNav'>Host Comments</A>&nbsp;|&nbsp;<A HREF='#SERVICECOMMENTS' CLASS='commentNav'>Service Comments</A>&nbsp;]</DIV>\n");
printf("<BR />\n");

/* add export to csv link */
printf("<DIV class='csv_export_link'><A HREF='%s&csvtype=comment' target='_blank'>Export to CSV</A></DIV>\n",get_export_csv_link(EXTINFO_CGI));
/* add export to csv, json, link */
printf("<div class='csv_export_link'>");
printf("<a href='%s' target='_blank'><img src='%s%s' border=0 alt='%s'></a>\n",get_export_csv_link(EXTINFO_CGI),url_images_path,EXPORT_CSV_ICON,EXPORT_CSV_ICON_ALT);
printf("<a href='%s' target='_blank'><img src='%s%s' border=0 alt='%s'></a>\n",get_export_json_link(EXTINFO_CGI),url_images_path,EXPORT_JSON_ICON,EXPORT_JSON_ICON_ALT);
printf("<a href='%s' target='_blank'><img src='%s%s' border=0 alt='%s'></a>\n",get_export_link(EXTINFO_CGI),url_images_path,EXPORT_LINK_ICON,EXPORT_LINK_ICON_ALT);
printf("</div>");

show_comments(HOST_COMMENT);
printf("<BR />\n");
@@ -727,8 +731,13 @@ int main(void){
printf("<DIV CLASS='downtimeNav'>[&nbsp;<A HREF='#HOSTDOWNTIME' CLASS='downtimeNav'>Host Downtime</A>&nbsp;|&nbsp;<A HREF='#SERVICEDOWNTIME' CLASS='downtimeNav'>Service Downtime</A>&nbsp;]</DIV>\n");
printf("<BR />\n");

/* add export to csv link */
printf("<DIV class='csv_export_link'><A HREF='%s&csvtype=downtime' target='_blank'>Export to CSV</A></DIV>\n",get_export_csv_link(EXTINFO_CGI));
/* add export to csv, json, link */
printf("<div class='csv_export_link'>");
printf("<a href='%s' target='_blank'><img src='%s%s' border=0 alt='%s'></a>\n",get_export_csv_link(EXTINFO_CGI),url_images_path,EXPORT_CSV_ICON,EXPORT_CSV_ICON_ALT);
printf("<a href='%s' target='_blank'><img src='%s%s' border=0 alt='%s'></a>\n",get_export_json_link(EXTINFO_CGI),url_images_path,EXPORT_JSON_ICON,EXPORT_JSON_ICON_ALT);
printf("<a href='%s' target='_blank'><img src='%s%s' border=0 alt='%s'></a>\n",get_export_link(EXTINFO_CGI),url_images_path,EXPORT_LINK_ICON,EXPORT_LINK_ICON_ALT);
printf("</div>");


show_downtime(HOST_DOWNTIME);
printf("<BR />\n");
@@ -1050,8 +1059,12 @@ void show_process_info(void){
} else {
printf("<BR />\n");

/* add export to csv link */
printf("<DIV class='csv_export_link'><A HREF='%s' target='_blank'>Export to CSV</A></DIV>\n",get_export_csv_link(EXTINFO_CGI));
/* add export to csv, json, link */
printf("<div class='csv_export_link'>");
printf("<a href='%s' target='_blank'><img src='%s%s' border=0 alt='%s'></a>\n",get_export_csv_link(EXTINFO_CGI),url_images_path,EXPORT_CSV_ICON,EXPORT_CSV_ICON_ALT);
printf("<a href='%s' target='_blank'><img src='%s%s' border=0 alt='%s'></a>\n",get_export_json_link(EXTINFO_CGI),url_images_path,EXPORT_JSON_ICON,EXPORT_JSON_ICON_ALT);
printf("<a href='%s' target='_blank'><img src='%s%s' border=0 alt='%s'></a>\n",get_export_link(EXTINFO_CGI),url_images_path,EXPORT_LINK_ICON,EXPORT_LINK_ICON_ALT);
printf("</div>");

printf("<DIV ALIGN=CENTER>\n");

@@ -2854,7 +2867,7 @@ void show_comments(int type){

/* add export to csv link */
if(display_type!=DISPLAY_COMMENTS)
printf("<TR><TD colspan='%d'><DIV class='csv_export_link'><A HREF='%s&csvtype=comment' target='_blank'>Export to CSV</A></DIV></TD></TR>\n",colspan,get_export_csv_link(EXTINFO_CGI));
printf("<TR><TD colspan='%d'><DIV class='csv_export_link'><A HREF='%s&csvtype=comment' target='_blank'><img src='%s%s' border=0 alt='%s'></A><a href='%s' target='_blank'><img src='%s%s' border=0 alt='%s'></a></DIV></TD></TR>\n",colspan,get_export_csv_link(EXTINFO_CGI),url_images_path,EXPORT_CSV_ICON,EXPORT_CSV_ICON_ALT,get_export_link(EXTINFO_CGI),url_images_path,EXPORT_LINK_ICON,EXPORT_LINK_ICON_ALT);

printf("<TR><TD colspan='%d' align='right'><input type='button' name='CommandButton' value='Delete Comments' onClick=cmd_submit(\'tableform%scomment\') disabled=\"disabled\"></TD></TR>\n",colspan,(type==HOST_COMMENT)?"host":"service");

@@ -3058,7 +3071,7 @@ void show_downtime(int type){

/* add export to csv link */
if(display_type!=DISPLAY_DOWNTIME)
printf("<TR><TD colspan='%d'><DIV class='csv_export_link'><A HREF='%s&csvtype=downtime' target='_blank'>Export to CSV</A></DIV></TD></TR>\n",colspan,get_export_csv_link(EXTINFO_CGI));
printf("<TR><TD colspan='%d'><DIV class='csv_export_link'><A HREF='%s&csvtype=downtime' target='_blank'><img src='%s%s' border=0 alt='%s'></A><a href='%s' target='_blank'><img src='%s%s' border=0 alt='%s'></a></DIV></TD></TR>\n",colspan,get_export_csv_link(EXTINFO_CGI),url_images_path,EXPORT_CSV_ICON,EXPORT_CSV_ICON_ALT,get_export_link(EXTINFO_CGI),url_images_path,EXPORT_LINK_ICON,EXPORT_LINK_ICON_ALT);

printf("<TR><TD colspan='%d' align='right'><input type='button' name='CommandButton' value='Delete Downtimes' onClick=cmd_submit(\'tableform%sdowntime\') disabled=\"disabled\"></TD></TR>\n",colspan,(type==HOST_DOWNTIME)?"host":"service");

@@ -3303,7 +3316,7 @@ void show_scheduling_queue(void){
printf("<TABLE BORDER=0 CLASS='queue'>\n");

/* add export to csv link */
printf("<TR><TD colspan='7'><DIV class='csv_export_link'><A HREF='%s' target='_blank'>Export to CSV</A></DIV></TD></TR>\n",get_export_csv_link(EXTINFO_CGI));
printf("<TR><TD colspan='7'><DIV class='csv_export_link'><A HREF='%s' target='_blank'><img src='%s%s' border=0 alt='%s'></A><a href='%s' target='_blank'><img src='%s%s' border=0 alt='%s'></a></DIV></TD></TR>\n",get_export_csv_link(EXTINFO_CGI),url_images_path,EXPORT_CSV_ICON,EXPORT_CSV_ICON_ALT,get_export_link(EXTINFO_CGI),url_images_path,EXPORT_LINK_ICON,EXPORT_LINK_ICON_ALT);

printf("<TR CLASS='queue'>");

@@ -508,6 +508,9 @@ int main(int argc, char **argv){
printf("</table>\n");
printf("</form>\n");

printf("<a href='%s' target='_blank'><img src='%s%s' border=0 alt='%s'></a>\n",get_export_link(HISTOGRAM_CGI),url_images_path,EXPORT_LINK_ICON,EXPORT_LINK_ICON_ALT);


printf("</td>\n");

/* end of top table */
@@ -296,6 +296,9 @@ int main(void){
printf("</table>\n");
printf("</form>\n");

printf("<a href='%s' target='_blank'><img src='%s%s' border=0 alt='%s'></a>\n",get_export_link(HISTORY_CGI),url_images_path,EXPORT_LINK_ICON,EXPORT_LINK_ICON_ALT);


printf("</td>\n");

/* end of top table */

0 comments on commit ec745dd

Please sign in to comment.
You can’t perform that action at this time.