-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
*/
/**Troubleshoot modules*/
one.f.troubleshooting = {
rootUrl: "/controller/web/troubleshoot",
- rightBottomDashlet: {
+ rightBottomDashlet: {
get: function() {
var $rightBottomDashlet = $("#right-bottom").find(".dashlet");
return $rightBottomDashlet;
},
setDashletHeader: function(label) {
- $("#right-bottom li a")[0].innerHTML = label;
+ $("#right-bottom li a")[0].innerHTML = label;
}
},
createTable: function(columnNames, body) {
modal: "one_f_troubleshooting_existingNodes_id_modal",
existingNodesDataGrid: "one_f_troubleshooting_existingNodes_id_datagrid",
portsDataGrid: "one_f_troubleshooting_existingNodes_id_portsDataGrid",
- flowsDataGrid: "one_f_troubleshooting_existingNodes_id_flowsDataGrid"
- },
- // TODO: Make these values configurable.
- autoRefreshInterval: {
- flows: 10000,
- ports: 10000,
- refreshRateInterval: 5000
+ flowsDataGrid: "one_f_troubleshooting_existingNodes_id_flowsDataGrid",
+ refreshFlowsButton:"one_f_troubleshooting_existingNodes_id_refreshFlowsButton",
+ refreshPortsButton:"one_f_troubleshooting_existingNodes_id_refreshPortsButton",
+ modal : {
+ nodeInfo : "one_f_troubleshooting_existingNodes_id_modal_nodeInfo",
+ cancelButton : "one_f_troubleshooting_existingNodes_id_modal_cancelButton",
+ }
},
load: {
main: function($dashlet) {
},
flows: function(nodeId) {
try {
- clearTimeout(one.f.troubleshooting.existingNodes.registry.refreshTimer);
+ if(one.f.troubleshooting === undefined){
+ return;
+ }
$.getJSON(one.main.constants.address.prefix + "/troubleshoot/flowStats?nodeId=" + nodeId, function(content) {
$rightBottomDashlet = one.f.troubleshooting.rightBottomDashlet.get();
one.f.troubleshooting.rightBottomDashlet.setDashletHeader("Flows");
one.lib.dashlet.empty($rightBottomDashlet);
$rightBottomDashlet.append(one.lib.dashlet.header("Flow Details"));
-
+ var button = one.lib.dashlet.button.single("Refresh",
+ one.f.troubleshooting.existingNodes.id.refreshFlowsButton, "btn-primary", "btn-mini");
+ var $button = one.lib.dashlet.button.button(button);
+ $button.click(function() {
+ one.f.troubleshooting.existingNodes.load.flows(nodeId);
+ });
+ $rightBottomDashlet.append($button);
var $gridHTML = one.lib.dashlet.datagrid.init(one.f.troubleshooting.existingNodes.id.flowsDataGrid, {
searchable: true,
filterable: false,
$rightBottomDashlet.append($gridHTML);
var dataSource = one.f.troubleshooting.existingNodes.data.flowsGrid(content);
$("#" + one.f.troubleshooting.existingNodes.id.flowsDataGrid).datagrid({dataSource: dataSource});
-
- var numberOfFlows = content.nodeData.length;
- var refreshRate = one.f.troubleshooting.existingNodes.autoRefreshInterval.flows;
- if (numberOfFlows > 0) {
- refreshRate += Math.floor(numberOfFlows / 500) *
- one.f.troubleshooting.existingNodes.autoRefreshInterval.refreshRateInterval;
- }
- one.f.troubleshooting.existingNodes.registry.refreshTimer = setTimeout(
- one.f.troubleshooting.existingNodes.load.flows,
- refreshRate, nodeId);
});
} catch(e) {}
},
ports: function(nodeId) {
try {
- clearTimeout(one.f.troubleshooting.existingNodes.registry.refreshTimer);
+ if(one.f.troubleshooting === undefined){
+ return;
+ }
$.getJSON(one.main.constants.address.prefix + "/troubleshoot/portStats?nodeId=" + nodeId, function(content) {
$rightBottomDashlet = one.f.troubleshooting.rightBottomDashlet.get();
one.f.troubleshooting.rightBottomDashlet.setDashletHeader("Ports");
one.lib.dashlet.empty($rightBottomDashlet);
$rightBottomDashlet.append(one.lib.dashlet.header("Port Details"));
-
+ var button = one.lib.dashlet.button.single("Refresh",
+ one.f.troubleshooting.existingNodes.id.refreshPortsButton, "btn-primary", "btn-mini");
+ var $button = one.lib.dashlet.button.button(button);
+ $button.click(function() {
+ one.f.troubleshooting.existingNodes.load.ports(nodeId);
+ });
+ $rightBottomDashlet.append($button);
var $gridHTML = one.lib.dashlet.datagrid.init(one.f.troubleshooting.existingNodes.id.portsDataGrid, {
searchable: true,
filterable: false,
$rightBottomDashlet.append($gridHTML);
var dataSource = one.f.troubleshooting.existingNodes.data.portsGrid(content);
$("#" + one.f.troubleshooting.existingNodes.id.portsDataGrid).datagrid({dataSource: dataSource});
-
- var numberOfPorts = content.nodeData.length;
- var refreshRate = one.f.troubleshooting.existingNodes.autoRefreshInterval.ports;
- if (numberOfPorts > 0) {
- refreshRate += Math.floor(numberOfPorts / 500) *
- one.f.troubleshooting.existingNodes.autoRefreshInterval.refreshRateInterval;
- }
- one.f.troubleshooting.existingNodes.registry.refreshTimer = setTimeout(
- one.f.troubleshooting.existingNodes.load.ports,
- refreshRate, nodeId);
});
} catch(e) {}
- }
+ }
},
ajax : function(url, callback) {
$.getJSON(url, function(data) {
},
{
property: 'nodeId',
- label: 'Static Route',
+ label: 'Node ID',
sortable: true
},
{
data: data.nodeData,
formatter: function(items) {
$.each(items, function(index, item) {
- item["statistics"] = "<a href=\"javascript:one.f.troubleshooting.existingNodes.load.flows('" + item["nodeId"] + "');\">Flows</a>" +
+ item.nodeName = "<a href=\"javascript:one.f.troubleshooting.existingNodes.data.nodeInfo('"
+ + item.nodeId + "');\">" + item.nodeName + "</a>"
+ item["statistics"] = "<a href=\"javascript:one.f.troubleshooting.existingNodes.load.flows('" + item["nodeId"] + "');\">Flows</a>" +
" <a href=\"javascript:one.f.troubleshooting.existingNodes.load.ports('" + item["nodeId"] + "');\">Ports</a>";
});
-
},
delay: 0
});
return source;
},
portsGrid: function(data) {
+ $.each(data.nodeData, function(index, item) {
+ item.rxPkts = one.lib.helper.parseInt(item.rxPkts);
+ item.txPkts = one.lib.helper.parseInt(item.txPkts);
+ item.rxBytes = one.lib.helper.parseInt(item.rxBytes);
+ item.txBytes = one.lib.helper.parseInt(item.txBytes);
+ item.rxDrops = one.lib.helper.parseInt(item.rxDrops);
+ item.txDrops = one.lib.helper.parseInt(item.txDrops);
+ item.rxErrors = one.lib.helper.parseInt(item.rxErrors);
+ item.txErrors = one.lib.helper.parseInt(item.txErrors);
+ item.rxFrameErrors = one.lib.helper.parseInt(item.rxFrameErrors);
+ item.rxOverRunErrors = one.lib.helper.parseInt(item.rxOverRunErrors);
+ item.rxCRCErrors = one.lib.helper.parseInt(item.rxCRCErrors);
+ item.collisions = one.lib.helper.parseInt(item.collisions);
+ });
var source = new StaticDataSource({
columns: [
{
}
],
data: data.nodeData,
- delay: 200
+ delay: 0
});
return source;
},
return result;
},
flowsGrid: function(data) {
+ $.each(data.nodeData, function(index, item) {
+ item.byteCount = one.lib.helper.parseInt(item.byteCount);
+ item.packetCount = one.lib.helper.parseInt(item.packetCount);
+ item.durationSeconds = one.lib.helper.parseInt(item.durationSeconds);
+ item.idleTimeout = one.lib.helper.parseInt(item.idleTimeout);
+ item.priority = one.lib.helper.parseInt(item.priority);
+ });
var source = new StaticDataSource({
columns: [
{
label: 'DL Vlan',
sortable: true
},
+ {
+ property: 'dlVlanPriority',
+ label: 'Vlan PCP',
+ sortable: true
+ },
{
property: 'nwSrc',
label: 'NW Src',
label: 'NW Dst',
sortable: true
},
+ {
+ property: 'nwTOS',
+ label: 'ToS Bits',
+ sortable: true
+ },
{
property: 'nwProto',
label: 'NW Proto',
label: 'Idle Timeout',
sortable: true
},
- {
- property: 'outPorts',
- label: 'Out Ports',
- sortable: true
- },
- {
- property: 'outVlanId',
- label: 'Out VlanId',
- sortable: true
- },
{
property: 'priority',
label: 'Priority',
entry.push(value["dlVlan"]);
entry.push(value["nwSrc"]);
entry.push(value["nwDst"]);
+ entry.push(value["nwTOS"]);
entry.push(value["nwProto"]);
entry.push(value["tpSrc"]);
entry.push(value["tpDst"]);
entry.push(value["packetCount"]);
entry.push(value["durationSeconds"]);
entry.push(value["idleTimeout"]);
- entry.push(value["outPorts"]);
- entry.push(value["outVlanId"]);
entry.push(value["priority"]);
tr.entry = entry;
result.push(tr);
});
return result;
+ },
+ nodeInfo : function(nodeId){
+ $.getJSON(one.main.constants.address.prefix + "/troubleshoot/nodeInfo?nodeId=" + nodeId, function(content) {
+ var h3 = 'Node Information'
+
+ var headers = [ 'Description','Specification'];
+
+ var attributes = ['table-striped', 'table-bordered', 'table-condensed'];
+ var $table = one.lib.dashlet.table.table(attributes);
+ var $thead = one.lib.dashlet.table.header(headers);
+ $table.append($thead);
+
+ var footer = [];
+
+ var cancelButton = one.lib.dashlet.button.single("Cancel",
+ one.f.troubleshooting.existingNodes.id.modal.nodeInfo, "", "");
+ var $cancelButton = one.lib.dashlet.button.button(cancelButton);
+ footer.push($cancelButton);
+
+ var body = []
+ $.each(content, function(key, value) {
+ var tr = {};
+ var entry = [];
+
+ entry.push(key);
+ entry.push(value);
+
+ tr.entry = entry;
+ body.push(tr);
+ });
+ var $tbody = one.lib.dashlet.table.body(body);
+ $table.append($tbody);
+
+ var $modal = one.lib.modal.spawn(one.f.troubleshooting.existingNodes.id.modal.nodeInfo, h3, $table , footer);
+ $modal.modal();
+
+ $('#'+one.f.troubleshooting.existingNodes.id.modal.nodeInfo, $modal).click(function() {
+ $modal.modal('hide');
+ });
+ });
}
}
};
$("#" + one.f.troubleshooting.uptime.id.datagrid).datagrid({dataSource: dataSource});
});
},
-
+
ajax : {
main : function(url, requestData, callback) {
$.getJSON(url, requestData, function(data) {
});
}
},
-
+
data: {
uptimeDataGrid: function(data) {
var source = new StaticDataSource({
var $p = $(document.createElement('p'));
$p.text('Please select a Flow or Ports statistics');
$p.addClass('text-center').addClass('text-info');
-
+
$dashlet.append($none)
.append($p);
}