From 5b8e4b9fd9b00276b2fb29e3e4f41da217c40f87 Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Tue, 12 Feb 2013 15:21:29 -0800 Subject: [PATCH] UI Plugin API: Implement 'apiCall' helper Adds a helper method to standardize how plugin writers handle server calls, without having to directly invoke jQuery.ajax. It will correctly sanitize data and ensure all required parameters (e.g., session key data) are passed. --- ui/scripts/plugins.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ui/scripts/plugins.js b/ui/scripts/plugins.js index f40d0fa7b17..b83dffe8c5d 100644 --- a/ui/scripts/plugins.js +++ b/ui/scripts/plugins.js @@ -12,6 +12,15 @@ }; var pluginAPI = { + apiCall: function(command, args) { + $.ajax({ + url: createURL(command), + success: args.success, + error: function(json) { + args.error(parseXMLHttpResponse(json)); + } + }) + }, addSection: function(section) { cloudStack.sections[section.id] = $.extend(section, { customIcon: 'plugins/' + section.id + '/icon.png'