<!DOCTYPE html>

<%@ include file="EgTrackerA.jsp" %>
<%@ page import = "egurkha.reporter.ErUtils"%>
<%@ page import = "com.egurkha.util.StringUtils"%>
<%@ taglib prefix ="egui" uri="../WEB-INF/eg-taglib.tld"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>

<%
	String isSubmit = request.getParameter("isSubmit");
	String queryStringForNewUI =(String)ErUtils.prepareQueryString(request.getParameterMap());
	String server = request.getParameter("server");
	String comp = request.getParameter("comp");
	String test = request.getParameter("testName");
	String duration = request.getParameter("duration");
	String strEnableSearch = request.getParameter("strEnabledSearch");
	String strDisableSearch = request.getParameter("strDisabledSearch");
	String requestFrom = request.getParameter("requestFrom");
	String reqfrom = request.getParameter("reqfrom");
	String criteria = request.getParameter("criteria");
	String userOption = request.getParameter("userOption");

	if ( StringUtils.isNull(reqfrom) )
	{
		reqfrom = "";
	}

	if ( StringUtils.isNull(criteria) )
	{
		criteria = "";
	}

	if ( StringUtils.isNull(userOption) )
	{
		userOption = "";
	}

	if ( StringUtils.isNull(server) )
	{
		server = "";
	}

	if ( StringUtils.isNull(comp) )
	{
		comp = "";
	}
	if ( StringUtils.isNull(test) )
	{
		test = "";
	}
	if ( StringUtils.isNull(duration) )
	{
		duration = "";
	}
	if ( StringUtils.isNull(strEnableSearch) )
	{
		strEnableSearch = "";
	}
	if ( StringUtils.isNull(strDisableSearch) )
	{
		strDisableSearch = "";
	}
	if ( StringUtils.isNull(requestFrom) )
	{
		requestFrom = "";
	}
%>
<html>
<head>
<title>Enable/Disable Test descriptors</title>
<meta charset="utf-8">
	<title>SAMPLES</title>

	<!--Skin color--------->
	<egui:skin ui = "admin"/>

	<!---Components, icons, skin and Core ext script--->
	<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>
	<link rel="stylesheet" href="/final/styles/jscrollpane/jquery.jscrollpane.css"/>


	<script language="JavaScript1.2" src="eg_scripts/validate.js"></script>
	<script language="JavaScript1.2" src="../scripts/<%=script_src%>"></script>

	<!-- Application folder -->
	<script src="TestDescriptors/app/app.js"></script>
</head>
<body>
<script language='javascript'>
	var csrfToken = '<%=strCsrfToken%>';
	var pageDesc = '<egui:intnl description="EgTestInfoView.jsp"/>';
	var pageName = "Enable/Disable Test Descriptor";
	var alert1 = '<egui:intnl text="admin.test.Please select a component type"/>';
	var alert2 = '<egui:intnl text="admin.test.No disabled descriptors selected"/>';
	var alert3 = '<egui:intnl text="admin.test.Please UPDATE your enable/disable changes before attempting to delete a component"/>';
	var alert4 = '<egui:intnl text="admin.test.Are you sure you want to delete the selected descriptors"/>'+'?';
	var alert5 = '<egui:intnl text="admin.test.Please select a component name"/>';
	var alert6 = '<egui:intnl text="admin.test.Please select a test"/>';
	var alert7 = '<egui:intnl text="admin.test.Please enable or disable atleast one descriptor"/>';
	var alert8 = '<egui:intnl text="admin.test.Please select atleast one descriptor from the available or disabled descriptors list"/>';
	var noAvailableDescSelecedMsg = '<egui:intnl text="admin.test.No Available Descriptor(s)"/>';
	var noAvailableDescSelecedMsg1 = '<egui:intnl text="admin.test.Please select an available Descriptor(s)"/>';
	var noDisabledDescSelecedMsg = '<egui:intnl text="admin.test.No Disabled Descriptor(s)"/>';
	var noDisabledDescSelecedMsg1 = '<egui:intnl text="admin.test.please select a disabled Descriptor(s)"/>';
	var isDescriptorChanged = true;
	var publicJson = '';
	var isSubmit = '<%=isSubmit%>';
	var defaultParams = '<%=queryStringForNewUI%>';
	var criteria = '<%=criteria%>';
	var userOption = '<%=userOption%>';
	var compType = '<%=server%>';
	var test = '<%=test%>';
	var comp = '<%=comp%>';
	var duration = '<%=duration%>';
	var enableFind = '<%=strEnableSearch%>';
	var disableFind = '<%=strDisableSearch%>';
	var requestFrom = '<%=requestFrom%>';

	if ('<%=reqfrom%>' == 'navlink')
	{
		sessionStorage.removeItem('criteria');
		sessionStorage.removeItem('userOption');
	}

	var label1 = '<egui:intnl text="admin.test.Component type"/>';
	var label2 = '<egui:intnl text="admin.test.Test"/>';
	var label3 = '<egui:intnl text="admin.test.Show active descriptors for"/>';
	var label4 = '<egui:intnl text="admin.test.Component name"/>';
	var label5 = '<egui:intnl text="admin.test.Add to Disabled"/>';
	var label6 = '<egui:intnl text="admin.test.Remove from Disabled"/>';
	var label7 = '<egui:intnl text="admin.test.Available Descriptors"/>';
	var label8 = '<egui:intnl text="admin.test.Disabled Descriptors"/>';
	var label9 = '<egui:intnl text="admin.test.View By"/>';

	var existingParams = '';
	var pageApplyDesc = '<egui:intnl description="EgApplyToOtherComponents.jsp"/>';
	var Back = '<egui:intnl text="admin.db.Back"/>';
	var applyPageDesc = pageName+' - '+'<egui:intnl text= "admin.test.Apply Configuration" />';
	var viewBy = '<egui:intnl text= "admin.test.View By" />';
	var zoneServLbl = '<egui:intnl text= "admin.test.Zone/Service/Segment" />';
	var apply_fromTitle = '<egui:intnl text= "admin.test.Components to be configured" />';
	var apply_toTitle = '<egui:intnl text= "admin.test.Existing components" />';
	var applyTitle = applyPageDesc;
	var alertMsg5 = '<egui:intnl text="admin.test.Please choose component(s) to be configured"/>';
	var alertMsg4 = '<egui:intnl text="admin.test.Please choose a descriptor" />';
	var confirmMsg1 = '<egui:intnl text="admin.test.Do you want to continue with this configuration" />'+'?';
	var alertMsg78 = '<egui:intnl text="admin.test.Changes have been configured successfully"/>';

	var paramName = '<egui:intnl text= "admin.test.Descriptor Name" />';
	var paramValue = '<egui:intnl text= "admin.test.Action Initiated" />';
	var btnText1 = '<egui:intnl text="admin.common.Apply to other components"/>';
	var btnText2 = '<egui:intnl text="admin.common.Update"/>';
	var btnText3 = '<egui:intnl text="admin.common.Apply"/>';
	var delText = '<egui:intnl text="admin.common.Delete"/>';
	var processUpdateMsg = '<egui:intnl text="admin.test.Changes have been updated successfully"/>';
	var noDataMsg = '<egui:intnl text="admin.test.No descriptors available for this test"/>';

	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"/>';

	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>
</body>
</html>

<%
	if(request.getQueryString() != null)
	{
		session.setAttribute("adminLastAccessedURL","/final/admin/EgTestInfoView.jsp?"+request.getQueryString());
	}
	else
	{
		session.setAttribute("adminLastAccessedURL","/final/admin/EgTestInfoView.jsp");
	}
%>



