From 062d35db7db04251d37301a210fd781dc2b76ab2 Mon Sep 17 00:00:00 2001 From: Risha Mars Date: Wed, 22 Aug 2018 10:43:27 -0700 Subject: [PATCH] Start tweaking the look and feel of the Octopus graph (#1501) Do a little more work to get the octopus graph closer to the mocks. This version gives you a slightly better navigational sense of where you are in the app, and gives you a clearer view of the neighbouring stats --- web/app/css/octopus.css | 61 +++++++------ web/app/js/components/Octopus.jsx | 106 +++++++++++------------ web/app/js/components/ResourceDetail.jsx | 10 ++- 3 files changed, 93 insertions(+), 84 deletions(-) diff --git a/web/app/css/octopus.css b/web/app/css/octopus.css index 321270f2c..e2a7421b2 100644 --- a/web/app/css/octopus.css +++ b/web/app/css/octopus.css @@ -1,40 +1,51 @@ @import 'styles.css'; .octopus-container { - padding: 80px; + padding: calc(var(--base-width) * 4); } .octopus-graph { - background-color: #ffffff; - height: 100%; - width: 600px; - margin-left: auto; - margin-right: auto; - padding: 24px; - box-shadow: 2px 2px 2px var(--neutralgrey); - - & .octopus-title, & .octopus-metric { - text-align: center; + & .octopus-body { + background-color: white; + margin-bottom: calc(var(--base-width) * 3); + box-shadow: 2px 2px 2px var(--neutralgrey); } - & .octopus-upstreams .neighbor, & .octopus-downstreams .neighbor { - clear: both; + & .octopus-col { + text-align: center; + } + & .resource-col { + background-color: #FAFAFA; + padding: 32px; + } - & .status-dot { - margin: 4px 4px 0 4px; + & .octopus-title { + padding: 8px 0; + + &.main { + font-size: 24px; + font-weight: var(--font-weight-extra-bold); + } + &.neighbor { + font-size: 16px; + font-weight: var(--font-weight-bold); } } - & .octopus-upstreams .neighbor > div div { - float: left; - } + & .octopus-metric { + line-height: 32px; - & .octopus-downstreams .neighbor > div div { - float: right; + &.status-good { + color: var(--green); + } + &.status-poor { + color: var(--siennared); + } + &.status-neutral { + color: #E0E0E0; + } + &.status-ok { + color: #FF8C00; + } } } - -.octopus-metric-lg { - text-align: center; - line-height: 32px; -} diff --git a/web/app/js/components/Octopus.jsx b/web/app/js/components/Octopus.jsx index 161f45f26..cb4e4bac2 100644 --- a/web/app/js/components/Octopus.jsx +++ b/web/app/js/components/Octopus.jsx @@ -1,95 +1,89 @@ import _ from 'lodash'; import PropTypes from 'prop-types'; import React from 'react'; -import { Col, Popover, Row } from 'antd'; +import { Col, Icon, Row } from 'antd'; import { metricToFormatter, toShortResourceName } from './util/Utils.js'; import './../../css/octopus.css'; const displayName = resource => `${toShortResourceName(resource.type)}/${resource.name}`; -const getDotClassification = sr => { +const getSrClassification = sr => { if (sr < 0.9) { - return "status-dot-poor"; + return "status-poor"; } else if (sr < 0.95) { - return "status-dot-ok"; - } else {return "status-dot-good";} + return "status-ok"; + } else {return "status-good";} }; -const Neighbor = ({neighbor, direction}) => { +const Metric = ({title, value, className}) => { return ( -
- } - placement={direction ==="in" ? "left" : "right"}> -
-
{direction === "in" ? "<" : ">"}
-
-
{displayName(neighbor)}
-
- -
- ); -}; -Neighbor.propTypes = { - direction: PropTypes.string.isRequired, - neighbor: PropTypes.shape({}).isRequired -}; - -const Metric = ({title, value, metricClass}) => { - return ( - +
{title}
{value}
); }; +Metric.defaultProps = { className: "" }; Metric.propTypes = { - metricClass: PropTypes.string.isRequired, + className: PropTypes.string, title: PropTypes.string.isRequired, value: PropTypes.string.isRequired }; -const MetricSummaryRow = ({resource, metricClass}) => { - return ( - - - - - - ); -}; -MetricSummaryRow.propTypes = { - metricClass: PropTypes.string.isRequired, - resource: PropTypes.shape({}).isRequired -}; - +const ArrowCol = ({showArrow}) => {!showArrow ? " " : }; +ArrowCol.propTypes = PropTypes.bool.isRequired; export default class Octopus extends React.Component { static defaultProps = { - metrics: {}, - neighbors: {} + neighbors: {}, + resource: {} } + static propTypes = { - metrics: PropTypes.shape({}), neighbors: PropTypes.shape({}), - resource: PropTypes.shape({}).isRequired + resource: PropTypes.shape({}) + } + + renderResourceSummary(resource, cn) { + return ( +
+
+ + {displayName(resource)} + +
+ + + +
+ ); } render() { - let { resource, metrics, neighbors } = this.props; + let { resource, neighbors } = this.props; + let hasUpstreams = _.size(neighbors.upstream) > 0; + let hasDownstreams = _.size(neighbors.downstream) > 0; return (
-

{displayName(resource)}

- -
- - - {_.map(neighbors.upstream, n => )} + + + {_.map(neighbors.upstream, n => this.renderResourceSummary(n, "neighbor"))} - - {_.map(neighbors.downstream, n => )} + + + + + {this.renderResourceSummary(resource, "main")} + + + + + + {_.map(neighbors.downstream, n => this.renderResourceSummary(n, "neighbor"))}
diff --git a/web/app/js/components/ResourceDetail.jsx b/web/app/js/components/ResourceDetail.jsx index fc49bb4ef..b81ff5c92 100644 --- a/web/app/js/components/ResourceDetail.jsx +++ b/web/app/js/components/ResourceDetail.jsx @@ -54,6 +54,10 @@ export class ResourceDetailBase extends React.Component { pollingInterval: 2000, resourceMetrics: [], podMetrics: [], // metrics for all pods whose owner is this resource + neighborMetrics: { + upstream: {}, + downstream: {} + }, pendingRequests: false, loaded: false, error: null @@ -170,9 +174,9 @@ export class ResourceDetailBase extends React.Component {
+ resource={this.state.resourceMetrics[0]} + neighbors={this.state.neighborMetrics} + api={this.api} />
{ _.isEmpty(this.state.neighborMetrics.upstream) ? null : (