X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=inline;f=static%2Fsrc%2Finstancehandler%2Finstance_list.js;h=db22bc26b03e4b574d03c185c3350f2e0e48aff5;hb=refs%2Fheads%2Fsol006v331;hp=a2c20036f52b15826f3540e07eecb12d06840c9c;hpb=e6eb7437628e932ef823800b5a8380790a6b22d7;p=osm%2FLW-UI.git
diff --git a/static/src/instancehandler/instance_list.js b/static/src/instancehandler/instance_list.js
index a2c2003..db22bc2 100644
--- a/static/src/instancehandler/instance_list.js
+++ b/static/src/instancehandler/instance_list.js
@@ -20,18 +20,6 @@ function performAction(instance_name, instance_id) {
$('#modal_instance_new_action').modal('show');
}
-function exportMetricNs(instance_name, instance_id) {
- var url = '/instances/ns/'+instance_id+'/monitoring/metric';
- $("#formExportMetricNS").attr("action", url);
- $('#modal_instance_export_metric').modal('show');
-}
-
-function newAlarmNs(instance_name, instance_id) {
- var url = '/instances/ns/'+instance_id+'/monitoring/alarm';
- $("#formAlarmNS").attr("action", url);
- $('#modal_instance_new_alarm').modal('show');
-}
-
function deleteNs(instance_name, instance_id, force) {
var url = '/instances/ns/'+instance_id+'/delete';
bootbox.confirm("Are you sure want to delete " + instance_name + "?", function (result) {
@@ -54,7 +42,91 @@ function deleteNs(instance_name, instance_id, force) {
}
else {
dialog.modal('hide');
- location.reload();
+ table.ajax.reload();
+ }
+ },
+ error: function (result) {
+ dialog.modal('hide');
+ 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
+ });
+ }
+ });
+ }
+ })
+}
+function deleteNsi(instance_name, instance_id, force) {
+ var url = '/instances/nsi/'+instance_id+'/delete';
+ bootbox.confirm("Are you sure want to delete " + instance_name + "?", function (result) {
+ if (result) {
+ if (force)
+ url = url + '?force=true';
+ var dialog = bootbox.dialog({
+ message: '
Loading...
',
+ closeButton: true
+ });
+ $.ajax({
+ url: url,
+ type: 'GET',
+ dataType: "json",
+ contentType: "application/json;charset=utf-8",
+ success: function (result) {
+ console.log(result)
+ if (result['error'] == true){
+ dialog.modal('hide');
+ 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
+ });
+ }
+ else {
+ dialog.modal('hide');
+ table.ajax.reload();
+ }
+ },
+ error: function (result) {
+ dialog.modal('hide');
+ 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
+ });
+ }
+ });
+ }
+ })
+}
+
+function deletePDU(instance_name, instance_id) {
+ var url = '/instances/pdu/'+instance_id+'/delete';
+ bootbox.confirm("Are you sure want to delete " + instance_name + "?", function (result) {
+ if (result) {
+ 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');
+ table.ajax.reload();
}
},
error: function (error) {
@@ -72,6 +144,25 @@ var addFormGroup = function (event) {
var $formGroup = $(this).closest('.form-group');
var $formGroupClone = $formGroup.clone();
+ $formGroupClone.find('input').val('');
+ $formGroupClone.find('button').toggleClass('btn-success btn-add btn-danger btn-remove');
+ $formGroupClone.find('button').text('â');
+ $formGroupClone.insertAfter($formGroup);
+
+};
+
+var removeFormGroup = function (event) {
+ event.preventDefault();
+ var $formGroup = $(this).closest('.form-group');
+ $formGroup.remove();
+};
+
+var addInterfaceGroup = function (event) {
+ event.preventDefault();
+
+ var $formGroup = $(this).closest('.interface-group');
+ var $formGroupClone = $formGroup.clone();
+
$(this)
.toggleClass('btn-success btn-add btn-danger btn-remove')
.html('â');
@@ -81,9 +172,9 @@ var addFormGroup = function (event) {
};
-var removeFormGroup = function (event) {
+var removeInterfaceGroup = function (event) {
event.preventDefault();
- var $formGroup = $(this).closest('.form-group');
+ var $formGroup = $(this).closest('.interface-group');
$formGroup.remove();
};
@@ -156,15 +247,18 @@ $(document).ready(function () {
}, json_editor_settings);
- $(document).on('click', '.btn-add', addFormGroup);
- $(document).on('click', '.btn-remove', removeFormGroup);
+ $(document).on('click', '.primitive-group .btn-add', addFormGroup);
+ $(document).on('click', '.primitive-group .btn-remove', removeFormGroup);
- $("#formActionNS").submit(function (event) {
+ $(document).on('click', '.interface-group .btn-add', addInterfaceGroup);
+ $(document).on('click', '.interface-group .btn-remove', removeInterfaceGroup);
+
+
+ $("#formCreateNS").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,
@@ -175,11 +269,8 @@ $(document).ready(function () {
contentType: false,
processData: false
}).done(function (response, textStatus, jqXHR) {
- $('#modal_instance_new_action').modal('hide');
- bootbox.alert({
- title: "Action",
- message: "Action received."
- });
+ table.ajax.reload();
+ $('#modal_new_instance').modal('hide');
}).fail(function (result) {
var data = result.responseJSON;
var title = "Error " + (data.code ? data.code : 'unknown');
@@ -191,12 +282,11 @@ $(document).ready(function () {
});
});
- $("#formAlarmNS").submit(function (event) {
+ $("#formCreatePDU").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,
@@ -207,11 +297,8 @@ $(document).ready(function () {
contentType: false,
processData: false
}).done(function (response, textStatus, jqXHR) {
- $('#modal_instance_new_action').modal('hide');
- bootbox.alert({
- title: "Metric",
- message: "Alarm created."
- });
+ table.ajax.reload();
+ $('#modal_new_pdu').modal('hide');
}).fail(function (result) {
var data = result.responseJSON;
var title = "Error " + (data.code ? data.code : 'unknown');
@@ -223,7 +310,7 @@ $(document).ready(function () {
});
});
- $("#formExportMetricNS").submit(function (event) {
+ $("#formActionNS").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
@@ -241,8 +328,8 @@ $(document).ready(function () {
}).done(function (response, textStatus, jqXHR) {
$('#modal_instance_new_action').modal('hide');
bootbox.alert({
- title: "Metric",
- message: "Metric exported."
+ title: "Action",
+ message: "Action received."
});
}).fail(function (result) {
var data = result.responseJSON;