Skip to content

Commit

Permalink
Add status code text to webui bar chart tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
wader authored and traefiker committed Jan 25, 2018
1 parent b50aebd commit fa1f4f7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions webui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"angular-ui-router": "^0.3.1",
"animate.css": "^3.4.0",
"bootstrap": "^3.3.6",
"http-status-codes": "^1.3.0",
"moment": "^2.14.1",
"nvd3": "^1.8.4"
},
Expand Down
19 changes: 17 additions & 2 deletions webui/src/app/sections/health/health.controller.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';
var d3 = require('d3'),
moment = require('moment');
moment = require('moment'),
HttpStatus = require('http-status-codes');

/** @ngInject */
function HealthController($scope, $interval, $log, Health) {
Expand All @@ -15,6 +16,12 @@ function HealthController($scope, $interval, $log, Health) {
vm.graph.totalStatusCodeCount.options = {
"chart": {
type: 'discreteBarChart',
tooltip: {
contentGenerator: function (e) {
var d = e.data;
return d.label + " " + d.text;
}
},
height: 200,
margin: {
top: 20,
Expand Down Expand Up @@ -69,9 +76,17 @@ function HealthController($scope, $interval, $log, Health) {
vm.graph.totalStatusCodeCount.data[0].values = [];
for (var code in totalStatusCodeCount) {
if (totalStatusCodeCount.hasOwnProperty(code)) {
var statusCodeText = "";
try {
statusCodeText = HttpStatus.getStatusText(code);
} catch (e) {
// HttpStatus.getStatusText throws error on unknown codes
statusCodeText = "Unknown status code";
}
vm.graph.totalStatusCodeCount.data[0].values.push({
label: code,
value: totalStatusCodeCount[code]
value: totalStatusCodeCount[code],
text: statusCodeText
});
}
}
Expand Down
4 changes: 4 additions & 0 deletions webui/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3073,6 +3073,10 @@ http-signature@~1.1.0:
jsprim "^1.2.2"
sshpk "^1.7.0"

http-status-codes@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/http-status-codes/-/http-status-codes-1.3.0.tgz#9cd0e71391773d0671b489d41cbc5094aa4163b6"

https-browserify@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-0.0.1.tgz#3f91365cabe60b77ed0ebba24b454e3e09d95a82"
Expand Down

0 comments on commit fa1f4f7

Please sign in to comment.