blob: b7bc224eed41d01dc9f4e07b3323035f4f0c9f2c [file] [log] [blame]
lombardofr93770e22019-08-30 19:37:56 +02001<!--
2Copyright 2019 ETSI
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15-->
16
lombardoffb37bca2018-05-03 16:20:04 +020017{% extends "base.html" %}
18{% load get %}
19{% load staticfiles %}
20
21
22{% block head_block %}
23 {{ block.super }}
lombardofre5a130a2019-07-15 09:17:59 +020024 <link rel="stylesheet" href="/static/node_modules/datatables.net-bs/css/dataTables.bootstrap.min.css">
lombardoffb37bca2018-05-03 16:20:04 +020025{% endblock %}
26{% block title_header_big %}
27 {{ block.super }}
28{% endblock %}
29{% block left_sidebar %}
30
lombardof911c9e42018-06-03 16:52:12 +020031 {% include 'osm/osm_project_left_sidebar.html' %}
lombardoffb37bca2018-05-03 16:20:04 +020032
33{% endblock %}
34
35
36{% block breadcrumb_body %}
37 {{ block.super }}
lombardofr2ad37de2018-07-18 09:47:28 +020038 <li><a href="{% url "vims:list" %}">VIMS</a></li>
lombardoffb37bca2018-05-03 16:20:04 +020039{% endblock %}
40
41{% block content_body %}
42 {{ block.super }}
43 {% include 'modal/vim_details.html' %}
44 {% csrf_token %}
45 <div class="row">
46 <div class="col-md-12">
47
48 <div class="box">
49 <div class="box-header with-border">
50 <h3 class="box-title">Registered VIM</h3>
51 <div class="box-tools">
lombardofr2ad37de2018-07-18 09:47:28 +020052 <a href='{% url "vims:create" %}' class="btn btn-block btn-primary btn-sm"><i
lombardoffb37bca2018-05-03 16:20:04 +020053 class="fa fa-plus"></i><span> New VIM</span></a>
54 </div>
55 </div>
56 <div class="box-body">
lombardofr45e33ee2018-07-18 19:22:37 +020057 <table id="vims_table" class="table table-bordered table-striped">
lombardoffb37bca2018-05-03 16:20:04 +020058 <thead>
59 <tr>
lombardoffb37bca2018-05-03 16:20:04 +020060 <th>Name</th>
lombardofr45e33ee2018-07-18 19:22:37 +020061 <th>Identifier</th>
lombardoffb37bca2018-05-03 16:20:04 +020062 <th>Type</th>
63 <th>Operational State</th>
64 <th>Description</th>
65 <th>Actions</th>
66 </tr>
67 </thead>
68 <tbody>
lombardoffb37bca2018-05-03 16:20:04 +020069
lombardoffb37bca2018-05-03 16:20:04 +020070 </tbody>
71 </table>
72 </div>
73 </div>
74 </div>
75
76 </div>
77{% endblock %}
78
79{% block resource_block %}
80 {{ block.super }}
lombardofre5a130a2019-07-15 09:17:59 +020081 <script src="/static/node_modules/datatables.net/js/jquery.dataTables.min.js"></script>
82 <script src="/static/node_modules/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
lombardofr45e33ee2018-07-18 19:22:37 +020083 <script>
84 $(document).ready( function () {
lombardofr4908f382018-09-10 11:36:06 +020085 var table = $('#vims_table').DataTable({
86 responsive: true,
87 "ajax": {
88 "url": "/vims/list/",
89 "dataSrc": function (json) {
90 return json['datacenters'];
91 },
92 statusCode: {
93 401: function () {
94 console.log("no auth");
95 moveToLogin(window.location.pathname);
96 }
97 },
98 "error": function (hxr, error, thrown) {
99 console.log(hxr)
100 console.log(thrown)
101 console.log(error);
102 }
103
104 },
105 "columns": [
106 {
107 "render": function (data, type, row) {
108 return row["name"];
109 },
110 "targets": 0
111 },
112 {
113 "render": function (data, type, row) {
114 return row['_id'];
115 },
116 "targets": 1
117 },
118 {
119 "render": function (data, type, row) {
120 return row["vim_type"];
121 },
122 "targets": 2
123 },
124 {
125 "render": function (data, type, row) {
126 return row["_admin"]['operationalState'];
127 },
128 "targets": 3
129 },
130 {
131 "render": function (data, type, row) {
132 return row["_admin"]['description'] || '';
133 },
134 "targets": 4
135 },
136 {
137 "render": function (data, type, row) {
138 return '<div class="btn-group"><button type="button" class="btn btn-default" ' +
139 'onclick="location.href=\'/vims/'+row['_id']+'\'" data-toggle="tooltip" data-placement="top" data-container="body" title="Show Info">' +
140 '<i class="fa fa-info"></i>' +
141 '</button> ' +
142 '<button type="button" class="btn btn-default"' +
143 'onclick="javascript:deleteVim(\''+row['_id']+'\', \''+ row["name"] +'\')" data-toggle="tooltip" data-placement="top" data-container="body" title="Delete">' +
144 '<i class="far fa-trash-alt" ></i></button></div>';
145 },
lombardofr99a3d352019-01-06 19:41:34 +0100146 "targets": 5,
147 "orderable": false
lombardofr4908f382018-09-10 11:36:06 +0200148 }
149 ]
150 });
151
152 setInterval(function () {
153 table.ajax.reload();
154 }, 10000);
155 });
lombardofr45e33ee2018-07-18 19:22:37 +0200156 </script>
lombardoffb37bca2018-05-03 16:20:04 +0200157 <script>
158
lombardofr4908f382018-09-10 11:36:06 +0200159 function deleteVim(vim_id, vim_name) {
160 var url = "/vims/"+vim_id+"/delete";
161 bootbox.confirm("Are you sure want to delete " + vim_name + "?", function (result) {
lombardoffb37bca2018-05-03 16:20:04 +0200162 if (result) {
lombardofrc9488202018-07-24 14:38:16 +0200163 var dialog = bootbox.dialog({
164 message: '<div class="text-center"><i class="fa fa-spin fa-spinner"></i> Loading...</div>',
165 closeButton: true
166 });
167 $.ajax({
168 url: url,
169 type: 'GET',
170 dataType: "json",
171 contentType: "application/json;charset=utf-8",
172 success: function (result) {
173 if (result['error'] == true) {
174 dialog.modal('hide');
175 bootbox.alert("An error occurred.");
176 }
177 else {
178 dialog.modal('hide');
179 location.reload();
180 }
181 },
182 error: function (error) {
183 dialog.modal('hide');
184 bootbox.alert("An error occurred.");
185 }
186 });
lombardoffb37bca2018-05-03 16:20:04 +0200187 }
188 })
189 }
190 </script>
191
192{% endblock %}