2 ============LICENSE_START=======================================================
4 ================================================================================
5 Copyright (C) 2017 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 ===================================================================
21 ECOMP is a trademark and service mark of AT&T Intellectual Property.
28 background-color:#f2bfab;
33 background-color:#dddd;
42 .fileUpload input.upload {
51 filter: alpha(opacity = 0);
56 display: inline-block;
73 background-color: #f5f5f5;
75 margin: 15px 15px 0 0;
80 #tcaEditHolder #properties_tab>div+div {
95 .tcaParentItems label{
105 border-bottom: 1px solid #ddd;
106 border-collapse: collapse;
116 #tcaTable tr.highlight{
117 background-color: #f5f5f5;
130 <script type="text/javascript">
131 function disablefile() {
133 document.getElementById("fileUpload").disabled = true;
137 function disableSVN() {
138 var selectLength = document.querySelectorAll(".disabled-block-container .tab-close-popup");
139 if(selectLength && selectLength.length>0){
140 for(var i = 0; i< selectLength.length ; i++){
141 selectLength[i].disabled = true;
145 document.getElementById("schemaLocation").disabled = true;
146 document.getElementById("userID").disabled = true;
147 document.getElementById("password").disabled = true;
153 <div id="configure-widgets" class="disabled-block-container">
154 <div class="modal-header">
155 <button type="button" class="close" ng-click="close(false)"
156 aria-hidden="true" style="margin-top: -3px">×</button>
157 <h4>TCA Micro Services</h4>
159 <div class="modal-body">
160 <div style="height: 10px"></div>
161 <div class="panel panel-default" id="panelHolder">
163 <span id="formSpan" style="display:none;">
164 <div class="panel-body">
166 <form class="tcaParentItems">
168 <div class="col-sm-8 form-group">
169 <label class="col-sm-3"> Name </label>
170 <div class="col-sm-9" style="padding:0px;">
171 <input class="form-control" type="text" maxlength="48" id="tname" name="tname"></input>
175 <div class="col-sm-8 form-group" style="display:none;">
176 <label class="col-sm-3"> UUID </label>
177 <div class="col-sm-9" style="padding:0px;">
178 <input class="form-control" onkeydown="return false;" type="text" id="tuuid" name="tuuid"></input>
182 <div class="col-sm-8 form-group" style="display:none;">
183 <label class="col-sm-3"> NF Code </label>
184 <div class="col-sm-9" style="padding:0px;">
185 <input class="form-control" onkeydown="return false;" type="text" id="tnfc" name="tnfc"></input>
191 <div class="col-sm-8 form-group">
192 <label class="col-sm-3"> Policy </label>
193 <div class="col-sm-9" style="padding:0px;">
194 <select name="tcaPol" id="tcaPol" enableFilter="true"></select>
197 <div class="col-sm-8 form-group">
198 <label class="col-sm-3">EventName</label>
199 <div class="col-sm-9" style="padding:0px;">
200 <select name="eventName" id="eventName" enableFilter="true"></select>
204 <div class="col-sm-8 form-group" style="display:none;">
205 <label class="col-sm-3"> Policy ID </label>
206 <div class="col-sm-9" style="padding:0px;">
207 <input class="form-control" onkeydown="return false;" type="text" id="tcaPolId" name="tcaPolId"></input>
214 <div class="tcaBody row">
215 <div class="col-sm-5" style="padding:0px 5px; margin: 15px;">
216 <div class="panel panel-default" id="tcaTableHolder">
217 <table id="tcaTable">
220 <div id="tcaError" class="tcaErr">Error: Please define/delete this new threshold</div>
221 <div id="tcaUnique" class="tcaErr">Error: Duplicate Set Name Found</div>
222 <div style="float:left">
223 <button type="button" id="createNewThresh" class="btn btn-sm">New Threshold</button>
225 <div style="float:right">
226 <button type="button" id="deleteThresh" class="btn btn-sm glyphicon glyphicon-trash" disabled></button>
231 <div id="tcaEditHolder" class="panel panel-default col-sm-6">
232 <div class="tab-content">
233 <div id="properties_tab" class="form-vertical">
235 <label class="control-label">Metric</label>
237 <select id="fieldPathM" name="fieldPathM"></select>
241 <label class="control-label">Operator</label>
243 <select id="operator" name="operator"></select>
247 <label class="control-label">Threshold</label>
249 <input type="text" maxlength="10" class="form-control" name="threshold"
250 onkeypress="return isNumberKey(event)" id="threshold"></input>
254 <label class="control-label">Control Loop Schema</label>
256 <select id="controlLoopSchema" name="controlLoopSchema"></select>
260 <label class="control-label">Closed Loop Event Status</label>
262 <select id="closedLoopEventStatus" name="closedLoopEventStatus"></select>
277 <div class="modal-footer">
278 <!--<button ng-click="reset()" class="btn btn-primary" style="float:left">Reset</button>-->
279 <button id="savePropsBtn" class="btn btn-primary">Close</button>
280 <button ng-click="close(true)" id="close_button"
281 class="btn btn-primary">Cancel</button>
284 <script language="javascript">
285 // helper that make jquery objects visibles or invisible
286 // to use instead of show to keep placeholder size correct
287 jQuery.fn.visible = function() {
288 return this.css('visibility', 'visible');
290 jQuery.fn.invisible = function() {
291 return this.css('visibility', 'hidden');
294 var generateTUUID = function(count){
295 var d = new Date().getTime();
296 var tuuid = 'xxxxxxxx-xxxx-txxx-xxxx-xxxxxxxxxxxx'.replace(/[x]/g, function(c){
297 var r = (d + Math.random()*16)%16 | 0;
298 d = Math.floor(d/16);
299 return (c == 'x' ? r : (r*0x3|0*8)).toString(16);
301 $("#formId" + count + " #tuuid").val(tuuid);
305 var propertiesToString = function(formIdNum) {
306 return $('#formId'+formIdNum+' #fieldPathM').val() + ' ' +
307 $('#formId'+formIdNum+' #operator').val() + ' ' +
308 $('#formId'+formIdNum+' #threshold').val() + ' ' +
309 $('#formId'+formIdNum+' #controlLoopSchema').val() + ' ' +
310 $('#formId'+formIdNum+' #closedLoopEventStatus').val();
313 loadPropertyWindow("tca");
315 //load dropdown with policy options
316 if (typeof allPolicies !== "undefined"){
317 $.each(Object.keys(allPolicies), function(val, text) {
318 $('#tcaPol').append($('<option></option>').val(text).html(text));
320 } else if (typeof elementMap !== "undefined"){
321 for (key in elementMap){
322 if (key.indexOf("Policy")>-1){
323 $.each(Object.keys(elementMap[key]), function(val, text){
325 $('<option></option>').val(text).html(text)
334 //load metrics dropdown
335 if (elementMap["global"]){
336 for (var i = 0; i < (elementMap["global"].length); i++){
337 if ((elementMap["global"][i]["name"]) == "vf"){
338 var vfSel = elementMap["global"][i]["value"];
339 if (vf_Services["shared"]["byVf"][vfSel]["kpi"]){
340 $.each((vf_Services["shared"]["byVf"][vfSel]["kpi"]), function(val, text) {
341 $('#fieldPathM').append(
342 $('<option></option>').val(val).html(text)
351 var arr = elementMap[lastElementSelected];
353 if (arr !== undefined) {
355 var num = add_one_more();
356 for (var i=0; i< arr[x].length; i++){
358 if (arr[x][i].hasOwnProperty('serviceConfigurations')){
359 for (var j=0; j<arr[x][i]["serviceConfigurations"].length; j++){
360 $("#formId" + num + " #tcaTable").prepend("<tr><td>"
361 +arr[x][i]["serviceConfigurations"][j][0]+" "
362 +(Object.keys(defaults_props['tca']['operator']).find(key => defaults_props['tca']['operator'][key] == (arr[x][i]["serviceConfigurations"][j][1])))+ " "
363 +arr[x][i]["serviceConfigurations"][j][2]+" "
364 +arr[x][i]["serviceConfigurations"][j][3]+" "
365 +arr[x][i]["serviceConfigurations"][j][4]+"</td></tr>");
368 $("#formId" + num + " #"+arr[x][i].name).val(arr[x][i].value);
371 $('#go_properties_tab'+num).text($('#formId' +num+ ' #tname').val());
372 $("#formId"+num + " #properties_tab").invisible();
376 $("#savePropsBtn").click(function(event) {
378 if (($('#formId'+num+' #tcaTable .highlight').length > 0 ) &&
379 (!($('#formId'+num+' #threshold').val()) || !($('#formId'+num+' #fieldPathM').val())) ) {
380 $('#formId'+num+' #tcaError').show();
383 $('#formId'+num+' .tcaErr').hide();
384 if ($('#formId'+num+' #tcaTable .highlight').length > 0){
385 $('#formId'+num+' #tcaTable .highlight td').text(propertiesToString(num));
388 $('.formId').each(function(){
389 var count = $(this).attr('id').slice(-1);
390 var header = $(this).find('.tcaParentItems').serializeArray();
394 $('#formId' +count+' #tcaTable tr').each(function(){
395 $('td', this).each(function(){
396 var splitTd = $(this).text().split(' ');
397 splitTd[1]=defaults_props['tca']['operator'][splitTd[1]];
398 var checkByKpi = vf_Services["shared"]["byKpi"][splitTd[0].replace(/\s/g, "")];
399 if (checkByKpi["fieldPath"]){
400 splitTd.push(Object.keys(vf_Services["shared"]["byKpi"][splitTd[0].replace(/\s/g, "")]["fieldPath"])[0]);
402 if ((checkByKpi["nfNamingCode"]) && (checkNF)){
403 $.grep(header, function(e,i){
404 if (e.name == "tnfc"){
405 header[i]["value"] = (Object.keys(checkByKpi["nfNamingCode"])[0]);
410 sconfa.push(splitTd);
414 var polSel = $(this).find('.tcaParentItems #tcaPol').val();
415 $.grep(header, function(e,i){
416 if (e.name == "tcaPolId"){
418 if (typeof allPolicies !== "undefined"){
419 header[i]["value"] = allPolicies[polSel][1]["value"];
420 } else if (typeof elementMap !== "undefined"){
421 for (key in elementMap){
422 if (key.indexOf("Policy")>-1){
423 header[i]["value"] = elementMap[key][polSel][1]["value"];
428 header[i]["value"]="";
433 sconf["serviceConfigurations"]=sconfa;
435 saveP[$(this).find('.tcaParentItems #tname').val()] = header;
438 saveProperties(saveP);
439 $("#close_button").click();
443 function uniquet(arr) {
445 for (var i=0, l=arr.length; i<l; i++){
446 if (a.indexOf(arr[i]) === -1 && arr[i] !== ''){
450 if (a.length==arr.length){
457 function add_one_more(){
458 $("#nav_Tabs li").removeClass("active");
459 var form=$($("#formSpan").children()[0]).clone();
461 if($(".formId").length>0){
464 for(var i=0;i<s.length; i++){
465 if(parseInt($(s[i]).attr("id").substring(6))>greatest){
466 greatest=parseInt($(s[i]).attr("id").substring(6))
470 $("#panelHolder").append(('<span class="formId" id="formId'+count+'"></span>'));
473 $("#panelHolder").append('<span class="formId" id="formId1"></span>');
476 $("#add_one_more").parent().before(' <li class="active"><a id="go_properties_tab'+count+'">New_Set</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>');
477 $("#formId"+count).append(form);
478 $('#formId'+count+ ' #properties_tab').invisible();
479 $(".formId").not($("#formId"+count)).css("display","none");
480 addCustListen(count);
485 function isNumberKey(event){
486 var charCode = (event.which) ? event.which : event.keyCode
487 if (charCode > 31 && (charCode < 48 || charCode > 57)){
493 function addCustListen(count) {
494 $('#go_properties_tab' + count).click(function(event) {
495 if ($("#nav_Tabs li.active").length>0){
496 var oldCount = $("#nav_Tabs li.active").find("a").attr("id").slice(-1);
497 if (($('#formId'+oldCount+' #tcaTable .highlight').length > 0 ) &&
498 (!($('#formId'+oldCount+' #threshold').val()) || !($('#formId'+oldCount+' #fieldPathM').val())) ) {
499 $('#formId'+oldCount+' #tcaError').show();
502 $('#formId'+oldCount+' .tcaErr').hide();
503 if ($('#formId'+oldCount+' #tcaTable .highlight').length > 0){
504 $('#formId'+oldCount+' #tcaTable .highlight td').text(propertiesToString(oldCount));
506 $("#formId"+oldCount+" #tcaTable .highlight").removeClass("highlight")
510 $("#nav_Tabs li").removeClass("active");
511 $(this).parent().addClass("active");
512 $("#formId"+count).css("display","");
513 $(".formId").not($("#formId"+count)).css("display","none");
516 $('#tab_close'+count).click(function(event){
517 $(this).parent().remove();
518 $("#formId"+count).remove();
521 $('#formId'+count+' #tcaTable').on('click', 'tr', function(event){
522 if (($('#formId'+count+' #tcaTable .highlight').length > 0 ) &&
523 (!($('#formId'+count+' #threshold').val()) || !($('#formId'+count+' #fieldPathM').val())) ) {
524 $('#formId'+count+' #tcaError').show();
527 $('#formId'+count+' .tcaErr').hide();
528 if ($('#formId'+count+' #tcaTable .highlight').length > 0){
529 $('#formId'+count+' #tcaTable .highlight td').text(propertiesToString(num));
531 //$('#formId'+count+' #tcaTable .highlight').text();
532 $(this).addClass('highlight').siblings().removeClass('highlight');
533 var str = $(this).text().split(' ');
534 $('#formId'+count + ' #properties_tab').visible();
535 if (str.length == 5){
536 $('#formId'+count+' #fieldPathM').val(str[0]).multiselect('refresh');
537 $('#formId'+count+' #operator').val(str[1]).multiselect('refresh');
538 $('#formId'+count+' #threshold').val(str[2]);
539 $('#formId'+count+' #controlLoopSchema').val(str[3]).multiselect('refresh');
540 $('#formId'+count+' #closedLoopEventStatus').val(str[4]).multiselect('refresh');
543 if ((!(readOnly||readMOnly)) && ($('#formId'+count + ' #deleteThresh').prop('disabled'))) {
544 $('#formId'+count + ' #deleteThresh').prop('disabled', false);
549 $('#formId'+count+' #deleteThresh').on('click', function(){
550 $('#formId'+num+' .tcaErr').hide();
551 $('#formId'+count+ ' #properties_tab').invisible();
552 $('#formId'+count+ ' #tcaTable .highlight').remove();
553 $('#formId'+count+ ' #deleteThresh').prop('disabled', true);
556 $('#formId'+count+' #createNewThresh').on('click', function(){
557 if (($('#formId'+count+' #tcaTable .highlight').length > 0 ) &&
558 (!($('#formId'+count+' #threshold').val()) || !($('#formId'+count+' #fieldPathM').val())) ){
559 $('#formId'+count+' #tcaError').show();
562 $('#formId'+count+' .tcaErr').hide();
563 if ($('#formId'+count+' #tcaTable .highlight').length > 0){
564 $('#formId'+count+' #tcaTable .highlight td').text(propertiesToString(count));
566 $('#formId'+count+ ' #properties_tab').visible();
567 if (('#formId'+count+' #tcaTable .highlight').length > 0 ){
568 $('#formId'+count+' #tcaTable tr.highlight').removeClass('highlight');
570 $('#formId'+count+' #tcaTable').prepend('<tr class="highlight"><td>New Threshold</td></tr>');
571 $('#formId'+count+' #fieldPathM').prop("selectedIndex", 0).multiselect('refresh');
572 $('#formId'+count+' #operator').prop("selectedIndex", 0).multiselect('refresh');
573 $('#formId'+count+' #threshold').val("");
574 $('#formId'+count+' #controlLoopSchema').prop("selectedIndex", 0).multiselect('refresh');
575 $('#formId'+count+' #closedLoopEventStatus').prop("selectedIndex", 0).multiselect('refresh');
577 if ($('#formId'+count + ' #deleteThresh').prop('disabled')) {
578 $('#formId'+count + ' #deleteThresh').prop('disabled', false);
583 $('#formId'+count+' #tname').on('change',function(){
584 $('#go_properties_tab'+count).text($('#formId'+count+' #tname').val())