Network Slice Templates
[osm/LW-UI.git] / static / src / netslicehandler / templates_list.js
1 /*
2 Copyright 2019 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 deleteTemplate(template_name, template_id) {
18 var url = '/netslices/templates/'+template_id+'/delete';
19 bootbox.confirm("Are you sure want to delete " + template_name + "?", function (result) {
20 if (result) {
21 var dialog = bootbox.dialog({
22 message: '<div class="text-center"><i class="fa fa-spin fa-spinner"></i> Loading...</div>',
23 closeButton: true
24 });
25 $.ajax({
26 url: url,
27 type: 'GET',
28 dataType: "json",
29 contentType: "application/json;charset=utf-8",
30 success: function (result) {
31 if (result['error'] == true){
32 dialog.modal('hide');
33 bootbox.alert("An error occurred.");
34 }
35 else {
36 dialog.modal('hide');
37 location.reload();
38 }
39 },
40 error: function (error) {
41 dialog.modal('hide');
42 bootbox.alert("An error occurred.");
43 }
44 });
45 }
46 })
47 }
48
49 function showNstDetails(template_id) {
50 var url_info = '/netslices/templates/'+template_id+'/details';
51 var dialog = bootbox.dialog({
52 message: '<div class="text-center"><i class="fa fa-spin fa-spinner"></i> Loading...</div>',
53 closeButton: true
54 });
55 $.ajax({
56 url: url_info,
57 type: 'GET',
58 dataType: "json",
59 contentType: "application/json;charset=utf-8",
60 success: function (result) {
61 console.log(result)
62 if (result['data'] !== undefined) {
63 editorJSON.setValue(JSON.stringify(result['data'], null, "\t"));
64 editorJSON.setOption("autoRefresh", true);
65 dialog.modal('hide');
66 $('#modal_show_nst').modal('show');
67 }
68 else {
69 dialog.modal('hide');
70 bootbox.alert("An error occurred while retrieving the information.");
71 }
72 },
73 error: function (result) {
74 dialog.modal('hide');
75 bootbox.alert("An error occurred while retrieving the information.");
76 }
77 });
78 }