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.
17 var RED = (function() {
19 function hideDropTarget() {
20 $("#dropTarget").hide();
21 RED.keyboard.remove(/* ESCAPE */ 27);
24 $('#chart').on("dragenter",function(event) {
25 if ($.inArray("text/plain",event.originalEvent.dataTransfer.types) != -1) {
26 $("#dropTarget").css({display:'table'});
27 RED.keyboard.add(/* ESCAPE */ 27,hideDropTarget);
31 $('#dropTarget').on("dragover",function(event) {
32 if ($.inArray("text/plain",event.originalEvent.dataTransfer.types) != -1) {
33 event.preventDefault();
36 .on("dragleave",function(event) {
39 .on("drop",function(event) {
40 var data = event.originalEvent.dataTransfer.getData("text/plain");
42 RED.view.importNodes(data);
43 event.preventDefault();
47 function save(force) {
48 if (RED.view.dirty()) {
49 //$("#debug-tab-clear").click(); // uncomment this to auto clear debug on deploy
53 var unknownNodes = [];
54 RED.nodes.eachNode(function(node) {
55 invalid = invalid || !node.valid;
56 if (node.type === "unknown") {
57 if (unknownNodes.indexOf(node.name) == -1) {
58 unknownNodes.push(node.name);
64 if (unknownNodes.length > 0) {
65 $( "#node-dialog-confirm-deploy-config" ).hide();
66 $( "#node-dialog-confirm-deploy-unknown" ).show();
67 var list = "<li>"+unknownNodes.join("</li><li>")+"</li>";
68 $( "#node-dialog-confirm-deploy-unknown-list" ).html(list);
70 $( "#node-dialog-confirm-deploy-config" ).show();
71 $( "#node-dialog-confirm-deploy-unknown" ).hide();
73 $( "#node-dialog-confirm-deploy" ).dialog( "open" );
77 var nns = RED.nodes.createCompleteNodeSet();
78 /****************************************/
79 /*added new code to save the Tabs order */
80 /****************************************/
81 //console.log("nns before changes.");
85 var nnsTabIdsArr = [];
86 var guiTabIdsArr = [];
87 nns.forEach(function(n) {
91 nnsTabIdsArr.push(n.id);
95 $("#workspace-tabs li a").each(function(){
96 var href = $(this).prop("href");
97 var indexOfHash = href.indexOf("#");
98 var idVal = href.slice(indexOfHash+1);
99 guiTabIdsArr.push(idVal);
100 nns.splice(idx,1,allTabsObj[idVal]);;
103 //console.log(nnsTabIdsArr.join(","));
104 //console.log(guiTabIdsArr.join(","));
105 //console.log("nns after changes.");
107 /****************************/
108 $("#btn-icn-deploy").removeClass('fa-download');
109 $("#btn-icn-deploy").addClass('spinner');
110 RED.view.dirty(false);
115 data: JSON.stringify(nns),
116 contentType: "application/json; charset=utf-8"
117 }).done(function(data,textStatus,xhr) {
118 RED.notify("Successfully saved","success");
119 RED.nodes.eachNode(function(node) {
122 node.changed = false;
124 if(node.credentials) {
125 delete node.credentials;
128 RED.nodes.eachConfig(function (confNode) {
129 if (confNode.credentials) {
130 delete confNode.credentials;
133 // Once deployed, cannot undo back to a clean state
134 RED.history.markAllDirty();
136 }).fail(function(xhr,textStatus,err) {
137 RED.view.dirty(true);
138 if (xhr.responseText) {
139 RED.notify("<strong>Error</strong>: "+xhr.responseText,"error");
141 RED.notify("<strong>Error</strong>: no response from server","error");
143 }).always(function() {
144 $("#btn-icn-deploy").removeClass('spinner');
145 $("#btn-icn-deploy").addClass('fa-download');
150 $('#btn-deploy').click(function() { save(); });
152 $( "#node-dialog-confirm-deploy" ).dialog({
153 title: "Confirm deploy",
160 text: "Confirm deploy",
163 $( this ).dialog( "close" );
169 $( this ).dialog( "close" );
175 function loadSettings() {
176 $.get('settings', function(data) {
178 console.log("Node-RED: "+data.version);
183 function loadNodeList() {
186 "Accept":"application/json"
190 success: function(data) {
191 RED.nodes.setNodeList(data);
197 function loadNodes() {
204 success: function(data) {
205 $("body").append(data);
206 $(".palette-spinner").hide();
207 $(".palette-scroll").show();
208 $("#palette-search").show();
214 function loadFlows() {
217 "Accept":"application/json"
221 success: function(nodes) {
222 RED.nodes.import(nodes);
223 RED.view.dirty(false);
225 RED.comms.subscribe("status/#",function(topic,msg) {
226 var parts = topic.split("/");
227 var node = RED.nodes.node(parts[1]);
236 RED.comms.subscribe("node/#",function(topic,msg) {
241 if (topic == "node/added") {
243 for (i=0;i<msg.length;i++) {
246 RED.nodes.addNodeSet(m);
248 addedTypes = addedTypes.concat(m.types);
249 $.get('nodes/'+id, function(data) {
250 $("body").append(data);
254 if (addedTypes.length) {
255 typeList = "<ul><li>"+addedTypes.join("</li><li>")+"</li></ul>";
256 RED.notify("Node"+(addedTypes.length!=1 ? "s":"")+" added to palette:"+typeList,"success");
258 } else if (topic == "node/removed") {
259 for (i=0;i<msg.length;i++) {
261 info = RED.nodes.removeNodeSet(m.id);
263 typeList = "<ul><li>"+m.types.join("</li><li>")+"</li></ul>";
264 RED.notify("Node"+(m.types.length!=1 ? "s":"")+" removed from palette:"+typeList,"success");
267 } else if (topic == "node/enabled") {
269 info = RED.nodes.getNodeSet(msg.id);
271 RED.nodes.enableNodeSet(msg.id);
272 typeList = "<ul><li>"+msg.types.join("</li><li>")+"</li></ul>";
273 RED.notify("Node"+(msg.types.length!=1 ? "s":"")+" enabled:"+typeList,"success");
275 $.get('nodes/'+msg.id, function(data) {
276 $("body").append(data);
277 typeList = "<ul><li>"+msg.types.join("</li><li>")+"</li></ul>";
278 RED.notify("Node"+(msg.types.length!=1 ? "s":"")+" added to palette:"+typeList,"success");
282 } else if (topic == "node/disabled") {
284 RED.nodes.disableNodeSet(msg.id);
285 typeList = "<ul><li>"+msg.types.join("</li><li>")+"</li></ul>";
286 RED.notify("Node"+(msg.types.length!=1 ? "s":"")+" disabled:"+typeList,"success");
294 var statusEnabled = false;
295 function toggleStatus(state) {
296 statusEnabled = state;
297 RED.view.status(statusEnabled);
300 function performLoopDetection(state) {
301 loopDetectionEnabled = state;
302 console.log("loopDetectionEnabled:" + loopDetectionEnabled);
305 var dgNumberEnabled = false;
306 function toggleDgNumberDisplay(state) {
307 dgNumberEnabled = state;
308 RED.view.showNumbers(dgNumberEnabled);
311 var nodePaletteDisplay = false;
312 function toggleNodePaletteDisplay(state) {
313 nodePaletteDisplay = state;
314 RED.view.showNodePalette(nodePaletteDisplay);
316 function displayAllDGs(state) {
317 //defined showSLa() in dgstart.html
322 function showHelp() {
324 var dialog = $('#node-help');
326 //$("#node-help").draggable({
327 // handle: ".modal-header"
330 dialog.on('show',function() {
331 RED.keyboard.disable();
333 dialog.on('hidden',function() {
334 RED.keyboard.enable();
341 //Custom Functions Added here
342 function showCodeCloudFlows(){
343 codeCloudFlowFiles=[];
344 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>";
345 $.get( "/getCodeCloudFlows")
346 .done(function( data ) {
348 var header="<div class='header'>List of DG Flows in Code Cloud</div><div><input id='flowFilterBoxId' type='text' onkeyup='filterFlows(this.value)'></div>";
349 var html= divStyle + header + "<div id='codecloud-data-container'>";
352 var files=data.files;
353 codeCloudFlowFiles=files;
354 //console.dir(files);
355 files.sort(function (a,b){
364 for(var i=0;files != null && i<files.length;i++){
365 html+="<li><a href=\"#\" onclick=\"getCommits('" + files[i] + "')\">" + files[i] + "</a></li>";
370 $( "#codecloud-browser-dialog" ).dialog({
371 title: "Code Cloud DG Flow Browser",
380 $( this ).dialog( "close" );
384 close: function(ev,ui){
385 $(this).dialog("destroy");
388 $("#codecloud-browser-dialog").show();
390 .fail(function(err) {
391 RED.notify("Failed to get users.");
398 function listYangFiles(){
400 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>";
401 $.get( "/getYangFiles")
402 .done(function( data ) {
404 var header="<div class='header'>List of Yang Files </div><div><input id='flowFilterBoxId' type='text' onkeyup='filterYangFiles(this.value)'></div>";
405 var html= divStyle + header + "<div id='list-yang-data-container'>";
408 var files=data.files;
410 //console.dir(files);
411 files.sort(function (a,b){
420 for(var i=0;files != null && i<files.length;i++){
421 html+="<li><a href=\"#\" onclick=\"getYangFile('" + files[i] + "')\">" + files[i] + "</a></li>";
426 $( "#list-yang-browser-dialog" ).dialog({
427 title: "List Yang Files",
436 $( this ).dialog( "close" );
440 close: function(ev,ui){
441 $(this).dialog("destroy");
444 $("#list-yang-browser-dialog").show();
446 .fail(function(err) {
447 RED.notify("Failed to get yang files.");
454 function listYangFiles(){
457 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>";
458 $.get( "/getYangFiles")
459 .done(function( data ) {
461 var header="<div class='header'>List of Yang Files </div><div><input id='flowFilterBoxId' type='text' onkeyup='filterYangFiles(this.value)'></div>";
462 var html= divStyle + header + "<div id='yang-files-data-container'>";
463 html+="<table id='yang-file-list-table' border=1>";
465 html+="<th>File</th>";
466 html+="<th>Delete</th>";
469 var files=data.files;
471 //console.dir(files);
472 files.sort(function (a,b){
481 for(var i=0;files != null && i<files.length;i++){
482 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>";
487 $( "#list-yang-browser-dialog" ).dialog({
488 title: "List Yang Files",
497 $( this ).dialog( "close" );
501 close: function(ev,ui){
502 $(this).dialog("destroy");
505 $("#list-yang-browser-dialog").show();
507 .fail(function(err) {
508 RED.notify("Failed to get yang files.");
515 function showGitPullDialog(){
516 $.get( "/getCurrentGitBranch")
517 .done(function( data ) {
519 if(data.output == "GIT_LOCAL_REPOSITORY_NOT_SET" ){
520 RED.notify("Git Local Repository path is not set. Please set it by choosing Configuration from the menu.");
524 var html= "<div id='gitcheckout-container'>";
527 html+="<td>Branch</td>";
528 html+="<td>" + data.output + "</td>";
531 html+="<td><input id='gitPullBtnId' type='button' value='Pull' onclick='performGitPull()'></td>";
532 html+="<td> </td>"
535 //html+="<td colspan=3><textarea readonly='1' rows='5' cols='200' id='responseId'></textarea></td>";
538 html+="<br><div id='responseId'></div>";
540 $( "#gitcommands-dialog" ).dialog({
550 $( this ).dialog( "close" );
554 close: function(ev,ui){
555 $(this).dialog("destroy");
558 $("#responseId").css({width:'550',height:'275px', border: '2px solid lightgrey',overflow:'scroll', padding: '20px' });
559 $("#responseId").hide();
560 $("#gitcommands-dialog").show();
563 .fail(function(err) {
564 RED.notify("Failed to get gitBranch.");
570 function showGitStatusDialog(){
571 $.get( "/getCurrentGitBranch")
572 .done(function( data ) {
574 if(data.output == "GIT_LOCAL_REPOSITORY_NOT_SET" ){
575 RED.notify("Git Local Repository path is not set. Please set it by choosing Configuration from the menu.");
579 var html= "<div id='gitcheckout-container'>";
582 html+="<td>Branch</td>";
583 html+="<td>" + data.output + "</td>";
586 html+="<td><input id='gitStatusBtnId' type='button' value='Status' onclick='performGitStatus()'></td>";
587 html+="<td> </td>"
590 //html+="<td colspan=3><textarea readonly='1' rows='5' cols='200' id='responseId'></textarea></td>";
593 html+="<br><div id='responseId'></div>";
595 $( "#gitcommands-dialog" ).dialog({
605 $( this ).dialog( "close" );
609 close: function(ev,ui){
610 $(this).dialog("destroy");
613 //$("#responseId").css({width:'600px',height:'100px','border-radius' : '25px', border: '2px solid lightgrey', padding: '20px' });
614 $("#responseId").css({width:'550px',height:'100px', border: '2px solid lightgrey',overflow:'scroll', padding: '20px' });
615 $("#responseId").hide();
616 $("#gitcommands-dialog").show();
619 .fail(function(err) {
620 RED.notify("Failed to get gitBranch.");
626 function showGitCheckoutDialog(){
627 $.get( "/getCurrentGitBranch")
628 .done(function( data ) {
630 if(data.output == "GIT_LOCAL_REPOSITORY_NOT_SET" ){
631 RED.notify("Git Local Repository path is not set. Please set it by choosing Configuration from the menu.");
635 var html= "<div id='gitcheckout-container'>";
638 html+="<td>Branch</td>";
639 html+="<td><input id='branchId' type='text' value='" + data.output + "'></td>";
642 html+="<td><input id='checkoutBtnId' type='button' value='Checkout' onclick='performGitCheckout()'></td>";
643 html+="<td> </td>"
646 //html+="<td colspan=3><textarea readonly='1' rows='5' cols='200' id='responseId'></textarea></td>";
649 html+="<br><div id='responseId'></div>";
651 $( "#gitcommands-dialog" ).dialog({
652 title: "Git Checkout",
661 $( this ).dialog( "close" );
665 close: function(ev,ui){
666 $(this).dialog("destroy");
669 $("#responseId").css({width:'300',height:'100px', border: '2px solid lightgrey',overflow:'scroll', padding: '20px' });
670 $("#responseId").hide();
671 $("#gitcommands-dialog").show();
674 .fail(function(err) {
675 RED.notify("Failed to get gitBranch.");
681 function showGitLocalFlows(){
683 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>";
684 $.get( "/getGitLocalFlows")
685 .done(function( data ) {
686 if(data != null && data.files != null && data.files.length == 1){
687 if(data.files[0] == "GIT_LOCAL_REPOSITORY_NOT_SET" ){
688 RED.notify("Git Local Repository path is not set. Please set it by choosing Configuration from the menu.");
692 //console.log("got response from server.");
694 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>";
695 var html= divStyle + header + "<div id='gitlocal-data-container'>";
698 var files=data.files;
699 gitLocalFlowFiles=files;
700 //console.dir(files);
701 files.sort(function (a,b){
710 for(var i=0;files != null && i<files.length;i++){
711 html+="<li><a href=\"#\" onclick=\"importGitLocalFlow('" + files[i] + "')\">" + files[i] + "</a></li>";
716 $( "#gitlocal-browser-dialog" ).dialog({
717 title: "Git Local Repository DG Flow Browser",
726 $(this).dialog("close");
731 $("#gitlocal-browser-dialog").show();
733 if ($("#gitlocal-browser-dialog").dialog( "isOpen" )===true) {
734 console.log("gitlocal dialog box is open");
737 console.log("gitlocal dialog box is not open");
738 // $( "#gitlocal-browser-dialog" ).dialog("destroy").remove();
739 console.log($("#gitlocal-browser-dialog").dialog( "widget" ));
740 $("#gitlocal-browser-dialog").dialog( "open" );
741 if ($("#gitlocal-browser-dialog").dialog( "isOpen" )===true) {
742 console.log("gitlocal dialog box is now open");
744 $("#gitlocal-browser-dialog").show();
749 .fail(function(err) {
750 RED.notify("Failed to get flows.");
753 console.log("Done displaying");
757 function showFlowShareUsers(){
758 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>";
759 $.get("/flowShareUsers")
760 .done(function (data){
762 var header="<div class='header'>List of Downloaded DG Flows</div>";
763 var html= divStyle + header + "<div id='data-container'>";
766 var users=data.flowShareUsers;
767 users.sort(function (a,b){
770 }else if(a.name < b.name){
776 for(var i=0;users != null && i<users.length;i++){
777 html+="<li><a href=\"#\" onclick=\"showFlowFiles('" + users[i].rootDir + "')\">" + users[i].name + "</a></li>";
782 $( "#dgflow-browser-dialog" ).dialog({
783 title: "Downloaded DG Flows Browser",
792 $( this ).dialog( "close" );
793 //$(this).dialog('destroy').remove();
798 $("#dgflow-browser-dialog").show();
800 if ($("#dgflow-browser-dialog").dialog( "isOpen" )===true) {
801 console.log("dgflow dialog box is open");
804 console.log("dgflow dialog box is not open");
805 $("#dgflow-browser-dialog").dialog( "open" );
806 $("#dgflow-browser-dialog").show();
811 .fail(function(err) {
812 RED.notify("Failed to get users.");
818 /* function showFlowShareUsers(){
819 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>";
820 $.get( "/flowShareUsers")
821 .done(function( data ) {
823 var header="<div class='header'>List of Downloaded DG Flows</div>";
824 var html= divStyle + header + "<div id='data-container'>";
827 var users=data.flowShareUsers;
828 users.sort(function (a,b){
831 }else if(a.name < b.name){
837 for(var i=0;users != null && i<users.length;i++){
838 html+="<li><a href=\"#\" onclick=\"showFlowFiles('" + users[i].rootDir + "')\">" + users[i].name + "</a></li>";
843 $( "#dgflow-browser-dialog" ).dialog({
844 title: "Downloaded DG Flows Browser",
853 //$( this ).dialog( "close" );
854 $(this).dialog('destroy').remove();
859 //$("#dgflow-browser-dialog").show();
860 $( "#dgflow-browser-dialog" ).dialog( "open" );
862 .fail(function(err) {
863 RED.notify("Failed to get users.");
871 function detectLoopInFlow(){
873 var activeWorkspace=RED.view.getWorkspace();
876 RED.nodes.eachNode(function(n) {
877 if (n.z == activeWorkspace) {
882 var nodeSet = RED.nodes.createExportableNodeSet(nSet);
884 var isLoopDetected = false;
885 var dgStartNode = getDgStartNode(nodeSet);
886 if(dgStartNode == null || dgStartNode == undefined) {
887 console.log("dgstart node not linked.");
891 var wires = dgStartNode.wires;
892 var nodesInPath = {};
893 var dgStartNodeId = dgStartNode.id;
894 if(wires != null && wires != undefined && wires[0] != undefined){
895 for(var k=0;k<wires[0].length;k++){
896 var val = wires[0][k];
897 nodesInPath[dgStartNodeId + "->" + val] = "";
900 nodesInPath[dgStartNodeId + "->" + ""] = "";
903 var loopDetectedObj = {};
904 /* the nodes will not be in order so will need to loop thru again */
905 for(var m=0;nodeSet != null && m<nodeSet.length;m++){
906 for(var i=0;nodeSet != null && i<nodeSet.length;i++){
907 var link=nodeSet[i].id;
908 //console.log("NAME:" + nodeSet[i].name + ":" + link);
909 if(link == dgStartNodeId) continue;
910 var wires = nodeSet[i].wires;
911 //console.log("link:" + link);
913 if(wires != null && wires != undefined && wires[0] != undefined){
914 for(var k=0;k<wires[0].length;k++){
915 var val = (wires[0])[k];
916 var keys = Object.keys(nodesInPath);
917 //console.log("keys:" + keys);
918 for (var j=0;j<keys.length;j++){
919 //console.log("key:" + keys[j]);
920 //console.log("val:" + val);
921 var index = keys[j].indexOf("->" + link);
922 var lastIndex = keys[j].lastIndexOf("->");
923 if(index != -1 && index == lastIndex){
924 //delete nodesInPath[key];
925 var previousNodeId = keys[j].substr(lastIndex +2);
926 var indexOfArrow = -1;
927 if(previousNodeId != ""){
928 indexOfArrow = previousNodeId.indexOf("->");
930 if(previousNodeId != null && indexOfArrow != -1){
931 previousNodeId = previousNodeId.substr(0,indexOfArrow);
933 nodesInPath[keys[j] + "->" + val] = "";
934 //console.log("keys[j]:" + keys[j]);
935 delKeys.push(keys[j]);
936 var prevNodeIdIndex = keys[j].indexOf("->" + previousNodeId);
937 var priorOccurence = keys[j].indexOf(val + "->");
938 if(priorOccurence != -1 && priorOccurence<prevNodeIdIndex){
939 //console.log("previousNodeId:" + previousNodeId);
940 //console.log("val:" + val);
941 var n1 = getNode(nodeSet,previousNodeId);
942 var n2 = getNode(nodeSet,val);
943 //console.log("loop detected for node " + n1.name + " and " + n2.name);
944 loopDetectedObj[n1.name + "->" + n2.name] ="looped";
945 console.dir(loopDetectedObj);
946 errList.push("Loop detected between " + n1.name + " and " + n2.name);
947 isLoopDetected = true;
953 for(var l=0;delKeys != null && l<delKeys.length;l++){
954 delete nodesInPath[delKeys[l]];
961 if(loopDetectedObj != null ){
963 for(var key in loopDetectedObj){
964 if(loopDetectedObj.hasOwnProperty(key)) {
965 console.log("Loop detected " + key);
966 msg += "<strong>Loop detected for:" + key + "</strong><br>";
970 isLoopDetected = true;
975 //images/page-loading.gif
979 function showLoopDetectionBox(){
981 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>"
982 $("#loop-detection-dialog").dialog({
985 title: "DG Flow Loop Detection",
991 if($("#loop-detection-dialog").dialog("isOpen") == true){
992 var errList = detectLoopInFlow();
995 $("#loop-detection-dialog").dialog("close");
998 for(var i=0;errList != null && i<errList.length;i++){
999 msgHtml += "<p>" + errList[i] + "</p>";
1002 $("loop-box-div").html("<p>SUCCESS. No Loop detected.</p>");
1004 $("loop-box-div").html(msgHtml);
1011 function showSelectedTabs(){
1013 var beforeTabsOrder=[];
1014 $(".red-ui-tabs li a").each(function(i){
1015 var id=$(this).attr("href").replace('#','');
1016 var title=$(this).attr("title");
1017 var isVisible = $(this).parent().is(":visible");
1018 if(title != 'info'){
1019 tabSheets.push({"id" : id ,"title":title,"module":"NOT_SET","version" : "NOT_SET","rpc":"NOT_SET","isVisible":isVisible});
1020 beforeTabsOrder.push(id);
1024 RED.nodes.eachNode(function(n) {
1025 if(n.type == 'service-logic'){
1027 var module = n.module;
1028 tabSheets.forEach(function(tab){
1031 tab.version=n.version;
1034 }else if(n.type == 'method'){
1036 tabSheets.forEach(function(tab){
1038 var rpc=getAttributeValue(n.xml,"rpc");
1044 //console.dir(tabSheets);
1045 var htmlStr = getHtmlStr(tabSheets);
1046 $("#filter-tabs-dialog").dialog({
1048 title: "DG Builder Tabs",
1054 /* This code allows for the drag-drop of the rows in the table */
1055 var fixHelperModified = function(e, tr) {
1056 var $originals = tr.children();
1057 var $helper = tr.clone();
1058 $helper.children().each(function(index) {
1059 $(this).width($originals.eq(index).width())
1063 updateIndex = function(e, ui) {
1064 var afterTabsOrder=[];
1065 $('td.index', ui.item.parent()).each(function (i) {
1066 $(this).html(i + 1);
1068 //RE-ARRANGE the tabs
1069 var ul = $("#workspace-tabs");
1070 $("#ftab02 tr td:nth-child(1)").each(function(i){
1071 var idStr = $(this).prop("id").replace("tab-td_","");
1072 afterTabsOrder.push(idStr);
1073 link = ul.find("a[href='#"+ idStr+"']");
1076 firstTab = $("#workspace-tabs li:first-child");
1077 lastTab = $("#workspace-tabs li:last-child");
1078 li.insertAfter(lastTab);
1079 //console.log( idStr);
1081 var beforeTabsStr = beforeTabsOrder.join(",");
1082 var afterTabsStr = afterTabsOrder.join(",");
1083 //console.log("beforeTabsStr:" +beforeTabsStr);
1084 //console.log("afterTabsStr:" +afterTabsStr);
1085 if(beforeTabsStr !== afterTabsStr){
1086 //activate only when order has changed
1087 //activate the deploy button
1088 RED.view.dirty(true);
1089 $("#btn-deploy").removeClass("disabled");
1093 $("#ftab02 tbody").sortable({
1094 helper: fixHelperModified,
1096 }).disableSelection();
1100 function getHtmlStr(rows){
1101 var styleStr = "<style> " +
1102 "table#ftab02 { width:100%; } \n" +
1103 "table#ftab02 th,table#ftab02 td { border: 1px solid black; border-collapse: collapse; } \n" +
1104 /*"table, th, td { border: 1px solid #65a9d7; border-collapse: collapse; } \n" +*/
1105 "table#ftab02 th,table#ftab02 td { padding: 5px; text-align: left; } \n" +
1106 "table#ftab02 tr:nth-child(even) { background-color: #eee; }\n" +
1107 "table#ftab02 tr:nth-child(odd) { background-color:#fff; }\n" +
1108 "table#ftab02 th { background-color: #65a9d7; color: white; }\n" +
1109 "table#ftab02 a { color: #337ab7; }\n" +
1110 "table#ftab02 a:link { color: #65a9d7; }\n" +
1111 "table#ftab02 a:visited { color: #636; }\n" +
1112 "table#ftab02 a:hover { color: #3366CC; cursor: pointer }\n" +
1113 "table#ftab02 a:active { color: #65a9d7 }\n" +
1115 if(rows != null && rows != undefined){
1116 //var alertDialog = '<div id="confdialog"></div>';
1117 //htmlStr= alertDialog + "<div style='width:1050;height:650'>" + styleStr;
1118 var alertDialog = '<div id="tabAlertDialog"></div>';
1119 htmlStr= alertDialog + "<div id='tabs-div' style='width:1050;height:650'>" + styleStr;
1120 htmlStr += "<table id='ftab02' >";
1122 htmlStr += "<th class='index'>No.</th>" ;
1123 htmlStr += "<th>Tab Title</th>" ;
1124 htmlStr += "<th>Module</th>" ;
1125 htmlStr += "<th>RPC</th>" ;
1126 htmlStr += "<th>Version</th>" ;
1127 htmlStr += "<th>Rename</th>" ;
1128 htmlStr += "<th>Delete</th>" ;
1130 htmlStr += "<tbody>";
1131 if(rows != null && rows.length == 0){
1133 htmlStr += "<td><b>No rows found</b></td>";
1134 htmlStr += "</tr></table></div>";
1137 for(var i=0;i<rows.length;i++){
1139 var title = row.title;
1140 var _module = row.module;
1141 var version = row.version;
1144 var isVisible = row.isVisible;
1145 htmlStr += "<tr id='tab-tr_" + idVal + "'>";
1146 //htmlStr += "<td id=" + "'tab-td_" + idVal + "' ><a href='javascript:activateClickedTab(\"" + idVal + "\")'>" + (i+1) + "</a></td>";
1147 htmlStr += "<td class='index' id=" + "'tab-td_" + idVal + "' >" + (i+1) + "</td>";
1148 htmlStr += "<td><a href='javascript:activateClickedTab(\"" + idVal + "\")'>" + title + "</a></td>";
1149 htmlStr += "<td>" + _module + "</td>";
1150 htmlStr += "<td>" + rpc + "</td>";
1151 htmlStr += "<td>" + version + "</td>";
1152 //htmlStr += "<td><a href='javascript:deleteOrRenameTab(\"" + idVal + "\")'>Delete/Rename</a></td>";
1153 htmlStr += "<td><input type='button' onclick='renameSelectedTab(\"" + idVal + "\",\"" + title + "\",\"" + _module + "\",\"" + rpc + "\",\"" + version + "\")' value='Rename'></td>";
1154 if(rows.length == 1){
1155 htmlStr += "<td><input type='button' disabled='1' onclick='deleteSelectedTab(\"" + idVal + "\",\"" + title + "\",\"" + _module + "\",\"" + rpc + "\",\"" + version + "\")' value='Delete'></td>";
1157 htmlStr += "<td><input type='button' onclick='deleteSelectedTab(\"" + idVal + "\",\"" + title + "\",\"" + _module + "\",\"" + rpc + "\",\"" + version + "\")' value='Delete'></td>";
1161 htmlStr += "<td><input type='checkbox' onclick=\"showOrHideTab(this,'" + idVal + "')\" checked='true'></td>";
1163 htmlStr += "<td><input type='checkbox' onclick=\"showOrHideTab(this,'" + idVal + "')\"></td>";
1168 htmlStr += "</tbody>";
1169 htmlStr += "</table>";
1170 htmlStr += "</div>";
1175 Added this logic because , when the configuration item is choosen in the menu the other dialog boxes were not poping up
1178 //var msecs1= Date.now();
1179 $( "#gitlocal-browser-dialog" ).dialog();
1180 $( "#gitlocal-browser-dialog" ).dialog("close");
1181 $( "#dgflow-browser-dialog" ).dialog();
1182 $( "#dgflow-browser-dialog" ).dialog("close");
1183 $( "#update-password-dialog" ).dialog();
1184 $( "#update-password-dialog" ).dialog("close");
1185 $( "#codecloud-browser-dialog" ).dialog();
1186 $( "#codecloud-browser-dialog" ).dialog("close");
1187 $( "#update-configuration-dialog" ).dialog();
1188 $( "#update-configuration-dialog" ).dialog("close");
1189 $( "#gitcommands-dialog" ).dialog();
1190 $( "#gitcommands-dialog" ).dialog("close");
1191 $("#filter-tabs-dialog").dialog();
1192 $("#filter-tabs-dialog").dialog("close");
1193 $("#loop-detection-dialog").dialog();
1194 $("#loop-detection-dialog").dialog("close");
1195 $("#dgstart-generate-xml-dialog").dialog();
1196 $("#dgstart-generate-xml-dialog").dialog("close");
1197 $("#xmldialog").dialog();
1198 $("#xmldialog").dialog("close");
1199 $("#upload-xml-status-dialog").dialog();
1200 $("#upload-xml-status-dialog").dialog("close");
1201 $("#flow-design-err-dialog").dialog();
1202 $("#flow-design-err-dialog").dialog("close");
1203 $("#sli-values-dialog").dialog();
1204 $("#sli-values-dialog").dialog("close");
1205 $("#comments-dialog").dialog();
1206 $("#comments-dialog").dialog("close");
1207 $("#show-errors-dialog").dialog();
1208 $("#show-errors-dialog").dialog("close");
1209 $("#dgnumber-find-dialog").dialog();
1210 $("#dgnumber-find-dialog").dialog("close");
1211 $("#search-text-dialog").dialog();
1212 $("#search-text-dialog").dialog("close");
1213 $("#yang-upload-dialog").dialog();
1214 $("#yang-upload-dialog").dialog("close");
1215 $("#yang-modules-browser-dialog").dialog();
1216 $("#yang-modules-browser-dialog").dialog("close");
1217 $("#list-yang-browser-dialog").dialog();
1218 $("#list-yang-browser-dialog").dialog("close");
1219 $("#request-input-dialog").dialog();
1220 $("#request-input-dialog").dialog("close");
1221 $("#test-dg-dialog").dialog();
1222 $("#test-dg-dialog").dialog("close");
1223 $("#ctx-values-dialog").dialog();
1224 $("#ctx-values-dialog").dialog("close");
1225 $("#list-input-browser-dialog").dialog();
1226 $("#list-input-browser-dialog").dialog("close");
1227 $("#diff-browser-dialog").dialog();
1228 $("#diff-browser-dialog").dialog("close");
1229 //var msecs2= Date.now();
1230 //console.log("Time taken for dialog boxes:" + (msecs2 - msecs1));
1234 //start functions to support Test DG
1236 getSliParametersFromDG();
1238 for (var property in callNodes) {
1239 if (callNodes.hasOwnProperty(property)) {
1240 console.log(property);
1241 var moduleRpc = property.split("_");
1242 var mName = moduleRpc[0];
1243 var rName = moduleRpc[1];
1251 function showInputFiles(files){
1252 var divStyle="<style>#input-files-data-container a { color: #067ab4; font-size: 0.75em;} #input-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#input-file-list-table { width:100%; } table#input-file-list-table th,table#input-file-list-table td { border: 1px solid black; border-collapse: collapse; } table#input-file-list-table th,table#input-file-list-table td { padding: 5px; text-align: left; } table#input-file-list-table tr:nth-child(even) { background-color: #eee; } table#input-file-list-table tr:nth-child(odd) { background-color:#fff; } table#input-file-list-table th { background-color: #65a9d7; color: white; } table#input-file-list-table a { color: #337ab7; } table#input-file-list-table a:link { color: #65a9d7; } table#input-file-list-table a:visited { color: #636; } table#input-file-list-table a:hover { color: #3366CC; cursor: pointer } table#input-file-list-table a:active { color: #65a9d7 }</style>";
1254 var header="<div class='header'>List of Input Files </div>";
1255 var html= divStyle + header + "<div id='input-files-data-container'>";
1256 html+="<table id='input-file-list-table' border=1>";
1258 html+="<th>File</th>";
1259 html+="<th>Delete</th>";
1261 files.sort(function (a,b){
1270 for(var i=0;files != null && i<files.length;i++){
1271 html+="<tr><td><a href=\"#\" onclick=\"loadInputFile('" + files[i] + "')\">" + files[i] + "</a></td><td>" + "<input type='button' onclick='deleteInputFile(\"" + files[i] + "\")' value='Delete'></td></td></td></tr>";
1275 $( "#list-input-browser-dialog" ).dialog({
1276 title: "List Input Files",
1285 $( this ).dialog( "close" );
1289 close: function(ev,ui){
1290 $(this).dialog("destroy");
1293 $("#list-input-browser-dialog").show();
1297 function showTestDGDialog(){
1298 $.get("/getCurrentSettings",function (data){
1299 var activeWorkspace=RED.view.getWorkspace();
1300 var currNodes = RED.nodes.nodes.filter(function(d) { return d.z == activeWorkspace })
1301 var moduleName = "";
1303 if(currNodes != null && currNodes.length > 1){
1304 currNodes.forEach(function(n){
1305 if(n.type == 'service-logic'){
1306 moduleName = getAttributeValue(n.xml,"module");
1307 }else if(n.type == 'method'){
1308 rpcName = getAttributeValue(n.xml,"rpc");
1313 var sliApiInputObj = { "input" : { "module-name" : moduleName, "rpc-name" : rpcName, "mode" : "sync", "sli-parameter" : []}};
1314 var intParameterObj = { "parameter-name" : "", "int-value": 0};
1315 var booleanParameterObj = { "parameter-name" : "", "boolean-value": true};
1317 //Use this logic to add all the Ctx variables that have -input.
1318 Object.keys(dgParsedParameters).forEach(function(key,index) {
1319 //console.log("key:" + key + " index" +index );
1320 if(key.indexOf("-input.") != -1){
1321 key = key.replace(/\$/g,"");
1322 var strParameterObj = { "parameter-name" : key, "string-value": ""};
1323 sliApiInputObj["input"]["sli-parameter"].push(strParameterObj);
1328 var sliApiInputStr = JSON.stringify(sliApiInputObj,null,4);
1330 //var htmlStr="<div id='request-template-div' style='width:875px;height:575px'><textarea style='width:875px;height:575px'>" + inputValStr + "</textarea></div>"
1331 //var htmlStr="<div id='request-template-div' style='width:750px;height:550px;font-weight:bold;font-size:1em'><pre>" + inputValStr + "</pre></div>"
1332 //var htmlStr = "<div id='test-dg-div' style='width:750px;height:50px'>";
1333 var htmlStr = "<label style='font-weight:bold;font-size:1em'>URL</label><input id='test-dg-url' type='textbox' style='width:743px;height:30px;font-weight:bold;font-size:1em' value='" + data.restConfUrl + "'><br><br><label style='font-weight:bold;font-size:1em'>Method</label><input type='radio' name='methodType' value='GET'> GET <input type='radio' name='methodType' value='POST' checked> POST <input type='radio' name='methodType' value='PUT' > PUT <input type='radio' name='methodType' value='DELETE' > DELETE <br><br><label style='font-weight:bold;font-size:1em'>Input</label>";
1334 htmlStr +="<textarea id='test-dg-request' style='width:750px;height:350px;font-size:1em' >" + sliApiInputStr + "</textarea><br><br><label style='font-weight:bold;font-size:1em'>Response</label><textarea id='test-dg-response' style='width:750px;height:150px;font-weight:bold;font-size:1em'></textarea>"
1335 //background: "#c3e8d1",
1336 $("#test-dg-dialog").dialog({
1337 dialogClass :"no-close",
1340 title: "Test DG Module:" + moduleName + " RPC:" + rpcName,
1347 $("#test-dg-response").val("");
1348 showCtxVariables(moduleName,rpcName);
1349 //console.dir(dgParsedParameters);
1356 "moduleName" : moduleName,
1360 $.post( "/getInputFiles",inputData )
1361 .done(function( data ) {
1362 //console.dir(data);
1363 if(data != undefined && data != null){
1364 showInputFiles(data.files);
1367 .fail(function(err) {
1368 console.log( "failed to save input. " + err );
1370 .always(function() {
1377 $("#test-dg-response").val("");
1378 var methodType =$("input[name=methodType]:checked").val();
1379 var urlValue = $("#test-dg-url").val();
1382 reqData = JSON.parse($("#test-dg-request").val());
1384 $("#test-dg-response").val(er);
1387 //console.log("urlValue:" + urlValue);
1388 //console.dir(reqData);
1389 var inputStr = $("#test-dg-request").val();
1390 //headers: { 'Authorization': 'Basic ' + btoa(data.restConfUser + ":" + data.restConfPassword)},
1392 "moduleName" : moduleName,
1393 "rpcName" : rpcName,
1394 "inputStr" : inputStr
1397 $.post( "/saveTestDGInput",inputData )
1398 .done(function( data ) {
1401 .fail(function(err) {
1402 console.log( "failed to save input. " + err );
1404 .always(function() {
1406 xhrFields: { withCredentials: true },
1409 data: JSON.stringify(reqData),
1410 contentType: "application/json; charset=utf-8",
1411 username : data.restConfUser,
1412 password : data.restConfPassword,
1413 success: function(data) {
1415 $("#test-dg-response").val(JSON.stringify(data,null,4));
1417 $("#test-dg-response").val("No Content returned");
1420 error: function(err) {
1422 $("#test-dg-response").val(JSON.stringify(err,null,4));
1424 $("#test-dg-response").val("error Occured");
1434 $("#test-dg-request").val(sliApiInputStr);
1435 $("#test-dg-response").val("");
1441 $("#test-dg-dialog").dialog("close");
1446 $('#test-dg-dialog').css('overflow', 'hidden');
1448 }).dialog("open").html(htmlStr).css("background","aliceblue");
1451 //end functions to support Test DG
1454 function updateConfiguration(){
1455 //console.log("in updateConfiguration");
1456 $.get("/getCurrentSettings",function (data){
1457 var dbHost = data.dbHost;
1458 var dbPort = data.dbPort;
1459 var dbName = data.dbName;
1460 var dbUser = data.dbUser;
1461 var dbPassword = data.dbPassword;
1462 var formatXML = data.formatXML;
1463 var formatJSON = data.formatJSON;
1464 var gitLocalRepository = data.gitLocalRepository;
1465 var performGitPull = data.performGitPull;
1467 var restConfUrl = data.restConfUrl;
1468 var restConfUser = data.restConfUser;
1469 var restConfPassword = data.restConfPassword;
1470 var emailAddress = data.emailAddress;
1472 if(dbHost == undefined) dbHost="";
1473 if(dbPort == undefined) dbPort="";
1474 if(dbName == undefined) dbName="";
1475 if(dbUser == undefined) dbUser="";
1476 if(dbPassword == undefined) dbPassword="";
1477 if(gitLocalRepository == undefined) gitLocalRepository="";
1478 if(performGitPull == undefined || performGitPull == null) performGitPull="N";
1479 if(restConfUrl == undefined) restConfUrl="";
1480 if(restConfUser == undefined) restConfUser="";
1481 if(restConfPassword == undefined) restConfPassword="";
1482 if(emailAddress == undefined) emailAddress="";
1483 if(formatXML == undefined) formatXML="Y";
1484 if(formatJSON == undefined) formatJSON="Y";
1486 var divStyle="border: 1px solid #a1a1a1; padding: 10px 40px; background: #dddddd; width: 600px; border-radius: 25px;";
1487 //var divStyle="border: 2px solid #a1a1a1; padding: 10px 40px; background: #99CCFF; width: 400px; border-radius: 25px;";
1491 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;} function changeTitle1(){ document.getElementById(\"restconfurl\").title=document.getElementById(\"restconfurl\").value;}</script>";
1492 html += "<div style='" + divStyle + "' >";
1493 html += "<table border='0' cellpadding='5' >";
1495 html += "<td style='font-size:12px;align:center'><b>DB Host IP</b></td>";
1496 html += "<td><input style='align:center;font-size:11px;font-weight:bold' id='dbhost' name='dbhost' type='text' value='" + dbHost + "'></td>";
1499 html += "<td style='font-size:12px;align:center'><b>DB Port</b></td>";
1500 html += "<td><input style='align:center;font-size:11px;font-weight:bold' id='dbport' name='dbport' type='text' value='" + dbPort + "'></td>";
1503 html += "<td style='font-size:12px;align:center'><b>DB Name</b></td>";
1504 html += "<td><input style='align:center;font-size:11px;font-weight:bold' id='dbname' name='dbname' type='text' value='" + dbName + "'></td>";
1507 html += "<td style='font-size:12px;align:center'><b>DB UserName</b></td>";
1508 html += "<td><input style='align:center;font-size:11px;font-weight:bold' id='dbuser' name='dbuser' type='password' value='" + dbUser + "'></td>";
1509 html += "<td><input style='background:background:white;width:20px;height:20px' type='checkbox' checked value='1' onclick=\"changeType(this,'dbuser')\">Hide</td>";
1512 html += "<td style='font-size:12px;align:center'><b>DB Password</b></td>";
1513 html += "<td><input style='align:center;font-size:11px;font-weight:bold' id='dbpassword' name='dbpassword' type='password' value='" + dbPassword + "'></td>";
1514 html += "<td><input style='background:background:white;width:20px;height:20px' type='checkbox' checked value='1' onclick=\"changeType(this,'dbpassword')\">Hide</td>";
1518 html += "<div style='fill:both;clear:both'></div><br>";
1519 html += "<div style='" + divStyle + "' >";
1520 html += "<table border='0' cellpadding='5' >";
1522 html += "<td style='font-size:12px;align:center'><b>RestConf URL</b></td>";
1523 html += "<td><textarea style='align:center;font-size:14px;width:100%' cols='100' rows='4' id='restconfurl' name='restconfurl' onkeyup='changeTitle1()' title='" + restConfUrl + "'>" + restConfUrl + "</textarea></td>";
1526 html += "<td style='font-size:12px;align:center'><b>RestConf UserName</b></td>";
1527 html += "<td><input style='align:center;font-size:11px;font-weight:bold' id='restconfuser' name='restconfuser' type='password' value='" + restConfUser + "'>";
1528 html += " <input style='background:background:white;width:20px;height:20px' type='checkbox' checked value='1' onclick=\"changeType(this,'restconfuser')\">Hide</td>";
1531 html += "<td style='font-size:12px;align:center'><b>RestConf Password</b></td>";
1532 html += "<td><input style='align:center;font-size:11px;font-weight:bold' id='restconfpassword' name='restconfpassword' type='password' value='" + restConfPassword + "'>";
1533 html += " <input style='background:background:white;width:20px;height:20px' type='checkbox' checked value='1' onclick=\"changeType(this,'restconfpassword')\">Hide</td>";
1537 html += "<div style='fill:both;clear:both'></div><br>";
1539 html += "<div style='" + divStyle + "' >";
1540 html += "<table border='0' cellpadding='5' width='100%' >";
1542 html += "<td style='font-size:12px;align:center'><b>Git Local Repository Path</b></td>";
1543 html += "<td><textarea style='align:center;font-size:14px;width:100%' cols='100' rows='4' id='gitLocalRepository' name='gitLocalRepository' onkeyup='changeTitle()' title='" + gitLocalRepository + "'>" + gitLocalRepository + "</textarea></td>";
1546 html += "<table border='0' cellpadding='5' >";
1548 if(performGitPull == "N"){
1549 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>";
1551 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>";
1556 html += "<div style='fill:both;clear:both'></div><br>";
1558 html += "<div style='" + divStyle + "' >";
1559 html += "<table border='0' cellpadding='5' width='100%' >";
1561 html += "<td style='font-size:12px;align:center'><b>Email</b></td>";
1562 html += "<td><input style='align:center;font-size:11px;font-weight:bold' id='emailaddress' name='emailaddress' type='text' value='" + emailAddress + "'></td>";
1565 if(formatXML == "Y"){
1566 html += "<td style='align:center;'><input style='color:blue;width:20px;height:20px;' id='formatXML' type='checkbox' value='Y' checked><b>Format XML</b></td>";
1568 html += "<td style='align:center;'><input style='color:blue;width:20px;height:20px;' id='formatXML' type='checkbox' value='Y'><b>Format XML</b></td>";
1570 if(formatJSON == "Y"){
1571 html += "<td style='align:center;'><input style='color:blue;width:20px;height:20px;' id='formatJSON' type='checkbox' value='Y' checked><b>Format JSON</b></td>";
1573 html += "<td style='align:center;'><input style='color:blue;width:20px;height:20px;' id='formatJSON' type='checkbox' value='Y'><b>Format JSON</b></td>";
1579 //console.log("html:" + html);
1580 $( "#update-configuration-dialog" ).dialog({
1581 title: "Configuration",
1590 var newDBHost = $("#dbhost").val().trim();
1591 var newDBPort = $("#dbport").val().trim();
1592 var newDBName = $("#dbname").val().trim();
1593 var newDBUser = $("#dbuser").val().trim();
1594 var newDBPassword = $("#dbpassword").val().trim();
1595 var newGitLocalRepository = $("#gitLocalRepository").val().trim();
1597 var isFormatXML = $('#formatXML').is(':checked');
1598 var isFormatJSON = $('#formatJSON').is(':checked');
1599 var isPerformGitPullChecked = $('#performGitPull').is(':checked');
1600 var newRestConfUrl = $("#restconfurl").val().trim();
1601 var newRestConfUser = $("#restconfuser").val().trim();
1602 var newRestConfPassword = $("#restconfpassword").val().trim();
1603 var newPerformGitPull = "N";
1604 var newEmailAddress = $("#emailaddress").val().trim();
1605 //console.log("newEmailAddress:" + newEmailAddress);
1606 if(isPerformGitPullChecked){
1607 newPerformGitPull = "Y";
1615 newFormatJSON = "Y";
1617 newFormatJSON = "N";
1619 if(newDBHost == ""){
1620 RED.notify("Error: DB Host is required.");
1621 $("#dbhost").focus();
1623 }else if(newDBPort == ""){
1624 RED.notify("Error: DB Port is required.");
1625 $("#dbport").focus();
1627 }else if(newDBName == ""){
1628 RED.notify("Error: DB Name is required.");
1629 $("#dbname").focus();
1631 }else if(newDBUser == ""){
1632 RED.notify("Error: DB User is required.");
1633 $("#dbuser").focus();
1635 }else if(newDBPassword == ""){
1636 RED.notify("Error: DB Password is required.");
1637 $("#dbpassword").focus();
1639 }else if(newEmailAddress == ""){
1640 RED.notify("Error: Email Address is required.");
1641 $("#emailaddress").focus();
1644 //console.log("newGitLocalRepository:" + newGitLocalRepository);
1645 var reqData= {"dbHost":newDBHost,
1646 "dbPort" : newDBPort,
1647 "dbName" : newDBName,
1648 "dbUser" : newDBUser,
1649 "dbPassword" : newDBPassword,
1650 "gitLocalRepository" : newGitLocalRepository,
1651 "performGitPull" : newPerformGitPull ,
1652 "formatXML": newFormatXML,
1653 "formatJSON": newFormatJSON,
1654 "restConfUrl" : newRestConfUrl,
1655 "restConfUser" : newRestConfUser,
1656 "restConfPassword" : newRestConfPassword,
1657 "emailAddress" : newEmailAddress
1659 $.post( "/updateConfiguration",reqData )
1660 .done(function( data ) {
1661 RED.settings.emailAddress = newEmailAddress;
1662 format_xml = newFormatXML;
1663 format_json = newFormatJSON;
1664 RED.notify("Configuration updated successfully");
1666 //RED.comms.connect();
1667 //$( "#update-configuration-dialog" ).dialog('close');
1668 $("#update-configuration-dialog").dialog("close");
1669 //location.reload();
1672 .fail(function(err) {
1673 console.log( "error" + err );
1674 RED.notify("Failed to update the Configuration.");
1676 .always(function() {
1684 $( this ).dialog( "close" );
1689 //$("#update-configuration-dialog").show();
1690 $("#gitLocalRepository").css({"width" : 300});
1695 function updatePassword(){
1697 html += "<div><span><b>New Password</b></span><br>";
1698 html += "<input id='passwd1' name='passwd1' type='password' value=''>";
1700 html += "<div><span><b>Confirm Password</b></span><br>";
1701 html += "<input id='passwd2' name='passwd2' type='password' value=''>";
1703 $( "#update-password-dialog" ).dialog({
1704 title: "Update Password",
1711 text: "Update Password",
1713 var passwd1 = $("#passwd1").val().trim();
1714 var passwd2 = $("#passwd2").val().trim();
1715 if((passwd1 != passwd2) || (passwd1 == "" || passwd2 == "")){
1716 RED.notify("Error:Passwords entered must be same and must be populated.");
1719 var reqData= {"password":passwd1};
1720 $.post( "/updatePassword",reqData )
1721 .done(function( data ) {
1722 RED.notify("Password updated successfully");
1724 $( "#update-password-dialog" ).dialog('close');
1726 .fail(function(err) {
1727 console.log( "error" + err );
1728 RED.notify("Failed to update the password.");
1730 .always(function() {
1738 $( this ).dialog( "close" );
1743 $("#update-password-dialog").show();
1747 function showAvailableYangModules(){
1748 availableYangModules=[];
1749 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>";
1750 $.get( "/listAvailableModules")
1751 .done(function( data ) {
1752 var header="<div class='header'>List of Available Yang Modules</div>";
1753 header += "<div><p><i>Check the modules that you want to load and click on the Load button.</i></p></div>";
1754 //header += "<div><input id='yangModuleFilterBoxId' type='text' onkeyup='filterYangModules(this.value)'></div>";
1755 var html= divStyle + header + "<div id='yang-modules-data-container'>";
1756 html+="<table id='yang-list-table' border=1>";
1759 html+="<th>Load</th>";
1760 html+="<th>Module</th>";
1763 var files=data.files;
1764 availableYangModules=files;
1765 //console.dir(files);
1766 files.sort(function (a,b){
1776 for(var i=0;files != null && i<files.length;i++){
1777 var val = files[i].replace(/:.*/,"");
1778 if(files[i].indexOf(":checked") != -1){
1779 html+="<tr><td>" + count + "</td><td><input type='checkbox' checked value='" + val + "'></td><td>" + val + "</td></tr>";
1781 html+="<tr><td>" + count + "</td><td><input type='checkbox' value='" + val + "'></td><td>" + val + "</td></tr>";
1788 $( "#yang-modules-browser-dialog" ).dialog({
1789 title: "Available Yang Modules",
1799 function getValuesForSelected() {
1800 $('#yang-modules-data-container :checked').each(function() {
1801 allVals.push($(this).val());
1805 var selectedModules = getValuesForSelected().toString();
1806 console.log(selectedModules);
1809 /*contentType: "application/x-www-form-urlencoded",*/
1810 url: '/loadSelectedModules?selectedModules=' + selectedModules,
1811 success: function(data) {
1812 RED.notify("Modules Loaded successfully");
1813 //emptying existing g;obal variables
1816 reqInputValues = {};
1818 if(data != undefined && data != null){
1819 for(var i=0;i<data.sliValuesObj.length;i++){
1820 var moduleName = data.sliValuesObj[i].moduleName;
1821 sliValuesObj[moduleName] = data.sliValuesObj[i][moduleName + '_PROPS'];
1822 rpcValues[moduleName] = data.sliValuesObj[i][ moduleName +'_RPCS'];
1823 for(var k=0;rpcValues[moduleName] != undefined && k<rpcValues[moduleName].length;k++){
1824 var rpcName = rpcValues[moduleName][k];
1825 reqInputValues[moduleName + "_" + rpcName] = data.sliValuesObj[i][rpcName +"-input"];
1826 //console.dir(reqInputValues);
1830 $( "#yang-modules-browser-dialog" ).dialog('close');
1831 console.log('success');
1832 //console.log(JSON.stringify(data));
1834 error: function(error) {
1835 RED.notify("Failed to load modules.");
1836 console.log("some error in fetching the notifications");
1844 $(this).dialog("close");
1849 $("#yang-modules-browser-dialog").show();
1851 .fail(function(err) {
1852 RED.notify("Failed to get yang modules.");
1854 .always(function() {
1855 console.log("Done displaying");
1861 RED.menu.init({id:"btn-sidemenu",
1863 {id:"btn-sidebar",icon:"fa fa-columns",label:"Sidebar (Ctrl+Space)",toggle:true,onselect:RED.sidebar.toggleSidebar},
1865 {id:"btn-manage-yang-modules-menu",icon:"fa fa-sign-in",label:"Manage Yang Modules",options:[
1866 {id:"btn-yang-upload",icon:"fa fa-clipboard",label:"Upload Yang File",onselect:RED.view.showYangUploadDialog},
1867 {id:"btn-available-yang-modules",icon:"fa fa-clipboard",label:"Available Yang Modules",onselect:showAvailableYangModules},
1868 {id:"btn-list-yang-files",icon:"fa fa-clipboard",label:"List Yang Files",onselect:listYangFiles},
1871 {id:"btn-dg-diff-menu",icon:"fa fa-sign-in",label:"DG diff",options:[
1872 {id:"btn-diff-json",icon:"fa fa-clipboard",label:"Json diff since import",onselect:RED.view.diffJsonSinceImportDialog},
1873 {id:"btn-diff-xml",icon:"fa fa-clipboard",label:"XML diff since import",onselect:RED.view.diffXmlSinceImportDialog},
1876 {id:"btn-configure-upload",icon:"fa fa-book",label:"Configuration",toggle:false,onselect:updateConfiguration},
1878 {id:"btn-manage-tabs",icon:"fa fa-info",label:"Manage Tabs",toggle:false,onselect:showSelectedTabs},
1880 {id:"btn-test-dg",icon:"fa fa-book",label:"Test DG",toggle:false,onselect:testDG},
1882 {id:"btn-find-dgnumber",icon:"fa fa-info",label:"Search Text (Ctrl+[)",toggle:false,onselect:RED.view.showSearchTextDialog},
1884 {id:"btn-find-dgnumber",icon:"fa fa-info",label:"Find Node (Ctrl+B)",toggle:false,onselect:RED.view.showDgNumberDialog},
1886 {id:"btn-request-input",icon:"fa fa-info",label:"RPC Input (Ctrl+O)",toggle:false,onselect:RED.view.showRequestTemplateDialog},
1888 /*{id:"btn-loop-detection",icon:"fa fa-info",label:"Loop Detection",toggle:true,onselect:performLoopDetection},
1890 {id:"btn-node-status",icon:"fa fa-info",label:"Node Status",toggle:true,onselect:toggleStatus},
1892 {id:"btn-node-dgnumber",icon:"fa fa-info",label:"Show Node Numbers",toggle:true,onselect:toggleDgNumberDisplay},
1894 {id:"btn-node-panel",icon:"fa fa-columns",label:"Node Palette (Ctrl+M)",toggle:true,onselect:toggleNodePaletteDisplay},
1896 {id:"btn-node-viewdgs",icon:"fa fa-info",label:"View All DG List",toggle:false,onselect:displayAllDGs},
1899 {id:"btn-node-gitmenu",icon:"fa fa-info",label:"Git Commands",options: [
1900 {id:"btn-node-gitcheckout",icon:"fa fa-info",label:"Git Checkout",onselect:showGitCheckoutDialog},
1901 {id:"btn-node-gitpull",icon:"fa fa-info",label:"Git Pull",onselect:showGitPullDialog},
1902 {id:"btn-node-gitstatus",icon:"fa fa-info",label:"Git Status",onselect:showGitStatusDialog}
1906 {id:"btn-import-menu",icon:"fa fa-sign-in",label:"Import...",options:[
1907 /*{id:"btn-import-codecloud",icon:"fa fa-clipboard",label:"Code Cloud",onselect:showCodeCloudFlows},
1909 {id:"btn-import-codecloud",icon:"fa fa-clipboard",label:"Git Local Repository",onselect:showGitLocalFlows},
1910 {id:"btn-import-userflows",icon:"fa fa-clipboard",label:"Downloaded DG Flows...",onselect:showFlowShareUsers},
1911 {id:"btn-import-clipboard",icon:"fa fa-clipboard",label:"Clipboard...",onselect:RED.view.showImportNodesDialog},
1912 {id:"btn-import-library",icon:"fa fa-book",label:"Library",options:[]}
1914 {id:"btn-export-menu",icon:"fa fa-sign-out",label:"Export...",disabled:true,options:[
1915 {id:"btn-export-clipboard",icon:"fa fa-clipboard",label:"Clipboard...",disabled:true,onselect:RED.view.showExportNodesDialog},
1916 {id:"btn-export-library",icon:"fa fa-book",label:"Library...",disabled:true,onselect:RED.view.showExportNodesLibraryDialog}
1919 {id:"btn-change-password",icon:"fa fa-columns",label:"Change Password",toggle:false,onselect:updatePassword},
1921 /*{id:"btn-config-nodes",icon:"fa fa-th-list",label:"Configuration nodes...",onselect:RED.sidebar.config.show},
1923 {id:"btn-workspace-menu",icon:"fa fa-th-large",label:"Workspaces",options:[
1924 {id:"btn-workspace-add",icon:"fa fa-plus",label:"Add"},
1925 {id:"btn-workspace-edit",icon:"fa fa-pencil",label:"Rename"},
1926 {id:"btn-workspace-delete",icon:"fa fa-minus",label:"Delete"},
1930 {id:"btn-keyboard-shortcuts",icon:"fa fa-keyboard-o",label:"Keyboard Shortcuts",onselect:showHelp}
1931 /*{id:"btn-help",icon:"fa fa-question",label:"Help...", href:"http://nodered.org/docs"}*/
1935 //Making default loop detection on and display check mark in the menu
1936 //$("#btn-loop-detection").addClass("active");
1938 RED.keyboard.add(/* ? */ 191,{shift:true,ctrl:true},function(){showHelp();d3.event.preventDefault();});
1940 RED.comms.connect();