<!DOCTYPE html>

<%@ include file = "EgTrackerA.jsp" %>
<%@ page import="java.util.*"%>
<%@ taglib prefix="egui" uri="../WEB-INF/eg-taglib.tld"%>
<%
	response.setContentType("text/html;charset=UTF-8");
	String operation = request.getParameter("operation");
	String element = request.getParameter("element");
	String name = request.getParameter("name");
	session.setAttribute("elementType",element);
	session.setAttribute("elementName",name);
	String selectedTreeNode = request.getParameter("selectedTreeNode");
	String selectedPage = request.getParameter("selectedPage");
	if(selectedTreeNode != null && selectedPage != null)
	{
		session.setAttribute("backPageURL","EgAggregateTree.jsp?selectedTreeNode="+selectedTreeNode+"&selectedPage="+selectedPage);
		session.setAttribute("redirectPageURL","aggShowTypes.jsp?"+request.getQueryString());
	}
	String pageTitleStr = "admin.common."+getCamelCaseString(element)+" Aggregates";


	// for limited components
	String fromWizard = request.getParameter("fromWizard");
	if(com.egurkha.util.StringUtils.isNull(fromWizard))
	{
		fromWizard = "";
	}

	String compGlanceCompType = request.getParameter("compGlanceCompType");
	if (com.egurkha.util.StringUtils.isNull(compGlanceCompType))
	{
		compGlanceCompType = "";
	}
%>
<%!
	public String getCamelCaseString(String data)
	{
		if (data == null || data.length() == 0)
		{
			return "";
		}

		String result = data.toLowerCase();
		String firstLetter = result.substring(0,1);
		String remainLetter = result.substring(1);
		result = firstLetter.toUpperCase()+remainLetter;
		return result;
	}
%>
<html>
<head>
	<meta charset="utf-8">

	<egui:skin ui="admin"/>

	<script type="text/javascript" src="../extjs/ext-all.js"></script>

	<!-- Fancy Scroll-->
	<script src="/final/jquery/jquery.js"></script>
	<script src="/final/styles/jscrollpane/jquery.jscrollpane.js" ></script>
	<script src="/final/styles/jscrollpane/jquery.mousewheel.js" ></script>
	<script src="/final/styles/jscrollpane/mwheelIntent.js" ></script>
	<script language="JavaScript" src="/final/scripts/utilities/EncodeDecodeParams.js"></script>
	<link rel="stylesheet" href="/final/styles/jscrollpane/jquery.jscrollpane.css"/>

	<!-- Application folder -->
	<script type="text/javascript" src="AggregateShowTypes/app/app.js"></script>
	<script language="JavaScript1.2" src="eg_scripts/validate.js"></script>

	<script type="text/javascript">
	var csrfToken = '<%=strCsrfToken%>';
	var pageDesc = '<egui:intnl description="aggShowTypes.jsp"/>';
	var publicJSON='';
	var name= '<%=name%>';
	var element= '<%=element%>';
	var operation= '<%=operation%>';
	var pageTitle = '<egui:intnl text="<%=pageTitleStr%>"/> - <%=name%>';
	var infoTitle = '<egui:intnl text="<%=pageTitleStr%>"/>';
	var notSelectd= '<egui:intnl text="admin.server.No component type selected"/>';
	var licence_not_allow='<egui:intnl text="admin.error.Your license does not allow you to add any aggregate components"/>';
	var licence_allow_onlyone = '<egui:intnl text="admin.error.Your license allows you to add only one aggregate component"/>';
	var countExceed = '<egui:intnl text="admin.error.You have exceeded the number of monitored targets allowed by your license by "/>'
	var titleText= '<egui:intnl text="admin.server.DETAILS OF AGGREGATE COMPONENTS"/>';
	var component_type =  '<egui:intnl text="admin.server.Types of Aggregate"/>';
	var nickname ='<egui:intnl text="admin.server.Nick Names"/>';
	var addAllButton ='<egui:intnl text="admin.server.Add All"/>';
	var noAssociationFound = '<egui:intnl text="admin.server.No component is associated to this"/>'+" "+element+"  "+name+".";
	var gridTitle= '<egui:intnl text="admin.server.DETAILS OF AGGREGATE COMPONENTS"/>';
	var noSearchComponentFound = '<egui:intnl text="admin.server.No search component type found"/>';
	var invalid_form = '<egui:intnl text="admin.server.Form is invalid"/>';

	var probsErrorMessage = '<egui:intnl text="admin.error.Problem encountered while loading the user interface"/>';
	var requestTimeOut = '<egui:intnl text="admin.error.Response timed out"/>';
	var errorTitle = '<egui:intnl text="admin.user.Error"/>';
	var intnlLabel10 = '<egui:intnl text="admin.server.Show Aggregate Components"/>';
	var intnlLabel11 = '<egui:intnl text="admin.server.Hide Aggregate Components"/>';
	
	var srcNotFnd = '<egui:intnl text="admin.server.No component types found for your current search"/>.';
	var LoadAlert1 = '<div class="egFlexCenterByColumnWise" style="height:100%"><div class="iconInformation"></div><div class="commonErrorMsgText" id="noCompAlrtDiv">'+srcNotFnd+'</div></div>';

	// wizard design starts...
	var fromWizard = '<%=fromWizard%>';
	var compGlanceCompType = '<%=compGlanceCompType%>';
	var homeTitle = '<div>'+pageTitle+' <img src="/final/images/spacer.gif" id="homeTitle" class="iconInfoCircle" style="vertical-align:text-top;position:relative;top:2px"/></div>';
	//var createZoneTitle = '<div>'+pageTitle+' <img src="/final/images/spacer.gif" id="createZoneTitle" class="iconInfoCircle" style="vertical-align:text-top;position:relative;top:2px"/></div>';
	//var childPageTitle = '<div>'+subPageTitle+' <img src="/final/images/spacer.gif" id="childPageTitle" class="iconInfoCircle" style="vertical-align:text-top;position:relative;top:2px"/></div>';


	// wizard design ends..
	</script>

	<script language="javascript">
		Ext.onReady(function(){
			Ext.Ajax.extraParams = {"com.eg.CSRF_NONCE" : csrfToken};
			Ext.data.Connection.prototype.extraParams = {"com.eg.CSRF_NONCE" : csrfToken};
			Ext.data.ScriptTagProxy.prototype.extraParams = {"com.eg.CSRF_NONCE" : csrfToken};

			Ext.Ajax.on('requestexception', function (conn, response, options) {
				var errorStr = response.responseText;
				if (errorStr != undefined && errorStr != 'undefined' && errorStr.indexOf("customerror") != -1)
				{
					if (errorStr.indexOf("user-session-invalid") != -1)
					{
						callWindow(1);
					}
					else if (errorStr.indexOf("user-deleted") != -1)
					{
						callWindow(2);
					}
					else if (errorStr.indexOf("user-timedout") != -1)
					{
						callWindow(3);
					}
				}
				else
				{
					if (response.status == 302 || (response.timedout != undefined && response.timedout == true))
					{
						Ext.Msg.show({
							title : errorTitle,
							msg : requestTimeOut,
							buttons : Ext.Msg.OK,
							icon : 'iconError'
						});
					}
					else
					{
						console.log(response.responseText);
						Ext.Msg.show({
							title : errorTitle,
							msg : probsErrorMessage,
							buttons : Ext.Msg.OK,
							icon : 'iconError'
						});
					}
				}
			});
		});
	</script>
</head>
<body>
</body>
</html>

<%
	if (com.egurkha.util.StringUtils.isNull(fromWizard))
	{
		if(request.getQueryString()!= null)
		{
			session.setAttribute("adminLastAccessedURL","/final/admin/EgAggregateTree.jsp?"+request.getQueryString());
		}
		else
		{
			session.setAttribute("adminLastAccessedURL","/final/admin/EgAggregateTree.jsp");
		}
	}
%>