X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=static%2Fsrc%2Finstancehandler%2Finstance_list.js;h=c53c0b4a29a0956bb3dc5089a80d40b87b67158f;hb=c9488202684cfc523815b2629239c285efef1253;hp=b4c0edcbccee523740cdb9170b1b8d53b7310156;hpb=99624b5f5ae95b0674f7f5005da04281e49ac5aa;p=osm%2FLW-UI.git diff --git a/static/src/instancehandler/instance_list.js b/static/src/instancehandler/instance_list.js index b4c0edc..c53c0b4 100644 --- a/static/src/instancehandler/instance_list.js +++ b/static/src/instancehandler/instance_list.js @@ -25,6 +25,10 @@ function exportMetricNs(url) { $('#modal_instance_export_metric').modal('show'); } +function showInstanceTopology(url) { + window.location.href = url; +} + function newAlarmNs(url) { $("#formAlarmNS").attr("action", url); $('#modal_instance_new_alarm').modal('show'); @@ -33,9 +37,32 @@ function newAlarmNs(url) { function deleteNs(url, force) { bootbox.confirm("Are you sure want to delete?", function (result) { if (result) { - if(force) + if (force) url = url + '?force=true'; - location.href = url + var dialog = bootbox.dialog({ + message: '
Loading...
', + closeButton: true + }); + $.ajax({ + url: url, + type: 'GET', + dataType: "json", + contentType: "application/json;charset=utf-8", + success: function (result) { + if (result['error'] == true){ + dialog.modal('hide'); + bootbox.alert("An error occurred."); + } + else { + dialog.modal('hide'); + location.reload(); + } + }, + error: function (error) { + dialog.modal('hide'); + bootbox.alert("An error occurred."); + } + }); } }) } @@ -72,10 +99,17 @@ function showInstanceDetails(url_info) { dataType: "json", contentType: "application/json;charset=utf-8", success: function (result) { - editorJSON.setValue(JSON.stringify(result, null, "\t")); - editorJSON.setOption("autoRefresh", true); - dialog.modal('hide'); - $('#modal_show_instance').modal('show'); + + if (result['data'] !== undefined) { + editorJSON.setValue(JSON.stringify(result['data'], null, "\t")); + editorJSON.setOption("autoRefresh", true); + dialog.modal('hide'); + $('#modal_show_instance').modal('show'); + } + else { + dialog.modal('hide'); + bootbox.alert("An error occurred while retrieving the information."); + } }, error: function (result) { dialog.modal('hide'); @@ -135,20 +169,20 @@ $(document).ready(function () { }, contentType: false, processData: false - }).done(function (response,textStatus, jqXHR) { + }).done(function (response, textStatus, jqXHR) { $('#modal_instance_new_action').modal('hide'); bootbox.alert({ - title: "Action", - message: "Action received." - }); - }).fail(function(result){ - var data = result.responseJSON; - var title = "Error " + (data.code ? data.code: 'unknown'); - var message = data.detail ? data.detail: 'No detail available.'; - bootbox.alert({ - title: title, - message: message - }); + title: "Action", + message: "Action received." + }); + }).fail(function (result) { + var data = result.responseJSON; + var title = "Error " + (data.code ? data.code : 'unknown'); + var message = data.detail ? data.detail : 'No detail available.'; + bootbox.alert({ + title: title, + message: message + }); }); }); @@ -167,20 +201,20 @@ $(document).ready(function () { }, contentType: false, processData: false - }).done(function (response,textStatus, jqXHR) { + }).done(function (response, textStatus, jqXHR) { $('#modal_instance_new_action').modal('hide'); bootbox.alert({ - title: "Metric", - message: "Alarm created." - }); - }).fail(function(result){ - var data = result.responseJSON; - var title = "Error " + (data.code ? data.code: 'unknown'); - var message = data.detail ? data.detail: 'No detail available.'; - bootbox.alert({ - title: title, - message: message - }); + title: "Metric", + message: "Alarm created." + }); + }).fail(function (result) { + var data = result.responseJSON; + var title = "Error " + (data.code ? data.code : 'unknown'); + var message = data.detail ? data.detail : 'No detail available.'; + bootbox.alert({ + title: title, + message: message + }); }); }); @@ -199,20 +233,20 @@ $(document).ready(function () { }, contentType: false, processData: false - }).done(function (response,textStatus, jqXHR) { + }).done(function (response, textStatus, jqXHR) { $('#modal_instance_new_action').modal('hide'); bootbox.alert({ - title: "Metric", - message: "Metric exported." - }); - }).fail(function(result){ - var data = result.responseJSON; - var title = "Error " + (data.code ? data.code: 'unknown'); - var message = data.detail ? data.detail: 'No detail available.'; - bootbox.alert({ - title: title, - message: message - }); + title: "Metric", + message: "Metric exported." + }); + }).fail(function (result) { + var data = result.responseJSON; + var title = "Error " + (data.code ? data.code : 'unknown'); + var message = data.detail ? data.detail : 'No detail available.'; + bootbox.alert({ + title: title, + message: message + }); }); });