bug 646 93/7293/1
authorlombardofr <lombardo@everyup.it>
Tue, 12 Mar 2019 14:39:06 +0000 (15:39 +0100)
committerlombardofr <lombardo@everyup.it>
Tue, 12 Mar 2019 14:39:06 +0000 (15:39 +0100)
Change-Id: Ibd5898c58a9a5e1015b6ab350c226d0c29f3ea16
Signed-off-by: lombardofr <lombardo@everyup.it>
lib/osm/osmclient/clientv2.py
packagehandler/views.py
projecthandler/template/project/projectlist.html
static/src/packagehandler/packages_list.js

index 0914fb3..2025277 100644 (file)
@@ -440,9 +440,10 @@ class Client(object):
             log.exception(e)
             result['data'] = str(e)
             return result
-        if r.status_code == requests.codes.ok:
+        if r:
             result['error'] = False
-        result['data'] = Util.json_loads_byteified(r.text)
+        if r.status_code != requests.codes.no_content:
+            result['data'] = Util.json_loads_byteified(r.text)
         return result
 
     def vnfd_delete(self, token, id):
index 9783348..de90737 100644 (file)
@@ -93,25 +93,11 @@ def delete_package(request, package_type=None, package_id=None):
         log.exception(e)
         result = {'error': True, 'data': str(e)}
 
-    url = 'package_list.html'
-    descriptors = {}
-    try:
-        if package_type == 'ns':
-            descriptors = client.nsd_list(user.get_token())
-        elif package_type == 'vnf':
-            descriptors = client.vnfd_list(user.get_token())
-    except Exception as e:
-        log.exception(e)
+    if result['error']:
+        return __response_handler(request, result['data'], url=None, status=result['data']['status'] if 'status' in result['data'] else 500)
+    else:
+        return __response_handler(request, {}, url=None, status=200)
 
-    return __response_handler(request, {
-        'descriptors': descriptors['data'] if descriptors and descriptors['error'] is False else [],
-        'project_id': project_id,
-        'project_type': 'osm',
-        'package_type': package_type,
-        'alert_message': {
-            'success': False if result['error'] is True else True,
-            'message': 'An error occurred while processing your request.' if result and result['error'] is True else "Record deleted successfully"}
-    }, url)
 
 @login_required
 def clone_package(request, package_type=None, package_id=None):
index 17382e4..e8cc77a 100644 (file)
@@ -94,7 +94,7 @@
             "columns": [
                 {
                     "render": function (data, type, row) {
-                       return '<a href="/projects/switch/'+row['name']+'" >'+row['name']+'</a>'
+                       return '<a href="/projects/'+row['name']+'/switch/" >'+row['name']+'</a>'
                     },
                     "targets": 0
                 },
index 20a2159..0eebca6 100644 (file)
@@ -33,7 +33,13 @@ function deletePackage(package_type, package_id, package_name) {
                 },
                 error: function (result) {
                     dialog.modal('hide');
-                    bootbox.alert("An error occurred.");
+                    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
+                    });
                 }
             });
         }
@@ -59,7 +65,13 @@ function clonePackage(package_type, package_id) {
                 },
                 error: function (result) {
                     dialog.modal('hide');
-                    bootbox.alert("An error occurred.");
+                    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
+                    });
                 }
             });
         }