Преглед изворни кода

Enhancement: provide some feedback to the end-user in case of a fatal error during an interactive export.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4276 a333f486-631f-4898-b8df-5754b55c2be0
dflaven пре 9 година
родитељ
комит
1aac2820ba
2 измењених фајлова са 28 додато и 2 уклоњено
  1. 19 2
      js/utils.js
  2. 9 0
      pages/ajax.render.php

+ 19 - 2
js/utils.js

@@ -538,8 +538,25 @@ function ExportStartExport()
 		oParams.query = $('#export-form :input[name=query]').val();		
 	}
 	$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', oParams, function(data) {
-		ExportRun(data);
-	}, 'json');
+		if (data == null)
+		{
+			ExportError('Export failed (no data provided), please contact your administrator');
+		}
+		else
+		{
+			ExportRun(data);			
+		}
+	}, 'json')
+	.fail(function() {
+		ExportError('Export failed, please contact your administrator');
+	});
+}
+
+function ExportError(sMessage)
+{
+	$('.export-message').html(sMessage);
+	$('.export-progress-bar').hide();
+	$('#export-btn').hide();	
 }
 		
 function ExportRun(data)

+ 9 - 0
pages/ajax.render.php

@@ -2066,6 +2066,15 @@ EOF
 		break;
 		
 		case 'export_build':
+		register_shutdown_function(function()
+		{
+			$aErr = error_get_last();
+			if (($aErr !== null) && ($aErr['type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR)))
+			{
+				ob_end_clean();
+				echo json_encode(array('code' => 'error', 'percentage' => 100, 'message' => Dict::Format('UI:Error_Details', $aErr['message'])));
+			}
+		});
 		try
 		{
 			$token = utils::ReadParam('token', null);