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;
74 background-color: #f5f5f5;
76 margin: 15px 15px 0 0;
90 .tcaParentItems label{
100 border-bottom: 1px solid #ddd;
101 border-collapse: collapse;
111 #tcaTable tr.highlight{
112 background-color: #f5f5f5;
125 <script type="text/javascript">
126 function disablefile() {
128 document.getElementById("fileUpload").disabled = true;
132 function disableSVN() {
133 var selectLength = document.querySelectorAll(".disabled-block-container .tab-close-popup");
134 if(selectLength && selectLength.length>0){
135 for(var i = 0; i< selectLength.length ; i++){
136 selectLength[i].disabled = true;
140 document.getElementById("schemaLocation").disabled = true;
141 document.getElementById("userID").disabled = true;
142 document.getElementById("password").disabled = true;
148 <div id="configure-widgets" class="disabled-block-container">
149 <div class="modal-header">
150 <button type="button" class="close" ng-click="close(false)"
151 aria-hidden="true" style="margin-top: -3px">×</button>
152 <h4>TCA Micro Services</h4>
154 <div class="modal-body">
155 <div style="height: 10px"></div>
156 <div class="panel panel-default" id="panelHolder">
158 <div class="panel-heading">
159 <ul id="nav_Tabs" class="nav nav-tabs">
160 <li class><a id="add_one_more" href="#desc_tab"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></a></li>
164 <span id="formSpan" style="display:none;">
165 <div class="panel-body">
167 <form class="tcaParentItems">
169 <div class="col-sm-8 form-group">
170 <label class="col-sm-3"> Name </label>
171 <div class="col-sm-9" style="padding:0px;">
172 <input class="form-control" type="text" maxlength="48" id="tname" name="tname"></input>
176 <div class="col-sm-8 form-group" style="display:none;">
177 <label class="col-sm-3"> UUID </label>
178 <div class="col-sm-9" style="padding:0px;">
179 <input class="form-control" onkeydown="return false;" type="text" id="tuuid" name="tuuid"></input>
183 <div class="col-sm-8 form-group" style="display:none;">
184 <label class="col-sm-3"> NF Code </label>
185 <div class="col-sm-9" style="padding:0px;">
186 <input class="form-control" onkeydown="return false;" type="text" id="tnfc" name="tnfc"></input>
190 <div class="col-sm-3 form-group">
191 <label class="col-sm-8"> Enable </label>
192 <input class="col-sm-4" type="checkbox" style="height:21px;
193 width:21px; margin:6px;" checked="checked" id="tcaEnab" name="tcaEnab"></input>
197 <div class="col-sm-8 form-group">
198 <label class="col-sm-3"> Policy </label>
199 <div class="col-sm-9" style="padding:0px;">
200 <select name="tcaPol" id="tcaPol" 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>
211 <div class="col-sm-3 form-group">
212 <label class="col-sm-8">Max Intervals</label>
213 <input class="col-sm-4 form-control" style="width:80%" type="text" maxlength="3"
214 id="tcaInt" onkeypress="return isNumberKey(event)" name="tcaInt"></input>
218 <div class="col-sm-8 form-group">
219 <label class="col-sm-3"> Severity </label>
220 <div class="col-sm-9" style="padding:0px;">
221 <select name="tcaSev" id="tcaSev" enableFilter="false">
226 <div class="col-sm-3 form-group">
227 <label class="col-sm-8">Min Violations</label>
228 <input class="col-sm-4 form-control" style="width:80%" type="text" maxlength="3"
229 id="tcaVio" onkeypress="return isNumberKey(event)" name="tcaVio"></input>
234 <div class="tcaBody row">
235 <div class="col-sm-5" style="padding:0px 5px; margin: 15px;">
236 <div class="panel panel-default" id="tcaTableHolder">
237 <table id="tcaTable">
240 <div id="tcaError" class="tcaErr">Error: Please define/delete this new threshold</div>
241 <div id="tcaUnique" class="tcaErr">Error: Duplicate Set Name Found</div>
242 <div style="float:left">
243 <button type="button" id="createNewThresh" class="btn btn-sm">New Threshold</button>
245 <div style="float:right">
246 <button type="button" id="deleteThresh" class="btn btn-sm glyphicon glyphicon-trash" disabled></button>
251 <div id="tcaEditHolder" class="panel panel-default col-sm-6">
252 <div class="tab-content">
253 <div id="properties_tab" style="padding:10px;" class="form-horizontal">
254 <div style="margin-bottom:20px;">
255 <label class="control-label">Metric</label>
257 <select id="fieldPathM" name="fieldPathM"></select>
260 <div style="margin-bottom:20px;">
261 <label class="control-label">Operator</label>
263 <select id="operator" name="operator"></select>
266 <div style="margin-bottom:20px;">
267 <label class="control-label">Threshold</label>
269 <input type="text" maxlength="10" class="form-control" name="threshold"
270 onkeypress="return isNumberKey(event)" id="threshold"></input>
285 <div class="modal-footer">
286 <!--<button ng-click="reset()" class="btn btn-primary" style="float:left">Reset</button>-->
287 <button id="savePropsBtn" class="btn btn-primary">Close</button>
288 <button ng-click="close(true)" id="close_button"
289 class="btn btn-primary">Cancel</button>
293 var generateTUUID = function(count){
294 var d = new Date().getTime();
295 var tuuid = 'xxxxxxxx-xxxx-txxx-xxxx-xxxxxxxxxxxx'.replace(/[x]/g, function(c){
296 var r = (d + Math.random()*16)%16 | 0;
297 d = Math.floor(d/16);
298 return (c == 'x' ? r : (r*0x3|0*8)).toString(16);
300 $("#formId" + count + " #tuuid").val(tuuid);
303 $("#add_one_more").click(function(event) {
304 event.preventDefault();
305 if ($("#nav_Tabs li.active").length>0){
306 var oldCount = $("#nav_Tabs li.active").find("a").attr("id").slice(-1);
307 if (($('#formId'+oldCount+' #tcaTable .highlight').length > 0 ) &&
308 (!($('#formId'+oldCount+' #threshold').val()) || !($('#formId'+oldCount+' #fieldPathM').val())) ) {
309 $('#formId'+oldCount+' #tcaError').show();
312 $('#formId'+oldCount+' .tcaErr').hide();
313 if ($('#formId'+oldCount+' #tcaTable .highlight').length > 0){
314 $('#formId'+oldCount+' #tcaTable .highlight td').text(
315 $('#formId'+oldCount+' #fieldPathM').val() + ' ' +
316 $('#formId'+oldCount+' #operator').val() + ' ' +
317 $('#formId'+oldCount+' #threshold').val());
319 $("#formId"+oldCount+" #tcaTable .highlight").removeClass("highlight")
322 var count = add_one_more();
323 generateTUUID(count);
325 loadPropertyWindow("tca");
327 //load dropdown with policy options
328 if (typeof allPolicies !== "undefined"){
329 $.each(Object.keys(allPolicies), function(val, text) {
330 $('#tcaPol').append($('<option></option>').val(text).html(text));
332 } else if (typeof elementMap !== "undefined"){
333 for (key in elementMap){
334 if (key.indexOf("Policy")>-1){
335 $.each(Object.keys(elementMap[key]), function(val, text){
337 $('<option></option>').val(text).html(text)
346 //load metrics dropdown
347 if (elementMap["global"]){
348 for (var i = 0; i < (elementMap["global"].length); i++){
349 if ((elementMap["global"][i]["name"]) == "vf"){
350 var vfSel = elementMap["global"][i]["value"];
351 if (vf_Services["shared"]["byVf"][vfSel]["kpi"]){
352 $.each((vf_Services["shared"]["byVf"][vfSel]["kpi"]), function(val, text) {
353 $('#fieldPathM').append(
354 $('<option></option>').val(val).html(text)
363 var arr = elementMap[lastElementSelected];
365 if (arr !== undefined) {
367 var num = add_one_more();
369 for (var i=0; i< arr[x].length; i++){
370 if (arr[x][i].name=='tcaEnab'){
371 $("#formId" + num + " #tcaEnab").prop("checked","true");
375 if (arr[x][i].hasOwnProperty('serviceConfigurations')){
376 for (var j=0; j<arr[x][i]["serviceConfigurations"].length; j++){
377 $("#formId" + num + " #tcaTable").prepend("<tr><td>"
378 +arr[x][i]["serviceConfigurations"][j][0]+" "
379 //+(defaults_props['tca']['operator']).getKey(arr[x][i]["serviceConfigurations"][j][1])+" "
380 +(Object.keys(defaults_props['tca']['operator']).find(key => defaults_props['tca']['operator'][key] == (arr[x][i]["serviceConfigurations"][j][1])))+ " "
381 +arr[x][i]["serviceConfigurations"][j][2]+"</td></tr>");
384 $("#formId" + num + " #"+arr[x][i].name).val(arr[x][i].value);
388 $("#formId" + num + " #tcaEnab").prop("checked",false);
390 $('#go_properties_tab'+num).text($('#formId' +num+ ' #tname').val());
391 $("#formId"+num + " #properties_tab").hide();
395 $("#savePropsBtn").click(function(event) {
396 var num = $('#nav_Tabs .active a').attr('id').slice(-1);
398 $('#nav_Tabs li:not(:last)').each(function(){
399 tabs.push($(this).text());
401 var nonunique = uniquet(tabs);
402 if (($('#formId'+num+' #tcaTable .highlight').length > 0 ) &&
403 (!($('#formId'+num+' #threshold').val()) || !($('#formId'+num+' #fieldPathM').val())) ) {
404 $('#formId'+num+' #tcaError').show();
406 } else if (nonunique){
407 $('#formId'+num+' #tcaUnique').show();
410 $('#formId'+num+' .tcaErr').hide();
411 if ($('#formId'+num+' #tcaTable .highlight').length > 0){
412 $('#formId'+num+' #tcaTable .highlight td').text(
413 $('#formId'+num+' #fieldPathM').val() + ' ' +
414 $('#formId'+num+' #operator').val() + ' ' +
415 $('#formId'+num+' #threshold').val());
418 $('.formId').each(function(){
419 var count = $(this).attr('id').slice(-1);
420 var header = $(this).find('.tcaParentItems').serializeArray();
424 $('#formId' +count+' #tcaTable tr').each(function(){
425 $('td', this).each(function(){
426 var splitTd = $(this).text().split(' ');
427 splitTd[1]=defaults_props['tca']['operator'][splitTd[1]];
428 var checkByKpi = vf_Services["shared"]["byKpi"][splitTd[0].replace(/\s/g, "")];
429 if (checkByKpi["fieldPath"]){
430 splitTd.push(Object.keys(vf_Services["shared"]["byKpi"][splitTd[0].replace(/\s/g, "")]["fieldPath"])[0]);
432 if ((checkByKpi["nfNamingCode"]) && (checkNF)){
433 $.grep(header, function(e,i){
434 if (e.name == "tnfc"){
435 header[i]["value"] = (Object.keys(checkByKpi["nfNamingCode"])[0]);
440 sconfa.push(splitTd);
444 var polSel = $(this).find('.tcaParentItems #tcaPol').val();
445 $.grep(header, function(e,i){
446 if (e.name == "tcaPolId"){
448 if (typeof allPolicies !== "undefined"){
449 header[i]["value"] = allPolicies[polSel][1]["value"];
450 } else if (typeof elementMap !== "undefined"){
451 for (key in elementMap){
452 if (key.indexOf("Policy")>-1){
453 header[i]["value"] = elementMap[key][polSel][1]["value"];
458 header[i]["value"]="";
463 sconf["serviceConfigurations"]=sconfa;
465 saveP[$(this).find('.tcaParentItems #tname').val()] = header;
468 saveProperties(saveP);
469 $("#close_button").click();
473 function uniquet(arr) {
475 for (var i=0, l=arr.length; i<l; i++){
476 if (a.indexOf(arr[i]) === -1 && arr[i] !== ''){
480 if (a.length==arr.length){
487 function add_one_more(){
488 $("#nav_Tabs li").removeClass("active");
489 var form=$($("#formSpan").children()[0]).clone();
491 if($(".formId").length>0){
494 for(var i=0;i<s.length; i++){
495 if(parseInt($(s[i]).attr("id").substring(6))>greatest){
496 greatest=parseInt($(s[i]).attr("id").substring(6))
500 $("#panelHolder").append(('<span class="formId" id="formId'+count+'"></span>'));
503 $("#panelHolder").append('<span class="formId" id="formId1"></span>');
506 $("#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>');
507 $("#formId"+count).append(form);
508 $('#formId'+count+ ' #properties_tab').hide();
509 $(".formId").not($("#formId"+count)).css("display","none");
510 addCustListen(count);
515 function isNumberKey(event){
516 var charCode = (event.which) ? event.which : event.keyCode
517 if (charCode > 31 && (charCode < 48 || charCode > 57)){
523 function addCustListen(count) {
524 $('#go_properties_tab' + count).click(function(event) {
525 if ($("#nav_Tabs li.active").length>0){
526 var oldCount = $("#nav_Tabs li.active").find("a").attr("id").slice(-1);
527 if (($('#formId'+oldCount+' #tcaTable .highlight').length > 0 ) &&
528 (!($('#formId'+oldCount+' #threshold').val()) || !($('#formId'+oldCount+' #fieldPathM').val())) ) {
529 $('#formId'+oldCount+' #tcaError').show();
532 $('#formId'+oldCount+' .tcaErr').hide();
533 if ($('#formId'+oldCount+' #tcaTable .highlight').length > 0){
534 $('#formId'+oldCount+' #tcaTable .highlight td').text(
535 $('#formId'+oldCount+' #fieldPathM').val() + ' ' +
536 $('#formId'+oldCount+' #operator').val() + ' ' +
537 $('#formId'+oldCount+' #threshold').val());
539 $("#formId"+oldCount+" #tcaTable .highlight").removeClass("highlight")
543 $("#nav_Tabs li").removeClass("active");
544 $(this).parent().addClass("active");
545 $("#formId"+count).css("display","");
546 $(".formId").not($("#formId"+count)).css("display","none");
549 $('#tab_close'+count).click(function(event){
550 $(this).parent().remove();
551 $("#formId"+count).remove();
554 $('#formId'+count+' #tcaTable').on('click', 'tr', function(event){
555 if (($('#formId'+count+' #tcaTable .highlight').length > 0 ) &&
556 (!($('#formId'+count+' #threshold').val()) || !($('#formId'+count+' #fieldPathM').val())) ) {
557 $('#formId'+count+' #tcaError').show();
560 $('#formId'+count+' .tcaErr').hide();
561 if ($('#formId'+count+' #tcaTable .highlight').length > 0){
562 $('#formId'+count+' #tcaTable .highlight td').text(
563 $('#formId'+count+' #fieldPathM').val() + ' ' +
564 $('#formId'+count+' #operator').val() + ' ' +
565 $('#formId'+count+' #threshold').val());
567 //$('#formId'+count+' #tcaTable .highlight').text();
568 $(this).addClass('highlight').siblings().removeClass('highlight');
569 var str = $(this).text().split(' ');
570 $('#formId'+count + ' #properties_tab').show();
571 if (str.length == 3){
572 $('#formId'+count+' #fieldPathM').val(str[0]).multiselect('refresh');
573 $('#formId'+count+' #operator').val(str[1]).multiselect('refresh');
574 $('#formId'+count+' #threshold').val(str[2]);
577 if ((!(readOnly||readMOnly)) && ($('#formId'+count + ' #deleteThresh').prop('disabled'))) {
578 $('#formId'+count + ' #deleteThresh').prop('disabled', false);
583 $('#formId'+count+' #deleteThresh').on('click', function(){
584 $('#formId'+num+' .tcaErr').hide();
585 $('#formId'+count+ ' #properties_tab').hide();
586 $('#formId'+count+ ' #tcaTable .highlight').remove();
587 $('#formId'+count+ ' #deleteThresh').prop('disabled', true);
590 $('#formId'+count+' #createNewThresh').on('click', function(){
591 if (($('#formId'+count+' #tcaTable .highlight').length > 0 ) &&
592 (!($('#formId'+count+' #threshold').val()) || !($('#formId'+count+' #fieldPathM').val())) ){
593 $('#formId'+count+' #tcaError').show();
596 $('#formId'+count+' .tcaErr').hide();
597 if ($('#formId'+count+' #tcaTable .highlight').length > 0){
598 $('#formId'+count+' #tcaTable .highlight td').text(
599 $('#formId'+count+' #fieldPathM').val() + ' ' +
600 $('#formId'+count+' #operator').val() + ' ' +
601 $('#formId'+count+' #threshold').val());
603 $('#formId'+count+ ' #properties_tab').show();
604 if (('#formId'+count+' #tcaTable .highlight').length > 0 ){
605 $('#formId'+count+' #tcaTable tr.highlight').removeClass('highlight');
607 $('#formId'+count+' #tcaTable').prepend('<tr class="highlight"><td>New Threshold</td></tr>');
608 $('#formId'+count+' #fieldPathM').prop("selectedIndex", 0).multiselect('refresh');
609 $('#formId'+count+' #operator').prop("selectedIndex", 0).multiselect('refresh');
610 $('#formId'+count+' #threshold').val("");
612 if ($('#formId'+count + ' #deleteThresh').prop('disabled')) {
613 $('#formId'+count + ' #deleteThresh').prop('disabled', false);
618 $('#formId'+count+' #tname').on('change',function(){
619 $('#go_properties_tab'+count).text($('#formId'+count+' #tname').val())