<link rel="stylesheet" href="/static/bower_components/codemirror/addon/dialog/dialog.css">
<link rel="stylesheet" href="/static/bower_components/codemirror/addon/display/fullscreen.css">
<link rel="stylesheet" href="/static/bower_components/select2/dist/css/select2.min.css">
+ <link rel="stylesheet" href="/static/css/lwuitable.css">
+ <link rel="stylesheet" href="/static/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
{% endblock %}
{% block title_header_big %}
{{ block.super }}
{% block breadcrumb_body %}
{{ block.super }}
- <li><a href="{% url 'projects:instances:list' project_id=project_id type=type %}">Instances</a></li>
+ <li><a href="{% url 'instances:list' type=type %}">{{ type|upper }} Instances</a></li>
{% endblock %}
{% block content_body %}
<div class="row">
<div class="col-md-12">
- <div class="box">
- <div class="box-header with-border">
- <h3 class="box-title">Instances</h3>
-
- <div class="box-tools">
-
- <button type="button" class="btn btn-default" data-container="body"
- data-toggle="tooltip" data-placement="top" title="Instantiate NS"
- onclick="javascript:openModalCreateNS({ 'project_id':'{{project_id}}','vim_list_url': '{% url "vim:list" %}'})" disabled>
- <i class="fa fa-paper-plane"></i> <span> New NS</span></button>
-
- </div>
-
- </div>
- <div class="box-body">
- <table id="instances_table" class="table table-bordered table-striped">
- <thead>
- <tr>
- <th>Id</th>
- <th>Name</th>
- <th>Nsd name</th>
- <th style="width:5%">Operational Status</th>
- <th style="width:5%">Config Status</th>
- <th>Detailed Status</th>
- <th >Actions</th>
- </tr>
- </thead>
- <tbody>
- {% for i in instances %}
- <tr>
-
- <td>{{ i|get:"_id" }}</td>
- <td>{{ i|get:"short-name" }}</td>
- <td>{{ i|get:"nsd-name-ref" }}</td>
-
- {% if i|get:"operational-status" == 'failed' %}
- <td><span class="label label-danger">{{ i|get:"operational-status" }}</span> </td>
- {% elif i|get:"operational-status" == 'init' %}
- <td><span class="label label-warning">{{ i|get:"operational-status" }}</span> </td>
- {% elif i|get:"operational-status" == 'running' %}
- <td><span class="label label-success">{{ i|get:"operational-status" }}</span> </td>
- {% else %}
- <td>{{ i|get:"operational-status" }}</td>
- {% endif %}
- {% if i|get:"config-status" == 'failed' %}
- <td><span class="label label-danger">{{ i|get:"config-status" }}</span> </td>
- {% elif i|get:"config-status" == 'init' %}
- <td><span class="label label-warning">{{ i|get:"config-status" }}</span> </td>
- {% elif i|get:"config-status" == 'running' %}
- <td><span class="label label-success">{{ i|get:"config-status" }}</span> </td>
- {% elif i|get:"config-status" == 'configured' %}
- <td><span class="label label-success">{{ i|get:"config-status" }}</span> </td>
- {% else %}
- <td>{{ i|get:"config-status" }}</td>
- {% endif %}
- <td style=" max-width:1px;overflow:hidden; white-space:nowrap; text-overflow:ellipsis;">{{ i|get:"detailed-status" }}</td>
- <td>
- <div class="btn-group">
- <button type="button" class="btn btn-default"
- onclick="javascript:showInstanceDetails('{% url 'projects:instances:show' instance_id=i|get:'_id' project_id=project_id type=type %}')"
- data-toggle="tooltip" data-placement="top" data-container="body" title="Show Info"><i
- class="fa fa-info"></i>
- </button>
-
- <button type="button" class="btn btn-default"
- onclick="javascript:deleteNs('{% url 'projects:instances:delete' instance_id=i|get:'_id' project_id=project_id type=type %}')"
- data-toggle="tooltip" data-placement="top" data-container="body" title="Delete"><i
- class="fa fa-trash-o"></i></button>
-
- <button type="button" class="btn btn-default dropdown-toggle"
- data-toggle="dropdown" aria-expanded="false">Actions
- <span class="fa fa-caret-down"></span></button>
- <ul class="dropdown-menu">
- <li><a href="#" onclick="javascript:performAction('{% url 'projects:instances:action' instance_id=i|get:'_id' project_id=project_id type=type %}')">
- <i class="fa fa-magic"></i>Exec NS Primitive</a></li>
- <li><a href="{% url 'projects:instances:ns_operations' project_id=project_id type=type instance_id=i|get:'_id'%}"> <i class="fa fa-list"></i>Active operations</a></li>
- </ul>
-
-
- </div>
-
- </td>
-
-
- </tr>
- {% endfor %}
- </tbody>
- </table>
- </div>
- </div>
+ {% if type == 'ns' %}
+ {% include 'instance_list_ns.html' %}
+ {% elif type == 'vnf' %}
+ {% include 'instance_list_vnf.html' %}
+ {% endif %}
+
</div>
</div>
{% include 'modal/instance_create.html' %}
{% include 'modal/instance_show.html' %}
{% include 'modal/instance_new_action.html' %}
+ {% include 'modal/instance_new_alarm.html' %}
+ {% include 'modal/instance_export_metric.html' %}
{% endblock %}
{% block resource_block %}
<script src="/static/bower_components/codemirror/keymap/sublime.js"></script>
<script src="/static/src/instancehandler/instance_list.js"></script>
<script src="/static/src/instancehandler/instance_create.js"></script>
+ <script src="/static/bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
+ <script src="/static/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
+
+ <script>
+ var instance_type = '{{ type }}';
+ var row_builder = {
+ 'ns': [
+ {
+ "render": function (data, type, row) {
+ return row["short-name"];
+ },
+ "targets": 0
+ },
+ {
+ "render": function (data, type, row) {
+ return row["_id"];
+ },
+ "targets": 1
+ },
+ {
+ "render": function (data, type, row) {
+ return row["nsd-name-ref"];
+ },
+ "targets": 2
+ },
+ {
+ // "width": "5%",
+ "render": function (data, type, row) {
+ if(row["operational-status"] === 'failed')
+ return '<span class="label label-danger">'+ row["operational-status"] +'</span>';
+ if(row["operational-status"] === 'init')
+ return '<span class="label label-warning">'+ row["operational-status"] +'</span>';
+ if(row["operational-status"] === 'running')
+ return '<span class="label label-success">'+ row["operational-status"] +'</span>';
+ return ''+row["operational-status"]+'';
+ },
+ "targets": 3
+ },
+ {
+ // "width": "5%",
+ "render": function (data, type, row) {
+ if(row["config-status"] === 'failed')
+ return '<span class="label label-danger">'+ row["config-status"] +'</span>';
+ if(row["config-status"] === 'init')
+ return '<span class="label label-warning">'+ row["config-status"] +'</span>';
+ if(row["config-status"] === 'running')
+ return '<span class="label label-success">'+ row["config-status"] +'</span>';
+ if(row["config-status"] === 'configured')
+ return '<span class="label label-success">'+ row["config-status"] +'</span>';
+ return ''+row["operational-status"]+'';
+ },
+ "targets": 4
+ },
+ {
+ // "className": "ellipsis",
+ "render": function (data, type, row) {
+ return row["detailed-status"];
+ },
+ "targets": 5
+ },{
+ // "width": "10%",
+ "render": function (data, type, row) {
+ return '<div class="btn-group">\n' +
+ ' <button type="button" class="btn btn-default"\n' +
+ ' onclick="javascript:showInstanceDetails(\''+instance_type+'\', \''+row["_id"]+'\')"\n' +
+ ' data-toggle="tooltip" data-placement="top" data-container="body" title="Show Info">\n' +
+ ' <i class="fa fa-info"></i>\n' +
+ ' </button>\n' +
+ ' <button type="button" class="btn btn-default"\n' +
+ ' onclick="javascript:deleteNs(\''+ row["short-name"] +'\', \''+row["_id"]+'\')"\n' +
+ ' data-toggle="tooltip" data-placement="top" data-container="body" title="Delete"><i\n' +
+ ' class="far fa-trash-alt"></i></button>\n' +
+ ' <button type="button" class="btn btn-default dropdown-toggle"\n' +
+ ' data-toggle="dropdown" aria-expanded="false">Actions\n' +
+ ' <span class="fa fa-caret-down"></span></button>\n' +
+ ' <ul class="dropdown-menu">\n' +
+ ' <li><a href="#"\n' +
+ ' onclick="javascript:performAction(\''+ row["short-name"] +'\', \''+row["_id"]+'\')">\n' +
+ ' <i class="fa fa-magic"></i> Exec NS Primitive</a></li>\n' +
+ ' <li>\n' +
+ ' <a href="/instances/ns/' +row["_id"] +'/operation">\n' +
+ ' <i class="fa fa-list"></i> Active operations</a></li>\n' +
+ ' <li class="divider"></li>\n' +
+ ' <li><a href="#"\n' +
+ ' onclick="javascript:newAlarmNs(\''+ row["short-name"] +'\', \''+row["_id"]+'\')">\n' +
+ ' <i class="far fa-bell"></i> New Alarm</a></li>\n' +
+ ' <li><a href="#"\n' +
+ ' onclick="javascript:exportMetricNs(\''+ row["short-name"] +'\', \''+row["_id"]+ '\')">\n' +
+ ' <i class="far fa-chart-bar"></i> Export metric</a></li>\n' +
+ ' <li class="divider"></li>\n' +
+ ' <li>\n' +
+ ' <a href="javascript:deleteNs(\''+ row["short-name"] +'\', \''+row["_id"]+'\', true)">\n' +
+ ' <i class="far fa-trash-alt" style="color:red" ></i> Force delete</a></li>\n' +
+ ' </ul>\n' +
+ '</div>';
+ },
+ "targets": 5
+ },
+
+ ],
+ 'vnf': [ {
+ "render": function (data, type, row) {
+ return row["_id"];
+ },
+ "targets": 0
+ },
+ {
+ "render": function (data, type, row) {
+ return '<a href="javascript:openDescriptorView(\'vnfd\', \'' + row["_id"]+'\')"> ' + row["vnfd-ref"] +' </a>';
+ },
+ "targets": 1
+ },
+ {
+ "render": function (data, type, row) {
+ return row["member-vnf-index-ref"];
+ },
+ "targets": 2
+ },
+ {
+ "render": function (data, type, row) {
+ return row["nsr-id-ref"];
+ },
+ "targets": 3
+ },
+ {
+ "render": function (data, type, row) {
+ return moment.unix(row['created-time']).format('YYYY-MM-DD hh:mm:ss a');
+ },
+ "targets": 4
+ },
+ {
+ "render": function (data, type, row) {
+ return '<div class="btn-group">\n' +
+ ' <button type="button" class="btn btn-default"\n' +
+ ' onclick="javascript:showInstanceDetails(\''+instance_type+'\', \''+row["_id"]+'\')"\n' +
+ ' data-toggle="tooltip" data-placement="top" data-container="body" title="Show Info">\n' +
+ ' <i class="fa fa-info"></i>\n' +
+ ' </button>\n' +
+ ' </div>';
+ },
+ "targets": 5
+ },
+ ]
+ };
+ $(document).ready(function () {
+ var table = $('#instances_table').DataTable({
+ responsive: true,
+ "ajax": {
+ "url": "/instances/" + instance_type + "/list/",
+ "dataSrc": function (json) {
+ return json.instances;
+ },
+ statusCode: {
+ 401: function(){
+ console.log("no auth");
+ moveToLogin(window.location.pathname);
+ }
+ },
+ "error": function(hxr, error, thrown){
+ console.log(error);
+ }
+
+ },
+ "columns": row_builder[instance_type]
+ });
+
+
+ setInterval(function () {
+ table.ajax.reload();
+ }, 10000);
+ });
+
+ </script>
{% endblock %}