diff options
Diffstat (limited to 'dgbuilder/nodes/dge/dgemain')
-rw-r--r-- | dgbuilder/nodes/dge/dgemain/GenericXML.html | 140 | ||||
-rw-r--r-- | dgbuilder/nodes/dge/dgemain/GenericXML.js | 31 | ||||
-rw-r--r-- | dgbuilder/nodes/dge/dgemain/comment.html | 97 | ||||
-rw-r--r-- | dgbuilder/nodes/dge/dgemain/comment.js | 23 | ||||
-rw-r--r-- | dgbuilder/nodes/dge/dgemain/dgstart.html | 1322 | ||||
-rw-r--r-- | dgbuilder/nodes/dge/dgemain/dgstart.js | 594 | ||||
-rw-r--r-- | dgbuilder/nodes/dge/dgemain/method.html | 141 | ||||
-rw-r--r-- | dgbuilder/nodes/dge/dgemain/method.js | 31 | ||||
-rw-r--r-- | dgbuilder/nodes/dge/dgemain/serviceLogic.html | 125 | ||||
-rw-r--r-- | dgbuilder/nodes/dge/dgemain/serviceLogic.js | 31 |
10 files changed, 0 insertions, 2535 deletions
diff --git a/dgbuilder/nodes/dge/dgemain/GenericXML.html b/dgbuilder/nodes/dge/dgemain/GenericXML.html deleted file mode 100644 index 4c9c01a6..00000000 --- a/dgbuilder/nodes/dge/dgemain/GenericXML.html +++ /dev/null @@ -1,140 +0,0 @@ -<!-- - Copyright 2013 IBM Corp. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - -<script type="text/x-red" data-template-name="GenericXML"> - <div class="form-row"> - <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> - <input type="text" id="node-input-name" placeholder="Name"> - </div> - <div class="form-row"> - <label for="node-input-xml"><i class="fa fa-wrench"></i> Node XML</label> - <input type="hidden" id="node-input-xml" autofocus="autofocus"> - <div style="height: 250px;" class="node-text-editor" id="node-input-xml-editor" onkeyup="resetStatus()" ></div> - </div> - <div class="form-row"> - <a href="#" class="btn btn-mini" id="node-input-validate" style="margin-top: 4px;"><b>Validate XML</b></a> - <a href="#" class="btn btn-mini" id="node-input-show-sli-values" style="margin-top: 4px;"><b>Show SLI Values</b></a> - <input type="hidden" id="node-input-comments"> - <a href="#" class="btn btn-mini" id="node-input-btnComments" style="margin-top: 4px;"><b>Add Comments</b></a> - <div id="node-validate-result" class="form-tips" style="float:right;font-size:10px"></div> - </div> - <div class="form-tips">See the Info tab for help using this node.</div> -</script> - -<script type="text/x-red" data-help-name="GenericXML"> - <p>A generic DGEmain node.</p> - <p>Name can be anything.</p> - <p>First line of XML must contain opening tag.</p> - <p>Do not include closing tag - it will be automatically generated.</p> -</script> - - -<script type="text/javascript"> - RED.nodes.registerType('GenericXML',{ - color:"#fdd0a2", - category: 'DGEmain', - defaults: { - name: {value:"dge-node"}, - xml: {value:""}, - comments:{value:""}, - outputs: {value:1} - }, - inputs:1, - outputs:1, - icon: "arrow-in.png", - label: function() { - return this.name; - }, - oneditprepare: function() { - $( "#node-input-outputs" ).spinner({ - min:1 - }); - - var comments = $( "#node-input-comments").val(); - if(comments != null){ - comments = comments.trim(); - if(comments != ''){ - $("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>"); - } - } - - function functionDialogResize(ev,ui) { - $("#node-input-xml-editor").css("height",(ui.size.height-275)+"px"); - }; - - $( "#dialog" ).on("dialogresize", functionDialogResize); - $( "#dialog" ).one("dialogopen", function(ev) { - var size = $( "#dialog" ).dialog('option','sizeCache-function'); - if (size) { - functionDialogResize(null,{size:size}); - } - }); - - /* close dialog when ESC is pressed and released */ - $( "#dialog" ).keyup(function(event){ - if(event.which == 27 ) { - $("#node-dialog-cancel").click(); - } - }); - - $( "#dialog" ).one("dialogclose", function(ev,ui) { - var height = $( "#dialog" ).dialog('option','height'); - $( "#dialog" ).off("dialogresize",functionDialogResize); - }); - var that = this; - require(["orion/editor/edit"], function(edit) { - that.editor = edit({ - parent:document.getElementById('node-input-xml-editor'), - lang:"html", - contents: $("#node-input-xml").val() - }); - RED.library.create({ - url:"functions", // where to get the data from - type:"function", // the type of object the library is for - editor:that.editor, // the field name the main text body goes to - fields:['name','outputs'] - }); - $("#node-input-name").focus(); - $("#node-input-validate").click(function(){ - console.log("validate clicked."); - //console.dir(that.editor); - //console.log("getText:" + that.editor.getText()); - var val = that.editor.getText(); - validateXML(val); - }); - $("#node-input-show-sli-values").click(function(){ - //console.log("SLIValues clicked."); - showValuesBox(that.editor,sliValuesObj); - }); - - }); - //for click of add comments button - $("#node-input-btnComments").click(function(e){ - showCommentsBox(); - }); - }, - oneditsave: function() { - $("#node-input-xml").val(this.editor.getText()); - var resp=validateXML(this.editor.getText()); - if(resp){ - this.status = {fill:"green",shape:"dot",text:"OK"}; - }else{ - this.status = {fill:"red",shape:"dot",text:"ERROR"}; - } - delete this.editor; - } - }); -</script> diff --git a/dgbuilder/nodes/dge/dgemain/GenericXML.js b/dgbuilder/nodes/dge/dgemain/GenericXML.js deleted file mode 100644 index e5fc0624..00000000 --- a/dgbuilder/nodes/dge/dgemain/GenericXML.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright 2013 IBM Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - **/ - -module.exports = function(RED) { - "use strict"; - var util = require("util"); - var vm = require("vm"); - - function GenericXML(n) { - RED.nodes.createNode(this,n); - this.name = n.name; - this.xml = n.xml; - this.topic = n.topic; - } - - RED.nodes.registerType("GenericXML",GenericXML); - // RED.library.register("GenericXML"); -} diff --git a/dgbuilder/nodes/dge/dgemain/comment.html b/dgbuilder/nodes/dge/dgemain/comment.html deleted file mode 100644 index c34d14c9..00000000 --- a/dgbuilder/nodes/dge/dgemain/comment.html +++ /dev/null @@ -1,97 +0,0 @@ -<!-- - Copyright 2013 IBM Corp. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - -<script type="text/x-red" data-template-name="comment"> - <div class="form-row"> - <label for="node-input-name"><i class="fa fa-comment"></i> Comment</label> - <input type="text" id="node-input-name" placeholder="Comment"> - </div> - <div class="form-row"> - <label for="node-input-info" style="width: 100% !important;"><i class="fa fa-comments"></i> More</label> - <input type="hidden" id="node-input-info" autofocus="autofocus"> - <div style="height: 250px;" class="node-text-editor" id="node-input-info-editor" ></div> - <input type="hidden" id="node-input-comments"> - </div> - <div class="form-tips">Tip: this isn't meant for "War and Peace" - but useful notes can be kept here.</div> -</script> - -<script type="text/x-red" data-help-name="comment"> - <p>Simple comment block.</p> -</script> - -<script type="text/javascript"> - RED.nodes.registerType('comment',{ - category: 'DGEmain', - color:"#ffffff", - defaults: { - name: {value:""}, - info: {value:""}, - comments:{value:""} - }, - inputs:0, - outputs:0, - icon: "comment.png", - label: function() { - return this.name||""; - }, - labelStyle: function() { - return this.name?"node_label_italic":""; - }, - oneditprepare: function() { - $( "#node-input-outputs" ).spinner({ - min:1 - }); - - var comments = $( "#node-input-comments").val(); - if(comments != null){ - comments = comments.trim(); - if(comments != ''){ - $("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>"); - } - } - - function functionDialogResize(ev,ui) { - $("#node-input-info-editor").css("height",(ui.size.height-235)+"px"); - }; - $( "#dialog" ).on("dialogresize", functionDialogResize); - $( "#dialog" ).one("dialogopen", function(ev) { - var size = $( "#dialog" ).dialog('option','sizeCache-function'); - if (size) { - functionDialogResize(null,{size:size}); - } - }); - $( "#dialog" ).one("dialogclose", function(ev,ui) { - var height = $( "#dialog" ).dialog('option','height'); - $( "#dialog" ).off("dialogresize",functionDialogResize); - }); - var that = this; - require(["orion/editor/edit"], function(edit) { - that.editor = edit({ - parent:document.getElementById('node-input-info-editor'), - lang:"text", - showLinesRuler:false, - showFoldingRuler:false, - contents: $("#node-input-info").val() - }); - $("#node-input-name").focus(); - }); - }, - oneditsave: function() { - $("#node-input-info").val(this.editor.getText()); - delete this.editor; - } - }); -</script> diff --git a/dgbuilder/nodes/dge/dgemain/comment.js b/dgbuilder/nodes/dge/dgemain/comment.js deleted file mode 100644 index ef5f0800..00000000 --- a/dgbuilder/nodes/dge/dgemain/comment.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright 2013 IBM Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - **/ - -module.exports = function(RED) { - "use strict"; - function CommentNode(n) { - RED.nodes.createNode(this,n); - } - RED.nodes.registerType("comment",CommentNode); -} diff --git a/dgbuilder/nodes/dge/dgemain/dgstart.html b/dgbuilder/nodes/dge/dgemain/dgstart.html deleted file mode 100644 index 9caa841a..00000000 --- a/dgbuilder/nodes/dge/dgemain/dgstart.html +++ /dev/null @@ -1,1322 +0,0 @@ -<!-- - Copyright 2013 IBM Corp. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<div id="svclogicPageDiv" ></div> -<!-- dgbuilder javascript files START --> -<script src="util/js/validateNodeXml.js"/> -<script src="util/js/sliValues.js"/> -<script src="util/js/dgeToXml.js"/> -<script src="util/js/vkbeautify.0.99.00.beta.js"/> -<!-- dgbuilder javascript files END --> - -<script type="text/x-red" data-template-name="dgstart"> - <div class="form-tips">See the Info tab for help using this node.</div> -</script> -<style> -.no-close .ui-dialog-titlebar-close {display: none } -.alertDialogButton { - border-top: 1px solid #96d1f8; - background: #65a9d7; - background: -webkit-gradient(linear, left top, left bottom, from(#3e779d), to(#65a9d7)); - background: -webkit-linear-gradient(top, #3e779d, #65a9d7); - background: -moz-linear-gradient(top, #3e779d, #65a9d7); - background: -ms-linear-gradient(top, #3e779d, #65a9d7); - background: -o-linear-gradient(top, #3e779d, #65a9d7); - padding: 5px 10px; - -webkit-border-radius: 8px; - -moz-border-radius: 8px; - border-radius: 8px; - -webkit-box-shadow: rgba(0,0,0,1) 0 1px 0; - -moz-box-shadow: rgba(0,0,0,1) 0 1px 0; - box-shadow: rgba(0,0,0,1) 0 1px 0; - text-shadow: rgba(0,0,0,.4) 0 1px 0; - color: white; - font-size: 14px; - font-family: Georgia, serif; - text-decoration: none; - vertical-align: middle; - } -.alertDialogButton:hover { - border-top-color: #28597a; - background: #28597a; - color: #ccc; - } - -.alertDialogButton:active { - border-top-color: #1b435e; - background: #1b435e; - } -.disabled-button { - border-top: 1px solid #96d1f8; - background: lightgrey; - background: -webkit-gradient(linear, left top, left bottom, from(grey), to(lightgrey)); - background: -webkit-linear-gradient(top, grey, grey); - background: -moz-linear-gradient(top, grey, grey); - background: -ms-linear-gradient(top, grey, grey); - background: -o-linear-gradient(top, grey, grey); - padding: 5px 10px; - -webkit-border-radius: 8px; - -moz-border-radius: 8px; - border-radius: 8px; - -webkit-box-shadow: rgba(0,0,0,1) 0 1px 0; - -moz-box-shadow: rgba(0,0,0,1) 0 1px 0; - box-shadow: rgba(0,0,0,1) 0 1px 0; - text-shadow: rgba(0,0,0,.4) 0 1px 0; - color: lightgrey; - font-size: 14px; - font-family: Georgia, serif; - text-decoration: none; - vertical-align: middle; - } -</style> -<script type="text/javascript"> - -function activateDG(module,rpc,version,mode,displayOnlyCurrent){ - var paramsObj = {'module': module , 'rpc' : rpc , 'version' : version , 'mode' : mode,'displayOnlyCurrent' : false}; - if(displayOnlyCurrent){ - paramsObj = {'module': module , 'rpc' : rpc , 'version' : version , 'mode' : mode,'displayOnlyCurrent' : true}; - } - var dgInfo = "<div><table width='100%' border='1'><tr style='background-color:#65a9d7;color:white;' ><th>Module</th><th>RPC</th><th>Version</th></tr><tr style='background-color:white'><td>" + module +"</td><td>" + rpc + "</td><td>" +version + "</td></tr></table></div><br>"; - var alertMsg = dgInfo + "<p>Are you sure you want to Activate this DG ?</p>"; -$( "#alertdialog" ).dialog({ - dialogClass: "no-close", - autoOpen :false, - modal:true, - draggable : true, - /*dialogClass: "alert",*/ - title: "Confirm Activate", - width: 600, - buttons: [ - { - text: "Activate", - class:"alertDialogButton", - click: function() { - $.get("/activateDG" , paramsObj) - .done(function( data ) { - //RED.notify("<strong>Activated Successfully</strong>"); - var htmlStr = ""; - var title =""; - if(displayOnlyCurrent){ - htmlStr=getHtmlStr(data,true); - title="Service Logic Administration Module=" + module + " and RPC=" + rpc; - }else{ - htmlStr=getHtmlStr(data); - title= "Service Logic Administration - " + data.dbHost; - } - $("#svclogicPageDiv").dialog({ - modal:true, - title: title, - width: 1200, - height: 750, - minWidth : 600, - minHeight :450, - }).html(htmlStr); - }) - .fail(function( err ) { - RED.notify("<strong>Could not Activate</strong>"); - var htmlStr = "<p>" + "could not activate" + module + " " + rpc + " " + version +"</p> <a onclick='javascript:showSLA()'></a>"; - if(displayOnlyCurrent == true){ - htmlStr = "<p>" + "could not activate" + module + " " + rpc + " " + version +"</p> <a onclick='javascript:showCurrentDGs(\"" + module + "\",\"" + rpc + "\")'>Back to DG List</a>"; - } - $("#svclogicPageDiv").dialog({ - modal:true, - title: "Service Logic Administration - " + err.dbHost, - width: 1200, - height: 750, - minWidth : 600, - minHeight :450, - }).html(htmlStr); - }) - .always(function() { - // $('.ui-dialog:has(#alertdialog)').empty().remove(); - $("#alertdialog" ).dialog('close'); - - }); - } - }, - { - text: "Cancel", - class:"alertDialogButton", - click: function() { - //$('.ui-dialog:has(#alertdialog)').empty().remove(); - $( this ).dialog( "close" ); - } - } - ] -}).html(alertMsg).dialog('open'); -//var dialogClass = $("#alertdialog").dialog( "option", "dialogClass" ); -//$( "#alertdialog" ).dialog( "option", "dialogClass", "alert" ); -//$("#alertdialog").dialog("widget").find(".ui-dialog-buttonpane").css("background-color", "#ECECFF"); -/* -$('#alertdialog').css("background-color", "#ECECEC"); -$("#alertdialog").dialog("widget").find(".ui-dialog-buttonpane").css("background-color", "#ECECEC"); - -// button pane style -$("#alertdialog").dialog("widget").find(".ui-dialog-buttonpane").css({"padding":".1em .1em .1em 0","margin":"0 0 0 0"} ) - -// button style -$("#alertdialog").dialog("widget").find("button").css({"padding":"0 .2em 0 .2em","margin":"0 .5em 0 0"} ) -$("#alertdialog").dialog("widget").find("button").addClass("alertDialogButton"); -*/ -//console.dir($("#alertdialog")); -} - - -function deActivateDG(module,rpc,version,mode,displayOnlyCurrent){ - var paramsObj = {'module': module , 'rpc' : rpc , 'version' : version , 'mode' : mode,'displayOnlyCurrent' : false}; - if(displayOnlyCurrent){ - paramsObj = {'module': module , 'rpc' : rpc , 'version' : version , 'mode' : mode,'displayOnlyCurrent' : true}; - } - var dgInfo = "<div ><table width='100%' border='1'><tr style='background-color:#65a9d7;color:white;'><th>Module</th><th>RPC</th><th>Version</th></tr><tr style='background-color:white'><td>" + module +"</td><td>" + rpc + "</td><td>" +version + "</td></tr></table></div><br>"; - var alertMsg = dgInfo + "<p>Are you sure you want to De-Activate this DG ?</p>"; -$( "#alertdialog" ).dialog({ - dialogClass: "no-close", - autoOpen : false, - modal:true, - draggable : true, - title: "Confirm De-Activate", - width: 600, - buttons: [ - { - text: "De-Activate", - class:"alertDialogButton", - click: function() { - $.get("/deActivateDG" , paramsObj) - .done(function( data ) { - //RED.notify("<strong>deActivated Successfully</strong>"); - var htmlStr = ""; - var title =""; - if(displayOnlyCurrent){ - htmlStr=getHtmlStr(data,true); - title="Service Logic Administration Module=" + module + " and RPC=" + rpc; - }else{ - htmlStr=getHtmlStr(data); - title= "Service Logic Administration - " + data.dbHost; - } - $("#svclogicPageDiv").dialog({ - modal:true, - title: title, - width: 1200, - height: 750, - minWidth : 600, - minHeight :450, - }).html(htmlStr); - }) - .fail(function( err ) { - RED.notify("<strong>Could not De-Activate</strong>"); - var htmlStr = "<p>" + "could not deactivate" + module + " " + rpc + " " + version +"</p> <a onclick='javascript:showSLA()'></a>"; - if(displayOnlyCurrent == true){ - htmlStr = "<p>" + "could not deactivate" + module + " " + rpc + " " + version +"</p> <a onclick='javascript:showCurrentDGs(\"" + module + "\",\"" + rpc + "\")'>Back to DG List</a>"; - } - $("#svclogicPageDiv").dialog({ - modal:true, - title: "Service Logic Administration - " + err.dbHost, - width: 1200, - height: 750, - minWidth : 600, - minHeight :450, - }).html(htmlStr); - }) - .always(function() { - //$('.ui-dialog:has(#alertdialog)').empty().remove(); - $( "#alertdialog" ).dialog( "close" ); - //$("#alertdialog" ).dialog('destroy').remove(); - }); - } - }, - { - text: "Cancel", - class:"alertDialogButton", - click: function() { - //$('.ui-dialog:has(#alertdialog)').empty().remove(); - //$(this).dialog('destroy').remove() - //$( this ).dialog( "close" ); - /*if ($("#alertdialog").hasClass('ui-dialog-content')) { - $("#alertdialog" ).dialog('close'); - }else{ - $( this ).dialog( "close" ); - } - */ - $( this ).dialog( "close" ); - } - } - ] -}).html(alertMsg).dialog("open"); -} - -function deleteDG(module,rpc,version,mode,displayOnlyCurrent){ - var paramsObj = {'module': module , 'rpc' : rpc , 'version' : version , 'mode' : mode,'displayOnlyCurrent' : false}; - if(displayOnlyCurrent){ - paramsObj = {'module': module , 'rpc' : rpc , 'version' : version , 'mode' : mode,'displayOnlyCurrent' : true}; - } - var dgInfo = "<div ><table width='100%' border='1'><tr style='background-color:#65a9d7;color:white;'><th>Module</th><th>RPC</th><th>Version</th></tr><tr style='background-color:white'><td>" + module +"</td><td>" + rpc + "</td><td>" +version + "</td></tr></table></div><br>"; - var alertMsg = dgInfo + "<p>Are you sure you want to Delete this DG ?</p>"; -$( "#alertdialog" ).dialog({ - dialogClass: "no-close", - autoOpen: false, - modal:true, - draggable : true, - title: "Confirm Delete", - width: 600, - buttons: [ - { - text: "Delete", - class:"alertDialogButton", - click: function() { - $.get("/deleteDG" , paramsObj) - .done(function( data ) { - RED.notify("<strong>Deleted " + module + " " + rpc + " " + version + " Successfully</strong>"); - var htmlStr = ""; - var title =""; - if(displayOnlyCurrent){ - htmlStr=getHtmlStr(data,true); - title="Service Logic Administration Module=" + module + " and RPC=" + rpc; - }else{ - htmlStr=getHtmlStr(data); - title= "Service Logic Administration - " + data.dbHost; - } - $("#svclogicPageDiv").dialog({ - modal:true, - title: title, - width: 1200, - height: 750, - minWidth : 600, - minHeight :450, - }).html(htmlStr); - }) - .fail(function( err ) { - //RED.notify("<strong>Could not Delete" + module + " " + rpc + " " + version + "</strong>"); - var htmlStr = "<p>" + "could not delete" + module + " " + rpc + " " + version +"</p> <a onclick='javascript:showSLA()'></a>"; - if(displayOnlyCurrent == true){ - htmlStr = "<p>" + "could not delete" + module + " " + rpc + " " + version +"</p> <a onclick='javascript:showCurrentDGs(\"" + module + "\",\"" + rpc + "\")'>Back to DG List</a>"; - } - $("#svclogicPageDiv").dialog({ - modal:true, - title: "Service Logic Administration - " + err.dbHost, - width: 1200, - height: 750, - minWidth : 600, - minHeight :450, - }).html(htmlStr); - }) - .always(function() { - $( "#alertdialog" ).dialog( "close" ); - //$('.ui-dialog:has(#alertdialog)').empty().remove(); - //$("#alertdialog" ).dialog('destroy').remove(); - }); - } - }, - { - text: "Cancel", - class:"alertDialogButton", - click: function() { - /* - if ($("#alertdialog").hasClass('ui-dialog-content')) { - $("#alertdialog" ).dialog('close'); - }else{ - $( this ).dialog( "close" ); - } - */ - //$( "#alertdialog" ).dialog( "close" ); - //$('.ui-dialog:has(#alertdialog)').empty().remove(); - //$( this ).dialog( "close" ); - $( this ).dialog( "close" ); - } - } - ] -}).html(alertMsg).dialog("open"); -} -/* -function downloadDGXml(_module,rpc,version,mode){ - var paramsObj = {'_module': _module , 'rpc' : rpc , 'version' : version , 'mode' : mode}; - var form = $('<form id="dwnldDbXmlFormId" method="POST" action="/downloadDGXml"></form>'); - form.append('<input type="hidden" name="_module" value="' + _module + '"/>'); - form.append('<input type="hidden" name="rpc" value="' + rpc + '"/>'); - form.append('<input type="hidden" name="version" value="' + version + '"/>'); - form.append('<input type="hidden" name="mode" value="' + mode + '"/>'); - form.appendTo('body'); - $("#dwnldDbXmlFormId").submit(); -} -*/ - -function displayXml(module,rpc,version,mode,displayOnlyCurrent){ - var paramsObj = {'_module': module , 'rpc' : rpc , 'version' : version , 'mode' : mode,'displayOnlyCurrent' : false}; - var title="Service Logic Administration"; - if(displayOnlyCurrent){ - paramsObj = {'_module': module , 'rpc' : rpc , 'version' : version , 'mode' : mode,'displayOnlyCurrent' : true}; - title="Service Logic Administration Module=" + module + " and RPC=" + rpc; - }else{ - title="Service Logic Administration"; - } - //var headingStr = "<a style='color: #337ab7;' onclick='javascript:showSLA()'><<Back to DG List</a><br><div style='background-color:#337ab7;clear:both;'><table style='width:100%;' border='0'>" + - var headingStr = "<a style='color: #337ab7;cursor:pointer;' onclick='javascript:showSLA()'><<Back to DG List</a><br><div style='clear:both;'><table style='width:25%' border='0'>" ; - if(displayOnlyCurrent == true){ - headingStr = "<a style='color: #337ab7;cursor:pointer;' onclick='javascript:showCurrentDGs(\"" + module + "\",\"" + rpc + "\")'><<Back to DG List</a><br><div style='clear:both;'><table style='width:25%' border='0'>" ; - } - headingStr += "<tr><td><b>Module</b></td><td>" + module + "</td></tr>" + - "<tr><td><b>RPC</b></td><td>" + rpc + "</td></tr>" + - "<tr><td><b>Version</b></td><td>" + version + "</td></tr>" + - "<tr><td><b>Mode</b></td><td>" + mode + "</td></tr>" + - "</table></div>"; - - //var urlStr = "/displayXml?_module=" + module + "&rpc=" + rpc + "&version=" + version + "&mode=" + mode; - $.get("/displayXml",paramsObj) - .done(function( data ) { - //var htmlStr= headingStr + '<div style="clear:both;"></div><div style="background-color:lightgrey;border-style: solid;border-color:#337ab7;clear:both;">' + data.xmldata + "</div>"; - var htmlStr= headingStr + '<hr style="clear:both;height:5px;background-color:#337ab7;"><div>' + data.xmldata + "</div>"; - $("#svclogicPageDiv").dialog({ - modal:true, - title: title, - width: 1200, - height: 750, - minWidth : 600, - minHeight :450, - }).html(htmlStr); - }) - .fail(function( err ) { - //RED.notify("<strong>Could not display XML</strong>"); - var htmlStr = "<p>" + "Could not display xml for" + module + " " + rpc + " " + version + "</p><a style='color: #337ab7;cursor:pointer;' onclick='javascript:showSLA()'>Back to DG List</a><br>"; - if(displayOnlyCurrent == true){ - htmlStr = "<p>" + "could not display XML" + module + " " + rpc + " " + version +"</p> <a onclick='javascript:showCurrentDGs(\"" + module + "\",\"" + rpc + "\")'>Back to DG List</a>"; - } - $("#svclogicPageDiv").dialog({ - modal:true, - title: "Service Logic Administration", - width: 1200, - height: 750, - minWidth : 600, - minHeight :450, - }).html(htmlStr); - }) - .always(function() { - }); -} - -function displayDG(module,rpc,version,mode,displayOnlyCurrent){ - var paramsObj = {'_module': module , 'rpc' : rpc , 'version' : version , 'mode' : mode,'displayOnlyCurrent' : false}; - var title="Service Logic Administration"; - if(displayOnlyCurrent){ - paramsObj = {'_module': module , 'rpc' : rpc , 'version' : version , 'mode' : mode,'displayOnlyCurrent' : true}; - } - //var headingStr = "<a style='color: #337ab7;cursor:pointer' onclick='javascript:showSLA()'><<Back to DG List</a><br><div><table id='msgTable' style='width:25%;background-color:lightgrey' border='0'>" + - var headingStr = "<a style='color: #337ab7;cursor:pointer;' onclick='javascript:showSLA()'><<Back to DG List</a><br><div><table id='msgTable' style='width:25%;' border='0'>" ; - if(displayOnlyCurrent == true){ - headingStr = "<a style='color: #337ab7;cursor:pointer;' onclick='javascript:showCurrentDGs(\"" + module + "\",\"" + rpc + "\")'><<Back to DG List</a><br><div style='clear:both;'><table style='width:25%' border='0'>" ; - title="Service Logic Administration Module=" + module + " and RPC=" + rpc; - } - headingStr +="<tr><td><b>Module</b></td><td>" + module + "</td></tr>" + - "<tr><td><b>RPC</b></td><td>" + rpc + "</td></tr>" + - "<tr><td><b>Version</b></td><td>" + version + "</td></tr>" + - "<tr><td><b>Mode</b></td><td>" + mode + "</td></tr>" + - "</table></div>"; - - //var urlStr = "/displayAsGv?_module=" + module + "&rpc=" + rpc + "&version=" + version + "&mode=" + mode; - $.get("/displayAsGv",paramsObj) - .done(function( data ) { - var htmlStr= headingStr + '<div style="background-color:white;">' + data.svg_html + "</div>"; - $("#svclogicPageDiv").dialog({ - modal:true, - title: "Service Logic Administration", - width: 1200, - height: 750, - minWidth : 600, - minHeight :450, - }).html(htmlStr); - }) - .fail(function( err ) { - //RED.notify("<strong>Could not display XML</strong>"); - var htmlStr = "<p>" + "Could not display DG for" + module + " " + rpc + " " + version + "</p><a style='color: #337ab7;cursor:pointer;' onclick='javascript:showSLA()'>Back to DG List</a><br>"; - if(displayOnlyCurrent == true){ - htmlStr = "<p>" + "could not display DG for" + module + " " + rpc + " " + version +"</p> <a onclick='javascript:showCurrentDGs(\"" + module + "\",\"" + rpc + "\")'>Back to DG List</a>"; - } - $("#svclogicPageDiv").dialog({ - modal:true, - title: "Service Logic Administration", - width: 1200, - height: 750, - minWidth : 600, - minHeight :450, - }).html(htmlStr); - }) - .always(function() { - }); -} - -function getHtmlStr(data,displayOnlyCurrent,module,rpc){ - var styleStr = "<style> " + - "table#t01 { width:100%; } \n" + - "table#t01 th,table#t01 td { border: 1px solid black; border-collapse: collapse; } \n" + - /*"table, th, td { border: 1px solid #65a9d7; border-collapse: collapse; } \n" +*/ - "table#t01 th,table#t01 td { padding: 5px; text-align: left; } \n" + - "table#t01 tr:nth-child(even) { background-color: #eee; }\n" + - "table#t01 tr:nth-child(odd) { background-color:#fff; }\n" + - "table#t01 th { background-color: #65a9d7; color: white; }\n" + - "table#t01 a { color: #337ab7; }\n" + - "table#t01 a:link { color: #65a9d7; }\n" + - "table#t01 a:visited { color: #636; }\n" + - "table#t01 a:hover { color: #3366CC; cursor: pointer }\n" + - "table#t01 a:active { color: #65a9d7 }\n" + - "</style>"; - if(data != null && data.rows != undefined && data.error == undefined){ - var alertDialog = '<div id="alertdialog"></div>'; - htmlStr= alertDialog + "<div style='width:1050;height:650'>" + styleStr; - htmlStr += "<table id='t01' >"; - htmlStr += "<tr>"; - htmlStr += "<th>Module</th>" ; - htmlStr += "<th>RPC</th>" ; - htmlStr += "<th>Version</th>" ; - htmlStr += "<th>Mode</th>" ; - htmlStr += "<th>Active</th>" ; - htmlStr += "<th>Activate/Deactivate</th>"; - htmlStr += "<th>Display DG</th>"; - htmlStr += "<th>XML</th>"; - htmlStr += "<th>Delete</th>"; - htmlStr += "</tr>"; - var rows = data.rows; - if(rows != null && rows.length == 0){ - htmlStr += "<tr>"; - htmlStr += "<td><b>No rows found</b></td>"; - htmlStr += "</tr></table></div>"; - return htmlStr; - } - for(var i=0;i<rows.length;i++){ - var row = rows[i]; - var _module = row.module; - var rpc = row.rpc; - var version = row.version; - var mode = row.mode; - var active = row.active; - htmlStr += "<tr>"; - htmlStr += "<td>" + _module + "</td>"; - htmlStr += "<td>" + rpc + "</td>"; - htmlStr += "<td>" + version + "</td>"; - htmlStr += "<td>" + mode + "</td>"; - htmlStr += "<td>" + active + "</td>"; - - var methodParams = "'" + _module + "','" + rpc + "','" + version + "','" + mode + "'"; - if(displayOnlyCurrent){ - methodParams+= ",true"; - } - if(active == 'Y'){ - htmlStr += "<td><a onclick=\"javascript:deActivateDG(" + methodParams + ")\">DeActivate</a></td>"; - }else{ - htmlStr += "<td><a onclick=\"javascript:activateDG(" + methodParams + ")\">Activate</a></td>"; - } - htmlStr += "<td><a onclick=\"javascript:displayDG(" + methodParams + ")\">Display</a></td>"; - - htmlStr += "<td><a onclick=\"javascript:displayXml(" + methodParams + ")\">XML</a></td>"; - - htmlStr += "<td><a onclick=\"javascript:deleteDG(" + methodParams + ")\">Delete</a></td>"; - htmlStr += "</tr>"; - } - htmlStr += "</table>"; - htmlStr += "</div>"; - } - return htmlStr; -} - -function showSLA(){ - var htmlStr = ""; - try{ - $.get("/listSLA") - .done(function( data ) { - var htmlStr=getHtmlStr(data); - $("#svclogicPageDiv").dialog({ - modal:true, - title: "Service Logic Administration - " + data.dbHost, - width: 1200, - height: 750, - minWidth : 600, - minHeight :450, - }).html(htmlStr); - }) - .fail(function(err) { - htmlStr= "<div>Error occured displaying the DG list</div>"; - $("#svclogicPageDiv").dialog({ - modal:true, - title: "Service Logic Administration - " + data.dbHost, - width: 1200, - height: 750, - minWidth : 600, - minHeight :450, - }).html(htmlStr); - }) - .always(function() { - }); - }catch(err){ - } -} - -function showCurrentDGs(module,rpc){ - var htmlStr = ""; - try{ - var params="?module=" + module + "&rpc=" + rpc; - var url="/listCurrentDGs" + params; - //console.log("url:" + url); - $.get(url) - .done(function( data ) { - var htmlStr=getHtmlStr(data,true); - $("#svclogicPageDiv").dialog({ - modal:true, - title:"Service Logic Administration Module=" + module + " and RPC=" + rpc, - width: 1200, - height: 750, - minWidth : 600, - minHeight :450, - }).html(htmlStr); - }) - .fail(function(err) { - htmlStr= "<div>Error occured displaying the DG list</div>"; - $("#svclogicPageDiv").dialog({ - modal:true, - title:"Service Logic Administration Module=" + module + " and RPC=" + rpc, - width: 1200, - height: 750, - minWidth : 600, - minHeight :450, - }).html(htmlStr); - }) - .always(function() { - }); - }catch(err){ - } -} - - -function displaySLA(callback){ - var htmlStr = ""; - try{ - $.get("/listSLA") - .done(function( data ) { - var htmlStr=getHtmlStr(data); - callback(htmlStr,data.dbHost); - }) - .fail(function(err) { - htmlStr= "<div>Error occured displaying the DG list</div>"; - callback(htmlStr,err.dbHost); - }) - .always(function() { - }); - }catch(err){ - callback(htmlStr,""); - } -} - -function displayCurrentDGs(module,rpc,callback){ - var htmlStr = ""; - try{ - var params="?module=" + module + "&rpc=" + rpc; - var url="/listCurrentDGs" + params; - //console.log("url:" + url); - $.get(url ) - .done(function( data ) { - var htmlStr=getHtmlStr(data,true); - callback(htmlStr,data.dbHost); - }) - .fail(function(err) { - htmlStr= "<div>Error occured displaying the Current DG list</div>"; - callback(htmlStr,err.dbHost); - }) - .always(function() { - }); - }catch(err){ - callback(htmlStr,""); - } -} - - -window.onbeforeunload = function (event) { - var dis = $('#btn-deploy').attr('class') - if ( dis.indexOf('disabled') == -1 ) { - var message = 'Important: You have changes that were not \'deployed\'.'; - if (typeof event == 'undefined') { - event = window.event; - } - if (event) { - event.returnValue = message; - } - return message; - } -}; -</script> -<script type="text/x-red" data-help-name="dgstart"> - <p>This node starts a flow. This node is required on every flow.</p> - <p>This node has a button to its left, when clicked generates the XML for the flow</p> - <img src="images/dgstart.png"></img> -</script> -<style> -.textview{ - font-size:20px; -} -</style> - -<div id="screenInfoId"></div> -<script type="text/javascript"> -function getAttributeValue(xmlStr,attribute){ - var attrVal=null; - try{ - var myRe = new RegExp(attribute + "[\s+]?=[\s+]?['\"]([^'\"]+)['\"]","m"); - var myArray = myRe.exec(xmlStr); - if(myArray != null && myArray[1] != null){ - attrVal=myArray[1]; - } - }catch(err){ - console.log(err); - } - return attrVal; - -} - - -function showDgStartGenerateXmlStatus(){ - var htmlStr="<div id='dgstart-generate-xml-div' style='width:375;height:225'><p>Generating XML. Please wait... </p><img src='images/page-loading.gif'></div>" - $("#dgstart-generate-xml-dialog").dialog({ - modal:true, - title: "DGBuilder XML Generation Status", - width: 400, - height: 250, - minWidth : 400, - minHeight :200, - }).html(htmlStr); -} - - RED.nodes.registerType('dgstart',{ - color:"#fdd0a2", - category: 'DGEmain', - defaults: { - name: {value:"DGSTART"}, - outputs: {value:1} - }, - inputs:0, - outputs:1, - icon: "inject.png", - label: function() { - return this.name; - }, - onpaletteadd: function() { - //console.log("DGSTART Added to the palette."); - }, - button: { - onclick: function() { - //$('#processingStatusId').text('working...'); - //$('#processingStatusId').html("<span><p> Processing Please Wait...</span><img src='images/page-loading.gif'>"); - $('#processingStatusId').html("<span style='font-size:0.2em;color:green'> Processing...</span>"); - var timerObj = window.setTimeout(function() { - //document.getElementById("processingStatusId").innerHTML ="<img src='images/page-loading.gif'>"; - - /* - var target = $(event.target); - //target.text("Validating XML"); - target.css({ "background-image": "url('images/page-loading.gif')" }); - target.css({ "background-repeat": "no-repeat" }); - target.css({ "background-size": "25px 25px" }); - */ - - //deploy button - //$("#btn-deploy") - var loopDetectionEnabled = true; - console.log("loopDetectionEnabled:" +loopDetectionEnabled); - if(loopDetectionEnabled){ - var msecs1= Date.now(); - var isLoopDetected = detectLoop(); - var msecs2= Date.now(); - console.log("Time taken for loop detection:" + (msecs2 - msecs1)); - if(isLoopDetected){ - //RED.notify("<strong>Error</strong>: Loop Detected","error"); - //target.css({ "background-image": "none" }); - return false; - } - } - var nodeSetWithUpdatedDgNumbers = updateDgNumbers(); - validateEachNodeXml(); - //var nodeToXmlStr = getNodeToXml(); - var unformatted_xml_str = getNodeToXml(); - //console.log("Size of unformatted_xml_str" + unformatted_xml_str.length); - //console.log("output:" + nodeToXmlStr); - var formatted_xml = vkbeautify.xml(unformatted_xml_str); - /* - var minified_xml = vkbeautify.xmlmin(unformatted_xml_str,true); - var lengthOfMinifiedXml = minified_xml.length; - if(lengthOfMinifiedXml >0){ - var val = lengthOfMinifiedXml/(1024*1024) - var minSizeStr = val.toFixed(4) + " MB"; - console.log("minified XML size:" + minSizeStr); - } - */ - var lengthOfXml = formatted_xml.length; - var sizeStr = ""; - if(lengthOfXml >0){ - var val = lengthOfXml/(1024*1024) - sizeStr = val.toFixed(4) + " MB"; - console.log("length:" + val); - } - var xmlLines = formatted_xml.split("\n"); - console.log("Number of lines " + xmlLines.length); - var numberOfLines = xmlLines.length; - //var display_formatted_xml = formatted_xml.replace("<","<"); - var currentNodeSet = getCurrentFlowNodeSet(); - //get max x and y coordinates - var x=0; - var y=0; - var maxX=0; - var maxY=0; - var moduleName = ""; - var dgVersion = ""; - var methodName = ""; - var formattedMethodName = ""; - var origModuleName = ""; - var origMethodName = ""; - for(var i=0;currentNodeSet != null && i<currentNodeSet.length;i++){ - if(currentNodeSet[i].type == "service-logic"){ - //moduleName = currentNodeSet[i].name; - moduleName = currentNodeSet[i].module; - dgVersion = currentNodeSet[i].version; - origModuleName = getAttributeValue(currentNodeSet[i].xml,"module"); - } - if(currentNodeSet[i].type == "method"){ - //methodName = currentNodeSet[i].name; - origMethodName = getAttributeValue(currentNodeSet[i].xml,"rpc");; - methodName = origMethodName; - if(methodName == ""){ - methodName = "rpc_not_set"; - } - } - x = currentNodeSet[i].x; - y = currentNodeSet[i].y; - if(x>maxX){ - maxX=x; - } - if(y>maxY){ - maxY=y; - } - } - //add 5 more pixels to that - maxX= Math.ceil(maxX) + 5; - maxY= Math.ceil(maxY) + 5; - //console.log("maxX:" + maxX); - //console.log("maxY:" + maxY); - var unformatted_json_str=JSON.stringify(currentNodeSet); - var formatted_json = vkbeautify.json(unformatted_json_str); - //var displayHtmlStr="<div><textarea readonly='1' style='width:1100px;height:700px;border:none'>" + formatted_xml + "</textarea></div>"; - var displayHtmlStr="<div style='font-size:20px;'><xmp>" + formatted_xml + "</xmp></div>"; - var xmlInfoStr = "<div id='xml-info-div'><p>" + "XML size:" + sizeStr + " <br>Number of Lines:" + numberOfLines + "</p></div>"; - var htmlCode =""; - $( "#xmldialog" ).dialog({ - title: "XML Generated", - width: 1200, - height: 750, - minWidth : 800, - minHeight :450, - dialogClass : "no-close", - closeOnEscape : false, - autoOpen : false, - resize: function( event, ui ) { - /* - $( this ).dialog( "option", "title", - ui.size.height + " x " + ui.size.width ); - */ - }, - modal: true, - /*show: { - effect: "slide", - duration: 1000 - }, - */ - /*hide: { - effect: "slide", - duration: 500 - }, - */ - buttons: { - /* - "+" : function () { - var size= $("#xmldialog").find('.textview').css("font-size"); - console.log("size:" + size); - size=size.replace("px",""); - var fsize=Number(size) +1; - if(fsize<19){ - fsize+=4; - } - if(fsize >= 26){ - return; - } - $("#xmldialog").find('.textview').css("font-size",fsize); - }, - "-" : function () { - var size= $("#xmldialog").find('.textview').css("font-size"); - console.log("size:" + size); - size=size.replace(/px/,""); - var fsize=Number(size) -1; - if(fsize <= 14){ - return; - } - $("#xmldialog").find('.textview').css("font-size",fsize); - }, - */ - "Validate XML" : function (event) { - if(!event) event = window.event; - var target = $(event.target); - target.text("Validating XML"); - target.css({ "background-image": "url('images/page-loading.gif')" }); - target.css({ "background-repeat": "no-repeat" }); - target.css({ "background-size": "25px 25px" }); - - var resp= validateFinalXML(unformatted_xml_str); - console.log("errorList:" + errList); - if(!resp){ - showErrors(); - } - target.text("Validate XML"); - target.css({ "background-image": "none" }); - }, - "Email Flow" : function (event) { - if(!event) event = window.event; - var target = $(event.target); - target.text("Processing"); - target.css({ "background-image": "url('images/page-loading.gif')" }); - target.css({ "background-repeat": "no-repeat" }); - target.css({ "background-size": "25px 25px" }); - d3.xhr("style.css").get(function(err,resp){ - console.log("resp:" + resp); - //console.dir(resp); - var styleSheetText = resp.responseText; - /*var htmlCode = "<style>" + styleSheetText + "</style></head>" + - '<body><div id="chart" class="ui-droppable">' + - */ - //var svgTagInfo = '<div style="overflow:auto;border:1px solid #D76D2D;height:600px;"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 1024 768" preserveAspectRatio="xMidYMid meet">'; - //var svgTagInfo = '<div style="overflow-x:auto;overflow-y:auto;border:1px solid #D76D2D;width:1200px;height:750px;"> <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="3500px" height="3200px" viewBox="0 0 5500 5000" >'; - var svgTagInfo = '<div style="overflow-x:auto;overflow-y:auto;border:1px solid #D76D2D;width:1200px;height:750px;"> <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="3500px" height="3200px" viewBox="0 0 8000 7500" >'; - var svgHtmlCode = $("svg").html(); - //svgHtmlCode = svgHtmlCode.replace('<rect width="5000" height="5000"','<rect width="' + maxX + '" height="' + maxY +'"'); - var find = 'href="icons/arrow-in.png"'; - var re = new RegExp(find, 'g'); - svgHtmlCode = svgHtmlCode.replace(re, 'href=""'); - find = 'href="icons/inject.png"'; - re = new RegExp(find, 'g'); - svgHtmlCode = svgHtmlCode.replace(re, 'href=""'); - htmlCode = "\n<style>\n" + styleSheetText + "</style></head>\n<body>" + svgTagInfo + svgHtmlCode + "\n</svg></div>"; - //console.log($("svg").html()); - //console.log(htmlCode); - //html,xml,json form id - /* - //using form to submit - var form = $('<form id="hxjFormId" method="POST" action="/sendEmail"></form>'); - form.append('<input id="flowHtmlId" type="hidden" name="flowHtml" value=""/>'); - form.append('<input id="flowXmlId" type="hidden" name="flowXml" value=""/>'); - form.append('<input id="flowJsonId" type="hidden" name="flowJson" value=""/>'); - $("#screenInfoId").append(form); - //console.log($("#screenInfoId").html()); - document.getElementById("flowHtmlId").value=htmlCode; - document.getElementById("flowXmlId").value=formatted_xml; - document.getElementById("flowJsonId").value=formatted_json; - //console.log($("#screenInfoId").html()); - $("#hxjFormId").submit(); - console.log("Submitted."); - */ - var reqData = { - "flowHtml" : htmlCode, - "flowXml" : formatted_xml, - "flowJson" : formatted_json - }; - - $.post( "/sendEmail",reqData ) - .done(function( data ) { - //console.log( "Data Loaded: " + data ); - if(data != null && data.envelope != undefined && data.envelope != null){ - var toAddress = data.envelope.to; - RED.notify("Email sent successfully to " + toAddress); - }else{ - RED.notify("Email sent successfully."); - } - }) - .fail(function(err) { - console.log( "error" + err ); - RED.notify("Email send Failed."); - }) - .always(function() { - console.log( "finished" ); - target.text("Email Flow"); - target.css({ "background-image": "none" }); - }); - - /* - d3.xhr("/sendEmail").post(reqData,function(err,resp){ - console.log("Error:" + JSON.stringify(err)); - console.log("resp:" + JSON.stringify(resp)); - console.dir(resp); - }); - */ - }); - }, - /* - Deploy : function () { - $("#btn-deploy").click(); - }, - */ - "Upload XML" : function (event) { - if(!event) event = window.event; - //Save the flows.json - //RED.view.dirty(true); - //$('#btn-deploy').click(); - console.log("Deployed.."); - var target = $(event.target); - target.text("Processing"); - target.css({ "background-image": "url('images/page-loading.gif')" }); - target.css({ "background-repeat": "no-repeat" }); - target.css({ "background-size": "25px 25px" }); - var date = new Date(); - - var fileName = date.getTime() + ".xml"; - var reqData = { - "flowXml" : unformatted_xml_str, - "module" : origModuleName, - "rpc" : origMethodName - }; - $.post("/uploadxml", reqData ) - .done(function( data ) { - console.log("calling uploadxml. sending to server"); - //var successHtmlStr = "<object width='600' height='450' type='text/html' data='" + data.url + "' />"; - - if( data != undefined && data != null && (data.stdout.indexOf('Saving SvcLogicGraph to database') != -1 || data.stderr.indexOf('Saving SvcLogicGraph to database') != -1)){ - //RED.notify("<strong>Uploaded Successfully</strong>"); - //console.dir(data); - var _moduleName = data.module; - var _rpc = data.rpc; - var msg = ""; - var actualMsg = ""; - var msg_lines = ""; - msg_lines += data.stderr; - msg_lines += data.stdout; - - msgHtmlStr="<div><p><b>Uploaded the XML.<br>Additional Details<br><textarea style='width:90%;height:100%' readonly='1' rows='10' cols='90' >" + msg_lines + "</textarea></div>"; - $("#upload-xml-status-dialog").dialog({ - modal:true, - title: "Upload XML ", - width: 900, - height: 750, - minWidth : 600, - minHeight :450, - buttons: [ - { - text: "ViewDGList", - class:"alertDialogButton", - click: function() { - $(this).dialog("close"); - displayCurrentDGs(_moduleName,_rpc,function(htmlStr,dbHost){ - $("#svclogicPageDiv").dialog({ - modal:true, - title:"Service Logic Administration Module=" + _moduleName + " and RPC=" + _rpc, - width: 1200, - height: 750, - minWidth : 600, - minHeight :450, - }).html(htmlStr); - }); - } - }, - { - text: "Close", - class:"alertDialogButton", - click: function() { - $(this).dialog("close"); - } - } - ] - }).html(msgHtmlStr); - }else{ - console.log("Could not upload."); - var emsg =JSON.parse( data.responseText); - var msg = ""; - var actualMsg = ""; - var msg_lines = ""; - if( emsg.stderr != "COMPILE_ERROR"){ - msg = JSON.stringify(emsg.stderr); - actualMsg = msg; - msg = msg.replace('\\t',""); - msg1 = msg.split('\\n'); - for(var k=0;k<=msg1.length && k<=10;k++){ - /* - if(k == 0){ - //msg_lines += "<span style='color:blue'>" + msg1[k] + "</span><br>"; - //msg_lines += msg1[k] +"\n"; - }else{ - if(msg1[k].indexOf("Caused by:") != -1){ - //msg_lines += "<span style='color:red'> " + msg1[k] + "</span><br>"; - msg_lines += msg1[k] ; - break; - } - } - */ - if(msg1[k] != null && msg1[k].indexOf("Caused by:") != -1){ - msg_lines += msg1[k] ; - if((k+1)<=msg1.length){ - msg_lines += "\n" + msg1[k+1] ; - } - if((k+2)<=msg1.length){ - msg_lines += "\n" + msg1[k+2] ; - } - break; - } - } - } - htmlStr="<div><p><b>Could not upload the XML. Status:" + data.status + " Message:" + data.statusText + "</b><br></p><br>Additional Details<br><textarea style='width:90%;height:100%' readonly='1' rows='10' cols='90' >" + msg_lines + "</textarea></div>"; - $("#svclogicPageDiv").dialog({ - modal:true, - title: "Upload XML ", - width: 900, - height: 750, - minWidth : 600, - minHeight :450, - }).html(htmlStr); - } - }) - .fail(function(err) { - //console.log( "error" + JSON.stringify(err) ); - //console.log( JSON.stringify(err.responseText)); - var emsg =JSON.parse( err.responseText); - //console.log( emsg.stderr); - var msg = ""; - var actualMsg = ""; - var msg_lines = ""; - if( emsg != null && emsg.stderr != 'COMPILE_ERROR'){ - msg = JSON.stringify(emsg.stderr); - actualMsg = msg; - //msg = msg.replace("Caused by:","<span style='color:red'>Caused by:</span>"); - msg = msg.replace(/\\t/g,""); - msg1 = msg.split('\\n'); - for(var k=0;k<=msg1.length && k<=msg1.length;k++){ - /* - if(k == 0){ - //msg_lines += "<span style='color:blue'>" + msg1[k] + "</span><br>"; - //msg_lines += msg1[k] + "\n" ; - }else{ - if(msg1[k].indexOf("Caused by:") != -1){ - //msg_lines += "<span style='color:red'> " + msg1[k] + "</span><br>"; - msg_lines += msg1[k] ; - break; - } - } - */ - if(msg1[k] != null && msg1[k].indexOf("Caused by:") != -1){ - msg_lines += msg1[k] ; - if((k+1)<=msg1.length){ - msg_lines += "\n" + msg1[k+1] ; - } - if((k+2)<=msg1.length){ - msg_lines += "\n" + msg1[k+2] ; - } - break; - } - } - }else{ - msg = JSON.stringify(emsg.stdout); - actualMsg = msg; - msg = msg.replace('\\t',""); - msg1 = msg.split('\\n'); - msg_lines=msg1; - } - var htmlStr="<div><p><b>Could not upload the XML. Status:" + err.status + " Message:" + err.statusText + "</b><br></p><br><b>Additional Details</b><br><textarea style='width:90%;height:100%' readonly='1' rows='15' cols='90'>" + msg_lines + "</textarea></div>"; - $("#svclogicPageDiv").dialog({ - modal:true, - title: "Upload XML ", - width: 900, - height: 750, - minWidth : 600, - minHeight :450, - }).html(htmlStr); - //RED.notify("<strong>ERROR:</strong>:" + err,"error"); - }) - .always(function() { - console.log( "finished" ); - target.text("Upload XML"); - target.css({ "background-image": "none" }); - }); - /* - d3.xhr("/uploadxml?fileName=" + fileName).post(function(err,resp) { - if ( resp != null && resp.status == 200) { - RED.notify("<strong>Uploaded Successfully</strong>"); - }else{ - RED.notify("<strong>ERROR:</strong>:" + err,"error"); - console.log(err); - //console.dir(resp); - } - }); - */ - }, - "View DG List": function () { - - displayCurrentDGs(origModuleName,origMethodName,function(htmlStr,dbHost){ - //console.log("htmlStr:" + htmlStr); - $("#svclogicPageDiv").dialog({ - modal:true, - title: "Service Logic Administration for Module=" + origModuleName + " and RPC=" + origMethodName, - width: 1200, - height: 750, - minWidth : 600, - minHeight :450, - }).html(htmlStr); - }); - }, - "Download XML": function () { - $(document).ready(function(){ - errList=[]; - if(moduleName != undefined && moduleName != null && moduleName != ""){ - moduleName=moduleName.replace(/\s/g, "_"); - }else{ - errList.push("Module name is required in the service-logic node."); - } - - if(dgVersion == undefined || dgVersion == null || dgVersion == ""){ - errList.push("Module version is required in the service-logic node."); - } - - if(methodName != undefined && methodName != null && methodName != ""){ - methodName=methodName.replace(/\s/g, "_"); - //formattedMethodName=methodName + "_" + dgVersion; - formattedMethodName=methodName ; - }else{ - errList.push("rpc name is required in the method node."); - } - console.log("Download Xml moduleName:" + moduleName); - console.log("Download Xml methodName:" + formattedMethodName); - - if(errList != null && errList.length > 0 ){ - showErrors(); - return; - } - - $("#dwnldXmlFormId").empty().remove(); - //using form to submit - var form = $('<form id="dwnldXmlFormId" method="POST" action="/downloadXml"></form>'); - form.append('<input id="flowXmlId" type="hidden" name="flowXml"/>'); - form.append('<input type="hidden" name="moduleName" value="' + moduleName + '"/>'); - form.append('<input type="hidden" name="methodName" value="' + formattedMethodName + '"/>'); - form.appendTo('body'); - //$("#flowXmlId").val(formatted_xml); - $("#flowXmlId").val(unformatted_xml_str); - $("#dwnldXmlFormId").submit(); - //console.log("Form submitted."); - }); - }, - "Download JSON": function () { - $(document).ready(function(){ - errList=[]; - if(moduleName != undefined && moduleName != null && moduleName != ""){ - moduleName=moduleName.replace(/\s/g, "_"); - }else{ - errList.push("Module name is required in the service-logic node."); - } - - if(dgVersion == undefined || dgVersion == null || dgVersion == ""){ - errList.push("Module version is required in the service-logic node."); - } - - if(methodName != undefined && methodName != null && methodName != ""){ - methodName=methodName.replace(/\s/g, "_"); - //formattedMethodName=methodName + "_" + dgVersion; - formattedMethodName=methodName ; - }else{ - errList.push("rpc name is required in the method node."); - } - console.log("Download Xml moduleName:" + moduleName); - console.log("Download Xml methodName:" + formattedMethodName); - - if(errList != null && errList.length > 0 ){ - showErrors(); - return; - } - //console.log("formatted_json:" + formatted_json); - $("#dwnldJsonFormId").empty().remove(); - //using form to submit - var form = $('<form id="dwnldJsonFormId" method="POST" action="/downloadJson"></form>'); - form.append('<input id="flowJsonId" type="hidden" name="flowJson" value=""/>'); - form.append('<input type="hidden" name="moduleName" value="' + moduleName + '"/>'); - form.append('<input type="hidden" name="methodName" value="' + formattedMethodName + '"/>'); - form.appendTo('body'); - //$("#flowJsonId").val(formatted_json); - $("#flowJsonId").val(unformatted_json_str); - $("#dwnldJsonFormId").submit(); - //console.log("Form submitted."); - }); - }, - Close: function () { - /* - console.log("clearing the variables."); - htmlCode =""; - formatted_json =""; - formatted_xml =""; - xmlLines =[]; - unformatted_xml_str=""; - unformatted_json_str=""; - */ - $('.ui-dialog:has(#xmldialog)').empty().remove(); - RED.view.redraw(); - - //console.log($("#xmldialog").attr('id')); - //$('.ui-dialog:has(# + $("#xmldialog").attr('id') + ')').empty().remove(); - //$("#xmldialog").hide(); - //$("#xmldialog").dialog("destroy").remove(); - } - }, - open:function (){ - $(function(){ - $("#xmldialog").dialog("widget").find(".ui-dialog-buttonpane").append(xmlInfoStr); - console.log("opened."); - }); - } - }).html(displayHtmlStr).dialog("open"); - - //}).html(displayHtmlStr).dialog("widget").find(".ui-dialog-buttonpane").append(xmlInfoStr); - - //display size and number of lines in XML - //$("#xmldialog").dialog("widget").find(".ui-dialog-buttonpane").append(xmlInfoStr); - - //$("#processingStatusId").html(""); - //This logic is commented as formatting and displaying orion is taking time - //START - /* - var msecs1= Date.now(); - var that = this; - require(["orion/editor/edit"], function(edit) { - that.editor = edit({ - parent:document.getElementById('xmldialog'), - lang:"html", - readonly:true, - //showLinesRuler: false, - contents: formatted_xml - }); - RED.library.create({ - url:"functions", // where to get the data from - type:"function", // the type of object the library is for - editor:that.editor, // the field name the main text body goes to - fields:['name','outputs'] - }); - }); - var msecs2= Date.now(); - //console.log("Time taken for displaying XML:" + (msecs2 - msecs1)); - */ - //END - //var success = customValidation(currentNodeSet); - var success = customValidation(nodeSetWithUpdatedDgNumbers); - if(!success){ - showFlowDesignErrorBox(); - } - $('#processingStatusId').html(""); - }, 0); - } - } - - }); -</script> diff --git a/dgbuilder/nodes/dge/dgemain/dgstart.js b/dgbuilder/nodes/dge/dgemain/dgstart.js deleted file mode 100644 index f2b4815e..00000000 --- a/dgbuilder/nodes/dge/dgemain/dgstart.js +++ /dev/null @@ -1,594 +0,0 @@ -/** - * Copyright 2013 IBM Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - **/ - - -module.exports = function(RED) { - "use strict"; - var util = require("util"); - var vm = require("vm"); - //var dgxml=require("/home/users/schinthakayala/nodered/sheshi/dgxml/dgxml2"); - var _=require('lodash'); - var fs=require('fs'); - var path = require('path'); - var appDir = path.dirname(require.main.filename); - var userDir = appDir + "/" + RED.settings.userDir; - var dbHost = RED.settings.dbHost; - var request = require('request'); - var sharedDir = appDir + "/" + RED.settings.sharedDir; - var xmlDir = appDir + "/" + RED.settings.xmlPath; - - //console.log("appDir:" + appDir); - //var dgeraw=fs.readFileSync(appDir + "/dge.json").toString(); - //var dgejson=JSON.parse(dgeraw); - //var uploadUrl=dgejson.slaHost + dgejson.uploadUrl; - //var slaUrl=dgejson.slaHost + dgejson.slaUrl; - //var uploadUrl=RED.settings.slaHost + RED.settings.uploadUrl; - //var slaUrl=RED.settings.slaHost + RED.settings.slaUrl; - var uploadUrl=""; - var slaUrl=""; - //console.log("Upload url: " + uploadUrl); - - function dgstart(n) { - RED.nodes.createNode(this,n); - this.name = n.name; - this.topic = n.topic; - } - - function writeHtmlToFile(fileName,str){ - var localfile = appDir + "/" + RED.settings.htmlPath + fileName; - try{ - fs.writeFileSync(localfile,str); - }catch(e){ - console.log("Error:" + e); - } - } - - function writeXmlToFile(fileName,str){ - var localfile = appDir + "/" + RED.settings.xmlPath + fileName; - try{ - fs.writeFileSync(localfile,str); - }catch(e){ - console.log("Error:" + e); - } - } - - function sendXml(fileName,res) { - var needle, localfile, data; - needle = require('needle') - localfile = appDir + "/" + RED.settings.xmlPath + fileName; - console.log("localfile:" + localfile); - data={ - uploadedfile: { file: localfile, content_type: 'text/xml' } - } - needle.post(uploadUrl, data, { multipart: true }, function(err, resp, body) { - //console.log(body) - if(resp != undefined && resp != null){ - console.log("resp Code for sendXml:" + resp.statusCode); - } - fs.unlink(localfile, function (error) { - if (error) { - console.log("Error deleting file "+localfile); - }else{ - //console.log("deleted file:" + localfile); - } - }); - - if(err){ - console.log("Error posting to slaUrl:" + slaUrl); - console.log("Error:" +err); - res.json({"error":err}); - }else{ - //console.dir(resp); - //console.log("slaUrl:" + slaUrl); - res.json({"url":slaUrl}); - } - - }); - } - - function oldsendXml(fileName) { - console.log("In sendXML for file: " + fileName); - var fileStream, formdata, localfile; - localfile = appDir + "/" + RED.settings.xmlPath + fileName; - - formdata = { - MAX_FILE_SIZE: "100000", - uploadedfile: { - options: { - contentType: 'audio/mpeg' - } - } - - }; - - console.log("Attempting to upload file: " + localfile); - console.log("Sending to: " + uploadUrl); - formdata.uploadedfile.value = fs.createReadStream(localfile); - fileStream = formdata.uploadedfile.value; - -//console.log("Formdata:"); -//console.dir(formdata); - - request.post({ - url: uploadUrl, - proxy: false, - formData: formdata - }, function(err, resp, body) { - fileStream.close(); - console.log("err: " + err); - return console.log("body: " + body); - }); - - }; - - RED.nodes.registerType("dgstart",dgstart); -/* - RED.httpAdmin.post("/uploadxml", function(req,res) { - console.dir(req); - console.log("USER:" + req.user); - console.log("Got request to upload xml to SDN-C."); - console.log("Requested filename to upload: " + req.params.fileName); - console.log("Requested xml to upload: " + req.params.xmlStr); - writeToFile( req.params.fileName,req.params.xmlStr); - - sendXml(req.params.fileName,res); - // res.send("Attempt complete."); - // res.redirect(slaUrl); - }); -*/ - - RED.httpAdmin.post("/OldUploadxml", function(req,res) { - //console.dir(req); - //console.log("USER:" + req.user); - var qs = require('querystring'); - var body = ''; - req.on('data', function (data) { - body += data; - // Too much POST data, kill the connection! - /*if (body.length > 1e6) - request.connection.destroy(); - */ - }); - req.on('end', function () { - //console.log("BODY:" + body); - var d = new Date().getTime(); - var user = req.user; - var fileName= user + "_" + d +".xml"; - var post = qs.parse(body); - //console.log(JSON.stringify(post)); - // use post['blah'], etc. - var localfile = appDir + "/" + RED.settings.xmlPath + fileName; - //console.log("localfile:" + localfile); - var xmlStr = post['flowXml']; - writeXmlToFile(fileName,xmlStr); - sendXml(fileName,res); - - }); - - }); - - RED.httpAdmin.post("/uploadxml", function(req,res) { - //console.dir(req); - //console.log("USER:" + req.user); - var qs = require('querystring'); - var body = ''; - req.on('data', function (data) { - body += data; - // Too much POST data, kill the connection! - /*if (body.length > 1e6) - request.connection.destroy(); - */ - }); - req.on('end', function () { - //console.log("BODY:" + body); - var d = new Date().getTime(); - var user = req.user; - var fileName= user + "_" + d +".xml"; - var post = qs.parse(body); - //console.log(JSON.stringify(post)); - // use post['blah'], etc. - var localfile = appDir + "/" + RED.settings.xmlPath + fileName; - //console.log("localfile:" + localfile); - var xmlStr = post['flowXml']; - var moduleName = post['module']; - var rpc = post['rpc']; - writeXmlToFile(fileName,xmlStr); - uploadDG(localfile,moduleName,rpc,res); - }); - - }); - - -function uploadDG(filePath,moduleName,rpc,res){ - console.log("called uploadDG..."); - var exec = require('child_process').exec; - var commandToExec = appDir + "/svclogic/svclogic.sh load " + filePath + " " + userDir + "/conf/svclogic.properties"; - console.log("commandToExec:" + commandToExec); - var child = exec(commandToExec ,function (error,stdout,stderr){ - //console.log(error); - console.log("stdout:" + stdout); - console.log("stderr:" + stderr); - if(error){ - console.log("Error occured:" + error); - if(stderr){ - //console.log("stderr:" + stderr); - res.send(500,{'error':error,'stderr':stderr}); - }else{ - res.send(500,{'error':error}); - } - //console.log("stdout :" + stdout); - }else{ - if(stdout ){ - //console.log("output:" + stdout); - if(stdout.indexOf('Compiler error') != -1){ - //console.log("compileError occured."); - - var resp = { - 'stdout':stdout, - 'stderr':"COMPILE_ERROR", - 'url':dbHost, - 'module':moduleName, - 'rpc':rpc - } - res.send(500,resp); - }else{ - res.send(200,{'stdout':stdout,'stderr':stderr,"url":dbHost,"module" : moduleName,"rpc" : rpc}); - } - } - if(stderr && !stdout){ - //console.log("stderr:" + stderr); - if(stderr.indexOf("Saving SvcLogicGraph to database") != -1){ - res.send(200,{'error':error,'stdout' :'','stderr':stderr,"url":dbHost,"module" : moduleName,"rpc" : rpc}); - }else{ - res.send(500,{'error':error,'stdout' :'','stderr':stderr}); - } - } - } - }); -} - - RED.httpAdmin.get("/displayXml", function(req,res) { - var _module = req.query._module; - var rpc = req.query.rpc; - var version = req.query.version; - var mode = req.query.mode; - var d = new Date().getTime(); - displayXml(_module,rpc,version,mode,res); - }); - -function displayXml(_module,rpc,version,mode,res){ - var exec = require('child_process').exec; - var msg = { - '_module' : _module, - 'rpc' : rpc, - 'version' : version, - 'mode' : mode - } - var commandToExec = appDir + "/svclogic/svclogic.sh get-source " + _module + " " - + rpc + " " + mode + " " + version + " " + userDir + "/conf/svclogic.properties"; - console.log("commandToExec:" + commandToExec); - var child = exec(commandToExec ,{'maxBuffer':16*1024*1024},function (error,stdout,stderr){ - if(error){ - console.log("Error occured:" + error); - if(stderr){ - //console.log("stderr:" + stderr); - res.send(500,{'error':error,'stderr':stderr,'msg':msg}); - }else{ - res.send(500,{'error':error,'msg':msg}); - } - }else{ - if(stderr){ - console.log("stderr:" + stderr); - } - if(stdout){ - res.send({'xmldata' : "<xmp>" + stdout + "</xmp>"}); - } - } - }); -} - - - RED.httpAdmin.post("/downloadDGXml", function(req,res) { - //console.dir(req); - var qs = require('querystring'); - var body = ''; - req.on('data', function (data) { - body += data; - }); - - req.on('end', function () { - var post = qs.parse(body); - var _module = post._module; - var rpc = post.rpc; - var version = post.version; - var mode = post.mode; - var d = new Date().getTime(); - downloadDGXml(_module,rpc,version,mode,res); - }); - }); - -function downloadDGXml(_module,rpc,version,mode,res){ - var exec = require('child_process').exec; - var msg = { - '_module' : _module, - 'rpc' : rpc, - 'version' : version, - 'mode' : mode - } - var commandToExec = appDir + "/svclogic/svclogic.sh get-source " + _module + " " - + rpc + " " + mode + " " + version + " " + userDir + "/conf/svclogic.properties"; - console.log("commandToExec:" + commandToExec); - var child = exec(commandToExec ,function (error,stdout,stderr){ - if(error){ - console.log("Error occured:" + error); - if(stderr){ - //console.log("stderr:" + stderr); - res.send(500,{'error':error,'stderr':stderr,'msg':msg}); - }else{ - res.send(500,{'error':error,'msg':msg}); - } - }else{ - if(stderr){ - console.log("stderr:" + stderr); - } - if(stdout){ - //console.log("output:" + stdout); - //var newOutput = "<pre>" + stdout.replace(/\n/g,'<br>') + "</pre>"; - //res.json({'stdout': stdout ,'stderr':stderr,"msg":msg}); - //res.set('Content-Type', 'text/xml'); - //res.set('Content-Type', 'application/octet-stream'); - //res.end("<code>" + stdout + "</code>" ); - //var newOutput ="<html><body>" + stdout + "</body></html>"; - //res.send(new Buffer( "<code>" + newOutput + "</code>" ) ); - //res.send(newOutput); - - /* - var xslStr = '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">' + - '<xsl:output omit-xml-declaration="yes" indent="yes"/>' + - '<xsl:template match="node()|@*">' + - '<xsl:copy>' + - '<xsl:apply-templates select="node()|@*"/>' + - '</xsl:copy>' + - '</xsl:template>' + - '</xsl:stylesheet>'; - */ - - var formatted_date = getCurrentDate(); - var fileName= "db_" + _module + "_" +rpc+ "_" + version + "_" + formatted_date + ".html"; - var file = xmlDir + "/" + fileName; - var xmlStr = '<xmp>' + stdout + "</xmp>"; - //var xmlStr = "<![CDATA[" + stdout + "]]"; - //var xmlStr = stdout.replace(/</g,"<"); - //xmlStr = xmlStr.replace(/>/g,">"); - //xmlStr = xmlStr.replace(/\n>/g,"<br>"); - //xmlStr = xmlStr.replace(/\t>/g," "); - - writeToFile(file,"<html><body>" +xmlStr+ "</body></html>"); - //console.log("xmlStr:" + xmlStr); - res.setHeader('Content-disposition', 'attachment; filename=' + file); - //res.setHeader('Content-type', 'text/html'); - res.setHeader('Content-type', 'text/xml'); - res.download(file); - } - } - }); -} - - - RED.httpAdmin.get("/displayAsGv", function(req,res) { - var _module = req.query._module; - var rpc = req.query.rpc; - var version = req.query.version; - var mode = req.query.mode; - var d = new Date().getTime(); - displayAsGv(_module,rpc,version,mode,res); - }); - -function displayAsGv(_module,rpc,version,mode,res){ - var exec = require('child_process').exec; - var msg = { - '_module' : _module, - 'rpc' : rpc, - 'version' : version, - 'mode' : mode - } - var commandToExec = appDir + "/svclogic/svclogic.sh print " + - _module + " " + rpc + " " + mode + " " + version + " " - //+ userDir + "/conf/svclogic.properties | dot -Tpng "; - //the label="""" is giving an error so replacing it with "null" - + userDir + "/conf/svclogic.properties |sed -e 's%label=\"\"\"\"%label=\"null\"%g'| dot -Tsvg "; - console.log("commandToExec:" + commandToExec); - //+ userDir + "/conf/svclogic.properties | dot -Tsvg "; - //var child = exec(commandToExec ,function (error,stdout,stderr){ - //var child = exec(commandToExec ,{maxBuffer:16*1024*1024},function (error,stdout,stderr){ - //var child = exec(commandToExec ,{encoding:'base64',maxBuffer:20*1024*1024},function (error,stdout,stderr){ - var child = exec(commandToExec ,{maxBuffer:20*1024*1024},function (error,stdout,stderr){ - if(error){ - console.log("Error occured:" + error); - if(stderr){ - console.log("stderr:" + stderr); - res.send(500,{'error':error,'stderr':stderr,"msg":msg}); - }else{ - res.send(500,{'error':error,"msg":msg}); - } - }else{ - if(stderr){ - console.log("stderr:" + stderr); - //To convert base64 to ascii - //console.log(new Buffer(stderr, 'base64').toString('ascii')); - } - if(stdout){ - //console.log(stdout.length); - //console.log("output:" + stdout); - //var svg_html = stdout ; - //var image = "<img src='data:image/png;base64," + stdout + "'>"; - //var image = "<iframe width='1200' height='750' src='data:image/png;base64," + stdout + "'></frame>"; - //var image = "<iframe width='1200' height='750' src='data:image/svg+xml;base64," + stdout + "'></frame>"; - //var image = "<iframe width='1200' height='750' src='data:image/gif;base64," + stdout + "'></frame>"; - var image = "<iframe width='1200' height='750' src='data:image/svg+xml;UTF-8," + stdout + "'></frame>"; - //console.log(image); - res.send({'svg_html':image}); - } - } - }); -} - - RED.httpAdmin.post("/shareFlow", function(req,res) { - //console.dir(req); - //console.log("USER:" + req.user); - var qs = require('querystring'); - var body = ''; - req.on('data', function (data) { - body += data; - // Too much POST data, kill the connection! - /*if (body.length > 1e6) - request.connection.destroy(); - */ - }); - req.on('end', function () { - var post = qs.parse(body); - - var nodeSet = JSON.parse(post['flowData']); - var activeWorkspace=post['activeWorkspace']; - var methodName = ""; - var moduleName = ""; - for(var i=0;nodeSet != null && i<nodeSet.length;i++){ - var node = nodeSet[i]; - if(node.type == 'module' ){ - moduleName= node.name; - moduleName=moduleName.replace(/ /g,"-"); - } - if(node.type == 'method' ){ - methodName= node.name; - methodName=methodName.replace(/ /g,"-"); - } - } - //console.log("BODY:" + body); - var d = new Date().getTime(); - var user = req.user; - var fileName= moduleName + "_" +methodName+".json"; - var localfile = sharedDir + "/" + fileName; - //console.log("localfile:" + localfile); - - writeToFile(localfile,JSON.stringify(nodeSet)); - res.send({"fileName": fileName}); - }); - - }); - - - RED.httpAdmin.post("/sendEmail", function(req,res) { - //console.dir(req); - console.log("USER:" + req.user); - var fromAddr = RED.settings.emailAddress; - var toAddr = RED.settings.emailAddress; - var qs = require('querystring'); - var body = ''; - req.on('data', function (data) { - body += data; - // Too much POST data, kill the connection! - /*if (body.length > 1e6) - request.connection.destroy(); - */ - }); - req.on('end', function () { - //console.log("BODY:" + body); - var d = new Date().getTime(); - var user = req.user; - var fileName= user + "_" + d +".html"; - var post = qs.parse(body); - //console.log(JSON.stringify(post)); - // use post['blah'], etc. - var localfile = appDir + "/" + RED.settings.htmlPath + fileName; - //console.log("localfile:" + localfile); - var nodemailer = require("nodemailer"); - nodemailer.sendmail = true; - var transporter = nodemailer.createTransport(); - var ua = req.headers['user-agent']; - var host = req.headers.host; - var fullHtml="<!doctype html><html><head>" + post['flowHtml']; - //fullHtml+="<div style='fill:both'></div>"; - fullHtml+="<div style='margin-left:10px;'><p>XML</p><br><textarea rows='50' cols='150'>" + post['flowXml'] + "</textarea>"; - fullHtml+="<p>JSON</p><br><textarea rows='50' cols='150'>" + post['flowJson'] + "</textarea></div>"; - fullHtml+="</body></html>"; - writeHtmlToFile(fileName,fullHtml); - - transporter.sendMail({ - from: fromAddr, - to: toAddr, - html: "<p>DG Node Flow. click on the attachment to view</p>", - subject: 'Node flow from Host:<' + host + '>', - attachments : [{'filename': fileName, - 'contentType': "text/html", - /*'filePath': localfile*/ - 'content': fs.createReadStream(localfile) - }] - - }, function(err, response) { - var fullPathtoFileName = appDir + "/" + RED.settings.htmlPath + fileName; - fs.unlink(fullPathtoFileName, function (error) { - if (error) { - console.log("Error deleting file "+fullPathtoFileName); - }else{ - //console.log("deleted file:" + fullPathtoFileName); - } - }); - - if(err){ - console.log("Error:" + err); - res.json(err); - }else{ - res.json(response); - } - console.log(response); - }); - - }); - - - }); -/* - RED.httpAdmin.post("/doxml/:id", function(req,res) { - var node = RED.nodes.getNode(req.params.id); - if (node != null) { - try { - // node.receive(); - //console.log("doxml was called for node: "); - //console.dir(node); - //console.log("calling getJson"); - var nrjson=dgxml.getJson(); - console.log("calling nodered2xml"); - var results=[]; - results=dgxml.nodered2xml(nrjson,node.id); - var nrxml=results[0]; - fileName=results[1]; - console.log("Got this filename: " + fileName); - // res.send(200); - console.log("appDir: " + appDir); - fs.writeFileSync(appDir + "/public/xml/"+fileName,nrxml); - // res.send("XML generated! See help on right for link."); - res.send(fileName); - } catch(err) { - res.send(500); - node.error("doxml failed:"+err); - console.log(err.stack); - } - } else { - res.send(404); - } - }); -*/ -} diff --git a/dgbuilder/nodes/dge/dgemain/method.html b/dgbuilder/nodes/dge/dgemain/method.html deleted file mode 100644 index 134896e7..00000000 --- a/dgbuilder/nodes/dge/dgemain/method.html +++ /dev/null @@ -1,141 +0,0 @@ -<!-- - Copyright 2013 IBM Corp. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - -<script type="text/x-red" data-template-name="method"> - <div class="form-row"> - <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> - <input type="text" id="node-input-name" placeholder="Name"> - </div> - <div class="form-row"> - <label for="node-input-xml"><i class="fa fa-wrench"></i> Node XML</label> - <input type="hidden" id="node-input-xml" autofocus="autofocus"> - <div style="height: 450px;" class="node-text-editor" id="node-input-xml-editor" onkeyup="resetStatus()" ></div> - </div> - <div class="form-row"> - <a href="#" class="btn btn-mini" id="node-input-validate" style="margin-top: 4px;"><b>Validate XML</b></a> - <a href="#" class="btn btn-mini" id="node-input-show-sli-values" style="margin-top: 4px;"><b>Show RPCs</b></a> - <input type="hidden" id="node-input-comments"> - <a href="#" class="btn btn-mini" id="node-input-btnComments" style="margin-top: 4px;"><b>Add Comments</b></a> - <div id="node-validate-result" class="form-tips" style="float:right;font-size:10px"></div> - </div> - <div class="form-tips">See the Info tab for help using this node.</div> -</script> -<script type="text/x-red" data-help-name="method"> - <p>A method node.</p> - <p>Name can be anything.</p> - <p>First line of XML must contain opening tag.</p> - <p>Do not include closing tag - it will be automatically generated.</p> -</script> - -<script type="text/javascript"> - RED.nodes.registerType('method',{ - color:"#fdd0a2", - category: 'DGEmain', - defaults: { - name: {value:"method"}, - xml: {value:"<method rpc='' mode='sync'>\n"}, - comments:{value:""}, - outputs: {value:1} - }, - inputs:1, - outputs:1, - icon: "arrow-in.png", - label: function() { - return this.name; - }, - oneditprepare: function() { - $( "#node-input-outputs" ).spinner({ - min:1 - }); - - var comments = $( "#node-input-comments").val(); - if(comments != null){ - comments = comments.trim(); - if(comments != ''){ - $("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>"); - } - } - - function functionDialogResize(ev,ui) { - $("#node-input-xml-editor").css("height",(ui.size.height-275)+"px"); - }; - - $( "#dialog" ).dialog( "option", "width", 1200 ); - $( "#dialog" ).dialog( "option", "height", 750 ); - $( "#dialog" ).on("dialogresize", functionDialogResize); - $( "#dialog" ).one("dialogopen", function(ev) { - var size = $( "#dialog" ).dialog('option','sizeCache-function'); - if (size) { - functionDialogResize(null,{size:size}); - } - }); - - /* close dialog when ESC is pressed and released */ - $( "#dialog" ).keyup(function(event){ - if(event.which == 27 ) { - $("#node-dialog-cancel").click(); - } - }); - - $( "#dialog" ).one("dialogclose", function(ev,ui) { - var height = $( "#dialog" ).dialog('option','height'); - $( "#dialog" ).off("dialogresize",functionDialogResize); - }); - var that = this; - require(["orion/editor/edit"], function(edit) { - that.editor = edit({ - parent:document.getElementById('node-input-xml-editor'), - lang:"html", - contents: $("#node-input-xml").val() - }); - RED.library.create({ - url:"functions", // where to get the data from - type:"function", // the type of object the library is for - editor:that.editor, // the field name the main text body goes to - fields:['name','outputs'] - }); - $("#node-input-name").focus(); - $("#node-input-validate").click(function(){ - console.log("validate clicked."); - //console.dir(that.editor); - //console.log("getText:" + that.editor.getText()); - var val = that.editor.getText(); - validateXML(val); - }); - $("#node-input-show-sli-values").click(function(){ - //console.log("show Values clicked."); - showRpcsValuesBox(that.editor,rpcValues); - }); - - }); - - //for click of add comments button - $("#node-input-btnComments").click(function(e){ - showCommentsBox(); - }); - }, - oneditsave: function() { - $("#node-input-xml").val(this.editor.getText()); - var resp=validateXML(this.editor.getText()); - if(resp){ - this.status = {fill:"green",shape:"dot",text:"OK"}; - }else{ - this.status = {fill:"red",shape:"dot",text:"ERROR"}; - } - delete this.editor; - } - }); -</script> diff --git a/dgbuilder/nodes/dge/dgemain/method.js b/dgbuilder/nodes/dge/dgemain/method.js deleted file mode 100644 index 6a29bd83..00000000 --- a/dgbuilder/nodes/dge/dgemain/method.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright 2013 IBM Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - **/ - -module.exports = function(RED) { - "use strict"; - var util = require("util"); - var vm = require("vm"); - - function method(n) { - RED.nodes.createNode(this,n); - this.name = n.name; - this.xml = n.xml; - this.topic = n.topic; - } - - RED.nodes.registerType("method",method); - // RED.library.register("method"); -} diff --git a/dgbuilder/nodes/dge/dgemain/serviceLogic.html b/dgbuilder/nodes/dge/dgemain/serviceLogic.html deleted file mode 100644 index ca8ac8c4..00000000 --- a/dgbuilder/nodes/dge/dgemain/serviceLogic.html +++ /dev/null @@ -1,125 +0,0 @@ -<!-- - Copyright 2013 IBM Corp. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - -<script type="text/x-red" data-template-name="service-logic"> - <div class="form-row"> - <!--<label for="node-input-name"><i class="fa"></i> Name</label>--> - <input type="hidden" id="node-input-name" placeholder="Name"> - </div> - <div class="form-row"> - <input type="hidden" id="node-input-xml"> - <label for="node-input-module"><i class="fa"></i>Module</label> - <input type="text" id="node-input-module" autofocus="autofocus"> - <label for="node-input-version"><i class="fa"></i>Version</label> - <input type="text" id="node-input-version"> - <input type="hidden" id="node-input-comments"> - <a href="#" class="btn btn-mini" id="node-input-btnComments" style="margin-top: 4px;"><b>Add Comments</b></a> - </div> - <!--<div class="form-tips">See the Info tab for help using this node.</div>--> -</script> - -<script type="text/x-red" data-help-name="service-logic"> - <p>A service-logic node.</p> - <p>Double click the node to configure the module name and the version</p> - -</script> - -<script type="text/javascript"> - RED.nodes.registerType('service-logic',{ - color:"#fdd0a2", - category: 'DGEmain', - defaults: { - name: {value:"service-logic"}, - module: {value:""}, - version: {value:""}, - comments:{value:""}, - xml: {value:"<service-logic xmlns='http://www.onap.org/sdnc/svclogic' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='' version=''>\n"}, - outputs: {value:1} - }, - inputs:1, - outputs:1, - icon: "arrow-in.png", - label: function() { - return this.name; - }, - oneditprepare: function() { - $( "#node-input-outputs" ).spinner({ - min:1 - }); - - var comments = $( "#node-input-comments").val(); - if(comments != null){ - comments = comments.trim(); - if(comments != ''){ - $("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>"); - } - } - - function functionDialogResize(ev,ui) { - //$("#node-input-xml-editor").css("height",(ui.size.height-275)+"px"); - }; - - $( "#dialog" ).on("dialogresize", functionDialogResize); - $( "#dialog" ).one("dialogopen", function(ev) { - var size = $( "#dialog" ).dialog('option','sizeCache-function'); - if (size) { - functionDialogResize(null,{size:size}); - } - }); - - /* close dialog when ESC is pressed and released */ - $( "#dialog" ).keyup(function(event){ - if(event.which == 27 ) { - $("#node-dialog-cancel").click(); - } - }); - - $( "#dialog" ).one("dialogclose", function(ev,ui) { - var height = $( "#dialog" ).dialog('option','height'); - $( "#dialog" ).off("dialogresize",functionDialogResize); - }); - - $("#node-input-module").focus(); - - //for click of add comments button - $("#node-input-btnComments").click(function(e){ - showCommentsBox(); - }); - }, - oneditsave: function() { - var module = $("#node-input-module").val(); - if(module == null){ - module=''; - } - var version = $("#node-input-version").val(); - if(version == null){ - version=''; - } - console.log("module:" + module); - console.log("version:" + version); - //xmlStr= xmlStr.replace("$MODULE",module); - //xmlStr= xmlStr.replace("$VERSION",version); - var xmlVal = "<service-logic xmlns='http://www.onap.org/sdnc/svclogic' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='" + module + "' version='" + version + "'>" - $("#node-input-xml").val(xmlVal); - if(module == "" || version == ""){ - this.status = {fill:"red",shape:"dot",text:"Not configured"}; - }else{ - this.status = {fill:"green",shape:"dot",text:"configured"}; - $("#node-input-name").val(module + " " + version); - } - } - }); -</script> diff --git a/dgbuilder/nodes/dge/dgemain/serviceLogic.js b/dgbuilder/nodes/dge/dgemain/serviceLogic.js deleted file mode 100644 index a5e77e4e..00000000 --- a/dgbuilder/nodes/dge/dgemain/serviceLogic.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright 2013 IBM Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - **/ - -module.exports = function(RED) { - "use strict"; - var util = require("util"); - var vm = require("vm"); - - function serviceLogic(n) { - RED.nodes.createNode(this,n); - this.name = n.name; - this.xml = n.xml; - this.topic = n.topic; - } - - RED.nodes.registerType("service-logic",serviceLogic); - // RED.library.register("service-logic"); -} |