X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=static%2Fsrc%2Finstancehandler%2Finstance_list.js;h=eed9d96333ca6b64fac15aaf74e5ab095b2c0410;hb=2ad37de399d1f309e265c060349ce44f80d8f480;hp=161cc51bcda803a1432ba6e7793968e260450a3d;hpb=fb37bca4b7e8178c65df2f1496afe372c1d55e78;p=osm%2FLW-UI.git diff --git a/static/src/instancehandler/instance_list.js b/static/src/instancehandler/instance_list.js index 161cc51..eed9d96 100644 --- a/static/src/instancehandler/instance_list.js +++ b/static/src/instancehandler/instance_list.js @@ -19,9 +19,26 @@ function performAction(url) { $('#modal_instance_new_action').modal('show'); } -function deleteNs(url) { +function exportMetricNs(url) { + console.log(url) + $("#formExportMetricNS").attr("action", 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'); +} + +function deleteNs(url, force) { bootbox.confirm("Are you sure want to delete?", function (result) { if (result) { + if(force) + url = url + '?force=true'; location.href = url } }) @@ -59,14 +76,21 @@ 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'); - bootbox.alert("An error occurred while retrieving the information for the NS"); + bootbox.alert("An error occurred while retrieving the information."); } }); } @@ -124,6 +148,74 @@ $(document).ready(function () { processData: false }).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 + }); + }); + }); + + $("#formAlarmNS").submit(function (event) { + event.preventDefault(); //prevent default action + var post_url = $(this).attr("action"); //get form action url + var request_method = $(this).attr("method"); //get form GET/POST method + var form_data = new FormData(this); //Encode form elements for submission + console.log(post_url); + $.ajax({ + url: post_url, + type: request_method, + data: form_data, + headers: { + "Accept": 'application/json' + }, + contentType: false, + processData: false + }).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 + }); + }); + }); + + $("#formExportMetricNS").submit(function (event) { + event.preventDefault(); //prevent default action + var post_url = $(this).attr("action"); //get form action url + var request_method = $(this).attr("method"); //get form GET/POST method + var form_data = new FormData(this); //Encode form elements for submission + console.log(post_url); + $.ajax({ + url: post_url, + type: request_method, + data: form_data, + headers: { + "Accept": 'application/json' + }, + contentType: false, + processData: false + }).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');