/* var sliValuesObj = {}; var rpcValues = {}; $(function(){ $.get("/loadJSFiles") .done(function( data ) { if(data != undefined && data != null){ console.dir(data.sliValuesObj[0]['AicHoming_PROPS']); console.dir(data.sliValuesObj[0]['AicHoming_RPCS']); } }) .fail(function(err) { }) .always(function() { }); }); */ var global_editor ; function addParam(idVal){ //console.log(val); //console.log(global_editor.getText()); if(global_added_obj["a" + idVal] != undefined && global_added_obj["a" + idVal] != null){ global_added_obj["a" + idVal]= global_added_obj["a" + idVal]+1; $("#addCnt" + + idVal).text("added " + global_added_obj["a" + idVal] + " times"); }else{ global_added_obj["a" + idVal]= 1; $("#addCnt" + + idVal).text("added " + global_added_obj["a" + idVal] + " time"); } var nameVal = document.getElementById("a" + idVal).value; var valueBoxVal = document.getElementById("valbox" + idVal).value; //$("#btn" + idVal).val('Added'); //$("#btn" + idVal).attr('disabled','disabled'); //console.dir(nameVal); //console.dir(valueBoxVal); var paramElement = "\n"; global_editor.setText(global_editor.getText() + paramElement); } var g_currValuesObj={}; function filterValues(filterVal){ global_added_obj={}; var matchedCnt =0; var valuesObj = g_currValuesObj; var newValuesObj ={}; var searchValues =[]; if(filterVal != null && filterVal != undefined){ filterVal=filterVal.trim(); } searchValues = filterVal.split(/ /); //console.log("filterVal:" + filterVal); if(searchValues != null && searchValues != undefined){ for (var key in valuesObj) { if (valuesObj.hasOwnProperty(key)) { var newArrObj = []; if(Array.isArray(valuesObj[key])){ var arrObj=valuesObj[key]; var cnt=1; for(var i=0;i"; if(Array.isArray(valuesObj[key])){ var arrObj=valuesObj[key]; var cnt=1; for(var i=0;i
"; var variableBox = ""; var valBox = ""; if(arrObj[i] != undefined && arrObj[i].length <150){ //v += "
" + "" ; v += "
" + "" ; variableBox = ""; }else{ v+= "
" + ""; variableBox = ""; } v += "" + "" + "
"; cnt++; } htmlVal+= v + "
"; } } } return htmlVal; } function getModuleName(){ var activeWorkspace=RED.view.getWorkspace(); var moduleName=""; RED.nodes.eachNode(function(n) { if (n.z == activeWorkspace) { if(n.type == 'service-logic'){ //console.log("getModuleName():<" + n.module + ">"); moduleName=n.module; } } }); return moduleName; } var global_added_obj={}; var displayingRpcs = false; function showRpcsValuesBox(editor,valuesObj){ displayingRpcs = true; showValuesBox(editor,valuesObj); } function showValuesBox(editor,valuesObj){ var moduleName = getModuleName(); var obj = valuesObj[moduleName]; //console.dir(valuesObj); //console.dir(obj); var moduleObj ={}; if(obj == undefined){ moduleObj[moduleName] = ["No SLI values setup for this module " + moduleName + ".Upload the yang file for this module or if already uploaded ,load it from the Available Modules from the Menu."]; }else{ moduleObj[moduleName] = obj; } showValuesBoxForModule(editor,moduleObj,moduleName); } function showValuesBoxForModule(editor,valuesObj,moduleName){ global_editor=editor; g_currValuesObj = valuesObj; //console.log(editor.getText()); //populate the valid SLI values var valuesHtml="
" ; valuesHtml+=buildValuesHtml(valuesObj); valuesHtml+="
"; global_added_obj={}; var title = "SLI Values for Module " + moduleName; if(displayingRpcs){ title = "RPCs for Module " + moduleName; } $('#sli-values-dialog').dialog({ modal: false, title: title, width: 1200, height: 500, dialogClass: 'color-dialog', open: function () { $("#sli-values-dialog").dialog("widget").find(".ui-dialog-buttonpane").css({'background': 'aliceblue'}); $(this).html(valuesHtml); }, buttons: { Close: function () { displayingRpcs = false; //$(this).dialog("close"); $(this).dialog("destroy"); } }, close: function(ev,ui){ displayingRpcs = false; $(this).dialog("destroy"); } }); // end dialog div } function showCommentsBox(){ var comments = $("#node-input-comments").val(); var commentsBoxHtml="
" ; var nodeName=$("#node-input-name").val(); $('#comments-dialog').dialog({ modal: true, title: "Add comments for Node " + nodeName, width: 450, height: 300, /* open: function () { $(this).html(commentsBoxHtml); }, */ buttons: { "Save Comments": function () { var v=$("#taCommentId").val(); if(v != null){ v = v.trim(); if(v != ''){ $("#node-input-btnComments").html("View Comments"); }else{ $("#node-input-btnComments").html("Add Comments"); } } //console.log("value from text area" + v); $("#node-input-comments").val(v); $(this).dialog("close"); //$(this).dialog("destroy"); }, Cancel: function () { var v=$("#taCommentId").val(); if(v != null){ v = v.trim(); if(v != ''){ $("#node-input-btnComments").html("View Comments"); }else{ $("#node-input-btnComments").html("Add Comments"); } } $(this).dialog("close"); //$(this).dialog("destroy"); } }, close: function(ev,ui){ //console.log("closing.."); $(this).dialog("destroy"); } }).html(commentsBoxHtml); //console.log("done"); /* function functionDialogResize(ev,ui) { console.log("ui.size.height:" + ui.size.height); $(this).css("height",(ui.size.height-275)+"px"); }; $( this ).on("dialogresize", functionDialogResize); $( this ).one("dialogopen", function(ev) { var size = $( "#sliValDiv" ).dialog('option','sizeCache-function'); if (size) { functionDialogResize(null,{size:size}); } }); */ } function selectText(objId,groupVal){ //console.log(objId + groupVal); //console.log(objId + groupVal); $(document).ready(function(){ //console.log("doc ready"); //console.dir($('#valAddDiv' + objId)); if ($('#valAddDiv' + objId).is(":visible")) { $("#variableBoxDiv" + objId ).hide("slow"); //$("#a" + objId ).css({"background": "rgb(223, 191, 191)", // "color": "rgb(32, 45, 87)"}); $("#a" + objId ).css({"background": "aliceblue", "color": "rgb(32, 45, 87)"}); /*"color": "rgb(32, 45, 87)"});*/ $("#valAddDiv" + objId ).hide("slow"); $("#valueBoxDiv" +objId).css({"border-color": "aliceblue", "border-width":"1px", "background-color":"aliceblue", "border-style":"solid"}); //$("#valAddDiv" + objId ).fadeOut("slow"); } else{ $("#variableBoxDiv" + objId ).show("slow"); $("#valAddDiv" + objId).show("slow"); /*$("#valueBoxDiv" +objId).css({"border-color": "rgb(75, 111, 147)", "border-width":"5px", "background-color": "rgb(223, 191, 191)", "border-style":"solid", "border-bottom": "5px solid rgb(75, 111, 147)"}); */ $("#valueBoxDiv" +objId).css({"border-color": "rgb(75, 111, 147)", "border-width":"3px", "background-color": "aliceblue", "border-style":"solid", "border-bottom": "3px solid rgb(75, 111, 147)"}); /*$("#a" + objId ).css({"background": "rgb(223, 191, 191)", "color": "rgb(75, 111, 147)"}); */ $("#a" + objId ).css({"background": "aliceblue", "color": "rgb(75, 111, 147)"}); } $("#a" + objId).select(); }); //console.log("group-heading" + objId); // var obj= document.getElementById("group-heading" + objId); // obj.innerText = groupVal; // obj.style.color = "blue"; // console.dir(obj); } function hidePrevGroup(objId){ // console.log("mouseout" ); // var obj= document.getElementById("group-heading" + objId); // obj.innerText = ""; } /* function fixDiv() { var $cache = $('#getFixed'); if ($(window).scrollTop() > 100) $cache.css({ 'position': 'fixed', 'top': '10px' }); else $cache.css({ 'position': 'relative', 'top': 'auto' }); } $(window).scroll(fixDiv); function isScrolledIntoView(elem) { var $elem = $(elem); var $window = $(window); var docViewTop = $window.scrollTop(); var docViewBottom = docViewTop + $window.height(); var elemTop = $elem.offset().top; var elemBottom = elemTop + $elem.height(); return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop)); } */ function getCommits(filePath){ var urlPath="/getCommitsInfo"; $.get(urlPath,{"filePath" : filePath }) .done(function( data ) { if(data != undefined && data != null){ //console.log(data.stdout); var jsonObj = JSON.parse(data.stdout); var codeCloudFilesHtmlStr = $( "#codecloud-browser-dialog" ).html(); var htmlStr = getCCFileHtmlStr(filePath,jsonObj,codeCloudFilesHtmlStr); $( "#codecloud-browser-dialog" ).html(htmlStr); /* for(var i=0;i"; var htmlStr=""; //console.dir(rows); if(rows != null && rows.length >0){ var alertDialog = '
'; htmlStr= alertDialog + "
" + styleStr; htmlStr += ""; htmlStr += ""; htmlStr += ""; htmlStr += "" ; htmlStr += "" ; htmlStr += "" ; htmlStr += "" ; htmlStr += ""; if(rows != null && rows.length == 0){ htmlStr += ""; htmlStr += ""; htmlStr += "
" + filePath + "
Commit IDDateAuthorComment
No rows found
"; return htmlStr; } for(var i=0;i" + _commitId + ""; htmlStr += "" + dt + ""; htmlStr += "" + author + ""; htmlStr += "" + comment + ""; htmlStr += ""; } htmlStr += ""; htmlStr += "
"; } //console.log(htmlStr); return htmlStr; } var gitLocalFlowFiles=[]; function filterGitLocalFlows(filterVal){ var matchedCnt =0; var valuesObj = gitLocalFlowFiles; //console.dir(codeCloudFlowFiles); var updatedValuesObj =[]; var searchValues =[]; if(filterVal != null && filterVal != undefined){ filterVal=filterVal.trim(); } searchValues = filterVal.split(/ /); //console.log("filterVal:" + filterVal); //console.dir(searchValues); if(searchValues != null && searchValues != undefined){ var foundCount = 0; for(var k=0;k0){ valuesObj=updatedValuesObj; } updatedValuesObj=[]; for(var i=0;i b){ return 1; }else if(a < b){ return -1; }else{ return 0; } }); for(var i=0;files != null && i" + files[i] + ""; } } html+=""; html+=""; $( "#gitlocal-data-container" ).html(html); } var codeCloudFlowFiles=[]; function filterFlows(filterVal){ var matchedCnt =0; var valuesObj = codeCloudFlowFiles; //console.dir(codeCloudFlowFiles); var updatedValuesObj =[]; var searchValues =[]; if(filterVal != null && filterVal != undefined){ filterVal=filterVal.trim(); } searchValues = filterVal.split(/ /); //console.log("filterVal:" + filterVal); //console.dir(searchValues); if(searchValues != null && searchValues != undefined){ var foundCount = 0; for(var k=0;k b){ return 1; }else if(a < b){ return -1; }else{ return 0; } }); for(var i=0;files != null && i" + files[i] + ""; } } html+=""; html+=""; $( "#codecloud-data-container" ).html(html); } var yangFilesList=[]; /* function filterYangFiles(filterVal){ var matchedCnt =0; var valuesObj = yangFilesList; var updatedValuesObj =[]; var searchValues =[]; if(filterVal != null && filterVal != undefined){ filterVal=filterVal.trim(); } searchValues = filterVal.split(/ /); if(searchValues != null && searchValues != undefined){ var foundCount = 0; for(var k=0;k b){ return 1; }else if(a < b){ return -1; }else{ return 0; } }); for(var i=0;files != null && i" + files[i] + ""; } } html+=""; html+=""; $( "#list-yang-data-container" ).html(html); } */ function filterYangFiles(filterVal){ var matchedCnt =0; var valuesObj = yangFilesList; var updatedValuesObj =[]; var searchValues =[]; if(filterVal != null && filterVal != undefined){ filterVal=filterVal.trim(); } searchValues = filterVal.split(/ /); if(searchValues != null && searchValues != undefined){ var foundCount = 0; for(var k=0;k b){ return 1; }else if(a < b){ return -1; }else{ return 0; } }); for(var i=0;files != null && i" + files[i] + "" + ""; } } html+=""; html+=""; $( "#yang-files-data-container" ).html(html); } function getYangFile(fileName){ $("#dwnldYangFormId").remove(); //using form to submit var form = $('
'); form.append(''); form.appendTo('body'); $("#dwnldYangFormId").submit(); } function deleteYangFile(fileName){ var reqData= {"fileName":fileName}; $.post( "/deleteYangFile",reqData ) .done(function( data ) { }) .fail(function(err) { console.log( "error" + err ); }) .always(function() { $("#list-yang-browser-dialog").dialog("close"); $("#btn-list-yang-files").trigger("click"); }); } function importCCFlow(commitId,filePath){ var urlPath="/importCodeCloudFlow"; $.get(urlPath,{"commitId" : commitId,"filePath" : filePath }) .done(function( data ) { var nodeSet = getCurrentFlowNodeSet(); //console.dir(nodeSet); if(nodeSet != null && nodeSet.length == 0){ RED.view.setIsImportAction(true); } if(data != undefined && data != null){ //console.log(data.stdout); var jsonObj = JSON.parse(data.stdout); $( "#codecloud-browser-dialog" ).dialog("close"); RED.view.importNodes(JSON.stringify(jsonObj)); } }) .fail(function(err) { RED.notify("Could not import flow from code cloud."); $( "#codecloud-browser-dialog").dialog("close"); console.log( "error occured importing flow."); }) .always(function() { }); } function importGitLocalFlow(filePath){ var urlPath="/importGitLocalFlow"; $.get(urlPath,{"filePath" : filePath}) .done(function( data ) { var nodeSet = getCurrentFlowNodeSet(); //console.dir(nodeSet); if(nodeSet != null && nodeSet.length == 0){ RED.view.setIsImportAction(true); } if(data != undefined && data != null){ //console.log(data.stdout); var jsonObj; try{ jsonObj = JSON.parse(data.stdout); $( "#gitlocal-browser-dialog" ).dialog("close"); RED.view.importNodes(JSON.stringify(jsonObj)); }catch(err){ RED.notify("Could not import flow from Local Git Repository."); $( "#gitlocal-browser-dialog").dialog("close"); console.log( "error occured importing flow." + err); } }else{ RED.notify("Could not import flow from Local Git Repository."); $( "#gitlocal-browser-dialog").dialog("close"); console.log( "error occured importing flow." + err); } }) .fail(function(err) { RED.notify("Could not import flow from Local Git Repository."); $( "#gitlocal-browser-dialog").dialog("close"); console.log( "error occured importing flow."); }) .always(function() { }); } var availableYangModules=[]; function filterYangModules(filterVal){ var matchedCnt =0; var valuesObj = availableYangModules ; //console.dir(codeCloudFlowFiles); var updatedValuesObj =[]; var searchValues =[]; if(filterVal != null && filterVal != undefined){ filterVal=filterVal.trim(); } searchValues = filterVal.split(/ /); //console.log("filterVal:" + filterVal); //console.dir(searchValues); if(searchValues != null && searchValues != undefined){ var foundCount = 0; for(var k=0;k0){ valuesObj=updatedValuesObj; } updatedValuesObj=[]; for(var i=0;i b){ return 1; }else if(a < b){ return -1; }else{ return 0; } }); var count=1; for(var i=0;files != null && i" + val + ""; }else{ html+="" + count + "" + val + ""; } count++; } } html+=""; html+=""; $( "#yang-modules-data-container" ).html(html); } function filterCtxVariables(filterVal){ var matchedCnt =0; var valuesObj = dgParsedParameters; var newValuesObj ={}; var searchValues =[]; if(filterVal != null && filterVal != undefined){ filterVal=filterVal.trim(); } searchValues = filterVal.split(/ /); //console.log("filterVal:" + filterVal); //console.log("searchValues:" + searchValues); if(searchValues != undefined && searchValues != null && searchValues != ""){ for (var key in valuesObj) { if (valuesObj.hasOwnProperty(key)) { key = key.replace(/\$/g,""); var foundCount=0; for(var k=0;k int" + "  boolean   " + ""; htmlVal = "
" + newParameterRow + "
"; for (var key in valuesObj) { if (valuesObj.hasOwnProperty(key)) { key = key.replace(/\$/g,""); var inputStr = $("#test-dg-request").val(); var inputObj = JSON.parse(inputStr); var paramsArrObj = inputObj["input"]["sli-parameter"]; var alreadyAdded = false; var intChecked = false; var booleanChecked = false; var prevValue=""; for(var i=0;paramsArrObj != null && i  "; }else{ addBtn = ""; } var typeBtns = " string" + "  int" + "  boolean"; if(intChecked){ typeBtns = " string" + "  int" + "  boolean"; }else if(booleanChecked){ typeBtns = " string" + "  int" + "  boolean"; } var valBox =typeBtns + "

" + ""; if(key.length <150){ v += "
" + "" ; }else{ v+= "
" + "
"; } v += "
"; cnt++; htmlVal+= v + ""; } return htmlVal; } function updateParam(idVal){ var action = $("#abtn" + idVal).val(); if(action == "Delete"){ var nameVal = document.getElementById("aCtx" + idVal).value; var valueBoxVal = document.getElementById("avalbox" + idVal).value; //$("#addCnt" + idVal).text("added"); var addBtn = ""; $("#btnsDivId" + idVal).html(addBtn); var inputStr = $("#test-dg-request").val(); var inputObj = JSON.parse(inputStr); var paramsArrObj = inputObj["input"]["sli-parameter"]; var index = -1; for(var i=0;paramsArrObj != null && i  "; $("#btnsDivId" + idVal).html(addBtn); var inputStr = $("#test-dg-request").val(); var inputObj = {}; try{ inputObj = JSON.parse(inputStr); }catch(e){ $("#test-dg-response").val("Json parsing error" + e); return false; } var typeVal = "input[name=typeBtns" + idVal + "]:checked"; var valType =$(typeVal).val(); //console.log(valType); var parameterObj ={}; if(valType == "string"){ parameterObj = { "parameter-name" : nameVal, "string-value": valueBoxVal}; }else if(valType == "int"){ var intValue = 0; try{ intValue = parseInt(valueBoxVal); }catch(e){ } parameterObj = { "parameter-name" : nameVal, "int-value": intValue}; }else if(valType == "boolean"){ var booleanValue = false; try{ booleanValue = JSON.parse(valueBoxVal); }catch(e){ } parameterObj = { "parameter-name" : nameVal, "boolean-value": booleanValue}; } inputObj["input"]["sli-parameter"].push(parameterObj); var newInputStr =""; try{ newInputStr = JSON.stringify(inputObj,null,4); }catch(e){ } $("#test-dg-request").val(newInputStr); //console.log("newInputStr:" + newInputStr); } } function addNewParameter(idVal){ var nameVal = document.getElementById("aCtx" + idVal).value; var valueBoxVal = document.getElementById("avalbox" + idVal).value; var inputStr = $("#test-dg-request").val(); var inputObj = {}; try{ inputObj = JSON.parse(inputStr); }catch(e){ $("#test-dg-response").val("Json parsing error" + e); return false; } var typeVal = "input[name=typeBtns" + idVal + "]:checked"; var valType =$(typeVal).val(); //console.log(valType); var parameterObj ={}; if(valType == "string"){ parameterObj = { "parameter-name" : nameVal, "string-value": valueBoxVal}; }else if(valType == "int"){ var intValue = 0; try{ intValue = parseInt(valueBoxVal); }catch(e){ } parameterObj = { "parameter-name" : nameVal, "int-value": intValue}; }else if(valType == "boolean"){ var booleanValue = false; try{ booleanValue = JSON.parse(valueBoxVal); }catch(e){ } parameterObj = { "parameter-name" : nameVal, "boolean-value": booleanValue}; } inputObj["input"]["sli-parameter"].push(parameterObj); var newInputStr =""; try{ newInputStr = JSON.stringify(inputObj,null,4); }catch(e){ } $("#test-dg-request").val(newInputStr); $( "#ctx-values-dialog" ).dialog("close"); $('.ui-button:contains("$Variables")').click(); //console.log("newInputStr:" + newInputStr); } function updateParamVal(idVal){ var nameVal = document.getElementById("aCtx" + idVal).value; //var valueBoxVal = document.getElementById("avalbox" + idVal).value; var valueBoxVal = $("#avalbox" + idVal).val(); var inputStr = $("#test-dg-request").val(); var inputObj = {}; try{ inputObj = JSON.parse(inputStr); }catch(e){ $("#test-dg-response").val("Json parsing error" + e); return false; } var paramsArrObj = inputObj["input"]["sli-parameter"]; var index = -1; for(var i=0;paramsArrObj != null && i