<%--
  -- @(#)asset.jsp	1.41 02/03/03
  -- Copyright 2001 Sun Microsystems, Inc., All Rights Reserved.
  -- A page to display the asset information.
  -- @version 1.41, 02/03/03
  -- @author  Pascal Ledru, Xuefeng Yao
  --
  --%>

<%@ page language="java" contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/tlds/app.tld" prefix="app" %>
<%@ taglib uri="/WEB-INF/tlds/component.tld" prefix="component" %>
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
<%@ page import="com.sun.jade.web.util.BreadCrumbBean" %>

<html:html locale="true">

<app:contentState/>
<app:assetInfo/>
<app:healthSummary2/>

<%
  String sortRule = request.getParameter("sortRule");
  String sortedProperty = request.getParameter("sortedProperty");
  String category = com.sun.jade.web.util.ElementFinder.getCategory(request);
  String OID = com.sun.jade.web.util.ElementFinder.getOID(request);
  String encodedOID = java.net.URLEncoder.encode(OID);
%>

<script language="JavaScript">
  function diagnoseAction() {
    window.location= "/jade/jsp/testList.jsp?mode=Device&OID=<%=encodedOID%>";
  }
  <logic:equal name="hasLauncher" value="true">
    function launch() {
      var w = window.open('<bean:write name="appInterpretedLink" filter="false"/>', 'deviceApp');
      w.focus();
    }
  </logic:equal>
</script>

<script language="JavaScript">

  function LinkUp(theForm) {
   for (var i = 0; i < theForm.mode.options.length; i++) {
          if (theForm.mode.options[i].selected)
		if (theForm.mode.options[i].text != "<bean:message key="option.otherViews"/>")              
                	  window.location = theForm.mode.options[i].value;
   }  
 }

</script>

<jsp:include page="header.jsp"/>

<BODY bgcolor="#FFFFFF" leftmargin="0" marginwidth="0" marginheight="0" topmargin="0">
  <jsp:include page="masthead.jsp">
    <jsp:param name="category"	  value="assets"/>
    <jsp:param name="subCategory" value="<%=com.sun.jade.web.util.ElementFinder.getCategory(request)%>"/>
  </jsp:include>

<app:breadCrumb/>

<%
    java.util.ArrayList breadCrumb = new java.util.ArrayList();
    BreadCrumbBean bcb1 = new BreadCrumbBean();	
    BreadCrumbBean bcb2 = new BreadCrumbBean();		
    bcb1.setDisplayName("assetsSummary");
    bcb1.setLink("/jade/jsp/healthSummary.jsp?mode=Summary");
    breadCrumb.add(bcb1);
    bcb2.setDisplayName(category);
    bcb2.setLink("/jade/jsp/assetDeviceType.jsp?mode=Category&category=" + category);
    breadCrumb.add(bcb2);

    
    java.util.ArrayList breadCrumb_dev = (java.util.ArrayList) pageContext.getAttribute("BreadCrumbBeanList");
    for( int i = 0; i < breadCrumb_dev.size() - 1; i ++ ) {
       BreadCrumbBean bcb_dev = (BreadCrumbBean)breadCrumb_dev.get(i);
       bcb_dev.setLink("/jade/jsp/asset.jsp?mode=Device&OID=" + bcb_dev.getOidName());
       breadCrumb.add(bcb_dev);
    }

    breadCrumb.add(breadCrumb_dev.get(breadCrumb_dev.size()-1));

    pageContext.setAttribute("breadCrumbBeanList",breadCrumb);
%>

<component:breadCrumb beanListName = "breadCrumbBeanList" />

<DIV class="content-layout">
<logic:present name="alertBean" scope="page">
<component:bigHorizontalSpacer />
<component:inlineAlert beanName="alertBean" /> 
</logic:present>
<table cellspacing="0" cellpadding="0" border="0">
<tr><td>

<component:bigHorizontalSpacer /> 
<table cellspacing="0" cellpadding="0" border="0" width="100%">
     <TR>
       <TD align="right">
          <%-- do we display one button or two --%>
          <% String visible = pageContext.getAttribute("hasLauncher").toString() + "," +
                              pageContext.getAttribute("hasDiagnostics").toString(); %>
	  <component:buttonGroup formName="null" 
                                 buttonNames="appNameLauncher,diagnoseButton"
                                 buttonLocalizationModes="inPage,inPage"
                                 buttonValues="javascript:launch(),javascript:diagnoseAction()" 
                                 buttonChecks="no,no"
                                 buttonVisibles="<%=visible%>"
                                 buttonType="regular" controlName="null" />
        </TD>
      </TR>
</table>


<logic:notEqual name="isMSE" value="true">
<component:bigHorizontalSpacer /> 

<app:sortOption/>
<jsp:setProperty name="sortOption" property="beanListName" value="healthSummary"/>
<jsp:setProperty name="sortOption" property="beanClassName" value="com.sun.jade.util.ItemImpl"/>
<jsp:setProperty name="sortOption" property="propertyList" value="name,value"/>
<jsp:setProperty name="sortOption" property="sortedProperty" value="<%=sortedProperty%>"/>
<jsp:setProperty name="sortOption" property="sortRule" value="<%=sortRule%>"/>
<app:sort/>
 
<div class="table-title-text"><bean:message key="title.subComponents"/></div>
<component:smallHorizontalSpacer />                                          

<component:table propertyList="name,value" categoryList="header.componentType,header.componentIds" beanListName="healthSummary"
                 beanClassName="com.sun.jade.util.ItemImpl" hasSort="yes" 
                 hasCheckbox="no" checkboxName="null" checkboxValue="null" 
                 wrap="nowrap,nowrap"
                 formName="null" sourcePage="asset.jsp" width="100%" />  

<component:bigHorizontalSpacer />         
</logic:notEqual>

<component:bigHorizontalSpacer /> 
<div class="table-title-text"><bean:message key="title.assetProperties"/></div>
<component:smallHorizontalSpacer />

<logic:notEqual name="isMSE" value="true">

<%
   String deviceName=(String)pageContext.getAttribute("deviceName");
   String link="/jade/jsp/deviceUpdate.jsp?name=" + java.net.URLEncoder.encode(deviceName);
%>

<script language="JavaScript">
  function linkTo() {
        window.location="<%=link%>";
   }
</script>

<component:buttonGroup formName="null" buttonNames="button.edit"
	                       buttonValues="javascript:linkTo()" buttonChecks="no" controlName="null" 
                               buttonType="mini" />

<component:smallHorizontalSpacer />
</logic:notEqual>

<%-- Asset information table entries. --%>
<component:table propertyList="name,valueAsHTMLString" categoryList="header.property,header.value" beanListName="assets"
                 beanClassName="com.sun.jade.logic.asset.AssetItemImpl" hasSort="no" 
                 hasCheckbox="no" checkboxName="null" checkboxValue="null" width="100%" 
                 wrap="nowrap,nowrap"
                 emptyTableIndication="noAssetProperties"
                 formName="null" sourcePage="null" />  
<component:bigHorizontalSpacer />

<app:healthInfo/>

<component:bigHorizontalSpacer />   
<DIV class="table-title-text"><bean:message key="title.healthSummary"/></DIV>
<component:smallHorizontalSpacer /> 

<%-- Health information table entries. --%>
                                  
<component:table propertyList="name,value" categoryList="header.property,header.value" beanListName="healthItem"
                 beanClassName="com.sun.jade.logic.health.HealthItem" hasSort="no" 
                 hasCheckbox="no" checkboxName="null" checkboxValue="null" width="100%" 
                 emptyTableIndication="noHealthProperties"
                 formName="null" sourcePage="healthContent.jsp" />  


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

</DIV>

</body>
</html:html>

