<%--
  /**
   * Copyright (c) 2003 by Sun Microsystems, Inc. All rights reserved.
   * Use is subject to license terms.
   *
   * "@(#)MainMenu.jsp    1.43    03/08/26     SMI"
   * 
   */
 --%>
<%@ include file="/layout/toptags.jsp"%>
<%@ page import="com.sun.netstorage.array.mgmt.cfg.core.ini.MaseratiConfig"%>
<%@ page import="com.sun.netstorage.array.mgmt.cfg.ui.forms.OverallSystemForm"%>
<%@ page import="com.sun.netstorage.array.mgmt.cfg.ui.business.T4s"%>
 
<!-- locale stuff -->
<html:html locale="true">
<!-- end locale -->

<!-- Place Java Script Here -->
 
<!-- HTML -->
<head>
<%@include file="/layout/page_head_section.jsp"%>
    <title>
        <bean:message  key="main.menu.title"/>
    </title>
   <script language="javascript">
   function submitAction(value) {
      if ("#" != value ) {
          document.forms[0].action=value;
          document.forms[0].submit();
      }
   }
   </script>
</head>

<%@include file="/layout/bodytag.jsp"%>
<%@include file="/layout/top.jsp"%>
<%@include file="/layout/breadcrumb.jsp"%>
<%@include file="/layout/spacer.jsp"%>

<html:form action="root.menu.item0.item0.do">
<%
  boolean isM1M2 = false;
  OverallSystemForm form = (OverallSystemForm)session.getAttribute("System");
  switch(form.getConfigType()) {
     case MaseratiConfig.MIDRANGE1_INT:
     case MaseratiConfig.MIDRANGE2_INT:
        isM1M2 = true;
        break;
  }
  boolean hasList = true;
  List arrayList = (List)session.getAttribute(Constants.HttpRequestFields.T4_LIST_PARAM);    
  if(arrayList == null || arrayList.isEmpty() ) {
     hasList = false;    
  }
  boolean allUnhealthy = false;
  if(form == null || form.getAllUnhealthy()) {
     allUnhealthy = true;
  }
%>
<!-- hidden element which specifies the action for this form -->
<input type="hidden" name="request_action" value="<%=request.getAttribute("request_action")%>">

<div class="content-layout">
<%@ include file="/layout/user_messages.jsp"%>
<%@ include file="/layout/spacer.jsp"%>
<!-- only show overall health if not m1m2 -->
<% if(!isM1M2) { %>
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
      <td>
       <table>
         <tr><td>
                <img src="/nsm/images/general/dot.gif" width="1" height="10" border="0">
         </td></tr>
         <tr><td>
           <table border="0" cellspacing="0" cellpadding="2" align="left" bgcolor="#9999CC">
             
             <tr><td>
               <table cellspacing="0" cellpadding="5" border="0"  bgcolor="#FFFFFF">
                 <tr>
                  <td valign="top"><img src="images/icons/info_16.gif" width="16" height="16" alt="Information" border="0"></td>
                  <td><div class="error-message-header-text"><bean:message key="main.menu.health.status"/>
                
                     <b><bean:message key='<%=((OverallSystemForm)session.getAttribute("System")).getHealthStatus()%>'/></b></div>
                </tr>
              </table>
             </td></tr>
           </table>
         </td></tr>
         <tr><td>
            <img src="/nsm/images/general/dot.gif" width="1" height="10" border="0">
         </td></tr>
       </table>
     </td>
   </tr>
  </table>
 <!-- spacer between two sections -->
<table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" width="100%">
  <tr>
    <td><img alt border="0" height="8" width="1" src="images/general/dot.gif"></td>
  </tr>
</table>

<% } // end if !m1m2%>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
   <tr>
      <td>
        <table border="0" cellpadding="0" cellspacing="0" width="100%">
          <tr>
            <td nowrap>
              <bean:message key="main.menu.health.info"/> 
	      <% if(Repository.getRepository().getConfigInteger() == MaseratiConfig.MIDRANGE3_INT) { %>
                <a href="<%=session.getAttribute(Constants.HttpSessionFields.SADE)%>" target="_blank"><bean:message key="main.menu.health.info.link"/></a>                              
	    <% } else { %>
	        <bean:message key="main.menu.health.info.link"/>
	    <% } %>
            </td>
          </tr>
        </table>
      </td>
   </tr>
</table>
<%@include file="/layout/spacer.jsp"%>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
   <tr>
     <td>
       <table border="0" cellpadding="0" cellspacing="0" width="100%">
         <tr>
           <td nowrap>
             <div class="major-category-text">
               <bean:write name="System" property="productName"/>                
             </div>
           </td>
           <td valign="bottom" width="99%">
             <table border="0" cellpadding="0" cellspacing="0" width="100%">
               <tr>
                 <td class="property-separator" valign="bottom"><img alt border="0" height="2" src="/images/general/dot.gif" width="1"></td>
               </tr>
            </table>
           </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td><img alt border="0" height="5" src="/images/general/dot.gif" width="1"></td>
  </tr>
  <tr>
    <td><img alt border="0" height="5" src="/images/general/dot.gif" width="1"></td>
  </tr>
  <tr>
    <td>
      <bean:message key="main.menu.array.selection.instructions"/>
    </td>
  </tr>
</table>

<%@include file="/layout/spacer.jsp"%>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
   <tr>
     <td>
       <table border="0" cellpadding="0" cellspacing="0" width="100%">
         <tr>
           <td nowrap>
             <div class="major-category-text">
               <bean:message key="main.menu.title" />                
             </div>
           </td>
        </tr>
      </table>
    </td>
  </tr>
</table>

  <table border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td nowrap>
        <table border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td align="left" valign="middle">
              <table border="0" cellpadding="0" cellspacing="0">
                <tr>                  
                  <td>
                    <table border="0" cellpadding="1" cellspacing="0" class="button-link-enabled-text">
                      <tr>
                        <td>
                          <table>
                            <tr>
                              <td align="center" valign="middle" nowrap>         
                                 <component:button text="main.menu.configure.button" href="javascript:document.forms[0].action='root.menu.item0.item1express.do';document.forms[0].submit();" title="main.menu.configure.button" isEnabled="<%= hasList && !allUnhealthy %>" />                                 
                              </td>
                            </tr>
                          </table>
                        </td>
                      </tr>
                    </table>
                  </td>
                  <td width="10"><img alt width="10" height="1" border="0" src="images/general/dot.gif"></td>                  
                </tr>
              </table>
            </td>
            
            <td align="left" valign="middle">
              <table border="0" cellpadding="0" cellspacing="0">
                <tr>                  
                  <td>
                    <table border="0" cellpadding="1" cellspacing="0" class="button-link-enabled-text">
                      <tr>
                        <td>
                          <table>
                            <tr>
                              <td align="center" valign="middle" nowrap>         
                                 <component:button text="main.menu.show.overview.button" href="javascript:document.forms[0].action='root.menu.item0.overview.do';document.forms[0].submit();" title="main.menu.show.overview.button" isEnabled="<%= hasList && !allUnhealthy %>" />                                 
                              </td>
                            </tr>
                          </table>
                        </td>
                      </tr>
                    </table>
                  </td>
                  <td width="10"><img alt width="10" height="1" border="0" src="images/general/dot.gif"></td>                  
                </tr>
              </table>
            </td>
            
            <td align="left" valign="middle">
              <table border="0" cellpadding="0" cellspacing="0">
                <tr>                  
                  <td>
                    <table border="0" cellpadding="1" cellspacing="0" class="button-link-enabled-text">
                      <tr>
                        <td>
                          <table>
                            <tr>
                              <td align="center" valign="middle" nowrap>         
                                 <component:button text="main.menu.refresh.list.button" href="javascript:submitForm('refresh');" title="main.menu.refresh.list.button" isEnabled="true" />                                 
                              </td>
                            </tr>
                          </table>
                        </td>
                      </tr>
                    </table>
                  </td>
                  <td width="10"><img alt width="10" height="1" border="0" src="images/general/dot.gif"></td>                  
                </tr>
              </table>
            </td>
            <td align="left" valign="middle">
              <table border="0" cellpadding="0" cellspacing="0">
                <tr>                  
                  <td>
                    <table border="0" cellpadding="1" cellspacing="0" class="button-link-enabled-text">
                      <tr>
                        <td>
                          <table>
                            <tr>
                              <td align="center" valign="middle" nowrap>         
                                <select name="selectedAction" onchange="submitAction(this.options[this.selectedIndex].value);">
			         <option value="#" selected> <bean:message key="main.menu.selection.header"/> </option>
                                 <% if (!allUnhealthy) { %>
			              <option value="root.menu.item0.item2pools.do" > <bean:message key="main.menu.selection.mg.pools"/></option>
			              <option value="root.menu.item0.item4.do" > <bean:message key="main.menu.selection.mg.volumes"/></option>
			              <option value="root.menu.item1.item0volgrps.do" > <bean:message key="main.menu.selection.mg.volume.groups"/></option>
			              <option value="root.menu.item1.item0ini.do" > <bean:message key="main.menu.selection.mg.initiators" /> </option>
			              <option value="root.menu.item1.item0inigrps.do"> <bean:message  key="main.menu.selection.mg.initiator.groups" /></option>
			              <option value="#" > <bean:message key="main.menu.selection.separator"/></option>
			              <option value="root.menu.item1.item0accessmatrix.do" > <bean:message key="main.menu.selection.matrix"/></option>
			              <option value="#" > <bean:message key="main.menu.selection.separator"/></option>
			              <option value="root.menu.item0.item2duplicate.do" > <bean:message key="main.menu.selection.dup.array"/></option>
			              <option value="root.menu.item1.item1seligs.do" > <bean:message key="main.menu.selection.dup.initiator"/></option>
				   <% if(isM1M2) { %> 
			              <option value="#" > <bean:message key="main.menu.selection.separator"/></option>
                                   <% } 
                                   } 
                                   if (isM1M2) {%>
                                     
			              <option  
                                           <% if (Constants.UserAccount.GUEST_ACCOUNT.equals(aui.role)) { %> 
                                                value="#"
                                                class="disabled-menu-text" 
                                           <%} else  {%>
                                                value="root.menu.item0arrayreg.do"
                                           <%} %>> 
                                                <bean:message key="main.menu.selection.reg.array"/>
                                      </option>
                                   <% }  %>
    				</select>
                              </td>
                            </tr>
                          </table>
                        </td>
                      </tr>
                    </table>
                  </td>
                  <td width="10"><img alt width="10" height="1" border="0" src="images/general/dot.gif"></td>                  
                </tr>
              </table>
            </td>

          </tr>
        </table>
      </td>
    </tr>
  </table>
 

<table>      
   <%@include file="/layout/prevnext.jsp"%>   
   <tr>
      <td nowrap>
         <table class="back-table" border="0" cellspacing="0" cellpadding="1" width="100%">
            <tr>
               <td>
                  <table class="front-table" border="0" cellspacing="0" cellpadding="0" width="100%">
                    <tr class="header-row">
                        <td>&nbsp; </td>
                        <td nowrap>
                          <div class="table-header-text">
                            <bean:message key="main.menu.t4.summary.name"/>
                          </div>
                        </td>                        
                        
                        <td nowrap>
                          <div class="table-header-text">
                            <bean:message key="main.menu.t4.summary.description"/>
                          </div>
                        </td>   
                        <td nowrap>
                          <div class="table-header-text">
                             <bean:message key="main.menu.t4.summary.firmware"/>
                          </div>
                        </td>                      
                        <td nowrap>
                          <div class="table-header-text">
                            <bean:message key="main.menu.t4.summary.health"/>
                          </div>
                        </td>                      
                   </tr>                                           
                 <%
                  if(!hasList) {  %>
                    <tr>
                       <td colspan="6">
                          <bean:message key="main.menu.t4.summary.noarrays"/> 
                       </td>
                    </tr>
                 <%
                  } else {
                     // there are some T4
                     // determine which T4 to select in the list
                     T4s t4BusObj = new T4s();
                     String selection = request.getParameter(Constants.HttpRequestFields.SELECTED_INDEX_PARAM);                        
		     //get health of selected array
		     try {
		        T4Interface tmpArray = (T4Interface)arrayList.get((new Integer(selection)).intValue());
			if(tmpArray.getHealthStatus() != Constants.T4.HEALTH_OK_CODE){
			   selection = null;
			}
	             } catch (Exception e){
		        selection = null;
		     }
                     // if the selection is null...
                     if(selection == null) {
                       // select the current T4 in the session
                       T4Interface current = (T4Interface)session.getAttribute(Constants.HttpSessionFields.CURRENT_T4);
                       if (current != null) {
                         try {
                            // get the index of the T4 in the session
                            selection = Integer.toString(t4BusObj.indexFromName(current.getName(), arrayList ));
                         } catch(Exception e) {                        	    	
                            selection = "" + t4BusObj.getFirstHealthyArrayIndex(arrayList);
                         }
                       } else {
                         selection = "" + t4BusObj.getFirstHealthyArrayIndex(arrayList);
                       }
                    }
		    Trace.verbose(this, "JSP", "\n\n\tSELECTION:" + selection + "\n");
                 %>                                      
                   <!-- Begin T4 row listing -->           
                   <logic:present name="T4List">         
                     <% String okHealth = 
                          Integer.toString(Constants.T4.HEALTH_OK_CODE);
                          List healthList = (List)session.getAttribute(
                                 Constants.HttpSessionFields.HEALTH_STATUS_LIST);
                     %>
                     <%@include file="/layout/listingCalc.jsp"%>
       	 	     <logic:iterate id="t4" name="T4List" type="T4Interface" indexId="index" offset='<%=offsetStr%>' length='<%=lengthStr%>'>

                     <tr>
                        <td align="center">                                                                  
                           <logic:notEqual name="t4" property="healthStatus" value="<%=okHealth%>">
                              &nbsp;
                           </logic:notEqual>
                           <logic:equal name="t4" property="healthStatus" value="<%=okHealth%>">
                              <logic:equal name="index" value="<%=selection%>">                     
                                 <input checked type="radio" name="index" value="<%=index%>">
                              </logic:equal>
                              <logic:notEqual name="index" value="<%=selection%>">                                                                             <input type="radio" name="index" value="<%=index%>"> 
                              </logic:notEqual>
                           </logic:equal>
                         </td>   
                         <td align="left" nowrap>     
                           <div class="table-label-text">                    
                              <bean:write name="t4" property="name"/>
                           </div>
                         </td> 
                         <td align="left" nowrap>              
                           <div class="table-label-text">                 
                           <logic:present name="t4" property="description">
                              <bean:write name="t4" property="description"/>
                           </logic:present>
                           <logic:notPresent name="t4" property="description">
                               &nbsp;
                           </logic:notPresent>
                           </div>
                         </td> 
                         <td align="right" nowrap>              
                           <div class="table-label-text">                 
                           <logic:present name="t4" property="firmwareVersion">
                              <bean:write name="t4" property="firmwareVersion"/>
                           </logic:present>
                           <logic:notPresent name="t4" property="firmwareVersion">
                               &nbsp;
                           </logic:notPresent>
                           </div>
                         </td> 
                         <td align="left" nowrap>              
                           <div class="table-label-text">                 
                             <% try { 
                             %>
                               <bean:message key='<%="array.health.code." + healthList.get(index.intValue())%>' />
                             <% }catch(Exception e) { %>
                               <bean:message key="array.health.code.x"/>
                             <% } %>
                           </div>
                         </td>                                                
                      </tr>
                      </logic:iterate>

                    </logic:present>
                   <% } //end of if (hasList) %>
                 </table>
               </td>
             </tr>
           </table>
        </td>
     </tr>
     <%@include file="/layout/prevnext.jsp"%>   
</table>
 
      
      
</div>

<table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" width="100%">
  <tr>
    <td><img alt border="0" height="20" width="1" src="images/general/dot.gif"></td>
  </tr>
</table>



<table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" width="100%">
  <tr>
    <td><img alt border="0" height="20" width="1" src="images/general/dot.gif"></td>
  </tr>
</table>

</html:form>
</body>
</html:html>
