Skip to content

Commit

Permalink
Merge pull request #642 from weaveworks/controls-bar
Browse files Browse the repository at this point in the history
Control bar below node details header
  • Loading branch information
davkal committed Nov 9, 2015
2 parents 89c4eb1 + 17f31cd commit 2dcc085
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 20 deletions.
16 changes: 12 additions & 4 deletions client/app/scripts/components/node-details-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,25 @@ const NodeControlButton = require('./node-control-button');
const NodeDetailsControls = React.createClass({

render: function() {
let spinnerClassName = 'fa fa-circle-o-notch fa-spin';
if (this.props.pending) {
spinnerClassName += ' node-details-controls-spinner';
} else {
spinnerClassName += ' node-details-controls-spinner hide';
}

return (
<div className="node-details-controls">
{this.props.error && <div className="node-details-controls-error" title={this.props.error}>
<span className="node-details-controls-error-icon fa fa-warning" />
<span className="node-details-controls-error-messages">{this.props.error}</span>
</div>}
{this.props.controls && this.props.controls.map(control => {
return (
<NodeControlButton control={control} pending={this.props.pending} />
);
})}
{this.props.controls && <span title="Applying..." className={spinnerClassName}></span>}
{this.props.error && <div className="node-details-controls-error" title={this.props.error}>
<span className="node-details-controls-error-icon fa fa-warning" />
<span className="node-details-controls-error-messages">{this.props.error}</span>
</div>}
</div>
);
}
Expand Down
19 changes: 14 additions & 5 deletions client/app/scripts/components/node-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,19 @@ const NodeDetails = React.createClass({
return this.renderLoading();
}

const style = {
'backgroundColor': this.getNodeColorDark(details.label_major)
const nodeColor = this.getNodeColorDark(details.label_major);
const styles = {
controls: {
'backgroundColor': this.brightenColor(nodeColor)
},
header: {
'backgroundColor': nodeColor
}
};

return (
<div className="node-details">
<div className="node-details-header" style={style}>
<NodeDetailsControls controls={details.controls}
pending={this.props.controlPending} error={this.props.controlError} />
<div className="node-details-header" style={styles.header}>
<h2 className="node-details-header-label truncate" title={details.label_major}>
{details.label_major}
</h2>
Expand All @@ -76,6 +80,11 @@ const NodeDetails = React.createClass({
</div>
</div>

{details.controls && details.controls.length > 0 && <div className="node-details-controls-wrapper" style={styles.controls}>
<NodeDetailsControls controls={details.controls}
pending={this.props.controlPending} error={this.props.controlError} />
</div>}

<div className="node-details-content">
{details.tables.map(function(table) {
const key = _.snakeCase(table.title);
Expand Down
17 changes: 14 additions & 3 deletions client/app/scripts/mixins/node-color-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,21 @@ const NodeColorMixin = {
let hsl = color.hsl();

// ensure darkness
// if (hsl.l > 0.5) {
hsl = hsl.darker();
// }
if (hsl.l > 0.7) {
hsl = hsl.darker(1.5);
} else {
hsl = hsl.darker(1);
}

return hsl.toString();
},
brightenColor: function(color) {
let hsl = d3.rgb(color).hsl();
if (hsl.l > 0.5) {
hsl = hsl.brighter(0.5);
} else {
hsl = hsl.brighter(0.8);
}
return hsl.toString();
}
};
Expand Down
24 changes: 16 additions & 8 deletions client/app/styles/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,12 @@ h2 {
height: 100%;
width: 100%;
background-color: rgba(255, 255, 255, 0.86);
display: flex;
flex-flow: column;

&-header {

padding: 24px 36px 24px 36px;
padding: 24px 36px 16px 36px;

&-row {
display: flex;
Expand Down Expand Up @@ -360,8 +362,10 @@ h2 {

&-controls {
white-space: nowrap;
text-align: right;
margin: -8px -8px 0 0;

&-wrapper {
padding: 8px 36px 8px 32px;
}

.node-control-button {
.palable;
Expand All @@ -384,10 +388,16 @@ h2 {
}
}

&-spinner {
.hideable;
color: @white;
margin-left: 8px;
}

&-error {
.truncate;
float: left;
width: 66%;
float: right;
width: 55%;
padding-top: 6px;
text-align: left;
color: @white;
Expand All @@ -400,9 +410,7 @@ h2 {
}

&-content {
position: absolute;
top: 128px;
bottom: 0;
flex: 1;
padding: 0 36px 0 36px;
overflow-y: scroll;
width: 100%;
Expand Down

0 comments on commit 2dcc085

Please sign in to comment.