| lombardofr | 93770e2 | 2019-08-30 19:37:56 +0200 | [diff] [blame] | 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 | |
| lombardof | a03da5e | 2018-06-02 18:36:44 +0200 | [diff] [blame] | 17 | {% extends "base.html" %} |
| 18 | {% load get %} |
| 19 | {% load staticfiles %} |
| 20 | |
| 21 | |
| 22 | {% block head_block %} |
| 23 | {{ block.super }} |
| lombardofr | e5a130a | 2019-07-15 09:17:59 +0200 | [diff] [blame] | 24 | <link rel="stylesheet" href="/static/node_modules/datatables.net-bs/css/dataTables.bootstrap.min.css"> |
| lombardof | a03da5e | 2018-06-02 18:36:44 +0200 | [diff] [blame] | 25 | |
| 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 }} |
| lombardofr | 2ad37de | 2018-07-18 09:47:28 +0200 | [diff] [blame] | 37 | <li><a href="{% url 'sdns:list' %}">SDN Controllers</a></li> |
| lombardof | a03da5e | 2018-06-02 18:36:44 +0200 | [diff] [blame] | 38 | {% 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"> |
| lombardofr | 2ad37de | 2018-07-18 09:47:28 +0200 | [diff] [blame] | 51 | <a href='{% url "sdns:create" %}' class="btn btn-block btn-primary btn-sm"><i |
| lombardof | a03da5e | 2018-06-02 18:36:44 +0200 | [diff] [blame] | 52 | class="fa fa-plus"></i><span> New SDN Controller</span></a> |
| 53 | </div> |
| 54 | </div> |
| 55 | <div class="box-body"> |
| lombardofr | 45e33ee | 2018-07-18 19:22:37 +0200 | [diff] [blame] | 56 | <table id="sdns_table" class="table table-bordered table-striped"> |
| lombardof | a03da5e | 2018-06-02 18:36:44 +0200 | [diff] [blame] | 57 | <thead> |
| 58 | <tr> |
| lombardof | a03da5e | 2018-06-02 18:36:44 +0200 | [diff] [blame] | 59 | <th>Name</th> |
| lombardofr | 45e33ee | 2018-07-18 19:22:37 +0200 | [diff] [blame] | 60 | <th>Identifier</th> |
| lombardof | a03da5e | 2018-06-02 18:36:44 +0200 | [diff] [blame] | 61 | <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> |
| lombardof | a03da5e | 2018-06-02 18:36:44 +0200 | [diff] [blame] | 70 | |
| lombardof | a03da5e | 2018-06-02 18:36:44 +0200 | [diff] [blame] | 71 | </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 --> |
| lombardofr | e5a130a | 2019-07-15 09:17:59 +0200 | [diff] [blame] | 83 | <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> |
| lombardof | a03da5e | 2018-06-02 18:36:44 +0200 | [diff] [blame] | 86 | <script src="/static/src/sdnctrlhandler/sdn_list.js"></script> |
| 87 | |
| lombardofr | 45e33ee | 2018-07-18 19:22:37 +0200 | [diff] [blame] | 88 | <script> |
| 89 | $(document).ready( function () { |
| lombardofr | 4908f38 | 2018-09-10 11:36:06 +0200 | [diff] [blame] | 90 | 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 | }, |
| lombardofr | 99a3d35 | 2019-01-06 19:41:34 +0100 | [diff] [blame] | 158 | "targets": 6, |
| 159 | "orderable": false |
| lombardofr | 4908f38 | 2018-09-10 11:36:06 +0200 | [diff] [blame] | 160 | } |
| 161 | ] |
| 162 | }); |
| 163 | |
| 164 | setInterval(function () { |
| 165 | table.ajax.reload(); |
| 166 | }, 10000); |
| 167 | }); |
| lombardofr | 45e33ee | 2018-07-18 19:22:37 +0200 | [diff] [blame] | 168 | </script> |
| lombardof | a03da5e | 2018-06-02 18:36:44 +0200 | [diff] [blame] | 169 | {% endblock %} |
| 170 | |
| 171 | {% block footer %} |
| 172 | {% include "footer.html" %} |
| 173 | {% endblock %} |