Modify nemo-ui(table style changes)
[nemo.git] / nemo-ui / src / main / resources / nemo / js / intentTopo.js
index 139b9c2fa6d117398f97d97f3da6e6f88aca6a1f..6d0ffc579dec3c7f71be135a7d1308beb146b189 100644 (file)
@@ -9,6 +9,7 @@ function getIntentInfos(){
                        dataType: "json",\r
                        success: function(data) {\r
                                console.log(data);\r
+                               IntentInfos=data;\r
                                userData=data;\r
                        },\r
                        error: function(data) {\r
@@ -29,8 +30,8 @@ function getIntentInfos(){
        //return virtualDatas;\r
  }\r
 \r
-getIntentDatas();\r
-\r
+getIntentInfos();\r
+//getIntentDatas();\r
  function getIntentInfoById(user_id,Data){\r
                //console.log(1);\r
        if(!Data) Data=IntentInfos;\r
@@ -53,7 +54,7 @@ getIntentDatas();
  }\r
 \r
  function getIntentInfoByName(user_name,Data){\r
-               //console.log(1);\r
+     console.log(Data);\r
        if(typeof(Data)=='string'){\r
     var user_json = JSON.parse(Data);\r
     }\r
@@ -171,6 +172,8 @@ getIntentDatas();
        }\r
 \r
        function flow_get_end_name(src_ip, dest_ip) {\r
+               // console.log(src_ip);\r
+               // console.log(dest_ip);\r
                var host_name = ['', ''];\r
                if (typeof(phy_host_ip[src_ip]) != "undefined")\r
                        host_name[0] = phy_host_ip[src_ip];\r
@@ -201,6 +204,8 @@ getIntentDatas();
        function flow_get_group(src_ip, dest_ip) {\r
                var src_host_name = flow_get_end_name(src_ip, dest_ip)[0];\r
                var dest_host_name = flow_get_end_name(src_ip, dest_ip)[1];\r
+               console.log(src_host_name);\r
+               console.log(dest_host_name);\r
                var group_node = ['', ''];\r
                for (var i = 0; i < jQuery("#service_svg2 g").length; i++) {\r
                        host_list = jQuery("#service_svg2 g:eq(" + i + ")").attr("sub").split(",");\r
@@ -226,6 +231,8 @@ getIntentDatas();
        function draw_flow_data(src_ip, dest_ip, flow_name) {\r
                var src_group = flow_get_group(src_ip, dest_ip)[0];\r
                var dest_group = flow_get_group(src_ip, dest_ip)[1];\r
+               console.log(src_group);\r
+               console.log(dest_group);\r
                //get flow count\r
                var flow_count_temp = 0;\r
                while (1) {\r
@@ -249,14 +256,14 @@ getIntentDatas();
 \r
 \r
                //get Radio\r
-               var cir_r = parseInt(jQuery("#" + src_group + " circle:eq(0)").attr("r"));\r
+               var cir_r = parseInt(jQuery("[id='" + src_group + "'] circle:eq(0)").attr("r"));\r
 \r
 \r
                //get circle cx cy\r
-               src_cx = parseInt(jQuery("#" + src_group + " circle:eq(0)").attr("cx"));\r
-               src_cy = parseInt(jQuery("#" + src_group + " circle:eq(0)").attr("cy"));\r
-               dest_cx = parseInt(jQuery("#" + dest_group + " circle:eq(0)").attr("cx"));\r
-               dest_cy = parseInt(jQuery("#" + dest_group + " circle:eq(0)").attr("cy"));\r
+               src_cx = parseInt(jQuery("[id='" + src_group + "'] circle:eq(0)").attr("cx"));\r
+               src_cy = parseInt(jQuery("[id='" + src_group + "'] circle:eq(0)").attr("cy"));\r
+               dest_cx = parseInt(jQuery("[id='" + dest_group + "'] circle:eq(0)").attr("cx"));\r
+               dest_cy = parseInt(jQuery("[id='" + dest_group + "'] circle:eq(0)").attr("cy"));\r
                console.log(src_cx + "  " + src_cy + "  " + dest_cx + "   " + dest_cy);\r
 \r
                //calculate deg\r
@@ -344,13 +351,21 @@ getIntentDatas();
        }\r
 \r
        function draw_connection_data(conn_name, node_name_1, node_name_2, bandwidth) {\r
+               // console.log(conn_name);\r
+               // console.log(node_name_1);\r
+               // console.log(node_name_2);\r
+               // console.log(bandwidth);\r
                if (conn_name != null && typeof(conn_name) != "undefined")\r
                        jQuery("#" + conn_name).remove();\r
                try {\r
-                       var node_cx_1 = jQuery("#" + node_name_1 + "_group").attr("cx");\r
-                       var node_cy_1 = jQuery("#" + node_name_1 + "_group").attr("cy");\r
-                       var node_cx_2 = jQuery("#" + node_name_2 + "_group").attr("cx");\r
-                       var node_cy_2 = jQuery("#" + node_name_2 + "_group").attr("cy");\r
+                       var node_cx_1 = jQuery("[id='" + node_name_1 + "_group']").attr("cx");\r
+                       var node_cy_1 = jQuery("[id='" + node_name_1 + "_group']").attr("cy");\r
+                       var node_cx_2 = jQuery("[id='" + node_name_2 + "_group']").attr("cx");\r
+                       var node_cy_2 = jQuery("[id='" + node_name_2 + "_group']").attr("cy");\r
+                       // console.log(node_cx_1);\r
+                       // console.log(node_cy_1);\r
+                       // console.log(node_cx_2);\r
+                       // console.log(node_cy_2);\r
                        //var g = document.createElementNS('http://www.w3.org/2000/svg', 'g');\r
                        var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\r
                        var path_main = jQuery(path).attr({\r
@@ -442,7 +457,7 @@ getIntentDatas();
                                "stroke-width": 0.8\r
 \r
                        });\r
-                       jQuery(text1).text(node_type);\r
+                       jQuery(text1).text(node_name);\r
                        var text2 = document.createElementNS('http://www.w3.org/2000/svg', 'text');\r
                        var text2_main = jQuery(text2).attr({\r
                                id: node_name + "_title2",\r
@@ -451,7 +466,7 @@ getIntentDatas();
                                fill: "                       ",\r
                                'text-anchor': 'middle'\r
                        });\r
-                       jQuery(text2).text(node_name);\r
+                       jQuery(text2).text(node_type);\r
                        var g_main = jQuery(g).append(inCircle1_main);\r
                        jQuery(g).append(text1_main);\r
                        jQuery(g).append(text2_main);\r
@@ -503,7 +518,7 @@ getIntentDatas();
                                "stroke": "black",\r
                                "stroke-width": 0.8\r
                        });\r
-                       jQuery(text1).text(node_type);\r
+                       jQuery(text1).text(node_name);\r
                        var text2 = document.createElementNS('http://www.w3.org/2000/svg', 'text');\r
                        var text2_main = jQuery(text2).attr({\r
                                id: node_name + "_title2",\r
@@ -512,7 +527,7 @@ getIntentDatas();
                                fill: "black",\r
                                'text-anchor': 'middle'\r
                        });\r
-                       jQuery(text2).text(node_name);\r
+                       jQuery(text2).text(node_type);\r
                        var text3 = document.createElementNS('http://www.w3.org/2000/svg', 'text');\r
                        var text3_main = jQuery(text3).attr({\r
                                id: node_list[0] + '_text',\r
@@ -529,9 +544,10 @@ getIntentDatas();
                        jQuery(g).append(text3_main);\r
                        jQuery(g).attr("id", node_name);\r
                        jQuery(g).attr("type", node_type);\r
-                       jQuery(g).attr("sub", node_list[0]);\r
+                       jQuery(g).attr("sub", node_name,node_list[0]);\r
                        if (node_type.indexOf("chain") > -1)\r
                                jQuery(g).attr("flow", 0);\r
+                       if(ip) jQuery(g).attr("ip-prefix", ip);\r
                        jQuery('#service_svg2').append(g_main);\r
                } else if (node_number == 2) {\r
                        var g = document.createElementNS('http://www.w3.org/2000/svg', 'g');\r
@@ -577,7 +593,7 @@ getIntentDatas();
                                "stroke": "black",\r
                                "stroke-width": 0.8\r
                        });\r
-                       jQuery(text1).text(node_type);\r
+                       jQuery(text1).text(node_name);\r
                        var text2 = document.createElementNS('http://www.w3.org/2000/svg', 'text');\r
                        var text2_main = jQuery(text2).attr({\r
                                id: node_name + "_title2",\r
@@ -586,7 +602,7 @@ getIntentDatas();
                                fill: "black",\r
                                'text-anchor': 'middle'\r
                        });\r
-                       jQuery(text2).text(node_name);\r
+                       jQuery(text2).text(node_type);\r
                        var text3 = document.createElementNS('http://www.w3.org/2000/svg', 'text');\r
                        var text3_main = jQuery(text3).attr({\r
                                id: node_list[0] + "_text",\r
@@ -614,13 +630,13 @@ getIntentDatas();
                        jQuery(g).append(text4_main);\r
                        jQuery(g).attr("id", node_name);\r
                        jQuery(g).attr("type", node_type);\r
-                       jQuery(g).attr("sub", node_list[0] + "," + node_list[1]);\r
+                       jQuery(g).attr("sub", node_name,node_list[0] + "," + node_list[1]);\r
                        if (node_type.indexOf("chain") > -1)\r
                                jQuery(g).attr("flow", 0);\r
+                   if(ip) jQuery(g).attr("ip-prefix", ip);\r
                        jQuery('#service_svg2').append(g);\r
 \r
                } else if (node_number == 3) {\r
-                       var g = document.createElementNS('http://www.w3.org/2000/svg', 'g');\r
                        var g = document.createElementNS('http://www.w3.org/2000/svg', 'g');\r
                        var circle_main = document.createElementNS('http://www.w3.org/2000/svg', 'circle');\r
                        var inCircle1_main = jQuery(circle_main).attr({\r
@@ -675,7 +691,7 @@ getIntentDatas();
                                "stroke": "black",\r
                                "stroke-width": 0.8\r
                        });\r
-                       jQuery(text1).text(node_type);\r
+                       jQuery(text1).text(node_name);\r
                        var text2 = document.createElementNS('http://www.w3.org/2000/svg', 'text');\r
                        var text2_main = jQuery(text2).attr({\r
                                id: node_name + "_title2",\r
@@ -684,7 +700,7 @@ getIntentDatas();
                                fill: "black",\r
                                'text-anchor': 'middle'\r
                        });\r
-                       jQuery(text2).text(node_name);\r
+                       jQuery(text2).text(node_type);\r
                        var text3 = document.createElementNS('http://www.w3.org/2000/svg', 'text');\r
                        var text3_main = jQuery(text3).attr({\r
                                id: node_list[0] + '_text',\r
@@ -723,7 +739,7 @@ getIntentDatas();
                        jQuery(g).append(text5_main);\r
                        jQuery(g).attr("id", node_name);\r
                        jQuery(g).attr("type", node_type);\r
-                       jQuery(g).attr("sub", node_list[0] + "," + node_list[1] + "," + node_list[2]);\r
+                       jQuery(g).attr("sub", node_name,node_list[0] + "," + node_list[1] + "," + node_list[2]);\r
                        if (node_type.indexOf("chain") > -1)\r
                                jQuery(g).attr("flow", 0);\r
                        jQuery('#service_svg2').append(g);\r
@@ -803,7 +819,16 @@ getIntentDatas();
                                sub_list[sub_count] = host_list[user_json_data["node"][lgroup_cursor]["sub-node"][sub_cursor]["node-id"]];\r
                                sub_count++;\r
                        }\r
-                       draw_group_data(user_json_data["node"][lgroup_cursor]["node-name"], sub_list.length, sub_list, user_json_data["node"][lgroup_cursor]["node-type"], "");\r
+                       var ip='';\r
+                       var myProperty=user_json_data["node"][lgroup_cursor]['property'];\r
+                       if(myProperty){\r
+                       for(var item in myProperty){\r
+                               if(myProperty[item]['property-name']=='ip-prefix'){\r
+                                       ip=myProperty[item]['property-values']['string-value'][0]['value'];\r
+                               }\r
+                       }\r
+               }\r
+                       draw_group_data(user_json_data["node"][lgroup_cursor]["node-name"], sub_list.length, sub_list, user_json_data["node"][lgroup_cursor]["node-type"], ip);\r
                        redraw_node_possition_data();\r
                        node_list[user_json_data["node"][lgroup_cursor]["node-id"]] = user_json_data["node"][lgroup_cursor]["node-name"];\r
                }\r
@@ -845,7 +870,7 @@ getIntentDatas();
                for (var conn_cursor in user_json_data["connection"]) {\r
                        var start_name = node_list[user_json_data["connection"][conn_cursor]["end-node"][0]["node-id"]];\r
                        var end_name = node_list[user_json_data["connection"][conn_cursor]["end-node"][1]["node-id"]];\r
-                       var bandwidth\r
+                       var bandwidth;\r
                        if (user_json_data["connection"][conn_cursor]["property"] != null)\r
                                bandwidth = user_json_data["connection"][conn_cursor]["property"][0]["property-values"]["int-value"][0]["value"];\r
                        else\r
@@ -874,10 +899,12 @@ getIntentDatas();
                //operation\r
                if (user_data["operations"] != null) {\r
                        for (var operation_cursor in user_data["operations"]["operation"]) {\r
+                               var myTarget=user_data["operations"]["operation"][operation_cursor]["action"][0]['action-name'];\r
+                               if(myTarget!='go-through') continue;\r
                                var flow_name = flow_list[user_data["operations"]["operation"][operation_cursor]["target-object"]];\r
                                var chain_name = node_list[user_data["operations"]["operation"][operation_cursor]["action"][0]["parameter-values"]["string-value"][0]["value"]];\r
-                               var node_start = jQuery("#" + flow_name).attr("node_start");\r
-                               var node_end = jQuery("#" + flow_name).attr("node_end");\r
+                               var node_start = jQuery("[id='" + flow_name+"']").attr("node_start");\r
+                               var node_end = jQuery("[id='" + flow_name+"']").attr("node_end");\r
                                var c1_flag = 0;\r
                                var c2_flag = 0;\r
                                for (var i = 0; i < jQuery("#service_svg2 path").length; i++) {\r
@@ -907,9 +934,6 @@ getIntentDatas();
                                lead_policy(node_start, chain_name, parseInt(jQuery("#" + flow_name).attr("count")), jQuery("#" + flow_name).attr("stroke"), flow_name + "_1", chain_name, node_start, node_end)\r
                                lead_policy(chain_name, node_end, parseInt(jQuery("#" + flow_name).attr("count")), jQuery("#" + flow_name).attr("stroke"), flow_name + "_2", chain_name, node_start, node_end)\r
                                jQuery("#" + flow_name).remove();\r
-\r
-\r
-\r
                        }\r
 \r
                }\r
@@ -1029,7 +1053,10 @@ getIntentDatas();
                                        if (match && match.length > 0) {\r
                                                nemo_str += " Match ";\r
                                                for (var k in match) {\r
+                                                       if(match[k]["match-item-value"]['string-value'])\r
                                                        nemo_str += match[k]['match-item-name'] + ':"' + match[k]["match-item-value"]['string-value'] + '",';\r
+                                                   else if(match[k]["match-item-value"]['int-value'])\r
+                                                       nemo_str += match[k]['match-item-name'] + ':' + match[k]["match-item-value"]['int-value'] + ',';\r
                                                }\r
                                                nemo_str = nemo_str.substring(0, nemo_str.length - 1);\r
                                        }\r
@@ -1056,7 +1083,10 @@ getIntentDatas();
                                if (action && action.length > 0) {\r
                                        nemo_str += " Action "\r
                                        for (var k in action) {\r
+                                               if(action[k]['action-name']=='go-through')\r
                                                nemo_str += action[k]['action-name'] + ":" + nodes[action[k]['parameter-values']["string-value"][0]['value']] + ',';\r
+                                          if(action[k]['action-name']=='deny')\r
+                                               nemo_str+= action[k]['action-name']+',';\r
                                        }\r
                                        nemo_str = nemo_str.substring(0, nemo_str.length - 1);\r
                                }\r