This is an automated email from the ASF dual-hosted git repository. eallen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git
The following commit(s) were added to refs/heads/master by this push: new 9300914 DISPATCH-1340 Show updated link statistics on client popup 9300914 is described below commit 9300914a8ddfa54854b87a34d1c241648dc79250 Author: Ernest Allen <eal...@redhat.com> AuthorDate: Tue May 21 08:08:28 2019 -0400 DISPATCH-1340 Show updated link statistics on client popup --- .../stand-alone/plugin/js/dlgDetailController.js | 342 +++++++++++++-------- 1 file changed, 211 insertions(+), 131 deletions(-) diff --git a/console/stand-alone/plugin/js/dlgDetailController.js b/console/stand-alone/plugin/js/dlgDetailController.js index 25d1fa3..6bb2d1a 100644 --- a/console/stand-alone/plugin/js/dlgDetailController.js +++ b/console/stand-alone/plugin/js/dlgDetailController.js @@ -22,18 +22,18 @@ import { utils } from "./amqp/utilities.js"; export class DetailDialogController { constructor(QDRService, $scope, $timeout, $uibModalInstance, d) { - this.controllerName = 'QDR.DetailDialogController'; + this.controllerName = "QDR.DetailDialogController"; this.rates = {}; let expandedRows = new Set(); - $scope.d = d; // the node object + $scope.d = d; // the node object $scope.detail = { - template: 'loading.html', + template: "loading.html" }; // count the number of characters in an array of strings - let countChars = function (ar) { + let countChars = function(ar) { let count = 0; - ar.forEach(a => count += a.length); + ar.forEach(a => (count += a.length)); return count; }; @@ -41,49 +41,62 @@ export class DetailDialogController { $scope.fields = { detailFields: { cols: [ - 'version', - 'mode', - 'presettledDeliveries', - 'droppedPresettledDeliveries', - 'acceptedDeliveries', - 'rejectedDeliveries', - 'releasedDeliveries', - 'modifiedDeliveries', - 'deliveriesIngress', - 'deliveriesEgress', - 'deliveriesTransit', - 'deliveriesIngressRouteContainer', - 'deliveriesEgressRouteContainer' + "version", + "mode", + "presettledDeliveries", + "droppedPresettledDeliveries", + "acceptedDeliveries", + "rejectedDeliveries", + "releasedDeliveries", + "modifiedDeliveries", + "deliveriesIngress", + "deliveriesEgress", + "deliveriesTransit", + "deliveriesIngressRouteContainer", + "deliveriesEgressRouteContainer" ] }, linkFields: { + attrs: [ + "linkType", + "owningAddr", + "settleRate", + "deliveriesDelayed1Sec", + "deliveriesDelayed10Sec", + "unsettledCount", + "capacity" + ], cols: [ - 'linkType', - 'owningAddr', - 'priority', - 'acceptedCount', - 'unsettledCount' - ] + "linkType", + "addr", + "settleRate", + "delayed1", + "delayed10", + "capacity" + ], + calc: { + addr: function(link) { + return utils.addr_text(link.owningAddr); + }, + delayed1: function(link) { + return link.deliveriesDelayed1Sec; + }, + delayed10: function(link) { + return link.deliveriesDelayed10Sec; + }, + capacity: function(link) { + return link.unsettledCount / link.capacity; + } + } }, linkRouteFields: { - cols: [ - 'prefix', - 'direction', - 'containerId' - ] + cols: ["prefix", "direction", "containerId"] }, autoLinkFields: { - cols: [ - 'addr', - 'direction', - 'containerId' - ] + cols: ["addr", "direction", "containerId"] }, addressFields: { - cols: [ - 'prefix', - 'distribution' - ] + cols: ["prefix", "distribution"] } }; // used for calculating sub-table cell widths @@ -92,12 +105,12 @@ export class DetailDialogController { } // close button clicked - $scope.okClick = function () { + $scope.okClick = function() { clearTimeout(updateTimer); $uibModalInstance.close(true); }; // a row was expanded/collapsed. add/remove it to/from the Set - $scope.expandClicked = function (id) { + $scope.expandClicked = function(id) { if (expandedRows.has(id)) { expandedRows.delete(id); } else { @@ -105,82 +118,119 @@ export class DetailDialogController { $scope.detail.moreInfo(id); } }; - $scope.expanded = function (id) { + $scope.expanded = function(id) { return expandedRows.has(id); }; // keep an array of column sizes - let updateSizes = function (fields, sizes, obj) { - fields.forEach(function (key) { - if (!sizes[key]) - sizes[key] = utils.humanify(key).length; + let updateSizes = function(fields, sizes, obj) { + fields.forEach(function(key) { + if (!sizes[key]) sizes[key] = utils.humanify(key).length; sizes[key] = Math.max(sizes[key], utils.pretty(obj[key]).length); }); sizes.total = 0; for (let key in sizes) { - if (key !== 'total') - sizes.total += sizes[key]; + if (key !== "total") sizes.total += sizes[key]; } }; // get the detail info for the popup - let groupDetail = function () { + let groupDetail = function() { let self = this; // queued function to get the .router info for an edge router - let q_getEdgeInfo = function (n, infoPerId, callback) { - let nodeId = utils.idFromName(n.container, '_edge'); - QDRService.management.topology.fetchEntities(nodeId, - [{ entity: 'router', attrs: [] }, - ], - function (results) { + let q_getEdgeInfo = function(n, infoPerId, callback) { + let nodeId = utils.idFromName(n.container, "_edge"); + QDRService.management.topology.fetchEntities( + nodeId, + [{ entity: "router", attrs: [] }], + function(results) { let r = results[nodeId].router; - infoPerId[n.container] = utils.flatten(r.attributeNames, r.results[0]); - let rates = utils.rates(infoPerId[n.container], ["acceptedDeliveries"], self.rates, n.container, 1); - infoPerId[n.container].acceptedDeliveriesRate = Math.round(rates.acceptedDeliveries, 2); + infoPerId[n.container] = utils.flatten( + r.attributeNames, + r.results[0] + ); + let rates = utils.rates( + infoPerId[n.container], + ["acceptedDeliveries"], + self.rates, + n.container, + 1 + ); + infoPerId[n.container].acceptedDeliveriesRate = Math.round( + rates.acceptedDeliveries, + 2 + ); infoPerId[n.container].linkRoutes = []; infoPerId[n.container].autoLinks = []; infoPerId[n.container].addresses = []; callback(null); - }); + } + ); }; - return new Promise((function (resolve) { + return new Promise(function(resolve) { let infoPerId = {}; // we are getting info for an edge router - if (d.nodeType === 'edge') { + if (d.nodeType === "edge") { // called for each expanded row to get further details about the edge router - $scope.detail.moreInfo = function (id) { - let nodeId = utils.idFromName(id, '_edge'); - QDRService.management.topology.fetchEntities(nodeId, + $scope.detail.moreInfo = function(id) { + let nodeId = utils.idFromName(id, "_edge"); + QDRService.management.topology.fetchEntities( + nodeId, [ - { entity: 'router.link', attrs: [] }, - { entity: 'linkRoute', attrs: $scope.fields.linkRouteFields.cols }, - { entity: 'autoLink', attrs: $scope.fields.autoLinkFields.cols }, - { entity: 'address', attrs: [] }, + { entity: "router.link", attrs: [] }, + { + entity: "linkRoute", + attrs: $scope.fields.linkRouteFields.cols + }, + { + entity: "autoLink", + attrs: $scope.fields.autoLinkFields.cols + }, + { entity: "address", attrs: [] } ], - function (results) { - $timeout(function () { + function(results) { + $timeout(function() { // save the results (and sizes) for each entity requested if (infoPerId[id]) { infoPerId[id].linkRouteSizes = {}; - infoPerId[id].linkRoutes = utils.flattenAll(results[nodeId].linkRoute, - function (route) { - updateSizes($scope.fields.linkRouteFields.cols, infoPerId[id].linkRouteSizes, route); + infoPerId[id].linkRoutes = utils.flattenAll( + results[nodeId].linkRoute, + function(route) { + updateSizes( + $scope.fields.linkRouteFields.cols, + infoPerId[id].linkRouteSizes, + route + ); return route; - }); + } + ); infoPerId[id].autoLinkSizes = {}; - infoPerId[id].autoLinks = utils.flattenAll(results[nodeId].autoLink, - function (link) { - updateSizes($scope.fields.autoLinkFields.cols, infoPerId[id].autoLinkSizes, link); + infoPerId[id].autoLinks = utils.flattenAll( + results[nodeId].autoLink, + function(link) { + updateSizes( + $scope.fields.autoLinkFields.cols, + infoPerId[id].autoLinkSizes, + link + ); return link; - }); + } + ); infoPerId[id].addressSizes = {}; - infoPerId[id].addresses = utils.flattenAll(results[nodeId].address, - function (addr) { - updateSizes($scope.fields.addressFields.cols, infoPerId[id].addressSizes, addr); + infoPerId[id].addresses = utils.flattenAll( + results[nodeId].address, + function(addr) { + updateSizes( + $scope.fields.addressFields.cols, + infoPerId[id].addressSizes, + addr + ); return addr; - }); + } + ); } }); - }); + } + ); }; // async send up to 10 requests @@ -192,37 +242,48 @@ export class DetailDialogController { } } // await until all sent requests have completed - q.await(function () { - $scope.detail.template = 'edgeRouters.html'; - $scope.detail.title = 'edge router'; + q.await(function() { + $scope.detail.template = "edgeRouters.html"; + $scope.detail.title = "edge router"; // send the results resolve({ - description: 'Select an edge router to see more info', + description: "Select an edge router to see more info", infoPerId: infoPerId }); }); } else { // we are getting info for a group of clients or consoles - $scope.detail.moreInfo = function () { }; - let attrs = utils.copy($scope.fields.linkFields.cols); - attrs.unshift('connectionId'); - QDRService.management.topology.fetchEntities(d.key, - [{ entity: 'router.link', attrs: attrs }], - function (results) { - let links = results[d.key]['router.link']; + $scope.detail.moreInfo = function() {}; + let attrs = utils.copy($scope.fields.linkFields.attrs); + attrs.unshift("connectionId"); + QDRService.management.topology.fetchEntities( + d.key, + [{ entity: "router.link", attrs: attrs }], + function(results) { + let links = results[d.key]["router.link"]; for (let i = 0; i < d.normals.length; i++) { let n = d.normals[i]; let conn = {}; infoPerId[n.container] = conn; conn.container = n.container; - conn.encrypted = n.encrypted ? 'True' : 'False'; + conn.encrypted = n.encrypted ? "True" : "False"; conn.host = n.host; //conn.links = []; conn.sizes = {}; - conn.links = utils.flattenAll(links, function (link) { + conn.links = utils.flattenAll(links, function(link) { + $scope.fields.linkFields.cols.forEach(function(col) { + if ($scope.fields.linkFields.calc[col]) { + link[col] = $scope.fields.linkFields.calc[col](link); + } + }); if (link.connectionId === n.connectionId) { link.owningAddr = utils.addr_text(link.owningAddr); - updateSizes($scope.fields.linkFields.cols, conn.sizes, link); + link.addr = link.owningAddr; + updateSizes( + $scope.fields.linkFields.cols, + conn.sizes, + link + ); return link; } else { return null; @@ -230,34 +291,43 @@ export class DetailDialogController { }); conn.linkCount = conn.links.length; } - let dir = d.cdir === 'in' ? 'inbound' : d.cdir === 'both' ? 'in and outbound' : 'outbound'; + let dir = + d.cdir === "in" + ? "inbound" + : d.cdir === "both" + ? "in and outbound" + : "outbound"; let count = d.normals.length; - let verb = count > 1 ? 'are' : 'is'; - let preposition = d.cdir === 'in' ? 'to' : d.cdir === 'both' ? 'for' : 'from'; - let plural = count > 1 ? 's' : ''; - $scope.detail.template = 'clients.html'; - $scope.detail.title = 'for client'; + let verb = count > 1 ? "are" : "is"; + let preposition = + d.cdir === "in" ? "to" : d.cdir === "both" ? "for" : "from"; + let plural = count > 1 ? "s" : ""; + $scope.detail.template = "clients.html"; + $scope.detail.title = "for client"; resolve({ - description: `There ${verb} ${count} ${dir} connection${plural} ${preposition} ${d.routerId} with role ${d.nodeType}`, + description: `There ${verb} ${count} ${dir} connection${plural} ${preposition} ${ + d.routerId + } with role ${d.nodeType}`, infoPerId: infoPerId }); - }); + } + ); } - })); + }); }; let dStart = 0; let dStop = Math.min(d.normals.length, 10); let cachedInfo = []; let updateTimer; - let doUpdateDetail = function () { + let doUpdateDetail = function() { cachedInfo = []; updateDetail.call(this); }; - let updateDetail = function () { - groupDetail.call(this) - .then(function (det) { - Object.keys(det.infoPerId).forEach(function (id) { + let updateDetail = function() { + groupDetail.call(this).then( + function(det) { + Object.keys(det.infoPerId).forEach(function(id) { cachedInfo.push(det.infoPerId[id]); }); if (dStop < d.normals.length) { @@ -265,40 +335,50 @@ export class DetailDialogController { dStop = Math.min(d.normals.length, dStart + 10); setTimeout(updateDetail.bind(this), 1); } else { - $timeout(function () { - $scope.detail.title = `for ${d.normals.length} ${$scope.detail.title}${d.normals.length > 1 ? 's' : ''}`; - $scope.detail.description = det.description; - $scope.detail.infoPerId = cachedInfo.sort(function (a, b) { - return a.name > b.name ? 1 : -1; - }); - dStart = 0; - dStop = Math.min(d.normals.length, 10); - updateTimer = setTimeout(doUpdateDetail.bind(this), 2000); - }.bind(this)); + $timeout( + function() { + $scope.detail.title = `for ${d.normals.length} ${ + $scope.detail.title + }${d.normals.length > 1 ? "s" : ""}`; + $scope.detail.description = det.description; + $scope.detail.infoPerId = cachedInfo.sort(function(a, b) { + return a.name > b.name ? 1 : -1; + }); + dStart = 0; + dStop = Math.min(d.normals.length, 10); + updateTimer = setTimeout(doUpdateDetail.bind(this), 2000); + }.bind(this) + ); } - }.bind(this)); + }.bind(this) + ); }; doUpdateDetail.call(this); } } -DetailDialogController.$inject = ['QDRService', '$scope', '$timeout', '$uibModalInstance', 'd']; +DetailDialogController.$inject = [ + "QDRService", + "$scope", + "$timeout", + "$uibModalInstance", + "d" +]; // SubTable directive export class SubTable { constructor() { - this.restrict = 'E'; + this.restrict = "E"; this.scope = { - sizes: '=sizes', - cols: '=cols', - rows: '=rows' + sizes: "=sizes", + cols: "=cols", + rows: "=rows" }; - this.templateUrl = 'sub-table.html'; + this.templateUrl = "sub-table.html"; } link(scope) { - scope.fieldWidth = function (val, sizes) { - if (!sizes) - return '10%'; - return `${Math.round(sizes[val] * 100 / sizes.total)}%`; + scope.fieldWidth = function(val, sizes) { + if (!sizes) return "10%"; + return `${Math.round((sizes[val] * 100) / sizes.total)}%`; }; } static create() { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org