From 77ee3cedd51be540600afa72126d5410606eb39c Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Thu, 8 Dec 2011 16:28:32 -0800 Subject: [PATCH] Clean up UI error handling Restore error messages for widgets -- as the default error handler will be overridden if an error fn is specified, thus rendering no message --- ui/scripts/sharedFunctions.js | 1 - ui/scripts/ui-custom/instanceWizard.js | 6 +++--- ui/scripts/ui-custom/zoneWizard.js | 6 +++--- ui/scripts/ui/widgets/listView.js | 12 ++++++------ ui/scripts/ui/widgets/notifications.js | 6 +++--- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/ui/scripts/sharedFunctions.js b/ui/scripts/sharedFunctions.js index 0d0daf1c757..917e3a5eb12 100644 --- a/ui/scripts/sharedFunctions.js +++ b/ui/scripts/sharedFunctions.js @@ -59,7 +59,6 @@ var pollAsyncJobResult = function(args) { else if (result.jobstatus == 2) { // Failed var msg = (result.jobresult.errortext == null)? "": result.jobresult.errortext; args.error({message: msg}); - cloudStack.dialog.notice({ message: msg }); } } }, diff --git a/ui/scripts/ui-custom/instanceWizard.js b/ui/scripts/ui-custom/instanceWizard.js index 672b8dcafab..bc6523e97a3 100644 --- a/ui/scripts/ui-custom/instanceWizard.js +++ b/ui/scripts/ui-custom/instanceWizard.js @@ -49,12 +49,12 @@ close(); }, - error: function(args) { + error: function(message) { $wizard.remove(); $('div.overlay').remove(); - if (args.message) { - //cloudStack.dialog.notice({ message: args.message }); + if (message) { + cloudStack.dialog.notice({ message: message }); } } } diff --git a/ui/scripts/ui-custom/zoneWizard.js b/ui/scripts/ui-custom/zoneWizard.js index 5a39cc28613..82695ef8244 100644 --- a/ui/scripts/ui-custom/zoneWizard.js +++ b/ui/scripts/ui-custom/zoneWizard.js @@ -37,12 +37,12 @@ close(); }, - error: function(args) { + error: function(message) { $wizard.remove(); $('div.overlay').remove(); - if (args.message) { - //cloudStack.dialog.notice({ message: args.message }); + if (message) { + cloudStack.dialog.notice({ message: message }); } } } diff --git a/ui/scripts/ui/widgets/listView.js b/ui/scripts/ui/widgets/listView.js index 6d0e7a7b8ba..dcd1a3392fc 100644 --- a/ui/scripts/ui/widgets/listView.js +++ b/ui/scripts/ui/widgets/listView.js @@ -220,9 +220,9 @@ } ); }, - error: function(data){ - // if (data.message) - // cloudStack.dialog.notice({ message: data.message }); + error: function(message){ + if (message) + cloudStack.dialog.notice({ message: message }); } } }; @@ -372,9 +372,9 @@ if (options.success) options.success(args); }, - error: function(args) { - if (args.message) { - //cloudStack.dialog.notice({ message: args.message }); + error: function(message) { + if (message) { + cloudStack.dialog.notice({ message: message }); $edit.hide(), $label.html(oldVal).fadeIn(); $instanceRow.closest('div.data-table').dataTable('refresh'); diff --git a/ui/scripts/ui/widgets/notifications.js b/ui/scripts/ui/widgets/notifications.js index 9e3510a8457..08b5dc48aba 100644 --- a/ui/scripts/ui/widgets/notifications.js +++ b/ui/scripts/ui/widgets/notifications.js @@ -1,4 +1,4 @@ -(function($) { +(function($, cloudStack) { /** * Notification handling */ @@ -89,7 +89,7 @@ incomplete: function(args) {}, error: function(args) { if (args.message) { - //cloudStack.dialog.notice({ message: args.message }); + cloudStack.dialog.notice({ message: args.message }); } clearInterval(pollTimer); @@ -287,4 +287,4 @@ if ($popup.size()) notifications.popup.reposition($popup, $popup.data('notifications-attach-to')); }); -})(window.jQuery); +})(window.jQuery, cloudStack);