aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html
blob: a527f53e6f2cded48af65961959971126b41dea7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

@media only all and (prefers-color-scheme: dark) {
.highlight .hll { background-color: #49483e }
.highlight .c { color: #75715e } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
.highlight .k { color: #66d9ef } /* Keyword */
.highlight .l { color: #ae81ff } /* Literal */
.highlight .n { color: #f8f8f2 } /* Name */
.highlight .o { color: #f92672 } /* Operator */
.highlight .p { color: #f8f8f2 } /* Punctuation */
.highlight .ch { color: #75715e } /* Comment.Hashbang */
.highlight .cm { color: #75715e } /* Comment.Multiline */
.highlight .cp { color: #75715e } /* Comment.Preproc */
.highlight .cpf { color: #75715e } /* Comment.PreprocFile */
.highlight .c1 { color: #75715e } /* Comment.Single */
.highlight .cs { color: #75715e } /* Comment.Special */
.highlight .gd { color: #f92672 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gi { color: #a6e22e } /* Generic.Inserted */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #75715e } /* Generic.Subheading */
.highlight .kc { color: #66d9ef } /* Keyword.Constant */
.highlight .kd { color: #66d9ef } /* Keyword.Declaration */
.highlight .kn { color: #f92672 } /* Keyword.Namespace */
.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */
.highlight .kr { color: #66d9ef } /* Keyword.Reserved */
.highlight .kt { color: #66d9ef } /* Keyword.Type */
.highlight .ld { color: #e6db74 } /* Literal.Date */
.highlight .m { color: #ae81ff } /* Literal.Number */
.highlight .s { color: #e6db74 } /* Literal.String */
.highlight .na { color: #a6e22e } /* Name.Attribute */
.highlight .nb { color: #f8f8f2 } /* Name.Builtin */
.highlight .nc { color: #a6e22e } /* Name.Class */
.highlight .no { color: #66d9ef } /* Name.Constant */
.highlight .nd { color: #a6e22e } /* Name.Decorator */
.highlight .ni { color: #f8f8f2 } /* Name.Entity */
.highlight .ne { color: #a6e22e } /* Name.Exception */
.highlight .nf { color: #a6e22e } /* Name.Function */
.highlight .nl { color: #f8f8f2 } /* Name.Label */
.highlight .nn { color: #f8f8f2 } /* Name.Namespace */
.highlight .nx { color: #a6e22e } /* Name.Other */
.highlight .py { color: #f8f8f2 } /* Name.Property */
.highlight .nt { color: #f92672 } /* Name.Tag */
.highlight .nv { color: #f8f8f2 } /* Name.Variable */
.highlight .ow { color: #f92672 } /* Operator.Word */
.highlight .w { color: #f8f8f2 } /* Text.Whitespace */
.highlight .mb { color: #ae81ff } /* Literal.Number.Bin */
.highlight .mf { color: #ae81ff } /* Literal.Number.Float */
.highlight .mh { color: #ae81ff } /* Literal.Number.Hex */
.highlight .mi { color: #ae81ff } /* Literal.Number.Integer */
.highlight .mo { color: #ae81ff } /* Literal.Number.Oct */
.highlight .sa { color: #e6db74 } /* Literal.String.Affix */
.highlight .sb { color: #e6db74 } /* Literal.String.Backtick */
.highlight .sc { color: #e6db74 } /* Literal.String.Char */
.highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */
.highlight .sd { color: #e6db74 } /* Literal.String.Doc */
.highlight .s2 { color: #e6db74 } /* Literal.String.Double */
.highlight .se { color: #ae81ff } /* Literal.String.Escape */
.highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */
.highlight .si { color: #e6db74 } /* Literal.String.Interpol */
.highlight .sx { color: #e6db74 } /* Literal.String.Other */
.highlight .sr { color: #e6db74 } /* Literal.String.Regex */
.highlight .s1 { color: #e6db74 } /* Literal.String.Single */
.highlight .ss { color: #e6db74 } /* Literal.String.Symbol */
.highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #a6e22e } /* Name.Function.Magic */
.highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */
.highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */
.highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */
.highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */
.highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */
}
@media (prefers-color-scheme: light) {
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
}
/**
 * ============LICENSE_START=======================================================
 * org.onap.aai
 * ================================================================================
 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */
package org.onap.aai.rest;

import com.jayway.jsonpath.JsonPath;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.aai.AAIJunitRunner;
import org.onap.aai.HttpTestUtil;
import org.onap.aai.PayloadUtil;
import org.skyscreamer.jsonassert.JSONAssert;

import javax.ws.rs.core.Response;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import static org.junit.Assert.assertEquals;

@RunWith(AAIJunitRunner.class)
public class TenantTest {

    private HttpTestUtil httpTestUtil;

    private Map<String, String> templateValuesMap;

    @Before
    public void setup(){
        httpTestUtil      = new HttpTestUtil();
        templateValuesMap = new HashMap<>();
    }

    @Ignore("Test is failing due to the deletion of node with children not correct will be fixed soon")
    @Test
    public void testCloudRegionTenantDeleteSuccessWithoutDeletingVserver() throws Exception {

        templateValuesMap.put("cloud-region-id", UUID.randomUUID().toString());
        templateValuesMap.put("cloud-owner", UUID.randomUUID().toString());
        templateValuesMap.put("tenant-id", UUID.randomUUID().toString());
        templateValuesMap.put("vserver-id", UUID.randomUUID().toString());

        String cloudRegionPayload = PayloadUtil.getTemplatePayload("cloud-region.json", templateValuesMap);
        String cloudRegionUri = String.format("/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/%s/%s",
                templateValuesMap.get("cloud-owner"),
                templateValuesMap.get("cloud-region-id")
        );

        String tenantUri = cloudRegionUri + "/tenants/tenant/" + templateValuesMap.get("tenant-id");
        String tenantPayload = PayloadUtil.getTemplatePayload("tenant.json", templateValuesMap);

        Response response     = httpTestUtil.doPut(cloudRegionUri, cloudRegionPayload);
        assertEquals("Expected the cloud region to be created", 201, response.getStatus());

        response     = httpTestUtil.doGet(tenantUri);
        assertEquals("Expected the cloud region to be created", 200, response.getStatus());
        String responseStr = response.getEntity().toString();

        JSONAssert.assertEquals(tenantPayload, responseStr, false);
        String resourceVersion = JsonPath.read(responseStr, "$.resource-version");

        response     = httpTestUtil.doDelete(tenantUri, resourceVersion);
        assertEquals("Expected the cloud region to be created", 204, response.getStatus());

        response     = httpTestUtil.doGet(cloudRegionUri);
        assertEquals("Expected the cloud region to be created", 200, response.getStatus());
        responseStr = response.getEntity().toString();
        resourceVersion = JsonPath.read(responseStr, "$.resource-version");

        response     = httpTestUtil.doDelete(cloudRegionUri, resourceVersion);
        assertEquals("Expected the cloud region to be created", 204, response.getStatus());
    }
}
753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939
<!--
  ============LICENSE_START=======================================================
  ONAP CLAMP
  ================================================================================
  Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
                              reserved.
  ================================================================================
  Licensed under the Apache License, Version 2.0 (the "License"); 
  you may not use this file except in compliance with the License. 
  You may obtain a copy of the License at
  
  http://www.apache.org/licenses/LICENSE-2.0
  
  Unless required by applicable law or agreed to in writing, software 
  distributed under the License is distributed on an "AS IS" BASIS, 
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
  See the License for the specific language governing permissions and 
  limitations under the License.
  ============LICENSE_END============================================
  ===================================================================
  
  -->


<style>
#deletePolicy {
	height: 34px;
	background-color: #dddd;
}

.disabled {
	background-color: #dddd;
}

.modelSearchBox {
	position: absolute;
	padding: 25px 12px;
}

label {
	text-align: right;
	vertical-align: middle;
}

.leftPolicyPanel {
	padding: 0 10px 0 0;
}

#createNewPolicy {
	height: 34px;
	width: 120px; /*84*/
	background-color: #f2bfab;
}

.idError {
	color: red;
	padding: 50px 0px;
	text-align: center;
	display: none;
}

.policyPanel {
	background-color: #f5f5f5;
	padding: 15px 5px 0 5px;
}

.form-group.clearfix {
	display: -webkit-flex;
	display: flex;
	align-items: center;
}

label {
	margin-bottom: 0px;
}

#policySearch {
	height: 33px;
	font-size: 12px;
	padding: 2px 2px 2px 30px;
	margin-bottom: 5px;
	width: 100%;
}

#policyTable {
	cursor: pointer;
	width: 100%;
}

#policyTable tr {
	border-bottom: 1px solid #ddd;
	border-collapse: collapse;
	text-align: left;
	font-size: 12px;
	font-weight: normal;
}

#policyTable td {
	padding: 8px 10px;
}

#policyTable tr.highlight {
	background-color: #f5f5f5;
	font-weight: bold;
	font-size: 13px;
}

#policyTableHolder {
	height: 200px;
	width: 100%;
	overflow: auto;
}
</style>


<div attribute-test="policywindowproperties" id="configure-widgets"
	class="disabled-block-container">
	<div attribute-test="policywindowpropertiesh" class="modal-header">
		<button type="button" class="close" ng-click="close(false)"
			aria-hidden="true" style="margin-top: -3px">&times;</button>
		<h4>Operational Policy</h4>
	</div>


	<div class="modal-body">
		<div attribute-test="policywindowpropertiesb" class="modal-body row">

			<div class="leftPolicyPanel">
				<div class="panel panel-default">
					<i class="glyphicon glyphicon-search modelSearchBox"></i> <input
						type="text" id="policySearch" onkeyup="searchPolicyList()"
						placeholder="Search ...">
					<div id="policyTableHolder">
						<table id="policyTable"></table>
					</div>
				</div>
				<div style="float: left">
					<button type="button" id="createNewPolicy" class="btn btn-sm">New
						Policy</button>
					</span>
				</div>
				<div style="float: right">
					<button type="button" id="deletePolicy"
						class="btn btn-sm glyphicon glyphicon-trash" disabled></button>
					</span>
				</div>
				<div id="repeatIdError" class="idError">Error: This Policy
					name is already taken.</div>
				<div id="newIdError" class="idError">Error: Please rename your
					new Policy.</div>
				<div id="spaceError" class="idError">Error: Spaces are not
					allowed in the ID.</div>
			</div>

			<div class="panel panel-default col-sm-9 policyPanel"
				style="display: none;">
				<form id="Timeoutform" class="form-horizontal">
					<div>
						<div class="form-group clearfix row">
							<label class="col-sm-2">Name</label>
							<div class="col-sm-3" style="padding: 0px;">
								<input type="text" id="pname" name="pname" maxlength="48"
									placeholder="Enter Unique Name" class="form-control">
							</div>

							<label class="col-sm-1">ID</label>
							<div class="col-sm-1" style="padding: 0px;">
								<input onkeydown="return false;" type="text" id="pid" name="pid"
									class="form-control" readonly>
							</div>

							<label for="userID" class="col-sm-3"
								style="padding-left: 5px; padding-right: 10px;">Overall
								Time Limit</label>
							<div class="col-sm-2" style="padding-left: 0px;">
								<input type="text" maxlength="10"
									onkeypress="return isNumberKey(event)" class="form-control"
									id="timeout" name="timeout">
							</div>
						</div>
					</div>
				</form>
				<div class="panel-heading" style="background-color: white;">
					<ul id="nav_Tabs" class="nav nav-tabs">
						<li class><a id="add_one_more" href="#desc_tab"><span
								class="glyphicon glyphicon-plus" aria-hidden="true"></span></a></li>
					</ul>
				</div>
				<div class="panel-body">
					<div class="tab-content">
						<div id="properties_tab" class="tab-pane fade in active"></div>
					</div>
				</div>
			</div>

			<span id="formSpan" style="display: none">
				<form class="saveProps" class="form-horizontal">
					<div>
						<div class="form-group clearfix">
							<label class="col-sm-4 control-label" for="recipe">Recipe</label>
							<div class="col-sm-8">
								<select class="form-control" name="recipe" id="recipe"
									enableFilter="true"></select>
							</div>
						</div>
						<div class="form-group clearfix">
							<label for="maxRetries" class="col-sm-4 control-label">
								Max Retries</label>
							<div class="col-sm-8">
								<input type="text" maxlength="5" class="form-control"
									id="maxRetries" onkeypress="return isNumberKey(event)"
									name="maxRetries"> </input>
							</div>
						</div>
						<div class="form-group clearfix">
							<label for="retryTimeLimit" class="col-sm-4 control-label">
								Retry Time Limit</label>
							<div class="col-sm-8">
								<input type="text" maxlength="5" class="form-control"
									id="retryTimeLimit" onkeypress="return isNumberKey(event)"
									name="retryTimeLimit"></input>
							</div>
						</div>
						<div style="display: none;" class="form-group clearfix">
							<label for="_id" class="col-sm-4 control-label"> PolicyID</label>
							<div class="col-sm-8">
								<input type="text" onkeydown="return false;"
									class="form-control" id="_id" name="_id" value=""></input>
							</div>
						</div>
						<div class="form-group clearfix">
							<label for="parentPolicy" class="col-sm-4 control-label">
								Parent Policy</label>
							<div class="col-sm-8">
								<select class="form-control" id="parentPolicy"
									name="parentPolicy" enableFilter="true"><option
										value=""></option></select>
							</div>
						</div>
						<div class="form-group clearfix">
							<label for="parentPolicyConditions"
								class="col-sm-4 control-label"> Parent Policy Conditions</label>
							<div class="col-sm-8">
								<select class="form-control" id="parentPolicyConditions"
									name="parentPolicyConditions" multiple></select>
							</div>
						</div>
						<div class="form-group clearfix">

							<label for="actor" class="col-sm-4 control-label"> Actor</label>
							<div class="col-sm-8">
								<select class="form-control" id="actor" name="actor"></select>
							</div>

							<label for="payload" class="col-sm-4 control-label">
								Payload</label>
							<div class="col-sm-8">
								<textarea class="form-control" id="recipeInput" name=recipeInput></textarea>
							</div>
						</div>
						<div class="form-group clearfix">
							<label for="targetType" class="col-sm-4 control-label">
								Target Type</label>
							<div class="col-sm-8">
								<select class="form-control" name="recipeLevel" id="recipeLevel">
								</select>
							</div>

							<label for="targetResourceId" class="col-sm-4 control-label">
								Target ResourceId</label>
							<div class="col-sm-8">
								<select class="form-control" name="targetResourceId"
									id="targetResourceId" enableFilter="true"
									onchange="changeTargetResourceIdOther();">
									<option value=""></option>
									<option value="Other:">Other:</option>
								</select>
							</div>
							<input type="text" style="display: none" class="form-control"
								id="targetResourceIdOther" name="targetResourceIdOther" value=""></input>
						</div>
						<div style="border: 2px dotted gray;">
							<div class="form-group clearfix">
								<label for="enableGuardPolicy" class="col-sm-4 control-label">
									Enable Guard Policy</label>
								<div class="col-sm-8">
									<input type="checkbox" class="form-control"
										name="enableGuardPolicy" id="enableGuardPolicy">
								</div>
								<div class="col-sm-8">
									<label for="guardPolicyType" class="col-sm-4 control-label">
										Guard Policy Type</label> 
										<select class="form-control"
										name="guardPolicyType" id="guardPolicyType"
										onchange="changeGuardPolicyType();">
										<option value="GUARD_MIN_MAX">MinMax</option>
										<option value="GUARD_YAML">FrequencyLimiter</option>
									</select>
								</div>
								<label for="guardTargets" class="col-sm-4 control-label">Guard
									targets</label>
								<div class="col-sm-8">
									<input class="form-control" name="guardTargets"
										id="guardTargets" />
								</div>
							</div>

							<div class="form-group clearfix" id="minMaxGuardPolicyDiv">
								<label for="minGuard" class="col-sm-4 control-label">
									Min Guard</label>
								<div class="col-sm-8">
									<input class="form-control" name="minGuard" id="minGuard" />
								</div>
								<label for="maxGuard" class="col-sm-4 control-label">
									Max Guard</label>
								<div class="col-sm-8">
									<input class="form-control" name="maxGuard" id="maxGuard" />
								</div>
							</div>
							<div class="form-group clearfix"
								id="frequencyLimiterGuardPolicyDiv" style="display: none">
								<label for="limitGuard" class="col-sm-4 control-label">Limit</label>
								<div class="col-sm-8">
									<input class="form-control" name="limitGuard" id="limitGuard" />
								</div>
								<div class="col-sm-8">
									<select class="form-control" name="timeUnitsGuard"
										id="timeUnitsGuard" /> <label for="timeWindowGuard"
										class="col-sm-4 control-label">Time Window</label>
								</div>
								<div class="col-sm-8">
									<input class="form-control" name="timeWindowGuard"
										id="timeWindowGuard" />
								</div>
							</div>
							<div class="form-group clearfix">
								<label for="guardActiveStart" class="col-sm-4 control-label">
									Guard Active Start</label>
								<div class="col-sm-8">
									<input class="form-control" name="guardActiveStart"
										id="guardActiveStart" />
								</div>
								<label for="guardActiveEnd" class="col-sm-4 control-label">
									Guard Active End</label>
								<div class="col-sm-8">
									<input class="form-control" name="guardActiveEnd"
										id="guardActiveEnd" />
								</div>
							</div>
						</div>
					</div>
				</form>
			</span>
		</div>
	</div>

	<div attribute-test="policywindowpropertiesf" class="modal-footer">
		<!--<button ng-click="reset()" class="btn btn-primary" style="float:left">Reset</button>-->
		<button id="savePropsBtn" class="btn btn-primary">Close</button>
		<button ng-click="close(true)" id="close_button"
			class="btn btn-primary">Cancel</button>
	</div>

	<script>
	
	function initTargetResourceId() {
		// Set all the Resource Invariant UUID in the target resource ID list (+Empty and other) 
		Object.keys(vf_Services["shared"]["byVf"]).forEach(function(key){
			$('#targetResourceId').append($('<option></option>').val(key).html(key));
		});
	}
	
	function changeTargetResourceIdOther() {
		if ($("#targetResourceId").val()==="Other:") {
			$("#targetResourceIdOther").show();
		} else {
			$("#targetResourceIdOther").hide();
			$("#targetResourceIdOther").val("");
		}
	}

	function changeGuardPolicyType() {
		console.log("executing GuardPolicyType")
		console.log("GuardPolicyType value:"+$("#guardPolicyType").val())
		if ($("#guardPolicyType").val()==="GUARD_MIN_MAX") {
			$("#minMaxGuardPolicyDiv").show();
			$("#frequencyLimiterGuardPolicyDiv").hide();
		} else if ($("#guardPolicyType").val()==="GUARD_YAML") {
			$("#minMaxGuardPolicyDiv").hide();
			$("#frequencyLimiterGuardPolicyDiv").show();
		}
	}
		//Basically this method will add a new form. All forms share the same class. When you want one form to show(active form) the other forms get the 
		// css attribute display:none
		$("#add_one_more").click(function(event) {
			event.preventDefault();
			var num = add_one_more();
			setMultiSelect();
		});
		loadPropertyWindow("policy")
		
		// by default, parentPolicyConditions is disabled
		//$("#parentPolicyConditions").prop('disabled', 'disabled');
		var parent_policy={}
		var policy_ids={}
		var loadingId=false;
		var allPolicies={};
		var allPolIds=[];
		
		//Grab saved values for dropdowns
		var obj = elementMap[lastElementSelected];
		
		if (!($.isEmptyObject(obj))){
			allPolicies = jQuery.extend({}, obj);			
			for (var x in allPolicies){
				$("#policyTable").prepend("<tr><td>"+x+"</td></tr>");
				if (allPolicies[x][1]['value']){
					allPolIds.push(parseInt(allPolicies[x][1]['value']));
				}
			}
		}
		$("#pname").val('');		

		//load recipes for a chosen policy
		function disperseConfig(policyObj, id){
			parent_policy={};
			//remove old gui forms
			for (var i=1; i<($(".formId").length + 1); i++){
				$("#go_properties_tab"+i).parent().remove();
			}
			$(".formId").remove();
			
			if (policyObj !== undefined) {
				var el = policyObj[id][3]['policyConfigurations']
				for (var i = 0; i < el.length; i++) {
					loadingId=true;
					var num = add_one_more();
					loadingId=false;
					for (var j = 0; j < el[i].length; j++) {
						if(el[i][j].hasOwnProperty("name")){
							$("#formId" + num + " #" + el[i][j].name).val(
									el[i][j].value);
							if(el[i][j].name==="_id")
								policy_ids["#formId" + num]=el[i][j].value
							if(el[i][j].name==='parentPolicy')
								parent_policy[num]=el[i][j].value 
							if(el[i][j].name==='recipe' && el[i][j].value.toString()!==''){
								$("#go_properties_tab"+num).text(el[i][j].value)
							}
							if(el[i][j].name==="targetResourceIdOther" && el[i][j].value.toString()!=='') {
								// Add the entry and set it
								$('#targetResourceId').append($('<option></option>').val($('#targetResourceIdOther').val()).html($('#targetResourceIdOther').val()));
								$('#targetResourceId').val($('#targetResourceIdOther').val());
							}
							
						}
					}
				}
				
				//Adding all the ids for parent policy options
				for(var i=1;i<=$(".formId").length;i++){
					for(k in policy_ids){
						if($("#formId"+i+" #_id").val()!==policy_ids[k].toString()  && $(k+" #recipe").val()!==undefined && $(k+" #recipe").val()!==""){
							$("#formId"+i+" #parentPolicy").append("<option value=\""+policy_ids[k]+"\">" +$(k+" #recipe").val()+"</option>");
						}
					}
				}
				
				for(k in parent_policy){
					$("#formId"+k+" #parentPolicy").val(parent_policy[k]);
					if($("#formId"+k+" #parentPolicy").val() ==""){
						$("#formId" +k+ " #parentPolicyConditions").multiselect("disable");
					} else {
						$("#formId" +k+ " #parentPolicyConditions").multiselect("enable");
					}
					// force the change event
					$("#formId"+k+" #parentPolicy").change();
				}
				
				// Now load all component with the right value defined in policyObj JSON
				for (headInd in policyObj[id]){
					if (!(policyObj[id][headInd].hasOwnProperty("policyConfigurations"))){
						$("#" + policyObj[id][headInd].name).val(policyObj[id][headInd].value);
					}
				}
			}

			setMultiSelect();
			
			if (readMOnly){
				$('select[multiple] option').each(function() {
		          var input = $('input[value="' + $(this).val() + '"]');
		          input.prop('disabled', true);
		          input.parent('li').addClass('disabled');
		        });
				$('input[value="multiselect-all"]').prop('disabled', true).parent('li').addClass('disabled');
			}
			changeGuardPolicyType();
		}

			function addSelectListen(count) {
				var onSelectChange = function() {
					var opselected = this.selectedOptions[0].text;

					if (this.id == "recipe"){
						if(opselected!==""){
							var polCount = $(this).closest("[id^='formId']").attr("id").substring(6);
							$(this).closest(".policyPanel").find("#go_properties_tab"+polCount).text(opselected);
						} else {
							$(this).closest("[id^='go_properties_tab']").text("Policy");
						}
					}

					if (this.id=="parentPolicy"){
						var ppCond = $(this).closest("[id^='formId']").find("#parentPolicyConditions");
						if(opselected==""){
							ppCond.multiselect("clearSelection");
							ppCond.multiselect("disable");
						} else {
							ppCond.multiselect("enable");
						}
					}
				};						 
				$("#formId"+count+" select").each( function () {
					this.change = onSelectChange;
				});
			}

		
		//This is ensure there are no repeated keys in the map
		function noRepeats(form) {
			//triggered per policy.
			var select = {};
			for (var i = 0; i < form.length; i++) {
				if (select[form[i].name] === undefined)
					select[form[i].name] = []
				select[form[i].name].push(form[i].value);
			}
			var arr = []
			for (s in select) {
				var f = {}
				f.name = s
				f.value = select[s]
				arr.push(f)
			}
			return arr
		}
		
		$("#savePropsBtn").click(function(event) {
			if($("#targetResourceIdOther").is(":visible")) {
				$('#targetResourceId').append($('<option></option>').val($("#targetResourceIdOther").val()).html($("#targetResourceIdOther").val()))
				$("#targetResourceId").val($("#targetResourceIdOther").val());
			}
			$(".idError").hide();
			if ($("#policyTable .highlight td").html() !== $("#pname").val()){
				//repeated name
				if ($.inArray($("#pname").val(), Object.keys(allPolicies)) > -1){
					$("#repeatIdError").show();
					return;
				} else { //not repeated
					delete allPolicies[$("#policyTable .highlight td").html()];
				}
			}
			if ($("#pname").val().trim() == "New_Policy"){
				$("#newIdError").show();
				return;
			}
			
			//Saves edits
			/* if ($("#policyTable .highlight").length > 0){
				saveLastPolicyLocally($("#policyTable .highlight").attr("id"));
			} */
			startNextItem();
			
			//Removes outdated (deleted) policies by checking against left menu
			var finalSaveList = {};
			$("#policyTable td").each(function(){
				var tableVal = $(this).text();
				if (tableVal in allPolicies){
					finalSaveList[tableVal] = allPolicies[tableVal];
				}
			});

			saveProperties(finalSaveList);
			$("#close_button").click();
		})		

		function add_one_more() {
			$("#nav_Tabs li").removeClass("active");
			
			//FormSpan contains a block of the form that is not being displayed. We will create clones of that and add them to tabs
			var form = $($("#formSpan").children()[0]).clone()
			var count = 0;
			//Each new tab will have the formId class attached to it. This way we can track how many forms we currently have out there and assign listeners to them
			if ($(".formId").length > 0) {
				var greatest = 0;
				var s = $(".formId");
				for (var i = 0; i < s.length; i++) {
					if (parseInt($(s[i]).attr("id").substring(6)) > greatest) {
						greatest = parseInt($(s[i]).attr("id").substring(6))
					}
				}
				count = greatest + 1;
				$("#properties_tab").append(
						('<span class="formId" id="formId'+count+'"></span>'));
			} else {
				count++;
				$("#properties_tab").append(
						'<span class="formId" id="formId1"></span>');
			}
			
			//$(form).find("#policyName").val("Recipe "+makid(2))
			//TODO change up how we auto assign policyName. There could be the case where we do this and it will have repeats
			//alert($(form).find("#_id").val())
			//policyNameChangeListener(form)
			$("#add_one_more")
					.parent()
					.before(
							' <li class="active"><a id="go_properties_tab'+count+'">Policy</a><button id="tab_close'+count+'" type="button" class="close tab-close-popup" aria-hidden="true" style="margin-top: -30px;margin-right: 5px">&times;</button></li>');
			$("#formId" + count).append(form);
			$(".formId").not($("#formId" + count)).css("display", "none")
			addCustListen(count)

			addSelectListen(count);
			// This is for when the process is not loading from map but being created
			if(!loadingId){
				var l=makeid()
				$(form).find("#_id").val(l)
				policy_ids["#formId" + count]=l
				var answers={}
				
				for(var i=1;i<=greatestIdNum();i++){
					if($("#formId"+i).length>0){
						answers["#formId"+i+" #parentPolicy"]=$("#formId"+i+" #parentPolicy").val();
						$("#formId"+i+" #parentPolicy").empty();
						
						for(k in policy_ids){
							if(($("#formId"+i+" #_id").val()!==policy_ids[k].toString()) && $(k+" #recipe").val()!==undefined && $(k+" #recipe").val()!==""){								
								$("#formId"+i+" #parentPolicy").append("<option value='"+policy_ids[k]+"'>"+$(k+" #recipe").val()+"</option>")
							}
						}
						$("#formId"+i+" #parentPolicy").prepend("<option value=''></option>")
					}
				}
				
				$("#formId"+count+" #parentPolicyConditions").multiselect("disable");
				
				//re-populate parent policy with chosen options
				for(k in answers){
					$(k).val(answers[k])
				}
			}
			
			return count;
		}
		
		function add_new_policy(issueNewNames) {	
			//remove old gui forms
			for (var i=1; i<($(".formId").length + 1); i++){
				$("#go_properties_tab"+i).parent().remove();
			}
			$(".formId").remove();
			
			//Reset headers
			//$("#pname").val("0");
			$("#pname").val("New_Policy");
			$("#timeout").val(defaults_props.policy.timeout);
			
			$("#add_one_more").click();
		}

		function addCustListen(count) {			
			$('#go_properties_tab' + count).click(function(event) {
				$("#nav_Tabs li").removeClass("active");
				$(this).parent().addClass("active");
				$("#formId" + count).css("display", "")
				$(".formId").not($("#formId" + count)).css("display", "none")

			})
			$('#tab_close' + count).click(function(event) {
				if(document.getElementById("timeout").disabled){
					return false;
				}
				$(this).parent().remove();
				for(var i=1;i<=greatestIdNum();i++){
					if(	$("#formId"+i).length>0){
						if(i!==count ){
							if(	$("#formId"+i+" #parentPolicy").val()===$("#formId"+count+" #_id").val().toString())
								$("#formId"+i+" #parentPolicy").val("")
							$("#formId"+i+" #parentPolicy option[value='"+$("#formId"+count+" #_id").val().toString()+"']").remove();
						}
					}
				}
				delete policy_ids["#formId" + count + " #_id"]
				$("#formId" + count).remove();
			})
		}
		
		
		function greatestIdNum() {
			var greatest = 0;
			var s = $(".formId");
			for (var i = 0; i < s.length; i++) {
				if (parseInt($(s[i]).attr("id").substring(6)) > greatest) {
					greatest = parseInt($(s[i]).attr("id").substring(6))
				}
			}
			return greatest;
		}

		//Generate random id for each policy
		//Also made sure ids couldnt be repeated
		function makeid(num) {

			var text = "";
			var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
			if (num == null)
				num = 7;
			for (var i = 0; i < 7; i++)
				text += possible.charAt(Math.floor(Math.random()
						* possible.length));
			var hasValue = false;
			for (k in policy_ids) {
				if (text === policy_ids[k])
					hasValue = true
			}
			if (hasValue)
				return makeid(num);
			else
				return text
		}

		var ParentPolicy = function(id, name) {
			this.id = id
			this.name = name
		}

		//Policy table search filter
		function searchPolicyList() {
			var search = document.getElementById("policySearch");
			var row = document.getElementsByTagName("td");
			for (var i = 0; i < row.length; i++) {
				if (row[i].innerHTML.toUpperCase().indexOf(
						search.value.toUpperCase()) > -1) {
					row[i].style.display = "";
				} else {
					row[i].style.display = "none";
				}
			}
		}

		function saveLastPolicyLocally(lastPolicyId) {
			var polForm = []

			var properties = $(".saveProps").not("#formSpan .saveProps");
			var timeoutForm = $("#Timeoutform").serializeArray();

			for (var i = 0; i < timeoutForm.length; i++) {
				polForm.push(timeoutForm[i]);
			}

			var d = {}
			d["policyConfigurations"] = [];
			for (var i = 0; i < properties.length; i++) {
				var ser = $(properties[i]).serializeArray();
				var s = noRepeats(ser)
				d["policyConfigurations"].push(s);
			}
			polForm.push(d);
			allPolicies[lastPolicyId] = polForm;
		}
		
		function getNextId(){
			var newPolId;
			allPolIds.sort();
			if ((Math.min.apply(Math, allPolIds) == 0)
					&& (allPolIds.length > 0)) {
				loop1: 
					for (var i = 1; i < allPolIds.length; i++) {
						if ((allPolIds[i] - allPolIds[i - 1]) != 1) {
							newPolId = (allPolIds[i - 1] + 1);
							break loop1;
						};
					};
				if (!newPolId) {
					newPolId = (Math.max.apply(Math, allPolIds)) + 1;
				}
			} else {
				newPolId = 0;
			}
			allPolIds.push(newPolId);
			$("#pid").val(newPolId);
		}

		$("#deletePolicy").on('click', function() {
			$(".idError").hide();
			//delete policy id
			allPolIds.splice((allPolIds.indexOf(parseInt($("#pid").val()))),1);
			
			//delete policy name
			var deleteId = $("#policyTable .highlight td").html();
			delete allPolicies[deleteId];
			$("#policyTable .highlight").remove();
			$("#pname").val('');
			expandTable();
		});

		$('#policyTable').on('click', 'tr', function(event) {
			$(".idError").hide();
			//edited name
			if ($("#policyTable .highlight td").html() !== $("#pname").val()){
				//repeated name
				if ($.inArray($("#pname").val(), Object.keys(allPolicies)) > -1){
					$("#repeatIdError").show();
					return;
				} else { //not repeated
					$("#repeatIdError").hide();
					delete allPolicies[$("#policyTable .highlight td").html()];
				}
			}
			//if (parseInt($("#pname").val()) == 0){
			if ($("#pname").val().trim() == "New_Policy"){
				$("#newIdError").show();
				return;
			}
			if (!(readMOnly)){
				startNextItem();
			} else {
				if ($("#policyTable .highlight").length == 0){
					collapseTable();		
				}
			}
			$(this).addClass('highlight').siblings().removeClass('highlight');
			disperseConfig(allPolicies, $(this).find("td").html());
		});

		$('#createNewPolicy').on('click', function(){
			$(".idError").hide();
			//edited name
			if ($("#policyTable .highlight td").html() !== $("#pname").val()){
				//repeated name
				if ($.inArray($("#pname").val(), Object.keys(allPolicies)) > -1){
					$("#repeatIdError").show();
					return;
				} else { //not repeated
					$("#repeatIdError").hide();
					delete allPolicies[$("#policyTable .highlight td").html()];
				}
			}
			//if (parseInt($("#pname").val()) == 0){
			if ($("#pname").val().trim() == "New_Policy"){
				$("#newIdError").show();
				return;
			}
			startNextItem();
			add_new_policy();
			if (("#policyTable .highlight").length > 0){
				$('#policyTable tr.highlight').removeClass('highlight');
			}
            $("#policyTable").prepend("<tr class='highlight'><td>New_Policy</td></tr>");
            
            getNextId();
		});

		$('#pname').on('keypress', function(e){
			/* var newVal = $(this).val() + String.fromCharCode(e.which);
			if ((newVal>99) || (($(this).val().length>2) && e.keyCode != 46 && e.keyCode !=8)){
				e.preventDefault();
			} */
			if (e.keyCode == 32){
				$("#spaceError").show();
				e.preventDefault();
			}
		});
		
		function isNumberKey(event){
			var charCode = (event.which) ? event.which : event.keyCode
			if (charCode > 31 && (charCode < 48 || charCode > 57)){
				return false;
			}
			return true;
		}

		function startNextItem() {
			//save last item before transitioning
			var lastItem = $("#policyTable .highlight");
			if (lastItem.length > 0) {
				saveLastPolicyLocally($("#pname").val());
				//lastItem.attr("id", $("#pname").val()); 
				lastItem.find("td").html($("#pname").val());
			} else {
				collapseTable();
			}

			//allow deleting
			if ($("#deletePolicy").prop("disabled")) {
				$("#deletePolicy").prop("disabled", false);
			}
		}
		
		setASDCFields();
		initTargetResourceId();
		
		//load metrics dropdown
		if (elementMap["global"]){
			for (var i = 0; i < (elementMap["global"].length); i++){
				if ((elementMap["global"][i]["name"]) == "actionSet"){
					var asSel = elementMap["global"][i]["value"];
					if (asSel == "vnfRecipe"){
						if (vf_Services["policy"][asSel]){
							$.each((vf_Services["policy"][asSel]), function(val, text) {
				                $('#recipe').append(
				                    $('<option></option>').val(val).html(text)
				                );
				            });
						}
						break;
					}
				};
			};
		};
		//Show table panel only
		function expandTable() {
			$(".policyPanel").css("display", "none");
			$(".leftPolicyPanel").removeClass("col-sm-3");
			$(".modelSearchBox").css("padding", "25px 12px");
			if (!($("#deletePolicy").prop("disabled"))) {
				$("#deletePolicy").prop("disabled", true);
			}
		}

		//Show both menus
		function collapseTable() {
			$(".leftPolicyPanel").addClass("col-sm-3");
			$(".modelSearchBox").css("padding", "10px 12px");
			$(".policyPanel").css("display", "unset");
		}
	</script>
</div>