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.
diff --git a/ui/scripts/plugins.js b/ui/scripts/plugins.js
index f40d0fa..b83dffe 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'