X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=dgbuilder%2Fpublic%2Fred%2Fui%2Fview.js;h=365b93c59051f96c8b9c27427abf0912bb91e856;hb=fc59bbb6279e492dea2fa361c7080163f3f888ea;hp=707bde9e357e9bc38028a7ee05f0ffd6850eb6f7;hpb=6741df81b766bb1dc271c214b923b18f52c20892;p=ccsdk%2Fdistribution.git
diff --git a/dgbuilder/public/red/ui/view.js b/dgbuilder/public/red/ui/view.js
index 707bde9e..365b93c5 100644
--- a/dgbuilder/public/red/ui/view.js
+++ b/dgbuilder/public/red/ui/view.js
@@ -17,6 +17,7 @@
RED.view = (function() {
/* increasing the width and height from 5000 to 7500*/
+var isImportAction = false;
var space_width = 7500,
space_height = 7500,
lineCurveScale = 0.75,
@@ -323,6 +324,7 @@ RED.view = (function() {
}
function canvasMouseDown() {
+ console.log("The state in canvasMouseDown:" + RED.view.state());
if (!mousedown_node && !mousedown_link) {
selected_link = null;
updateSelection();
@@ -480,10 +482,11 @@ RED.view = (function() {
}
}
}
- redraw();
+ redraw();
}
function canvasMouseUp() {
+ console.log("The state in canvasMouseUp:" + RED.view.state());
if (mousedown_node && mouse_mode == RED.state.JOINING) {
drag_line.attr("class", "drag_line_hidden");
}
@@ -534,11 +537,40 @@ RED.view = (function() {
RED.keyboard.remove(/* ESCAPE */ 27);
setDirty(true);
}
- redraw();
- // clear mouse event vars
- resetMouseVars();
+ console.log("isImportAction:" + RED.view.getIsImportAction());
+ if (RED.view.getIsImportAction() === true){
+ RED.view.setIsImportAction(false);
+ console.log("updated isImportAction:" + isImportAction);
+ redraw();
+ // clear mouse event vars
+ resetMouseVars();
+ //save the imported DG
+ try{
+ var obj = getCurrentFlowNodeSet();
+ //console.dir(obj);
+ //console.log("workspace id:" + RED.view.getWorkspace());
+ var dgTabId = RED.view.getWorkspace();
+ console.log("dgTabId:" + dgTabId);
+ $.post("/saveImportedDG",{"importedNodes" :JSON.stringify(obj,null,4),"currTabId": dgTabId})
+ .done(function( data ) {
+ console.log("saved imported DG");
+ })
+ .fail(function(err) {
+ console.log("error saving imported DG");
+ })
+ .always(function() {
+ });
+ }catch(err){
+ console.log(err);
+ }
+ }else{
+ redraw();
+ // clear mouse event vars
+ resetMouseVars();
+ }
}
+
$('#btn-zoom-out').click(function() {zoomOut();});
$('#btn-zoom-zero').click(function() {zoomZero();});
$('#btn-zoom-in').click(function() {zoomIn();});
@@ -1621,6 +1653,8 @@ RED.view = (function() {
RED.keyboard.enable();
}
});
+
+
$( "#node-dialog-delete-workspace" ).dialog({
modal: true,
autoOpen: false,
@@ -1674,6 +1708,12 @@ RED.view = (function() {
getWorkspace: function() {
return activeWorkspace;
},
+ setIsImportAction: function(iaction) {
+ isImportAction = iaction ;
+ },
+ getIsImportAction: function() {
+ return isImportAction ;
+ },
showWorkspace: function(id) {
workspace_tabs.activateTab(id);
},
@@ -1700,7 +1740,7 @@ RED.view = (function() {
$(function() {
var htmlStr= "
";
@@ -2034,6 +2074,192 @@ RED.view = (function() {
RED.nodes.eachNode(function(n) { n.dirty = true;});
redraw();
},
+ diffJsonSinceImportDialog: function diffJsonSinceImportDialog(){
+ var currDGObj = getCurrentFlowNodeSet();
+ var currDGObjStr = JSON.stringify(currDGObj,null,4);
+ //console.log(currDGObjStr);
+ //$(function() {
+var htmlStr = "" +
+ "
" +
+ "
" +
+ "
" +
+"
" +
+
+"" ;
+var origDGFile ="[]";
+var diffStatus = "DG JSON UNCHANGED";
+ $.get("/readFile",{"filePath" : "orig_dgs/" + activeWorkspace })
+ .done(function( data ) {
+ if(data != undefined && data != null && data.output != undefined ){
+ origDGFile= data.output;
+ }
+ })
+ .fail(function(err) {
+ })
+ .always(function() {
+ if(origDGFile != currDGObjStr){
+ diffStatus="DG JSON CHANGED";
+ }
+ htmlStr += "" +
+ origDGFile +
+ "
" +
+ "" +
+ currDGObjStr +
+ "
" ;
+
+//var htmlStr='';
+
+ $("#diff-browser-dialog").dialog({
+ modal:true,
+ autoOpen :false,
+ title: "Json Diff :" + diffStatus,
+ width: 1200,
+ height: 600,
+ minWidth :1200 ,
+ minHeight :600,
+ buttons :[
+ {
+ text: "Close",
+ click: function() {
+ //$( this ).dialog( "close" );
+ $("#diff-browser-dialog").dialog("close");
+ }
+ }
+ ],
+ open:function(){
+ $('#diff-browser-dialog').keypress(function(e) {
+ if (e.keyCode == $.ui.keyCode.ENTER) {
+ $('#diff-browser-dialog').parent().find('.ui-dialog-buttonpane button:first').click();
+ return false;
+ }
+ });
+ }
+ }).dialog('open').html(htmlStr);
+ });
+ //});
+ },
+ diffXmlSinceImportDialog: function diffXmlSinceImportDialog(){
+ var currDGObj = getCurrentFlowNodeSet();
+ //console.dir(currDGObj);
+ var currDGObjStr ="";
+ try{
+ currDGObjStr = getNodeToXml(JSON.stringify(currDGObj));
+ }catch(err){
+ }
+ var curr_formatted_xml = vkbeautify.xml(currDGObjStr);
+ //console.log(curr_formatted_xml);
+ //console.log(currDGObjStr);
+ //$(function() {
+var htmlStr = "" +
+ "
" +
+ "
" +
+ "
" +
+"
" +
+
+"" ;
+var origXmlFile ="";
+var origDGFile ="";
+var diffStatus = "DG XML UNCHANGED";
+ $.get("/readFile",{"filePath" : "orig_dgs/" + activeWorkspace })
+ .done(function( data ) {
+ if(data != undefined && data != null && data.output != undefined ){
+ origDGFile= data.output;
+ try{
+ var origDGObjStr = getNodeToXml(origDGFile);
+ origXmlFile = vkbeautify.xml(origDGObjStr);
+ }catch(err){
+ }
+ }
+ })
+ .fail(function(err) {
+ })
+ .always(function() {
+ if(origXmlFile != curr_formatted_xml){
+ diffStatus = "DG XML CHANGED";
+ }
+ htmlStr += "" +
+ origXmlFile +
+ "
" +
+ "" +
+ curr_formatted_xml +
+ "
" ;
+
+//var htmlStr='';
+
+ $("#diff-browser-dialog").dialog({
+ modal:true,
+ autoOpen :false,
+ title: "XML Diff",
+ width: 1200,
+ height: 600,
+ minWidth : 1200,
+ minHeight :600,
+ buttons :[
+ {
+ text: "Close",
+ click: function() {
+ //$( this ).dialog( "close" );
+ $("#diff-browser-dialog").dialog("close");
+ }
+ }
+ ],
+ open:function(){
+ $('#diff-browser-dialog').keypress(function(e) {
+ if (e.keyCode == $.ui.keyCode.ENTER) {
+ $('#diff-browser-dialog').parent().find('.ui-dialog-buttonpane button:first').click();
+ return false;
+ }
+ });
+ }
+ }).dialog('open').html(htmlStr);
+ });
+ //});
+ },
showNodePalette: function(s) {
showNodePalette=s;
if(!s){
@@ -2044,10 +2270,10 @@ RED.view = (function() {
}
//console.log("showNodePalette:" + showNodePalette);
},
-
//TODO: should these move to an import/export module?
showImportNodesDialog: showImportNodesDialog,
showExportNodesDialog: showExportNodesDialog,
showExportNodesLibraryDialog: showExportNodesLibraryDialog
};
+
})();