fix error handling nsd/vnd composer; promt for cp-ref

Change-Id: Icbec00681fa1274f7d242505d4f9bf9b3c755c4e
Signed-off-by: lombardofr <lombardo@everyup.it>
diff --git a/static/TopologyComposer/js/model_graph_editor.js b/static/TopologyComposer/js/model_graph_editor.js
index 4afc955..4ec7650 100644
--- a/static/TopologyComposer/js/model_graph_editor.js
+++ b/static/TopologyComposer/js/model_graph_editor.js
@@ -195,8 +195,10 @@
      * @returns {boolean}
      */
     ModelGraphEditor.prototype.updateGraphParams = function (args, success, error) {
+        var self = this;
         var controller = new  TCD3.OsmController();
-        controller.updateGraphParams(args, function(){
+        controller.updateGraphParams(args, function(result){
+            self.updateData(result);
             success && success();
         }, error);
     };
@@ -218,8 +220,9 @@
             if (self.model.layer[current_layer].nodes[node_type].removable.callback) {
                 var c = self.model.callback[self.model.layer[current_layer].nodes[node_type].removable.callback].class;
                 var controller = new  TCD3.OsmController();
-                controller[self.model.layer[current_layer].nodes[node_type].removable.callback](self, node, function () {
-                    self.parent.removeNode.call(self, node);
+                controller[self.model.layer[current_layer].nodes[node_type].removable.callback](self, node, function (result) {
+                    self._deselectAllNodes();
+                    self.updateData(result);
                     success && success();
                 }, error);
             } else {
@@ -263,11 +266,10 @@
                 link.directed_edge = direct_edge;
                 var c = self.model.callback[callback].class;
                 var controller = new  TCD3.OsmController();
-                controller[callback](self, link, function () {
+                controller[callback](self, link, function (result) {
                     self._deselectAllNodes();
-                    self.parent.addLink.call(self, link);
-                    if (success)
-                        success();
+                    self.updateData(result);
+                    success && success();
                 }, error);
             } else {
                 log('addLink: callback undefined in model spec.');
diff --git a/static/src/descriptorhandler/composer.js b/static/src/descriptorhandler/composer.js
index 18072a8..b3d849e 100644
--- a/static/src/descriptorhandler/composer.js
+++ b/static/src/descriptorhandler/composer.js
@@ -141,8 +141,14 @@
 
         graph_editor.addNode(node_information, function () {
             console.log("OK")
-        }, function (error) {
-            showAlert(error)
+        }, function (result) {
+            var data = result.responseJSON;
+            var title = "Error " + (data && data.code ? data.code : 'unknown');
+                var message = data && data.detail ? data.detail : 'No detail available.';
+                bootbox.alert({
+                    title: title,
+                    message: message
+                });
         })
 
     };
@@ -287,7 +293,13 @@
                 palette.append(palette_template)
             },
             error: function (result) {
-                showAlert(result);
+                var data = result.responseJSON;
+                var title = "Error " + (data && data.code ? data.code : 'unknown');
+                var message = data && data.detail ? data.detail : 'No detail available.';
+                bootbox.alert({
+                    title: title,
+                    message: message
+                });
             }
         });
     }
diff --git a/static/src/descriptorhandler/controller.js b/static/src/descriptorhandler/controller.js
index 6285f82..fd22411 100644
--- a/static/src/descriptorhandler/controller.js
+++ b/static/src/descriptorhandler/controller.js
@@ -51,23 +51,29 @@
 
             var vnfd_node = (link.source.info.type === 'vnf') ? link.source : link.target;
             var vld_node = (link.source.info.type === 'ns_vl') ? link.source : link.target;
+            bootbox.prompt("Please insert the vnfd-connection-point-ref:", function(result){
+                if (result){
+                    data_form.append('csrfmiddlewaretoken', getCookie('csrftoken'));
+                    data_form.append('vnfd-connection-point-ref', result);
+                    data_form.append('member-vnf-index-ref', vnfd_node.info.osm['member-vnf-index']);
+                    data_form.append('vnfd-id-ref', vnfd_node.info.osm['vnfd-id-ref']);
+                    data_form.append('vld_id', vld_node.info.osm['id']);
 
-            data_form.append('csrfmiddlewaretoken', getCookie('csrftoken'));
-            data_form.append('vnfd-connection-point-ref', 'cp_temp');
-            data_form.append('member-vnf-index-ref', vnfd_node.info.osm['member-vnf-index']);
-            data_form.append('vnfd-id-ref', vnfd_node.info.osm['vnfd-id-ref']);
-            data_form.append('vld_id', vld_node.info.osm['id']);
+                    $.ajax({
+                        url: '/projects/descriptors/' + desc_type + '/' + desc_id + '/addElement/' + element_type,
+                        type: 'POST',
+                        data: data_form,
+                        cache: false,
+                        contentType: false,
+                        processData: false,
+                        success: success,
+                        error: error
+                    });
+                }
 
-            $.ajax({
-                url: '/projects/descriptors/' + desc_type + '/' + desc_id + '/addElement/' + element_type,
-                type: 'POST',
-                data: data_form,
-                cache: false,
-                contentType: false,
-                processData: false,
-                success: success,
-                error: error
             });
+
+
         }
         else if (desc_type === 'vnfd') {
             if (['vdu', 'cp'].indexOf(link.source.info.type) > -1 && ['vdu', 'cp'].indexOf(link.target.info.type) > -1) {
@@ -78,6 +84,7 @@
                 data_form.append('csrfmiddlewaretoken', getCookie('csrftoken'));
                 data_form.append('vdu_id', vdu_node.info.osm.id);
                 data_form.append('external-connection-point-ref', cp_node.info.osm.name);
+                data_form.append('name',  "eth_" + generateUID());
                 $.ajax({
                     url: '/projects/descriptors/' + desc_type + '/' + desc_id + '/addElement/interface',
                     type: 'POST',
@@ -210,7 +217,7 @@
             var vld_node = (link.source.info.type === 'ns_vl') ? link.source : link.target;
 
             data_form.append('csrfmiddlewaretoken', getCookie('csrftoken'));
-            data_form.append('vnfd-connection-point-ref', 'cp_temp');
+            //data_form.append('vnfd-connection-point-ref', 'cp_temp');
             data_form.append('member-vnf-index-ref', vnfd_node.info.osm['member-vnf-index']);
             data_form.append('vnfd-id-ref', vnfd_node.info.osm['vnfd-id-ref']);
             data_form.append('vld_id', vld_node.info.osm['id']);
diff --git a/static/src/osm_gui_properties.js b/static/src/osm_gui_properties.js
index 0241b34..0060e13 100644
--- a/static/src/osm_gui_properties.js
+++ b/static/src/osm_gui_properties.js
@@ -55,13 +55,13 @@
             "vdur": {
                 "shape": "square",
                 "color": "#cf1c24",
-                "size": 60,
+                "size": 40,
                 "name": "VDUR"
             },
             "vnfr": {
                 "shape": "square",
                 "color": "#605ca8",
-                "size": 60,
+                "size": 40,
                 "name": "VNFR"
             },