UI plugins API: addSection method Adds 'addSection' method to UI plugins, which will add a new top-level section. It follows the same syntax used by the existing sections in the UI.
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/1a3ea282 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/1a3ea282 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/1a3ea282 Branch: refs/heads/master Commit: 1a3ea282437d17d2ecd7b3b5feb4dac30adc290b Parents: 977123b Author: Brian Federle <[email protected]> Authored: Thu Dec 20 13:27:37 2012 -0800 Committer: Brian Federle <[email protected]> Committed: Thu Dec 20 13:27:37 2012 -0800 ---------------------------------------------------------------------- ui/plugins/testPlugin/testPlugin.js | 13 ++++++++++--- ui/scripts/plugins.js | 15 ++++++++++----- 2 files changed, 20 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1a3ea282/ui/plugins/testPlugin/testPlugin.js ---------------------------------------------------------------------- diff --git a/ui/plugins/testPlugin/testPlugin.js b/ui/plugins/testPlugin/testPlugin.js index 4539924..abb4813 100644 --- a/ui/plugins/testPlugin/testPlugin.js +++ b/ui/plugins/testPlugin/testPlugin.js @@ -1,7 +1,14 @@ (function (cloudStack) { cloudStack.plugins.testPlugin = function(plugin) { - // - // Plugin code goes here - // + plugin.ui.addSection({ + id: 'testPlugin', + title: 'TestPlugin', + preFilter: function(args) { + return isAdmin(); + }, + show: function() { + return $('<div>').html('Test plugin section'); + } + }); }; }(cloudStack)); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1a3ea282/ui/scripts/plugins.js ---------------------------------------------------------------------- diff --git a/ui/scripts/plugins.js b/ui/scripts/plugins.js index 250d507..5cc3185 100644 --- a/ui/scripts/plugins.js +++ b/ui/scripts/plugins.js @@ -1,4 +1,13 @@ (function($, cloudStack, require) { + var pluginAPI = { + addSection: function(section) { + cloudStack.sections[section.id] = section; + }, + extend: function(obj) { + $.extend(true, cloudStack, obj); + } + }; + cloudStack.sections.plugins = { title: 'Plugins', show: cloudStack.uiCustom.plugins @@ -15,11 +24,7 @@ // Execute plugin cloudStack.plugins[pluginID]({ - ui: { - extend: function(obj) { - $.extend(true, cloudStack, obj); - } - } + ui: pluginAPI }); }); });
