Browse Source

console logs and code layout

Peter Holmberg 7 năm trước cách đây
mục cha
commit
efb71d1026

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

@@ -33,6 +33,7 @@ export default class Thresholds extends PureComponent<PanelOptionsProps<OptionsP
       return threshold;
       return threshold;
     });
     });
 
 
+    // Setting value to a value between the new threshold.
     const value = newThresholds[index].value - (newThresholds[index].value - newThresholds[index - 1].value) / 2;
     const value = newThresholds[index].value - (newThresholds[index].value - newThresholds[index - 1].value) / 2;
 
 
     this.setState(
     this.setState(
@@ -57,12 +58,12 @@ export default class Thresholds extends PureComponent<PanelOptionsProps<OptionsP
   onChangeThresholdValue = (event, threshold) => {
   onChangeThresholdValue = (event, threshold) => {
     const { thresholds } = this.state;
     const { thresholds } = this.state;
 
 
-    const newThresholds = thresholds.map(currentThreshold => {
-      if (currentThreshold === threshold) {
-        currentThreshold = { ...currentThreshold, value: event.target.value };
+    const newThresholds = thresholds.map(t => {
+      if (t === threshold) {
+        t = { ...t, value: event.target.value };
       }
       }
 
 
-      return currentThreshold;
+      return t;
     });
     });
 
 
     this.setState({
     this.setState({
@@ -73,12 +74,12 @@ export default class Thresholds extends PureComponent<PanelOptionsProps<OptionsP
   onChangeThresholdColor = (threshold, color) => {
   onChangeThresholdColor = (threshold, color) => {
     const { thresholds } = this.state;
     const { thresholds } = this.state;
 
 
-    const newThresholds = thresholds.map(currentThreshold => {
-      if (currentThreshold === threshold) {
-        currentThreshold = { ...currentThreshold, color: color };
+    const newThresholds = thresholds.map(t => {
+      if (t === threshold) {
+        t = { ...t, color: color };
       }
       }
 
 
-      return currentThreshold;
+      return t;
     });
     });
 
 
     this.setState(
     this.setState(
@@ -112,11 +113,9 @@ export default class Thresholds extends PureComponent<PanelOptionsProps<OptionsP
 
 
     if (index === 0) {
     if (index === 0) {
       return thresholds[0].color;
       return thresholds[0].color;
-    } else if (index < thresholds.length) {
-      return thresholds[index].color;
     }
     }
 
 
-    return 'rgb(212, 74, 58)';
+    return index < thresholds.length ? thresholds[index].color : 'rgb(212, 74, 58)';
   }
   }
 
 
   renderNoThresholds() {
   renderNoThresholds() {

+ 0 - 3
public/app/viz/Gauge.tsx

@@ -41,7 +41,6 @@ export class Gauge extends PureComponent<Props> {
   }
   }
 
 
   componentDidUpdate(prevProps: Props) {
   componentDidUpdate(prevProps: Props) {
-    console.log('did update');
     this.draw();
     this.draw();
   }
   }
 
 
@@ -82,8 +81,6 @@ export class Gauge extends PureComponent<Props> {
       };
       };
     });
     });
 
 
-    console.log(formattedThresholds);
-
     const options = {
     const options = {
       series: {
       series: {
         gauges: {
         gauges: {