<%@  page pageEncoding="utf-8" contentType="text/html;charset=utf-8" import="com.novell.webaccess.common.JSPConduit, com.novell.emframe.dev.eMFrameUtils,
                                                                             com.novell.emframe.fw.config.ModuleInfo,
                                                                             java.util.*" %>
<%@ taglib uri="/WEB-INF/iman.tld" prefix="iman" %>
<%   JSPConduit c = JSPConduit.getJSPConduit(request);
   c.stringTable("DevResources");
   c.stringTable("BaseResources");
   c.stringTable("FwResources");%>

<HTML><HEAD><TITLE></TITLE>
<LINK rel='stylesheet' href='<%= c.getModulesUrl() + "/dev/css/hf_style.css" %>'>
<jsp:include page='<%= c.getPath("dev/eMFrameScripts_inc.jsp") %>' flush="true" />
	<script language="javascript">
   function checkboxSelect()
   {
      var i=0;
      var tag="Modules";
      var len = tag.length;
      if(document.getElementById("selectall").checked)
      {
         for(i=0; i<document.InstalledNPM.elements.length; i++)
         {
            var s = document.InstalledNPM.elements[i].name;
            if (s.substring(0,len)==tag)
            {
               document.InstalledNPM.elements[i].checked=true;
            }
         }
      }
      else
      {
         for(i=0; i<document.InstalledNPM.elements.length; i++)
         {
            var s = document.InstalledNPM.elements[i].name;
            if (s.substring(0,len)==tag)
            {
               document.InstalledNPM.elements[i].checked=false;
            }
         }
      }
   }


   function getSelectedModules()
   {
      var i = 0;
      var count = 0;
      var selectedItems = new Array();

      for(i=0; i<document.InstalledNPM.elements.length; i++)
      {
         if (document.InstalledNPM.elements[i].checked == true && document.InstalledNPM.elements[i].value != "selectall")
         {
            // Add it to the list
            selectedItems[count] = document.InstalledNPM.elements[i].value;
            count++;
         }
      }
      return (pack(selectedItems));
   }



   function deleteSelectedModules()
   {
      var ret = confirm( "<%= c.string("InstalledModules.ConfirmDelete") %>" );
      if( ret == true )
      {

         var i = 0;
         var count = 0;
         var selectedItems = new Array();

         for(i=0; i<document.InstalledNPM.elements.length; i++)
         {
            if (document.InstalledNPM.elements[i].checked == true && document.InstalledNPM.elements[i].value != "selectall")
            {
               // Add it to the list
               selectedItems[count] = document.InstalledNPM.elements[i].value;
               count++;
            }
         }

         var strUrl = "webacc?NPService=<%= c.var("taskId") %>&moduleaction=Delete&selectedItems=" + pack(selectedItems);
         window.location.href = strUrl;
      }
   }

   function uninstallSelectedModules()
   {
      var ret = confirm( "<%= c.string("InstalledModules.ConfirmUninstall") %>" );
      if( ret == true )
      {

         var i = 0;
         var count = 0;
         var selectedItems = getSelectedModules();

         var strUrl = "webacc?NPService=<%= c.var("taskId") %>&moduleaction=Uninstall&selectedItems=" + selectedItems;
         window.location.href = strUrl;
      }
   }

   function refreshModules()
   {
      var strUrl = "webacc?NPService=<%= c.var("taskId") %>&moduleaction=Refresh";
      window.location.href = strUrl;
   }

   </script>
</HEAD>
<BODY TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#000000" bgcolor="#FFFFFF">
<FORM name="InstalledNPM" method="post" action="webacc">
   <input type=hidden name="NPService" value="<%= c.var("taskId" ) %>">
   <input type=hidden name="moduleaction" value="InstalledNPM">

   <!-- End of hidden tags -->

   <% c.set("TaskHeader.title", c.string("InstalledModules.Modules"));
	   c.set("TaskHeader.iconUrl", "dir/object16.gif");
      c.set("TaskHeader.helpFile", "base/installednpm.html");%>

   <jsp:include page='<%= c.getPath("dev/TaskHeader_inc.jsp") %>' flush="true" />
<%--	<div class="formdescriptextml0"><%= c.string("InstalledModules.Description") %></div>--%>
<%--   <%--%>
<%--      String sError = (String)request.getAttribute( "ModulesError" );--%>
<%--      if( sError != null && sError.length() != 0 )--%>
<%--      { %>--%>
<%--         <table border="0" cellpadding="3" cellspacing="0">--%>
<%--            <tr>--%>
<%--                  <td>--%>
<%--                     <img ALIGN="absmiddle"--%>
<%--                        alt="<%= c.string( "Error" ) %>"--%>
<%--                        border="0"--%>
<%--                        src="<%= c.getModulesUrl() + "/dev/images/error32.gif" %>"/>--%>
<%--                  </td>--%>
<%--                  <td>--%>
<%--                     <div class="errormessage">--%>
<%--                        <%= sError %>--%>
<%--                     </div>--%>
<%--                  </td>--%>
<%--            </tr>--%>
<%--         </table>--%>
<%--   <% } %>--%>
   <table border="0" cellpadding="3" cellspacing="0">
      <tr>
         <td class="formdescriptextml0"><%= c.string("InstalledModules.Description") %></td>
      </tr>
   </table>
   <br>
   <iman:messagebar />
	<TABLE width="100%" border="0" cellspacing="0" cellpadding="3">
      	<TR class="tablehead1">
      		<TD colspan="5"><%= c.string( "InstalledModules.Modules" ) %></TD>
 		</TR>
      <tr class="tablesubhead1">
         <td colspan="5">
            <a href="#" onClick="javascript:refreshModules(); return false;">
               <%= c.string( "ModulesToInstall.Refresh" ) %>
            </a>
            |
            <a href="#" onClick="javascript:uninstallSelectedModules(); return false;">
               <%= c.string( "ModulesToInstall.Uninstall" ) %>
            </a>
         </td>
      </tr>
		<tr class="tablesubhead1">
			<td style="border-bottom: 1px solid black; padding-left:7"><input onclick="checkboxSelect()" id="selectall" type="checkbox" name="selectall" value="selectall" title='<%= c.string( "ModulesToInstall.SelectAll" ) %>' alt='<%= c.string( "ModulesToInstall.SelectAll" ) %>'>
			<td style="border-bottom: 1px solid black; padding-left:7"><%= c.string( "ModulesToInstall.Name" ) %></td>
			<td style="border-bottom: 1px solid black; padding-left:7" nowrap="true"><%= c.string( "InstalledModules.LocalVersion" ) %></td>
			<td width="100%" style="border-bottom: 1px solid black; padding-left:7"><%= c.string( "ModulesToInstall.Description" ) %></td>
		</tr>
      <%
         ArrayList htModules = (ArrayList)request.getAttribute( "InstalledNPM");
         if(htModules.size() > 0)
         {
            for(int i = 0; i < htModules.size(); i++)
            {
               ModuleInfo mInfo = (ModuleInfo)htModules.get(i);
               String sModuleID =  mInfo.getModuleID();

               out.write( "<tr class='smalltext' ><td style='padding-left:10'>"); %>
               <input type="checkbox" name="Modules<%= i %>" value="<%= sModuleID %>">
               <%
               out.write( "</td><td nowrap='true' style='padding-left:10'>" + mInfo.getModuleTitle() );
               if( mInfo.getModuleVersion() != null )
                  out.write( "</td><td style='padding-left:10'>" + mInfo.getModuleVersion() );
               else
                  out.write( "</td><td style='padding-left:10'>" + "<font color='#aaaaaa'>" + c.string( "InstalledModules.notinstalled" ) + "</font>" );
               if( mInfo.getModuleDescription() != null )
                  out.write( "</td><td style='padding-left:10'>" + mInfo.getModuleDescription() );
               else
                  out.write( "</td><td style='padding-left:10'>" );
               out.write( "</td></tr>" );
            }
         }
         else
         {
            out.write( "<tr><td colspan='5' style='padding:30'><i>" + c.string( "InstalledModules.NoModulesInstalled" ) + "</i></td></tr>");
         }
		 %>

      <tr>
         <jsp:include page='<%= c.getPath("dev/Bar_inc.jsp") %>' flush="true" />
      </tr>
      <tr>
         <a href="webacc?NPService=fw.LaunchService&NPAction=Return&returnID=<%= c.var("taskId") %>"><IMG src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.Close.image") %>" border=0></a>
      </tr>
   </TABLE>

</FORM>
</BODY></HTML>

