<%--
  /**
   * Copyright (c) 2003 by Sun Microsystems, Inc. All rights reserved.
   * Use is subject to license terms.
   *
   * "@(#)admin_select_array.jsp    1.24    03/08/26     SMI"
   * 
   */
 --%>
<%@ include file="/layout/toptags.jsp"%>

<!-- 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>
</head>

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

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

<html:form action="root.menu.item3.item0.m1m2.do">

<!-- hidden element which specifies the action for this form -->
<input type="hidden" name="request_action" value="<%=request.getAttribute("request_action")%>">

<div class="content-layout">

  <%

    com.sun.netstorage.array.mgmt.cfg.ui.forms.AdminArraySelectionForm form = 
     (com.sun.netstorage.array.mgmt.cfg.ui.forms.AdminArraySelectionForm)
       session.getAttribute("AdminArraySelection");
    boolean allOk = true;
    if(form != null) {
       if(form.getAllUnhealthy()) {
            allOk = false;
       }
    }
    boolean hasList = true;
    List t4List = (List)session.getAttribute("T4List");    
    if(t4List == null || t4List.size() == 0 ) {
    	hasList = false;    
  %>
   <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/warning_16.gif" width="16" height="16" alt='<bean:message key="icon.warning"/>' border="0"></td>
                  <td><div class="error-message-header-text">                                   
                     <b><bean:message key="storage.mgmt.system.noarrays"/></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>
  <% } else if(!allOk) { %>
   <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/warning_16.gif" width="16" height="16" alt="Warning" border="0"></td>
                  <td><div class="error-message-header-text">                                   
                     <b><bean:message key="storage.mgmt.system.allunhealthyarrays"/></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>

<!-- 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>


  <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.t4.section.title"/> 
              </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.t4.section.instructions"/>
                        </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>


  <table border="0" cellspacing="0" cellpadding="0" width="100%">
    <tr>
      <td nowrap>
        <table border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td>
             <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="admin.arrayselect.network.button" href="javascript:document.forms[0].action='root.menu.item3.item0.m1m2.network.do';document.forms[0].submit();" title="admin.arrayselect.network.button" isEnabled="<%=hasList && allOk && !readOnly %>" />
                              </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>
             <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="admin.arrayselect.time.button" href="javascript:document.forms[0].action='root.menu.item3.item0.m1m2.time.do';document.forms[0].submit();" title="admin.arrayselect.time.button" isEnabled="<%=hasList && allOk && !readOnly %>" />
                              </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>
             <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>         
<%
  String confirmRebootURL = 
    "root.menu.item3.item0.m1m2.power.do?action=confirmreboot" ; %>



 <component:button text="admin.general.individualarray.reset" href="javascript:document.forms[0].action='root.menu.item3.item0.m1m2.powerrebootconfirm.do';document.forms[0].submit();" title="admin.general.individualarray.reset" isEnabled="<%=hasList && allOk && !readOnly %>" />

                              </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>
             <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="admin.general.individualarray.shutdown" href="javascript:document.forms[0].action='root.menu.item3.item0.m1m2.powershutdownconfirm.do';document.forms[0].submit();" title="admin.general.individualarray.shutdown" isEnabled="<%=hasList && allOk && !readOnly %>" />
                              </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>
             <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="admin.general.individualarray.resetlabels" href="javascript:document.forms[0].action='root.menu.item3.item0.m1m2.resetlabelsconfirm.do';document.forms[0].submit();" title="admin.general.individualarray.resetlabels" isEnabled="<%=hasList && allOk && !readOnly %>" />
                              </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>
             <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="refreshlist" href="javascript:submitForm('refresh');" title="refreshlist" isEnabled="<%=hasList%>" />
                              </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>
 
 <% if(hasList) { %>
      <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> </td>
                        
                        <td>
                          <div class="table-header-text">
                            <bean:message key="main.menu.t4.summary.name"/>
                          </div>
                        </td>                        
                        
                        <td>
                          <div class="table-header-text">
                            <bean:message key="main.menu.t4.summary.description"/>
                          </div>
                        </td>   
                        <td>
                             <div class="table-header-text">
                               <bean:message key="array.firmware-version.label"/>
                             </div>
                        </td>                                          
                        <td>
                          <div class="table-header-text">
                            <bean:message key="main.menu.t4.summary.health"/>
                          </div>
                        </td>                      
                      </tr>                                           
                      <%
                        // determine which T4 to select in the list
                   	    com.sun.netstorage.array.mgmt.cfg.ui.business.T4s t4BusObj = new com.sun.netstorage.array.mgmt.cfg.ui.business.T4s();
                        List arrayList =
                           (List)session.getAttribute(
                              Constants.HttpRequestFields.T4_LIST_PARAM);
                        String selection = request.getParameter(Constants.HttpRequestFields.SELECTED_INDEX_PARAM);                        
                        // 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);
                        	}
                        } 
                      %>                                      
                      <!-- 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%>" <% if(readOnly) {%>disabled <% } %>>
                                </logic:equal>
                                <logic:notEqual name="index" value="<%=selection%>">                                                     
                                   <input type="radio" name="index" value="<%=index%>" <% if(readOnly) {%>disabled <% } %>> 
                                </logic:notEqual>
                              </logic:equal>
                            </td>   
                            <td>
                              <logic:notEqual name="t4" property="healthStatus" value="<%=okHealth%>">
                                <div class="table-label-text">                    
                                    <bean:write name="t4" property="name"/>
                                </div>
                              </logic:notEqual>
                              <logic:equal name="t4" property="healthStatus" value="<%=okHealth%>">
                                <div class="table-label-text">                    
                                    <%String url = 
                                        "root.menu.item3.item0.arraydetails.do?arrayIndex="+index; %>
                                    <html:link href="<%=url%>"><%=t4.getName()%></html:link>
                                </div>
                              </logic:equal>
                            </td> 
                            <td>              
                              <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">
                              <logic:notEqual name="t4" property="healthStatus" value="<%=okHealth%>">
                                <div class="table-label-text">                    
                                    -
                                </div>
                              </logic:notEqual>
                              <logic:equal name="t4" property="healthStatus" value="<%=okHealth%>">
                                <div class="table-label-text">                    
                                    <%=t4.getFirmwareVersion()%>
                                </div>
                              </logic:equal>
                            </td> 
                            <td align="left">              
                              <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>
                    </table>
                  </td>
                </tr>
              </table>
            </td>
          </tr>
         <%@include file="/layout/prevnext.jsp"%>   
        </table>
<% } // end if(hasList) 
%>      
</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>
