Commit cc664d71 authored by Leigh Stoller's avatar Leigh Stoller

Add list-wires.php, to dump entire wires table in a searchable/sortable

table.
parent 9c216565
$(function ()
{
'use strict';
var templates = APT_OPTIONS.fetchTemplateList(['list-wires']);
var mainTemplate = _.template(templates['list-wires']);
function initialize()
{
window.APT_OPTIONS.initialize(sup);
sup.CallServerMethod(null, "wires", "List", null,
function(json) {
console.info("list", json);
if (json.code) {
alert("Could not get wire list " +
"from server: " + json.value);
return;
}
GeneratePageBody(json.value);
});
}
function GeneratePageBody(wires)
{
// Generate the template.
var html = mainTemplate({
wires: wires,
isadmin: window.ISADMIN,
});
$('#main-body').html(html);
// Format dates with moment before display.
$('.format-date').each(function() {
var date = $.trim($(this).html());
if (date != "") {
$(this).html(moment($(this).html()).format("lll"));
}
});
// This activates the popover subsystem.
$('[data-toggle="popover"]').popover({
trigger: 'hover',
});
// This activates the tooltip subsystem.
$('[data-toggle="tooltip"]').tooltip({
trigger: 'hover',
});
var table = $(".tablesorter")
.tablesorter({
theme : 'green',
widgets: ["filter"],
widgetOptions: {
// include child row content while filtering, if true
filter_childRows : true,
// include all columns in the search.
filter_anyMatch : true,
// class name applied to filter row and each input
filter_cssFilter : 'form-control',
// search from beginning
filter_startsWith : false,
// Set this option to false for case sensitive search
filter_ignoreCase : true,
// Only one search box.
filter_columnFilters : true,
}
});
$('#waiting').addClass("hidden");
}
$(document).ready(initialize);
});
<?php
#
# Copyright (c) 2000-2019 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
# This file is part of the Emulab network testbed software.
#
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this file. If not, see <http://www.gnu.org/licenses/>.
#
# }}}
#
chdir("..");
include("defs.php3");
chdir("apt");
include("quickvm_sup.php");
# Must be after quickvm_sup.php since it changes the auth domain.
$page_title = "List Vlans";
#
# Get current user.
#
RedirectSecure();
$this_user = CheckLoginOrRedirect();
$this_idx = $this_user->uid_idx();
if (!ISADMIN()) {
SPITUSERERROR("Not enough permission!");
}
SPITHEADER(1);
echo "<link rel='stylesheet'
href='css/tablesorter.css'>\n";
# Place to hang the toplevel template.
echo "<div id='main-body'>
<center id='waiting'>
<h5>Patience please, this will take a few moments</h5>
<br>
<img src='images/spinner.gif' />
</center>
</div>\n";
REQUIRE_UNDERSCORE();
REQUIRE_SUP();
REQUIRE_MOMENT();
SPITREQUIRE("js/list-wires.js",
"<script src='js/lib/jquery.tablesorter.min.js'></script>".
"<script src='js/lib/jquery.tablesorter.widgets.min.js'></script>".
"<script src='js/lib/sugar.min.js'></script>".
"<script src='js/lib/jquery.tablesorter.parser-date.js'></script>");
AddTemplateList(array("list-wires"));
SPITFOOTER();
?>
......@@ -427,6 +427,11 @@ $routing = array("geni-login" =>
"Do_GetInfo",
"List" =>
"Do_List")),
"wires" =>
array("file" => "wires.ajax",
"guest" => false,
"methods" => array("List" =>
"Do_List")),
"news" =>
array("file" => "news.ajax",
"guest" => false,
......
<style>
.table-condensed > thead > tr > th,
.table-condensed > tbody > tr > th,
.table-condensed > tfoot > tr > th,
.table-condensed > thead > tr > td,
.table-condensed > tbody > tr > td,
.table-condensed > tfoot > tr > td {
padding-top: 2px;
padding-bottom: 2px;
font-size: small;
}
.panel-body > table {
margin-bottom: 0px;
}
.table-fixed {
overflow-y: auto;
height: 400px;
}
</style>
<div class='col-lg-12 col-lg-offset-0
col-md-12 col-md-offset-0
col-sm-12 col-sm-offset-0
col-xs-12 col-xs-offset-0'>
<div>
<table class='tablesorter'>
<thead>
<th>Type</th>
<th>ID</th>
<th>Len</th>
<th>Node</th>
<th>Iface</th>
<th>Role</th>
<th>Type</th>
<th>Node</th>
<th>Iface</th>
<th>Role</th>
<th>Type</th>
</thead>
<tbody>
<% _.each(wires, function(info) { %>
<tr>
<td><%- info.wire_type %></td>
<td>
<% if (info.wire_id) { %><%- info.wire_id %><% } %>
</td>
<td>
<% if (info.wire_length != 0) { %>
<%- info.wire_length %><% } %>
</td>
<td>
<%
var url = "show-node.php?node_id=" + info.node_id1;
if (info.isswitch1) {
url = url + "#" + info.card1 + ":" + info.port1;
} %>
<a href="<%- url %>"><%- info.node_id1 %></a>
</td>
<td><%- info.iface1 %>
<% if (info.isswitch1) { %>
(<%- info.card1 %>,<%- info.port1 %>)
<span id='<% print(info.card1 + ":" +
info.port1) %>'></span>
<% } %>
</td>
<td><%- info.role1 %></td>
<td><%- info.type1 %></td>
<td>
<%
var url = "show-node.php?node_id=" + info.node_id2;
if (info.isswitch2) {
url = url + "#" + info.card2 + ":" + info.port2;
} %>
<a href="<%- url %>"><%- info.node_id2 %></a>
</td>
<td><%- info.iface2 %>
<% if (info.isswitch2) { %>
(<%- info.card2 %>,<%- info.port2 %>)
<span id='<% print(info.card2 + ":" +
info.port2) %>'></span>
<% } %>
</td>
<td><%- info.role2 %></td>
<td><%- info.type2 %></td>
</tr>
<% }); %>
</tbody>
</table>
</div>
</div>
<div id='oops_div'></div>
<div id='waitwait_div'></div>
<?php
#
# Copyright (c) 2000-2019 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
# This file is part of the Emulab network testbed software.
#
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this file. If not, see <http://www.gnu.org/licenses/>.
#
# }}}
#
chdir("..");
include_once("webtask.php");
include_once("node_defs.php");
chdir("apt");
function Do_List()
{
global $this_user, $ajax_args;
$result = array();
if (!ISADMIN()) {
SPITAJAX_ERROR(1, "Not enough permission");
return;
}
$query_result =
DBQueryFatal("select distinct w.*,".
" i1.role as irole1,i1.interface_type as itype1,".
" i2.role as irole2,i2.interface_type as itype2,".
" t1.isswitch as isswitch1,".
" t2.isswitch as isswitch2 ".
" from wires as w ".
"left join interfaces as i1 on ".
" i1.node_id=w.node_id1 and i1.iface=w.iface1 ".
"left join interfaces as i2 on ".
" i2.node_id=w.node_id2 and i2.iface=w.iface2 ".
"left join nodes as n1 on n1.node_id=w.node_id1 ".
"left join node_types as t1 on t1.type=n1.type ".
"left join nodes as n2 on n2.node_id=w.node_id2 ".
"left join node_types as t2 on t2.type=n2.type ".
"order by w.node_id1,w.iface1");
while ($row = mysql_fetch_array($query_result)) {
$info = array();
$info["wire_type"] = $row["type"];
$info["wire_length"] = $row["len"];
$info["wire_id"] = $row["cable"];
$info["node_id1"] = $row["node_id1"];
$info["iface1"] = $row["iface1"];
$info["type1"] = $row["itype1"];
$info["role1"] = $row["irole1"];
$info["card1"] = $row["card1"];
$info["port1"] = $row["port1"];
$info["isswitch1"] = $row["isswitch1"] == 1 ? true : false;
$info["node_id2"] = $row["node_id2"];
$info["iface2"] = $row["iface2"];
$info["type2"] = $row["itype2"];
$info["role2"] = $row["irole2"];
$info["card2"] = $row["card2"];
$info["port2"] = $row["port2"];
$info["isswitch2"] = $row["isswitch2"] == 1 ? true : false;
$result[] = $info;
}
SPITAJAX_RESPONSE($result);
}
# Local Variables:
# mode:php
# End:
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment