2 ============LICENSE_START=======================================================
4 ================================================================================
5 Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
7 ================================================================================
8 Licensed under the Apache License, Version 2.0 (the "License");
9 you may not use this file except in compliance with the License.
10 You may obtain a copy of the License at
12 http://www.apache.org/licenses/LICENSE-2.0
14 Unless required by applicable law or agreed to in writing, software
15 distributed under the License is distributed on an "AS IS" BASIS,
16 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 See the License for the specific language governing permissions and
18 limitations under the License.
19 ============LICENSE_END============================================
20 ===================================================================
28 background-color: #dddd;
32 background-color: #dddd;
42 vertical-align: middle;
52 background-color: #f2bfab;
63 background-color: #f5f5f5;
64 padding: 15px 5px 0 5px;
67 .form-group.clearfix {
68 display: -webkit-flex;
80 padding: 2px 2px 2px 30px;
91 border-bottom: 1px solid #ddd;
92 border-collapse: collapse;
102 #policyTable tr.highlight {
103 background-color: #f5f5f5;
116 <div attribute-test="policywindowproperties" id="configure-widgets"
117 class="disabled-block-container">
118 <div attribute-test="policywindowpropertiesh" class="modal-header">
119 <button type="button" class="close" ng-click="close(false)"
120 aria-hidden="true" style="margin-top: -3px">×</button>
121 <h4>Operational Policy</h4>
125 <div class="modal-body">
126 <div attribute-test="policywindowpropertiesb" class="modal-body row">
128 <div class="leftPolicyPanel">
129 <div class="panel panel-default">
130 <i class="glyphicon glyphicon-search modelSearchBox"></i> <input
131 type="text" id="policySearch" onkeyup="searchPolicyList()"
132 placeholder="Search ...">
133 <div id="policyTableHolder">
134 <table id="policyTable"></table>
137 <div style="float: left">
138 <button type="button" id="createNewPolicy" class="btn btn-sm">New
142 <div style="float: right">
143 <button type="button" id="deletePolicy"
144 class="btn btn-sm glyphicon glyphicon-trash" disabled></button>
147 <div id="repeatIdError" class="idError">Error: This Policy
148 name is already taken.</div>
149 <div id="newIdError" class="idError">Error: Please rename your
151 <div id="spaceError" class="idError">Error: Spaces are not
152 allowed in the ID.</div>
155 <div class="panel panel-default col-sm-9 policyPanel"
156 style="display: none;">
157 <form id="Timeoutform" class="form-horizontal">
159 <div class="form-group clearfix row">
160 <label class="col-sm-2">Name</label>
161 <div class="col-sm-3" style="padding: 0px;">
162 <input type="text" id="pname" name="pname" maxlength="48"
163 placeholder="Enter Unique Name" class="form-control">
166 <label class="col-sm-1">ID</label>
167 <div class="col-sm-1" style="padding: 0px;">
168 <input onkeydown="return false;" type="text" id="pid" name="pid"
169 class="form-control" readonly>
172 <label for="userID" class="col-sm-3"
173 style="padding-left: 5px; padding-right: 10px;">Overall
175 <div class="col-sm-2" style="padding-left: 0px;">
176 <input type="text" maxlength="10"
177 onkeypress="return isNumberKey(event)" class="form-control"
178 id="timeout" name="timeout">
183 <div class="panel-heading" style="background-color: white;">
184 <ul id="nav_Tabs" class="nav nav-tabs">
185 <li class><a id="add_one_more" href="#desc_tab"><span
186 class="glyphicon glyphicon-plus" aria-hidden="true"></span></a></li>
189 <div class="panel-body">
190 <div class="tab-content">
191 <div id="properties_tab" class="tab-pane fade in active"></div>
196 <span id="formSpan" style="display: none">
197 <form class="saveProps" class="form-horizontal">
199 <div class="form-group clearfix">
200 <label class="col-sm-4 control-label" for="recipe">Recipe</label>
201 <div class="col-sm-8">
202 <select class="form-control" name="recipe" id="recipe"
203 enableFilter="true"></select>
206 <div class="form-group clearfix">
207 <label for="maxRetries" class="col-sm-4 control-label">
209 <div class="col-sm-8">
210 <input type="text" maxlength="5" class="form-control"
211 id="maxRetries" onkeypress="return isNumberKey(event)"
212 name="maxRetries"> </input>
215 <div class="form-group clearfix">
216 <label for="retryTimeLimit" class="col-sm-4 control-label">
217 Retry Time Limit</label>
218 <div class="col-sm-8">
219 <input type="text" maxlength="5" class="form-control"
220 id="retryTimeLimit" onkeypress="return isNumberKey(event)"
221 name="retryTimeLimit"></input>
224 <div style="display: none;" class="form-group clearfix">
225 <label for="_id" class="col-sm-4 control-label"> PolicyID</label>
226 <div class="col-sm-8">
227 <input type="text" onkeydown="return false;"
228 class="form-control" id="_id" name="_id" value=""></input>
231 <div class="form-group clearfix">
232 <label for="parentPolicy" class="col-sm-4 control-label">
233 Parent Policy</label>
234 <div class="col-sm-8">
235 <select class="form-control" id="parentPolicy"
236 name="parentPolicy" enableFilter="true"><option
237 value=""></option></select>
240 <div class="form-group clearfix">
241 <label for="parentPolicyConditions"
242 class="col-sm-4 control-label"> Parent Policy Conditions</label>
243 <div class="col-sm-8">
244 <select class="form-control" id="parentPolicyConditions"
245 name="parentPolicyConditions" multiple></select>
248 <div class="form-group clearfix">
250 <label for="actor" class="col-sm-4 control-label"> Actor</label>
251 <div class="col-sm-8">
252 <select class="form-control" id="actor" name="actor"></select>
255 <label for="payload" class="col-sm-4 control-label">
257 <div class="col-sm-8">
258 <textarea class="form-control" id="recipeInput" name=recipeInput></textarea>
261 <div class="form-group clearfix">
262 <label for="targetType" class="col-sm-4 control-label">
264 <div class="col-sm-8">
265 <select class="form-control" name="recipeLevel" id="recipeLevel">
269 <label for="targetResourceId" class="col-sm-4 control-label">
270 Target ResourceId</label>
271 <div class="col-sm-8">
272 <select class="form-control" name="targetResourceId"
273 id="targetResourceId" enableFilter="true"
274 onchange="changeTargetResourceIdOther();">
275 <option value=""></option>
276 <option value="Other:">Other:</option>
279 <input type="text" style="display: none" class="form-control"
280 id="targetResourceIdOther" name="targetResourceIdOther" value=""></input>
282 <div style="border: 2px dotted gray;">
283 <div class="form-group clearfix">
284 <label for="enableGuardPolicy" class="col-sm-4 control-label">
285 Enable Guard Policy</label>
286 <div class="col-sm-8">
287 <input type="checkbox" class="form-control"
288 name="enableGuardPolicy" id="enableGuardPolicy">
290 <div class="col-sm-8">
291 <label for="guardPolicyType" class="col-sm-4 control-label">
292 Guard Policy Type</label> <select class="form-control"
293 name="guardPolicyType" id="guardPolicyType"
294 onchange="changeGuardPolicyType();">
295 <option value="GUARD_MIN_MAX">MinMax</option>
296 <option value="GUARD_YAML">FrequencyLimiter</option>
299 <label for="guardTargets" class="col-sm-4 control-label">Guard
301 <div class="col-sm-8">
302 <input class="form-control" name="guardTargets"
307 <div class="form-group clearfix" id="minMaxGuardPolicyDiv">
308 <label for="minGuard" class="col-sm-4 control-label">
310 <div class="col-sm-8">
311 <input class="form-control" name="minGuard" id="minGuard" />
313 <label for="maxGuard" class="col-sm-4 control-label">
315 <div class="col-sm-8">
316 <input class="form-control" name="maxGuard" id="maxGuard" />
319 <div class="form-group clearfix"
320 id="frequencyLimiterGuardPolicyDiv" style="display: none">
321 <label for="limitGuard" class="col-sm-4 control-label">Limit</label>
322 <div class="col-sm-8">
323 <input class="form-control" name="limitGuard" id="limitGuard" />
325 <div class="col-sm-8">
326 <select class="form-control" name="timeUnitsGuard"
327 id="timeUnitsGuard" /> <label for="timeWindowGuard"
328 class="col-sm-4 control-label">Time Window</label>
330 <div class="col-sm-8">
331 <input class="form-control" name="timeWindowGuard"
332 id="timeWindowGuard" />
335 <div class="form-group clearfix">
336 <label for="guardActiveStart" class="col-sm-4 control-label">
337 Guard Active Start</label>
338 <div class="col-sm-8">
339 <input class="form-control" name="guardActiveStart"
340 id="guardActiveStart" />
342 <label for="guardActiveEnd" class="col-sm-4 control-label">
343 Guard Active End</label>
344 <div class="col-sm-8">
345 <input class="form-control" name="guardActiveEnd"
346 id="guardActiveEnd" />
356 <div attribute-test="policywindowpropertiesf" class="modal-footer">
357 <!--<button ng-click="reset()" class="btn btn-primary" style="float:left">Reset</button>-->
358 <button id="savePropsBtn" class="btn btn-primary">Close</button>
359 <button ng-click="close(true)" id="close_button"
360 class="btn btn-primary">Cancel</button>
364 function searchActiveFormId() {
365 var formArray = Array.from(document.getElementsByClassName("formId"));
366 for (var i=0, max=formArray.length; i < max; i++) {
368 console.log("Search active FormId, current element "+formArray[i].id);
369 if (formArray[i].style.display !== "none") {
370 console.log("Active form is:"+formArray[i].id);
374 console.log("No active formId found !");
377 function initTargetResourceId() {
378 var formItemActive = searchActiveFormId();
379 // Set all the Resource Invariant UUID in the target resource ID list (+Empty and other)
380 Object.keys(vf_Services["shared"]["byVf"]).forEach(function(key){
381 $("#"+formItemActive.id+" #targetResourceId").append($('<option></option>').val(key).html(key));
385 function changeTargetResourceIdOther() {
386 var formItemActive = searchActiveFormId();
387 if ($("#"+formItemActive.id+" #targetResourceId").val()==="Other:") {
388 $("#"+formItemActive.id+" #targetResourceIdOther").show();
390 $("#"+formItemActive.id+" #targetResourceIdOther").hide();
391 $("#"+formItemActive.id+" #targetResourceIdOther").val("");
395 function changeGuardPolicyType() {
396 var formItemActive = searchActiveFormId();
397 if ($("#"+formItemActive.id+" #guardPolicyType").val()==="GUARD_MIN_MAX") {
398 $("#"+formItemActive.id+" #minMaxGuardPolicyDiv").show();
399 $("#"+formItemActive.id+" #frequencyLimiterGuardPolicyDiv").hide();
400 } else if ($("#"+formItemActive.id+" #guardPolicyType").val()==="GUARD_YAML") {
401 $("#"+formItemActive.id+" #minMaxGuardPolicyDiv").hide();
402 $("#"+formItemActive.id+" #frequencyLimiterGuardPolicyDiv").show();
405 //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
406 // css attribute display:none
407 $("#add_one_more").click(function(event) {
408 event.preventDefault();
409 var num = add_one_more();
412 loadPropertyWindow("policy")
414 // by default, parentPolicyConditions is disabled
415 //$("#parentPolicyConditions").prop('disabled', 'disabled');
422 //Grab saved values for dropdowns
423 var obj = elementMap[lastElementSelected];
425 if (!($.isEmptyObject(obj))){
426 allPolicies = jQuery.extend({}, obj);
427 for (var x in allPolicies){
428 $("#policyTable").prepend("<tr><td>"+x+"</td></tr>");
429 if (allPolicies[x][1]['value']){
430 allPolIds.push(parseInt(allPolicies[x][1]['value']));
436 //load recipes for a chosen policy
437 function disperseConfig(policyObj, id){
439 //remove old gui forms
440 for (var i=1; i<($(".formId").length + 1); i++){
441 $("#go_properties_tab"+i).parent().remove();
443 $(".formId").remove();
445 if (policyObj !== undefined) {
446 var el = policyObj[id][3]['policyConfigurations']
447 for (var i = 0; i < el.length; i++) {
449 var num = add_one_more();
451 for (var j = 0; j < el[i].length; j++) {
452 if(el[i][j].hasOwnProperty("name")){
453 $("#formId" + num + " #" + el[i][j].name).val(
455 if(el[i][j].name==="_id")
456 policy_ids["#formId" + num]=el[i][j].value
457 if(el[i][j].name==='parentPolicy')
458 parent_policy[num]=el[i][j].value
459 if(el[i][j].name==='recipe' && el[i][j].value.toString()!==''){
460 $("#go_properties_tab"+num).text(el[i][j].value)
462 if(el[i][j].name==="targetResourceIdOther" && el[i][j].value.toString()!=='') {
463 // Add the entry and set it
464 $("#formId" + num + " #targetResourceId").append($('<option></option>').val($("#formId" + num + " #targetResourceIdOther").val()).html($("#formId" + num + " #targetResourceIdOther").val()));
465 $("#formId" + num + " #targetResourceId").val($("#formId" + num + " #targetResourceIdOther").val());
467 changeGuardPolicyType();
472 //Adding all the ids for parent policy options
473 for(var i=1;i<=$(".formId").length;i++){
474 for(k in policy_ids){
475 if($("#formId"+i+" #_id").val()!==policy_ids[k].toString() && $(k+" #recipe").val()!==undefined && $(k+" #recipe").val()!==""){
476 $("#formId"+i+" #parentPolicy").append("<option value=\""+policy_ids[k]+"\">" +$(k+" #recipe").val()+"</option>");
481 for(k in parent_policy){
482 $("#formId"+k+" #parentPolicy").val(parent_policy[k]);
483 if($("#formId"+k+" #parentPolicy").val() ==""){
484 $("#formId" +k+ " #parentPolicyConditions").multiselect("disable");
486 $("#formId" +k+ " #parentPolicyConditions").multiselect("enable");
488 // force the change event
489 $("#formId"+k+" #parentPolicy").change();
492 // Now load all component with the right value defined in policyObj JSON
493 for (headInd in policyObj[id]){
494 if (!(policyObj[id][headInd].hasOwnProperty("policyConfigurations"))){
495 $("#" + policyObj[id][headInd].name).val(policyObj[id][headInd].value);
503 $('select[multiple] option').each(function() {
504 var input = $('input[value="' + $(this).val() + '"]');
505 input.prop('disabled', true);
506 input.parent('li').addClass('disabled');
508 $('input[value="multiselect-all"]').prop('disabled', true).parent('li').addClass('disabled');
513 function addSelectListen(count) {
514 var onSelectChange = function() {
515 var opselected = this.selectedOptions[0].text;
517 if (this.id == "recipe"){
519 var polCount = $(this).closest("[id^='formId']").attr("id").substring(6);
520 $(this).closest(".policyPanel").find("#go_properties_tab"+polCount).text(opselected);
522 $(this).closest("[id^='go_properties_tab']").text("Policy");
526 if (this.id=="parentPolicy"){
527 var ppCond = $(this).closest("[id^='formId']").find("#parentPolicyConditions");
529 ppCond.multiselect("clearSelection");
530 ppCond.multiselect("disable");
532 ppCond.multiselect("enable");
536 $("#formId"+count+" select").each( function () {
537 this.change = onSelectChange;
542 //This is ensure there are no repeated keys in the map
543 function noRepeats(form) {
544 //triggered per policy.
546 for (var i = 0; i < form.length; i++) {
547 if (select[form[i].name] === undefined)
548 select[form[i].name] = []
549 select[form[i].name].push(form[i].value);
561 $("#savePropsBtn").click(function(event) {
562 if($("#targetResourceIdOther").is(":visible")) {
563 $('#targetResourceId').append($('<option></option>').val($("#targetResourceIdOther").val()).html($("#targetResourceIdOther").val()))
564 $("#targetResourceId").val($("#targetResourceIdOther").val());
566 $(".idError").hide();
567 if ($("#policyTable .highlight td").html() !== $("#pname").val()){
569 if ($.inArray($("#pname").val(), Object.keys(allPolicies)) > -1){
570 $("#repeatIdError").show();
572 } else { //not repeated
573 delete allPolicies[$("#policyTable .highlight td").html()];
576 if ($("#pname").val().trim() == "New_Policy"){
577 $("#newIdError").show();
582 /* if ($("#policyTable .highlight").length > 0){
583 saveLastPolicyLocally($("#policyTable .highlight").attr("id"));
587 //Removes outdated (deleted) policies by checking against left menu
588 var finalSaveList = {};
589 $("#policyTable td").each(function(){
590 var tableVal = $(this).text();
591 if (tableVal in allPolicies){
592 finalSaveList[tableVal] = allPolicies[tableVal];
596 saveProperties(finalSaveList);
597 $("#close_button").click();
600 function add_one_more() {
601 $("#nav_Tabs li").removeClass("active");
603 //FormSpan contains a block of the form that is not being displayed. We will create clones of that and add them to tabs
604 var form = $($("#formSpan").children()[0]).clone()
606 //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
607 if ($(".formId").length > 0) {
609 var s = $(".formId");
610 for (var i = 0; i < s.length; i++) {
611 if (parseInt($(s[i]).attr("id").substring(6)) > greatest) {
612 greatest = parseInt($(s[i]).attr("id").substring(6))
615 count = greatest + 1;
616 $("#properties_tab").append(
617 ('<span class="formId" id="formId'+count+'"></span>'));
620 $("#properties_tab").append(
621 '<span class="formId" id="formId1"></span>');
624 //$(form).find("#policyName").val("Recipe "+makid(2))
625 //TODO change up how we auto assign policyName. There could be the case where we do this and it will have repeats
626 //alert($(form).find("#_id").val())
627 //policyNameChangeListener(form)
631 ' <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">×</button></li>');
632 $("#formId" + count).append(form);
633 $(".formId").not($("#formId" + count)).css("display", "none")
636 addSelectListen(count);
637 // This is for when the process is not loading from map but being created
640 $(form).find("#_id").val(l)
641 policy_ids["#formId" + count]=l
644 for(var i=1;i<=greatestIdNum();i++){
645 if($("#formId"+i).length>0){
646 answers["#formId"+i+" #parentPolicy"]=$("#formId"+i+" #parentPolicy").val();
647 $("#formId"+i+" #parentPolicy").empty();
649 for(k in policy_ids){
650 if(($("#formId"+i+" #_id").val()!==policy_ids[k].toString()) && $(k+" #recipe").val()!==undefined && $(k+" #recipe").val()!==""){
651 $("#formId"+i+" #parentPolicy").append("<option value='"+policy_ids[k]+"'>"+$(k+" #recipe").val()+"</option>")
654 $("#formId"+i+" #parentPolicy").prepend("<option value=''></option>")
658 $("#formId"+count+" #parentPolicyConditions").multiselect("disable");
660 //re-populate parent policy with chosen options
669 function add_new_policy(issueNewNames) {
670 //remove old gui forms
671 for (var i=1; i<($(".formId").length + 1); i++){
672 $("#go_properties_tab"+i).parent().remove();
674 $(".formId").remove();
677 //$("#pname").val("0");
678 $("#pname").val("New_Policy");
679 $("#timeout").val(defaults_props.policy.timeout);
681 $("#add_one_more").click();
684 function addCustListen(count) {
685 $('#go_properties_tab' + count).click(function(event) {
686 $("#nav_Tabs li").removeClass("active");
687 $(this).parent().addClass("active");
688 $("#formId" + count).css("display", "")
689 $(".formId").not($("#formId" + count)).css("display", "none")
692 $('#tab_close' + count).click(function(event) {
693 if(document.getElementById("timeout").disabled){
696 $(this).parent().remove();
697 for(var i=1;i<=greatestIdNum();i++){
698 if( $("#formId"+i).length>0){
700 if( $("#formId"+i+" #parentPolicy").val()===$("#formId"+count+" #_id").val().toString())
701 $("#formId"+i+" #parentPolicy").val("")
702 $("#formId"+i+" #parentPolicy option[value='"+$("#formId"+count+" #_id").val().toString()+"']").remove();
706 delete policy_ids["#formId" + count + " #_id"]
707 $("#formId" + count).remove();
712 function greatestIdNum() {
714 var s = $(".formId");
715 for (var i = 0; i < s.length; i++) {
716 if (parseInt($(s[i]).attr("id").substring(6)) > greatest) {
717 greatest = parseInt($(s[i]).attr("id").substring(6))
723 //Generate random id for each policy
724 //Also made sure ids couldnt be repeated
725 function makeid(num) {
728 var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
731 for (var i = 0; i < 7; i++)
732 text += possible.charAt(Math.floor(Math.random()
734 var hasValue = false;
735 for (k in policy_ids) {
736 if (text === policy_ids[k])
745 var ParentPolicy = function(id, name) {
750 //Policy table search filter
751 function searchPolicyList() {
752 var search = document.getElementById("policySearch");
753 var row = document.getElementsByTagName("td");
754 for (var i = 0; i < row.length; i++) {
755 if (row[i].innerHTML.toUpperCase().indexOf(
756 search.value.toUpperCase()) > -1) {
757 row[i].style.display = "";
759 row[i].style.display = "none";
764 function saveLastPolicyLocally(lastPolicyId) {
767 var properties = $(".saveProps").not("#formSpan .saveProps");
768 var timeoutForm = $("#Timeoutform").serializeArray();
770 for (var i = 0; i < timeoutForm.length; i++) {
771 polForm.push(timeoutForm[i]);
775 d["policyConfigurations"] = [];
776 for (var i = 0; i < properties.length; i++) {
777 var ser = $(properties[i]).serializeArray();
778 var s = noRepeats(ser)
779 d["policyConfigurations"].push(s);
782 allPolicies[lastPolicyId] = polForm;
785 function getNextId(){
788 if ((Math.min.apply(Math, allPolIds) == 0)
789 && (allPolIds.length > 0)) {
791 for (var i = 1; i < allPolIds.length; i++) {
792 if ((allPolIds[i] - allPolIds[i - 1]) != 1) {
793 newPolId = (allPolIds[i - 1] + 1);
798 newPolId = (Math.max.apply(Math, allPolIds)) + 1;
803 allPolIds.push(newPolId);
804 $("#pid").val(newPolId);
807 $("#deletePolicy").on('click', function() {
808 $(".idError").hide();
810 allPolIds.splice((allPolIds.indexOf(parseInt($("#pid").val()))),1);
813 var deleteId = $("#policyTable .highlight td").html();
814 delete allPolicies[deleteId];
815 $("#policyTable .highlight").remove();
820 $('#policyTable').on('click', 'tr', function(event) {
821 $(".idError").hide();
823 if ($("#policyTable .highlight td").html() !== $("#pname").val()){
825 if ($.inArray($("#pname").val(), Object.keys(allPolicies)) > -1){
826 $("#repeatIdError").show();
828 } else { //not repeated
829 $("#repeatIdError").hide();
830 delete allPolicies[$("#policyTable .highlight td").html()];
833 //if (parseInt($("#pname").val()) == 0){
834 if ($("#pname").val().trim() == "New_Policy"){
835 $("#newIdError").show();
841 if ($("#policyTable .highlight").length == 0){
845 $(this).addClass('highlight').siblings().removeClass('highlight');
846 disperseConfig(allPolicies, $(this).find("td").html());
849 $('#createNewPolicy').on('click', function(){
850 $(".idError").hide();
852 if ($("#policyTable .highlight td").html() !== $("#pname").val()){
854 if ($.inArray($("#pname").val(), Object.keys(allPolicies)) > -1){
855 $("#repeatIdError").show();
857 } else { //not repeated
858 $("#repeatIdError").hide();
859 delete allPolicies[$("#policyTable .highlight td").html()];
862 //if (parseInt($("#pname").val()) == 0){
863 if ($("#pname").val().trim() == "New_Policy"){
864 $("#newIdError").show();
869 if (("#policyTable .highlight").length > 0){
870 $('#policyTable tr.highlight').removeClass('highlight');
872 $("#policyTable").prepend("<tr class='highlight'><td>New_Policy</td></tr>");
877 $('#pname').on('keypress', function(e){
878 /* var newVal = $(this).val() + String.fromCharCode(e.which);
879 if ((newVal>99) || (($(this).val().length>2) && e.keyCode != 46 && e.keyCode !=8)){
882 if (e.keyCode == 32){
883 $("#spaceError").show();
888 function isNumberKey(event){
889 var charCode = (event.which) ? event.which : event.keyCode
890 if (charCode > 31 && (charCode < 48 || charCode > 57)){
896 function startNextItem() {
897 //save last item before transitioning
898 var lastItem = $("#policyTable .highlight");
899 if (lastItem.length > 0) {
900 saveLastPolicyLocally($("#pname").val());
901 //lastItem.attr("id", $("#pname").val());
902 lastItem.find("td").html($("#pname").val());
908 if ($("#deletePolicy").prop("disabled")) {
909 $("#deletePolicy").prop("disabled", false);
914 initTargetResourceId();
916 //load metrics dropdown
917 if (elementMap["global"]){
918 for (var i = 0; i < (elementMap["global"].length); i++){
919 if ((elementMap["global"][i]["name"]) == "actionSet"){
920 var asSel = elementMap["global"][i]["value"];
921 if (asSel == "vnfRecipe"){
922 if (vf_Services["policy"][asSel]){
923 $.each((vf_Services["policy"][asSel]), function(val, text) {
925 $('<option></option>').val(val).html(text)
934 //Show table panel only
935 function expandTable() {
936 $(".policyPanel").css("display", "none");
937 $(".leftPolicyPanel").removeClass("col-sm-3");
938 $(".modelSearchBox").css("padding", "25px 12px");
939 if (!($("#deletePolicy").prop("disabled"))) {
940 $("#deletePolicy").prop("disabled", true);
945 function collapseTable() {
946 $(".leftPolicyPanel").addClass("col-sm-3");
947 $(".modelSearchBox").css("padding", "10px 12px");
948 $(".policyPanel").css("display", "unset");