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
8 http://www.apache.org/licenses/LICENSE-2.0
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.
17 {% extends
"base.html" %}
19 {% load staticfiles %}
22 {% block head_block %}
24 <link rel=
"stylesheet" href=
"/static/node_modules/datatables.net-bs/css/dataTables.bootstrap.min.css">
26 {% block title_header_big %}
29 {% block left_sidebar %}
31 {% include 'osm/osm_project_left_sidebar.html' %}
36 {% block breadcrumb_body %}
38 <li><a href=
"{% url "wims:list
" %}">VIMS
</a></li>
41 {% block content_body %}
43 {% include 'modal/wim_details.html' %}
44 {% include 'modal/wim_create.html' %}
47 <div class=
"col-md-12">
50 <div class=
"box-header with-border">
51 <h3 class=
"box-title">Registered WIM
</h3>
52 <div class=
"box-tools">
53 <button type=
"button" class=
"btn btn-default" data-container=
"body"
54 data-toggle=
"tooltip" data-placement=
"top" title=
"New PDU"
55 onclick=
"javascript:openModalCreateWIM()">
56 <i class=
"fa fa-plus"></i> <span> New WIM
</span>
60 <div class=
"box-body">
61 <table id=
"wims_table" class=
"table table-bordered table-striped">
67 <th>Operational State
</th>
83 {% block resource_block %}
85 <script src=
"/static/node_modules/datatables.net/js/jquery.dataTables.min.js"></script>
86 <script src=
"/static/node_modules/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
88 $(document).ready( function () {
89 var table = $('#wims_table').DataTable({
93 "dataSrc": function (json) {
94 return json['datacenters'];
98 console.log(
"no auth");
99 moveToLogin(window.location.pathname);
102 "error": function (hxr, error, thrown) {
111 "render": function (data, type, row) {
117 "render": function (data, type, row) {
123 "render": function (data, type, row) {
124 return row[
"wim_type"];
129 "render": function (data, type, row) {
130 return row[
"_admin"]['operationalState'];
135 "render": function (data, type, row) {
136 return row['description'] || '';
141 "render": function (data, type, row) {
142 return '
<div class=
"btn-group"><button type=
"button" class=
"btn btn-default" ' +
143 '
onclick=
"javascript:showWIM( \''+row['_id'] + '\', \''+row['name'] +'\')" data-toggle=
"tooltip" data-placement=
"top" data-container=
"body" title=
"Show Info">' +
144 '
<i class=
"fa fa-info"></i>' +
146 '
<button type=
"button" class=
"btn btn-default"' +
147 '
onclick=
"javascript:deleteWim(\''+row['_id']+'\', \''+ row["name
"] +'\')" data-toggle=
"tooltip" data-placement=
"top" data-container=
"body" title=
"Delete">' +
148 '
<i class=
"far fa-trash-alt" ></i></button></div>';
156 setInterval(function () {
161 function openModalCreateWIM(){
162 $('#modal_new_wim').modal('show');
164 function deleteWim(wim_id, wim_name) {
165 var url =
"/wims/"+wim_id+
"/delete";
166 bootbox.confirm(
"Are you sure want to delete " + wim_name +
"?", function (result) {
168 var dialog = bootbox.dialog({
169 message: '
<div class=
"text-center"><i class=
"fa fa-spin fa-spinner"></i> Loading...
</div>',
176 contentType:
"application/json;charset=utf-8",
177 success: function (result) {
178 if (result['error'] == true) {
179 dialog.modal('hide');
180 bootbox.alert(
"An error occurred.");
183 dialog.modal('hide');
187 error: function (error) {
188 dialog.modal('hide');
189 bootbox.alert(
"An error occurred.");
196 function showWIM(wim_uuid) {
197 var dialog = bootbox.dialog({
198 message: '
<div class=
"text-center"><i class=
"fa fa-spin fa-spinner"></i> Loading...
</div>',
203 url: '/wims/' + wim_uuid ,
206 contentType:
"application/json;charset=utf-8",
207 success: function (result) {
208 //$('#modal_show_vim_body').empty();
209 var wim = result.wim;
212 $('#modal_show_wim_body').find('span').text('-');
214 $('#' + k).text(wim[k])
217 for (var i in wim['_admin']) {
218 if (i === 'modified' || i === 'created') {
219 //$('#' + i).text(new Date(wim['_admin'][i]*
1000).toUTCString());
220 $('#' + i).text(moment(wim['_admin'][i] *
1000).format('DD/MM/YY hh:mm:ss'));
222 else if (i === 'deployed') {
223 $('#' + i).text(JSON.stringify(wim['_admin'][i]))
226 $('#' + i).text(wim['_admin'][i])
229 dialog.modal('hide');
230 $('#modal_show_wim').modal('show');
233 dialog.modal('hide');
234 bootbox.alert(
"An error occurred while retrieving the WIM info.");
238 error: function (result) {
239 dialog.modal('hide');
240 bootbox.alert(
"An error occurred while retrieving the WIM info.");