blob: 2d74bea9c0e947b1495931d8d23f5db82e31fc42 [file] [log] [blame]
lombardofr93770e22019-08-30 19:37:56 +02001<!--
2Copyright 2019 EveryUP srl
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
lombardofa03da5e2018-06-02 18:36:44 +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">
lombardofa03da5e2018-06-02 18:36:44 +020025
26{% endblock %}
27{% block title_header_big %}
28 {{ block.super }}
29{% endblock %}
30{% block left_sidebar %}
31 {% include 'osm/osm_project_left_sidebar.html' %}
32{% endblock %}
33
34
35{% block breadcrumb_body %}
36 {{ block.super }}
lombardofr2ad37de2018-07-18 09:47:28 +020037 <li><a href="{% url 'sdns:list' %}">SDN Controllers</a></li>
lombardofa03da5e2018-06-02 18:36:44 +020038{% endblock %}
39
40{% block content_body %}
41 {{ block.super }}
42 {% include 'modal/sdn_details.html' %}
43 {% csrf_token %}
44 <div class="row">
45 <div class="col-md-12">
46
47 <div class="box">
48 <div class="box-header with-border">
49 <h3 class="box-title">Registered SDN Controllers</h3>
50 <div class="box-tools">
lombardofr2ad37de2018-07-18 09:47:28 +020051 <a href='{% url "sdns:create" %}' class="btn btn-block btn-primary btn-sm"><i
lombardofa03da5e2018-06-02 18:36:44 +020052 class="fa fa-plus"></i><span> New SDN Controller</span></a>
53 </div>
54 </div>
55 <div class="box-body">
lombardofr45e33ee2018-07-18 19:22:37 +020056 <table id="sdns_table" class="table table-bordered table-striped">
lombardofa03da5e2018-06-02 18:36:44 +020057 <thead>
58 <tr>
lombardofa03da5e2018-06-02 18:36:44 +020059 <th>Name</th>
lombardofr45e33ee2018-07-18 19:22:37 +020060 <th>Identifier</th>
lombardofa03da5e2018-06-02 18:36:44 +020061 <th>Type</th>
62 <th>Operational State</th>
63 <th>IP</th>
64 <th>Port</th>
65 <th>Actions</th>
66
67 </tr>
68 </thead>
69 <tbody>
lombardofa03da5e2018-06-02 18:36:44 +020070
lombardofa03da5e2018-06-02 18:36:44 +020071 </tbody>
72 </table>
73 </div>
74 </div>
75 </div>
76
77 </div>
78{% endblock %}
79
80{% block resource_block %}
81 {{ block.super }}
82 <!-- moment JS -->
lombardofre5a130a2019-07-15 09:17:59 +020083 <script src="/static/node_modules/moment/moment.js"></script>
84 <script src="/static/node_modules/datatables.net/js/jquery.dataTables.min.js"></script>
85 <script src="/static/node_modules/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
lombardofa03da5e2018-06-02 18:36:44 +020086 <script src="/static/src/sdnctrlhandler/sdn_list.js"></script>
87
lombardofr45e33ee2018-07-18 19:22:37 +020088 <script>
89 $(document).ready( function () {
lombardofr4908f382018-09-10 11:36:06 +020090 var table = $('#sdns_table').DataTable({
91 responsive: true,
92 "ajax": {
93 "url": "/sdn/list",
94 "dataSrc": function (json) {
95 console.log(json)
96 return json['sdns'];
97 },
98 statusCode: {
99 401: function () {
100 console.log("no auth");
101 moveToLogin(window.location.pathname);
102 }
103 },
104 "error": function (hxr, error, thrown) {
105 console.log(hxr)
106 console.log(thrown)
107 console.log(error);
108 }
109
110 },
111 "columns": [
112 {
113 "render": function (data, type, row) {
114 return row["name"];
115 },
116 "targets": 0
117 },
118 {
119 "render": function (data, type, row) {
120 return row['_id'];
121 },
122 "targets": 1
123 },
124 {
125 "render": function (data, type, row) {
126 return row["type"];
127 },
128 "targets": 2
129 },
130 {
131 "render": function (data, type, row) {
132 return row["_admin"]["operationalState"];
133 },
134 "targets": 3
135 },
136 {
137 "render": function (data, type, row) {
138 return row["ip"];
139 },
140 "targets": 4
141 },
142 {
143 "render": function (data, type, row) {
144 return row["port"];
145 },
146 "targets": 5
147 },
148 {
149 "render": function (data, type, row) {
150 return '<div class="btn-group">' +
151 '<button type="button" class="btn btn-default" ' +
152 'onclick="javascript:showSDN( \''+row['_id'] + '\', \''+row['name'] +'\')" data-toggle="tooltip" data-placement="top" data-container="body" title="Show Info"><i class="fa fa-info"></i>' +
153 '</button>' +
154 '<button type="button" class="btn btn-default"' +
155 'onclick="javascript:deleteSDN(\''+row['_id']+'\', \''+ row["name"] +'\')" data-toggle="tooltip" data-placement="top" data-container="body" title="Delete">' +
156 '<i class="far fa-trash-alt" ></i></button></div>';
157 },
lombardofr99a3d352019-01-06 19:41:34 +0100158 "targets": 6,
159 "orderable": false
lombardofr4908f382018-09-10 11:36:06 +0200160 }
161 ]
162 });
163
164 setInterval(function () {
165 table.ajax.reload();
166 }, 10000);
167 });
lombardofr45e33ee2018-07-18 19:22:37 +0200168 </script>
lombardofa03da5e2018-06-02 18:36:44 +0200169{% endblock %}
170
171{% block footer %}
172 {% include "footer.html" %}
173{% endblock %}