Skip to content
Browse files

add vpc filter

  • Loading branch information...
1 parent e32fba5 commit c04d56fd238eda191b16805a48b1f4936bba6be1 @winebarrel winebarrel committed May 6, 2012
Showing with 26 additions and 4 deletions.
  1. +6 −2 ec2ui/content/ec2ui/security_groups_tab_overlay.xul
  2. +20 −2 ec2ui/content/ec2ui/securitygroupsview.js
View
8 ec2ui/content/ec2ui/security_groups_tab_overlay.xul
@@ -37,8 +37,12 @@
tooltiptext="&ec2ui.secgroups.delete.tip;"
oncommand="ec2ui_SecurityGroupsTreeView.deleteSelected();" />
<toolbarseparator />
- <checkbox id="ec2ui.securitygroups.onlyvpc" label="Only VPC"
- checked="false" oncommand="ec2ui_SecurityGroupsTreeView.invalidate();"/>
+ <menulist id="ec2ui.securitygroups.vpcmenu" selectedIndex="0" oncommand="ec2ui_SecurityGroupsTreeView.invalidate();">
+ <menupopup>
+ <menuitem label="All Instances" value="all"/>
+ <menuitem label="No VPC" value="no-vpc" />
+ </menupopup>
+ </menulist>
</hbox>
</toolbar>
<!--
View
22 ec2ui/content/ec2ui/securitygroupsview.js
@@ -86,7 +86,8 @@ var ec2ui_SecurityGroupsTreeView = {
filterGroups : function(groups) {
var searchText = (document.getElementById('ec2ui.securitygroups.search').value || '').trim();
- var filterVpc = document.getElementById("ec2ui.securitygroups.onlyvpc").checked;
+ var vpcMenu = document.getElementById("ec2ui.securitygroups.vpcmenu");
+ var filterVpc = (vpcMenu.selectedItem.value == 'all') ? false : vpcMenu.selectedItem.value;
if (searchText.length == 0 && !filterVpc) {
return groups;
@@ -99,7 +100,7 @@ var ec2ui_SecurityGroupsTreeView = {
for(var i in groups) {
grp = groups[i];
- if (filterVpc && !grp.vpcId) {
+ if (filterVpc && !((filterVpc == 'no-vpc' && !grp.vpcId) || (filterVpc == grp.vpcId))) {
continue;
}
@@ -118,6 +119,23 @@ var ec2ui_SecurityGroupsTreeView = {
notifyModelChanged: function(interest) {
this.invalidate();
+ this.refreshVpcMenu();
+ },
+
+ refreshVpcMenu: function() {
+ var vpcs = ec2ui_session.model.getVpcs();
+ var vpcMenu = document.getElementById("ec2ui.securitygroups.vpcmenu");
+ if (!vpcs || !vpcMenu) { return; }
+
+ var count = vpcMenu.itemCount;
+
+ for(var i = count - 1; i >= 2; i--) {
+ vpcMenu.removeItemAt(i);
+ }
+
+ for (var i in vpcs) {
+ vpcMenu.appendItem(vpcs[i].id + (vpcs[i].tag == null ? '' : " [" + vpcs[i].tag + "]"), vpcs[i].id);
+ }
},
getSelectedGroup : function() {

0 comments on commit c04d56f

Please sign in to comment.
Something went wrong with that request. Please try again.