<%--
/*
 * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
 * 
 *  Use is subject to license terms.
 * 
 *  "@(#)admin_expansion_wiz_unconfigure.jsp     1.9     03/09/25     SMI"
 */
--%>
<%@ include file="/layout/toptags.jsp"%>
<!-- locale stuff -->
<html:html locale="true">
<!-- end locale -->
<%
    String isAdd = 
      (String)session.getAttribute(Constants.HttpSessionFields.IS_ADD_EXPANSION);
%>
<head>
<%@include file="/layout/page_head_section.jsp"%>
</head>
<% 
    String fileName = "admin_expansion_wiz_unconfigure.jsp";

    com.sun.netstorage.array.mgmt.cfg.ui.forms.AdminExpansionForm form = 
      (com.sun.netstorage.array.mgmt.cfg.ui.forms.AdminExpansionForm)
         session.getAttribute("Expansion");          
    T4Interface t4 = 
      (T4Interface) 
        session.getAttribute(Constants.HttpSessionFields.CURRENT_T4);
    // this page is used by both the add and remove expansion
    //  wizards
    // this code will determine which action to use
    // set it to remove by default
    String formAction = "/RemoveExpansionWizard.do";
    // if the boot_r feature is supported, use the
    //   remove wizard with no rarp page
    if(t4 != null &&
       t4.isFeatureSupported(Constants.SupportedFeature.FEATURE_BOOT_R)) {
       formAction = "/RemoveExpansionWizardNoRarp.do";
    }

    if("true".equals(isAdd)) {
      formAction = "/AddExpansionWizard.do";
    }

    // get the unconfiguration thread from the session
    com.sun.netstorage.array.mgmt.cfg.ui.business.ArrayUnconfigurationThread thread = 
       (com.sun.netstorage.array.mgmt.cfg.ui.business.ArrayUnconfigurationThread)
         session.getAttribute(Constants.HttpSessionFields.UNCONFIG_THREAD);
    boolean isThreadDone = false;
    if(thread != null) {
       isThreadDone = thread.isThreadDone();
       Trace.verbose(this, fileName, 
           "Thread is not null, get thread status;is thread done? " + isThreadDone); 
    }
    Trace.verbose(this, fileName, "is thread done? " + isThreadDone); 
%>

<%@ include file="/layout/wizard_body_tag.jsp" %>
<body class="wizard-contents-body">

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

<html:form name="wizardframework" type="com.sun.netstorage.array.mgmt.cfg.ui.forms.WizardFrameworkForm" action="<%=formAction%>">
<%@ include file="/wizard/wizard_framework_fields.jsp"%>


<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr class="wizard-content-title-row">

    <td>
      <div class="wizard-content-title-text">
        <bean:message key="expansion.unconfigure.header"/>
      </div>
    </td>
  </tr>
  <tr>
    <td class="wizard-content-divider"><img alt width="1" height="1" src="/images/general/dot.gif" border="0"></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="20" width="1" src="images/general/dot.gif"></td>
  </tr>
</table>

<table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" width="100%">   
  <tr>
   <td>
      <bean:message key="expansion.unconfigure.instructions"/>
   </td>
  </tr>
</table>

<!-- spacer between two sections -->
<table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td><img alt border="0" height="20" width="1" src="images/general/dot.gif"></td>
  </tr>
  <tr>
    <td>
      <div class="major-category-text">
        <bean:message key="expansion.unconfigure.executing.step"/>
      </div>
    </td>
  </tr>
  <tr>
    <td><img alt width="1" height="8" border="0" src="images/general/dot.gif"></td>
  </tr>
</table>

<!-- the anchor to the top of the steps table -->
<a name="topofsteps"></a>

<table class="back-table" border="0" cellspacing="0" cellpadding="1" >
  <tr>
    <td>
      <table class="front-table" border="0" cellspacing="0" cellpadding="0" >

        <tr class="header-row">
          <td></td>
          <td>
            <div class="table-header-text">
              <bean:message key="expansion.unconfigure.executing.table.desc"/>
            </div>
          </td>
          <td>
            <div class="table-header-text">
              <bean:message key="expansion.unconfigure.executing.table.status"/>
            </div>
          </td>
        </tr>
        <%

          String stepProperty = "removeStepMessageKeys";
          if("true".equals(isAdd)) {
            stepProperty = "addStepMessageKeys";
          }
        %>
        <!-- unconfiguration step rows -->
          <logic:present name="Expansion" property="<%=stepProperty%>">
            <logic:iterate id="stepKey" name="Expansion" property="<%=stepProperty%>" indexId="idx">
              <% String step = (String)stepKey; %>
             <tr>
              <td>
                <div class="table-normal-text">
                   <% 
                    if(thread != null) {
                      Integer currentStep = new Integer(thread.getCurrentStep()); 
                      if(idx.equals(currentStep) && !isThreadDone) {
                    %>
                   <img alt="Steps Position Arrow" src="images/general/arrow.gif" border="0" width="11" height="13">
                   <% } else { %>
                       &nbsp;
                   <% }
                    } %>
                </div>
              </td>
              <td>
                <div class="table-normal-text">
                   <%
                      String arg = "";
                      try {
                        arg = form.getControllerToMove().getId();
                      } catch(Exception ex) {}
                   %>
                   <bean:message key="<%=step%>" arg0='<%=arg%>'/>
                </div>
              </td>
              <td>
                <div class="table-normal-text">
                   <img alt="" border="0" width="10" height="10" lowsrc="<%=form.getStepStatusIcon(idx.toString())%>" src="<%=form.getStepStatusIcon(idx.toString())%>">
                   <bean:message key="<%=form.getStepStatus(idx.toString())%>"/>
                </div>
              </td>
             </tr>
            </logic:iterate>
          </logic:present>
      </table>
    </td>
       </tr>
</table>

</div>
<!-- Place Java Script Here -->
<script language="JavaScript">
    function submitForm() {
      if ( document.images )
      {
         preload( 'success_10', 'images/icons/success_10.gif' );
         preload( 'minor_10', 'images/icons/minor_10.gif' );
         preload( 'major_10', 'images/icons/major_10.gif' );
      }
      <% String _page = "2"; 
        if(t4.isFeatureSupported(Constants.SupportedFeature.FEATURE_BOOT_R) || 
           "true".equals(isAdd)) { 
          _page = "1";
        }
      %>
       parent.setPage(<%=_page%>, "Page");
	}

    function preload( imageObject, imageSource )
    {
       if ( document.images )
       {
          eval( imageObject + ' = new Image()' )
          eval( imageObject + '.src = "' + imageSource + '"' )
       }
    }
    function jump() {
        window.location.href="#topofsteps";
    }
    window.setTimeout(jump, 300);
<%
   if(!isThreadDone) {
     session.setAttribute("disableNext", "true");
%>
	window.setTimeout(submitForm, 500);
<% 
   } else { 
      // remove the thread from the session when it
      //  is done
      Trace.verbose(this, fileName, 
         "Unconfiguration thread is done, remove from session");
      session.removeAttribute(Constants.HttpSessionFields.UNCONFIG_THREAD);

      // still disable the next button if there are errors
      if(!form.getHasErrors()) {
        session.removeAttribute("disableNext");
      }
   } 
%>

</script>

</html:form>
</body>

</html:html>
