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 ) { 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 ) { 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); }