Commit 34325298 authored by Matt Strum's avatar Matt Strum
Browse files

Ready to add different views for the map based on user or general resources and slices

parent 68bbc562
......@@ -37,10 +37,14 @@
public var console:ConsoleWindow;
public var rspecView:XmlWindow;
public var about:AboutWindow = new AboutWindow();
[Bindable]
public var pgHandler:ProtoGeniHandler;
[Bindable]
public var slicesMenu : ArrayCollection;
public var main:Main;
//------------------------------------------
......@@ -66,6 +70,11 @@
chooseCMWindow = new ChooseComponentManagerWindow();
chooseCMWindow.main = this;
}
public function showAbout():void {
PopUpManager.addPopUp(about, this, false);
PopUpManager.centerPopUp(about);
}
//------------------------------------------
// Component Manager
......@@ -115,6 +124,15 @@
}
}
// ComboBox
public function fillCombobox():void {
slicesMenu = pgHandler.CurrentUser.displaySlices();
}
public function getSliceLabel(s : Slice):String {
return s.DisplayString();
}
// Google maps
private function onMapPreinitialize(event:Event):void {
var myMapOptions:MapOptions = new MapOptions();
......@@ -192,7 +210,7 @@
click="viewRspec()"
toolTip="View the most recent RSpec"/>
<mx:VRule height="14"/>
<mx:ComboBox id="slicesCombobox"></mx:ComboBox>
<mx:ComboBox id="slicesCombobox" dataProvider="{slicesMenu}" labelFunction="getSliceLabel"></mx:ComboBox>
<mx:CheckBox label="Only my resources" id="onlyMyResourcesCheckbox"/>
<mx:Spacer width="100%"/>
<mx:Label text="Initialized" id="progressLabel" fontStyle="normal" fontWeight="bold"/>
......@@ -200,7 +218,7 @@
<mx:Spacer width="100%"/>
<pgmap:ImageButton id="infoButton"
source="@Embed('../images/information.png')"
click="viewInformation()"
click="showAbout()"
toolTip="View more information" />
<pgmap:ImageButton id="fullscreenButton"
source="@Embed('../images/arrow_out.png')"
......
......@@ -13,6 +13,12 @@ package pgmap
public static var failColor:String = "#FE0000";
public static var waitColor:String = "#FF7F00";
public static var hideColor:Object = 0xCCCCCC;
public static var linkColor:Object = 0xFFCFD1;
public static var linkBorderColor:Object = 0xFF00FF;
public static var nodeColor:Object = 0x092B9F;
public static var nodeBorderColor:Object = 0xD2E1F0;
[Bindable]
[Embed(source="../../images/tick.png")]
public static var availableIcon:Class;
......@@ -29,6 +35,22 @@ package pgmap
[Embed(source="../../images/link.png")]
public static var linkIcon:Class;
[Bindable]
[Embed(source="../../images/flag_green.png")]
public static var flagGreenIcon:Class;
[Bindable]
[Embed(source="../../images/flag_red.png")]
public static var flagRedIcon:Class;
[Bindable]
[Embed(source="../../images/flag_yellow.png")]
public static var flagYellowIcon:Class;
[Bindable]
[Embed(source="../../images/error.png")]
public static var errorIcon:Class;
public static function assignIcon(val:Boolean):Class {
if (val)
return availableIcon;
......
......@@ -19,9 +19,6 @@
[Bindable]
public var links:ArrayCollection;
[Bindable]
public var link:Link = null;
public var main:pgmap;
public function loadCollection(group:ArrayCollection):void {
......@@ -32,109 +29,22 @@
} else {
listLinks.visible = false;
listLinks.includeInLayout = false;
nodeInfoHolder.percentWidth = 100;
linkInfo.percentWidth = 100;
title = "Link Information";
}
loadLink(links[0]);
linkInfo.load(links[0]);
}
public function loadGroup(group:LinkGroup):void {
loadCollection(group.collection);
}
public function loadLink(l:Link):void {
link = l;
txtBandwidth.text = Common.kbsToString(l.bandwidth);
interface1Button.setStyle("icon",Common.assignAvailabilityIcon(l.interface1.owner));
interface2Button.setStyle("icon",Common.assignAvailabilityIcon(l.interface2.owner));
}
public function viewRspec():void {
var rspecView:XmlWindow = new XmlWindow();
PopUpManager.addPopUp(rspecView, main, false);
PopUpManager.centerPopUp(rspecView);
rspecView.loadXml(link.rspec);
}
]]>
</mx:Script>
<mx:HDividedBox width="100%" height="100%">
<mx:List width="35%" height="100%" id="listLinks"
dataProvider="{links}"
labelField="name" change="loadLink(event.target.selectedItem)"></mx:List>
<mx:VBox height="100%" width="65%" verticalGap="0" paddingTop="0" paddingRight="0" paddingLeft="0" paddingBottom="0" horizontalGap="0" id="nodeInfoHolder">
<mx:Grid width="100%" height="100%" verticalGap="2" horizontalGap="2">
<mx:GridRow width="100%">
<mx:GridItem rowSpan="2">
<mx:Button label="RSPEC" width="100%" height="100%" click="viewRspec()"/>
</mx:GridItem>
<mx:GridItem width="100%">
<mx:Label text="{link.name}" fontSize="17" fontWeight="bold"/>
</mx:GridItem>
</mx:GridRow>
<mx:GridRow width="100%">
<mx:GridItem width="100%">
<mx:Label text="Bandwidth" fontWeight="bold"/>
<mx:Label id="txtBandwidth"/>
<mx:VRule height="16"/>
<mx:Label text="Latency" fontWeight="bold"/>
<mx:Label text="{link.latency}"/>
<mx:VRule height="16"/>
<mx:Label text="Packet Loss" fontWeight="bold"/>
<mx:Label text="{link.packetLoss}"/>
</mx:GridItem>
</mx:GridRow>
<mx:GridRow width="100%">
<mx:GridItem>
<mx:Label text="UUID" fontWeight="bold"/>
</mx:GridItem>
<mx:GridItem width="100%">
<mx:Label text="{link.uuid}"/>
</mx:GridItem>
</mx:GridRow>
<mx:GridRow width="100%">
<mx:GridItem>
<mx:Label text="Manager" fontWeight="bold"/>
</mx:GridItem>
<mx:GridItem width="100%">
<mx:Label text="{link.manager}"/>
</mx:GridItem>
</mx:GridRow>
<mx:GridRow width="100%">
<mx:GridItem>
<mx:VBox horizontalAlign="right" width="100%">
<mx:Label text="Connects" fontWeight="bold"/>
</mx:VBox>
</mx:GridItem>
<mx:GridItem width="100%">
<mx:VBox width="100%">
<mx:Button id="interface1Button" label="{link.interface1.owner.name}" click="Common.viewNode(link.interface1.owner);"/>
<mx:Label text="on {link.interface1.id}"/>
</mx:VBox>
</mx:GridItem>
</mx:GridRow>
<mx:GridRow width="100%">
<mx:GridItem>
<mx:VBox horizontalAlign="right" width="100%">
<mx:Label text="to" fontWeight="bold"/>
</mx:VBox>
</mx:GridItem>
<mx:GridItem width="100%">
<mx:VBox width="100%">
<mx:Button id="interface2Button" label="{link.interface2.owner.name}" click="Common.viewNode(link.interface2.owner);"/>
<mx:Label text="on {link.interface2.id}"/>
</mx:VBox>
</mx:GridItem>
</mx:GridRow>
<mx:GridRow width="100%" height="100%">
<mx:GridItem>
<mx:Label text="Types" fontWeight="bold"/>
</mx:GridItem>
<mx:GridItem width="100%">
<mx:List width="100%" height="100%" id="listNodes" dataProvider="{link.types}"></mx:List>
</mx:GridItem>
</mx:GridRow>
</mx:Grid>
</mx:VBox>
labelField="name" change="linkInfo.load(event.target.selectedItem)"></mx:List>
<LinkAdvancedInformation height="100%" width="65%" verticalGap="0" paddingTop="0" paddingRight="0" paddingLeft="0" paddingBottom="0" horizontalGap="0" id="linkInfo"/>
</mx:HDividedBox>
</ResizeWindow>
......@@ -21,9 +21,6 @@
[Bindable]
public var nodes:ArrayCollection;
[Bindable]
public var node:Node = null;
[Bindable]
public var linkedNodes:ArrayCollection = new ArrayCollection();
......@@ -38,11 +35,11 @@
} else {
listNodes.visible = false;
listNodes.includeInLayout = false;
nodeInfoHolder.percentWidth = 100;
nodeInfo.percentWidth = 100;
title = "Node Information";
}
loadNode(nodes[0]);
nodeInfo.load(nodes[0]);
}
public function loadGroup(group:NodeGroup):void {
......@@ -50,120 +47,6 @@
title = group.city + " Node";
loadCollection(group.collection);
}
public function loadNode(n:Node):void {
node = n;
imgAvailable.source = Common.assignAvailabilityIcon(n);
imgExclusive.source = Common.assignIcon(n.exclusive);
linksEndpointVbox.removeAllChildren();
linksStartpointVbox.removeAllChildren();
var endpointArray:ArrayCollection = new ArrayCollection();
var startpointArray:ArrayCollection = new ArrayCollection();
for each(var i:NodeInterface in n.interfaces.collection) {
for each(var l:Link in i.links) {
var n:Node;
var iEnd:NodeInterface;
var iStart:NodeInterface;
if(l.interface1 == i) {
n = l.interface2.owner;
iEnd = l.interface2;
iStart = l.interface1;
} else {
n = l.interface1.owner;
iEnd = l.interface1;
iStart = l.interface2;
}
// Build up endpoint
var nodeFound:Boolean = false;
for each(var na:Object in endpointArray) {
if(na.node == n) {
nodeFound = true;
na.links.addItem({i: iEnd, l: l});
break;
}
}
if(!nodeFound) {
var newLinks:ArrayCollection = new ArrayCollection();
newLinks.addItem({i: iEnd, l: l});
endpointArray.addItem({node: n, links: newLinks});
}
// Build up startpoint
var interfaceFound:Boolean = false;
for each(var ia:Object in startpointArray) {
if(ia.link.i == iStart) {
interfaceFound = true;
if(!ia.nodes.contains(n))
ia.nodes.addItem(n);
break;
}
}
if(!interfaceFound) {
var newNodes:ArrayCollection = new ArrayCollection();
newNodes.addItem(n);
startpointArray.addItem({link: {i: iStart, l: l}, nodes: newNodes});
}
}
}
// Build endpoint interface
for each(var nodeInfo:Object in endpointArray) {
linksEndpointVbox.addChild(Common.getNodeButton(nodeInfo.node));
for each(var nodeLink:Object in nodeInfo.links) {
var linkHbox:HBox = new HBox();
var space:Spacer = new Spacer();
space.width = 16;
linkHbox.addChild(space);
linkHbox.addChild(Common.getLinkButton(nodeLink.i, nodeLink.l));
linksEndpointVbox.addChild(linkHbox);
}
}
// Build startpoint interface
for each(var linkInfo:Object in startpointArray) {
linksStartpointVbox.addChild(Common.getLinkButton(linkInfo.link.i, linkInfo.link.l));
for each(var node:Node in linkInfo.nodes) {
var linkHbox2:HBox = new HBox();
var space2:Spacer = new Spacer();
space2.width = 16;
linkHbox2.addChild(space2);
linkHbox2.addChild(Common.getNodeButton(node));
linksStartpointVbox.addChild(linkHbox2);
}
}
}
public function viewLinks():void {
var lgWindow:LinkGroupAdvancedWindow = new LinkGroupAdvancedWindow();
lgWindow.main = main;
PopUpManager.addPopUp(lgWindow, main, false);
PopUpManager.centerPopUp(lgWindow);
lgWindow.loadCollection(node.GetLinks());
}
public function viewNodes():void {
var hgWindow:NodeGroupAdvancedWindow = new NodeGroupAdvancedWindow();
hgWindow.main = main;
PopUpManager.addPopUp(hgWindow, main, false);
PopUpManager.centerPopUp(hgWindow);
hgWindow.loadCollection(node.GetNodes());
}
public function viewRspec():void {
var rspecView:XmlWindow = new XmlWindow();
PopUpManager.addPopUp(rspecView, main, false);
PopUpManager.centerPopUp(rspecView);
rspecView.loadXml(node.rspec);
}
private function assignAvailableIcon(item:Object):Class {
return Common.assignAvailabilityIcon(item as Node);
......@@ -173,80 +56,8 @@
<mx:HDividedBox width="100%" height="100%">
<mx:List width="25%" height="100%" id="listNodes"
dataProvider="{nodes}"
labelField="name" change="loadNode(event.target.selectedItem)"
labelField="name" change="nodeInfo.load(event.target.selectedItem)"
iconFunction="assignAvailableIcon"></mx:List>
<mx:VBox height="100%" width="75%" verticalGap="0" paddingTop="0" paddingRight="0" paddingLeft="0" paddingBottom="0" horizontalGap="0" id="nodeInfoHolder">
<mx:Grid width="100%" height="100%" verticalGap="2" horizontalGap="2">
<mx:GridRow width="100%">
<mx:GridItem rowSpan="2">
<mx:Button label="RSPEC" width="100%" height="100%" click="viewRspec()"/>
</mx:GridItem>
<mx:GridItem width="100%">
<mx:Label text="{node.name}" fontSize="17" fontWeight="bold"/>
</mx:GridItem>
</mx:GridRow>
<mx:GridRow width="100%">
<mx:GridItem width="100%">
<mx:Label text="Exclusive" fontWeight="bold"/>
<mx:Image id="imgExclusive"/>
<mx:VRule height="16"/>
<mx:Label text="Availability" fontWeight="bold"/>
<mx:Image id="imgAvailable"/>
<mx:VRule height="16"/>
<mx:Label text="Status" fontWeight="bold"/>
<mx:Label text="{node.status}" fontWeight="normal"/>
</mx:GridItem>
</mx:GridRow>
<mx:GridRow width="100%">
<mx:GridItem>
<mx:Label text="UUID" fontWeight="bold"/>
</mx:GridItem>
<mx:GridItem width="100%">
<mx:Label text="{node.uuid}"/>
</mx:GridItem>
</mx:GridRow>
<mx:GridRow width="100%">
<mx:GridItem>
<mx:Label text="Manager" fontWeight="bold"/>
</mx:GridItem>
<mx:GridItem width="100%">
<mx:Label text="{node.manager}"/>
</mx:GridItem>
</mx:GridRow>
<mx:GridRow width="100%" height="86">
<mx:GridItem>
<mx:Label text="Types" fontWeight="bold"/>
</mx:GridItem>
<mx:GridItem width="100%">
<mx:DataGrid width="100%" height="100%" id="gridTypes" dataProvider="{node.types}">
<mx:columns>
<mx:DataGridColumn headerText="Name" dataField="name"/>
<mx:DataGridColumn headerText="Slots" dataField="slots"/>
<mx:DataGridColumn headerText="Static" dataField="isStatic"/>
</mx:columns>
</mx:DataGrid>
</mx:GridItem>
</mx:GridRow>
<mx:GridRow width="100%" height="100%">
<mx:GridItem>
<mx:VBox horizontalAlign="right">
<mx:Label text="Links to" fontWeight="bold"/>
<mx:HRule width="32"/>
<mx:Label text="View all" fontWeight="normal"/>
<mx:Button label="Links" click="viewLinks();" width="100%"/>
<mx:Button label="Nodes" click="viewNodes();" width="100%"/>
</mx:VBox>
</mx:GridItem>
<mx:GridItem width="100%">
<mx:TabNavigator width="100%" height="100%" paddingTop="2" paddingRight="2" paddingLeft="2" paddingBottom="2">
<mx:VBox label="Endpoint" width="100%" height="100%" id="linksEndpointVbox">
</mx:VBox>
<mx:VBox label="Startpoint" width="100%" height="100%" id="linksStartpointVbox">
</mx:VBox>
</mx:TabNavigator>
</mx:GridItem>
</mx:GridRow>
</mx:Grid>
</mx:VBox>
<NodeAdvancedInformation height="100%" width="75%" verticalGap="0" paddingTop="0" paddingRight="0" paddingLeft="0" paddingBottom="0" horizontalGap="0" id="nodeInfo" />
</mx:HDividedBox>
</ResizeWindow>
......@@ -17,7 +17,6 @@ package pgmap
import flash.events.MouseEvent;
import flash.geom.Point;
import mx.controls.Alert;
import mx.managers.PopUpManager;
public class ProtoGeniMapHandler
......@@ -42,7 +41,7 @@ package pgmap
//tooltip: g.country,
label: g.collection.length.toString()
}));
var groupInfo:NodeGroupInfo = new NodeGroupInfo();
groupInfo.Load(g, this.main);
......@@ -121,6 +120,8 @@ package pgmap
}
}
main.fillCombobox();
main.setProgress("Done", Common.successColor);
}
......
......@@ -19,6 +19,7 @@
import flash.events.ErrorEvent;
import flash.utils.ByteArray;
import mx.controls.Alert;
import mx.utils.Base64Decoder;
public class ProtoGeniRpcHandler
......@@ -30,10 +31,14 @@
[Bindable]
public var useCompression : Boolean = true;
public var sliceUrns : Array;
public var sliceNodes : Array;
public var sliceNodesStatus : Array;
public var slices : Array;
public var sliceCredentials : Array;
public var allSlices : Array;
public var slicesLeft : Array;
public var allSlivers : Array;
public var sliversLeft : Array;
public var main : pgmap;
......@@ -57,6 +62,21 @@
Components = null;
Rspec = null;
}
public function prepareSlices():void {
slicesLeft = new Array();
for each(var s:Slice in allSlices) {
slicesLeft.push(s);
}
}
public function prepareSlivers():void {
sliversLeft = new Array();
for each(var s:Slice in allSlices) {
if(s.status == "ready")
sliversLeft.push(s);
}
}
public function postCall() : void {
main.console.appendText("Seeing if there are any other method to call...\n");
......@@ -72,15 +92,20 @@
main.setProgress("Operation failed!", Common.failColor);
main.stopWaiting();
main.console.appendText("****fail****");
var msg : String = "";
if (fault != null)
{
msg = fault.getFaultString();
main.console.appendText("\nFAILURE fault: " + opName + ": "
+ fault.getFaultString());
+ msg);
}
else
{
msg = event.toString();
main.console.appendText("\nFAILURE event: " + opName + ": "
+ event.toString());
+ msg);
if(msg.search("#2048") > -1)
Alert.show("Stream error, possibly due to server error");
}
main.console.appendText("\nURL: " + op.getUrl());
}
......@@ -237,9 +262,8 @@
main.pgHandler.CurrentUser.email = response.value.email;
main.pgHandler.CurrentUser.name = response.value.name;
sliceCredentials = new Array();
slices = response.value.slices;
if(slices != null && slices.length > 0)
sliceUrns = response.value.slices;
if(allSlices != null && allSlices.length > 0)
startSliceLookup();
else
main.pgHandler.map.drawMap();
......@@ -253,13 +277,13 @@
public function startSliceLookup() : void
{
opName = "Looking up " + slices.length + " more slice(s)";
opName = "Looking up " + sliceUrns.length + " more slice(s)";
main.setProgress(opName, Common.waitColor);
main.startWaiting();
main.console.appendText(opName);
op.reset(Geni.resolve);
op.addField("credential", main.pgHandler.CurrentUser.credential);
op.addField("hrn", slices.pop());
op.addField("hrn", sliceUrns.pop());
op.addField("type", "Slice");
op.call(completeSliceLookup, failure);
addSend();
......@@ -277,13 +301,15 @@
slice.creator = main.pgHandler.CurrentUser;
slice.hrn = response.value.hrn;
sliceCredentials.push(slice);
allSlices.push(slice);
main.pgHandler.CurrentUser.slices.addItem(slice);
if(slices.length > 0)
if(sliceUrns.length > 0)
startSliceLookup();
else
else {