فهرست منبع

moving min/max to gauge options

Peter Holmberg 7 سال پیش
والد
کامیت
8615de8119
2فایلهای تغییر یافته به همراه25 افزوده شده و 14 حذف شده
  1. 17 4
      public/app/plugins/panel/gauge/GaugeOptions.tsx
  2. 8 10
      public/app/plugins/panel/gauge/Thresholds.tsx

+ 17 - 4
public/app/plugins/panel/gauge/GaugeOptions.tsx

@@ -1,14 +1,19 @@
 import React, { PureComponent } from 'react';
 import React, { PureComponent } from 'react';
 import { Switch } from 'app/core/components/Switch/Switch';
 import { Switch } from 'app/core/components/Switch/Switch';
 import { OptionModuleProps } from './module';
 import { OptionModuleProps } from './module';
+import { Label } from '../../../core/components/Label/Label';
 
 
 export default class GaugeOptions extends PureComponent<OptionModuleProps> {
 export default class GaugeOptions extends PureComponent<OptionModuleProps> {
-  toggleThresholdLabels = () =>
+  onToggleThresholdLabels = () =>
     this.props.onChange({ ...this.props.options, showThresholdLabels: !this.props.options.showThresholdLabels });
     this.props.onChange({ ...this.props.options, showThresholdLabels: !this.props.options.showThresholdLabels });
 
 
-  toggleThresholdMarkers = () =>
+  onToggleThresholdMarkers = () =>
     this.props.onChange({ ...this.props.options, showThresholdMarkers: !this.props.options.showThresholdMarkers });
     this.props.onChange({ ...this.props.options, showThresholdMarkers: !this.props.options.showThresholdMarkers });
 
 
+  onMinValueChange = ({ target }) => this.props.onChange({ ...this.props.options, minValue: target.value });
+
+  onMaxValueChange = ({ target }) => this.props.onChange({ ...this.props.options, maxValue: target.value });
+
   render() {
   render() {
     const { showThresholdLabels, showThresholdMarkers } = this.props.options;
     const { showThresholdLabels, showThresholdMarkers } = this.props.options;
 
 
@@ -20,7 +25,7 @@ export default class GaugeOptions extends PureComponent<OptionModuleProps> {
             label="Threshold labels"
             label="Threshold labels"
             labelClass="width-10"
             labelClass="width-10"
             checked={showThresholdLabels}
             checked={showThresholdLabels}
-            onChange={this.toggleThresholdLabels}
+            onChange={this.onToggleThresholdLabels}
           />
           />
         </div>
         </div>
         <div className="gf-form-inline">
         <div className="gf-form-inline">
@@ -28,9 +33,17 @@ export default class GaugeOptions extends PureComponent<OptionModuleProps> {
             label="Threshold markers"
             label="Threshold markers"
             labelClass="width-10"
             labelClass="width-10"
             checked={showThresholdMarkers}
             checked={showThresholdMarkers}
-            onChange={this.toggleThresholdMarkers}
+            onChange={this.onToggleThresholdMarkers}
           />
           />
         </div>
         </div>
+        <div className="gf-form-inline">
+          <Label width={6}>Min value</Label>
+          <input type="text" className="gf-form-input width-12" onChange={this.onMinValueChange} />
+        </div>
+        <div className="gf-form-inline">
+          <Label width={6}>Max value</Label>
+          <input type="text" className="gf-form-input width-12" onChange={this.onMaxValueChange} />
+        </div>
       </div>
       </div>
     );
     );
   }
   }

+ 8 - 10
public/app/plugins/panel/gauge/Thresholds.tsx

@@ -169,22 +169,20 @@ export default class Thresholds extends PureComponent<OptionModuleProps, State>
       const rowStyle = classNames({
       const rowStyle = classNames({
         'threshold-row': true,
         'threshold-row': true,
         'threshold-row-min': index === 0,
         'threshold-row-min': index === 0,
-        'threshold-row-max': index === thresholds.length - 1,
       });
       });
 
 
       return (
       return (
         <div className={rowStyle} key={`${threshold.index}-${index}`}>
         <div className={rowStyle} key={`${threshold.index}-${index}`}>
           <div className="threshold-row-inner">
           <div className="threshold-row-inner">
             <div className="threshold-row-color">
             <div className="threshold-row-color">
-              {threshold.color &&
-                index !== thresholds.length - 1 && (
-                  <div className="threshold-row-color-inner">
-                    <ColorPicker
-                      color={threshold.color}
-                      onChange={color => this.onChangeThresholdColor(threshold, color)}
-                    />
-                  </div>
-                )}
+              {threshold.color && (
+                <div className="threshold-row-color-inner">
+                  <ColorPicker
+                    color={threshold.color}
+                    onChange={color => this.onChangeThresholdColor(threshold, color)}
+                  />
+                </div>
+              )}
             </div>
             </div>
             <input
             <input
               className="threshold-row-input"
               className="threshold-row-input"