<%--  $Id: HomeLayout.jsp,v 1.1.2.36 2006/04/14 09:55:11 sudharshan Exp $  --%>

<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<%@ taglib prefix="html" uri="http://jakarta.apache.org/struts/tags-html" %>
<%@include file="/webclient/common/jspf/commonIncludes.jspf" %>
<%@ page import="java.util.*" %>
<script language="javascript" src="/webclient/common/js/swipe.js" type="text/javascript"></script>


<html>

<script language="javascript">
    
function showNetworkDatabaseFromPieChart(nodetype)
{
    //var url = "/fault/AlarmView.do?selectedTab=Fault&selectedNode=Alerts&severity="+severity;
    var url = "/topo/NetworkInventory.do?selectedTab=Network+Database&viewId=Network+Database&type="+nodetype+"&displayName="+nodetype;
    window.location.href= url;
    //window.close();
}

function showAlarmsFromAcc(severity)
{
    var category = '<c:out value="${requiredCategory}"/>';
    if(category=='All')
    {
       var url = "/fault/AlarmView.do?selectedTab=Fault&selectedNode=Alerts&severity="+severity;
    }
    else
    {
       var url = "/fault/AlarmView.do?selectedTab=Fault&selectedNode=Alerts&severity="+severity+"&category="+'<c:out value="${requiredCategory}"/>';
    }
    window.location.href= url;
    
}
</script>
<body >
<table width="100%" border="0" cellspacing="0" cellpadding="3">
    <tr> 
    <td height="8" colspan="2"></td>
  </tr>
  <tr> 
    <td width="6%" height="15" colspan="2"><table width="100%" height="100%" valign="bottom" border="0" align="left" cellpadding="0" cellspacing="0">
        <tr> 
          <c:if test="${showInventory=='true'}">
          <td width="35%" height="25%"><span class="header1">&nbsp;
             <fmt:message key='webclient.home.inventory.table.header'/> 
            </span> <%--  <span class="text">(<a href="#">Customize</a>)</span> --%> </td>
          </c:if>
          <c:if test="${showActiveAlarm=='true'}">
          <td width="25%" align="center" class="header1"><fmt:message key='webclient.home.alarms.chart.active'/></td>
          </c:if>
          <c:if test="${showAlarmGraph=='true'}">
          <td width="40%" align="center" class="header1"><fmt:message key='webclient.home.alarms.chart.graph'/></td>
          </c:if>
<%-- 
          <td width="3%" align="right" class="header1"><a href="#"><img src="icon_down.gif" alt="Move this section down" width="16" height="16" hspace="1" border="0"></a></td> --%>
        </tr>
      </table></td>
  </tr>

  <tr>
    <%--      <c:out value="${severityList}"/> this is the severity --%>
 
    <td height="30" colspan="2"><table width="99%" border="0" align="left" cellpadding="2" cellspacing="0" class="homeTableBorder">
        <tr > 
         <c:if test="${showInventory=='true'}">
          <td  width="35%" height="100%" rowspan="2" valign="top"> <table width="98%" height="100%" border="0" align="left" cellpadding="5" cellspacing="1">
              <c:forEach var="invTable" items="${inventTable}" varStatus="status">
                <tr> 
                <td width="50%" height="25" align="left"  class="inventoryName"><span class="text">
                   <img src="<c:out value="${invTable.typeImage}" />"border=0 align="absbottom" width="16" height="16" hspace="0">&nbsp;<a class="linkNoUnderline" href="/topo/NetworkInventory.do?selectedTab=Network+Database&viewId=Network+Database&type=<c:out value='${invTable.type}'/>&displayName=<c:out value='${invTable.displayName}'/>&showMenus=false" title="<fmt:message key='${invTable.displayName}'/>"><fmt:message key='${invTable.displayName}'/></a></span></td>
            <c:forEach var="severity" items="${severityList}" varStatus="status">
         <c:choose>
         <c:when test="${severity=='Clear'}">
                <td  width="25%" align="right" class="inventoryUp"><span>
                <a class="adminLink" href="/topo/NetworkInventory.do?selectedTab=Network+Database&viewId=Network+Database&type=<c:out value='${invTable.type}'/>&displayName=<c:out value='${invTable.displayName}'/>&showMenus=false&status=<c:out value='${severity}'/>" title="<fmt:message key='webclient.inventory.device${severity}'/>" ><c:out value='${invTable[severity]}'/></a></span><img src="/webclient/common/images/arrow_up.gif" width="8" height="9" hspace="2" border="0"></td>
          </c:when>
         <c:otherwise>

                 <td width="25%" align="right" class="inventoryDown"><span> 
<a class="adminLink" href="/topo/NetworkInventory.do?selectedTab=Network+Database&viewId=Network+Database&type=<c:out value='${invTable.type}'/>&displayName=<c:out value='${invTable.displayName}'/>&status=<c:out value='${severity}'/>&showMenus=false" title="<fmt:message key='${severity}'/>" ><c:out value='${invTable[severity]}'/></a></span><img src="/webclient/common/images/arrow_down.gif" width="8" height="9" hspace="2"></td>
         </c:otherwise>
        </c:choose>
        </c:forEach>
                </tr> 
                </c:forEach>

              </tr>
            </table></td>
            </c:if>
            <%--    
            <td  ><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td  align="center"><img src="<c:out value='${topochart_filepath}'/>" width="185" height="130" border="0" usemap="#<c:out value='${topochart_filepath}'/>">  
                 </td>
              </tr>
            </table></td>
--%>
          <c:set var="category" value="${requiredCategory}"/>
          <c:if test="${showActiveAlarm=='true'}">
          <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr><td align="center" class="text"><fmt:message key="webclient.home.activealarm.category.title"/> : <c:out value="${requiredCategory}"/></td>
              </tr>
              <tr> 
                <td align="center"><img src="<c:out value='${homeacc_filepath}'/>" width="185" height="130" border="0" usemap="#<c:out value='${homeacc_filepath}'/>">  
                 </td>
              </tr>
            </table></td>
            </c:if>
          <c:if test="${showAlarmGraph=='true'}">
          <td height="25%" valign="bottom"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td align="left"> <img  src="<c:out value='${filepath_barchart}'/>" width="270" height="130" border="0" usemap="#<c:out value='${filepath_barchart}'/>" > 
                </td>
              </tr>
            </table></td>
            </c:if>
        </tr>
<c:if test="${showActiveAlarm=='true'|| showAlarmGraph=='true'}">
        <tr> 
          <td height="50%" colspan="2" align="center"><img src="/webclient/common/images/legend.gif" vspace="1"></td>
        </tr>
</c:if>
      </table></td>
  </tr>

 <tr>
 <td colspan="2" height="13"> </td>
 </tr>

<c:if test="${showAlarms=='true'}">  
  <tr> 
    <td height="20" valign="middle"><span class="header1">&nbsp;&nbsp;&nbsp;<fmt:message key='webclient.home.alarms.table.recent'/></span><span class="text"> </td>
  </tr>
<tr>

    <td height="20" colspan="2">

        <tiles:insert attribute="ListView"/>

</td>
</tr>
</c:if>
<%-- Report starts here --%>
<%--
<tr>
 <td align="right"><a href="#"><img src="icon_up.gif" alt="Move this section down" width="16" height="16" hspace="1" border="0"></a> 
                  <a href="#"> <img src="icon_down.gif" alt="Move this section down" width="16" height="16" hspace="1" border="0"></a></td>
  </tr>

--%>

 <tr>
 <td colspan="2" height="13"> </td>
 </tr>

<c:if test="${showReports=='true'}">

<tr> 
    <td height="20" colspan="2">

        <table id="reportsTable" width="100%" border="0" valign="top" cellspacing="3" cellpadding="4">
        
<%
int perftot = 0;
Vector ccprop = (Vector)request.getAttribute("reportComplete");

if(ccprop != null)
{
    perftot = ccprop.size();

    if(perftot%2==0 && perftot!=0)
    {
        perftot = (perftot/2)-1;
    }
    else
    {
        perftot = (perftot/2);
    }

Enumeration en = ccprop.elements();
for(int i=0; i<=perftot; i++)
{
%>

<tr>
 <c:forEach  begin="0" end="1" varStatus="status">  
<td valign="top" width="50%" >

<%
if(en.hasMoreElements())
{
Properties cprop = (Properties)en.nextElement();
request.setAttribute("cprop",cprop);
%>

 <table border="0" cellspacing="0" valign="top" cellpadding="0" width="99%">
        <tr>
            <td height="20" align="left" nowrap colspan="2"><span class="header1">&nbsp;<fmt:message key='webclient.home.report.table.header'><fmt:param><c:out value="${ReportsLength}"/></fmt:param></fmt:message> <fmt:message key='${cprop.moType}'/> <fmt:message key='webclient.home.report.table.header.by'/> <fmt:message key='${cprop.displayName}'/>-<fmt:message key='${ReportsPeriod}'/></font></span></td>       	 	
	</tr>
        </table>

    	<table width="99%" border="0" cellspacing="0" valign="top" cellpadding="0" class=homeTableDarkBorder >
           <tr class="homeHeader" height=22>
                <td valign="middle"  class="boldWhiteText"><fmt:message key = 'webclient.home.report.table.name'> <fmt:param><c:out value="${cprop.units}"/></fmt:param></fmt:message></td>
        	<td align="center" valign="middle" class="boldWhiteText"><fmt:message key = 'webclient.home.report.table.min'/></td>
        	<td align="center" valign="middle" class="boldWhiteText"><fmt:message key = 'webclient.home.report.table.max'/></td>
        	<td align="center" valign="middle" class="boldWhiteText"><fmt:message key = 'webclient.home.report.table.avg'/></td>
          </tr>

<%
    Vector vecProps = (Vector)cprop.get("CPUList");
    if(vecProps != null) {
    Enumeration enumm = vecProps.elements();
    int leng = vecProps.size();
    if(leng != 0) {

    int inc = 0;
    while(enumm.hasMoreElements())
    {
%>
        <c:choose>
           <c:when test="${inc%2==1}">
              <TR class="reportsOddRow" height=22>
           </c:when>
           <c:otherwise>
              <TR class="reportsEvenRow" height=22>
           </c:otherwise>
        </c:choose>
<%
inc = inc +1;
request.setAttribute("inc",""+inc);
Properties prop = (Properties)enumm.nextElement();
request.setAttribute("prop",prop);
if(prop != null)
{
String name = prop.getProperty("Name");

if(name != null) {
  
    //  <c:set var="tname" value="${prop.Name}" scope="request" />  
    //String name  = (String) request.getAttribute("tname");
    if (name.length() > 35)
    {
        request.setAttribute("trimname",(name.substring(0,33)+".."));
    } 
    else
    {
        request.setAttribute("trimname",name);
    }
}
   String width = prop.getProperty("Value");
   if(Integer.parseInt(width)>= 100)
   {
      width= "100";
   }
   request.setAttribute("widthSize",width);
         %>
        <td class="txtGlobal" width="50%" nowrap align="left">
<a class="linkNoUnderline" href="/topo/objectdetails.do?requestid=SNAPSHOT&name=<c:out value='${prop.Name}'/>&selectedTab=Network Database" title="<c:out value='${prop.Name}' />" >  <c:out value="${trimname}"/></a> </td> 
        <td class="txtGlobal" width="12%" nowrap align="center"><c:out value="${prop.MinValue}"/></td>
        <td class="txtGlobal" width="13%" nowrap align="center"><c:out value="${prop.MaxValue}"/></td>    
        

        <c:choose>
        <c:when test="${cprop.units == '%'}" >
        <td class="txtGlobal" width="25%" >
            <table height="10" class="progressTable" border="0" cellpadding="0" cellspacing="0">
               <tr class="txtGlobal"> 
                   <td nowrap ><img src="/webclient/common/images/green.gif" width="<c:out value='${widthSize}'/>" height="7" hspace="1"> <c:out value="${widthSize}"/></td>
               </tr>
            </table>
        </td>
        </c:when>
        <c:otherwise>
            <td class="txtGlobal" width="12%" nowrap align="center"> <c:out value="${prop.Value}"/></td>
        </c:otherwise>
        </c:choose>
    	</tr>
  
<%
}
}
}
else
{
%>
 <c:forEach begin="0" end="${ReportsLength-1}" varStatus="status">
             <c:choose>
                <c:when test="${status.count%2==1}">
                   <TR class="reportsEvenRow" height=22>
                </c:when>
                <c:otherwise>
                   <TR class="reportsOddRow" height=22>
                </c:otherwise>            
             </c:choose>
            <c:choose>
               <c:when test="${status.count==3}">
               <td width="100%" colspan =4 align="center"><span class="boldText"><fmt:message key='${cprop.displayName}'/> <fmt:message key='webclient.report.notavailable'/></span> </td>
               </c:when>
              <c:otherwise>
                    <td width="100%" nowrap class="txtGlobal" colspan =4 ></td>
              </c:otherwise>
            </c:choose> 
          </tr>
            </c:forEach>
<%

}
}
%>

</table >
</td>

<%
}
%>

</c:forEach>
</tr>
 <tr>
 <td colspan="2" height="10"> </td>
 </tr>
<%
}
 //</c:forEach >
}
%>

</table >

  </td>
  </tr>
</c:if>
</table>
</body>

</html>
