From 81007ff38578588906737df3082b42fb7f2ee011 Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Mon, 27 Aug 2012 10:57:47 +0200 Subject: Successful action notification User was not notified about success of actions executed from action list, action panel or facet cotrol bar. This patch adds IPA.notify_success(message) call. It creates a yellow notification area with supplied message in Web UI header in the middle of the green area (empty space of first level navigation). This area is displayed for 3s and then it fades out (800ms). It also fades out when it is clicked. This call is used(directly or indirectly) in: * search facets: delete, disable, enable actions * details facets: delete action * user details facet: reset password action * host details facet: unprovision, set OTP actions * service details facet: unprovision action * host and service details facet: request, revoke, restore certificates actions * group details facet: change to POSIX/external actions * dns zone details facet: add/remove permission actions https://fedorahosted.org/freeipa/ticket/2977 --- install/ui/search.js | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) (limited to 'install/ui/search.js') diff --git a/install/ui/search.js b/install/ui/search.js index 2c30b5b7..154d7ffa 100644 --- a/install/ui/search.js +++ b/install/ui/search.js @@ -308,10 +308,11 @@ IPA.search_deleter_dialog = function(spec) { var batch = that.create_command(); - batch.on_success = function() { + batch.on_success = function(data, text_status, xhr) { that.facet.refresh(); that.facet.on_update.notify([],that.facet); that.close(); + IPA.notify_success(IPA.messages.search.deleted); }; batch.on_error = function() { @@ -414,13 +415,14 @@ IPA.batch_items_action = function(spec) { var that = IPA.action(spec); that.method = spec.method || 'disable'; + that.success_msg = spec.success_msg; - that.execute = function(facet, on_success, on_error) { + that.execute_action = function(facet, on_success, on_error) { var entity = facet.managed_entity; var pkeys = facet.get_selected_values(); - var batch = IPA.batch_command({ + that.batch = IPA.batch_command({ name: entity.name + '_batch_'+ that.method, on_success: that.get_on_success(facet, on_success) }); @@ -434,15 +436,21 @@ IPA.batch_items_action = function(spec) { args: [pkey] }); - batch.add_command(command); + that.batch.add_command(command); } - batch.execute(); + that.batch.execute(); }; that.on_success = function(facet, data, text_status, xhr) { facet.on_update.notify(); facet.refresh(); + + if (that.success_msg) { + var succeeded = that.batch.commands.length - that.batch.errors.errors.length; + var msg = that.success_msg.replace('${count}', succeeded); + IPA.notify_success(msg); + } }; that.get_on_success = function(facet, on_success) { @@ -455,3 +463,29 @@ IPA.batch_items_action = function(spec) { return that; }; + +IPA.batch_disable_action = function(spec) { + + spec = spec || {}; + + spec.name = spec.name || 'disable'; + spec.method = spec.method || 'disable'; + spec.needs_confirm = spec.needs_confirm === undefined ? true : spec.needs_confirm; + spec.enable_cond = spec.enable_cond || ['item-selected']; + spec.success_msg = spec.success_msg || IPA.messages.search.disabled; + + return IPA.batch_items_action(spec); +}; + +IPA.batch_enable_action = function(spec) { + + spec = spec || {}; + + spec.name = spec.name || 'enable'; + spec.method = spec.method || 'enable'; + spec.needs_confirm = spec.needs_confirm === undefined ? true : spec.needs_confirm; + spec.enable_cond = spec.enable_cond || ['item-selected']; + spec.success_msg = spec.success_msg || IPA.messages.search.enabled; + + return IPA.batch_items_action(spec); +}; \ No newline at end of file -- cgit