Permalink
Browse files

add vpc filter

  • Loading branch information...
1 parent eddedc5 commit 9245c994bcb2e0462ddea8e9f8107af95af43777 @winebarrel winebarrel committed May 6, 2012
Showing with 27 additions and 4 deletions.
  1. +6 −2 ec2ui/content/ec2ui/instances_tab_overlay.xul
  2. +21 −2 ec2ui/content/ec2ui/instancesview.js
@@ -143,8 +143,12 @@
checked="false" oncommand="ec2ui_InstancesTreeView.invalidate();"/>
<checkbox id="ec2ui.instances.nostopped" label="Hide Stopped"
checked="false" oncommand="ec2ui_InstancesTreeView.invalidate();"/>
- <checkbox id="ec2ui.instances.onlyvpc" label="Only VPC"
- checked="false" oncommand="ec2ui_InstancesTreeView.invalidate();"/>
+ <menulist id="ec2ui.instances.vpcmenu" selectedIndex="0" oncommand="ec2ui_InstancesTreeView.invalidate();">
+ <menupopup>
+ <menuitem label="All Instances" value="all"/>
+ <menuitem label="No VPC" value="no-vpc" />
+ </menupopup>
+ </menulist>
</hbox>
</toolbar>
@@ -189,7 +189,9 @@ var ec2ui_InstancesTreeView = {
var searchText = this.getSearchText();
var filterTerm = document.getElementById("ec2ui.instances.noterminated").checked;
var filterStop = document.getElementById("ec2ui.instances.nostopped").checked;
- var filterVpc = document.getElementById("ec2ui.instances.onlyvpc").checked;
+ var vpcMenu = document.getElementById("ec2ui.instances.vpcmenu");
+ var filterVpc = (vpcMenu.selectedItem.value == 'all') ? false : vpcMenu.selectedItem.value;
+
if (searchText.length == 0 &&
!(filterTerm || filterStop || filterVpc)) {
return instances;
@@ -208,7 +210,7 @@ var ec2ui_InstancesTreeView = {
inst.state == "stopped") {
continue;
}
- if (filterVpc && !inst.vpcId) {
+ if (filterVpc && !((filterVpc == 'no-vpc' && !inst.vpcId) || (filterVpc == inst.vpcId))) {
continue;
}
if (inst.id.match(this.instanceIdRegex) &&
@@ -819,6 +821,23 @@ var ec2ui_InstancesTreeView = {
notifyModelChanged: function(interest) {
this.invalidate();
+ this.refreshVpcMenu();
+ },
+
+ refreshVpcMenu: function() {
+ var vpcs = ec2ui_session.model.getVpcs();
+ var vpcMenu = document.getElementById("ec2ui.instances.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].cidr + ")" + (vpcs[i].tag == null ? '' : " [" + vpcs[i].tag + "]"), vpcs[i].id);
+ }
},
enableOrDisableItems : function(event) {

0 comments on commit 9245c99

Please sign in to comment.