2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
13 // specify dashlets and layouts
17 name : 'Existing Nodes'
32 one.f.dashlet.existingNodes
41 one.f.dashlet.flowsOrPorts
48 $(one.f.menu.left.top).each(function(index, value) {
49 var $nav = $(".nav", "#left-top");
50 one.main.page.dashlet($nav, value);
53 $(one.f.menu.left.bottom).each(function(index, value) {
54 var $nav = $(".nav", "#left-bottom");
55 one.main.page.dashlet($nav, value);
58 $(one.f.menu.right.bottom).each(function(index, value) {
59 var $nav = $(".nav", "#right-bottom");
60 one.main.page.dashlet($nav, value);
63 /**Troubleshoot modules*/
64 one.f.troubleshooting = {
65 rootUrl: "/controller/web/troubleshoot",
68 var $rightBottomDashlet = $("#right-bottom").find(".dashlet");
69 return $rightBottomDashlet;
71 setDashletHeader: function(label) {
72 $("#right-bottom li a")[0].innerHTML = label;
75 createTable: function(columnNames, body) {
76 var tableAttributes = ["table-striped", "table-bordered", "table-condensed"];
77 var $table = one.lib.dashlet.table.table(tableAttributes);
78 var tableHeaders = columnNames;
79 var $thead = one.lib.dashlet.table.header(tableHeaders);
80 var $tbody = one.lib.dashlet.table.body(body, tableHeaders);
87 one.f.troubleshooting.existingNodes = {
89 popout: "one_f_troubleshooting_existingNodes_id_popout",
90 modal: "one_f_troubleshooting_existingNodes_id_modal",
91 existingNodesDataGrid: "one_f_troubleshooting_existingNodes_id_datagrid",
92 portsDataGrid: "one_f_troubleshooting_existingNodes_id_portsDataGrid",
93 flowsDataGrid: "one_f_troubleshooting_existingNodes_id_flowsDataGrid",
94 refreshFlowsButton:"one_f_troubleshooting_existingNodes_id_refreshFlowsButton",
95 refreshPortsButton:"one_f_troubleshooting_existingNodes_id_refreshPortsButton"
99 main: function($dashlet) {
100 one.lib.dashlet.empty($dashlet);
101 $dashlet.append(one.lib.dashlet.header(one.f.dashlet.existingNodes.name));
102 // TODO(l): Add a generic auto expand function to one.lib and replace custom height setting.
103 //$('#left-top').height('100%');
104 one.f.troubleshooting.existingNodes.ajax(one.f.troubleshooting.rootUrl + "/existingNodes" , function(content) {
105 var $gridHTML = one.lib.dashlet.datagrid.init(one.f.troubleshooting.existingNodes.id.existingNodesDataGrid, {
109 flexibleRowsPerPage: true
110 }, "table-striped table-condensed");
111 $dashlet.append($gridHTML);
112 var dataSource = one.f.troubleshooting.existingNodes.data.existingNodesGrid(content);
113 $("#" + one.f.troubleshooting.existingNodes.id.existingNodesDataGrid).datagrid({dataSource: dataSource});
117 flows: function(nodeId) {
119 if(one.f.troubleshooting === undefined){
122 $.getJSON(one.main.constants.address.prefix + "/troubleshoot/flowStats?nodeId=" + nodeId, function(content) {
123 $rightBottomDashlet = one.f.troubleshooting.rightBottomDashlet.get();
124 one.f.troubleshooting.rightBottomDashlet.setDashletHeader("Flows");
125 one.lib.dashlet.empty($rightBottomDashlet);
126 $rightBottomDashlet.append(one.lib.dashlet.header("Flow Details"));
127 var button = one.lib.dashlet.button.single("Refresh",
128 one.f.troubleshooting.existingNodes.id.refreshFlowsButton, "btn-primary", "btn-mini");
129 var $button = one.lib.dashlet.button.button(button);
130 $button.click(function() {
131 one.f.troubleshooting.existingNodes.load.flows(nodeId);
133 $rightBottomDashlet.append($button);
134 var $gridHTML = one.lib.dashlet.datagrid.init(one.f.troubleshooting.existingNodes.id.flowsDataGrid, {
138 flexibleRowsPerPage: true
139 }, "table-striped table-condensed");
140 $rightBottomDashlet.append($gridHTML);
141 var dataSource = one.f.troubleshooting.existingNodes.data.flowsGrid(content);
142 $("#" + one.f.troubleshooting.existingNodes.id.flowsDataGrid).datagrid({dataSource: dataSource});
146 ports: function(nodeId) {
148 if(one.f.troubleshooting === undefined){
151 $.getJSON(one.main.constants.address.prefix + "/troubleshoot/portStats?nodeId=" + nodeId, function(content) {
152 $rightBottomDashlet = one.f.troubleshooting.rightBottomDashlet.get();
153 one.f.troubleshooting.rightBottomDashlet.setDashletHeader("Ports");
154 one.lib.dashlet.empty($rightBottomDashlet);
155 $rightBottomDashlet.append(one.lib.dashlet.header("Port Details"));
156 var button = one.lib.dashlet.button.single("Refresh",
157 one.f.troubleshooting.existingNodes.id.refreshPortsButton, "btn-primary", "btn-mini");
158 var $button = one.lib.dashlet.button.button(button);
159 $button.click(function() {
160 one.f.troubleshooting.existingNodes.load.ports(nodeId);
162 $rightBottomDashlet.append($button);
163 var $gridHTML = one.lib.dashlet.datagrid.init(one.f.troubleshooting.existingNodes.id.portsDataGrid, {
167 flexibleRowsPerPage: true
168 }, "table-striped table-condensed");
169 $rightBottomDashlet.append($gridHTML);
170 var dataSource = one.f.troubleshooting.existingNodes.data.portsGrid(content);
171 $("#" + one.f.troubleshooting.existingNodes.id.portsDataGrid).datagrid({dataSource: dataSource});
176 ajax : function(url, callback) {
177 $.getJSON(url, function(data) {
185 existingNodesGrid: function(data) {
186 var source = new StaticDataSource({
189 property: 'nodeName',
199 property: 'statistics',
205 formatter: function(items) {
206 $.each(items, function(index, item) {
207 item["statistics"] = "<a href=\"javascript:one.f.troubleshooting.existingNodes.load.flows('" + item["nodeId"] + "');\">Flows</a>" +
208 " <a href=\"javascript:one.f.troubleshooting.existingNodes.load.ports('" + item["nodeId"] + "');\">Ports</a>";
215 portsGrid: function(data) {
216 $.each(data.nodeData, function(index, item) {
217 item.rxPkts = one.lib.helper.parseInt(item.rxPkts);
218 item.txPkts = one.lib.helper.parseInt(item.txPkts);
219 item.rxBytes = one.lib.helper.parseInt(item.rxBytes);
220 item.txBytes = one.lib.helper.parseInt(item.txBytes);
221 item.rxDrops = one.lib.helper.parseInt(item.rxDrops);
222 item.txDrops = one.lib.helper.parseInt(item.txDrops);
223 item.rxErrors = one.lib.helper.parseInt(item.rxErrors);
224 item.txErrors = one.lib.helper.parseInt(item.txErrors);
225 item.rxFrameErrors = one.lib.helper.parseInt(item.rxFrameErrors);
226 item.rxOverRunErrors = one.lib.helper.parseInt(item.rxOverRunErrors);
227 item.rxCRCErrors = one.lib.helper.parseInt(item.rxCRCErrors);
228 item.collisions = one.lib.helper.parseInt(item.collisions);
230 var source = new StaticDataSource({
233 property: 'nodeConnector',
234 label: 'Node Connector',
268 property: 'rxErrors',
273 property: 'txErrors',
278 property: 'rxFrameErrors',
279 label: 'Rx Frame Errs',
283 property: 'rxOverRunErrors',
284 label: 'Rx OverRun Errs',
288 property: 'rxCRCErrors',
289 label: 'Rx CRC Errs',
293 property: 'collisions',
303 ports: function(data) {
305 $.each(data.nodeData, function(key, value) {
308 entry.push(value["nodeConnector"]);
309 entry.push(value["rxPkts"]);
310 entry.push(value["txPkts"]);
311 entry.push(value["rxBytes"]);
312 entry.push(value["txBytes"]);
313 entry.push(value["rxDrops"]);
314 entry.push(value["txDrops"]);
315 entry.push(value["rxErrors"]);
316 entry.push(value["txErrors"]);
317 entry.push(value["rxFrameErrors"]);
318 entry.push(value["rxOverRunErrors"]);
319 entry.push(value["rxCRCErrors"]);
320 entry.push(value["collisions"]);
326 flowsGrid: function(data) {
327 $.each(data.nodeData, function(index, item) {
328 item.byteCount = one.lib.helper.parseInt(item.byteCount);
329 item.packetCount = one.lib.helper.parseInt(item.packetCount);
330 item.durationSeconds = one.lib.helper.parseInt(item.durationSeconds);
331 item.idleTimeout = one.lib.helper.parseInt(item.idleTimeout);
332 item.priority = one.lib.helper.parseInt(item.priority);
334 var source = new StaticDataSource({
337 property: 'nodeName',
367 property: 'dlVlanPriority',
407 property: 'byteCount',
412 property: 'packetCount',
413 label: 'Packet Count',
417 property: 'durationSeconds',
418 label: 'Duration Seconds',
422 property: 'idleTimeout',
423 label: 'Idle Timeout',
427 property: 'priority',
437 flows: function(data) {
439 $.each(data.nodeData, function(key, value) {
442 entry.push(value["nodeName"]);
443 entry.push(value["inPort"]);
444 entry.push(value["dlSrc"]);
445 entry.push(value["dlDst"]);
446 entry.push(value["dlType"]);
447 entry.push(value["dlVlan"]);
448 entry.push(value["nwSrc"]);
449 entry.push(value["nwDst"]);
450 entry.push(value["nwTOS"]);
451 entry.push(value["nwProto"]);
452 entry.push(value["tpSrc"]);
453 entry.push(value["tpDst"]);
454 entry.push(value["actions"]);
455 entry.push(value["byteCount"]);
456 entry.push(value["packetCount"]);
457 entry.push(value["durationSeconds"]);
458 entry.push(value["idleTimeout"]);
459 entry.push(value["priority"]);
468 one.f.troubleshooting.uptime = {
470 popout: "one_f_troubleshooting_uptime_id_popout",
471 modal: "one_f_troubleshooting_uptime_id_modal",
472 datagrid: "one_f_troubleshooting_uptime_id_datagrid"
475 dashlet: function($dashlet) {
476 one.lib.dashlet.empty($dashlet);
477 $dashlet.append(one.lib.dashlet.header(one.f.dashlet.uptime.name));
478 var url = one.f.troubleshooting.rootUrl + "/uptime";
479 one.f.troubleshooting.uptime.ajax.main(url , {} ,function(content) {
480 var $gridHTML = one.lib.dashlet.datagrid.init(one.f.troubleshooting.uptime.id.datagrid, {
484 flexibleRowsPerPage: true
485 }, "table-striped table-condensed");
486 $dashlet.append($gridHTML);
487 var dataSource = one.f.troubleshooting.uptime.data.uptimeDataGrid(content);
488 $("#" + one.f.troubleshooting.uptime.id.datagrid).datagrid({dataSource: dataSource});
493 main : function(url, requestData, callback) {
494 $.getJSON(url, requestData, function(data) {
501 uptimeDataGrid: function(data) {
502 var source = new StaticDataSource({
505 property: 'nodeName',
515 property: 'connectedSince',
525 uptime: function(data) {
527 $.each(data.nodeData, function(key, value) {
530 entry.push(value["nodeName"]);
531 entry.push(value["nodeId"]);
532 entry.push(value["connectedSince"]);
541 one.f.troubleshooting.statistics = {
542 dashlet : function($dashlet) {
543 var $h4 = one.lib.dashlet.header("Statistics");
544 $dashlet.append($h4);
546 var $none = $(document.createElement('div'));
547 $none.addClass('none');
548 var $p = $(document.createElement('p'));
549 $p.text('Please select a Flow or Ports statistics');
550 $p.addClass('text-center').addClass('text-info');
552 $dashlet.append($none)
558 $('.dash .nav a', '#main').click(function() {
560 var $li = $(this).parent();
561 var $ul = $li.parent();
562 one.lib.nav.unfocus($ul);
563 $li.addClass('active');
564 // clear respective dashlet
565 var $dashlet = $ul.parent().find('.dashlet');
566 one.lib.dashlet.empty($dashlet);
567 // callback based on menu
568 var id = $(this).attr('id');
569 var menu = one.f.dashlet;
571 case menu.existingNodes.id:
572 one.f.troubleshooting.existingNodes.load.main($dashlet);
575 one.f.troubleshooting.uptime.dashlet($dashlet);
577 case menu.flowsOrPorts.id:
578 one.f.troubleshooting.statistics.dashlet($dashlet);
583 // activate first tab on each dashlet
584 $('.dash .nav').each(function(index, value) {
585 $($(value).find('li')[0]).find('a').click();