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:#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>
183 <div class="col-sm-8 form-group">
184 <label class="col-sm-3"> Policy </label>
185 <div class="col-sm-9" style="padding:0px;">
186 <select name="tcaPol" id="tcaPol" enableFilter="true"></select>
189 <div class="col-sm-8 form-group">
190 <label class="col-sm-3">EventName</label>
191 <div class="col-sm-9" style="padding:0px;">
192 <select name="eventName" id="eventName" enableFilter="true"></select>
195 <div class="col-sm-8 form-group">
196 <label class="col-sm-3">Control Loop Schema Type</label>
197 <div class="col-sm-9" style="padding:0px;">
198 <select name="controlLoopSchemaType" id="controlLoopSchemaType" enableFilter="true"></select>
201 <div class="col-sm-8 form-group" style="display:none;">
202 <label class="col-sm-3"> Policy ID </label>
203 <div class="col-sm-9" style="padding:0px;">
204 <input class="form-control" onkeydown="return false;" type="text" id="tcaPolId" name="tcaPolId"></input>
211 <div class="tcaBody row">
212 <div class="col-sm-5" style="padding:0px 5px; margin: 15px;">
213 <div class="panel panel-default" id="tcaTableHolder">
214 <table id="tcaTable">
217 <div id="tcaError" class="tcaErr">Error: Please define/delete this new threshold</div>
218 <div id="tcaUnique" class="tcaErr">Error: Duplicate Set Name Found</div>
219 <div style="float:left">
220 <button type="button" id="createNewThresh" class="btn btn-sm">New Threshold</button>
222 <div style="float:right">
223 <button type="button" id="deleteThresh" class="btn btn-sm glyphicon glyphicon-trash" disabled></button>
228 <div id="tcaEditHolder" class="panel panel-default col-sm-6">
229 <div class="tab-content">
230 <div id="properties_tab" class="form-vertical">
232 <label class="control-label">Metric</label>
234 <select id="fieldPathM" name="fieldPathM"></select>
238 <label class="control-label">Operator</label>
240 <select id="operator" name="operator"></select>
244 <label class="control-label">Threshold</label>
246 <input type="text" maxlength="10" class="form-control" name="threshold"
247 onkeypress="return isNumberKey(event)" id="threshold"></input>
251 <label class="control-label">Closed Loop Event Status</label>
253 <select id="closedLoopEventStatus" name="closedLoopEventStatus"></select>
268 <div class="modal-footer">
269 <!--<button ng-click="reset()" class="btn btn-primary" style="float:left">Reset</button>-->
270 <button id="savePropsBtn" class="btn btn-primary">Close</button>
271 <button ng-click="close(true)" id="close_button"
272 class="btn btn-primary">Cancel</button>
275 <script language="javascript">
276 // helper that make jquery objects visibles or invisible
277 // to use instead of show to keep placeholder size correct
278 jQuery.fn.visible = function() {
279 return this.css('visibility', 'visible');
281 jQuery.fn.invisible = function() {
282 return this.css('visibility', 'hidden');
285 var generateTUUID = function(count){
286 var d = new Date().getTime();
287 var tuuid = 'xxxxxxxx-xxxx-txxx-xxxx-xxxxxxxxxxxx'.replace(/[x]/g, function(c){
288 var r = (d + Math.random()*16)%16 | 0;
289 d = Math.floor(d/16);
290 return (c == 'x' ? r : (r*0x3|0*8)).toString(16);
292 $("#formId" + count + " #tuuid").val(tuuid);
296 var propertiesToString = function(formIdNum) {
297 return $('#formId'+formIdNum+' #fieldPathM').find(':selected').text() + ' ' +
298 $('#formId'+formIdNum+' #operator').val() + ' ' +
299 $('#formId'+formIdNum+' #threshold').val() + ' ' +
300 $('#formId'+formIdNum+' #closedLoopEventStatus').val();
303 loadPropertyWindow("tca");
305 //load dropdown with policy options
306 if (typeof allPolicies !== "undefined"){
307 $.each(Object.keys(allPolicies), function(val, text) {
308 $('#tcaPol').append($('<option></option>').val(text).html(text));
310 } else if (typeof elementMap !== "undefined"){
311 for (key in elementMap){
312 if (key.indexOf("Policy")>-1){
313 $.each(Object.keys(elementMap[key]), function(val, text){
315 $('<option></option>').val(text).html(text)
322 var fieldPathMLabel2Value = function(label) {
323 return Object.keys(defaults_props['tca']['fieldPathM']).find(key => defaults_props['tca']['fieldPathM'][key] == label)
325 var fieldPathMValue2Label = function(value) {
326 return defaults_props['tca']['fieldPathM'][value];
331 var arr = elementMap[lastElementSelected];
333 if (arr !== undefined) {
335 var num = add_one_more();
336 for (var i=0; i< arr[x].length; i++){
338 if (arr[x][i].hasOwnProperty('serviceConfigurations')){
339 for (var j=0; j<arr[x][i]["serviceConfigurations"].length; j++){
340 $("#formId" + num + " #tcaTable").prepend("<tr><td>"
341 +fieldPathMValue2Label(arr[x][i]["serviceConfigurations"][j][0])+ " "
342 +(Object.keys(defaults_props['tca']['operator']).find(key => defaults_props['tca']['operator'][key] == (arr[x][i]["serviceConfigurations"][j][1])))+ " "
343 +arr[x][i]["serviceConfigurations"][j][2]+" "
344 +arr[x][i]["serviceConfigurations"][j][3]+" "
345 +arr[x][i]["serviceConfigurations"][j][4]+"</td></tr>");
348 $("#formId" + num + " #"+arr[x][i].name).val(arr[x][i].value);
351 $('#go_properties_tab'+num).text($('#formId' +num+ ' #tname').val());
352 $("#formId"+num + " #properties_tab").invisible();
355 var count = add_one_more();
356 generateTUUID(count);
359 $("#savePropsBtn").click(function(event) {
361 if (($('#formId'+num+' #tcaTable .highlight').length > 0 ) &&
362 (!($('#formId'+num+' #threshold').val()) || !($('#formId'+num+' #fieldPathM').val())) ) {
363 $('#formId'+num+' #tcaError').show();
366 $('#formId'+num+' .tcaErr').hide();
367 if ($('#formId'+num+' #tcaTable .highlight').length > 0){
368 $('#formId'+num+' #tcaTable .highlight td').text(propertiesToString(num));
371 $('.formId').each(function(){
372 var count = $(this).attr('id').slice(-1);
373 var header = $(this).find('.tcaParentItems').serializeArray();
376 $('#formId' +count+' #tcaTable tr').each(function(){
377 $('td', this).each(function(){
378 var splitTd = $(this).text().split(' ');
379 splitTd[0]=fieldPathMLabel2Value(splitTd[0]);
380 splitTd[1]=defaults_props['tca']['operator'][splitTd[1]];
381 sconfa.push(splitTd);
385 var polSel = $(this).find('.tcaParentItems #tcaPol').val();
386 $.grep(header, function(e,i){
387 if (e.name == "tcaPolId"){
389 if (typeof allPolicies !== "undefined"){
390 header[i]["value"] = allPolicies[polSel][1]["value"];
391 } else if (typeof elementMap !== "undefined"){
392 for (key in elementMap){
393 if (key.indexOf("Policy")>-1){
394 header[i]["value"] = elementMap[key][polSel][1]["value"];
399 header[i]["value"]="";
404 sconf["serviceConfigurations"]=sconfa;
406 saveP[$(this).find('.tcaParentItems #tname').val()] = header;
409 saveProperties(saveP);
410 $("#close_button").click();
414 function uniquet(arr) {
416 for (var i=0, l=arr.length; i<l; i++){
417 if (a.indexOf(arr[i]) === -1 && arr[i] !== ''){
421 if (a.length==arr.length){
428 function add_one_more(){
429 $("#nav_Tabs li").removeClass("active");
430 var form=$($("#formSpan").children()[0]).clone();
432 if($(".formId").length>0){
435 for(var i=0;i<s.length; i++){
436 if(parseInt($(s[i]).attr("id").substring(6))>greatest){
437 greatest=parseInt($(s[i]).attr("id").substring(6))
441 $("#panelHolder").append(('<span class="formId" id="formId'+count+'"></span>'));
444 $("#panelHolder").append('<span class="formId" id="formId1"></span>');
447 $("#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>');
448 $("#formId"+count).append(form);
449 $('#formId'+count+ ' #properties_tab').invisible();
450 $(".formId").not($("#formId"+count)).css("display","none");
451 addCustListen(count);
456 function isNumberKey(event){
457 var charCode = (event.which) ? event.which : event.keyCode
458 if (charCode > 31 && (charCode < 48 || charCode > 57)){
464 function addCustListen(count) {
465 $('#go_properties_tab' + count).click(function(event) {
466 if ($("#nav_Tabs li.active").length>0){
467 var oldCount = $("#nav_Tabs li.active").find("a").attr("id").slice(-1);
468 if (($('#formId'+oldCount+' #tcaTable .highlight').length > 0 ) &&
469 (!($('#formId'+oldCount+' #threshold').val()) || !($('#formId'+oldCount+' #fieldPathM').val())) ) {
470 $('#formId'+oldCount+' #tcaError').show();
473 $('#formId'+oldCount+' .tcaErr').hide();
474 if ($('#formId'+oldCount+' #tcaTable .highlight').length > 0){
475 $('#formId'+oldCount+' #tcaTable .highlight td').text(propertiesToString(oldCount));
477 $("#formId"+oldCount+" #tcaTable .highlight").removeClass("highlight")
481 $("#nav_Tabs li").removeClass("active");
482 $(this).parent().addClass("active");
483 $("#formId"+count).css("display","");
484 $(".formId").not($("#formId"+count)).css("display","none");
487 $('#tab_close'+count).click(function(event){
488 $(this).parent().remove();
489 $("#formId"+count).remove();
492 $('#formId'+count+' #tcaTable').on('click', 'tr', function(event){
493 if (($('#formId'+count+' #tcaTable .highlight').length > 0 ) &&
494 (!($('#formId'+count+' #threshold').val()) || !($('#formId'+count+' #fieldPathM').val())) ) {
495 $('#formId'+count+' #tcaError').show();
498 $('#formId'+count+' .tcaErr').hide();
499 if ($('#formId'+count+' #tcaTable .highlight').length > 0){
500 $('#formId'+count+' #tcaTable .highlight td').text(propertiesToString(num));
502 //$('#formId'+count+' #tcaTable .highlight').text();
503 $(this).addClass('highlight').siblings().removeClass('highlight');
504 var str = $(this).text().split(' ');
505 $('#formId'+count + ' #properties_tab').visible();
506 if (str.length == 5){
507 $('#formId'+count+' #fieldPathM').val(fieldPathMLabel2Value(str[0])).multiselect('refresh');
508 $('#formId'+count+' #operator').val(str[1]).multiselect('refresh');
509 $('#formId'+count+' #threshold').val(str[2]);
510 $('#formId'+count+' #closedLoopEventStatus').val(str[3]).multiselect('refresh');
513 if ((!(readMOnly)) && ($('#formId'+count + ' #deleteThresh').prop('disabled'))) {
514 $('#formId'+count + ' #deleteThresh').prop('disabled', false);
519 $('#formId'+count+' #deleteThresh').on('click', function(){
520 $('#formId'+num+' .tcaErr').hide();
521 $('#formId'+count+ ' #properties_tab').invisible();
522 $('#formId'+count+ ' #tcaTable .highlight').remove();
523 $('#formId'+count+ ' #deleteThresh').prop('disabled', true);
526 $('#formId'+count+' #createNewThresh').on('click', function(){
527 if (($('#formId'+count+' #tcaTable .highlight').length > 0 ) &&
528 (!($('#formId'+count+' #threshold').val()) || !($('#formId'+count+' #fieldPathM').val())) ){
529 $('#formId'+count+' #tcaError').show();
532 $('#formId'+count+' .tcaErr').hide();
533 if ($('#formId'+count+' #tcaTable .highlight').length > 0){
534 $('#formId'+count+' #tcaTable .highlight td').text(propertiesToString(count));
536 $('#formId'+count+ ' #properties_tab').visible();
537 if (('#formId'+count+' #tcaTable .highlight').length > 0 ){
538 $('#formId'+count+' #tcaTable tr.highlight').removeClass('highlight');
540 $('#formId'+count+' #tcaTable').prepend('<tr class="highlight"><td>New Threshold</td></tr>');
541 $('#formId'+count+' #fieldPathM').prop("selectedIndex", 0).multiselect('refresh');
542 $('#formId'+count+' #operator').prop("selectedIndex", 0).multiselect('refresh');
543 $('#formId'+count+' #threshold').val("");
544 $('#formId'+count+' #closedLoopEventStatus').prop("selectedIndex", 0).multiselect('refresh');
546 if ($('#formId'+count + ' #deleteThresh').prop('disabled')) {
547 $('#formId'+count + ' #deleteThresh').prop('disabled', false);
552 $('#formId'+count+' #tname').on('change',function(){
553 $('#go_properties_tab'+count).text($('#formId'+count+' #tname').val())