improved ns topology
[osm/LW-UI.git] / static / src / sdnctrlhandler / sdn_list.js
1 /*
2 Copyright 2018 EveryUP srl
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17 function deleteSDN(sdn_uuid, name) {
18 bootbox.confirm("Are you sure want to delete " + name +"?", function (result) {
19 if (result) {
20 var dialog = bootbox.dialog({
21 message: '<div class="text-center"><i class="fa fa-spin fa-spinner"></i> Loading...</div>',
22 closeButton: true
23 });
24 $.ajax({
25 url: '/sdn/' + sdn_uuid + '/delete',
26 type: 'GET',
27 dataType: "json",
28 contentType: "application/json;charset=utf-8",
29 success: function (result) {
30 if (result['error'] == true){
31 dialog.modal('hide');
32 bootbox.alert("An error occurred.");
33 }
34 else {
35 dialog.modal('hide');
36 location.reload();
37 }
38 },
39 error: function (error) {
40 dialog.modal('hide');
41 bootbox.alert("An error occurred.");
42 }
43 });
44 }
45 })
46 }
47
48 function showSDN(sdn_uuid) {
49 var dialog = bootbox.dialog({
50 message: '<div class="text-center"><i class="fa fa-spin fa-spinner"></i> Loading...</div>',
51 closeButton: true
52 });
53
54 $.ajax({
55 url: '/sdn/' + sdn_uuid ,
56 type: 'GET',
57 dataType: "json",
58 contentType: "application/json;charset=utf-8",
59 success: function (result) {
60 //$('#modal_show_vim_body').empty();
61 var sdn = result.sdn;
62 if (sdn) {
63 $('#modal_show_sdn_body').find('span').text('-');
64 for (var k in sdn) {
65 $('#' + k).text(sdn[k])
66 }
67 if (sdn['_admin']) {
68 for (var i in sdn['_admin']) {
69 if (i === 'modified' || i === 'created') {
70 //$('#' + i).text(new Date(sdn['_admin'][i]* 1000).toUTCString());
71 $('#' + i).text(moment(sdn['_admin'][i] * 1000).format('DD/MM/YY hh:mm:ss'));
72 }
73 else if (i === 'deployed') {
74 $('#' + i).text(JSON.stringify(sdn['_admin'][i]))
75 }
76 else
77 $('#' + i).text(sdn['_admin'][i])
78 }
79 }
80 dialog.modal('hide');
81 $('#modal_show_sdn').modal('show');
82 }
83 else {
84 dialog.modal('hide');
85 bootbox.alert("An error occurred while retrieving the SDN controller info.");
86 }
87
88 },
89 error: function (result) {
90 dialog.modal('hide');
91 bootbox.alert("An error occurred while retrieving the SDN controller info.");
92 }
93 });
94
95 }