<%--
  -- @(#)topologySnapshot.jsp	1.27 02/03/03
  -- Copyright 2001 Sun Microsystems, Inc., All Rights Reserved.
  -- Display list of snapshots.
  -- @version 1.27, 02/03/03
  -- @author  Pascal Ledru
  --
  --%>

<%@ 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" %>

<jsp:include page="header.jsp"/>
<script language="JavaScript1.2" src="../js/checkbox.js">
</script>

<%
  String sortRule = request.getParameter("sortRule");
  String sortedProperty = request.getParameter("sortedProperty");
  if(sortedProperty == null)
	sortedProperty = "time";
%>

<script language="JavaScript1.2">

  function add() {
	window.location = "/jade/jsp/topologyAddition.jsp";
  }

  function validate() {
	 ret = numOfChecked(document.topoSnapshot,"snapshot");
	 if(document.topoSnapshot.submitControl.value == "delete") {
	   	 if (ret[0] == 0) {
                           alert('<bean:message key="note.atLeastOneTopologyToDelete"/>');
	                   return false;
        	 } 
       		 else {
                           return true;
        	 }
	 } else {
		return true;
	 }
  }

  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 != "- Actions -")
			if(theForm.mode.options[i].value == "delete") {
                          ret = numOfChecked(document.topoSnapshot,"snapshot");
		          if (ret[0] == 0) {
                              alert('<bean:message key="note.atLeastOneDeviceToDelete"/>');
                          } 
                          else {
                            document.topoSnapshot.submit();
                          }
		        }
			else 
                	  window.location = theForm.mode.options[i].value; 
   }  
  }
  
</script>

<html:html locale="true">

<app:topologySnapshot/>
<app:contentState/>

<app:sortOption/>
<jsp:setProperty name="sortOption" property="beanListName" value="topologySnapshots"/>
<jsp:setProperty name="sortOption" property="beanClassName" value="com.sun.jade.web.topology.Snapshot"/>
<jsp:setProperty name="sortOption" property="propertyList" value="name,time"/>
<jsp:setProperty name="sortOption" property="sortedProperty" value="<%=sortedProperty%>"/>
<jsp:setProperty name="sortOption" property="sortRule" value="<%=sortRule%>"/>
<app:sort/>


<logic:present name="contentStateBean" scope="session">
   <jsp:setProperty name="contentStateBean" property="contentFrameSource" value="topologySnapshot.jsp"/>
</logic:present>


<body bgcolor="#FFFFFF" leftmargin="0" marginwidth="0" marginheight="0" topmargin="0">

  <jsp:include page="masthead.jsp">
    <jsp:param name="category"    value="topology"/>
    <jsp:param name="subCategory" value="historical"/>
  </jsp:include>

 <%
   BreadCrumbBean bcb1 = new BreadCrumbBean();	
   bcb1.setDisplayName("topologyCurrent");
   bcb1.setLink("topology.jsp");

   BreadCrumbBean bcb2 = new BreadCrumbBean();	
   bcb2.setDisplayName("historical");

   java.util.ArrayList breadCrumb = new java.util.ArrayList();
   breadCrumb.add(bcb1);
   breadCrumb.add(bcb2);

   pageContext.setAttribute("breadCrumbBeanList",breadCrumb);
%>
  <component:breadCrumb beanListName = "breadCrumbBeanList" />

<form name="topoSnapshot" action="/jade/topologyDeleter" method=POST>
<input type=hidden name="submitControl">
 <DIV class="content-layout">

 <logic:present name="alertBean" scope="page">
 <component:bigHorizontalSpacer />
 <component:inlineAlert beanName="alertBean" /> 
 </logic:present>

 <component:bigHorizontalSpacer />   
 <div class="table-title-text"><bean:message key="title.topologySnapshot"/></div>
 <component:smallHorizontalSpacer />
 <component:buttonGroup formName="topoSnapshot" buttonNames="button.delete"
	                       buttonValues="delete" buttonChecks="no" 
			       validateFunction="validate"  
                               buttonType="mini" controlName="submitControl" />
 <component:smallHorizontalSpacer />    
 <component:table propertyList="nameWithLink,date"
                       categoryList="header.name,header.date"
                       beanListName="topologySnapshots"
                       beanClassName="com.sun.jade.web.topology.Snapshot"
                       hasSort="yes"
                       hasCheckbox="yes"
                       checkboxName="snapshot"
                       checkboxValue="name"
                       formName="topoSnapshot" 
                       emptyTableIndication="noSavedTopologies"
                       sourcePage="topologySnapshot.jsp" />
 </DIV>

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