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',
397 property: 'byteCount',
402 property: 'packetCount',
403 label: 'Packet Count',
407 property: 'durationSeconds',
408 label: 'Duration Seconds',
412 property: 'idleTimeout',
413 label: 'Idle Timeout',
417 property: 'priority',
427 flows: function(data) {
429 $.each(data.nodeData, function(key, value) {
432 entry.push(value["nodeName"]);
433 entry.push(value["inPort"]);
434 entry.push(value["dlSrc"]);
435 entry.push(value["dlDst"]);
436 entry.push(value["dlType"]);
437 entry.push(value["dlVlan"]);
438 entry.push(value["nwSrc"]);
439 entry.push(value["nwDst"]);
440 entry.push(value["nwProto"]);
441 entry.push(value["tpSrc"]);
442 entry.push(value["tpDst"]);
443 entry.push(value["actions"]);
444 entry.push(value["byteCount"]);
445 entry.push(value["packetCount"]);
446 entry.push(value["durationSeconds"]);
447 entry.push(value["idleTimeout"]);
448 entry.push(value["priority"]);
457 one.f.troubleshooting.uptime = {
459 popout: "one_f_troubleshooting_uptime_id_popout",
460 modal: "one_f_troubleshooting_uptime_id_modal",
461 datagrid: "one_f_troubleshooting_uptime_id_datagrid"
464 dashlet: function($dashlet) {
465 one.lib.dashlet.empty($dashlet);
466 $dashlet.append(one.lib.dashlet.header(one.f.dashlet.uptime.name));
467 var url = one.f.troubleshooting.rootUrl + "/uptime";
468 one.f.troubleshooting.uptime.ajax.main(url , {} ,function(content) {
469 var $gridHTML = one.lib.dashlet.datagrid.init(one.f.troubleshooting.uptime.id.datagrid, {
473 flexibleRowsPerPage: true
474 }, "table-striped table-condensed");
475 $dashlet.append($gridHTML);
476 var dataSource = one.f.troubleshooting.uptime.data.uptimeDataGrid(content);
477 $("#" + one.f.troubleshooting.uptime.id.datagrid).datagrid({dataSource: dataSource});
482 main : function(url, requestData, callback) {
483 $.getJSON(url, requestData, function(data) {
490 uptimeDataGrid: function(data) {
491 var source = new StaticDataSource({
494 property: 'nodeName',
504 property: 'connectedSince',
514 uptime: function(data) {
516 $.each(data.nodeData, function(key, value) {
519 entry.push(value["nodeName"]);
520 entry.push(value["nodeId"]);
521 entry.push(value["connectedSince"]);
530 one.f.troubleshooting.statistics = {
531 dashlet : function($dashlet) {
532 var $h4 = one.lib.dashlet.header("Statistics");
533 $dashlet.append($h4);
535 var $none = $(document.createElement('div'));
536 $none.addClass('none');
537 var $p = $(document.createElement('p'));
538 $p.text('Please select a Flow or Ports statistics');
539 $p.addClass('text-center').addClass('text-info');
541 $dashlet.append($none)
547 $('.dash .nav a', '#main').click(function() {
549 var $li = $(this).parent();
550 var $ul = $li.parent();
551 one.lib.nav.unfocus($ul);
552 $li.addClass('active');
553 // clear respective dashlet
554 var $dashlet = $ul.parent().find('.dashlet');
555 one.lib.dashlet.empty($dashlet);
556 // callback based on menu
557 var id = $(this).attr('id');
558 var menu = one.f.dashlet;
560 case menu.existingNodes.id:
561 one.f.troubleshooting.existingNodes.load.main($dashlet);
564 one.f.troubleshooting.uptime.dashlet($dashlet);
566 case menu.flowsOrPorts.id:
567 one.f.troubleshooting.statistics.dashlet($dashlet);
572 // activate first tab on each dashlet
573 $('.dash .nav').each(function(index, value) {
574 $($(value).find('li')[0]).find('a').click();