diff --git a/pandora_console/godmode/agentes/planned_downtime.export_csv.php b/pandora_console/godmode/agentes/planned_downtime.export_csv.php index d61df4e8c3..e0331d7895 100644 --- a/pandora_console/godmode/agentes/planned_downtime.export_csv.php +++ b/pandora_console/godmode/agentes/planned_downtime.export_csv.php @@ -124,6 +124,8 @@ if (!empty($groups)) { if (!empty($downtimes)) { ob_clean(); // Show contentype header + // Set cookie for download control. + setDownloadCookieToken(); header('Content-type: text/csv'); header('Content-Disposition: attachment; filename="pandora_planned_downtime_'.date('Y/m/d H:i:s').'.csv"'); @@ -161,7 +163,7 @@ if (!empty($downtimes)) { if (!empty($downtime_agents)) { foreach ($downtime_agents as $downtime_agent) { $downtime_items = []; - $downtime_items[] = $downtime_agent[alias]; + $downtime_items[] = $downtime_agent['alias']; if (!$downtime_agent['all_modules']) { $agent_id = $downtime_agent['agent_id']; diff --git a/pandora_console/godmode/agentes/planned_downtime.list.php b/pandora_console/godmode/agentes/planned_downtime.list.php index 0900ee2aba..cd80d79caa 100755 --- a/pandora_console/godmode/agentes/planned_downtime.list.php +++ b/pandora_console/godmode/agentes/planned_downtime.list.php @@ -907,7 +907,7 @@ if ($downtimes === false && $filter_performed === false) { __('Export to CSV'), 'csv_export', false, - 'location.href="godmode/agentes/planned_downtime.export_csv.php?'.$filter_params_str.'"', + 'blockResubmit($(this)); location.href=\'godmode/agentes/planned_downtime.export_csv.php?'.$filter_params_str.'\'', 'class="sub next"' ); echo ''; diff --git a/pandora_console/godmode/modules/manage_network_templates.php b/pandora_console/godmode/modules/manage_network_templates.php index 00dab888b2..aa9c8009fc 100644 --- a/pandora_console/godmode/modules/manage_network_templates.php +++ b/pandora_console/godmode/modules/manage_network_templates.php @@ -189,6 +189,8 @@ if ($export_profile) { } } + // Set cookie for download control. + setDownloadCookieToken(); // Send headers to tell the browser we're sending a file header('Content-type: application/octet-stream'); header('Content-Disposition: attachment; filename='.preg_replace('/\s/', '_', $profile_info['name']).'.csv'); @@ -285,7 +287,7 @@ foreach ($result as $row) { ] ); $data[3] = ''.html_print_image('images/cross.png', true, ['title' => __('Delete'), 'class' => 'invert_filter']).''; - $data[3] .= ''.html_print_image('images/csv.png', true, ['title' => __('Export to CSV'), 'class' => 'invert_filter']).''; + $data[3] .= ''.html_print_image('images/csv.png', true, ['title' => __('Export to CSV'), 'class' => 'invert_filter']).''; array_push($table->data, $data); } diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 60b1601dc0..5357bdad13 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -1055,7 +1055,7 @@ switch ($action) { ] ); $data[2] .= ''; - $data[3] = ''; + $data[3] = ''; $data[3] .= html_print_image( 'images/xml.png', true, diff --git a/pandora_console/include/class/Diagnostics.class.php b/pandora_console/include/class/Diagnostics.class.php index b8ca6e3690..a8f84f04be 100644 --- a/pandora_console/include/class/Diagnostics.class.php +++ b/pandora_console/include/class/Diagnostics.class.php @@ -141,8 +141,9 @@ class Diagnostics extends Wizard 'images/pdf.png', true, [ - 'title' => __('Export to PDF'), - 'class' => 'invert_filter', + 'title' => __('Export to PDF'), + 'class' => 'invert_filter', + 'onclick' => 'blockResubmit($(this))', ] ); $header_buttons = [ diff --git a/pandora_console/include/class/ModuleTemplates.class.php b/pandora_console/include/class/ModuleTemplates.class.php index ba67142560..782d3bb82d 100644 --- a/pandora_console/include/class/ModuleTemplates.class.php +++ b/pandora_console/include/class/ModuleTemplates.class.php @@ -506,6 +506,7 @@ class ModuleTemplates extends HTML header('Content-Disposition: attachment; filename='.preg_replace('/\s/', '_', $fileName).'.csv'); header('Pragma: no-cache'); header('Expires: 0'); + setDownloadCookieToken(); // Clean up output buffering while (@ob_end_clean()) { @@ -931,7 +932,7 @@ class ModuleTemplates extends HTML ] ); $data[3] = ''.html_print_image('images/cross.png', true, ['title' => __('Delete'), 'class' => 'invert_filter']).''; - $data[3] .= ''.html_print_image('images/csv.png', true, ['title' => __('Export to CSV'), 'class' => 'invert_filter']).''; + $data[3] .= ''.html_print_image('images/csv.png', true, ['title' => __('Export to CSV'), 'class' => 'invert_filter']).''; array_push($table->data, $data); } diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index ed999553cb..3ee1815e08 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -6269,3 +6269,24 @@ function arrayOutputSorting($sort, $sortField) } }; } + + +/** + * Get dowload started cookie from js and set ready cokkie for download ready comntrol. + * + * @return + */ +function setDownloadCookieToken() +{ + $download_cookie = get_cookie('downloadToken', false); + if ($download_cookie === false) { + return; + } else { + setcookie( + 'downloadReady', + $download_cookie, + (time() + 15), + '/' + ); + } +} diff --git a/pandora_console/include/functions_reporting_xml.php b/pandora_console/include/functions_reporting_xml.php index 196027e90c..9b733c40d3 100644 --- a/pandora_console/include/functions_reporting_xml.php +++ b/pandora_console/include/functions_reporting_xml.php @@ -46,6 +46,8 @@ function reporting_xml_get_report($report, $filename, $return=false) // Download if marked to download. if ($filename !== false) { + // Cookie for download control. + setDownloadCookieToken(); header('Content-Type: application/xml; charset=UTF-8'); header('Content-Disposition: attachment; filename="'.$filename.'.xml"'); } diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 49f1971867..f31d02b3c5 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -3540,6 +3540,11 @@ function ui_print_datatable(array $parameters) titleAttr: "'.__('Export current page to CSV').'", title: "export_'.$parameters['id'].'_current_page_'.date('Y-m-d').'", fieldSeparator: "'.$config['csv_divider'].'", + action: function ( e, dt, node, config ) { + blockResubmit(node); + // Call the default csvHtml5 action method to create the CSV file + $.fn.dataTable.ext.buttons.csvHtml5.action.call(this, e, dt, node, config); + }, exportOptions : { modifier : { // DataTables core @@ -3547,7 +3552,7 @@ function ui_print_datatable(array $parameters) page : "All", search : "applied" }'.$export_columns.' - } + }, } ] : [], lengthMenu: '.json_encode($pagination_options).', @@ -3671,6 +3676,16 @@ function ui_print_datatable(array $parameters) $js .= '$(".datatables_thead_tr").css("height", 0);'; } + if (isset($parameters['csv']) === true) { + $js."'$('#".$table_id."').on( 'buttons-processing', function ( e, indicator ) { + if ( indicator ) { + console.log('a'); + } + else { + console.log('b'); + }"; + } + $js .= '});'; $js .= ''; diff --git a/pandora_console/include/graphs/export_data.php b/pandora_console/include/graphs/export_data.php index a3c42577be..17b59b2baa 100644 --- a/pandora_console/include/graphs/export_data.php +++ b/pandora_console/include/graphs/export_data.php @@ -51,6 +51,9 @@ $default_filename = 'data_exported - '.date($config['date_format']); $filename = (string) get_parameter('filename', $default_filename); $filename = io_safe_output($filename); +// Set cookie for download control. +setDownloadCookieToken(); + /* * $data = array( * 'head' => array(,,...,), diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index 629e1a48f4..0b48540052 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -2716,6 +2716,7 @@ function pandoraFlotArea( $("#menu_export_csv_" + graph_id).click(function(e) { e.preventDefault(); + blockResubmit($(this)); plot.exportDataCSV(); var es_firefox = navigator.userAgent.toLowerCase().indexOf("firefox") > -1; diff --git a/pandora_console/include/javascript/buttons.html5.min.js b/pandora_console/include/javascript/buttons.html5.min.js index deee7fee68..c65fb2737a 100644 --- a/pandora_console/include/javascript/buttons.html5.min.js +++ b/pandora_console/include/javascript/buttons.html5.min.js @@ -5,31 +5,4 @@ FileSaver.js (1.3.3) - MIT license Copyright © 2016 Eli Grey - http://eligrey.com */ -(function(f){"function"===typeof define&&define.amd?define(["jquery","datatables.net","datatables.net-buttons"],function(g){return f(g,window,document)}):"object"===typeof exports?module.exports=function(g,p,z,t){g||(g=window);p&&p.fn.dataTable||(p=require("datatables.net")(g,p).$);p.fn.dataTable.Buttons||require("datatables.net-buttons")(g,p);return f(p,g,g.document,z,t)}:f(jQuery,window,document)})(function(f,g,p,z,t,w){function A(a){for(var b="";0<=a;)b=String.fromCharCode(a%26+65)+b,a=Math.floor(a/ -26)-1;return b}function E(a,b){y===w&&(y=-1===C.serializeToString(f.parseXML(F["xl/worksheets/sheet1.xml"])).indexOf("xmlns:r"));f.each(b,function(b,c){if(f.isPlainObject(c))b=a.folder(b),E(b,c);else{if(y){var d=c.childNodes[0],e,h=[];for(e=d.attributes.length-1;0<=e;e--){var m=d.attributes[e].nodeName;var k=d.attributes[e].nodeValue;-1!==m.indexOf(":")&&(h.push({name:m,value:k}),d.removeAttribute(m))}e=0;for(m=h.length;e'+c),c=c.replace(/_dt_b_namespace_token_/g,":"),c=c.replace(/xmlns:NS[\d]+="" NS[\d]+:/g,""));c=c.replace(/<([^<>]*?) xmlns=""([^<>]*?)>/g,"<$1 $2>");a.file(b,c)}})}function r(a,b,d){var c=a.createElement(b);d&&(d.attr&&f(c).attr(d.attr),d.children&&f.each(d.children,function(a,b){c.appendChild(b)}),null!==d.text&&d.text!==w&&c.appendChild(a.createTextNode(d.text))); -return c}function L(a,b){var d=a.header[b].length;a.footer&&a.footer[b].length>d&&(d=a.footer[b].length);for(var c=0,f=a.body.length;cd&&(d=e);if(401*a[1]?!0:!1};try{var C=new XMLSerializer,y}catch(a){}var F={"_rels/.rels":'', -"xl/_rels/workbook.xml.rels":'',"[Content_Types].xml":'', -"xl/workbook.xml":'', -"xl/worksheets/sheet1.xml":'',"xl/styles.xml":''}, -K=[{match:/^\-?\d+\.\d%$/,style:60,fmt:function(a){return a/100}},{match:/^\-?\d+\.?\d*%$/,style:56,fmt:function(a){return a/100}},{match:/^\-?\$[\d,]+.?\d*$/,style:57},{match:/^\-?£[\d,]+.?\d*$/,style:58},{match:/^\-?€[\d,]+.?\d*$/,style:59},{match:/^\-?\d+$/,style:65},{match:/^\-?\d+\.\d{2}$/,style:66},{match:/^\([\d,]+\)$/,style:61,fmt:function(a){return-1*a.replace(/[\(\)]/g,"")}},{match:/^\([\d,]+\.\d{2}\)$/,style:62,fmt:function(a){return-1*a.replace(/[\(\)]/g,"")}},{match:/^\-?[\d,]+$/,style:63}, -{match:/^\-?[\d,]+\.\d{2}$/,style:64}];v.ext.buttons.copyHtml5={className:"buttons-copy buttons-html5",text:function(a){return a.i18n("buttons.copy","Copy")},action:function(a,b,d,c){this.processing(!0);var g=this;a=I(b,c);var e=b.buttons.exportInfo(c),h=H(c),m=a.str;d=f("
").css({height:1,width:1,overflow:"hidden",position:"fixed",top:0,left:0});e.title&&(m=e.title+h+h+m);e.messageTop&&(m=e.messageTop+h+h+m);e.messageBottom&&(m=m+h+h+e.messageBottom);c.customize&&(m=c.customize(m,c,b));c=f("