1 {% extends
"base.html" %}
8 <link rel=
"stylesheet" href=
"/static/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
10 {% block title_header_big %}
13 {% block left_sidebar %}
15 {% include 'osm/osm_project_left_sidebar.html' %}
20 {% block breadcrumb_body %}
22 <li><a href=
"{% url "wims:list
" %}">VIMS
</a></li>
25 {% block content_body %}
27 {% include 'modal/wim_details.html' %}
28 {% include 'modal/wim_create.html' %}
31 <div class=
"col-md-12">
34 <div class=
"box-header with-border">
35 <h3 class=
"box-title">Registered WIM
</h3>
36 <div class=
"box-tools">
37 <button type=
"button" class=
"btn btn-default" data-container=
"body"
38 data-toggle=
"tooltip" data-placement=
"top" title=
"New PDU"
39 onclick=
"javascript:openModalCreateWIM()">
40 <i class=
"fa fa-plus"></i> <span> New WIM
</span>
44 <div class=
"box-body">
45 <table id=
"wims_table" class=
"table table-bordered table-striped">
51 <th>Operational State
</th>
67 {% block resource_block %}
69 <script src=
"/static/bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
70 <script src=
"/static/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
72 $(document).ready( function () {
73 var table = $('#wims_table').DataTable({
77 "dataSrc": function (json) {
78 return json['datacenters'];
82 console.log(
"no auth");
83 moveToLogin(window.location.pathname);
86 "error": function (hxr, error, thrown) {
95 "render": function (data, type, row) {
101 "render": function (data, type, row) {
107 "render": function (data, type, row) {
108 return row[
"wim_type"];
113 "render": function (data, type, row) {
114 return row[
"_admin"]['operationalState'];
119 "render": function (data, type, row) {
120 return row['description'] || '';
125 "render": function (data, type, row) {
126 return '
<div class=
"btn-group"><button type=
"button" class=
"btn btn-default" ' +
127 '
onclick=
"javascript:showWIM( \''+row['_id'] + '\', \''+row['name'] +'\')" data-toggle=
"tooltip" data-placement=
"top" data-container=
"body" title=
"Show Info">' +
128 '
<i class=
"fa fa-info"></i>' +
130 '
<button type=
"button" class=
"btn btn-default"' +
131 '
onclick=
"javascript:deleteWim(\''+row['_id']+'\', \''+ row["name
"] +'\')" data-toggle=
"tooltip" data-placement=
"top" data-container=
"body" title=
"Delete">' +
132 '
<i class=
"far fa-trash-alt" ></i></button></div>';
140 setInterval(function () {
145 function openModalCreateWIM(){
146 $('#modal_new_wim').modal('show');
148 function deleteWim(wim_id, wim_name) {
149 var url =
"/wims/"+wim_id+
"/delete";
150 bootbox.confirm(
"Are you sure want to delete " + wim_name +
"?", function (result) {
152 var dialog = bootbox.dialog({
153 message: '
<div class=
"text-center"><i class=
"fa fa-spin fa-spinner"></i> Loading...
</div>',
160 contentType:
"application/json;charset=utf-8",
161 success: function (result) {
162 if (result['error'] == true) {
163 dialog.modal('hide');
164 bootbox.alert(
"An error occurred.");
167 dialog.modal('hide');
171 error: function (error) {
172 dialog.modal('hide');
173 bootbox.alert(
"An error occurred.");
180 function showWIM(wim_uuid) {
181 var dialog = bootbox.dialog({
182 message: '
<div class=
"text-center"><i class=
"fa fa-spin fa-spinner"></i> Loading...
</div>',
187 url: '/wims/' + wim_uuid ,
190 contentType:
"application/json;charset=utf-8",
191 success: function (result) {
192 //$('#modal_show_vim_body').empty();
193 var wim = result.wim;
196 $('#modal_show_wim_body').find('span').text('-');
198 $('#' + k).text(wim[k])
201 for (var i in wim['_admin']) {
202 if (i === 'modified' || i === 'created') {
203 //$('#' + i).text(new Date(wim['_admin'][i]*
1000).toUTCString());
204 $('#' + i).text(moment(wim['_admin'][i] *
1000).format('DD/MM/YY hh:mm:ss'));
206 else if (i === 'deployed') {
207 $('#' + i).text(JSON.stringify(wim['_admin'][i]))
210 $('#' + i).text(wim['_admin'][i])
213 dialog.modal('hide');
214 $('#modal_show_wim').modal('show');
217 dialog.modal('hide');
218 bootbox.alert(
"An error occurred while retrieving the WIM info.");
222 error: function (result) {
223 dialog.modal('hide');
224 bootbox.alert(
"An error occurred while retrieving the WIM info.");