| lombardof | fb37bca | 2018-05-03 16:20:04 +0200 | [diff] [blame] | 1 | {% extends "base.html" %} |
| 2 | {% load get %} |
| 3 | {% load staticfiles %} |
| 4 | |
| 5 | |
| 6 | {% block head_block %} |
| 7 | {{ block.super }} |
| lombardofr | 45e33ee | 2018-07-18 19:22:37 +0200 | [diff] [blame] | 8 | <link rel="stylesheet" href="/static/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css"> |
| lombardof | fb37bca | 2018-05-03 16:20:04 +0200 | [diff] [blame] | 9 | {% endblock %} |
| 10 | {% block title_header_big %} |
| 11 | {{ block.super }} |
| 12 | {% endblock %} |
| 13 | {% block left_sidebar %} |
| 14 | |
| lombardof | 911c9e4 | 2018-06-03 16:52:12 +0200 | [diff] [blame] | 15 | {% include 'osm/osm_project_left_sidebar.html' %} |
| lombardof | fb37bca | 2018-05-03 16:20:04 +0200 | [diff] [blame] | 16 | |
| 17 | {% endblock %} |
| 18 | |
| 19 | |
| 20 | {% block breadcrumb_body %} |
| 21 | {{ block.super }} |
| lombardofr | 2ad37de | 2018-07-18 09:47:28 +0200 | [diff] [blame] | 22 | <li><a href="{% url "vims:list" %}">VIMS</a></li> |
| lombardof | fb37bca | 2018-05-03 16:20:04 +0200 | [diff] [blame] | 23 | {% endblock %} |
| 24 | |
| 25 | {% block content_body %} |
| 26 | {{ block.super }} |
| 27 | {% include 'modal/vim_details.html' %} |
| 28 | {% csrf_token %} |
| 29 | <div class="row"> |
| 30 | <div class="col-md-12"> |
| 31 | |
| 32 | <div class="box"> |
| 33 | <div class="box-header with-border"> |
| 34 | <h3 class="box-title">Registered VIM</h3> |
| 35 | <div class="box-tools"> |
| lombardofr | 2ad37de | 2018-07-18 09:47:28 +0200 | [diff] [blame] | 36 | <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] | 37 | class="fa fa-plus"></i><span> New VIM</span></a> |
| 38 | </div> |
| 39 | </div> |
| 40 | <div class="box-body"> |
| lombardofr | 45e33ee | 2018-07-18 19:22:37 +0200 | [diff] [blame] | 41 | <table id="vims_table" class="table table-bordered table-striped"> |
| lombardof | fb37bca | 2018-05-03 16:20:04 +0200 | [diff] [blame] | 42 | <thead> |
| 43 | <tr> |
| lombardof | fb37bca | 2018-05-03 16:20:04 +0200 | [diff] [blame] | 44 | <th>Name</th> |
| lombardofr | 45e33ee | 2018-07-18 19:22:37 +0200 | [diff] [blame] | 45 | <th>Identifier</th> |
| lombardof | fb37bca | 2018-05-03 16:20:04 +0200 | [diff] [blame] | 46 | <th>Type</th> |
| 47 | <th>Operational State</th> |
| 48 | <th>Description</th> |
| 49 | <th>Actions</th> |
| 50 | </tr> |
| 51 | </thead> |
| 52 | <tbody> |
| 53 | {% for p in datacenters %} |
| 54 | |
| 55 | <tr> |
| lombardof | fb37bca | 2018-05-03 16:20:04 +0200 | [diff] [blame] | 56 | <td>{{ p|get:"name" }}</td> |
| lombardofr | 45e33ee | 2018-07-18 19:22:37 +0200 | [diff] [blame] | 57 | <td>{{ p|get:"_id" }}</td> |
| lombardof | fb37bca | 2018-05-03 16:20:04 +0200 | [diff] [blame] | 58 | <td>{{ p|get:"vim_type" }}</td> |
| 59 | <td>{{ p|get_sub:"_admin,operationalState"}}</td> |
| 60 | <td>{{ p|get_sub:"_admin,description" }}</td> |
| 61 | |
| 62 | |
| 63 | <td> |
| 64 | <div class="btn-group"> |
| 65 | <button type="button" class="btn btn-default" |
| lombardofr | 2ad37de | 2018-07-18 09:47:28 +0200 | [diff] [blame] | 66 | onclick="location.href='{% url "vims:show" vim_id=p|get:"_id" %}'" data-toggle="tooltip" data-placement="top" data-container="body" title="Show Info"><i |
| lombardof | fb37bca | 2018-05-03 16:20:04 +0200 | [diff] [blame] | 67 | class="fa fa-info"></i></button> |
| 68 | <button type="button" class="btn btn-default" |
| lombardofr | 2ad37de | 2018-07-18 09:47:28 +0200 | [diff] [blame] | 69 | onclick="javascript:deleteVim('{% url "vims:delete" vim_id=p|get:"_id" %}')" data-toggle="tooltip" data-placement="top" data-container="body" title="Delete"><i |
| lombardof | e28478c | 2018-06-07 13:07:27 +0200 | [diff] [blame] | 70 | class="far fa-trash-alt" ></i></button> |
| lombardof | fb37bca | 2018-05-03 16:20:04 +0200 | [diff] [blame] | 71 | </div> |
| 72 | </td> |
| 73 | |
| 74 | </tr> |
| 75 | {% endfor %} |
| 76 | </tbody> |
| 77 | </table> |
| 78 | </div> |
| 79 | </div> |
| 80 | </div> |
| 81 | |
| 82 | </div> |
| 83 | {% endblock %} |
| 84 | |
| 85 | {% block resource_block %} |
| 86 | {{ block.super }} |
| lombardofr | 45e33ee | 2018-07-18 19:22:37 +0200 | [diff] [blame] | 87 | <script src="/static/bower_components/datatables.net/js/jquery.dataTables.min.js"></script> |
| 88 | <script src="/static/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script> |
| 89 | <script> |
| 90 | $(document).ready( function () { |
| 91 | $('#vims_table').DataTable(); |
| 92 | } ); |
| 93 | </script> |
| lombardof | fb37bca | 2018-05-03 16:20:04 +0200 | [diff] [blame] | 94 | <script> |
| 95 | |
| lombardof | 911c9e4 | 2018-06-03 16:52:12 +0200 | [diff] [blame] | 96 | function deleteVim(url) { |
| lombardof | fb37bca | 2018-05-03 16:20:04 +0200 | [diff] [blame] | 97 | bootbox.confirm("Are you sure want to delete?", function (result) { |
| 98 | if (result) { |
| lombardofr | c948820 | 2018-07-24 14:38:16 +0200 | [diff] [blame^] | 99 | var dialog = bootbox.dialog({ |
| 100 | message: '<div class="text-center"><i class="fa fa-spin fa-spinner"></i> Loading...</div>', |
| 101 | closeButton: true |
| 102 | }); |
| 103 | $.ajax({ |
| 104 | url: url, |
| 105 | type: 'GET', |
| 106 | dataType: "json", |
| 107 | contentType: "application/json;charset=utf-8", |
| 108 | success: function (result) { |
| 109 | if (result['error'] == true) { |
| 110 | dialog.modal('hide'); |
| 111 | bootbox.alert("An error occurred."); |
| 112 | } |
| 113 | else { |
| 114 | dialog.modal('hide'); |
| 115 | location.reload(); |
| 116 | } |
| 117 | }, |
| 118 | error: function (error) { |
| 119 | dialog.modal('hide'); |
| 120 | bootbox.alert("An error occurred."); |
| 121 | } |
| 122 | }); |
| lombardof | fb37bca | 2018-05-03 16:20:04 +0200 | [diff] [blame] | 123 | } |
| 124 | }) |
| 125 | } |
| 126 | </script> |
| 127 | |
| 128 | {% endblock %} |