X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=inline;f=static%2Fsrc%2Finstancehandler%2Finstance_list.js;h=db22bc26b03e4b574d03c185c3350f2e0e48aff5;hb=fab2fa4d25c3e0065d3ca8632d0447a782f65448;hp=eed9d96333ca6b64fac15aaf74e5ab095b2c0410;hpb=99f922f1dc8623a444930a621ce3696802d619c0;p=osm%2FLW-UI.git
diff --git a/static/src/instancehandler/instance_list.js b/static/src/instancehandler/instance_list.js
index eed9d96..db22bc2 100644
--- a/static/src/instancehandler/instance_list.js
+++ b/static/src/instancehandler/instance_list.js
@@ -14,32 +14,126 @@
limitations under the License.
*/
-function performAction(url) {
+function performAction(instance_name, instance_id) {
+ var url = '/instances/ns/'+instance_id+'/action';
$("#formActionNS").attr("action", url);
$('#modal_instance_new_action').modal('show');
}
-function exportMetricNs(url) {
- console.log(url)
- $("#formExportMetricNS").attr("action", url);
- $('#modal_instance_export_metric').modal('show');
-}
-
-function showInstanceTopology(url) {
- window.location.href = url;
+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) {
+ 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) {
+ if (result['error'] == true){
+ dialog.modal('hide');
+ bootbox.alert("An error occurred.");
+ }
+ 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 newAlarmNs(url) {
- $("#formAlarmNS").attr("action", url);
- $('#modal_instance_new_alarm').modal('show');
+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 deleteNs(url, force) {
- bootbox.confirm("Are you sure want to delete?", function (result) {
+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) {
- 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');
+ table.ajax.reload();
+ }
+ },
+ error: function (error) {
+ dialog.modal('hide');
+ bootbox.alert("An error occurred.");
+ }
+ });
}
})
}
@@ -50,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('â');
@@ -59,13 +172,19 @@ 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();
};
-function showInstanceDetails(url_info) {
+function showTopology(type, instance_id) {
+ var url = '/instances/'+type+'/'+instance_id+'/topology';
+ window.location = url;
+}
+
+function showInstanceDetails(type, instance_id) {
+ var url_info = '/instances/'+type+'/'+instance_id;
var dialog = bootbox.dialog({
message: ' Loading...
',
closeButton: true
@@ -77,13 +196,13 @@ function showInstanceDetails(url_info) {
contentType: "application/json;charset=utf-8",
success: function (result) {
- if(result['data'] !== undefined) {
+ 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{
+ else {
dialog.modal('hide');
bootbox.alert("An error occurred while retrieving the information.");
}
@@ -128,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,
@@ -146,29 +268,25 @@ $(document).ready(function () {
},
contentType: false,
processData: false
- }).done(function (response,textStatus, jqXHR) {
- $('#modal_instance_new_action').modal('hide');
+ }).done(function (response, textStatus, jqXHR) {
+ table.ajax.reload();
+ $('#modal_new_instance').modal('hide');
+ }).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: "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: title,
+ message: message
+ });
});
});
- $("#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,
@@ -178,24 +296,21 @@ $(document).ready(function () {
},
contentType: false,
processData: false
- }).done(function (response,textStatus, jqXHR) {
- $('#modal_instance_new_action').modal('hide');
+ }).done(function (response, textStatus, jqXHR) {
+ table.ajax.reload();
+ $('#modal_new_pdu').modal('hide');
+ }).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: "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: title,
+ message: message
+ });
});
});
- $("#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
@@ -210,20 +325,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: "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
+ });
});
});