cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [17/23] git commit: updated refs/heads/master to fc08c23
Date Fri, 19 Apr 2013 17:28:06 GMT
Project selector UI functionality


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/d529eba9
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/d529eba9
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/d529eba9

Branch: refs/heads/master
Commit: d529eba941f626d458d1e08bad860e97797d90fa
Parents: a748988
Author: Brian Federle <brian.federle@citrix.com>
Authored: Tue Apr 16 11:44:00 2013 -0700
Committer: Brian Federle <brian.federle@citrix.com>
Committed: Tue Apr 16 11:44:00 2013 -0700

----------------------------------------------------------------------
 ui/scripts/ui-custom/projectSelect.js |   38 ++++++++++++++++++++++++++-
 ui/scripts/ui-custom/projects.js      |    6 +++-
 2 files changed, 41 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d529eba9/ui/scripts/ui-custom/projectSelect.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui-custom/projectSelect.js b/ui/scripts/ui-custom/projectSelect.js
index f93fefc..82d02c1 100644
--- a/ui/scripts/ui-custom/projectSelect.js
+++ b/ui/scripts/ui-custom/projectSelect.js
@@ -20,13 +20,47 @@
     var $header = $('#header .controls');
     var $projectSwitcher = $('<div>').addClass('project-switcher');
     var $projectSelect = $('<select>').append(
-      $('<option>').attr('value', 'basic').html(_l('Project 1')),
-      $('<option>').attr('value', 'advanced').html(_l('Project 2'))
+      $('<option>').attr('value', '-1').html(_l('Default view'))
     );
     var $label = $('<label>').html('Project:');
 
+    // Get project list
+    cloudStack.projects.dataProvider({
+      context: cloudStack.context,
+      response: {
+        success: function(args) {
+          var projects = args.data;
+
+          $(projects).map(function(index, project) {
+            var $option = $('<option>').val(project.id);
+
+            $option.html(project.displaytext ? project.displaytext : project.name);
+            $option.appendTo($projectSelect);
+          });
+        },
+        error: function() {}
+      }
+    });
+
     $projectSwitcher.append($label, $projectSelect);
     $projectSwitcher.insertBefore($header.find('.region-switcher'));
+
+    // Change project event
+    $projectSelect.change(function() {
+      var projectID = $projectSelect.val();
+
+      if (projectID != -1) {
+        cloudStack.context.projects = [{
+          id: projectID
+        }];
+
+        cloudStack.uiCustom.projects({ alreadySelected: true });
+      } else {
+        cloudStack.context.projects = null;
+        $('#cloudStack3-container').removeClass('project-view');
+        $('#navigation li.dashboard').click();
+      }
+    });
   });
 }(jQuery, cloudStack));      
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d529eba9/ui/scripts/ui-custom/projects.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui-custom/projects.js b/ui/scripts/ui-custom/projects.js
index 117c433..82abadd 100644
--- a/ui/scripts/ui-custom/projects.js
+++ b/ui/scripts/ui-custom/projects.js
@@ -728,7 +728,11 @@
     };
     $dashboardNavItem.bind('click', event);
 
-    pageElems.selector(args);
+    if (args.alreadySelected) {
+      showDashboard();
+    } else {
+      pageElems.selector(args);
+    }
   };
 
   /**


Mime
View raw message