From eabea789be4a45dc9040cc8573dcb4b14041be35 Mon Sep 17 00:00:00 2001 From: will Date: Tue, 21 Dec 2010 17:52:20 -0800 Subject: [PATCH] bug 7638: Added deep link support for the UI. Only support values are "instance", "volume", and "ip" for now as indicated in the bug. Use lp=instance, lp=volume, or lp=storage --- ui/scripts/cloud.core.init.js | 28 ++++++++++++++++++++++++---- ui/scripts/cloud.core.js | 2 ++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/ui/scripts/cloud.core.init.js b/ui/scripts/cloud.core.init.js index 299455c7842..0b36e76d65f 100644 --- a/ui/scripts/cloud.core.init.js +++ b/ui/scripts/cloud.core.init.js @@ -17,6 +17,26 @@ */ $(document).ready(function() { + function initUI() { + var context = $.urlParam('lp'); + if (context != null) { + if (context == 'instance') { + $("#leftmenu_instances").click(); + $("#leftmenu_instances_my_instances").click(); + } else if (context == 'volume') { + $("#leftmenu_storage").click(); + $("#leftmenu_volume").click(); + } else if (context == 'ip') { + $("#leftmenu_network").click(); + $("#leftmenu_ip").click(); + } else { + $("#leftmenu_dashboard").click(); + } + } else { + $("#leftmenu_dashboard").click(); + } + } + $(".leftmenu_content_flevel").hover( function() { $(this).find(".leftmenu_arrows_firstlevel_open").show(); @@ -597,9 +617,9 @@ $(document).ready(function() { $("#main_username").text(g_username); $("#login_wrapper").hide(); - showLeftNavigationBasedOnRole(); + showLeftNavigationBasedOnRole(); + initUI(); $("#main").show(); - $("#leftmenu_dashboard").click(); }, error: function() { $("#account_password").val(""); @@ -672,8 +692,8 @@ $(document).ready(function() { success: function(json) { buildSecondLevelNavigation(); $("#main_username").text(g_username); - $("#leftmenu_dashboard").click(); - showLeftNavigationBasedOnRole(); + showLeftNavigationBasedOnRole(); + initUI(); $("#main").show(); }, error: function(xmlHTTP) { diff --git a/ui/scripts/cloud.core.js b/ui/scripts/cloud.core.js index 74830a50e32..f23a7cb7e57 100644 --- a/ui/scripts/cloud.core.js +++ b/ui/scripts/cloud.core.js @@ -15,6 +15,8 @@ * along with this program. If not, see . * */ + + $.urlParam = function(name){ var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href); if (!results) { return 0; } return results[1] || 0;} //***** actions for a tab in right panel (begin) ************************************************************************ function buildActionLinkForTab(label, actionMap, $actionMenu, $midmenuItem1, $thisTab) {