| lombardofr | 93770e2 | 2019-08-30 19:37:56 +0200 | [diff] [blame^] | 1 | <!-- |
| 2 | Copyright 2019 ETSI |
| 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 | fb37bca | 2018-05-03 16:20:04 +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 | fb37bca | 2018-05-03 16:20:04 +0200 | [diff] [blame] | 25 | {% endblock %} |
| 26 | {% block title_header_big %} |
| 27 | {{ block.super }} |
| 28 | {% endblock %} |
| 29 | {% block left_sidebar %} |
| 30 | |
| lombardof | 911c9e4 | 2018-06-03 16:52:12 +0200 | [diff] [blame] | 31 | {% include 'osm/osm_project_left_sidebar.html' %} |
| lombardof | fb37bca | 2018-05-03 16:20:04 +0200 | [diff] [blame] | 32 | |
| 33 | {% endblock %} |
| 34 | |
| 35 | |
| 36 | {% block breadcrumb_body %} |
| 37 | {{ block.super }} |
| lombardofr | 2ad37de | 2018-07-18 09:47:28 +0200 | [diff] [blame] | 38 | <li><a href="{% url "vims:list" %}">VIMS</a></li> |
| lombardof | fb37bca | 2018-05-03 16:20:04 +0200 | [diff] [blame] | 39 | {% 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"> |
| lombardofr | 2ad37de | 2018-07-18 09:47:28 +0200 | [diff] [blame] | 52 | <a href='{% url "vims:create" %}' class="btn btn-block btn-primary btn-sm"><i |
| lombardof | fb37bca | 2018-05-03 16:20:04 +0200 | [diff] [blame] | 53 | class="fa fa-plus"></i><span> New VIM</span></a> |
| 54 | </div> |
| 55 | </div> |
| 56 | <div class="box-body"> |
| lombardofr | 45e33ee | 2018-07-18 19:22:37 +0200 | [diff] [blame] | 57 | <table id="vims_table" class="table table-bordered table-striped"> |
| lombardof | fb37bca | 2018-05-03 16:20:04 +0200 | [diff] [blame] | 58 | <thead> |
| 59 | <tr> |
| lombardof | fb37bca | 2018-05-03 16:20:04 +0200 | [diff] [blame] | 60 | <th>Name</th> |
| lombardofr | 45e33ee | 2018-07-18 19:22:37 +0200 | [diff] [blame] | 61 | <th>Identifier</th> |
| lombardof | fb37bca | 2018-05-03 16:20:04 +0200 | [diff] [blame] | 62 | <th>Type</th> |
| 63 | <th>Operational State</th> |
| 64 | <th>Description</th> |
| 65 | <th>Actions</th> |
| 66 | </tr> |
| 67 | </thead> |
| 68 | <tbody> |
| lombardof | fb37bca | 2018-05-03 16:20:04 +0200 | [diff] [blame] | 69 | |
| lombardof | fb37bca | 2018-05-03 16:20:04 +0200 | [diff] [blame] | 70 | </tbody> |
| 71 | </table> |
| 72 | </div> |
| 73 | </div> |
| 74 | </div> |
| 75 | |
| 76 | </div> |
| 77 | {% endblock %} |
| 78 | |
| 79 | {% block resource_block %} |
| 80 | {{ block.super }} |
| lombardofr | e5a130a | 2019-07-15 09:17:59 +0200 | [diff] [blame] | 81 | <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> |
| lombardofr | 45e33ee | 2018-07-18 19:22:37 +0200 | [diff] [blame] | 83 | <script> |
| 84 | $(document).ready( function () { |
| lombardofr | 4908f38 | 2018-09-10 11:36:06 +0200 | [diff] [blame] | 85 | 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 | }, |
| lombardofr | 99a3d35 | 2019-01-06 19:41:34 +0100 | [diff] [blame] | 146 | "targets": 5, |
| 147 | "orderable": false |
| lombardofr | 4908f38 | 2018-09-10 11:36:06 +0200 | [diff] [blame] | 148 | } |
| 149 | ] |
| 150 | }); |
| 151 | |
| 152 | setInterval(function () { |
| 153 | table.ajax.reload(); |
| 154 | }, 10000); |
| 155 | }); |
| lombardofr | 45e33ee | 2018-07-18 19:22:37 +0200 | [diff] [blame] | 156 | </script> |
| lombardof | fb37bca | 2018-05-03 16:20:04 +0200 | [diff] [blame] | 157 | <script> |
| 158 | |
| lombardofr | 4908f38 | 2018-09-10 11:36:06 +0200 | [diff] [blame] | 159 | 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) { |
| lombardof | fb37bca | 2018-05-03 16:20:04 +0200 | [diff] [blame] | 162 | if (result) { |
| lombardofr | c948820 | 2018-07-24 14:38:16 +0200 | [diff] [blame] | 163 | 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 | }); |
| lombardof | fb37bca | 2018-05-03 16:20:04 +0200 | [diff] [blame] | 187 | } |
| 188 | }) |
| 189 | } |
| 190 | </script> |
| 191 | |
| 192 | {% endblock %} |