From 9260dae493a9e18a3b4887407bf7ad9aaccb2aa8 Mon Sep 17 00:00:00 2001 From: nathangray Date: Mon, 4 Jul 2016 12:49:47 -0600 Subject: [PATCH] Add totals (selected, successful, skipped, failed) to long task dialog --- api/js/etemplate/et2_widget_dialog.js | 19 +++++++++++++++++++ api/lang/egw_en.lang | 1 + api/templates/default/long_task.xet | 1 + 3 files changed, 21 insertions(+) diff --git a/api/js/etemplate/et2_widget_dialog.js b/api/js/etemplate/et2_widget_dialog.js index 599af10b68..edfe6a153b 100644 --- a/api/js/etemplate/et2_widget_dialog.js +++ b/api/js/etemplate/et2_widget_dialog.js @@ -724,6 +724,12 @@ jQuery.extend(et2_dialog, //(function(){ "use strict"; return var log = null; var progressbar = null; var cancel = false; + var totals = { + success: 0, + skipped: 0, + failed: 0, + widget: null + }; // Updates progressbar & log, calls next step var update = function(response) { @@ -731,6 +737,7 @@ jQuery.extend(et2_dialog, //(function(){ "use strict"; return var index = this || 0; progressbar.set_value(100*(index/_list.length)); + progressbar.set_label(index +' / ' + _list.length); // Display response information switch(response.type) @@ -740,6 +747,8 @@ jQuery.extend(et2_dialog, //(function(){ "use strict"; return .text(response.data) .appendTo(log); + totals.failed++ + // Ask to retry / ignore / abort et2_createWidget("dialog", { callback:function(button) { @@ -750,6 +759,7 @@ jQuery.extend(et2_dialog, //(function(){ "use strict"; return return update.call(index,''); case 'dialog[skip]': // Continue with next index + totals.skipped++; return update.call(index,''); default: // Try again with previous index @@ -772,6 +782,7 @@ jQuery.extend(et2_dialog, //(function(){ "use strict"; return default: if(response) { + totals.success++; log.append("
"+response+"
"); } } @@ -779,6 +790,12 @@ jQuery.extend(et2_dialog, //(function(){ "use strict"; return var height = log[0].scrollHeight; log.scrollTop(height); + // Update totals + totals.widget.set_value(egw.lang( + "Total: %1 Successful: %2 Failed: %3 Skipped: %4", + _list.length, totals.success, totals.failed, totals.skipped + )); + // Fire next step if(!cancel && index < _list.length) { @@ -806,6 +823,8 @@ jQuery.extend(et2_dialog, //(function(){ "use strict"; return // Get access to template widgets log = jQuery(dialog.template.widgetContainer.getWidgetById('log').getDOMNode()); progressbar = dialog.template.widgetContainer.getWidgetById('progressbar'); + progressbar.set_label('0 / ' + _list.length); + totals.widget = dialog.template.widgetContainer.getWidgetById('totals'); // Start window.setTimeout(function() {update.call(0,'');},0); diff --git a/api/lang/egw_en.lang b/api/lang/egw_en.lang index 4dd64857dd..0cbf9c93f8 100644 --- a/api/lang/egw_en.lang +++ b/api/lang/egw_en.lang @@ -1312,6 +1312,7 @@ tonga common en TONGA too many unsucessful attempts to login: %1 for the user '%2', %3 for the ip %4 common en Too many unsuccessful attempts to log in: %1 for the user '%2', %3 for the IP %4 top common en Top total common en Total +total: %1 successful: %2 failed: %3 skipped: %4 common en Total: %1 Successful: %2 Failed: %3 Skipped: %4 transparant bg for the icons? common en Transparant bg for the icons tree common en Tree trinidad and tobago common en TRINIDAD AND TOBAGO diff --git a/api/templates/default/long_task.xet b/api/templates/default/long_task.xet index baa678793c..445f4a4a09 100644 --- a/api/templates/default/long_task.xet +++ b/api/templates/default/long_task.xet @@ -8,6 +8,7 @@