<%@ page language="java" %> 
<%@taglib uri="/WEB-INF/tld/com_iplanet_jato/jato.tld" prefix="jato"%> 
<%@taglib uri="/WEB-INF/tld/com_sun_web_ui/cc.tld" prefix="cc"%>
<%@taglib uri="/WEB-INF/lib/sa.tld" prefix="sa"%>

<jato:useViewBean className="com.sun.netstorage.mgmt.fm.storade.ui.viewbeans.topology.TopologyViewBean">

<%
  String isPrivilegedUser = (String)session.getAttribute("storade.privilegedRole");
  if (isPrivilegedUser == null) isPrivilegedUser = "false";
%>

<%
  String appName = com.sun.netstorage.mgmt.fm.storade.ui.util.Connection.getAppName();
%>

<script language="javascript">
// This function will toggle the disabled state of buttons
// depending on single or multiple selections.

function toggleDisabledState1() {
   // do we have the role to activate the menu?
   if (!('true' == '<%=isPrivilegedUser%>')) return;
   // Action button and menu names.
   var testButton = "Topology.testButton";
  
   // Element name (prefix) of selection checkbox/radiobutton.
   var elementName = "Topology.TopologyTable.SelectionRadiobutton";
  
   // Document form.
   var form = document.form;

   // Flag indicating to disable action button and menu options.
   var disabled = true;

   for (i = 0; i < form.elements.length; i++) {
        var e = form.elements[i];

        if (e.name.indexOf(elementName) != -1) {
             if (e.checked) {
                disabled = false;
                break;
            }
        }
   }

   ccSetButtonDisabled(testButton, "form", disabled);	
}

function toggleDisabledState2() {
   // do we have the role to activate the menu?
   if (!('true' == '<%=isPrivilegedUser%>')) return;
   // Action button and menu names.
   var testButton = "Topology.testDirectButton";
  
   // Element name (prefix) of selection checkbox/radiobutton.
   var elementName = "Topology.DirectAttachedTable.SelectionRadiobutton";
  
   // Document form.
   var form = document.form;

   // Flag indicating to disable action button and menu options.
   var disabled = true;

   for (i = 0; i < form.elements.length; i++) {
        var e = form.elements[i];

        if (e.name.indexOf(elementName) != -1) {
             if (e.checked) {
                disabled = false;
                break;
            }
        }
   }

   ccSetButtonDisabled(testButton, "form", disabled);	
}
</script>



<!-- Masthead -->
<sa:primarymasthead name="Masthead" showDefaultPageTitle="withBarOnly"> 

<jato:form name="form" method="post" defaultCommandChild="/TopologyImage">

<!-- start table for correct spacing -->
<table width=100% border=0 cellspacing=0 cellpadding=10>

<!-- Actions, Filter and View menus -->
<tr>

<jato:content name="ActionMenuSection">
<td align=left>
<cc:dropdownmenu name="ActionsMenu" commandChild="ActionsMenuHref"
    title="topology.actionsMenu"
    bundleID="appBundle" type="jump" dynamic="true" />
</td>
</jato:content>

<td align=right nowrap>
<cc:label name="ViewLabel" defaultValue="topology.view"
    bundleID="appBundle" elementName="ViewMenu" />
<cc:dropdownmenu name="ViewMenu" commandChild="ViewMenuHref"
    bundleID="appBundle" type="jump" dynamic="true" />

</td></tr>

<tr><td colspan=2>

<!-- Topology Snapshot popup -->
<jato:content name="SnapshotPopupSection">
<script type="text/javascript">
var win = window.open('/<%=appName%>/topology/TakeSnapshot','snapshotWindow','scrollbars,resizable,height=400,width=600,left='+((window.screen.width-600)/2)+',top='+((window.screen.height-400)/2));
win.focus();
</script>
</jato:content>

<!-- Topology Image -->
<jato:content name="GraphicalSection">
<cc:topology name="TopologyImage" bundleID="appBundle" />
</jato:content>

<!-- The Topology Applet -->
<jato:content name="AppletSection">
<script language=JavaScript>

  var a_width;
  var a_height;
  if (navigator.appName.indexOf("Netscape") != -1) {
      a_width = window.innerWidth - 34;
      a_height = window.innerHeight- 252;
  } else {
      a_width = window.document.body.offsetWidth - 34;
      a_height = window.document.body.offsetHeight - 292;
  }
  var s = '<applet code=VertexApplet.class codebase=/storade/applet archive=topo.jar height=' +a_height+ ' width=' +a_width + ' MAYSCRIPT>';
  window.document.writeln(s);
  window.document.writeln('');
</script>

<%=session.getAttribute("appletParameters") %>

</applet>

</jato:content>

</td></tr>

</table>

<!-- Topology Table -->
<jato:content name="TabularSection">

<jato:content name="SwitchConnectionTable">

<cc:actiontable
 name="TopologyTable"
 bundleID="appBundle"
 title="topology.table.title"
 summary="topology.table.summary"
 empty="topology.table.empty"
 rowSelectionType="single"
 selectionJavascript="toggleDisabledState1()"
 showAdvancedSortingIcon="false"
 showLowerActions="false"
 showPaginationControls="true"
 showPaginationIcon="true"
 showSelectionIcons="false"
 showSortingRow="true"
 maxRows="25"
 page="1" />

<cc:spacer name="spacer" height="20" newline="true"/>

</jato:content>

<jato:content name="DirectAttachedConnectionTable">

<cc:actiontable
 name="DirectAttachedTable"
 bundleID="appBundle"
 title="table.directAttachedConnections.title"
 summary="table.directAttachedConnections.summary"
 empty="table.directAttachedConnections.empty"
 rowSelectionType="single"
 selectionJavascript="toggleDisabledState2()"
 showAdvancedSortingIcon="false"
 showLowerActions="false"
 showPaginationControls="true"
 showPaginationIcon="true"
 showSelectionIcons="false"
 showSortingRow="true"
 maxRows="25"
 page="1" />
</jato:content>

</jato:content>

<cc:hidden name="topologyID"/>

</jato:form>

<script language="javascript">
window.name="mainForTopology";
</script>

</sa:primarymasthead>

</jato:useViewBean>

