2 * Copyright 2013 IBM Corp.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 var RED = (function() {
18 function hideDropTarget() {
19 $("#dropTarget").hide();
20 RED.keyboard.remove(/* ESCAPE */ 27);
23 $('#chart').on("dragenter",function(event) {
24 if ($.inArray("text/plain",event.originalEvent.dataTransfer.types) != -1) {
25 $("#dropTarget").css({display:'table'});
26 RED.keyboard.add(/* ESCAPE */ 27,hideDropTarget);
30 $('#dropTarget').on("dragover",function(event) {
31 if ($.inArray("text/plain",event.originalEvent.dataTransfer.types) != -1) {
32 event.preventDefault();
35 .on("dragleave",function(event) {
38 .on("drop",function(event) {
39 var data = event.originalEvent.dataTransfer.getData("text/plain");
41 RED.view.importNodes(data);
42 event.preventDefault();
46 function save(force) {
47 if (RED.view.dirty()) {
48 //$("#debug-tab-clear").click(); // uncomment this to auto clear debug on deploy
52 var unknownNodes = [];
53 RED.nodes.eachNode(function(node) {
54 invalid = invalid || !node.valid;
55 if (node.type === "unknown") {
56 if (unknownNodes.indexOf(node.name) == -1) {
57 unknownNodes.push(node.name);
63 if (unknownNodes.length > 0) {
64 $( "#node-dialog-confirm-deploy-config" ).hide();
65 $( "#node-dialog-confirm-deploy-unknown" ).show();
66 var list = "<li>"+unknownNodes.join("</li><li>")+"</li>";
67 $( "#node-dialog-confirm-deploy-unknown-list" ).html(list);
69 $( "#node-dialog-confirm-deploy-config" ).show();
70 $( "#node-dialog-confirm-deploy-unknown" ).hide();
72 $( "#node-dialog-confirm-deploy" ).dialog( "open" );
76 var nns = RED.nodes.createCompleteNodeSet();
77 /****************************************/
78 /*added new code to save the Tabs order */
79 /****************************************/
80 //console.log("nns before changes.");
84 var nnsTabIdsArr = [];
85 var guiTabIdsArr = [];
86 nns.forEach(function(n) {
90 nnsTabIdsArr.push(n.id);
94 $("#workspace-tabs li a").each(function(){
95 var href = $(this).prop("href");
96 var indexOfHash = href.indexOf("#");
97 var idVal = href.slice(indexOfHash+1);
98 guiTabIdsArr.push(idVal);
99 nns.splice(idx,1,allTabsObj[idVal]);;
102 //console.log(nnsTabIdsArr.join(","));
103 //console.log(guiTabIdsArr.join(","));
104 //console.log("nns after changes.");
106 /****************************/
107 $("#btn-icn-deploy").removeClass('fa-download');
108 $("#btn-icn-deploy").addClass('spinner');
109 RED.view.dirty(false);
114 data: JSON.stringify(nns),
115 contentType: "application/json; charset=utf-8"
116 }).done(function(data,textStatus,xhr) {
117 RED.notify("Successfully saved","success");
118 RED.nodes.eachNode(function(node) {
121 node.changed = false;
123 if(node.credentials) {
124 delete node.credentials;
127 RED.nodes.eachConfig(function (confNode) {
128 if (confNode.credentials) {
129 delete confNode.credentials;
132 // Once deployed, cannot undo back to a clean state
133 RED.history.markAllDirty();
135 }).fail(function(xhr,textStatus,err) {
136 RED.view.dirty(true);
137 if (xhr.responseText) {
138 RED.notify("<strong>Error</strong>: "+xhr.responseText,"error");
140 RED.notify("<strong>Error</strong>: no response from server","error");
142 }).always(function() {
143 $("#btn-icn-deploy").removeClass('spinner');
144 $("#btn-icn-deploy").addClass('fa-download');
149 $('#btn-deploy').click(function() { save(); });
151 $( "#node-dialog-confirm-deploy" ).dialog({
152 title: "Confirm deploy",
159 text: "Confirm deploy",
162 $( this ).dialog( "close" );
168 $( this ).dialog( "close" );
174 function loadSettings() {
175 $.get('settings', function(data) {
177 console.log("Node-RED: "+data.version);
182 function loadNodeList() {
185 "Accept":"application/json"
189 success: function(data) {
190 RED.nodes.setNodeList(data);
196 function loadNodes() {
203 success: function(data) {
204 $("body").append(data);
205 $(".palette-spinner").hide();
206 $(".palette-scroll").show();
207 $("#palette-search").show();
213 function loadFlows() {
216 "Accept":"application/json"
220 success: function(nodes) {
221 RED.nodes.import(nodes);
222 RED.view.dirty(false);
224 RED.comms.subscribe("status/#",function(topic,msg) {
225 var parts = topic.split("/");
226 var node = RED.nodes.node(parts[1]);
235 RED.comms.subscribe("node/#",function(topic,msg) {
240 if (topic == "node/added") {
242 for (i=0;i<msg.length;i++) {
245 RED.nodes.addNodeSet(m);
247 addedTypes = addedTypes.concat(m.types);
248 $.get('nodes/'+id, function(data) {
249 $("body").append(data);
253 if (addedTypes.length) {
254 typeList = "<ul><li>"+addedTypes.join("</li><li>")+"</li></ul>";
255 RED.notify("Node"+(addedTypes.length!=1 ? "s":"")+" added to palette:"+typeList,"success");
257 } else if (topic == "node/removed") {
258 for (i=0;i<msg.length;i++) {
260 info = RED.nodes.removeNodeSet(m.id);
262 typeList = "<ul><li>"+m.types.join("</li><li>")+"</li></ul>";
263 RED.notify("Node"+(m.types.length!=1 ? "s":"")+" removed from palette:"+typeList,"success");
266 } else if (topic == "node/enabled") {
268 info = RED.nodes.getNodeSet(msg.id);
270 RED.nodes.enableNodeSet(msg.id);
271 typeList = "<ul><li>"+msg.types.join("</li><li>")+"</li></ul>";
272 RED.notify("Node"+(msg.types.length!=1 ? "s":"")+" enabled:"+typeList,"success");
274 $.get('nodes/'+msg.id, function(data) {
275 $("body").append(data);
276 typeList = "<ul><li>"+msg.types.join("</li><li>")+"</li></ul>";
277 RED.notify("Node"+(msg.types.length!=1 ? "s":"")+" added to palette:"+typeList,"success");
281 } else if (topic == "node/disabled") {
283 RED.nodes.disableNodeSet(msg.id);
284 typeList = "<ul><li>"+msg.types.join("</li><li>")+"</li></ul>";
285 RED.notify("Node"+(msg.types.length!=1 ? "s":"")+" disabled:"+typeList,"success");
293 var statusEnabled = false;
294 function toggleStatus(state) {
295 statusEnabled = state;
296 RED.view.status(statusEnabled);
299 function performLoopDetection(state) {
300 loopDetectionEnabled = state;
301 console.log("loopDetectionEnabled:" + loopDetectionEnabled);
304 var dgNumberEnabled = false;
305 function toggleDgNumberDisplay(state) {
306 dgNumberEnabled = state;
307 RED.view.showNumbers(dgNumberEnabled);
310 var nodePaletteDisplay = false;
311 function toggleNodePaletteDisplay(state) {
312 nodePaletteDisplay = state;
313 RED.view.showNodePalette(nodePaletteDisplay);
315 function displayAllDGs(state) {
316 //defined showSLa() in dgstart.html
321 function showHelp() {
323 var dialog = $('#node-help');
325 //$("#node-help").draggable({
326 // handle: ".modal-header"
329 dialog.on('show',function() {
330 RED.keyboard.disable();
332 dialog.on('hidden',function() {
333 RED.keyboard.enable();
340 //Custom Functions Added here
341 function showCodeCloudFlows(){
342 codeCloudFlowFiles=[];
343 var divStyle="<style>#codecloud-data-container a { color: #067ab4; font-size: 0.75em;} #codecloud-data-container a:hover { text-decoration: underline; padding: -15px -15px -15px 15px; } .header { height: 40px; border-bottom: 1px solid #EEE; background-color: #ffffff; height: 40px; -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -moz-border-radius-topleft: 5px; -moz-border-radius-topright: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; } .footer { height: 40px; background-color: whiteSmoke; border-top: 1px solid #DDD; -webkit-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; -moz-border-radius-bottomleft: 5px; -moz-border-radius-bottomright: 5px; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; }</style>";
344 $.get( "/getCodeCloudFlows")
345 .done(function( data ) {
347 var header="<div class='header'>List of DG Flows in Code Cloud</div><div><input id='flowFilterBoxId' type='text' onkeyup='filterFlows(this.value)'></div>";
348 var html= divStyle + header + "<div id='codecloud-data-container'>";
351 var files=data.files;
352 codeCloudFlowFiles=files;
353 //console.dir(files);
354 files.sort(function (a,b){
363 for(var i=0;files != null && i<files.length;i++){
364 html+="<li><a href=\"#\" onclick=\"getCommits('" + files[i] + "')\">" + files[i] + "</a></li>";
369 $( "#codecloud-browser-dialog" ).dialog({
370 title: "Code Cloud DG Flow Browser",
379 $( this ).dialog( "close" );
383 close: function(ev,ui){
384 $(this).dialog("destroy");
387 $("#codecloud-browser-dialog").show();
389 .fail(function(err) {
390 RED.notify("Failed to get users.");
396 function listYangFiles(){
398 var divStyle="<style>#list-yang-data-container a { color: #067ab4; font-size: 0.75em;} #list-yang-data-container a:hover { text-decoration: underline; padding: -15px -15px -15px 15px; } .header { height: 40px; border-bottom: 1px solid #EEE; background-color: #ffffff; height: 40px; -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -moz-border-radius-topleft: 5px; -moz-border-radius-topright: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; } .footer { height: 40px; background-color: whiteSmoke; border-top: 1px solid #DDD; -webkit-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; -moz-border-radius-bottomleft: 5px; -moz-border-radius-bottomright: 5px; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; }</style>";
399 $.get( "/getYangFiles")
400 .done(function( data ) {
402 var header="<div class='header'>List of Yang Files </div><div><input id='flowFilterBoxId' type='text' onkeyup='filterYangFiles(this.value)'></div>";
403 var html= divStyle + header + "<div id='list-yang-data-container'>";
406 var files=data.files;
408 //console.dir(files);
409 files.sort(function (a,b){
418 for(var i=0;files != null && i<files.length;i++){
419 html+="<li><a href=\"#\" onclick=\"getYangFile('" + files[i] + "')\">" + files[i] + "</a></li>";
424 $( "#list-yang-browser-dialog" ).dialog({
425 title: "List Yang Files",
434 $( this ).dialog( "close" );
438 close: function(ev,ui){
439 $(this).dialog("destroy");
442 $("#list-yang-browser-dialog").show();
444 .fail(function(err) {
445 RED.notify("Failed to get yang files.");
452 function listYangFiles(){
455 var divStyle="<style>#yang-files-data-container a { color: #067ab4; font-size: 0.75em;} #yang-files-data-container a:hover { text-decoration: underline; padding: -15px -15px -15px 15px; } .header { height: 40px; border-bottom: 1px solid #EEE; background-color: #ffffff; height: 40px; -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -moz-border-radius-topleft: 5px; -moz-border-radius-topright: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; } .footer { height: 40px; background-color: whiteSmoke; border-top: 1px solid #DDD; -webkit-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; -moz-border-radius-bottomleft: 5px; -moz-border-radius-bottomright: 5px; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; } table#yang-file-list-table { width:100%; } table#yang-file-list-table th,table#yang-file-list-table td { border: 1px solid black; border-collapse: collapse; } table#yang-file-list-table th,table#yang-file-list-table td { padding: 5px; text-align: left; } table#yang-file-list-table tr:nth-child(even) { background-color: #eee; } table#yang-file-list-table tr:nth-child(odd) { background-color:#fff; } table#yang-file-list-table th { background-color: #65a9d7; color: white; } table#yang-file-list-table a { color: #337ab7; } table#yang-file-list-table a:link { color: #65a9d7; } table#yang-file-list-table a:visited { color: #636; } table#yang-file-list-table a:hover { color: #3366CC; cursor: pointer } table#yang-file-list-table a:active { color: #65a9d7 }</style>";
456 $.get( "/getYangFiles")
457 .done(function( data ) {
459 var header="<div class='header'>List of Yang Files </div><div><input id='flowFilterBoxId' type='text' onkeyup='filterYangFiles(this.value)'></div>";
460 var html= divStyle + header + "<div id='yang-files-data-container'>";
461 html+="<table id='yang-file-list-table' border=1>";
463 html+="<th>File</th>";
464 html+="<th>Delete</th>";
467 var files=data.files;
469 //console.dir(files);
470 files.sort(function (a,b){
479 for(var i=0;files != null && i<files.length;i++){
480 html+="<tr><td><a href=\"#\" onclick=\"getYangFile('" + files[i] + "')\">" + files[i] + "</a></td><td>" + "<input type='button' onclick='deleteYangFile(\"" + files[i] + "\")' value='Delete'></td></td></td></tr>";
485 $( "#list-yang-browser-dialog" ).dialog({
486 title: "List Yang Files",
495 $( this ).dialog( "close" );
499 close: function(ev,ui){
500 $(this).dialog("destroy");
503 $("#list-yang-browser-dialog").show();
505 .fail(function(err) {
506 RED.notify("Failed to get yang files.");
513 function showGitPullDialog(){
514 $.get( "/getCurrentGitBranch")
515 .done(function( data ) {
517 if(data.output == "GIT_LOCAL_REPOSITORY_NOT_SET" ){
518 RED.notify("Git Local Repository path is not set. Please set it by choosing Configuration from the menu.");
522 var html= "<div id='gitcheckout-container'>";
525 html+="<td>Branch</td>";
526 html+="<td>" + data.output + "</td>";
529 html+="<td><input id='gitPullBtnId' type='button' value='Pull' onclick='performGitPull()'></td>";
530 html+="<td> </td>"
533 //html+="<td colspan=3><textarea readonly='1' rows='5' cols='200' id='responseId'></textarea></td>";
536 html+="<br><div id='responseId'></div>";
538 $( "#gitcommands-dialog" ).dialog({
548 $( this ).dialog( "close" );
552 close: function(ev,ui){
553 $(this).dialog("destroy");
556 $("#responseId").css({width:'550',height:'275px', border: '2px solid lightgrey',overflow:'scroll', padding: '20px' });
557 $("#responseId").hide();
558 $("#gitcommands-dialog").show();
561 .fail(function(err) {
562 RED.notify("Failed to get gitBranch.");
568 function showGitStatusDialog(){
569 $.get( "/getCurrentGitBranch")
570 .done(function( data ) {
572 if(data.output == "GIT_LOCAL_REPOSITORY_NOT_SET" ){
573 RED.notify("Git Local Repository path is not set. Please set it by choosing Configuration from the menu.");
577 var html= "<div id='gitcheckout-container'>";
580 html+="<td>Branch</td>";
581 html+="<td>" + data.output + "</td>";
584 html+="<td><input id='gitStatusBtnId' type='button' value='Status' onclick='performGitStatus()'></td>";
585 html+="<td> </td>"
588 //html+="<td colspan=3><textarea readonly='1' rows='5' cols='200' id='responseId'></textarea></td>";
591 html+="<br><div id='responseId'></div>";
593 $( "#gitcommands-dialog" ).dialog({
603 $( this ).dialog( "close" );
607 close: function(ev,ui){
608 $(this).dialog("destroy");
611 //$("#responseId").css({width:'600px',height:'100px','border-radius' : '25px', border: '2px solid lightgrey', padding: '20px' });
612 $("#responseId").css({width:'550px',height:'100px', border: '2px solid lightgrey',overflow:'scroll', padding: '20px' });
613 $("#responseId").hide();
614 $("#gitcommands-dialog").show();
617 .fail(function(err) {
618 RED.notify("Failed to get gitBranch.");
624 function showGitCheckoutDialog(){
625 $.get( "/getCurrentGitBranch")
626 .done(function( data ) {
628 if(data.output == "GIT_LOCAL_REPOSITORY_NOT_SET" ){
629 RED.notify("Git Local Repository path is not set. Please set it by choosing Configuration from the menu.");
633 var html= "<div id='gitcheckout-container'>";
636 html+="<td>Branch</td>";
637 html+="<td><input id='branchId' type='text' value='" + data.output + "'></td>";
640 html+="<td><input id='checkoutBtnId' type='button' value='Checkout' onclick='performGitCheckout()'></td>";
641 html+="<td> </td>"
644 //html+="<td colspan=3><textarea readonly='1' rows='5' cols='200' id='responseId'></textarea></td>";
647 html+="<br><div id='responseId'></div>";
649 $( "#gitcommands-dialog" ).dialog({
650 title: "Git Checkout",
659 $( this ).dialog( "close" );
663 close: function(ev,ui){
664 $(this).dialog("destroy");
667 $("#responseId").css({width:'300',height:'100px', border: '2px solid lightgrey',overflow:'scroll', padding: '20px' });
668 $("#responseId").hide();
669 $("#gitcommands-dialog").show();
672 .fail(function(err) {
673 RED.notify("Failed to get gitBranch.");
679 function showGitLocalFlows(){
681 var divStyle="<style>#gitlocal-data-container a { color: #067ab4; font-size: 0.75em;} #gitlocal-data-container a:hover { text-decoration: underline; padding: -15px -15px -15px 15px; } .header { height: 40px; border-bottom: 1px solid #EEE; background-color: #ffffff; height: 40px; -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -moz-border-radius-topleft: 5px; -moz-border-radius-topright: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; } .footer { height: 40px; background-color: whiteSmoke; border-top: 1px solid #DDD; -webkit-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; -moz-border-radius-bottomleft: 5px; -moz-border-radius-bottomright: 5px; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; }</style>";
682 $.get( "/getGitLocalFlows")
683 .done(function( data ) {
684 if(data != null && data.files != null && data.files.length == 1){
685 if(data.files[0] == "GIT_LOCAL_REPOSITORY_NOT_SET" ){
686 RED.notify("Git Local Repository path is not set. Please set it by choosing Configuration from the menu.");
690 //console.log("got response from server.");
692 var header="<div class='header'>List of DG Flows from Git Local Repository </div><div><input id='flowFilterBoxId' type='text' onkeyup='filterGitLocalFlows(this.value)'></div>";
693 var html= divStyle + header + "<div id='gitlocal-data-container'>";
696 var files=data.files;
697 gitLocalFlowFiles=files;
698 //console.dir(files);
699 files.sort(function (a,b){
708 for(var i=0;files != null && i<files.length;i++){
709 html+="<li><a href=\"#\" onclick=\"importGitLocalFlow('" + files[i] + "')\">" + files[i] + "</a></li>";
714 $( "#gitlocal-browser-dialog" ).dialog({
715 title: "Git Local Repository DG Flow Browser",
724 $(this).dialog("close");
729 $("#gitlocal-browser-dialog").show();
731 if ($("#gitlocal-browser-dialog").dialog( "isOpen" )===true) {
732 console.log("gitlocal dialog box is open");
735 console.log("gitlocal dialog box is not open");
736 // $( "#gitlocal-browser-dialog" ).dialog("destroy").remove();
737 console.log($("#gitlocal-browser-dialog").dialog( "widget" ));
738 $("#gitlocal-browser-dialog").dialog( "open" );
739 if ($("#gitlocal-browser-dialog").dialog( "isOpen" )===true) {
740 console.log("gitlocal dialog box is now open");
742 $("#gitlocal-browser-dialog").show();
747 .fail(function(err) {
748 RED.notify("Failed to get flows.");
751 console.log("Done displaying");
755 function showFlowShareUsers(){
756 var divStyle="<style>#data-container a { color: #067ab4; font-size: 0.75em;} #data-container a:hover { text-decoration: underline; padding: -15px -15px -15px 15px; } .header { height: 40px; border-bottom: 1px solid #EEE; background-color: #ffffff; height: 40px; -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -moz-border-radius-topleft: 5px; -moz-border-radius-topright: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; } .footer { height: 40px; background-color: whiteSmoke; border-top: 1px solid #DDD; -webkit-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; -moz-border-radius-bottomleft: 5px; -moz-border-radius-bottomright: 5px; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; }</style>";
757 $.get("/flowShareUsers")
758 .done(function (data){
760 var header="<div class='header'>List of Downloaded DG Flows</div>";
761 var html= divStyle + header + "<div id='data-container'>";
764 var users=data.flowShareUsers;
765 users.sort(function (a,b){
768 }else if(a.name < b.name){
774 for(var i=0;users != null && i<users.length;i++){
775 html+="<li><a href=\"#\" onclick=\"showFlowFiles('" + users[i].rootDir + "')\">" + users[i].name + "</a></li>";
780 $( "#dgflow-browser-dialog" ).dialog({
781 title: "Downloaded DG Flows Browser",
790 $( this ).dialog( "close" );
791 //$(this).dialog('destroy').remove();
796 $("#dgflow-browser-dialog").show();
798 if ($("#dgflow-browser-dialog").dialog( "isOpen" )===true) {
799 console.log("dgflow dialog box is open");
802 console.log("dgflow dialog box is not open");
803 $("#dgflow-browser-dialog").dialog( "open" );
804 $("#dgflow-browser-dialog").show();
809 .fail(function(err) {
810 RED.notify("Failed to get users.");
816 /* function showFlowShareUsers(){
817 var divStyle="<style>#data-container a { color: #067ab4; font-size: 0.75em;} #data-container a:hover { text-decoration: underline; padding: -15px -15px -15px 15px; } .header { height: 40px; border-bottom: 1px solid #EEE; background-color: #ffffff; height: 40px; -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -moz-border-radius-topleft: 5px; -moz-border-radius-topright: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; } .footer { height: 40px; background-color: whiteSmoke; border-top: 1px solid #DDD; -webkit-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; -moz-border-radius-bottomleft: 5px; -moz-border-radius-bottomright: 5px; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; }</style>";
818 $.get( "/flowShareUsers")
819 .done(function( data ) {
821 var header="<div class='header'>List of Downloaded DG Flows</div>";
822 var html= divStyle + header + "<div id='data-container'>";
825 var users=data.flowShareUsers;
826 users.sort(function (a,b){
829 }else if(a.name < b.name){
835 for(var i=0;users != null && i<users.length;i++){
836 html+="<li><a href=\"#\" onclick=\"showFlowFiles('" + users[i].rootDir + "')\">" + users[i].name + "</a></li>";
841 $( "#dgflow-browser-dialog" ).dialog({
842 title: "Downloaded DG Flows Browser",
851 //$( this ).dialog( "close" );
852 $(this).dialog('destroy').remove();
857 //$("#dgflow-browser-dialog").show();
858 $( "#dgflow-browser-dialog" ).dialog( "open" );
860 .fail(function(err) {
861 RED.notify("Failed to get users.");
869 function detectLoopInFlow(){
871 var activeWorkspace=RED.view.getWorkspace();
874 RED.nodes.eachNode(function(n) {
875 if (n.z == activeWorkspace) {
880 var nodeSet = RED.nodes.createExportableNodeSet(nSet);
882 var isLoopDetected = false;
883 var dgStartNode = getDgStartNode(nodeSet);
884 if(dgStartNode == null || dgStartNode == undefined) {
885 console.log("dgstart node not linked.");
889 var wires = dgStartNode.wires;
890 var nodesInPath = {};
891 var dgStartNodeId = dgStartNode.id;
892 if(wires != null && wires != undefined && wires[0] != undefined){
893 for(var k=0;k<wires[0].length;k++){
894 var val = wires[0][k];
895 nodesInPath[dgStartNodeId + "->" + val] = "";
898 nodesInPath[dgStartNodeId + "->" + ""] = "";
901 var loopDetectedObj = {};
902 /* the nodes will not be in order so will need to loop thru again */
903 for(var m=0;nodeSet != null && m<nodeSet.length;m++){
904 for(var i=0;nodeSet != null && i<nodeSet.length;i++){
905 var link=nodeSet[i].id;
906 //console.log("NAME:" + nodeSet[i].name + ":" + link);
907 if(link == dgStartNodeId) continue;
908 var wires = nodeSet[i].wires;
909 //console.log("link:" + link);
911 if(wires != null && wires != undefined && wires[0] != undefined){
912 for(var k=0;k<wires[0].length;k++){
913 var val = (wires[0])[k];
914 var keys = Object.keys(nodesInPath);
915 //console.log("keys:" + keys);
916 for (var j=0;j<keys.length;j++){
917 //console.log("key:" + keys[j]);
918 //console.log("val:" + val);
919 var index = keys[j].indexOf("->" + link);
920 var lastIndex = keys[j].lastIndexOf("->");
921 if(index != -1 && index == lastIndex){
922 //delete nodesInPath[key];
923 var previousNodeId = keys[j].substr(lastIndex +2);
924 var indexOfArrow = -1;
925 if(previousNodeId != ""){
926 indexOfArrow = previousNodeId.indexOf("->");
928 if(previousNodeId != null && indexOfArrow != -1){
929 previousNodeId = previousNodeId.substr(0,indexOfArrow);
931 nodesInPath[keys[j] + "->" + val] = "";
932 //console.log("keys[j]:" + keys[j]);
933 delKeys.push(keys[j]);
934 var prevNodeIdIndex = keys[j].indexOf("->" + previousNodeId);
935 var priorOccurence = keys[j].indexOf(val + "->");
936 if(priorOccurence != -1 && priorOccurence<prevNodeIdIndex){
937 //console.log("previousNodeId:" + previousNodeId);
938 //console.log("val:" + val);
939 var n1 = getNode(nodeSet,previousNodeId);
940 var n2 = getNode(nodeSet,val);
941 //console.log("loop detected for node " + n1.name + " and " + n2.name);
942 loopDetectedObj[n1.name + "->" + n2.name] ="looped";
943 console.dir(loopDetectedObj);
944 errList.push("Loop detected between " + n1.name + " and " + n2.name);
945 isLoopDetected = true;
951 for(var l=0;delKeys != null && l<delKeys.length;l++){
952 delete nodesInPath[delKeys[l]];
959 if(loopDetectedObj != null ){
961 for(var key in loopDetectedObj){
962 if(loopDetectedObj.hasOwnProperty(key)) {
963 console.log("Loop detected " + key);
964 msg += "<strong>Loop detected for:" + key + "</strong><br>";
968 isLoopDetected = true;
973 //images/page-loading.gif
977 function showLoopDetectionBox(){
979 var htmlStr="<div id='loop-box-div' style='width:375;height:225'><p>Loop detection in Progress ...</p><img src='images/page-loading.gif'></div>"
980 $("#loop-detection-dialog").dialog({
983 title: "DG Flow Loop Detection",
989 if($("#loop-detection-dialog").dialog("isOpen") == true){
990 var errList = detectLoopInFlow();
993 $("#loop-detection-dialog").dialog("close");
996 for(var i=0;errList != null && i<errList.length;i++){
997 msgHtml += "<p>" + errList[i] + "</p>";
1000 $("loop-box-div").html("<p>SUCCESS. No Loop detected.</p>");
1002 $("loop-box-div").html(msgHtml);
1009 function showSelectedTabs(){
1011 var beforeTabsOrder=[];
1012 $(".red-ui-tabs li a").each(function(i){
1013 var id=$(this).attr("href").replace('#','');
1014 var title=$(this).attr("title");
1015 var isVisible = $(this).parent().is(":visible");
1016 if(title != 'info'){
1017 tabSheets.push({"id" : id ,"title":title,"module":"NOT_SET","version" : "NOT_SET","rpc":"NOT_SET","isVisible":isVisible});
1018 beforeTabsOrder.push(id);
1022 RED.nodes.eachNode(function(n) {
1023 if(n.type == 'service-logic'){
1025 var module = n.module;
1026 tabSheets.forEach(function(tab){
1029 tab.version=n.version;
1032 }else if(n.type == 'method'){
1034 tabSheets.forEach(function(tab){
1036 var rpc=getAttributeValue(n.xml,"rpc");
1042 //console.dir(tabSheets);
1043 var htmlStr = getHtmlStr(tabSheets);
1044 $("#filter-tabs-dialog").dialog({
1046 title: "DG Builder Tabs",
1052 /* This code allows for the drag-drop of the rows in the table */
1053 var fixHelperModified = function(e, tr) {
1054 var $originals = tr.children();
1055 var $helper = tr.clone();
1056 $helper.children().each(function(index) {
1057 $(this).width($originals.eq(index).width())
1061 updateIndex = function(e, ui) {
1062 var afterTabsOrder=[];
1063 $('td.index', ui.item.parent()).each(function (i) {
1064 $(this).html(i + 1);
1066 //RE-ARRANGE the tabs
1067 var ul = $("#workspace-tabs");
1068 $("#ftab02 tr td:nth-child(1)").each(function(i){
1069 var idStr = $(this).prop("id").replace("tab-td_","");
1070 afterTabsOrder.push(idStr);
1071 link = ul.find("a[href='#"+ idStr+"']");
1074 firstTab = $("#workspace-tabs li:first-child");
1075 lastTab = $("#workspace-tabs li:last-child");
1076 li.insertAfter(lastTab);
1077 //console.log( idStr);
1079 var beforeTabsStr = beforeTabsOrder.join(",");
1080 var afterTabsStr = afterTabsOrder.join(",");
1081 //console.log("beforeTabsStr:" +beforeTabsStr);
1082 //console.log("afterTabsStr:" +afterTabsStr);
1083 if(beforeTabsStr !== afterTabsStr){
1084 //activate only when order has changed
1085 //activate the deploy button
1086 RED.view.dirty(true);
1087 $("#btn-deploy").removeClass("disabled");
1091 $("#ftab02 tbody").sortable({
1092 helper: fixHelperModified,
1094 }).disableSelection();
1098 function getHtmlStr(rows){
1099 var styleStr = "<style> " +
1100 "table#ftab02 { width:100%; } \n" +
1101 "table#ftab02 th,table#ftab02 td { border: 1px solid black; border-collapse: collapse; } \n" +
1102 /*"table, th, td { border: 1px solid #65a9d7; border-collapse: collapse; } \n" +*/
1103 "table#ftab02 th,table#ftab02 td { padding: 5px; text-align: left; } \n" +
1104 "table#ftab02 tr:nth-child(even) { background-color: #eee; }\n" +
1105 "table#ftab02 tr:nth-child(odd) { background-color:#fff; }\n" +
1106 "table#ftab02 th { background-color: #65a9d7; color: white; }\n" +
1107 "table#ftab02 a { color: #337ab7; }\n" +
1108 "table#ftab02 a:link { color: #65a9d7; }\n" +
1109 "table#ftab02 a:visited { color: #636; }\n" +
1110 "table#ftab02 a:hover { color: #3366CC; cursor: pointer }\n" +
1111 "table#ftab02 a:active { color: #65a9d7 }\n" +
1113 if(rows != null && rows != undefined){
1114 //var alertDialog = '<div id="confdialog"></div>';
1115 //htmlStr= alertDialog + "<div style='width:1050;height:650'>" + styleStr;
1116 var alertDialog = '<div id="tabAlertDialog"></div>';
1117 htmlStr= alertDialog + "<div id='tabs-div' style='width:1050;height:650'>" + styleStr;
1118 htmlStr += "<table id='ftab02' >";
1120 htmlStr += "<th class='index'>No.</th>" ;
1121 htmlStr += "<th>Tab Title</th>" ;
1122 htmlStr += "<th>Module</th>" ;
1123 htmlStr += "<th>RPC</th>" ;
1124 htmlStr += "<th>Version</th>" ;
1125 htmlStr += "<th>Rename</th>" ;
1126 htmlStr += "<th>Delete</th>" ;
1128 htmlStr += "<tbody>";
1129 if(rows != null && rows.length == 0){
1131 htmlStr += "<td><b>No rows found</b></td>";
1132 htmlStr += "</tr></table></div>";
1135 for(var i=0;i<rows.length;i++){
1137 var title = row.title;
1138 var _module = row.module;
1139 var version = row.version;
1142 var isVisible = row.isVisible;
1143 htmlStr += "<tr id='tab-tr_" + idVal + "'>";
1144 //htmlStr += "<td id=" + "'tab-td_" + idVal + "' ><a href='javascript:activateClickedTab(\"" + idVal + "\")'>" + (i+1) + "</a></td>";
1145 htmlStr += "<td class='index' id=" + "'tab-td_" + idVal + "' >" + (i+1) + "</td>";
1146 htmlStr += "<td><a href='javascript:activateClickedTab(\"" + idVal + "\")'>" + title + "</a></td>";
1147 htmlStr += "<td>" + _module + "</td>";
1148 htmlStr += "<td>" + rpc + "</td>";
1149 htmlStr += "<td>" + version + "</td>";
1150 //htmlStr += "<td><a href='javascript:deleteOrRenameTab(\"" + idVal + "\")'>Delete/Rename</a></td>";
1151 htmlStr += "<td><input type='button' onclick='renameSelectedTab(\"" + idVal + "\",\"" + title + "\",\"" + _module + "\",\"" + rpc + "\",\"" + version + "\")' value='Rename'></td>";
1152 if(rows.length == 1){
1153 htmlStr += "<td><input type='button' disabled='1' onclick='deleteSelectedTab(\"" + idVal + "\",\"" + title + "\",\"" + _module + "\",\"" + rpc + "\",\"" + version + "\")' value='Delete'></td>";
1155 htmlStr += "<td><input type='button' onclick='deleteSelectedTab(\"" + idVal + "\",\"" + title + "\",\"" + _module + "\",\"" + rpc + "\",\"" + version + "\")' value='Delete'></td>";
1159 htmlStr += "<td><input type='checkbox' onclick=\"showOrHideTab(this,'" + idVal + "')\" checked='true'></td>";
1161 htmlStr += "<td><input type='checkbox' onclick=\"showOrHideTab(this,'" + idVal + "')\"></td>";
1166 htmlStr += "</tbody>";
1167 htmlStr += "</table>";
1168 htmlStr += "</div>";
1173 Added this logic because , when the configuration item is choosen in the menu the other dialog boxes were not poping up
1176 //var msecs1= Date.now();
1177 $( "#gitlocal-browser-dialog" ).dialog();
1178 $( "#gitlocal-browser-dialog" ).dialog("close");
1179 $( "#dgflow-browser-dialog" ).dialog();
1180 $( "#dgflow-browser-dialog" ).dialog("close");
1181 $( "#update-password-dialog" ).dialog();
1182 $( "#update-password-dialog" ).dialog("close");
1183 $( "#codecloud-browser-dialog" ).dialog();
1184 $( "#codecloud-browser-dialog" ).dialog("close");
1185 $( "#update-configuration-dialog" ).dialog();
1186 $( "#update-configuration-dialog" ).dialog("close");
1187 $( "#gitcommands-dialog" ).dialog();
1188 $( "#gitcommands-dialog" ).dialog("close");
1189 $("#filter-tabs-dialog").dialog();
1190 $("#filter-tabs-dialog").dialog("close");
1191 $("#loop-detection-dialog").dialog();
1192 $("#loop-detection-dialog").dialog("close");
1193 $("#dgstart-generate-xml-dialog").dialog();
1194 $("#dgstart-generate-xml-dialog").dialog("close");
1195 $("#xmldialog").dialog();
1196 $("#xmldialog").dialog("close");
1197 $("#upload-xml-status-dialog").dialog();
1198 $("#upload-xml-status-dialog").dialog("close");
1199 $("#flow-design-err-dialog").dialog();
1200 $("#flow-design-err-dialog").dialog("close");
1201 $("#sli-values-dialog").dialog();
1202 $("#sli-values-dialog").dialog("close");
1203 $("#comments-dialog").dialog();
1204 $("#comments-dialog").dialog("close");
1205 $("#show-errors-dialog").dialog();
1206 $("#show-errors-dialog").dialog("close");
1207 $("#dgnumber-find-dialog").dialog();
1208 $("#dgnumber-find-dialog").dialog("close");
1209 $("#search-text-dialog").dialog();
1210 $("#search-text-dialog").dialog("close");
1211 $("#yang-upload-dialog").dialog();
1212 $("#yang-upload-dialog").dialog("close");
1213 $("#yang-modules-browser-dialog").dialog();
1214 $("#yang-modules-browser-dialog").dialog("close");
1215 $("#list-yang-browser-dialog").dialog();
1216 $("#list-yang-browser-dialog").dialog("close");
1217 $("#request-input-dialog").dialog();
1218 $("#request-input-dialog").dialog("close");
1219 //var msecs2= Date.now();
1220 //console.log("Time taken for dialog boxes:" + (msecs2 - msecs1));
1223 function updateConfiguration(){
1224 //console.log("in updateConfiguration");
1225 $.get("/getCurrentSettings",function (data){
1226 var dbHost = data.dbHost;
1227 var dbPort = data.dbPort;
1228 var dbName = data.dbName;
1229 var dbUser = data.dbUser;
1230 var dbPassword = data.dbPassword;
1231 var gitLocalRepository = data.gitLocalRepository;
1232 var performGitPull = data.performGitPull;
1234 if(dbHost == undefined) dbHost="";
1235 if(dbPort == undefined) dbPort="";
1236 if(dbName == undefined) dbName="";
1237 if(dbUser == undefined) dbUser="";
1238 if(dbPassword == undefined) dbPassword="";
1239 if(gitLocalRepository == undefined) gitLocalRepository="";
1240 if(performGitPull == undefined || performGitPull == null) performGitPull="N";
1242 var divStyle="border: 1px solid #a1a1a1; padding: 10px 40px; background: #dddddd; width: 500px; border-radius: 25px;";
1243 //var divStyle="border: 2px solid #a1a1a1; padding: 10px 40px; background: #99CCFF; width: 400px; border-radius: 25px;";
1247 html += "<script>function changeType(obj,targetId){if( obj.checked== true){$('#' + targetId).prop('type','password');}else{$('#'+ targetId).prop('type','text');}} function changeTitle(){ document.getElementById(\"gitLocalRepository\").title=document.getElementById(\"gitLocalRepository\").value;}</script>";
1248 html += "<div style='" + divStyle + "' >";
1249 html += "<table border='0' cellpadding='5' >";
1251 html += "<td style='font-size:12px;align:center'><b>DB Host IP</b></td>";
1252 html += "<td><input style='align:center;font-size:11px;font-weight:bold' id='dbhost' name='dbhost' type='text' value='" + dbHost + "'></td>";
1255 html += "<td style='font-size:12px;align:center'><b>DB Port</b></td>";
1256 html += "<td><input style='align:center;font-size:11px;font-weight:bold' id='dbport' name='dbport' type='text' value='" + dbPort + "'></td>";
1259 html += "<td style='font-size:12px;align:center'><b>DB Name</b></td>";
1260 html += "<td><input style='align:center;font-size:11px;font-weight:bold' id='dbname' name='dbname' type='text' value='" + dbName + "'></td>";
1263 html += "<td style='font-size:12px;align:center'><b>DB UserName</b></td>";
1264 html += "<td><input style='align:center;font-size:11px;font-weight:bold' id='dbuser' name='dbuser' type='password' value='" + dbUser + "'></td>";
1265 html += "<td><input style='background:background:white;width:20px;height:20px' type='checkbox' checked value='1' onclick=\"changeType(this,'dbuser')\">Hide</td>";
1268 html += "<td style='font-size:12px;align:center'><b>DB Password</b></td>";
1269 html += "<td><input style='align:center;font-size:11px;font-weight:bold' id='dbpassword' name='dbpassword' type='password' value='" + dbPassword + "'></td>";
1270 html += "<td><input style='background:background:white;width:20px;height:20px' type='checkbox' checked value='1' onclick=\"changeType(this,'dbpassword')\">Hide</td>";
1274 html += "<div style='fill:both;clear:both'></div><br>";
1276 html += "<div style='" + divStyle + "' >";
1277 html += "<table border='0' cellpadding='5' >";
1279 html += "<td style='font-size:12px;align:center'><b>Git Local Repository Path</b></td>";
1280 html += "<td><textarea style='align:center;font-size:14px;' cols='50' rows='4' id='gitLocalRepository' name='gitLocalRepository' onkeyup='changeTitle()' title='" + gitLocalRepository + "'>" + gitLocalRepository + "</textarea></td>";
1283 html += "<table border='0' cellpadding='5' >";
1285 if(performGitPull == "N"){
1286 html += "<td style='align:center;'><input style='color:blue;width:20px;height:20px;' id='performGitPull' type='checkbox' value='Y'>Perform Git Pull in Local Git Repository prior to import</td>";
1288 html += "<td style='align:center;'><input style='color:blue;width:20px;height:20px;' id='performGitPull' type='checkbox' value='Y' checked>Perform Git Pull in Local Git Repository prior to import</td>";
1294 //console.log("html:" + html);
1295 $( "#update-configuration-dialog" ).dialog({
1296 title: "Configuration",
1305 var newDBHost = $("#dbhost").val().trim();
1306 var newDBPort = $("#dbport").val().trim();
1307 var newDBName = $("#dbname").val().trim();
1308 var newDBUser = $("#dbuser").val().trim();
1309 var newDBPassword = $("#dbpassword").val().trim();
1310 var newGitLocalRepository = $("#gitLocalRepository").val().trim();
1311 var isPerformGitPullChecked = $('#performGitPull').is(':checked');
1312 var newPerformGitPull = "N";
1313 if(isPerformGitPullChecked){
1314 newPerformGitPull = "Y";
1316 if(newDBHost == ""){
1317 RED.notify("Error: DB Host is required.");
1318 $("#dbhost").focus();
1320 }else if(newDBPort == ""){
1321 RED.notify("Error: DB Port is required.");
1322 $("#dbport").focus();
1324 }else if(newDBName == ""){
1325 RED.notify("Error: DB Name is required.");
1326 $("#dbname").focus();
1328 }else if(newDBUser == ""){
1329 RED.notify("Error: DB User is required.");
1330 $("#dbuser").focus();
1332 }else if(newDBPassword == ""){
1333 RED.notify("Error: DB Password is required.");
1334 $("#dbpassword").focus();
1337 console.log("newGitLocalRepository:" + newGitLocalRepository);
1338 var reqData= {"dbHost":newDBHost,
1339 "dbPort" : newDBPort,
1340 "dbName" : newDBName,
1341 "dbUser" : newDBUser,
1342 "dbPassword" : newDBPassword,
1343 "gitLocalRepository" : newGitLocalRepository,
1344 "performGitPull" : newPerformGitPull
1346 $.post( "/updateConfiguration",reqData )
1347 .done(function( data ) {
1348 RED.notify("Configuration updated successfully");
1350 //RED.comms.connect();
1351 //$( "#update-configuration-dialog" ).dialog('close');
1352 $("#update-configuration-dialog").dialog("close");
1353 //location.reload();
1356 .fail(function(err) {
1357 console.log( "error" + err );
1358 RED.notify("Failed to update the Configuration.");
1360 .always(function() {
1368 $( this ).dialog( "close" );
1373 //$("#update-configuration-dialog").show();
1374 $("#gitLocalRepository").css({"width" : 300});
1379 function updatePassword(){
1381 html += "<div><span><b>New Password</b></span><br>";
1382 html += "<input id='passwd1' name='passwd1' type='password' value=''>";
1384 html += "<div><span><b>Confirm Password</b></span><br>";
1385 html += "<input id='passwd2' name='passwd2' type='password' value=''>";
1387 $( "#update-password-dialog" ).dialog({
1388 title: "Update Password",
1395 text: "Update Password",
1397 var passwd1 = $("#passwd1").val().trim();
1398 var passwd2 = $("#passwd2").val().trim();
1399 if((passwd1 != passwd2) || (passwd1 == "" || passwd2 == "")){
1400 RED.notify("Error:Passwords entered must be same and must be populated.");
1403 var reqData= {"password":passwd1};
1404 $.post( "/updatePassword",reqData )
1405 .done(function( data ) {
1406 RED.notify("Password updated successfully");
1408 $( "#update-password-dialog" ).dialog('close');
1410 .fail(function(err) {
1411 console.log( "error" + err );
1412 RED.notify("Failed to update the password.");
1414 .always(function() {
1422 $( this ).dialog( "close" );
1427 $("#update-password-dialog").show();
1431 function showAvailableYangModules(){
1432 availableYangModules=[];
1433 var divStyle="<style>#yang-modules-data-container a { color: #067ab4; font-size: 0.75em;} #yang-modules-data-container a:hover { text-decoration: underline; padding: -15px -15px -15px 15px; } .header { height: 40px; border-bottom: 1px solid #EEE; background-color: #ffffff; height: 40px; -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -moz-border-radius-topleft: 5px; -moz-border-radius-topright: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; } .footer { height: 40px; background-color: whiteSmoke; border-top: 1px solid #DDD; -webkit-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; -moz-border-radius-bottomleft: 5px; -moz-border-radius-bottomright: 5px; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; } table#yang-list-table { width:100%; } table#yang-list-table th,table#yang-list-table td { border: 1px solid black; border-collapse: collapse; } table#yang-list-table th,table#yang-list-table td { padding: 5px; text-align: left; } table#yang-list-table tr:nth-child(even) { background-color: #eee; } table#yang-list-table tr:nth-child(odd) { background-color:#fff; } table#yang-list-table th { background-color: #65a9d7; color: white; } table#yang-list-table a { color: #337ab7; } table#yang-list-table a:link { color: #65a9d7; } table#yang-list-table a:visited { color: #636; } table#yang-list-table a:hover { color: #3366CC; cursor: pointer } table#yang-list-table a:active { color: #65a9d7 }</style>";
1434 $.get( "/listAvailableModules")
1435 .done(function( data ) {
1436 var header="<div class='header'>List of Available Yang Modules</div>";
1437 header += "<div><p><i>Check the modules that you want to load and click on the Load button.</i></p></div>";
1438 //header += "<div><input id='yangModuleFilterBoxId' type='text' onkeyup='filterYangModules(this.value)'></div>";
1439 var html= divStyle + header + "<div id='yang-modules-data-container'>";
1440 html+="<table id='yang-list-table' border=1>";
1443 html+="<th>Load</th>";
1444 html+="<th>Module</th>";
1447 var files=data.files;
1448 availableYangModules=files;
1449 //console.dir(files);
1450 files.sort(function (a,b){
1460 for(var i=0;files != null && i<files.length;i++){
1461 var val = files[i].replace(/:.*/,"");
1462 if(files[i].indexOf(":checked") != -1){
1463 html+="<tr><td>" + count + "</td><td><input type='checkbox' checked value='" + val + "'></td><td>" + val + "</td></tr>";
1465 html+="<tr><td>" + count + "</td><td><input type='checkbox' value='" + val + "'></td><td>" + val + "</td></tr>";
1472 $( "#yang-modules-browser-dialog" ).dialog({
1473 title: "Available Yang Modules",
1483 function getValuesForSelected() {
1484 $('#yang-modules-data-container :checked').each(function() {
1485 allVals.push($(this).val());
1489 var selectedModules = getValuesForSelected().toString();
1490 console.log(selectedModules);
1493 /*contentType: "application/x-www-form-urlencoded",*/
1494 url: '/loadSelectedModules?selectedModules=' + selectedModules,
1495 success: function(data) {
1496 RED.notify("Modules Loaded successfully");
1497 //emptying existing g;obal variables
1500 reqInputValues = {};
1502 if(data != undefined && data != null){
1503 for(var i=0;i<data.sliValuesObj.length;i++){
1504 var moduleName = data.sliValuesObj[i].moduleName;
1505 sliValuesObj[moduleName] = data.sliValuesObj[i][moduleName + '_PROPS'];
1506 rpcValues[moduleName] = data.sliValuesObj[i][ moduleName +'_RPCS'];
1507 for(var k=0;rpcValues[moduleName] != undefined && k<rpcValues[moduleName].length;k++){
1508 var rpcName = rpcValues[moduleName][k];
1509 reqInputValues[moduleName + "_" + rpcName] = data.sliValuesObj[i][rpcName +"-input"];
1510 //console.dir(reqInputValues);
1514 $( "#yang-modules-browser-dialog" ).dialog('close');
1515 console.log('success');
1516 //console.log(JSON.stringify(data));
1518 error: function(error) {
1519 RED.notify("Failed to load modules.");
1520 console.log("some error in fetching the notifications");
1528 $(this).dialog("close");
1533 $("#yang-modules-browser-dialog").show();
1535 .fail(function(err) {
1536 RED.notify("Failed to get yang modules.");
1538 .always(function() {
1539 console.log("Done displaying");
1545 RED.menu.init({id:"btn-sidemenu",
1547 {id:"btn-sidebar",icon:"fa fa-columns",label:"Sidebar (Ctrl+Space)",toggle:true,onselect:RED.sidebar.toggleSidebar},
1549 {id:"btn-manage-yang-modules-menu",icon:"fa fa-sign-in",label:"Manage Yang Modules",options:[
1550 {id:"btn-yang-upload",icon:"fa fa-clipboard",label:"Upload Yang File",onselect:RED.view.showYangUploadDialog},
1551 {id:"btn-available-yang-modules",icon:"fa fa-clipboard",label:"Available Yang Modules",onselect:showAvailableYangModules},
1552 {id:"btn-list-yang-files",icon:"fa fa-clipboard",label:"List Yang Files",onselect:listYangFiles},
1555 {id:"btn-configure-upload",icon:"fa fa-book",label:"Configuration",toggle:false,onselect:updateConfiguration},
1557 {id:"btn-manage-tabs",icon:"fa fa-info",label:"Manage Tabs",toggle:false,onselect:showSelectedTabs},
1559 {id:"btn-search-text",icon:"fa fa-info",label:"Search Text (Ctrl+[)",toggle:false,onselect:RED.view.showSearchTextDialog},
1561 {id:"btn-find-dgnumber",icon:"fa fa-info",label:"Find Node (Ctrl+B)",toggle:false,onselect:RED.view.showDgNumberDialog},
1563 {id:"btn-request-input",icon:"fa fa-info",label:"RPC Input (Ctrl+O)",toggle:false,onselect:RED.view.showRequestTemplateDialog},
1565 {id:"btn-node-status",icon:"fa fa-info",label:"Node Status",toggle:true,onselect:toggleStatus},
1567 {id:"btn-node-dgnumber",icon:"fa fa-info",label:"Show Node Numbers",toggle:true,onselect:toggleDgNumberDisplay},
1569 {id:"btn-node-panel",icon:"fa fa-columns",label:"Node Palette (Ctrl+M)",toggle:true,onselect:toggleNodePaletteDisplay},
1571 {id:"btn-node-viewdgs",icon:"fa fa-info",label:"View All DG List",toggle:false,onselect:displayAllDGs},
1574 {id:"btn-node-gitmenu",icon:"fa fa-info",label:"Git Commands",options: [
1575 {id:"btn-node-gitcheckout",icon:"fa fa-info",label:"Git Checkout",onselect:showGitCheckoutDialog},
1576 {id:"btn-node-gitpull",icon:"fa fa-info",label:"Git Pull",onselect:showGitPullDialog},
1577 {id:"btn-node-gitstatus",icon:"fa fa-info",label:"Git Status",onselect:showGitStatusDialog}
1581 {id:"btn-import-menu",icon:"fa fa-sign-in",label:"Import...",options:[
1582 /*{id:"btn-import-codecloud",icon:"fa fa-clipboard",label:"Code Cloud",onselect:showCodeCloudFlows},
1584 {id:"btn-import-codecloud",icon:"fa fa-clipboard",label:"Git Local Repository",onselect:showGitLocalFlows},
1585 {id:"btn-import-userflows",icon:"fa fa-clipboard",label:"Downloaded DG Flows...",onselect:showFlowShareUsers},
1586 {id:"btn-import-clipboard",icon:"fa fa-clipboard",label:"Clipboard...",onselect:RED.view.showImportNodesDialog},
1587 {id:"btn-import-library",icon:"fa fa-book",label:"Library",options:[]}
1589 {id:"btn-export-menu",icon:"fa fa-sign-out",label:"Export...",disabled:true,options:[
1590 {id:"btn-export-clipboard",icon:"fa fa-clipboard",label:"Clipboard...",disabled:true,onselect:RED.view.showExportNodesDialog},
1591 {id:"btn-export-library",icon:"fa fa-book",label:"Library...",disabled:true,onselect:RED.view.showExportNodesLibraryDialog}
1594 {id:"btn-change-password",icon:"fa fa-columns",label:"Change Password",toggle:false,onselect:updatePassword},
1596 /*{id:"btn-config-nodes",icon:"fa fa-th-list",label:"Configuration nodes...",onselect:RED.sidebar.config.show},
1598 {id:"btn-workspace-menu",icon:"fa fa-th-large",label:"Workspaces",options:[
1599 {id:"btn-workspace-add",icon:"fa fa-plus",label:"Add"},
1600 {id:"btn-workspace-edit",icon:"fa fa-pencil",label:"Rename"},
1601 {id:"btn-workspace-delete",icon:"fa fa-minus",label:"Delete"},
1605 {id:"btn-keyboard-shortcuts",icon:"fa fa-keyboard-o",label:"Keyboard Shortcuts",onselect:showHelp}
1606 /*{id:"btn-help",icon:"fa fa-question",label:"Help...", href:"http://nodered.org/docs"}*/
1610 //Making default loop detection on and display check mark in the menu
1611 //$("#btn-loop-detection").addClass("active");
1613 RED.keyboard.add(/* ? */ 191,{shift:true},function(){showHelp();d3.event.preventDefault();});
1615 RED.comms.connect();