This is an automated email from the ASF dual-hosted git repository. eallen pushed a commit to branch eallen-DISPATCH-1385 in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git
commit 6824e7fb9847ab47af5c92b85247d5abfbf71518 Author: Ernest Allen <eal...@redhat.com> AuthorDate: Fri Oct 4 10:27:34 2019 -0400 Added Links overview table --- console/react/src/layout.js | 13 -- console/react/src/overview/linksTable.js | 156 ++++++++++++++++++++++++ console/react/src/overview/overviewTableBase.js | 1 - console/react/src/overview/overviewTablePage.js | 7 +- 4 files changed, 162 insertions(+), 15 deletions(-) diff --git a/console/react/src/layout.js b/console/react/src/layout.js index 6db1a2e..afae49e 100644 --- a/console/react/src/layout.js +++ b/console/react/src/layout.js @@ -66,19 +66,6 @@ class PageLayout extends React.Component { this.tables = ["routers", "addresses", "links", "connections", "logs"]; /* - links: [ - { title: "name", displayName: "Link" }, - { title: "linkType" }, - { title: "linkDir" }, - { title: "adminStatus" }, - { title: "operStatus" }, - { title: "deliveryCount" }, - { title: "rate" }, - { title: "delayed1Sec" }, - { title: "delayed10Sec" }, - { title: "outstanding" }, - { title: "address" } - ], connections: [ { title: "name", displayName: "host" }, { title: "container" }, diff --git a/console/react/src/overview/linksTable.js b/console/react/src/overview/linksTable.js new file mode 100644 index 0000000..d528bc3 --- /dev/null +++ b/console/react/src/overview/linksTable.js @@ -0,0 +1,156 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +import { sortable } from "@patternfly/react-table"; +import OverviewTableBase from "./overviewTableBase"; + +class LinksTable extends OverviewTableBase { + constructor(props) { + super(props); + this.fields = [ + { title: "Link", field: "name" }, + { title: "Type", field: "linkType", transforms: [sortable] }, + { title: "Dir", field: "linkDir" }, + { title: "Admin status", field: "adminStatus" }, + { title: "Oper status", field: "operStatus" }, + { title: "Deliveries", field: "deliveryCount" }, + { title: "Rate", field: "rate" }, + { title: "Delayed 1 sec", field: "delayed1Sec" }, + { title: "Delayed 10 secs", field: "delayed10Sec" }, + { title: "Outstanding", field: "outstanding" }, + { title: "Address", field: "owningAddr", transforms: [sortable] } + ]; + } + doFetch = (page, perPage) => { + return new Promise(resolve => { + this.props.service.management.topology.fetchAllEntities( + { entity: "router.link" }, + nodes => { + // we have all the data now in the nodes object + let linkFields = []; + const now = new Date(); + var prettyVal = value => { + return typeof value === "undefined" + ? "-" + : this.props.service.utilities.pretty(value); + }; + var uncounts = link => { + return this.props.service.utilities.pretty( + link.undeliveredCount + link.unsettledCount + ); + }; + var getLinkName = (node, link) => { + let namestr = this.props.service.utilities.nameFromId(node); + return `${namestr}:${link.identity}`; + }; + var fixAddress = link => { + let addresses = []; + let owningAddr = link.owningAddr || ""; + let rawAddress = owningAddr; + /* + - "L*" => "* (local)" + - "M0*" => "* (direct)" + - "M1*" => "* (dequeue)" + - "MX*" => "* (phase X)" + */ + let address = undefined; + let starts = { L: "(local)", M0: "(direct)", M1: "(dequeue)" }; + for (let start in starts) { + if (owningAddr.startsWith(start)) { + let ends = owningAddr.substr(start.length); + address = ends + " " + starts[start]; + rawAddress = ends; + break; + } + } + if (!address) { + // check for MX* + if (owningAddr.length > 3) { + if (owningAddr[0] === "M") { + let phase = parseInt(owningAddr.substr(1)); + if (phase && !isNaN(phase)) { + let phaseStr = phase + ""; + let star = owningAddr.substr(2 + phaseStr.length); + address = `${star} (phase ${phaseStr})`; + } + } + } + } + addresses[0] = address || owningAddr; + addresses[1] = rawAddress; + return addresses; + }; + for (let node in nodes) { + const response = nodes[node]["router.link"]; + for (let i = 0; i < response.results.length; i++) { + const result = response.results[i]; + const link = this.props.service.utilities.flatten( + response.attributeNames, + result + ); + let linkName = getLinkName(node, link); + let addresses = fixAddress(link); + + linkFields.push({ + link: linkName, + title: linkName, + outstanding: uncounts(link), + operStatus: link.operStatus, + adminStatus: link.adminStatus, + owningAddr: addresses[0], + + acceptedCount: prettyVal(link.acceptedCount), + modifiedCount: prettyVal(link.modifiedCount), + presettledCount: prettyVal(link.presettledCount), + rejectedCount: prettyVal(link.rejectedCount), + releasedCount: prettyVal(link.releasedCount), + deliveryCount: prettyVal(link.deliveryCount), + + rate: prettyVal(link.settleRate), + deliveriesDelayed10Sec: prettyVal(link.deliveriesDelayed10Sec), + deliveriesDelayed1Sec: prettyVal(link.deliveriesDelayed1Sec), + capacity: link.capacity, + undeliveredCount: link.undeliveredCount, + unsettledCount: link.unsettledCount, + + rawAddress: addresses[1], + rawDeliveryCount: link.deliveryCount, + name: link.name, + linkName: link.linkName, + connectionId: link.connectionId, + linkDir: link.linkDir, + linkType: link.linkType, + peer: link.peer, + type: link.type, + + uid: linkName, + timestamp: now, + nodeId: node, + identity: link.identity + }); + } + } + resolve(this.slice(linkFields, page, perPage)); + } + ); + }); + }; +} + +export default LinksTable; diff --git a/console/react/src/overview/overviewTableBase.js b/console/react/src/overview/overviewTableBase.js index a1969c8..54625ce 100644 --- a/console/react/src/overview/overviewTableBase.js +++ b/console/react/src/overview/overviewTableBase.js @@ -175,7 +175,6 @@ class OverviewTableBase extends React.Component { }; render() { - console.log("OverviewTable rendered"); const { loading } = this.state; return ( <React.Fragment> diff --git a/console/react/src/overview/overviewTablePage.js b/console/react/src/overview/overviewTablePage.js index 579f605..052a7cb 100644 --- a/console/react/src/overview/overviewTablePage.js +++ b/console/react/src/overview/overviewTablePage.js @@ -11,6 +11,7 @@ import { Card, CardBody } from "@patternfly/react-core"; import RoutersTable from "./routersTable"; import AddressesTable from "./addressesTable"; +import LinksTable from "./linksTable"; class OverviewTablePage extends React.Component { constructor(props) { super(props); @@ -31,9 +32,13 @@ class OverviewTablePage extends React.Component { /> ); } + if (this.props.entity === "links") { + return ( + <LinksTable entity={this.props.entity} service={this.props.service} /> + ); + } }; render() { - console.log("OverviewTablePage render"); return ( <React.Fragment> <PageSection --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org